From 7dc3e45101b6efe87ba62e01354a66959aba1361 Mon Sep 17 00:00:00 2001 From: Matteo Figus Date: Mon, 16 Feb 2015 15:37:59 +0000 Subject: [PATCH 1/4] ie8 failover div rendering --- Gruntfile.js | 8 +- client/index.js | 16 +- .../oc-client/_package/src/head.load.js | 707 ++++++++++++++++++ .../oc-client/_package/src/oc-client.js | 307 ++++---- .../oc-client/_package/src/oc-client.min.js | 2 +- components/oc-client/src/head.load.js | 707 ++++++++++++++++++ components/oc-client/src/oc-client.js | 307 ++++---- components/oc-client/src/oc-client.min.js | 2 +- grunt-tasks/jshint.js | 2 +- test/acceptance/client.js | 37 +- 10 files changed, 1782 insertions(+), 313 deletions(-) create mode 100644 components/oc-client/_package/src/head.load.js create mode 100644 components/oc-client/src/head.load.js diff --git a/Gruntfile.js b/Gruntfile.js index 6d00ac654..6246fe3c1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -28,9 +28,6 @@ module.exports = function(grunt) { // default task grunt.registerTask('default', ['test', 'build']); - // build task - grunt.registerTask('build', ['build-web-client']); - // Setup the precommit hook grunt.registerTask('hooks', ['githooks:all']); @@ -38,13 +35,14 @@ module.exports = function(grunt) { grunt.registerTask('test', ['jshint:all', 'mochaTest:unit', 'mochaTest:acceptance']); // custom tasks - grunt.registerTask('build-web-client', 'Builds and minifies the web-client.js', function(){ + grunt.registerTask('build', 'Builds and minifies the oc-client component', function(){ var done = this.async(), handlebarsRuntime = fs.readFileSync(path.join(__dirname, 'node_modules/handlebars/dist/handlebars.runtime.min.js')).toString(), jadeRuntime = fs.readFileSync(path.join(__dirname, 'node_modules/jade/runtime.js')).toString(), + headLoad = fs.readFileSync(path.join(__dirname, 'components/oc-client/src/head.load.js')).toString(), ocClient = fs.readFileSync(path.join(__dirname, 'components/oc-client/src/oc-client.js')).toString(), - bundle = format('{0}\n;\n{1}\n;\n{2}\n;\noc.clientVersion=\'{3}\';', jadeRuntime, handlebarsRuntime, ocClient, taskObject.pkg.version), + bundle = format('{0}\n;\n{1}\n;\n{2}\n;\n{3}\n;\noc.clientVersion=\'{4}\';', jadeRuntime, handlebarsRuntime, headLoad, ocClient, taskObject.pkg.version), ocClientPackageInfo = require('./components/oc-client/package.json'); ocClientPackageInfo.version = taskObject.pkg.version; diff --git a/client/index.js b/client/index.js index 4eaebbdc2..6366ca562 100644 --- a/client/index.js +++ b/client/index.js @@ -114,7 +114,7 @@ var Client = function(conf){ } fs.readFile(path.resolve(__dirname, '../components/oc-client/src/oc-client.min.js'), 'utf-8', function(err, clientJs){ - var clientSideHtml = format('{1}', clientJs, self.getUnrenderedComponent(href)); + var clientSideHtml = format('{1}', clientJs, self.getUnrenderedComponent(href, options)); return callback(errorDescription, clientSideHtml); }); @@ -126,7 +126,7 @@ var Client = function(conf){ local = isLocal(apiResponse); if(options.render === 'client'){ - return callback(null, self.getUnrenderedComponent(href)); + return callback(null, self.getUnrenderedComponent(href, options)); } self.getStaticTemplate(apiResponse.template.src, !local, function(templateText){ @@ -150,8 +150,16 @@ var Client = function(conf){ }); }; - this.getUnrenderedComponent = function(href){ - return format('', href); + this.getUnrenderedComponent = function(href, options){ + + if(!options || !options.ie8){ + return format('', href); + } + + return format('', href); }; this.getRenderedComponent = function(data){ diff --git a/components/oc-client/_package/src/head.load.js b/components/oc-client/_package/src/head.load.js new file mode 100644 index 000000000..b7a31c778 --- /dev/null +++ b/components/oc-client/_package/src/head.load.js @@ -0,0 +1,707 @@ +///#source 1 1 /src/1.0.0/load.js +/*! head.load - v1.0.3 */ +/* + * HeadJS The only script in your + * Author Tero Piirainen (tipiirai) + * Maintainer Robert Hoffmann (itechnology) + * License MIT / http://bit.ly/mit-license + * WebSite http://headjs.com + */ +(function (win, undefined) { + "use strict"; + + //#region variables + var doc = win.document, + domWaiters = [], + handlers = {}, // user functions waiting for events + assets = {}, // loadable items in various states + isAsync = "async" in doc.createElement("script") || "MozAppearance" in doc.documentElement.style || win.opera, + isDomReady, + + /*** public API ***/ + headVar = win.head_conf && win.head_conf.head || "head", + api = win[headVar] = (win[headVar] || function () { api.ready.apply(null, arguments); }), + + // states + PRELOADING = 1, + PRELOADED = 2, + LOADING = 3, + LOADED = 4; + //#endregion + + //#region PRIVATE functions + + //#region Helper functions + function noop() { + // does nothing + } + + function each(arr, callback) { + if (!arr) { + return; + } + + // arguments special type + if (typeof arr === "object") { + arr = [].slice.call(arr); + } + + // do the job + for (var i = 0, l = arr.length; i < l; i++) { + callback.call(arr, arr[i], i); + } + } + + /* A must read: http://bonsaiden.github.com/JavaScript-Garden + ************************************************************/ + function is(type, obj) { + var clas = Object.prototype.toString.call(obj).slice(8, -1); + return obj !== undefined && obj !== null && clas === type; + } + + function isFunction(item) { + return is("Function", item); + } + + function isArray(item) { + return is("Array", item); + } + + function toLabel(url) { + ///Converts a url to a file label + var items = url.split("/"), + name = items[items.length - 1], + i = name.indexOf("?"); + + return i !== -1 ? name.substring(0, i) : name; + } + + // INFO: this look like a "im triggering callbacks all over the place, but only wanna run it one time function" ..should try to make everything work without it if possible + // INFO: Even better. Look into promises/defered's like jQuery is doing + function one(callback) { + ///Execute a callback only once + callback = callback || noop; + + if (callback._done) { + return; + } + + callback(); + callback._done = 1; + } + //#endregion + + function conditional(test, success, failure, callback) { + /// + /// INFO: use cases: + /// head.test(condition, null , "file.NOk" , callback); + /// head.test(condition, "fileOk.js", null , callback); + /// head.test(condition, "fileOk.js", "file.NOk" , callback); + /// head.test(condition, "fileOk.js", ["file.NOk", "file.NOk"], callback); + /// head.test({ + /// test : condition, + /// success : [{ label1: "file1Ok.js" }, { label2: "file2Ok.js" }], + /// failure : [{ label1: "file1NOk.js" }, { label2: "file2NOk.js" }], + /// callback: callback + /// ); + /// head.test({ + /// test : condition, + /// success : ["file1Ok.js" , "file2Ok.js"], + /// failure : ["file1NOk.js", "file2NOk.js"], + /// callback: callback + /// ); + /// + var obj = (typeof test === "object") ? test : { + test: test, + success: !!success ? isArray(success) ? success : [success] : false, + failure: !!failure ? isArray(failure) ? failure : [failure] : false, + callback: callback || noop + }; + + // Test Passed ? + var passed = !!obj.test; + + // Do we have a success case + if (passed && !!obj.success) { + obj.success.push(obj.callback); + api.load.apply(null, obj.success); + } + // Do we have a fail case + else if (!passed && !!obj.failure) { + obj.failure.push(obj.callback); + api.load.apply(null, obj.failure); + } + else { + callback(); + } + + return api; + } + + function getAsset(item) { + /// + /// Assets are in the form of + /// { + /// name : label, + /// url : url, + /// state: state + /// } + /// + var asset = {}; + + if (typeof item === "object") { + for (var label in item) { + if (!!item[label]) { + asset = { + name: label, + url : item[label] + }; + } + } + } + else { + asset = { + name: toLabel(item), + url : item + }; + } + + // is the item already existant + var existing = assets[asset.name]; + if (existing && existing.url === asset.url) { + return existing; + } + + assets[asset.name] = asset; + return asset; + } + + function allLoaded(items) { + items = items || assets; + + for (var name in items) { + if (items.hasOwnProperty(name) && items[name].state !== LOADED) { + return false; + } + } + + return true; + } + + function onPreload(asset) { + asset.state = PRELOADED; + + each(asset.onpreload, function (afterPreload) { + afterPreload.call(); + }); + } + + function preLoad(asset, callback) { + if (asset.state === undefined) { + + asset.state = PRELOADING; + asset.onpreload = []; + + loadAsset({ url: asset.url, type: "cache" }, function () { + onPreload(asset); + }); + } + } + + function apiLoadHack() { + /// preload with text/cache hack + /// + /// head.load("http://domain.com/file.js","http://domain.com/file.js", callBack) + /// head.load(["http://domain.com/file.js","http://domain.com/file.js"], callBack) + /// head.load({ label1: "http://domain.com/file.js" }, { label2: "http://domain.com/file.js" }, callBack) + /// head.load([{ label1: "http://domain.com/file.js" }, { label2: "http://domain.com/file.js" }], callBack) + /// + var args = arguments, + callback = args[args.length - 1], + rest = [].slice.call(args, 1), + next = rest[0]; + + if (!isFunction(callback)) { + callback = null; + } + + // if array, repush as args + if (isArray(args[0])) { + args[0].push(callback); + api.load.apply(null, args[0]); + + return api; + } + + // multiple arguments + if (!!next) { + /* Preload with text/cache hack (not good!) + * http://blog.getify.com/on-script-loaders/ + * http://www.nczonline.net/blog/2010/12/21/thoughts-on-script-loaders/ + * If caching is not configured correctly on the server, then items could load twice ! + *************************************************************************************/ + each(rest, function (item) { + // item is not a callback or empty string + if (!isFunction(item) && !!item) { + preLoad(getAsset(item)); + } + }); + + // execute + load(getAsset(args[0]), isFunction(next) ? next : function () { + api.load.apply(null, rest); + }); + } + else { + // single item + load(getAsset(args[0])); + } + + return api; + } + + function apiLoadAsync() { + /// + /// simply load and let browser take care of ordering + /// + /// head.load("http://domain.com/file.js","http://domain.com/file.js", callBack) + /// head.load(["http://domain.com/file.js","http://domain.com/file.js"], callBack) + /// head.load({ label1: "http://domain.com/file.js" }, { label2: "http://domain.com/file.js" }, callBack) + /// head.load([{ label1: "http://domain.com/file.js" }, { label2: "http://domain.com/file.js" }], callBack) + /// + var args = arguments, + callback = args[args.length - 1], + items = {}; + + if (!isFunction(callback)) { + callback = null; + } + + // if array, repush as args + if (isArray(args[0])) { + args[0].push(callback); + api.load.apply(null, args[0]); + + return api; + } + + // JRH 262#issuecomment-26288601 + // First populate the items array. + // When allLoaded is called, all items will be populated. + // Issue when lazy loaded, the callback can execute early. + each(args, function (item, i) { + if (item !== callback) { + item = getAsset(item); + items[item.name] = item; + } + }); + + each(args, function (item, i) { + if (item !== callback) { + item = getAsset(item); + + load(item, function () { + if (allLoaded(items)) { + one(callback); + } + }); + } + }); + + return api; + } + + function load(asset, callback) { + ///Used with normal loading logic + callback = callback || noop; + + if (asset.state === LOADED) { + callback(); + return; + } + + // INFO: why would we trigger a ready event when its not really loaded yet ? + if (asset.state === LOADING) { + api.ready(asset.name, callback); + return; + } + + if (asset.state === PRELOADING) { + asset.onpreload.push(function () { + load(asset, callback); + }); + return; + } + + asset.state = LOADING; + + loadAsset(asset, function () { + asset.state = LOADED; + + callback(); + + // handlers for this asset + each(handlers[asset.name], function (fn) { + one(fn); + }); + + // dom is ready & no assets are queued for loading + // INFO: shouldn't we be doing the same test above ? + if (isDomReady && allLoaded()) { + each(handlers.ALL, function (fn) { + one(fn); + }); + } + }); + } + + function getExtension(url) { + url = url || ""; + + var items = url.split("?")[0].split("."); + return items[items.length-1].toLowerCase(); + } + + /* Parts inspired from: https://github.com/cujojs/curl + ******************************************************/ + function loadAsset(asset, callback) { + callback = callback || noop; + + function error(event) { + event = event || win.event; + + // release event listeners + ele.onload = ele.onreadystatechange = ele.onerror = null; + + // do callback + callback(); + + // need some more detailed error handling here + } + + function process(event) { + event = event || win.event; + + // IE 7/8 (2 events on 1st load) + // 1) event.type = readystatechange, s.readyState = loading + // 2) event.type = readystatechange, s.readyState = loaded + + // IE 7/8 (1 event on reload) + // 1) event.type = readystatechange, s.readyState = complete + + // event.type === 'readystatechange' && /loaded|complete/.test(s.readyState) + + // IE 9 (3 events on 1st load) + // 1) event.type = readystatechange, s.readyState = loading + // 2) event.type = readystatechange, s.readyState = loaded + // 3) event.type = load , s.readyState = loaded + + // IE 9 (2 events on reload) + // 1) event.type = readystatechange, s.readyState = complete + // 2) event.type = load , s.readyState = complete + + // event.type === 'load' && /loaded|complete/.test(s.readyState) + // event.type === 'readystatechange' && /loaded|complete/.test(s.readyState) + + // IE 10 (3 events on 1st load) + // 1) event.type = readystatechange, s.readyState = loading + // 2) event.type = load , s.readyState = complete + // 3) event.type = readystatechange, s.readyState = loaded + + // IE 10 (3 events on reload) + // 1) event.type = readystatechange, s.readyState = loaded + // 2) event.type = load , s.readyState = complete + // 3) event.type = readystatechange, s.readyState = complete + + // event.type === 'load' && /loaded|complete/.test(s.readyState) + // event.type === 'readystatechange' && /complete/.test(s.readyState) + + // Other Browsers (1 event on 1st load) + // 1) event.type = load, s.readyState = undefined + + // Other Browsers (1 event on reload) + // 1) event.type = load, s.readyState = undefined + + // event.type == 'load' && s.readyState = undefined + + // !doc.documentMode is for IE6/7, IE8+ have documentMode + if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) { + // remove timeouts + win.clearTimeout(asset.errorTimeout); + win.clearTimeout(asset.cssTimeout); + + // release event listeners + ele.onload = ele.onreadystatechange = ele.onerror = null; + + // do callback + callback(); + } + } + + function isCssLoaded() { + // should we test again ? 20 retries = 5secs ..after that, the callback will be triggered by the error handler at 7secs + if (asset.state !== LOADED && asset.cssRetries <= 20) { + + // loop through stylesheets + for (var i = 0, l = doc.styleSheets.length; i < l; i++) { + // do we have a match ? + // we need to tests agains ele.href and not asset.url, because a local file will be assigned the full http path on a link element + if (doc.styleSheets[i].href === ele.href) { + process({ "type": "load" }); + return; + } + } + + // increment & try again + asset.cssRetries++; + asset.cssTimeout = win.setTimeout(isCssLoaded, 250); + } + } + + var ele; + var ext = getExtension(asset.url); + + if (ext === "css") { + ele = doc.createElement("link"); + ele.type = "text/" + (asset.type || "css"); + ele.rel = "stylesheet"; + ele.href = asset.url; + + /* onload supported for CSS on unsupported browsers + * Safari windows 5.1.7, FF < 10 + */ + + // Set counter to zero + asset.cssRetries = 0; + asset.cssTimeout = win.setTimeout(isCssLoaded, 500); + } + else { + ele = doc.createElement("script"); + ele.type = "text/" + (asset.type || "javascript"); + ele.src = asset.url; + } + + ele.onload = ele.onreadystatechange = process; + ele.onerror = error; + + /* Good read, but doesn't give much hope ! + * http://blog.getify.com/on-script-loaders/ + * http://www.nczonline.net/blog/2010/12/21/thoughts-on-script-loaders/ + * https://hacks.mozilla.org/2009/06/defer/ + */ + + // ASYNC: load in parallel and execute as soon as possible + ele.async = false; + // DEFER: load in parallel but maintain execution order + ele.defer = false; + + // timout for asset loading + asset.errorTimeout = win.setTimeout(function () { + error({ type: "timeout" }); + }, 7e3); + + // use insertBefore to keep IE from throwing Operation Aborted (thx Bryan Forbes!) + var head = doc.head || doc.getElementsByTagName("head")[0]; + + // but insert at end of head, because otherwise if it is a stylesheet, it will not override values + head.insertBefore(ele, head.lastChild); + } + + /* Parts inspired from: https://github.com/jrburke/requirejs + ************************************************************/ + function init() { + var items = doc.getElementsByTagName("script"); + + // look for a script with a data-head-init attribute + for (var i = 0, l = items.length; i < l; i++) { + var dataMain = items[i].getAttribute("data-headjs-load"); + if (!!dataMain) { + api.load(dataMain); + return; + } + } + } + + function ready(key, callback) { + /// + /// INFO: use cases: + /// head.ready(callBack); + /// head.ready(document , callBack); + /// head.ready("file.js", callBack); + /// head.ready("label" , callBack); + /// head.ready(["label1", "label2"], callback); + /// + + // DOM ready check: head.ready(document, function() { }); + if (key === doc) { + if (isDomReady) { + one(callback); + } + else { + domWaiters.push(callback); + } + + return api; + } + + // shift arguments + if (isFunction(key)) { + callback = key; + key = "ALL"; // holds all callbacks that where added without labels: ready(callBack) + } + + // queue all items from key and return. The callback will be executed if all items from key are already loaded. + if (isArray(key)) { + var items = {}; + + each(key, function (item) { + items[item] = assets[item]; + + api.ready(item, function() { + if (allLoaded(items)) { + one(callback); + } + }); + }); + + return api; + } + + // make sure arguments are sane + if (typeof key !== "string" || !isFunction(callback)) { + return api; + } + + // this can also be called when we trigger events based on filenames & labels + var asset = assets[key]; + + // item already loaded --> execute and return + if (asset && asset.state === LOADED || key === "ALL" && allLoaded() && isDomReady) { + one(callback); + return api; + } + + var arr = handlers[key]; + if (!arr) { + arr = handlers[key] = [callback]; + } + else { + arr.push(callback); + } + + return api; + } + + /* Mix of stuff from jQuery & IEContentLoaded + * http://dev.w3.org/html5/spec/the-end.html#the-end + ***************************************************/ + function domReady() { + // Make sure body exists, at least, in case IE gets a little overzealous (jQuery ticket #5443). + if (!doc.body) { + // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if assets are queued) + win.clearTimeout(api.readyTimeout); + api.readyTimeout = win.setTimeout(domReady, 50); + return; + } + + if (!isDomReady) { + isDomReady = true; + + init(); + each(domWaiters, function (fn) { + one(fn); + }); + } + } + + function domContentLoaded() { + // W3C + if (doc.addEventListener) { + doc.removeEventListener("DOMContentLoaded", domContentLoaded, false); + domReady(); + } + + // IE + else if (doc.readyState === "complete") { + // we're here because readyState === "complete" in oldIE + // which is good enough for us to call the dom ready! + doc.detachEvent("onreadystatechange", domContentLoaded); + domReady(); + } + } + + // Catch cases where ready() is called after the browser event has already occurred. + // we once tried to use readyState "interactive" here, but it caused issues like the one + // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 + if (doc.readyState === "complete") { + domReady(); + } + + // W3C + else if (doc.addEventListener) { + doc.addEventListener("DOMContentLoaded", domContentLoaded, false); + + // A fallback to window.onload, that will always work + win.addEventListener("load", domReady, false); + } + + // IE + else { + // Ensure firing before onload, maybe late but safe also for iframes + doc.attachEvent("onreadystatechange", domContentLoaded); + + // A fallback to window.onload, that will always work + win.attachEvent("onload", domReady); + + // If IE and not a frame + // continually check to see if the document is ready + var top = false; + + try { + top = !win.frameElement && doc.documentElement; + } catch (e) { } + + if (top && top.doScroll) { + (function doScrollCheck() { + if (!isDomReady) { + try { + // Use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + top.doScroll("left"); + } catch (error) { + // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if assets are queued) + win.clearTimeout(api.readyTimeout); + api.readyTimeout = win.setTimeout(doScrollCheck, 50); + return; + } + + // and execute any waiting functions + domReady(); + } + }()); + } + } + //#endregion + + //#region Public Exports + // INFO: determine which method to use for loading + api.load = api.js = isAsync ? apiLoadAsync : apiLoadHack; + api.test = conditional; + api.ready = ready; + //#endregion + + //#region INIT + // perform this when DOM is ready + api.ready(doc, function () { + if (allLoaded()) { + each(handlers.ALL, function (callback) { + one(callback); + }); + } + + if (api.feature) { + api.feature("domloaded", true); + } + }); + //#endregion +}(window)); \ No newline at end of file diff --git a/components/oc-client/_package/src/oc-client.js b/components/oc-client/_package/src/oc-client.js index 18c6d3020..3923f752f 100644 --- a/components/oc-client/_package/src/oc-client.js +++ b/components/oc-client/_package/src/oc-client.js @@ -2,11 +2,10 @@ var oc = oc || {}; -(function(Handlebars, $document, $window, debug){ +(function(Handlebars, head, $document, $window, debug){ // Constants - var HTML5SHIV_URL = 'https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js', - IE89_AJAX_POLYFILL_URL = 'https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js', + var IE89_AJAX_POLYFILL_URL = 'https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js', JQUERY_URL = 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js', RETRY_INTERVAL = 5000, OC_TAG = 'oc-component', @@ -22,7 +21,13 @@ var oc = oc || {}; // The code var headScripts = [], $ = typeof(jQuery) !== 'undefined' ? jQuery : undefined, - noop = function(){}; + noop = function(){}, + nav = $window.navigator.userAgent, + is8 = !!(nav.match(/MSIE 8/)), + is9 = !!(nav.match(/MSIE 9/)), + initialised = false, + initialising = false, + readySubscribers = []; var logger = { error: function(msg){ @@ -44,39 +49,6 @@ var oc = oc || {}; return -1; }; - // a minimal vanilla require.js - var _require = function(hrefs, callback){ - - var callbacks = hrefs.length, - $head = $document.getElementsByTagName('head')[0]; - - var tryExit = function(){ - callbacks--; - if(callbacks === 0 && typeof(callback) === 'function'){ - callback(); - callback = noop; - } - }; - - var appendScript = function(href){ - headScripts.push(href); - var $script = $document.createElement('script'); - - $script.type = 'text/javascript'; - $script.src = href; - $script.onload = tryExit; - $head.appendChild($script); - }; - - for(var i = 0; i < hrefs.length; i++){ - if(_indexOf(headScripts, hrefs[i]) < 0){ - appendScript(hrefs[i]); - } else { - tryExit(); - } - } - }; - var processHtml = function($component, data, callback){ var newId = Math.floor(Math.random()*9999999999); @@ -94,147 +66,182 @@ var oc = oc || {}; callback(); }; - oc.render = function(compiledView, model, callback){ - if(!oc.components[compiledView.key]){ - callback(MESSAGES_ERRORS_LOADING_COMPONENT.replace('{0}', compiledView.key)); + oc.ready = function(callback){ + + if(initialised){ + return callback(); + } else if(initialising) { + readySubscribers.push(callback); } else { - var compiledComponent = ''; - if(compiledView.type === 'handlebars'){ - var linkedComponent = Handlebars.template(oc.components[compiledView.key], []); - compiledComponent = linkedComponent(model); - } else if(compiledView.type === 'jade'){ - compiledComponent = oc.components[compiledView.key](model); + initialising = true; + + var requirePolyfills = function(cb){ + if(is8 || is9){ + head.load(IE89_AJAX_POLYFILL_URL, cb); + } else { + cb(); + } + }; + + var done = function(){ + initialised = true; + initialising = false; + callback(); + for(var i = 0; i < readySubscribers.length; i++){ + readySubscribers[i](); + } + }; + + if(!$){ + head.load(JQUERY_URL, function(){ + $ = jQuery; + requirePolyfills(done); + }); } else { - return callback(MESSAGES_ERRORS_VIEW_ENGINE_NOT_SUPPORTED.replace('{0}', compiledView.type)); + requirePolyfills(done); } - callback(null, compiledComponent); } }; - oc.renderNestedComponent = function($component, callback){ - $component.html('
' + MESSAGES_LOADING_COMPONENT + '
'); + oc.render = function(compiledView, model, callback){ + oc.ready(function(){ + if(!oc.components[compiledView.key]){ + callback(MESSAGES_ERRORS_LOADING_COMPONENT.replace('{0}', compiledView.key)); + } else { + var compiledComponent = ''; - oc.renderByHref($component.attr('href'), function(err, data){ - if(err || !data || !data.html){ - return logger.error(err); + if(compiledView.type === 'handlebars'){ + var linkedComponent = Handlebars.template(oc.components[compiledView.key], []); + compiledComponent = linkedComponent(model); + } else if(compiledView.type === 'jade'){ + compiledComponent = oc.components[compiledView.key](model); + } else { + return callback(MESSAGES_ERRORS_VIEW_ENGINE_NOT_SUPPORTED.replace('{0}', compiledView.type)); + } + callback(null, compiledComponent); } + }); + }; + + oc.renderNestedComponent = function($component, callback){ + oc.ready(function(){ + $component.html('
' + MESSAGES_LOADING_COMPONENT + '
'); + + oc.renderByHref($component.attr('href'), function(err, data){ + if(err || !data || !data.html){ + return logger.error(err); + } - processHtml($component, data, callback); + processHtml($component, data, callback); + }); }); }; oc.renderByHref = function(href, callback){ - if(href !== ''){ - $.ajax({ - url: href, - headers: { 'render-mode': 'pre-rendered' }, - crossDomain: true, - async: true, - success: function(apiResponse){ - if(apiResponse.renderMode === 'pre-rendered'){ - _require([apiResponse.template.src], function(){ - oc.render(apiResponse.template, apiResponse.data, function(err, html){ - if(err){ - return callback(MESSAGES_ERRORS_RENDERING.replace('{0}', apiResponse.href).replace('{1}', err)); - } - logger.info(MESSAGES_RENDERED.replace('{0}', apiResponse.template.src)); - callback(null, { - html: html, - key: apiResponse.template.key, - version: apiResponse.version + oc.ready(function(){ + if(href !== ''){ + $.ajax({ + url: href, + headers: { 'render-mode': 'pre-rendered' }, + crossDomain: true, + async: true, + success: function(apiResponse){ + if(apiResponse.renderMode === 'pre-rendered'){ + head.load([apiResponse.template.src], function(){ + oc.render(apiResponse.template, apiResponse.data, function(err, html){ + if(err){ + return callback(MESSAGES_ERRORS_RENDERING.replace('{0}', apiResponse.href).replace('{1}', err)); + } + logger.info(MESSAGES_RENDERED.replace('{0}', apiResponse.template.src)); + callback(null, { + html: html, + key: apiResponse.template.key, + version: apiResponse.version + }); }); }); - }); - } else if(apiResponse.renderMode === 'rendered'){ - logger.info(MESSAGES_RENDERED.replace('{0}', apiResponse.href)); - callback(null, { - html: $(apiResponse.html).html(), - version: apiResponse.version - }); + } else if(apiResponse.renderMode === 'rendered'){ + logger.info(MESSAGES_RENDERED.replace('{0}', apiResponse.href)); + + var innerHtmlPlusEnding = apiResponse.html.slice(apiResponse.html.indexOf('>') + 1), + innerHtml = innerHtmlPlusEnding.slice(0, innerHtmlPlusEnding.indexOf('<')); + + callback(null, { + html: innerHtml, + version: apiResponse.version + }); + } + }, + error: function(){ + logger.error(MESSAGES_ERRORS_RETRIEVING); + setTimeout(function() { + oc.renderByHref(href, callback); + }, RETRY_INTERVAL); } - }, - error: function(){ - logger.error(MESSAGES_ERRORS_RETRIEVING); - setTimeout(function() { - oc.renderByHref(href, callback); - }, RETRY_INTERVAL); - } - }); - } else { - return callback(MESSAGES_ERRORS_RENDERING.replace('{1}', MESSAGES_ERRORS_HREF_MISSING)); - } + }); + } else { + return callback(MESSAGES_ERRORS_RENDERING.replace('{1}', MESSAGES_ERRORS_HREF_MISSING)); + } + }); }; - oc.renderUnloadedComponents = oc.refresh = function(){ - var $unloadedComponents = $(OC_TAG + '[data-rendered!=true]'); - - var renderUnloadedComponent = function($unloadedComponents, i){ - logger.info(MESSAGES_RETRIEVING); - oc.renderNestedComponent($($unloadedComponents[i]), function(){ - i++; - if(i < $unloadedComponents.length){ - renderUnloadedComponent($unloadedComponents, i); - } else { - oc.renderUnloadedComponents(); - } - }); - }; - - if($unloadedComponents.length > 0){ - renderUnloadedComponent($unloadedComponents, 0); - } - }; + oc.renderUnloadedComponents = function(){ + oc.ready(function(){ + var selector = (is8 ? 'div[data-oc-component=true]' : OC_TAG), + $unloadedComponents = $(selector + '[data-rendered!=true]'); + + var renderUnloadedComponent = function($unloadedComponents, i){ + logger.info(MESSAGES_RETRIEVING); + oc.renderNestedComponent($($unloadedComponents[i]), function(){ + i++; + if(i < $unloadedComponents.length){ + renderUnloadedComponent($unloadedComponents, i); + } else { + oc.renderUnloadedComponents(); + } + }); + }; - oc.setEventListeners = function(component){ - component.off('reRender'); - component.on('reRender', function(event, href){ - var self = $(event.target); - if(!!href && href !== ''){ - self.attr('href', href); + if($unloadedComponents.length > 0){ + renderUnloadedComponent($unloadedComponents, 0); } - self.attr('data-hash', ''); - self.attr('data-rendered', false); - oc.renderUnloadedComponents(); - return false; }); - component.trigger('loaded'); }; - oc.load = function(placeholder, href, callback){ - if(typeof(callback) !== 'function'){ - callback = noop; - } - - if($(placeholder)){ - $(placeholder).html('<' + OC_TAG + ' href="' + href + '" />'); - var newComponent = $(OC_TAG, placeholder); - oc.renderNestedComponent(newComponent, function(){ - callback(newComponent); + oc.setEventListeners = function(component){ + oc.ready(function(){ + component.off('reRender'); + component.on('reRender', function(event, href){ + var self = $(event.target); + if(!!href && href !== ''){ + self.attr('href', href); + } + self.attr('data-hash', ''); + self.attr('data-rendered', false); + oc.renderUnloadedComponents(); + return false; }); - } + component.trigger('loaded'); + }); }; - var ensureJqueryIsLoaded = function(callback){ - if(!$){ - _require([JQUERY_URL], function(){ - $ = jQuery; - - var nav = $window.navigator.userAgent, - is8 = !!(nav.match(/MSIE 8/)), - is9 = !!(nav.match(/MSIE 9/)); + oc.load = function(placeholder, href, callback){ + oc.ready(function(){ + if(typeof(callback) !== 'function'){ + callback = noop; + } - if(is8 || is9){ - _require([IE89_AJAX_POLYFILL_URL, HTML5SHIV_URL], callback); - } else { - callback(); - } - }); - } else { - callback(); - } + if($(placeholder)){ + $(placeholder).html('<' + OC_TAG + ' href="' + href + '" />'); + var newComponent = $(OC_TAG, placeholder); + oc.renderNestedComponent(newComponent, function(){ + callback(newComponent); + }); + } + }); }; - ensureJqueryIsLoaded(oc.renderUnloadedComponents); + oc.ready(oc.renderUnloadedComponents); -})(Handlebars, document, window, true); // jshint ignore:line \ No newline at end of file +})(Handlebars, head, document, window, true); // jshint ignore:line \ No newline at end of file diff --git a/components/oc-client/_package/src/oc-client.min.js b/components/oc-client/_package/src/oc-client.min.js index d8e76728a..9f30732d7 100644 --- a/components/oc-client/_package/src/oc-client.min.js +++ b/components/oc-client/_package/src/oc-client.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r;"undefined"!=typeof window?r=window:"undefined"!=typeof global?r=global:"undefined"!=typeof self&&(r=self),r.jade=e()}}(function(){return function e(r,n,t){function o(a,s){if(!n[a]){if(!r[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[a]={exports:{}};r[a][0].call(u.exports,function(e){var n=r[a][1][e];return o(n?n:e)},u,u.exports,e,r,n,t)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a/g,">").replace(/"/g,""");return r===""+e?e:r},n.rethrow=function a(r,n,t,o){if(!(r instanceof Error))throw r;if(!("undefined"==typeof window&&n||o))throw r.message+=" on line "+t,r;try{o=o||e("fs").readFileSync(n,"utf8")}catch(i){a(r,null,t)}var s=3,c=o.split("\n"),l=Math.max(t-s,0),u=Math.min(c.length,t+s),s=c.slice(l,u).map(function(e,r){var n=r+l+1;return(n==t?" > ":" ")+n+"| "+e}).join("\n");throw r.path=n,r.message=(n||"Jade")+":"+t+"\n"+s+"\n\n"+r.message,r}},{fs:2}],2:[function(){},{}]},{},[1])(1)});var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var r;return e.prototype.toString=function(){return""+this.string},r=e}(),r=function(e){"use strict";function r(e){return s[e]||"&"}function n(e,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}function t(e){return e instanceof a?e.toString():e||0===e?(e=""+e,l.test(e)?e.replace(c,r):e):""}function o(e){return e||0===e?p(e)&&0===e.length?!0:!1:!0}var i={},a=e,s={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},c=/[&<>"'`]/g,l=/[&<>"'`]/;i.extend=n;var u=Object.prototype.toString;i.toString=u;var f=function(e){return"function"==typeof e};f(/x/)&&(f=function(e){return"function"==typeof e&&"[object Function]"===u.call(e)});var f;i.isFunction=f;var p=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===u.call(e):!1};return i.isArray=p,i.escapeExpression=t,i.isEmpty=o,i}(e),n=function(){"use strict";function e(e,r){var t;r&&r.firstLine&&(t=r.firstLine,e+=" - "+t+":"+r.firstColumn);for(var o=Error.prototype.constructor.call(this,e),i=0;i0?e.helpers.each(r,n):t(this):o(r)}),e.registerHelper("each",function(e,r){var n,t=r.fn,o=r.inverse,i=0,a="";if(p(e)&&(e=e.call(this)),r.data&&(n=v(r.data)),e&&"object"==typeof e)if(f(e))for(var s=e.length;s>i;i++)n&&(n.index=i,n.first=0===i,n.last=i===e.length-1),a+=t(e[i],{data:n});else for(var c in e)e.hasOwnProperty(c)&&(n&&(n.key=c,n.index=i,n.first=0===i),a+=t(e[c],{data:n}),i++);return 0===i&&(a=o(this)),a}),e.registerHelper("if",function(e,r){return p(e)&&(e=e.call(this)),!r.hash.includeZero&&!e||a.isEmpty(e)?r.inverse(this):r.fn(this)}),e.registerHelper("unless",function(r,n){return e.helpers["if"].call(this,r,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,r){return p(e)&&(e=e.call(this)),a.isEmpty(e)?void 0:r.fn(e)}),e.registerHelper("log",function(r,n){var t=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(t,r)})}function o(e,r){m.log(e,r)}var i={},a=e,s=r,c="1.3.0";i.VERSION=c;var l=4;i.COMPILER_REVISION=l;var u={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};i.REVISION_CHANGES=u;var f=a.isArray,p=a.isFunction,d=a.toString,h="[object Object]";i.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,r,n){if(d.call(e)===h){if(n||r)throw new s("Arg not supported with multiple helpers");a.extend(this.helpers,e)}else n&&(r.not=n),this.helpers[e]=r},registerPartial:function(e,r){d.call(e)===h?a.extend(this.partials,e):this.partials[e]=r}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,r){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,r)}}};i.logger=m,i.log=o;var v=function(e){var r={};return a.extend(r,e),r};return i.createFrame=v,i}(r,n),o=function(e,r,n){"use strict";function t(e){var r=e&&e[0]||1,n=p;if(r!==n){if(n>r){var t=d[n],o=d[r];throw new f("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+t+") or downgrade your runtime to an older version ("+o+").")}throw new f("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,r){if(!r)throw new f("No environment passed to template");var n=function(e,n,t,o,i,a){var s=r.VM.invokePartial.apply(this,arguments);if(null!=s)return s;if(r.compile){var c={helpers:o,partials:i,data:a};return i[n]=r.compile(e,{data:void 0!==a},r),i[n](t,c)}throw new f("The partial "+n+" could not be compiled when running in runtime-only mode")},t={escapeExpression:u.escapeExpression,invokePartial:n,programs:[],program:function(e,r,n){var t=this.programs[e];return n?t=a(e,r,n):t||(t=this.programs[e]=a(e,r)),t},merge:function(e,r){var n=e||r;return e&&r&&e!==r&&(n={},u.extend(n,r),u.extend(n,e)),n},programWithDepth:r.VM.programWithDepth,noop:r.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var i,a,s=o.partial?o:r;o.partial||(i=o.helpers,a=o.partials);var c=e.call(t,s,n,i,a,o.data);return o.partial||r.VM.checkRevision(t.compilerInfo),c}}function i(e,r,n){var t=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},r.apply(this,[e,o.data||n].concat(t))};return o.program=e,o.depth=t.length,o}function a(e,r,n){var t=function(e,t){return t=t||{},r(e,t.data||n)};return t.program=e,t.depth=0,t}function s(e,r,n,t,o,i){var a={partial:!0,helpers:t,partials:o,data:i};if(void 0===e)throw new f("The partial "+r+" could not be found");return e instanceof Function?e(n,a):void 0}function c(){return""}var l={},u=e,f=r,p=n.COMPILER_REVISION,d=n.REVISION_CHANGES;return l.checkRevision=t,l.template=o,l.programWithDepth=i,l.program=a,l.invokePartial=s,l.noop=c,l}(r,n,t),i=function(e,r,n,t,o){"use strict";var i,a=e,s=r,c=n,l=t,u=o,f=function(){var e=new a.HandlebarsEnvironment;return l.extend(e,a),e.SafeString=s,e.Exception=c,e.Utils=l,e.VM=u,e.template=function(r){return u.template(r,e)},e},p=f();return p.create=f,i=p}(t,e,n,r,o);return i}(),oc=oc||{};!function(e,r,n,t){var o="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js",i="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js",a="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js",s=5e3,c="oc-component",l="Href parameter missing",u="Error loading {0} component",f="Error rendering component: {0}, error: {1}",p="Failed to retrieve the component. Retrying in {0} seconds...".replace("{0}",s/1e3),d="Error loading component: view engine {0} not supported",h="Loading...",m="Component '{0}' correctly rendered",v="Unrendered component found. Trying to retrieve it...",g=[],y="undefined"!=typeof jQuery?jQuery:void 0,w=function(){},j={error:function(e){return console.log(e)},info:function(e){return t?console.log(e):void 0}},b=function(e,r){for(var n=0;n'+h+""),oc.renderByHref(e.attr("href"),function(n,t){return!n&&t&&t.html?void E(e,t,r):j.error(n)})},oc.renderByHref=function(e,r){return""===e?r(f.replace("{1}",l)):void y.ajax({url:e,headers:{"render-mode":"pre-rendered"},crossDomain:!0,async:!0,success:function(e){"pre-rendered"===e.renderMode?x([e.template.src],function(){oc.render(e.template,e.data,function(n,t){return n?r(f.replace("{0}",e.href).replace("{1}",n)):(j.info(m.replace("{0}",e.template.src)),void r(null,{html:t,key:e.template.key,version:e.version}))})}):"rendered"===e.renderMode&&(j.info(m.replace("{0}",e.href)),r(null,{html:y(e.html).html(),version:e.version}))},error:function(){j.error(p),setTimeout(function(){oc.renderByHref(e,r)},s)}})},oc.renderUnloadedComponents=oc.refresh=function(){var e=y(c+"[data-rendered!=true]"),r=function(e,n){j.info(v),oc.renderNestedComponent(y(e[n]),function(){n++,n0&&r(e,0)},oc.setEventListeners=function(e){e.off("reRender"),e.on("reRender",function(e,r){var n=y(e.target);return r&&""!==r&&n.attr("href",r),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")},oc.load=function(e,r,n){if("function"!=typeof n&&(n=w),y(e)){y(e).html("<"+c+' href="'+r+'" />');var t=y(c,e);oc.renderNestedComponent(t,function(){n(t)})}};var O=function(e){y?e():x([a],function(){y=jQuery;var r=n.navigator.userAgent,t=!!r.match(/MSIE 8/),a=!!r.match(/MSIE 9/);t||a?x([i,o],e):e()})};O(oc.renderUnloadedComponents)}(Handlebars,document,window,!0),oc.clientVersion="0.8.3"; \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.jade=e()}}(function(){return function e(t,n,r){function o(i,c){if(!n[i]){if(!t[i]){var l="function"==typeof require&&require;if(!c&&l)return l(i,!0);if(a)return a(i,!0);var s=new Error("Cannot find module '"+i+"'");throw s.code="MODULE_NOT_FOUND",s}var u=n[i]={exports:{}};t[i][0].call(u.exports,function(e){var n=t[i][1][e];return o(n?n:e)},u,u.exports,e,t,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i/g,">").replace(/"/g,""");return t===""+e?e:t},n.rethrow=function i(t,n,r,o){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&n||o))throw t.message+=" on line "+r,t;try{o=o||e("fs").readFileSync(n,"utf8")}catch(a){i(t,null,r)}var c=3,l=o.split("\n"),s=Math.max(r-c,0),u=Math.min(l.length,r+c),c=l.slice(s,u).map(function(e,t){var n=t+s+1;return(n==r?" > ":" ")+n+"| "+e}).join("\n");throw t.path=n,t.message=(n||"Jade")+":"+r+"\n"+c+"\n\n"+t.message,t}},{fs:2}],2:[function(){},{}]},{},[1])(1)});var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var t;return e.prototype.toString=function(){return""+this.string},t=e}(),t=function(e){"use strict";function t(e){return c[e]||"&"}function n(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}function r(e){return e instanceof i?e.toString():e||0===e?(e=""+e,s.test(e)?e.replace(l,t):e):""}function o(e){return e||0===e?d(e)&&0===e.length?!0:!1:!0}var a={},i=e,c={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},l=/[&<>"'`]/g,s=/[&<>"'`]/;a.extend=n;var u=Object.prototype.toString;a.toString=u;var f=function(e){return"function"==typeof e};f(/x/)&&(f=function(e){return"function"==typeof e&&"[object Function]"===u.call(e)});var f;a.isFunction=f;var d=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===u.call(e):!1};return a.isArray=d,a.escapeExpression=r,a.isEmpty=o,a}(e),n=function(){"use strict";function e(e,t){var r;t&&t.firstLine&&(r=t.firstLine,e+=" - "+r+":"+t.firstColumn);for(var o=Error.prototype.constructor.call(this,e),a=0;a0?e.helpers.each(t,n):r(this):o(t)}),e.registerHelper("each",function(e,t){var n,r=t.fn,o=t.inverse,a=0,i="";if(d(e)&&(e=e.call(this)),t.data&&(n=v(t.data)),e&&"object"==typeof e)if(f(e))for(var c=e.length;c>a;a++)n&&(n.index=a,n.first=0===a,n.last=a===e.length-1),i+=r(e[a],{data:n});else for(var l in e)e.hasOwnProperty(l)&&(n&&(n.key=l,n.index=a,n.first=0===a),i+=r(e[l],{data:n}),a++);return 0===a&&(i=o(this)),i}),e.registerHelper("if",function(e,t){return d(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||i.isEmpty(e)?t.inverse(this):t.fn(this)}),e.registerHelper("unless",function(t,n){return e.helpers["if"].call(this,t,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,t){return d(e)&&(e=e.call(this)),i.isEmpty(e)?void 0:t.fn(e)}),e.registerHelper("log",function(t,n){var r=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(r,t)})}function o(e,t){m.log(e,t)}var a={},i=e,c=t,l="1.3.0";a.VERSION=l;var s=4;a.COMPILER_REVISION=s;var u={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};a.REVISION_CHANGES=u;var f=i.isArray,d=i.isFunction,p=i.toString,h="[object Object]";a.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,t,n){if(p.call(e)===h){if(n||t)throw new c("Arg not supported with multiple helpers");i.extend(this.helpers,e)}else n&&(t.not=n),this.helpers[e]=t},registerPartial:function(e,t){p.call(e)===h?i.extend(this.partials,e):this.partials[e]=t}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,t){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,t)}}};a.logger=m,a.log=o;var v=function(e){var t={};return i.extend(t,e),t};return a.createFrame=v,a}(t,n),o=function(e,t,n){"use strict";function r(e){var t=e&&e[0]||1,n=d;if(t!==n){if(n>t){var r=p[n],o=p[t];throw new f("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+r+") or downgrade your runtime to an older version ("+o+").")}throw new f("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,t){if(!t)throw new f("No environment passed to template");var n=function(e,n,r,o,a,i){var c=t.VM.invokePartial.apply(this,arguments);if(null!=c)return c;if(t.compile){var l={helpers:o,partials:a,data:i};return a[n]=t.compile(e,{data:void 0!==i},t),a[n](r,l)}throw new f("The partial "+n+" could not be compiled when running in runtime-only mode")},r={escapeExpression:u.escapeExpression,invokePartial:n,programs:[],program:function(e,t,n){var r=this.programs[e];return n?r=i(e,t,n):r||(r=this.programs[e]=i(e,t)),r},merge:function(e,t){var n=e||t;return e&&t&&e!==t&&(n={},u.extend(n,t),u.extend(n,e)),n},programWithDepth:t.VM.programWithDepth,noop:t.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var a,i,c=o.partial?o:t;o.partial||(a=o.helpers,i=o.partials);var l=e.call(r,c,n,a,i,o.data);return o.partial||t.VM.checkRevision(r.compilerInfo),l}}function a(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},t.apply(this,[e,o.data||n].concat(r))};return o.program=e,o.depth=r.length,o}function i(e,t,n){var r=function(e,r){return r=r||{},t(e,r.data||n)};return r.program=e,r.depth=0,r}function c(e,t,n,r,o,a){var i={partial:!0,helpers:r,partials:o,data:a};if(void 0===e)throw new f("The partial "+t+" could not be found");return e instanceof Function?e(n,i):void 0}function l(){return""}var s={},u=e,f=t,d=n.COMPILER_REVISION,p=n.REVISION_CHANGES;return s.checkRevision=r,s.template=o,s.programWithDepth=a,s.program=i,s.invokePartial=c,s.noop=l,s}(t,n,r),a=function(e,t,n,r,o){"use strict";var a,i=e,c=t,l=n,s=r,u=o,f=function(){var e=new i.HandlebarsEnvironment;return s.extend(e,i),e.SafeString=c,e.Exception=l,e.Utils=s,e.VM=u,e.template=function(t){return u.template(t,e)},e},d=f();return d.create=f,a=d}(r,e,n,t,o);return a}();!function(e,t){"use strict";function n(){}function r(e,t){if(e){"object"==typeof e&&(e=[].slice.call(e));for(var n=0,r=e.length;r>n;n++)t.call(e,e[n],n)}}function o(e,n){var r=Object.prototype.toString.call(n).slice(8,-1);return n!==t&&null!==n&&r===e}function a(e){return o("Function",e)}function i(e){return o("Array",e)}function c(e){var t=e.split("/"),n=t[t.length-1],r=n.indexOf("?");return-1!==r?n.substring(0,r):n}function l(e){e=e||n,e._done||(e(),e._done=1)}function s(e,t,r,o){var a="object"==typeof e?e:{test:e,success:t?i(t)?t:[t]:!1,failure:r?i(r)?r:[r]:!1,callback:o||n},c=!!a.test;return c&&a.success?(a.success.push(a.callback),k.load.apply(null,a.success)):!c&&a.failure?(a.failure.push(a.callback),k.load.apply(null,a.failure)):o(),k}function u(e){var t={};if("object"==typeof e)for(var n in e)e[n]&&(t={name:n,url:e[n]});else t={name:c(e),url:e};var r=M[t.name];return r&&r.url===t.url?r:(M[t.name]=t,t)}function f(e){e=e||M;for(var t in e)if(e.hasOwnProperty(t)&&e[t].state!==C)return!1;return!0}function d(e){e.state=N,r(e.onpreload,function(e){e.call()})}function p(e){e.state===t&&(e.state=I,e.onpreload=[],g({url:e.url,type:"cache"},function(){d(e)}))}function h(){var e=arguments,t=e[e.length-1],n=[].slice.call(e,1),o=n[0];return a(t)||(t=null),i(e[0])?(e[0].push(t),k.load.apply(null,e[0]),k):(o?(r(n,function(e){!a(e)&&e&&p(u(e))}),v(u(e[0]),a(o)?o:function(){k.load.apply(null,n)})):v(u(e[0])),k)}function m(){var e=arguments,t=e[e.length-1],n={};return a(t)||(t=null),i(e[0])?(e[0].push(t),k.load.apply(null,e[0]),k):(r(e,function(e){e!==t&&(e=u(e),n[e.name]=e)}),r(e,function(e){e!==t&&(e=u(e),v(e,function(){f(n)&&l(t)}))}),k)}function v(e,t){return t=t||n,e.state===C?void t():e.state===H?void k.ready(e.name,t):e.state===I?void e.onpreload.push(function(){v(e,t)}):(e.state=H,void g(e,function(){e.state=C,t(),r(T[e.name],function(e){l(e)}),S&&f()&&r(T.ALL,function(e){l(e)})}))}function y(e){e=e||"";var t=e.split("?")[0].split(".");return t[t.length-1].toLowerCase()}function g(t,r){function o(t){t=t||e.event,c.onload=c.onreadystatechange=c.onerror=null,r()}function a(n){n=n||e.event,("load"===n.type||/loaded|complete/.test(c.readyState)&&(!x.documentMode||x.documentMode<9))&&(e.clearTimeout(t.errorTimeout),e.clearTimeout(t.cssTimeout),c.onload=c.onreadystatechange=c.onerror=null,r())}function i(){if(t.state!==C&&t.cssRetries<=20){for(var n=0,r=x.styleSheets.length;r>n;n++)if(x.styleSheets[n].href===c.href)return void a({type:"load"});t.cssRetries++,t.cssTimeout=e.setTimeout(i,250)}}r=r||n;var c,l=y(t.url);"css"===l?(c=x.createElement("link"),c.type="text/"+(t.type||"css"),c.rel="stylesheet",c.href=t.url,t.cssRetries=0,t.cssTimeout=e.setTimeout(i,500)):(c=x.createElement("script"),c.type="text/"+(t.type||"javascript"),c.src=t.url),c.onload=c.onreadystatechange=a,c.onerror=o,c.async=!1,c.defer=!1,t.errorTimeout=e.setTimeout(function(){o({type:"timeout"})},7e3);var s=x.head||x.getElementsByTagName("head")[0];s.insertBefore(c,s.lastChild)}function w(){for(var e=x.getElementsByTagName("script"),t=0,n=e.length;n>t;t++){var r=e[t].getAttribute("data-headjs-load");if(r)return void k.load(r)}}function E(e,t){if(e===x)return S?l(t):O.push(t),k;if(a(e)&&(t=e,e="ALL"),i(e)){var n={};return r(e,function(e){n[e]=M[e],k.ready(e,function(){f(n)&&l(t)})}),k}if("string"!=typeof e||!a(t))return k;var o=M[e];if(o&&o.state===C||"ALL"===e&&f()&&S)return l(t),k;var c=T[e];return c?c.push(t):c=T[e]=[t],k}function b(){return x.body?void(S||(S=!0,w(),r(O,function(e){l(e)}))):(e.clearTimeout(k.readyTimeout),void(k.readyTimeout=e.setTimeout(b,50)))}function j(){x.addEventListener?(x.removeEventListener("DOMContentLoaded",j,!1),b()):"complete"===x.readyState&&(x.detachEvent("onreadystatechange",j),b())}var S,x=e.document,O=[],T={},M={},A="async"in x.createElement("script")||"MozAppearance"in x.documentElement.style||e.opera,L=e.head_conf&&e.head_conf.head||"head",k=e[L]=e[L]||function(){k.ready.apply(null,arguments)},I=1,N=2,H=3,C=4;if("complete"===x.readyState)b();else if(x.addEventListener)x.addEventListener("DOMContentLoaded",j,!1),e.addEventListener("load",b,!1);else{x.attachEvent("onreadystatechange",j),e.attachEvent("onload",b);var R=!1;try{R=!e.frameElement&&x.documentElement}catch(q){}R&&R.doScroll&&!function P(){if(!S){try{R.doScroll("left")}catch(t){return e.clearTimeout(k.readyTimeout),void(k.readyTimeout=e.setTimeout(P,50))}b()}}()}k.load=k.js=A?m:h,k.test=s,k.ready=E,k.ready(x,function(){f()&&r(T.ALL,function(e){l(e)}),k.feature&&k.feature("domloaded",!0)})}(window);var oc=oc||{};!function(e,t,n,r,o){var a="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js",i="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js",c=5e3,l="oc-component",s="Href parameter missing",u="Error loading {0} component",f="Error rendering component: {0}, error: {1}",d="Failed to retrieve the component. Retrying in {0} seconds...".replace("{0}",c/1e3),p="Error loading component: view engine {0} not supported",h="Loading...",m="Component '{0}' correctly rendered",v="Unrendered component found. Trying to retrieve it...",y="undefined"!=typeof jQuery?jQuery:void 0,g=function(){},w=r.navigator.userAgent,E=!!w.match(/MSIE 8/),b=!!w.match(/MSIE 9/),j=!1,S=!1,x=[],O={error:function(e){return console.log(e)},info:function(e){return o?console.log(e):void 0}},T=function(e,t,n){var r=Math.floor(9999999999*Math.random());e.html(t.html),e.attr("id",r),e.attr("data-rendered",!0),e.attr("data-version",t.version),t.key&&(e.attr("data-hash",t.key),oc.setEventListeners(e)),n()};oc.ready=function(e){if(j)return e();if(S)x.push(e);else{S=!0;var n=function(e){E||b?t.load(a,e):e()},r=function(){j=!0,S=!1,e();for(var t=0;t'+h+""),oc.renderByHref(e.attr("href"),function(n,r){return!n&&r&&r.html?void T(e,r,t):O.error(n)})})},oc.renderByHref=function(e,n){oc.ready(function(){return""===e?n(f.replace("{1}",s)):void y.ajax({url:e,headers:{"render-mode":"pre-rendered"},crossDomain:!0,async:!0,success:function(e){if("pre-rendered"===e.renderMode)t.load([e.template.src],function(){oc.render(e.template,e.data,function(t,r){return t?n(f.replace("{0}",e.href).replace("{1}",t)):(O.info(m.replace("{0}",e.template.src)),void n(null,{html:r,key:e.template.key,version:e.version}))})});else if("rendered"===e.renderMode){O.info(m.replace("{0}",e.href));var r=e.html.slice(e.html.indexOf(">")+1),o=r.slice(0,r.indexOf("<"));n(null,{html:o,version:e.version})}},error:function(){O.error(d),setTimeout(function(){oc.renderByHref(e,n)},c)}})})},oc.renderUnloadedComponents=function(){oc.ready(function(){var e=E?"div[data-oc-component=true]":l,t=y(e+"[data-rendered!=true]"),n=function(e,t){O.info(v),oc.renderNestedComponent(y(e[t]),function(){t++,t0&&n(t,0)})},oc.setEventListeners=function(e){oc.ready(function(){e.off("reRender"),e.on("reRender",function(e,t){var n=y(e.target);return t&&""!==t&&n.attr("href",t),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")})},oc.load=function(e,t,n){oc.ready(function(){if("function"!=typeof n&&(n=g),y(e)){y(e).html("<"+l+' href="'+t+'" />');var r=y(l,e);oc.renderNestedComponent(r,function(){n(r)})}})},oc.ready(oc.renderUnloadedComponents)}(Handlebars,head,document,window,!0),oc.clientVersion="0.8.3"; \ No newline at end of file diff --git a/components/oc-client/src/head.load.js b/components/oc-client/src/head.load.js new file mode 100644 index 000000000..b7a31c778 --- /dev/null +++ b/components/oc-client/src/head.load.js @@ -0,0 +1,707 @@ +///#source 1 1 /src/1.0.0/load.js +/*! head.load - v1.0.3 */ +/* + * HeadJS The only script in your + * Author Tero Piirainen (tipiirai) + * Maintainer Robert Hoffmann (itechnology) + * License MIT / http://bit.ly/mit-license + * WebSite http://headjs.com + */ +(function (win, undefined) { + "use strict"; + + //#region variables + var doc = win.document, + domWaiters = [], + handlers = {}, // user functions waiting for events + assets = {}, // loadable items in various states + isAsync = "async" in doc.createElement("script") || "MozAppearance" in doc.documentElement.style || win.opera, + isDomReady, + + /*** public API ***/ + headVar = win.head_conf && win.head_conf.head || "head", + api = win[headVar] = (win[headVar] || function () { api.ready.apply(null, arguments); }), + + // states + PRELOADING = 1, + PRELOADED = 2, + LOADING = 3, + LOADED = 4; + //#endregion + + //#region PRIVATE functions + + //#region Helper functions + function noop() { + // does nothing + } + + function each(arr, callback) { + if (!arr) { + return; + } + + // arguments special type + if (typeof arr === "object") { + arr = [].slice.call(arr); + } + + // do the job + for (var i = 0, l = arr.length; i < l; i++) { + callback.call(arr, arr[i], i); + } + } + + /* A must read: http://bonsaiden.github.com/JavaScript-Garden + ************************************************************/ + function is(type, obj) { + var clas = Object.prototype.toString.call(obj).slice(8, -1); + return obj !== undefined && obj !== null && clas === type; + } + + function isFunction(item) { + return is("Function", item); + } + + function isArray(item) { + return is("Array", item); + } + + function toLabel(url) { + ///Converts a url to a file label + var items = url.split("/"), + name = items[items.length - 1], + i = name.indexOf("?"); + + return i !== -1 ? name.substring(0, i) : name; + } + + // INFO: this look like a "im triggering callbacks all over the place, but only wanna run it one time function" ..should try to make everything work without it if possible + // INFO: Even better. Look into promises/defered's like jQuery is doing + function one(callback) { + ///Execute a callback only once + callback = callback || noop; + + if (callback._done) { + return; + } + + callback(); + callback._done = 1; + } + //#endregion + + function conditional(test, success, failure, callback) { + /// + /// INFO: use cases: + /// head.test(condition, null , "file.NOk" , callback); + /// head.test(condition, "fileOk.js", null , callback); + /// head.test(condition, "fileOk.js", "file.NOk" , callback); + /// head.test(condition, "fileOk.js", ["file.NOk", "file.NOk"], callback); + /// head.test({ + /// test : condition, + /// success : [{ label1: "file1Ok.js" }, { label2: "file2Ok.js" }], + /// failure : [{ label1: "file1NOk.js" }, { label2: "file2NOk.js" }], + /// callback: callback + /// ); + /// head.test({ + /// test : condition, + /// success : ["file1Ok.js" , "file2Ok.js"], + /// failure : ["file1NOk.js", "file2NOk.js"], + /// callback: callback + /// ); + /// + var obj = (typeof test === "object") ? test : { + test: test, + success: !!success ? isArray(success) ? success : [success] : false, + failure: !!failure ? isArray(failure) ? failure : [failure] : false, + callback: callback || noop + }; + + // Test Passed ? + var passed = !!obj.test; + + // Do we have a success case + if (passed && !!obj.success) { + obj.success.push(obj.callback); + api.load.apply(null, obj.success); + } + // Do we have a fail case + else if (!passed && !!obj.failure) { + obj.failure.push(obj.callback); + api.load.apply(null, obj.failure); + } + else { + callback(); + } + + return api; + } + + function getAsset(item) { + /// + /// Assets are in the form of + /// { + /// name : label, + /// url : url, + /// state: state + /// } + /// + var asset = {}; + + if (typeof item === "object") { + for (var label in item) { + if (!!item[label]) { + asset = { + name: label, + url : item[label] + }; + } + } + } + else { + asset = { + name: toLabel(item), + url : item + }; + } + + // is the item already existant + var existing = assets[asset.name]; + if (existing && existing.url === asset.url) { + return existing; + } + + assets[asset.name] = asset; + return asset; + } + + function allLoaded(items) { + items = items || assets; + + for (var name in items) { + if (items.hasOwnProperty(name) && items[name].state !== LOADED) { + return false; + } + } + + return true; + } + + function onPreload(asset) { + asset.state = PRELOADED; + + each(asset.onpreload, function (afterPreload) { + afterPreload.call(); + }); + } + + function preLoad(asset, callback) { + if (asset.state === undefined) { + + asset.state = PRELOADING; + asset.onpreload = []; + + loadAsset({ url: asset.url, type: "cache" }, function () { + onPreload(asset); + }); + } + } + + function apiLoadHack() { + /// preload with text/cache hack + /// + /// head.load("http://domain.com/file.js","http://domain.com/file.js", callBack) + /// head.load(["http://domain.com/file.js","http://domain.com/file.js"], callBack) + /// head.load({ label1: "http://domain.com/file.js" }, { label2: "http://domain.com/file.js" }, callBack) + /// head.load([{ label1: "http://domain.com/file.js" }, { label2: "http://domain.com/file.js" }], callBack) + /// + var args = arguments, + callback = args[args.length - 1], + rest = [].slice.call(args, 1), + next = rest[0]; + + if (!isFunction(callback)) { + callback = null; + } + + // if array, repush as args + if (isArray(args[0])) { + args[0].push(callback); + api.load.apply(null, args[0]); + + return api; + } + + // multiple arguments + if (!!next) { + /* Preload with text/cache hack (not good!) + * http://blog.getify.com/on-script-loaders/ + * http://www.nczonline.net/blog/2010/12/21/thoughts-on-script-loaders/ + * If caching is not configured correctly on the server, then items could load twice ! + *************************************************************************************/ + each(rest, function (item) { + // item is not a callback or empty string + if (!isFunction(item) && !!item) { + preLoad(getAsset(item)); + } + }); + + // execute + load(getAsset(args[0]), isFunction(next) ? next : function () { + api.load.apply(null, rest); + }); + } + else { + // single item + load(getAsset(args[0])); + } + + return api; + } + + function apiLoadAsync() { + /// + /// simply load and let browser take care of ordering + /// + /// head.load("http://domain.com/file.js","http://domain.com/file.js", callBack) + /// head.load(["http://domain.com/file.js","http://domain.com/file.js"], callBack) + /// head.load({ label1: "http://domain.com/file.js" }, { label2: "http://domain.com/file.js" }, callBack) + /// head.load([{ label1: "http://domain.com/file.js" }, { label2: "http://domain.com/file.js" }], callBack) + /// + var args = arguments, + callback = args[args.length - 1], + items = {}; + + if (!isFunction(callback)) { + callback = null; + } + + // if array, repush as args + if (isArray(args[0])) { + args[0].push(callback); + api.load.apply(null, args[0]); + + return api; + } + + // JRH 262#issuecomment-26288601 + // First populate the items array. + // When allLoaded is called, all items will be populated. + // Issue when lazy loaded, the callback can execute early. + each(args, function (item, i) { + if (item !== callback) { + item = getAsset(item); + items[item.name] = item; + } + }); + + each(args, function (item, i) { + if (item !== callback) { + item = getAsset(item); + + load(item, function () { + if (allLoaded(items)) { + one(callback); + } + }); + } + }); + + return api; + } + + function load(asset, callback) { + ///Used with normal loading logic + callback = callback || noop; + + if (asset.state === LOADED) { + callback(); + return; + } + + // INFO: why would we trigger a ready event when its not really loaded yet ? + if (asset.state === LOADING) { + api.ready(asset.name, callback); + return; + } + + if (asset.state === PRELOADING) { + asset.onpreload.push(function () { + load(asset, callback); + }); + return; + } + + asset.state = LOADING; + + loadAsset(asset, function () { + asset.state = LOADED; + + callback(); + + // handlers for this asset + each(handlers[asset.name], function (fn) { + one(fn); + }); + + // dom is ready & no assets are queued for loading + // INFO: shouldn't we be doing the same test above ? + if (isDomReady && allLoaded()) { + each(handlers.ALL, function (fn) { + one(fn); + }); + } + }); + } + + function getExtension(url) { + url = url || ""; + + var items = url.split("?")[0].split("."); + return items[items.length-1].toLowerCase(); + } + + /* Parts inspired from: https://github.com/cujojs/curl + ******************************************************/ + function loadAsset(asset, callback) { + callback = callback || noop; + + function error(event) { + event = event || win.event; + + // release event listeners + ele.onload = ele.onreadystatechange = ele.onerror = null; + + // do callback + callback(); + + // need some more detailed error handling here + } + + function process(event) { + event = event || win.event; + + // IE 7/8 (2 events on 1st load) + // 1) event.type = readystatechange, s.readyState = loading + // 2) event.type = readystatechange, s.readyState = loaded + + // IE 7/8 (1 event on reload) + // 1) event.type = readystatechange, s.readyState = complete + + // event.type === 'readystatechange' && /loaded|complete/.test(s.readyState) + + // IE 9 (3 events on 1st load) + // 1) event.type = readystatechange, s.readyState = loading + // 2) event.type = readystatechange, s.readyState = loaded + // 3) event.type = load , s.readyState = loaded + + // IE 9 (2 events on reload) + // 1) event.type = readystatechange, s.readyState = complete + // 2) event.type = load , s.readyState = complete + + // event.type === 'load' && /loaded|complete/.test(s.readyState) + // event.type === 'readystatechange' && /loaded|complete/.test(s.readyState) + + // IE 10 (3 events on 1st load) + // 1) event.type = readystatechange, s.readyState = loading + // 2) event.type = load , s.readyState = complete + // 3) event.type = readystatechange, s.readyState = loaded + + // IE 10 (3 events on reload) + // 1) event.type = readystatechange, s.readyState = loaded + // 2) event.type = load , s.readyState = complete + // 3) event.type = readystatechange, s.readyState = complete + + // event.type === 'load' && /loaded|complete/.test(s.readyState) + // event.type === 'readystatechange' && /complete/.test(s.readyState) + + // Other Browsers (1 event on 1st load) + // 1) event.type = load, s.readyState = undefined + + // Other Browsers (1 event on reload) + // 1) event.type = load, s.readyState = undefined + + // event.type == 'load' && s.readyState = undefined + + // !doc.documentMode is for IE6/7, IE8+ have documentMode + if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) { + // remove timeouts + win.clearTimeout(asset.errorTimeout); + win.clearTimeout(asset.cssTimeout); + + // release event listeners + ele.onload = ele.onreadystatechange = ele.onerror = null; + + // do callback + callback(); + } + } + + function isCssLoaded() { + // should we test again ? 20 retries = 5secs ..after that, the callback will be triggered by the error handler at 7secs + if (asset.state !== LOADED && asset.cssRetries <= 20) { + + // loop through stylesheets + for (var i = 0, l = doc.styleSheets.length; i < l; i++) { + // do we have a match ? + // we need to tests agains ele.href and not asset.url, because a local file will be assigned the full http path on a link element + if (doc.styleSheets[i].href === ele.href) { + process({ "type": "load" }); + return; + } + } + + // increment & try again + asset.cssRetries++; + asset.cssTimeout = win.setTimeout(isCssLoaded, 250); + } + } + + var ele; + var ext = getExtension(asset.url); + + if (ext === "css") { + ele = doc.createElement("link"); + ele.type = "text/" + (asset.type || "css"); + ele.rel = "stylesheet"; + ele.href = asset.url; + + /* onload supported for CSS on unsupported browsers + * Safari windows 5.1.7, FF < 10 + */ + + // Set counter to zero + asset.cssRetries = 0; + asset.cssTimeout = win.setTimeout(isCssLoaded, 500); + } + else { + ele = doc.createElement("script"); + ele.type = "text/" + (asset.type || "javascript"); + ele.src = asset.url; + } + + ele.onload = ele.onreadystatechange = process; + ele.onerror = error; + + /* Good read, but doesn't give much hope ! + * http://blog.getify.com/on-script-loaders/ + * http://www.nczonline.net/blog/2010/12/21/thoughts-on-script-loaders/ + * https://hacks.mozilla.org/2009/06/defer/ + */ + + // ASYNC: load in parallel and execute as soon as possible + ele.async = false; + // DEFER: load in parallel but maintain execution order + ele.defer = false; + + // timout for asset loading + asset.errorTimeout = win.setTimeout(function () { + error({ type: "timeout" }); + }, 7e3); + + // use insertBefore to keep IE from throwing Operation Aborted (thx Bryan Forbes!) + var head = doc.head || doc.getElementsByTagName("head")[0]; + + // but insert at end of head, because otherwise if it is a stylesheet, it will not override values + head.insertBefore(ele, head.lastChild); + } + + /* Parts inspired from: https://github.com/jrburke/requirejs + ************************************************************/ + function init() { + var items = doc.getElementsByTagName("script"); + + // look for a script with a data-head-init attribute + for (var i = 0, l = items.length; i < l; i++) { + var dataMain = items[i].getAttribute("data-headjs-load"); + if (!!dataMain) { + api.load(dataMain); + return; + } + } + } + + function ready(key, callback) { + /// + /// INFO: use cases: + /// head.ready(callBack); + /// head.ready(document , callBack); + /// head.ready("file.js", callBack); + /// head.ready("label" , callBack); + /// head.ready(["label1", "label2"], callback); + /// + + // DOM ready check: head.ready(document, function() { }); + if (key === doc) { + if (isDomReady) { + one(callback); + } + else { + domWaiters.push(callback); + } + + return api; + } + + // shift arguments + if (isFunction(key)) { + callback = key; + key = "ALL"; // holds all callbacks that where added without labels: ready(callBack) + } + + // queue all items from key and return. The callback will be executed if all items from key are already loaded. + if (isArray(key)) { + var items = {}; + + each(key, function (item) { + items[item] = assets[item]; + + api.ready(item, function() { + if (allLoaded(items)) { + one(callback); + } + }); + }); + + return api; + } + + // make sure arguments are sane + if (typeof key !== "string" || !isFunction(callback)) { + return api; + } + + // this can also be called when we trigger events based on filenames & labels + var asset = assets[key]; + + // item already loaded --> execute and return + if (asset && asset.state === LOADED || key === "ALL" && allLoaded() && isDomReady) { + one(callback); + return api; + } + + var arr = handlers[key]; + if (!arr) { + arr = handlers[key] = [callback]; + } + else { + arr.push(callback); + } + + return api; + } + + /* Mix of stuff from jQuery & IEContentLoaded + * http://dev.w3.org/html5/spec/the-end.html#the-end + ***************************************************/ + function domReady() { + // Make sure body exists, at least, in case IE gets a little overzealous (jQuery ticket #5443). + if (!doc.body) { + // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if assets are queued) + win.clearTimeout(api.readyTimeout); + api.readyTimeout = win.setTimeout(domReady, 50); + return; + } + + if (!isDomReady) { + isDomReady = true; + + init(); + each(domWaiters, function (fn) { + one(fn); + }); + } + } + + function domContentLoaded() { + // W3C + if (doc.addEventListener) { + doc.removeEventListener("DOMContentLoaded", domContentLoaded, false); + domReady(); + } + + // IE + else if (doc.readyState === "complete") { + // we're here because readyState === "complete" in oldIE + // which is good enough for us to call the dom ready! + doc.detachEvent("onreadystatechange", domContentLoaded); + domReady(); + } + } + + // Catch cases where ready() is called after the browser event has already occurred. + // we once tried to use readyState "interactive" here, but it caused issues like the one + // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 + if (doc.readyState === "complete") { + domReady(); + } + + // W3C + else if (doc.addEventListener) { + doc.addEventListener("DOMContentLoaded", domContentLoaded, false); + + // A fallback to window.onload, that will always work + win.addEventListener("load", domReady, false); + } + + // IE + else { + // Ensure firing before onload, maybe late but safe also for iframes + doc.attachEvent("onreadystatechange", domContentLoaded); + + // A fallback to window.onload, that will always work + win.attachEvent("onload", domReady); + + // If IE and not a frame + // continually check to see if the document is ready + var top = false; + + try { + top = !win.frameElement && doc.documentElement; + } catch (e) { } + + if (top && top.doScroll) { + (function doScrollCheck() { + if (!isDomReady) { + try { + // Use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + top.doScroll("left"); + } catch (error) { + // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if assets are queued) + win.clearTimeout(api.readyTimeout); + api.readyTimeout = win.setTimeout(doScrollCheck, 50); + return; + } + + // and execute any waiting functions + domReady(); + } + }()); + } + } + //#endregion + + //#region Public Exports + // INFO: determine which method to use for loading + api.load = api.js = isAsync ? apiLoadAsync : apiLoadHack; + api.test = conditional; + api.ready = ready; + //#endregion + + //#region INIT + // perform this when DOM is ready + api.ready(doc, function () { + if (allLoaded()) { + each(handlers.ALL, function (callback) { + one(callback); + }); + } + + if (api.feature) { + api.feature("domloaded", true); + } + }); + //#endregion +}(window)); \ No newline at end of file diff --git a/components/oc-client/src/oc-client.js b/components/oc-client/src/oc-client.js index 18c6d3020..3923f752f 100644 --- a/components/oc-client/src/oc-client.js +++ b/components/oc-client/src/oc-client.js @@ -2,11 +2,10 @@ var oc = oc || {}; -(function(Handlebars, $document, $window, debug){ +(function(Handlebars, head, $document, $window, debug){ // Constants - var HTML5SHIV_URL = 'https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js', - IE89_AJAX_POLYFILL_URL = 'https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js', + var IE89_AJAX_POLYFILL_URL = 'https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js', JQUERY_URL = 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js', RETRY_INTERVAL = 5000, OC_TAG = 'oc-component', @@ -22,7 +21,13 @@ var oc = oc || {}; // The code var headScripts = [], $ = typeof(jQuery) !== 'undefined' ? jQuery : undefined, - noop = function(){}; + noop = function(){}, + nav = $window.navigator.userAgent, + is8 = !!(nav.match(/MSIE 8/)), + is9 = !!(nav.match(/MSIE 9/)), + initialised = false, + initialising = false, + readySubscribers = []; var logger = { error: function(msg){ @@ -44,39 +49,6 @@ var oc = oc || {}; return -1; }; - // a minimal vanilla require.js - var _require = function(hrefs, callback){ - - var callbacks = hrefs.length, - $head = $document.getElementsByTagName('head')[0]; - - var tryExit = function(){ - callbacks--; - if(callbacks === 0 && typeof(callback) === 'function'){ - callback(); - callback = noop; - } - }; - - var appendScript = function(href){ - headScripts.push(href); - var $script = $document.createElement('script'); - - $script.type = 'text/javascript'; - $script.src = href; - $script.onload = tryExit; - $head.appendChild($script); - }; - - for(var i = 0; i < hrefs.length; i++){ - if(_indexOf(headScripts, hrefs[i]) < 0){ - appendScript(hrefs[i]); - } else { - tryExit(); - } - } - }; - var processHtml = function($component, data, callback){ var newId = Math.floor(Math.random()*9999999999); @@ -94,147 +66,182 @@ var oc = oc || {}; callback(); }; - oc.render = function(compiledView, model, callback){ - if(!oc.components[compiledView.key]){ - callback(MESSAGES_ERRORS_LOADING_COMPONENT.replace('{0}', compiledView.key)); + oc.ready = function(callback){ + + if(initialised){ + return callback(); + } else if(initialising) { + readySubscribers.push(callback); } else { - var compiledComponent = ''; - if(compiledView.type === 'handlebars'){ - var linkedComponent = Handlebars.template(oc.components[compiledView.key], []); - compiledComponent = linkedComponent(model); - } else if(compiledView.type === 'jade'){ - compiledComponent = oc.components[compiledView.key](model); + initialising = true; + + var requirePolyfills = function(cb){ + if(is8 || is9){ + head.load(IE89_AJAX_POLYFILL_URL, cb); + } else { + cb(); + } + }; + + var done = function(){ + initialised = true; + initialising = false; + callback(); + for(var i = 0; i < readySubscribers.length; i++){ + readySubscribers[i](); + } + }; + + if(!$){ + head.load(JQUERY_URL, function(){ + $ = jQuery; + requirePolyfills(done); + }); } else { - return callback(MESSAGES_ERRORS_VIEW_ENGINE_NOT_SUPPORTED.replace('{0}', compiledView.type)); + requirePolyfills(done); } - callback(null, compiledComponent); } }; - oc.renderNestedComponent = function($component, callback){ - $component.html('
' + MESSAGES_LOADING_COMPONENT + '
'); + oc.render = function(compiledView, model, callback){ + oc.ready(function(){ + if(!oc.components[compiledView.key]){ + callback(MESSAGES_ERRORS_LOADING_COMPONENT.replace('{0}', compiledView.key)); + } else { + var compiledComponent = ''; - oc.renderByHref($component.attr('href'), function(err, data){ - if(err || !data || !data.html){ - return logger.error(err); + if(compiledView.type === 'handlebars'){ + var linkedComponent = Handlebars.template(oc.components[compiledView.key], []); + compiledComponent = linkedComponent(model); + } else if(compiledView.type === 'jade'){ + compiledComponent = oc.components[compiledView.key](model); + } else { + return callback(MESSAGES_ERRORS_VIEW_ENGINE_NOT_SUPPORTED.replace('{0}', compiledView.type)); + } + callback(null, compiledComponent); } + }); + }; + + oc.renderNestedComponent = function($component, callback){ + oc.ready(function(){ + $component.html('
' + MESSAGES_LOADING_COMPONENT + '
'); + + oc.renderByHref($component.attr('href'), function(err, data){ + if(err || !data || !data.html){ + return logger.error(err); + } - processHtml($component, data, callback); + processHtml($component, data, callback); + }); }); }; oc.renderByHref = function(href, callback){ - if(href !== ''){ - $.ajax({ - url: href, - headers: { 'render-mode': 'pre-rendered' }, - crossDomain: true, - async: true, - success: function(apiResponse){ - if(apiResponse.renderMode === 'pre-rendered'){ - _require([apiResponse.template.src], function(){ - oc.render(apiResponse.template, apiResponse.data, function(err, html){ - if(err){ - return callback(MESSAGES_ERRORS_RENDERING.replace('{0}', apiResponse.href).replace('{1}', err)); - } - logger.info(MESSAGES_RENDERED.replace('{0}', apiResponse.template.src)); - callback(null, { - html: html, - key: apiResponse.template.key, - version: apiResponse.version + oc.ready(function(){ + if(href !== ''){ + $.ajax({ + url: href, + headers: { 'render-mode': 'pre-rendered' }, + crossDomain: true, + async: true, + success: function(apiResponse){ + if(apiResponse.renderMode === 'pre-rendered'){ + head.load([apiResponse.template.src], function(){ + oc.render(apiResponse.template, apiResponse.data, function(err, html){ + if(err){ + return callback(MESSAGES_ERRORS_RENDERING.replace('{0}', apiResponse.href).replace('{1}', err)); + } + logger.info(MESSAGES_RENDERED.replace('{0}', apiResponse.template.src)); + callback(null, { + html: html, + key: apiResponse.template.key, + version: apiResponse.version + }); }); }); - }); - } else if(apiResponse.renderMode === 'rendered'){ - logger.info(MESSAGES_RENDERED.replace('{0}', apiResponse.href)); - callback(null, { - html: $(apiResponse.html).html(), - version: apiResponse.version - }); + } else if(apiResponse.renderMode === 'rendered'){ + logger.info(MESSAGES_RENDERED.replace('{0}', apiResponse.href)); + + var innerHtmlPlusEnding = apiResponse.html.slice(apiResponse.html.indexOf('>') + 1), + innerHtml = innerHtmlPlusEnding.slice(0, innerHtmlPlusEnding.indexOf('<')); + + callback(null, { + html: innerHtml, + version: apiResponse.version + }); + } + }, + error: function(){ + logger.error(MESSAGES_ERRORS_RETRIEVING); + setTimeout(function() { + oc.renderByHref(href, callback); + }, RETRY_INTERVAL); } - }, - error: function(){ - logger.error(MESSAGES_ERRORS_RETRIEVING); - setTimeout(function() { - oc.renderByHref(href, callback); - }, RETRY_INTERVAL); - } - }); - } else { - return callback(MESSAGES_ERRORS_RENDERING.replace('{1}', MESSAGES_ERRORS_HREF_MISSING)); - } + }); + } else { + return callback(MESSAGES_ERRORS_RENDERING.replace('{1}', MESSAGES_ERRORS_HREF_MISSING)); + } + }); }; - oc.renderUnloadedComponents = oc.refresh = function(){ - var $unloadedComponents = $(OC_TAG + '[data-rendered!=true]'); - - var renderUnloadedComponent = function($unloadedComponents, i){ - logger.info(MESSAGES_RETRIEVING); - oc.renderNestedComponent($($unloadedComponents[i]), function(){ - i++; - if(i < $unloadedComponents.length){ - renderUnloadedComponent($unloadedComponents, i); - } else { - oc.renderUnloadedComponents(); - } - }); - }; - - if($unloadedComponents.length > 0){ - renderUnloadedComponent($unloadedComponents, 0); - } - }; + oc.renderUnloadedComponents = function(){ + oc.ready(function(){ + var selector = (is8 ? 'div[data-oc-component=true]' : OC_TAG), + $unloadedComponents = $(selector + '[data-rendered!=true]'); + + var renderUnloadedComponent = function($unloadedComponents, i){ + logger.info(MESSAGES_RETRIEVING); + oc.renderNestedComponent($($unloadedComponents[i]), function(){ + i++; + if(i < $unloadedComponents.length){ + renderUnloadedComponent($unloadedComponents, i); + } else { + oc.renderUnloadedComponents(); + } + }); + }; - oc.setEventListeners = function(component){ - component.off('reRender'); - component.on('reRender', function(event, href){ - var self = $(event.target); - if(!!href && href !== ''){ - self.attr('href', href); + if($unloadedComponents.length > 0){ + renderUnloadedComponent($unloadedComponents, 0); } - self.attr('data-hash', ''); - self.attr('data-rendered', false); - oc.renderUnloadedComponents(); - return false; }); - component.trigger('loaded'); }; - oc.load = function(placeholder, href, callback){ - if(typeof(callback) !== 'function'){ - callback = noop; - } - - if($(placeholder)){ - $(placeholder).html('<' + OC_TAG + ' href="' + href + '" />'); - var newComponent = $(OC_TAG, placeholder); - oc.renderNestedComponent(newComponent, function(){ - callback(newComponent); + oc.setEventListeners = function(component){ + oc.ready(function(){ + component.off('reRender'); + component.on('reRender', function(event, href){ + var self = $(event.target); + if(!!href && href !== ''){ + self.attr('href', href); + } + self.attr('data-hash', ''); + self.attr('data-rendered', false); + oc.renderUnloadedComponents(); + return false; }); - } + component.trigger('loaded'); + }); }; - var ensureJqueryIsLoaded = function(callback){ - if(!$){ - _require([JQUERY_URL], function(){ - $ = jQuery; - - var nav = $window.navigator.userAgent, - is8 = !!(nav.match(/MSIE 8/)), - is9 = !!(nav.match(/MSIE 9/)); + oc.load = function(placeholder, href, callback){ + oc.ready(function(){ + if(typeof(callback) !== 'function'){ + callback = noop; + } - if(is8 || is9){ - _require([IE89_AJAX_POLYFILL_URL, HTML5SHIV_URL], callback); - } else { - callback(); - } - }); - } else { - callback(); - } + if($(placeholder)){ + $(placeholder).html('<' + OC_TAG + ' href="' + href + '" />'); + var newComponent = $(OC_TAG, placeholder); + oc.renderNestedComponent(newComponent, function(){ + callback(newComponent); + }); + } + }); }; - ensureJqueryIsLoaded(oc.renderUnloadedComponents); + oc.ready(oc.renderUnloadedComponents); -})(Handlebars, document, window, true); // jshint ignore:line \ No newline at end of file +})(Handlebars, head, document, window, true); // jshint ignore:line \ No newline at end of file diff --git a/components/oc-client/src/oc-client.min.js b/components/oc-client/src/oc-client.min.js index d8e76728a..9f30732d7 100644 --- a/components/oc-client/src/oc-client.min.js +++ b/components/oc-client/src/oc-client.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r;"undefined"!=typeof window?r=window:"undefined"!=typeof global?r=global:"undefined"!=typeof self&&(r=self),r.jade=e()}}(function(){return function e(r,n,t){function o(a,s){if(!n[a]){if(!r[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[a]={exports:{}};r[a][0].call(u.exports,function(e){var n=r[a][1][e];return o(n?n:e)},u,u.exports,e,r,n,t)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a/g,">").replace(/"/g,""");return r===""+e?e:r},n.rethrow=function a(r,n,t,o){if(!(r instanceof Error))throw r;if(!("undefined"==typeof window&&n||o))throw r.message+=" on line "+t,r;try{o=o||e("fs").readFileSync(n,"utf8")}catch(i){a(r,null,t)}var s=3,c=o.split("\n"),l=Math.max(t-s,0),u=Math.min(c.length,t+s),s=c.slice(l,u).map(function(e,r){var n=r+l+1;return(n==t?" > ":" ")+n+"| "+e}).join("\n");throw r.path=n,r.message=(n||"Jade")+":"+t+"\n"+s+"\n\n"+r.message,r}},{fs:2}],2:[function(){},{}]},{},[1])(1)});var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var r;return e.prototype.toString=function(){return""+this.string},r=e}(),r=function(e){"use strict";function r(e){return s[e]||"&"}function n(e,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}function t(e){return e instanceof a?e.toString():e||0===e?(e=""+e,l.test(e)?e.replace(c,r):e):""}function o(e){return e||0===e?p(e)&&0===e.length?!0:!1:!0}var i={},a=e,s={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},c=/[&<>"'`]/g,l=/[&<>"'`]/;i.extend=n;var u=Object.prototype.toString;i.toString=u;var f=function(e){return"function"==typeof e};f(/x/)&&(f=function(e){return"function"==typeof e&&"[object Function]"===u.call(e)});var f;i.isFunction=f;var p=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===u.call(e):!1};return i.isArray=p,i.escapeExpression=t,i.isEmpty=o,i}(e),n=function(){"use strict";function e(e,r){var t;r&&r.firstLine&&(t=r.firstLine,e+=" - "+t+":"+r.firstColumn);for(var o=Error.prototype.constructor.call(this,e),i=0;i0?e.helpers.each(r,n):t(this):o(r)}),e.registerHelper("each",function(e,r){var n,t=r.fn,o=r.inverse,i=0,a="";if(p(e)&&(e=e.call(this)),r.data&&(n=v(r.data)),e&&"object"==typeof e)if(f(e))for(var s=e.length;s>i;i++)n&&(n.index=i,n.first=0===i,n.last=i===e.length-1),a+=t(e[i],{data:n});else for(var c in e)e.hasOwnProperty(c)&&(n&&(n.key=c,n.index=i,n.first=0===i),a+=t(e[c],{data:n}),i++);return 0===i&&(a=o(this)),a}),e.registerHelper("if",function(e,r){return p(e)&&(e=e.call(this)),!r.hash.includeZero&&!e||a.isEmpty(e)?r.inverse(this):r.fn(this)}),e.registerHelper("unless",function(r,n){return e.helpers["if"].call(this,r,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,r){return p(e)&&(e=e.call(this)),a.isEmpty(e)?void 0:r.fn(e)}),e.registerHelper("log",function(r,n){var t=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(t,r)})}function o(e,r){m.log(e,r)}var i={},a=e,s=r,c="1.3.0";i.VERSION=c;var l=4;i.COMPILER_REVISION=l;var u={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};i.REVISION_CHANGES=u;var f=a.isArray,p=a.isFunction,d=a.toString,h="[object Object]";i.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,r,n){if(d.call(e)===h){if(n||r)throw new s("Arg not supported with multiple helpers");a.extend(this.helpers,e)}else n&&(r.not=n),this.helpers[e]=r},registerPartial:function(e,r){d.call(e)===h?a.extend(this.partials,e):this.partials[e]=r}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,r){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,r)}}};i.logger=m,i.log=o;var v=function(e){var r={};return a.extend(r,e),r};return i.createFrame=v,i}(r,n),o=function(e,r,n){"use strict";function t(e){var r=e&&e[0]||1,n=p;if(r!==n){if(n>r){var t=d[n],o=d[r];throw new f("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+t+") or downgrade your runtime to an older version ("+o+").")}throw new f("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,r){if(!r)throw new f("No environment passed to template");var n=function(e,n,t,o,i,a){var s=r.VM.invokePartial.apply(this,arguments);if(null!=s)return s;if(r.compile){var c={helpers:o,partials:i,data:a};return i[n]=r.compile(e,{data:void 0!==a},r),i[n](t,c)}throw new f("The partial "+n+" could not be compiled when running in runtime-only mode")},t={escapeExpression:u.escapeExpression,invokePartial:n,programs:[],program:function(e,r,n){var t=this.programs[e];return n?t=a(e,r,n):t||(t=this.programs[e]=a(e,r)),t},merge:function(e,r){var n=e||r;return e&&r&&e!==r&&(n={},u.extend(n,r),u.extend(n,e)),n},programWithDepth:r.VM.programWithDepth,noop:r.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var i,a,s=o.partial?o:r;o.partial||(i=o.helpers,a=o.partials);var c=e.call(t,s,n,i,a,o.data);return o.partial||r.VM.checkRevision(t.compilerInfo),c}}function i(e,r,n){var t=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},r.apply(this,[e,o.data||n].concat(t))};return o.program=e,o.depth=t.length,o}function a(e,r,n){var t=function(e,t){return t=t||{},r(e,t.data||n)};return t.program=e,t.depth=0,t}function s(e,r,n,t,o,i){var a={partial:!0,helpers:t,partials:o,data:i};if(void 0===e)throw new f("The partial "+r+" could not be found");return e instanceof Function?e(n,a):void 0}function c(){return""}var l={},u=e,f=r,p=n.COMPILER_REVISION,d=n.REVISION_CHANGES;return l.checkRevision=t,l.template=o,l.programWithDepth=i,l.program=a,l.invokePartial=s,l.noop=c,l}(r,n,t),i=function(e,r,n,t,o){"use strict";var i,a=e,s=r,c=n,l=t,u=o,f=function(){var e=new a.HandlebarsEnvironment;return l.extend(e,a),e.SafeString=s,e.Exception=c,e.Utils=l,e.VM=u,e.template=function(r){return u.template(r,e)},e},p=f();return p.create=f,i=p}(t,e,n,r,o);return i}(),oc=oc||{};!function(e,r,n,t){var o="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js",i="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js",a="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js",s=5e3,c="oc-component",l="Href parameter missing",u="Error loading {0} component",f="Error rendering component: {0}, error: {1}",p="Failed to retrieve the component. Retrying in {0} seconds...".replace("{0}",s/1e3),d="Error loading component: view engine {0} not supported",h="Loading...",m="Component '{0}' correctly rendered",v="Unrendered component found. Trying to retrieve it...",g=[],y="undefined"!=typeof jQuery?jQuery:void 0,w=function(){},j={error:function(e){return console.log(e)},info:function(e){return t?console.log(e):void 0}},b=function(e,r){for(var n=0;n'+h+""),oc.renderByHref(e.attr("href"),function(n,t){return!n&&t&&t.html?void E(e,t,r):j.error(n)})},oc.renderByHref=function(e,r){return""===e?r(f.replace("{1}",l)):void y.ajax({url:e,headers:{"render-mode":"pre-rendered"},crossDomain:!0,async:!0,success:function(e){"pre-rendered"===e.renderMode?x([e.template.src],function(){oc.render(e.template,e.data,function(n,t){return n?r(f.replace("{0}",e.href).replace("{1}",n)):(j.info(m.replace("{0}",e.template.src)),void r(null,{html:t,key:e.template.key,version:e.version}))})}):"rendered"===e.renderMode&&(j.info(m.replace("{0}",e.href)),r(null,{html:y(e.html).html(),version:e.version}))},error:function(){j.error(p),setTimeout(function(){oc.renderByHref(e,r)},s)}})},oc.renderUnloadedComponents=oc.refresh=function(){var e=y(c+"[data-rendered!=true]"),r=function(e,n){j.info(v),oc.renderNestedComponent(y(e[n]),function(){n++,n0&&r(e,0)},oc.setEventListeners=function(e){e.off("reRender"),e.on("reRender",function(e,r){var n=y(e.target);return r&&""!==r&&n.attr("href",r),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")},oc.load=function(e,r,n){if("function"!=typeof n&&(n=w),y(e)){y(e).html("<"+c+' href="'+r+'" />');var t=y(c,e);oc.renderNestedComponent(t,function(){n(t)})}};var O=function(e){y?e():x([a],function(){y=jQuery;var r=n.navigator.userAgent,t=!!r.match(/MSIE 8/),a=!!r.match(/MSIE 9/);t||a?x([i,o],e):e()})};O(oc.renderUnloadedComponents)}(Handlebars,document,window,!0),oc.clientVersion="0.8.3"; \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.jade=e()}}(function(){return function e(t,n,r){function o(i,c){if(!n[i]){if(!t[i]){var l="function"==typeof require&&require;if(!c&&l)return l(i,!0);if(a)return a(i,!0);var s=new Error("Cannot find module '"+i+"'");throw s.code="MODULE_NOT_FOUND",s}var u=n[i]={exports:{}};t[i][0].call(u.exports,function(e){var n=t[i][1][e];return o(n?n:e)},u,u.exports,e,t,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i/g,">").replace(/"/g,""");return t===""+e?e:t},n.rethrow=function i(t,n,r,o){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&n||o))throw t.message+=" on line "+r,t;try{o=o||e("fs").readFileSync(n,"utf8")}catch(a){i(t,null,r)}var c=3,l=o.split("\n"),s=Math.max(r-c,0),u=Math.min(l.length,r+c),c=l.slice(s,u).map(function(e,t){var n=t+s+1;return(n==r?" > ":" ")+n+"| "+e}).join("\n");throw t.path=n,t.message=(n||"Jade")+":"+r+"\n"+c+"\n\n"+t.message,t}},{fs:2}],2:[function(){},{}]},{},[1])(1)});var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var t;return e.prototype.toString=function(){return""+this.string},t=e}(),t=function(e){"use strict";function t(e){return c[e]||"&"}function n(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}function r(e){return e instanceof i?e.toString():e||0===e?(e=""+e,s.test(e)?e.replace(l,t):e):""}function o(e){return e||0===e?d(e)&&0===e.length?!0:!1:!0}var a={},i=e,c={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},l=/[&<>"'`]/g,s=/[&<>"'`]/;a.extend=n;var u=Object.prototype.toString;a.toString=u;var f=function(e){return"function"==typeof e};f(/x/)&&(f=function(e){return"function"==typeof e&&"[object Function]"===u.call(e)});var f;a.isFunction=f;var d=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===u.call(e):!1};return a.isArray=d,a.escapeExpression=r,a.isEmpty=o,a}(e),n=function(){"use strict";function e(e,t){var r;t&&t.firstLine&&(r=t.firstLine,e+=" - "+r+":"+t.firstColumn);for(var o=Error.prototype.constructor.call(this,e),a=0;a0?e.helpers.each(t,n):r(this):o(t)}),e.registerHelper("each",function(e,t){var n,r=t.fn,o=t.inverse,a=0,i="";if(d(e)&&(e=e.call(this)),t.data&&(n=v(t.data)),e&&"object"==typeof e)if(f(e))for(var c=e.length;c>a;a++)n&&(n.index=a,n.first=0===a,n.last=a===e.length-1),i+=r(e[a],{data:n});else for(var l in e)e.hasOwnProperty(l)&&(n&&(n.key=l,n.index=a,n.first=0===a),i+=r(e[l],{data:n}),a++);return 0===a&&(i=o(this)),i}),e.registerHelper("if",function(e,t){return d(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||i.isEmpty(e)?t.inverse(this):t.fn(this)}),e.registerHelper("unless",function(t,n){return e.helpers["if"].call(this,t,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,t){return d(e)&&(e=e.call(this)),i.isEmpty(e)?void 0:t.fn(e)}),e.registerHelper("log",function(t,n){var r=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(r,t)})}function o(e,t){m.log(e,t)}var a={},i=e,c=t,l="1.3.0";a.VERSION=l;var s=4;a.COMPILER_REVISION=s;var u={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};a.REVISION_CHANGES=u;var f=i.isArray,d=i.isFunction,p=i.toString,h="[object Object]";a.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,t,n){if(p.call(e)===h){if(n||t)throw new c("Arg not supported with multiple helpers");i.extend(this.helpers,e)}else n&&(t.not=n),this.helpers[e]=t},registerPartial:function(e,t){p.call(e)===h?i.extend(this.partials,e):this.partials[e]=t}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,t){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,t)}}};a.logger=m,a.log=o;var v=function(e){var t={};return i.extend(t,e),t};return a.createFrame=v,a}(t,n),o=function(e,t,n){"use strict";function r(e){var t=e&&e[0]||1,n=d;if(t!==n){if(n>t){var r=p[n],o=p[t];throw new f("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+r+") or downgrade your runtime to an older version ("+o+").")}throw new f("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,t){if(!t)throw new f("No environment passed to template");var n=function(e,n,r,o,a,i){var c=t.VM.invokePartial.apply(this,arguments);if(null!=c)return c;if(t.compile){var l={helpers:o,partials:a,data:i};return a[n]=t.compile(e,{data:void 0!==i},t),a[n](r,l)}throw new f("The partial "+n+" could not be compiled when running in runtime-only mode")},r={escapeExpression:u.escapeExpression,invokePartial:n,programs:[],program:function(e,t,n){var r=this.programs[e];return n?r=i(e,t,n):r||(r=this.programs[e]=i(e,t)),r},merge:function(e,t){var n=e||t;return e&&t&&e!==t&&(n={},u.extend(n,t),u.extend(n,e)),n},programWithDepth:t.VM.programWithDepth,noop:t.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var a,i,c=o.partial?o:t;o.partial||(a=o.helpers,i=o.partials);var l=e.call(r,c,n,a,i,o.data);return o.partial||t.VM.checkRevision(r.compilerInfo),l}}function a(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},t.apply(this,[e,o.data||n].concat(r))};return o.program=e,o.depth=r.length,o}function i(e,t,n){var r=function(e,r){return r=r||{},t(e,r.data||n)};return r.program=e,r.depth=0,r}function c(e,t,n,r,o,a){var i={partial:!0,helpers:r,partials:o,data:a};if(void 0===e)throw new f("The partial "+t+" could not be found");return e instanceof Function?e(n,i):void 0}function l(){return""}var s={},u=e,f=t,d=n.COMPILER_REVISION,p=n.REVISION_CHANGES;return s.checkRevision=r,s.template=o,s.programWithDepth=a,s.program=i,s.invokePartial=c,s.noop=l,s}(t,n,r),a=function(e,t,n,r,o){"use strict";var a,i=e,c=t,l=n,s=r,u=o,f=function(){var e=new i.HandlebarsEnvironment;return s.extend(e,i),e.SafeString=c,e.Exception=l,e.Utils=s,e.VM=u,e.template=function(t){return u.template(t,e)},e},d=f();return d.create=f,a=d}(r,e,n,t,o);return a}();!function(e,t){"use strict";function n(){}function r(e,t){if(e){"object"==typeof e&&(e=[].slice.call(e));for(var n=0,r=e.length;r>n;n++)t.call(e,e[n],n)}}function o(e,n){var r=Object.prototype.toString.call(n).slice(8,-1);return n!==t&&null!==n&&r===e}function a(e){return o("Function",e)}function i(e){return o("Array",e)}function c(e){var t=e.split("/"),n=t[t.length-1],r=n.indexOf("?");return-1!==r?n.substring(0,r):n}function l(e){e=e||n,e._done||(e(),e._done=1)}function s(e,t,r,o){var a="object"==typeof e?e:{test:e,success:t?i(t)?t:[t]:!1,failure:r?i(r)?r:[r]:!1,callback:o||n},c=!!a.test;return c&&a.success?(a.success.push(a.callback),k.load.apply(null,a.success)):!c&&a.failure?(a.failure.push(a.callback),k.load.apply(null,a.failure)):o(),k}function u(e){var t={};if("object"==typeof e)for(var n in e)e[n]&&(t={name:n,url:e[n]});else t={name:c(e),url:e};var r=M[t.name];return r&&r.url===t.url?r:(M[t.name]=t,t)}function f(e){e=e||M;for(var t in e)if(e.hasOwnProperty(t)&&e[t].state!==C)return!1;return!0}function d(e){e.state=N,r(e.onpreload,function(e){e.call()})}function p(e){e.state===t&&(e.state=I,e.onpreload=[],g({url:e.url,type:"cache"},function(){d(e)}))}function h(){var e=arguments,t=e[e.length-1],n=[].slice.call(e,1),o=n[0];return a(t)||(t=null),i(e[0])?(e[0].push(t),k.load.apply(null,e[0]),k):(o?(r(n,function(e){!a(e)&&e&&p(u(e))}),v(u(e[0]),a(o)?o:function(){k.load.apply(null,n)})):v(u(e[0])),k)}function m(){var e=arguments,t=e[e.length-1],n={};return a(t)||(t=null),i(e[0])?(e[0].push(t),k.load.apply(null,e[0]),k):(r(e,function(e){e!==t&&(e=u(e),n[e.name]=e)}),r(e,function(e){e!==t&&(e=u(e),v(e,function(){f(n)&&l(t)}))}),k)}function v(e,t){return t=t||n,e.state===C?void t():e.state===H?void k.ready(e.name,t):e.state===I?void e.onpreload.push(function(){v(e,t)}):(e.state=H,void g(e,function(){e.state=C,t(),r(T[e.name],function(e){l(e)}),S&&f()&&r(T.ALL,function(e){l(e)})}))}function y(e){e=e||"";var t=e.split("?")[0].split(".");return t[t.length-1].toLowerCase()}function g(t,r){function o(t){t=t||e.event,c.onload=c.onreadystatechange=c.onerror=null,r()}function a(n){n=n||e.event,("load"===n.type||/loaded|complete/.test(c.readyState)&&(!x.documentMode||x.documentMode<9))&&(e.clearTimeout(t.errorTimeout),e.clearTimeout(t.cssTimeout),c.onload=c.onreadystatechange=c.onerror=null,r())}function i(){if(t.state!==C&&t.cssRetries<=20){for(var n=0,r=x.styleSheets.length;r>n;n++)if(x.styleSheets[n].href===c.href)return void a({type:"load"});t.cssRetries++,t.cssTimeout=e.setTimeout(i,250)}}r=r||n;var c,l=y(t.url);"css"===l?(c=x.createElement("link"),c.type="text/"+(t.type||"css"),c.rel="stylesheet",c.href=t.url,t.cssRetries=0,t.cssTimeout=e.setTimeout(i,500)):(c=x.createElement("script"),c.type="text/"+(t.type||"javascript"),c.src=t.url),c.onload=c.onreadystatechange=a,c.onerror=o,c.async=!1,c.defer=!1,t.errorTimeout=e.setTimeout(function(){o({type:"timeout"})},7e3);var s=x.head||x.getElementsByTagName("head")[0];s.insertBefore(c,s.lastChild)}function w(){for(var e=x.getElementsByTagName("script"),t=0,n=e.length;n>t;t++){var r=e[t].getAttribute("data-headjs-load");if(r)return void k.load(r)}}function E(e,t){if(e===x)return S?l(t):O.push(t),k;if(a(e)&&(t=e,e="ALL"),i(e)){var n={};return r(e,function(e){n[e]=M[e],k.ready(e,function(){f(n)&&l(t)})}),k}if("string"!=typeof e||!a(t))return k;var o=M[e];if(o&&o.state===C||"ALL"===e&&f()&&S)return l(t),k;var c=T[e];return c?c.push(t):c=T[e]=[t],k}function b(){return x.body?void(S||(S=!0,w(),r(O,function(e){l(e)}))):(e.clearTimeout(k.readyTimeout),void(k.readyTimeout=e.setTimeout(b,50)))}function j(){x.addEventListener?(x.removeEventListener("DOMContentLoaded",j,!1),b()):"complete"===x.readyState&&(x.detachEvent("onreadystatechange",j),b())}var S,x=e.document,O=[],T={},M={},A="async"in x.createElement("script")||"MozAppearance"in x.documentElement.style||e.opera,L=e.head_conf&&e.head_conf.head||"head",k=e[L]=e[L]||function(){k.ready.apply(null,arguments)},I=1,N=2,H=3,C=4;if("complete"===x.readyState)b();else if(x.addEventListener)x.addEventListener("DOMContentLoaded",j,!1),e.addEventListener("load",b,!1);else{x.attachEvent("onreadystatechange",j),e.attachEvent("onload",b);var R=!1;try{R=!e.frameElement&&x.documentElement}catch(q){}R&&R.doScroll&&!function P(){if(!S){try{R.doScroll("left")}catch(t){return e.clearTimeout(k.readyTimeout),void(k.readyTimeout=e.setTimeout(P,50))}b()}}()}k.load=k.js=A?m:h,k.test=s,k.ready=E,k.ready(x,function(){f()&&r(T.ALL,function(e){l(e)}),k.feature&&k.feature("domloaded",!0)})}(window);var oc=oc||{};!function(e,t,n,r,o){var a="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js",i="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js",c=5e3,l="oc-component",s="Href parameter missing",u="Error loading {0} component",f="Error rendering component: {0}, error: {1}",d="Failed to retrieve the component. Retrying in {0} seconds...".replace("{0}",c/1e3),p="Error loading component: view engine {0} not supported",h="Loading...",m="Component '{0}' correctly rendered",v="Unrendered component found. Trying to retrieve it...",y="undefined"!=typeof jQuery?jQuery:void 0,g=function(){},w=r.navigator.userAgent,E=!!w.match(/MSIE 8/),b=!!w.match(/MSIE 9/),j=!1,S=!1,x=[],O={error:function(e){return console.log(e)},info:function(e){return o?console.log(e):void 0}},T=function(e,t,n){var r=Math.floor(9999999999*Math.random());e.html(t.html),e.attr("id",r),e.attr("data-rendered",!0),e.attr("data-version",t.version),t.key&&(e.attr("data-hash",t.key),oc.setEventListeners(e)),n()};oc.ready=function(e){if(j)return e();if(S)x.push(e);else{S=!0;var n=function(e){E||b?t.load(a,e):e()},r=function(){j=!0,S=!1,e();for(var t=0;t'+h+""),oc.renderByHref(e.attr("href"),function(n,r){return!n&&r&&r.html?void T(e,r,t):O.error(n)})})},oc.renderByHref=function(e,n){oc.ready(function(){return""===e?n(f.replace("{1}",s)):void y.ajax({url:e,headers:{"render-mode":"pre-rendered"},crossDomain:!0,async:!0,success:function(e){if("pre-rendered"===e.renderMode)t.load([e.template.src],function(){oc.render(e.template,e.data,function(t,r){return t?n(f.replace("{0}",e.href).replace("{1}",t)):(O.info(m.replace("{0}",e.template.src)),void n(null,{html:r,key:e.template.key,version:e.version}))})});else if("rendered"===e.renderMode){O.info(m.replace("{0}",e.href));var r=e.html.slice(e.html.indexOf(">")+1),o=r.slice(0,r.indexOf("<"));n(null,{html:o,version:e.version})}},error:function(){O.error(d),setTimeout(function(){oc.renderByHref(e,n)},c)}})})},oc.renderUnloadedComponents=function(){oc.ready(function(){var e=E?"div[data-oc-component=true]":l,t=y(e+"[data-rendered!=true]"),n=function(e,t){O.info(v),oc.renderNestedComponent(y(e[t]),function(){t++,t0&&n(t,0)})},oc.setEventListeners=function(e){oc.ready(function(){e.off("reRender"),e.on("reRender",function(e,t){var n=y(e.target);return t&&""!==t&&n.attr("href",t),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")})},oc.load=function(e,t,n){oc.ready(function(){if("function"!=typeof n&&(n=g),y(e)){y(e).html("<"+l+' href="'+t+'" />');var r=y(l,e);oc.renderNestedComponent(r,function(){n(r)})}})},oc.ready(oc.renderUnloadedComponents)}(Handlebars,head,document,window,!0),oc.clientVersion="0.8.3"; \ No newline at end of file diff --git a/grunt-tasks/jshint.js b/grunt-tasks/jshint.js index c2aa38e34..a8d4d3f14 100644 --- a/grunt-tasks/jshint.js +++ b/grunt-tasks/jshint.js @@ -5,7 +5,7 @@ module.exports = { jshintrc: '.jshintrc', ignores: [ 'node_modules', - 'components/oc-client/src/handlebars.1.3.0.js', + 'components/oc-client/src/head.load.js', 'components/oc-client/src/oc-client.min.js', 'components/oc-client/_package/**/*', 'components/base-component-handlebars/_package/**/*', diff --git a/test/acceptance/client.js b/test/acceptance/client.js index 1e2d9bceb..60639b2be 100644 --- a/test/acceptance/client.js +++ b/test/acceptance/client.js @@ -99,7 +99,7 @@ describe('client', function(){ expect($component.data('rendered')).to.eql(false); }); - it('should contain the component version', function(){ + it('should contain the component url', function(){ expect($component.attr('href')).to.eql('http://localhost:1234/hello-world/~1.0.0'); }); @@ -107,6 +107,41 @@ describe('client', function(){ expect(error).to.eql('Server-side rendering failed'); }); }); + + describe('when client-side failover rendering enabled with ie8=true', function(){ + + var $componentScript, + $clientScript, + error, + options = { ie8: true }; + + before(function(done){ + clientOfflineRegistry.renderComponent('hello-world', options, function(err, html){ + result = html; + error = err; + var $ = cheerio.load(result); + $componentScript = $('script.ocComponent'); + $clientScript = $('script.ocClientScript'); + done(); + }); + }); + + it('should include the client-side rendering script', function(){ + expect($clientScript).to.have.length.above(0); + }); + + it('should include the non rendered scripted component', function(){ + expect($componentScript).to.have.length.above(0); + }); + + it('should contain the component url', function(){ + expect($componentScript.toString()).to.contain('http://localhost:1234/hello-world/~1.0.0'); + }); + + it('should contain the error details', function(){ + expect(error).to.eql('Server-side rendering failed'); + }); + }); }); describe('when server-side rendering an existing component linked to a responsive registry', function(){ From 48c1f42f7471d3273523be5c07b64b1607590c78 Mon Sep 17 00:00:00 2001 From: Matteo Figus Date: Mon, 16 Feb 2015 18:26:50 +0000 Subject: [PATCH 2/4] Some fixes --- .../oc-client/_package/src/oc-client.js | 34 +++++++++++++------ .../oc-client/_package/src/oc-client.min.js | 2 +- components/oc-client/src/oc-client.js | 34 +++++++++++++------ components/oc-client/src/oc-client.min.js | 2 +- 4 files changed, 48 insertions(+), 24 deletions(-) diff --git a/components/oc-client/_package/src/oc-client.js b/components/oc-client/_package/src/oc-client.js index 3923f752f..e8403d422 100644 --- a/components/oc-client/_package/src/oc-client.js +++ b/components/oc-client/_package/src/oc-client.js @@ -8,6 +8,7 @@ var oc = oc || {}; var IE89_AJAX_POLYFILL_URL = 'https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js', JQUERY_URL = 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js', RETRY_INTERVAL = 5000, + POLLING_INTERVAL = 500, OC_TAG = 'oc-component', MESSAGES_ERRORS_HREF_MISSING = 'Href parameter missing', MESSAGES_ERRORS_LOADING_COMPONENT = 'Error loading {0} component', @@ -56,6 +57,7 @@ var oc = oc || {}; $component.html(data.html); $component.attr('id', newId); $component.attr('data-rendered', true); + $component.attr('data-rendering', false); $component.attr('data-version', data.version); if(!!data.key){ @@ -125,16 +127,27 @@ var oc = oc || {}; }; oc.renderNestedComponent = function($component, callback){ - oc.ready(function(){ - $component.html('
' + MESSAGES_LOADING_COMPONENT + '
'); + oc.ready(function(){ + var dataRendering = $component.attr('data-rendering'), + dataRendered = $component.attr('data-rendered'), + isRendering = typeof(dataRendering) === 'boolean' ? dataRendering : (dataRendering === 'true'), + isRendered = typeof(dataRendered) === 'boolean' ? dataRendered : (dataRendered === 'true'); - oc.renderByHref($component.attr('href'), function(err, data){ - if(err || !data || !data.html){ - return logger.error(err); - } + if(!isRendering && !isRendered){ + logger.info(MESSAGES_RETRIEVING); + $component.attr('data-rendering', true); + $component.html('
' + MESSAGES_LOADING_COMPONENT + '
'); - processHtml($component, data, callback); - }); + oc.renderByHref($component.attr('href'), function(err, data){ + if(err || !data || !data.html){ + return logger.error(err); + } + + processHtml($component, data, callback); + }); + } else { + setTimeout(callback, POLLING_INTERVAL); + } }); }; @@ -165,8 +178,8 @@ var oc = oc || {}; logger.info(MESSAGES_RENDERED.replace('{0}', apiResponse.href)); var innerHtmlPlusEnding = apiResponse.html.slice(apiResponse.html.indexOf('>') + 1), - innerHtml = innerHtmlPlusEnding.slice(0, innerHtmlPlusEnding.indexOf('<')); - + innerHtml = innerHtmlPlusEnding.slice(0, innerHtmlPlusEnding.lastIndexOf('<')); + callback(null, { html: innerHtml, version: apiResponse.version @@ -192,7 +205,6 @@ var oc = oc || {}; $unloadedComponents = $(selector + '[data-rendered!=true]'); var renderUnloadedComponent = function($unloadedComponents, i){ - logger.info(MESSAGES_RETRIEVING); oc.renderNestedComponent($($unloadedComponents[i]), function(){ i++; if(i < $unloadedComponents.length){ diff --git a/components/oc-client/_package/src/oc-client.min.js b/components/oc-client/_package/src/oc-client.min.js index 9f30732d7..b616f5a49 100644 --- a/components/oc-client/_package/src/oc-client.min.js +++ b/components/oc-client/_package/src/oc-client.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.jade=e()}}(function(){return function e(t,n,r){function o(i,c){if(!n[i]){if(!t[i]){var l="function"==typeof require&&require;if(!c&&l)return l(i,!0);if(a)return a(i,!0);var s=new Error("Cannot find module '"+i+"'");throw s.code="MODULE_NOT_FOUND",s}var u=n[i]={exports:{}};t[i][0].call(u.exports,function(e){var n=t[i][1][e];return o(n?n:e)},u,u.exports,e,t,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i/g,">").replace(/"/g,""");return t===""+e?e:t},n.rethrow=function i(t,n,r,o){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&n||o))throw t.message+=" on line "+r,t;try{o=o||e("fs").readFileSync(n,"utf8")}catch(a){i(t,null,r)}var c=3,l=o.split("\n"),s=Math.max(r-c,0),u=Math.min(l.length,r+c),c=l.slice(s,u).map(function(e,t){var n=t+s+1;return(n==r?" > ":" ")+n+"| "+e}).join("\n");throw t.path=n,t.message=(n||"Jade")+":"+r+"\n"+c+"\n\n"+t.message,t}},{fs:2}],2:[function(){},{}]},{},[1])(1)});var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var t;return e.prototype.toString=function(){return""+this.string},t=e}(),t=function(e){"use strict";function t(e){return c[e]||"&"}function n(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}function r(e){return e instanceof i?e.toString():e||0===e?(e=""+e,s.test(e)?e.replace(l,t):e):""}function o(e){return e||0===e?d(e)&&0===e.length?!0:!1:!0}var a={},i=e,c={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},l=/[&<>"'`]/g,s=/[&<>"'`]/;a.extend=n;var u=Object.prototype.toString;a.toString=u;var f=function(e){return"function"==typeof e};f(/x/)&&(f=function(e){return"function"==typeof e&&"[object Function]"===u.call(e)});var f;a.isFunction=f;var d=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===u.call(e):!1};return a.isArray=d,a.escapeExpression=r,a.isEmpty=o,a}(e),n=function(){"use strict";function e(e,t){var r;t&&t.firstLine&&(r=t.firstLine,e+=" - "+r+":"+t.firstColumn);for(var o=Error.prototype.constructor.call(this,e),a=0;a0?e.helpers.each(t,n):r(this):o(t)}),e.registerHelper("each",function(e,t){var n,r=t.fn,o=t.inverse,a=0,i="";if(d(e)&&(e=e.call(this)),t.data&&(n=v(t.data)),e&&"object"==typeof e)if(f(e))for(var c=e.length;c>a;a++)n&&(n.index=a,n.first=0===a,n.last=a===e.length-1),i+=r(e[a],{data:n});else for(var l in e)e.hasOwnProperty(l)&&(n&&(n.key=l,n.index=a,n.first=0===a),i+=r(e[l],{data:n}),a++);return 0===a&&(i=o(this)),i}),e.registerHelper("if",function(e,t){return d(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||i.isEmpty(e)?t.inverse(this):t.fn(this)}),e.registerHelper("unless",function(t,n){return e.helpers["if"].call(this,t,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,t){return d(e)&&(e=e.call(this)),i.isEmpty(e)?void 0:t.fn(e)}),e.registerHelper("log",function(t,n){var r=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(r,t)})}function o(e,t){m.log(e,t)}var a={},i=e,c=t,l="1.3.0";a.VERSION=l;var s=4;a.COMPILER_REVISION=s;var u={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};a.REVISION_CHANGES=u;var f=i.isArray,d=i.isFunction,p=i.toString,h="[object Object]";a.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,t,n){if(p.call(e)===h){if(n||t)throw new c("Arg not supported with multiple helpers");i.extend(this.helpers,e)}else n&&(t.not=n),this.helpers[e]=t},registerPartial:function(e,t){p.call(e)===h?i.extend(this.partials,e):this.partials[e]=t}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,t){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,t)}}};a.logger=m,a.log=o;var v=function(e){var t={};return i.extend(t,e),t};return a.createFrame=v,a}(t,n),o=function(e,t,n){"use strict";function r(e){var t=e&&e[0]||1,n=d;if(t!==n){if(n>t){var r=p[n],o=p[t];throw new f("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+r+") or downgrade your runtime to an older version ("+o+").")}throw new f("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,t){if(!t)throw new f("No environment passed to template");var n=function(e,n,r,o,a,i){var c=t.VM.invokePartial.apply(this,arguments);if(null!=c)return c;if(t.compile){var l={helpers:o,partials:a,data:i};return a[n]=t.compile(e,{data:void 0!==i},t),a[n](r,l)}throw new f("The partial "+n+" could not be compiled when running in runtime-only mode")},r={escapeExpression:u.escapeExpression,invokePartial:n,programs:[],program:function(e,t,n){var r=this.programs[e];return n?r=i(e,t,n):r||(r=this.programs[e]=i(e,t)),r},merge:function(e,t){var n=e||t;return e&&t&&e!==t&&(n={},u.extend(n,t),u.extend(n,e)),n},programWithDepth:t.VM.programWithDepth,noop:t.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var a,i,c=o.partial?o:t;o.partial||(a=o.helpers,i=o.partials);var l=e.call(r,c,n,a,i,o.data);return o.partial||t.VM.checkRevision(r.compilerInfo),l}}function a(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},t.apply(this,[e,o.data||n].concat(r))};return o.program=e,o.depth=r.length,o}function i(e,t,n){var r=function(e,r){return r=r||{},t(e,r.data||n)};return r.program=e,r.depth=0,r}function c(e,t,n,r,o,a){var i={partial:!0,helpers:r,partials:o,data:a};if(void 0===e)throw new f("The partial "+t+" could not be found");return e instanceof Function?e(n,i):void 0}function l(){return""}var s={},u=e,f=t,d=n.COMPILER_REVISION,p=n.REVISION_CHANGES;return s.checkRevision=r,s.template=o,s.programWithDepth=a,s.program=i,s.invokePartial=c,s.noop=l,s}(t,n,r),a=function(e,t,n,r,o){"use strict";var a,i=e,c=t,l=n,s=r,u=o,f=function(){var e=new i.HandlebarsEnvironment;return s.extend(e,i),e.SafeString=c,e.Exception=l,e.Utils=s,e.VM=u,e.template=function(t){return u.template(t,e)},e},d=f();return d.create=f,a=d}(r,e,n,t,o);return a}();!function(e,t){"use strict";function n(){}function r(e,t){if(e){"object"==typeof e&&(e=[].slice.call(e));for(var n=0,r=e.length;r>n;n++)t.call(e,e[n],n)}}function o(e,n){var r=Object.prototype.toString.call(n).slice(8,-1);return n!==t&&null!==n&&r===e}function a(e){return o("Function",e)}function i(e){return o("Array",e)}function c(e){var t=e.split("/"),n=t[t.length-1],r=n.indexOf("?");return-1!==r?n.substring(0,r):n}function l(e){e=e||n,e._done||(e(),e._done=1)}function s(e,t,r,o){var a="object"==typeof e?e:{test:e,success:t?i(t)?t:[t]:!1,failure:r?i(r)?r:[r]:!1,callback:o||n},c=!!a.test;return c&&a.success?(a.success.push(a.callback),k.load.apply(null,a.success)):!c&&a.failure?(a.failure.push(a.callback),k.load.apply(null,a.failure)):o(),k}function u(e){var t={};if("object"==typeof e)for(var n in e)e[n]&&(t={name:n,url:e[n]});else t={name:c(e),url:e};var r=M[t.name];return r&&r.url===t.url?r:(M[t.name]=t,t)}function f(e){e=e||M;for(var t in e)if(e.hasOwnProperty(t)&&e[t].state!==C)return!1;return!0}function d(e){e.state=N,r(e.onpreload,function(e){e.call()})}function p(e){e.state===t&&(e.state=I,e.onpreload=[],g({url:e.url,type:"cache"},function(){d(e)}))}function h(){var e=arguments,t=e[e.length-1],n=[].slice.call(e,1),o=n[0];return a(t)||(t=null),i(e[0])?(e[0].push(t),k.load.apply(null,e[0]),k):(o?(r(n,function(e){!a(e)&&e&&p(u(e))}),v(u(e[0]),a(o)?o:function(){k.load.apply(null,n)})):v(u(e[0])),k)}function m(){var e=arguments,t=e[e.length-1],n={};return a(t)||(t=null),i(e[0])?(e[0].push(t),k.load.apply(null,e[0]),k):(r(e,function(e){e!==t&&(e=u(e),n[e.name]=e)}),r(e,function(e){e!==t&&(e=u(e),v(e,function(){f(n)&&l(t)}))}),k)}function v(e,t){return t=t||n,e.state===C?void t():e.state===H?void k.ready(e.name,t):e.state===I?void e.onpreload.push(function(){v(e,t)}):(e.state=H,void g(e,function(){e.state=C,t(),r(T[e.name],function(e){l(e)}),S&&f()&&r(T.ALL,function(e){l(e)})}))}function y(e){e=e||"";var t=e.split("?")[0].split(".");return t[t.length-1].toLowerCase()}function g(t,r){function o(t){t=t||e.event,c.onload=c.onreadystatechange=c.onerror=null,r()}function a(n){n=n||e.event,("load"===n.type||/loaded|complete/.test(c.readyState)&&(!x.documentMode||x.documentMode<9))&&(e.clearTimeout(t.errorTimeout),e.clearTimeout(t.cssTimeout),c.onload=c.onreadystatechange=c.onerror=null,r())}function i(){if(t.state!==C&&t.cssRetries<=20){for(var n=0,r=x.styleSheets.length;r>n;n++)if(x.styleSheets[n].href===c.href)return void a({type:"load"});t.cssRetries++,t.cssTimeout=e.setTimeout(i,250)}}r=r||n;var c,l=y(t.url);"css"===l?(c=x.createElement("link"),c.type="text/"+(t.type||"css"),c.rel="stylesheet",c.href=t.url,t.cssRetries=0,t.cssTimeout=e.setTimeout(i,500)):(c=x.createElement("script"),c.type="text/"+(t.type||"javascript"),c.src=t.url),c.onload=c.onreadystatechange=a,c.onerror=o,c.async=!1,c.defer=!1,t.errorTimeout=e.setTimeout(function(){o({type:"timeout"})},7e3);var s=x.head||x.getElementsByTagName("head")[0];s.insertBefore(c,s.lastChild)}function w(){for(var e=x.getElementsByTagName("script"),t=0,n=e.length;n>t;t++){var r=e[t].getAttribute("data-headjs-load");if(r)return void k.load(r)}}function E(e,t){if(e===x)return S?l(t):O.push(t),k;if(a(e)&&(t=e,e="ALL"),i(e)){var n={};return r(e,function(e){n[e]=M[e],k.ready(e,function(){f(n)&&l(t)})}),k}if("string"!=typeof e||!a(t))return k;var o=M[e];if(o&&o.state===C||"ALL"===e&&f()&&S)return l(t),k;var c=T[e];return c?c.push(t):c=T[e]=[t],k}function b(){return x.body?void(S||(S=!0,w(),r(O,function(e){l(e)}))):(e.clearTimeout(k.readyTimeout),void(k.readyTimeout=e.setTimeout(b,50)))}function j(){x.addEventListener?(x.removeEventListener("DOMContentLoaded",j,!1),b()):"complete"===x.readyState&&(x.detachEvent("onreadystatechange",j),b())}var S,x=e.document,O=[],T={},M={},A="async"in x.createElement("script")||"MozAppearance"in x.documentElement.style||e.opera,L=e.head_conf&&e.head_conf.head||"head",k=e[L]=e[L]||function(){k.ready.apply(null,arguments)},I=1,N=2,H=3,C=4;if("complete"===x.readyState)b();else if(x.addEventListener)x.addEventListener("DOMContentLoaded",j,!1),e.addEventListener("load",b,!1);else{x.attachEvent("onreadystatechange",j),e.attachEvent("onload",b);var R=!1;try{R=!e.frameElement&&x.documentElement}catch(q){}R&&R.doScroll&&!function P(){if(!S){try{R.doScroll("left")}catch(t){return e.clearTimeout(k.readyTimeout),void(k.readyTimeout=e.setTimeout(P,50))}b()}}()}k.load=k.js=A?m:h,k.test=s,k.ready=E,k.ready(x,function(){f()&&r(T.ALL,function(e){l(e)}),k.feature&&k.feature("domloaded",!0)})}(window);var oc=oc||{};!function(e,t,n,r,o){var a="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js",i="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js",c=5e3,l="oc-component",s="Href parameter missing",u="Error loading {0} component",f="Error rendering component: {0}, error: {1}",d="Failed to retrieve the component. Retrying in {0} seconds...".replace("{0}",c/1e3),p="Error loading component: view engine {0} not supported",h="Loading...",m="Component '{0}' correctly rendered",v="Unrendered component found. Trying to retrieve it...",y="undefined"!=typeof jQuery?jQuery:void 0,g=function(){},w=r.navigator.userAgent,E=!!w.match(/MSIE 8/),b=!!w.match(/MSIE 9/),j=!1,S=!1,x=[],O={error:function(e){return console.log(e)},info:function(e){return o?console.log(e):void 0}},T=function(e,t,n){var r=Math.floor(9999999999*Math.random());e.html(t.html),e.attr("id",r),e.attr("data-rendered",!0),e.attr("data-version",t.version),t.key&&(e.attr("data-hash",t.key),oc.setEventListeners(e)),n()};oc.ready=function(e){if(j)return e();if(S)x.push(e);else{S=!0;var n=function(e){E||b?t.load(a,e):e()},r=function(){j=!0,S=!1,e();for(var t=0;t'+h+""),oc.renderByHref(e.attr("href"),function(n,r){return!n&&r&&r.html?void T(e,r,t):O.error(n)})})},oc.renderByHref=function(e,n){oc.ready(function(){return""===e?n(f.replace("{1}",s)):void y.ajax({url:e,headers:{"render-mode":"pre-rendered"},crossDomain:!0,async:!0,success:function(e){if("pre-rendered"===e.renderMode)t.load([e.template.src],function(){oc.render(e.template,e.data,function(t,r){return t?n(f.replace("{0}",e.href).replace("{1}",t)):(O.info(m.replace("{0}",e.template.src)),void n(null,{html:r,key:e.template.key,version:e.version}))})});else if("rendered"===e.renderMode){O.info(m.replace("{0}",e.href));var r=e.html.slice(e.html.indexOf(">")+1),o=r.slice(0,r.indexOf("<"));n(null,{html:o,version:e.version})}},error:function(){O.error(d),setTimeout(function(){oc.renderByHref(e,n)},c)}})})},oc.renderUnloadedComponents=function(){oc.ready(function(){var e=E?"div[data-oc-component=true]":l,t=y(e+"[data-rendered!=true]"),n=function(e,t){O.info(v),oc.renderNestedComponent(y(e[t]),function(){t++,t0&&n(t,0)})},oc.setEventListeners=function(e){oc.ready(function(){e.off("reRender"),e.on("reRender",function(e,t){var n=y(e.target);return t&&""!==t&&n.attr("href",t),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")})},oc.load=function(e,t,n){oc.ready(function(){if("function"!=typeof n&&(n=g),y(e)){y(e).html("<"+l+' href="'+t+'" />');var r=y(l,e);oc.renderNestedComponent(r,function(){n(r)})}})},oc.ready(oc.renderUnloadedComponents)}(Handlebars,head,document,window,!0),oc.clientVersion="0.8.3"; \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.jade=e()}}(function(){return function e(t,n,r){function o(i,c){if(!n[i]){if(!t[i]){var l="function"==typeof require&&require;if(!c&&l)return l(i,!0);if(a)return a(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var s=n[i]={exports:{}};t[i][0].call(s.exports,function(e){var n=t[i][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i/g,">").replace(/"/g,""");return t===""+e?e:t},n.rethrow=function i(t,n,r,o){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&n||o))throw t.message+=" on line "+r,t;try{o=o||e("fs").readFileSync(n,"utf8")}catch(a){i(t,null,r)}var c=3,l=o.split("\n"),u=Math.max(r-c,0),s=Math.min(l.length,r+c),c=l.slice(u,s).map(function(e,t){var n=t+u+1;return(n==r?" > ":" ")+n+"| "+e}).join("\n");throw t.path=n,t.message=(n||"Jade")+":"+r+"\n"+c+"\n\n"+t.message,t}},{fs:2}],2:[function(){},{}]},{},[1])(1)});var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var t;return e.prototype.toString=function(){return""+this.string},t=e}(),t=function(e){"use strict";function t(e){return c[e]||"&"}function n(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}function r(e){return e instanceof i?e.toString():e||0===e?(e=""+e,u.test(e)?e.replace(l,t):e):""}function o(e){return e||0===e?d(e)&&0===e.length?!0:!1:!0}var a={},i=e,c={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},l=/[&<>"'`]/g,u=/[&<>"'`]/;a.extend=n;var s=Object.prototype.toString;a.toString=s;var f=function(e){return"function"==typeof e};f(/x/)&&(f=function(e){return"function"==typeof e&&"[object Function]"===s.call(e)});var f;a.isFunction=f;var d=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===s.call(e):!1};return a.isArray=d,a.escapeExpression=r,a.isEmpty=o,a}(e),n=function(){"use strict";function e(e,t){var r;t&&t.firstLine&&(r=t.firstLine,e+=" - "+r+":"+t.firstColumn);for(var o=Error.prototype.constructor.call(this,e),a=0;a0?e.helpers.each(t,n):r(this):o(t)}),e.registerHelper("each",function(e,t){var n,r=t.fn,o=t.inverse,a=0,i="";if(d(e)&&(e=e.call(this)),t.data&&(n=v(t.data)),e&&"object"==typeof e)if(f(e))for(var c=e.length;c>a;a++)n&&(n.index=a,n.first=0===a,n.last=a===e.length-1),i+=r(e[a],{data:n});else for(var l in e)e.hasOwnProperty(l)&&(n&&(n.key=l,n.index=a,n.first=0===a),i+=r(e[l],{data:n}),a++);return 0===a&&(i=o(this)),i}),e.registerHelper("if",function(e,t){return d(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||i.isEmpty(e)?t.inverse(this):t.fn(this)}),e.registerHelper("unless",function(t,n){return e.helpers["if"].call(this,t,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,t){return d(e)&&(e=e.call(this)),i.isEmpty(e)?void 0:t.fn(e)}),e.registerHelper("log",function(t,n){var r=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(r,t)})}function o(e,t){m.log(e,t)}var a={},i=e,c=t,l="1.3.0";a.VERSION=l;var u=4;a.COMPILER_REVISION=u;var s={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};a.REVISION_CHANGES=s;var f=i.isArray,d=i.isFunction,p=i.toString,h="[object Object]";a.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,t,n){if(p.call(e)===h){if(n||t)throw new c("Arg not supported with multiple helpers");i.extend(this.helpers,e)}else n&&(t.not=n),this.helpers[e]=t},registerPartial:function(e,t){p.call(e)===h?i.extend(this.partials,e):this.partials[e]=t}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,t){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,t)}}};a.logger=m,a.log=o;var v=function(e){var t={};return i.extend(t,e),t};return a.createFrame=v,a}(t,n),o=function(e,t,n){"use strict";function r(e){var t=e&&e[0]||1,n=d;if(t!==n){if(n>t){var r=p[n],o=p[t];throw new f("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+r+") or downgrade your runtime to an older version ("+o+").")}throw new f("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,t){if(!t)throw new f("No environment passed to template");var n=function(e,n,r,o,a,i){var c=t.VM.invokePartial.apply(this,arguments);if(null!=c)return c;if(t.compile){var l={helpers:o,partials:a,data:i};return a[n]=t.compile(e,{data:void 0!==i},t),a[n](r,l)}throw new f("The partial "+n+" could not be compiled when running in runtime-only mode")},r={escapeExpression:s.escapeExpression,invokePartial:n,programs:[],program:function(e,t,n){var r=this.programs[e];return n?r=i(e,t,n):r||(r=this.programs[e]=i(e,t)),r},merge:function(e,t){var n=e||t;return e&&t&&e!==t&&(n={},s.extend(n,t),s.extend(n,e)),n},programWithDepth:t.VM.programWithDepth,noop:t.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var a,i,c=o.partial?o:t;o.partial||(a=o.helpers,i=o.partials);var l=e.call(r,c,n,a,i,o.data);return o.partial||t.VM.checkRevision(r.compilerInfo),l}}function a(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},t.apply(this,[e,o.data||n].concat(r))};return o.program=e,o.depth=r.length,o}function i(e,t,n){var r=function(e,r){return r=r||{},t(e,r.data||n)};return r.program=e,r.depth=0,r}function c(e,t,n,r,o,a){var i={partial:!0,helpers:r,partials:o,data:a};if(void 0===e)throw new f("The partial "+t+" could not be found");return e instanceof Function?e(n,i):void 0}function l(){return""}var u={},s=e,f=t,d=n.COMPILER_REVISION,p=n.REVISION_CHANGES;return u.checkRevision=r,u.template=o,u.programWithDepth=a,u.program=i,u.invokePartial=c,u.noop=l,u}(t,n,r),a=function(e,t,n,r,o){"use strict";var a,i=e,c=t,l=n,u=r,s=o,f=function(){var e=new i.HandlebarsEnvironment;return u.extend(e,i),e.SafeString=c,e.Exception=l,e.Utils=u,e.VM=s,e.template=function(t){return s.template(t,e)},e},d=f();return d.create=f,a=d}(r,e,n,t,o);return a}();!function(e,t){"use strict";function n(){}function r(e,t){if(e){"object"==typeof e&&(e=[].slice.call(e));for(var n=0,r=e.length;r>n;n++)t.call(e,e[n],n)}}function o(e,n){var r=Object.prototype.toString.call(n).slice(8,-1);return n!==t&&null!==n&&r===e}function a(e){return o("Function",e)}function i(e){return o("Array",e)}function c(e){var t=e.split("/"),n=t[t.length-1],r=n.indexOf("?");return-1!==r?n.substring(0,r):n}function l(e){e=e||n,e._done||(e(),e._done=1)}function u(e,t,r,o){var a="object"==typeof e?e:{test:e,success:t?i(t)?t:[t]:!1,failure:r?i(r)?r:[r]:!1,callback:o||n},c=!!a.test;return c&&a.success?(a.success.push(a.callback),L.load.apply(null,a.success)):!c&&a.failure?(a.failure.push(a.callback),L.load.apply(null,a.failure)):o(),L}function s(e){var t={};if("object"==typeof e)for(var n in e)e[n]&&(t={name:n,url:e[n]});else t={name:c(e),url:e};var r=M[t.name];return r&&r.url===t.url?r:(M[t.name]=t,t)}function f(e){e=e||M;for(var t in e)if(e.hasOwnProperty(t)&&e[t].state!==C)return!1;return!0}function d(e){e.state=N,r(e.onpreload,function(e){e.call()})}function p(e){e.state===t&&(e.state=k,e.onpreload=[],g({url:e.url,type:"cache"},function(){d(e)}))}function h(){var e=arguments,t=e[e.length-1],n=[].slice.call(e,1),o=n[0];return a(t)||(t=null),i(e[0])?(e[0].push(t),L.load.apply(null,e[0]),L):(o?(r(n,function(e){!a(e)&&e&&p(s(e))}),v(s(e[0]),a(o)?o:function(){L.load.apply(null,n)})):v(s(e[0])),L)}function m(){var e=arguments,t=e[e.length-1],n={};return a(t)||(t=null),i(e[0])?(e[0].push(t),L.load.apply(null,e[0]),L):(r(e,function(e){e!==t&&(e=s(e),n[e.name]=e)}),r(e,function(e){e!==t&&(e=s(e),v(e,function(){f(n)&&l(t)}))}),L)}function v(e,t){return t=t||n,e.state===C?void t():e.state===H?void L.ready(e.name,t):e.state===k?void e.onpreload.push(function(){v(e,t)}):(e.state=H,void g(e,function(){e.state=C,t(),r(T[e.name],function(e){l(e)}),S&&f()&&r(T.ALL,function(e){l(e)})}))}function y(e){e=e||"";var t=e.split("?")[0].split(".");return t[t.length-1].toLowerCase()}function g(t,r){function o(t){t=t||e.event,c.onload=c.onreadystatechange=c.onerror=null,r()}function a(n){n=n||e.event,("load"===n.type||/loaded|complete/.test(c.readyState)&&(!x.documentMode||x.documentMode<9))&&(e.clearTimeout(t.errorTimeout),e.clearTimeout(t.cssTimeout),c.onload=c.onreadystatechange=c.onerror=null,r())}function i(){if(t.state!==C&&t.cssRetries<=20){for(var n=0,r=x.styleSheets.length;r>n;n++)if(x.styleSheets[n].href===c.href)return void a({type:"load"});t.cssRetries++,t.cssTimeout=e.setTimeout(i,250)}}r=r||n;var c,l=y(t.url);"css"===l?(c=x.createElement("link"),c.type="text/"+(t.type||"css"),c.rel="stylesheet",c.href=t.url,t.cssRetries=0,t.cssTimeout=e.setTimeout(i,500)):(c=x.createElement("script"),c.type="text/"+(t.type||"javascript"),c.src=t.url),c.onload=c.onreadystatechange=a,c.onerror=o,c.async=!1,c.defer=!1,t.errorTimeout=e.setTimeout(function(){o({type:"timeout"})},7e3);var u=x.head||x.getElementsByTagName("head")[0];u.insertBefore(c,u.lastChild)}function w(){for(var e=x.getElementsByTagName("script"),t=0,n=e.length;n>t;t++){var r=e[t].getAttribute("data-headjs-load");if(r)return void L.load(r)}}function b(e,t){if(e===x)return S?l(t):O.push(t),L;if(a(e)&&(t=e,e="ALL"),i(e)){var n={};return r(e,function(e){n[e]=M[e],L.ready(e,function(){f(n)&&l(t)})}),L}if("string"!=typeof e||!a(t))return L;var o=M[e];if(o&&o.state===C||"ALL"===e&&f()&&S)return l(t),L;var c=T[e];return c?c.push(t):c=T[e]=[t],L}function E(){return x.body?void(S||(S=!0,w(),r(O,function(e){l(e)}))):(e.clearTimeout(L.readyTimeout),void(L.readyTimeout=e.setTimeout(E,50)))}function j(){x.addEventListener?(x.removeEventListener("DOMContentLoaded",j,!1),E()):"complete"===x.readyState&&(x.detachEvent("onreadystatechange",j),E())}var S,x=e.document,O=[],T={},M={},A="async"in x.createElement("script")||"MozAppearance"in x.documentElement.style||e.opera,I=e.head_conf&&e.head_conf.head||"head",L=e[I]=e[I]||function(){L.ready.apply(null,arguments)},k=1,N=2,H=3,C=4;if("complete"===x.readyState)E();else if(x.addEventListener)x.addEventListener("DOMContentLoaded",j,!1),e.addEventListener("load",E,!1);else{x.attachEvent("onreadystatechange",j),e.attachEvent("onload",E);var R=!1;try{R=!e.frameElement&&x.documentElement}catch(q){}R&&R.doScroll&&!function P(){if(!S){try{R.doScroll("left")}catch(t){return e.clearTimeout(L.readyTimeout),void(L.readyTimeout=e.setTimeout(P,50))}E()}}()}L.load=L.js=A?m:h,L.test=u,L.ready=b,L.ready(x,function(){f()&&r(T.ALL,function(e){l(e)}),L.feature&&L.feature("domloaded",!0)})}(window);var oc=oc||{};!function(e,t,n,r,o){var a="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js",i="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js",c=5e3,l=500,u="oc-component",s="Href parameter missing",f="Error loading {0} component",d="Error rendering component: {0}, error: {1}",p="Failed to retrieve the component. Retrying in {0} seconds...".replace("{0}",c/1e3),h="Error loading component: view engine {0} not supported",m="Loading...",v="Component '{0}' correctly rendered",y="Unrendered component found. Trying to retrieve it...",g="undefined"!=typeof jQuery?jQuery:void 0,w=function(){},b=r.navigator.userAgent,E=!!b.match(/MSIE 8/),j=!!b.match(/MSIE 9/),S=!1,x=!1,O=[],T={error:function(e){return console.log(e)},info:function(e){return o?console.log(e):void 0}},M=function(e,t,n){var r=Math.floor(9999999999*Math.random());e.html(t.html),e.attr("id",r),e.attr("data-rendered",!0),e.attr("data-rendering",!1),e.attr("data-version",t.version),t.key&&(e.attr("data-hash",t.key),oc.setEventListeners(e)),n()};oc.ready=function(e){if(S)return e();if(x)O.push(e);else{x=!0;var n=function(e){E||j?t.load(a,e):e()},r=function(){S=!0,x=!1,e();for(var t=0;t'+m+""),oc.renderByHref(e.attr("href"),function(n,r){return!n&&r&&r.html?void M(e,r,t):T.error(n)}))})},oc.renderByHref=function(e,n){oc.ready(function(){return""===e?n(d.replace("{1}",s)):void g.ajax({url:e,headers:{"render-mode":"pre-rendered"},crossDomain:!0,async:!0,success:function(e){if("pre-rendered"===e.renderMode)t.load([e.template.src],function(){oc.render(e.template,e.data,function(t,r){return t?n(d.replace("{0}",e.href).replace("{1}",t)):(T.info(v.replace("{0}",e.template.src)),void n(null,{html:r,key:e.template.key,version:e.version}))})});else if("rendered"===e.renderMode){T.info(v.replace("{0}",e.href));var r=e.html.slice(e.html.indexOf(">")+1),o=r.slice(0,r.lastIndexOf("<"));n(null,{html:o,version:e.version})}},error:function(){T.error(p),setTimeout(function(){oc.renderByHref(e,n)},c)}})})},oc.renderUnloadedComponents=function(){oc.ready(function(){var e=E?"div[data-oc-component=true]":u,t=g(e+"[data-rendered!=true]"),n=function(e,t){oc.renderNestedComponent(g(e[t]),function(){t++,t0&&n(t,0)})},oc.setEventListeners=function(e){oc.ready(function(){e.off("reRender"),e.on("reRender",function(e,t){var n=g(e.target);return t&&""!==t&&n.attr("href",t),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")})},oc.load=function(e,t,n){oc.ready(function(){if("function"!=typeof n&&(n=w),g(e)){g(e).html("<"+u+' href="'+t+'" />');var r=g(u,e);oc.renderNestedComponent(r,function(){n(r)})}})},oc.ready(oc.renderUnloadedComponents)}(Handlebars,head,document,window,!0),oc.clientVersion="0.8.3"; \ No newline at end of file diff --git a/components/oc-client/src/oc-client.js b/components/oc-client/src/oc-client.js index 3923f752f..e8403d422 100644 --- a/components/oc-client/src/oc-client.js +++ b/components/oc-client/src/oc-client.js @@ -8,6 +8,7 @@ var oc = oc || {}; var IE89_AJAX_POLYFILL_URL = 'https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js', JQUERY_URL = 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js', RETRY_INTERVAL = 5000, + POLLING_INTERVAL = 500, OC_TAG = 'oc-component', MESSAGES_ERRORS_HREF_MISSING = 'Href parameter missing', MESSAGES_ERRORS_LOADING_COMPONENT = 'Error loading {0} component', @@ -56,6 +57,7 @@ var oc = oc || {}; $component.html(data.html); $component.attr('id', newId); $component.attr('data-rendered', true); + $component.attr('data-rendering', false); $component.attr('data-version', data.version); if(!!data.key){ @@ -125,16 +127,27 @@ var oc = oc || {}; }; oc.renderNestedComponent = function($component, callback){ - oc.ready(function(){ - $component.html('
' + MESSAGES_LOADING_COMPONENT + '
'); + oc.ready(function(){ + var dataRendering = $component.attr('data-rendering'), + dataRendered = $component.attr('data-rendered'), + isRendering = typeof(dataRendering) === 'boolean' ? dataRendering : (dataRendering === 'true'), + isRendered = typeof(dataRendered) === 'boolean' ? dataRendered : (dataRendered === 'true'); - oc.renderByHref($component.attr('href'), function(err, data){ - if(err || !data || !data.html){ - return logger.error(err); - } + if(!isRendering && !isRendered){ + logger.info(MESSAGES_RETRIEVING); + $component.attr('data-rendering', true); + $component.html('
' + MESSAGES_LOADING_COMPONENT + '
'); - processHtml($component, data, callback); - }); + oc.renderByHref($component.attr('href'), function(err, data){ + if(err || !data || !data.html){ + return logger.error(err); + } + + processHtml($component, data, callback); + }); + } else { + setTimeout(callback, POLLING_INTERVAL); + } }); }; @@ -165,8 +178,8 @@ var oc = oc || {}; logger.info(MESSAGES_RENDERED.replace('{0}', apiResponse.href)); var innerHtmlPlusEnding = apiResponse.html.slice(apiResponse.html.indexOf('>') + 1), - innerHtml = innerHtmlPlusEnding.slice(0, innerHtmlPlusEnding.indexOf('<')); - + innerHtml = innerHtmlPlusEnding.slice(0, innerHtmlPlusEnding.lastIndexOf('<')); + callback(null, { html: innerHtml, version: apiResponse.version @@ -192,7 +205,6 @@ var oc = oc || {}; $unloadedComponents = $(selector + '[data-rendered!=true]'); var renderUnloadedComponent = function($unloadedComponents, i){ - logger.info(MESSAGES_RETRIEVING); oc.renderNestedComponent($($unloadedComponents[i]), function(){ i++; if(i < $unloadedComponents.length){ diff --git a/components/oc-client/src/oc-client.min.js b/components/oc-client/src/oc-client.min.js index 9f30732d7..b616f5a49 100644 --- a/components/oc-client/src/oc-client.min.js +++ b/components/oc-client/src/oc-client.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.jade=e()}}(function(){return function e(t,n,r){function o(i,c){if(!n[i]){if(!t[i]){var l="function"==typeof require&&require;if(!c&&l)return l(i,!0);if(a)return a(i,!0);var s=new Error("Cannot find module '"+i+"'");throw s.code="MODULE_NOT_FOUND",s}var u=n[i]={exports:{}};t[i][0].call(u.exports,function(e){var n=t[i][1][e];return o(n?n:e)},u,u.exports,e,t,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i/g,">").replace(/"/g,""");return t===""+e?e:t},n.rethrow=function i(t,n,r,o){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&n||o))throw t.message+=" on line "+r,t;try{o=o||e("fs").readFileSync(n,"utf8")}catch(a){i(t,null,r)}var c=3,l=o.split("\n"),s=Math.max(r-c,0),u=Math.min(l.length,r+c),c=l.slice(s,u).map(function(e,t){var n=t+s+1;return(n==r?" > ":" ")+n+"| "+e}).join("\n");throw t.path=n,t.message=(n||"Jade")+":"+r+"\n"+c+"\n\n"+t.message,t}},{fs:2}],2:[function(){},{}]},{},[1])(1)});var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var t;return e.prototype.toString=function(){return""+this.string},t=e}(),t=function(e){"use strict";function t(e){return c[e]||"&"}function n(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}function r(e){return e instanceof i?e.toString():e||0===e?(e=""+e,s.test(e)?e.replace(l,t):e):""}function o(e){return e||0===e?d(e)&&0===e.length?!0:!1:!0}var a={},i=e,c={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},l=/[&<>"'`]/g,s=/[&<>"'`]/;a.extend=n;var u=Object.prototype.toString;a.toString=u;var f=function(e){return"function"==typeof e};f(/x/)&&(f=function(e){return"function"==typeof e&&"[object Function]"===u.call(e)});var f;a.isFunction=f;var d=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===u.call(e):!1};return a.isArray=d,a.escapeExpression=r,a.isEmpty=o,a}(e),n=function(){"use strict";function e(e,t){var r;t&&t.firstLine&&(r=t.firstLine,e+=" - "+r+":"+t.firstColumn);for(var o=Error.prototype.constructor.call(this,e),a=0;a0?e.helpers.each(t,n):r(this):o(t)}),e.registerHelper("each",function(e,t){var n,r=t.fn,o=t.inverse,a=0,i="";if(d(e)&&(e=e.call(this)),t.data&&(n=v(t.data)),e&&"object"==typeof e)if(f(e))for(var c=e.length;c>a;a++)n&&(n.index=a,n.first=0===a,n.last=a===e.length-1),i+=r(e[a],{data:n});else for(var l in e)e.hasOwnProperty(l)&&(n&&(n.key=l,n.index=a,n.first=0===a),i+=r(e[l],{data:n}),a++);return 0===a&&(i=o(this)),i}),e.registerHelper("if",function(e,t){return d(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||i.isEmpty(e)?t.inverse(this):t.fn(this)}),e.registerHelper("unless",function(t,n){return e.helpers["if"].call(this,t,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,t){return d(e)&&(e=e.call(this)),i.isEmpty(e)?void 0:t.fn(e)}),e.registerHelper("log",function(t,n){var r=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(r,t)})}function o(e,t){m.log(e,t)}var a={},i=e,c=t,l="1.3.0";a.VERSION=l;var s=4;a.COMPILER_REVISION=s;var u={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};a.REVISION_CHANGES=u;var f=i.isArray,d=i.isFunction,p=i.toString,h="[object Object]";a.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,t,n){if(p.call(e)===h){if(n||t)throw new c("Arg not supported with multiple helpers");i.extend(this.helpers,e)}else n&&(t.not=n),this.helpers[e]=t},registerPartial:function(e,t){p.call(e)===h?i.extend(this.partials,e):this.partials[e]=t}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,t){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,t)}}};a.logger=m,a.log=o;var v=function(e){var t={};return i.extend(t,e),t};return a.createFrame=v,a}(t,n),o=function(e,t,n){"use strict";function r(e){var t=e&&e[0]||1,n=d;if(t!==n){if(n>t){var r=p[n],o=p[t];throw new f("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+r+") or downgrade your runtime to an older version ("+o+").")}throw new f("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,t){if(!t)throw new f("No environment passed to template");var n=function(e,n,r,o,a,i){var c=t.VM.invokePartial.apply(this,arguments);if(null!=c)return c;if(t.compile){var l={helpers:o,partials:a,data:i};return a[n]=t.compile(e,{data:void 0!==i},t),a[n](r,l)}throw new f("The partial "+n+" could not be compiled when running in runtime-only mode")},r={escapeExpression:u.escapeExpression,invokePartial:n,programs:[],program:function(e,t,n){var r=this.programs[e];return n?r=i(e,t,n):r||(r=this.programs[e]=i(e,t)),r},merge:function(e,t){var n=e||t;return e&&t&&e!==t&&(n={},u.extend(n,t),u.extend(n,e)),n},programWithDepth:t.VM.programWithDepth,noop:t.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var a,i,c=o.partial?o:t;o.partial||(a=o.helpers,i=o.partials);var l=e.call(r,c,n,a,i,o.data);return o.partial||t.VM.checkRevision(r.compilerInfo),l}}function a(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},t.apply(this,[e,o.data||n].concat(r))};return o.program=e,o.depth=r.length,o}function i(e,t,n){var r=function(e,r){return r=r||{},t(e,r.data||n)};return r.program=e,r.depth=0,r}function c(e,t,n,r,o,a){var i={partial:!0,helpers:r,partials:o,data:a};if(void 0===e)throw new f("The partial "+t+" could not be found");return e instanceof Function?e(n,i):void 0}function l(){return""}var s={},u=e,f=t,d=n.COMPILER_REVISION,p=n.REVISION_CHANGES;return s.checkRevision=r,s.template=o,s.programWithDepth=a,s.program=i,s.invokePartial=c,s.noop=l,s}(t,n,r),a=function(e,t,n,r,o){"use strict";var a,i=e,c=t,l=n,s=r,u=o,f=function(){var e=new i.HandlebarsEnvironment;return s.extend(e,i),e.SafeString=c,e.Exception=l,e.Utils=s,e.VM=u,e.template=function(t){return u.template(t,e)},e},d=f();return d.create=f,a=d}(r,e,n,t,o);return a}();!function(e,t){"use strict";function n(){}function r(e,t){if(e){"object"==typeof e&&(e=[].slice.call(e));for(var n=0,r=e.length;r>n;n++)t.call(e,e[n],n)}}function o(e,n){var r=Object.prototype.toString.call(n).slice(8,-1);return n!==t&&null!==n&&r===e}function a(e){return o("Function",e)}function i(e){return o("Array",e)}function c(e){var t=e.split("/"),n=t[t.length-1],r=n.indexOf("?");return-1!==r?n.substring(0,r):n}function l(e){e=e||n,e._done||(e(),e._done=1)}function s(e,t,r,o){var a="object"==typeof e?e:{test:e,success:t?i(t)?t:[t]:!1,failure:r?i(r)?r:[r]:!1,callback:o||n},c=!!a.test;return c&&a.success?(a.success.push(a.callback),k.load.apply(null,a.success)):!c&&a.failure?(a.failure.push(a.callback),k.load.apply(null,a.failure)):o(),k}function u(e){var t={};if("object"==typeof e)for(var n in e)e[n]&&(t={name:n,url:e[n]});else t={name:c(e),url:e};var r=M[t.name];return r&&r.url===t.url?r:(M[t.name]=t,t)}function f(e){e=e||M;for(var t in e)if(e.hasOwnProperty(t)&&e[t].state!==C)return!1;return!0}function d(e){e.state=N,r(e.onpreload,function(e){e.call()})}function p(e){e.state===t&&(e.state=I,e.onpreload=[],g({url:e.url,type:"cache"},function(){d(e)}))}function h(){var e=arguments,t=e[e.length-1],n=[].slice.call(e,1),o=n[0];return a(t)||(t=null),i(e[0])?(e[0].push(t),k.load.apply(null,e[0]),k):(o?(r(n,function(e){!a(e)&&e&&p(u(e))}),v(u(e[0]),a(o)?o:function(){k.load.apply(null,n)})):v(u(e[0])),k)}function m(){var e=arguments,t=e[e.length-1],n={};return a(t)||(t=null),i(e[0])?(e[0].push(t),k.load.apply(null,e[0]),k):(r(e,function(e){e!==t&&(e=u(e),n[e.name]=e)}),r(e,function(e){e!==t&&(e=u(e),v(e,function(){f(n)&&l(t)}))}),k)}function v(e,t){return t=t||n,e.state===C?void t():e.state===H?void k.ready(e.name,t):e.state===I?void e.onpreload.push(function(){v(e,t)}):(e.state=H,void g(e,function(){e.state=C,t(),r(T[e.name],function(e){l(e)}),S&&f()&&r(T.ALL,function(e){l(e)})}))}function y(e){e=e||"";var t=e.split("?")[0].split(".");return t[t.length-1].toLowerCase()}function g(t,r){function o(t){t=t||e.event,c.onload=c.onreadystatechange=c.onerror=null,r()}function a(n){n=n||e.event,("load"===n.type||/loaded|complete/.test(c.readyState)&&(!x.documentMode||x.documentMode<9))&&(e.clearTimeout(t.errorTimeout),e.clearTimeout(t.cssTimeout),c.onload=c.onreadystatechange=c.onerror=null,r())}function i(){if(t.state!==C&&t.cssRetries<=20){for(var n=0,r=x.styleSheets.length;r>n;n++)if(x.styleSheets[n].href===c.href)return void a({type:"load"});t.cssRetries++,t.cssTimeout=e.setTimeout(i,250)}}r=r||n;var c,l=y(t.url);"css"===l?(c=x.createElement("link"),c.type="text/"+(t.type||"css"),c.rel="stylesheet",c.href=t.url,t.cssRetries=0,t.cssTimeout=e.setTimeout(i,500)):(c=x.createElement("script"),c.type="text/"+(t.type||"javascript"),c.src=t.url),c.onload=c.onreadystatechange=a,c.onerror=o,c.async=!1,c.defer=!1,t.errorTimeout=e.setTimeout(function(){o({type:"timeout"})},7e3);var s=x.head||x.getElementsByTagName("head")[0];s.insertBefore(c,s.lastChild)}function w(){for(var e=x.getElementsByTagName("script"),t=0,n=e.length;n>t;t++){var r=e[t].getAttribute("data-headjs-load");if(r)return void k.load(r)}}function E(e,t){if(e===x)return S?l(t):O.push(t),k;if(a(e)&&(t=e,e="ALL"),i(e)){var n={};return r(e,function(e){n[e]=M[e],k.ready(e,function(){f(n)&&l(t)})}),k}if("string"!=typeof e||!a(t))return k;var o=M[e];if(o&&o.state===C||"ALL"===e&&f()&&S)return l(t),k;var c=T[e];return c?c.push(t):c=T[e]=[t],k}function b(){return x.body?void(S||(S=!0,w(),r(O,function(e){l(e)}))):(e.clearTimeout(k.readyTimeout),void(k.readyTimeout=e.setTimeout(b,50)))}function j(){x.addEventListener?(x.removeEventListener("DOMContentLoaded",j,!1),b()):"complete"===x.readyState&&(x.detachEvent("onreadystatechange",j),b())}var S,x=e.document,O=[],T={},M={},A="async"in x.createElement("script")||"MozAppearance"in x.documentElement.style||e.opera,L=e.head_conf&&e.head_conf.head||"head",k=e[L]=e[L]||function(){k.ready.apply(null,arguments)},I=1,N=2,H=3,C=4;if("complete"===x.readyState)b();else if(x.addEventListener)x.addEventListener("DOMContentLoaded",j,!1),e.addEventListener("load",b,!1);else{x.attachEvent("onreadystatechange",j),e.attachEvent("onload",b);var R=!1;try{R=!e.frameElement&&x.documentElement}catch(q){}R&&R.doScroll&&!function P(){if(!S){try{R.doScroll("left")}catch(t){return e.clearTimeout(k.readyTimeout),void(k.readyTimeout=e.setTimeout(P,50))}b()}}()}k.load=k.js=A?m:h,k.test=s,k.ready=E,k.ready(x,function(){f()&&r(T.ALL,function(e){l(e)}),k.feature&&k.feature("domloaded",!0)})}(window);var oc=oc||{};!function(e,t,n,r,o){var a="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js",i="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js",c=5e3,l="oc-component",s="Href parameter missing",u="Error loading {0} component",f="Error rendering component: {0}, error: {1}",d="Failed to retrieve the component. Retrying in {0} seconds...".replace("{0}",c/1e3),p="Error loading component: view engine {0} not supported",h="Loading...",m="Component '{0}' correctly rendered",v="Unrendered component found. Trying to retrieve it...",y="undefined"!=typeof jQuery?jQuery:void 0,g=function(){},w=r.navigator.userAgent,E=!!w.match(/MSIE 8/),b=!!w.match(/MSIE 9/),j=!1,S=!1,x=[],O={error:function(e){return console.log(e)},info:function(e){return o?console.log(e):void 0}},T=function(e,t,n){var r=Math.floor(9999999999*Math.random());e.html(t.html),e.attr("id",r),e.attr("data-rendered",!0),e.attr("data-version",t.version),t.key&&(e.attr("data-hash",t.key),oc.setEventListeners(e)),n()};oc.ready=function(e){if(j)return e();if(S)x.push(e);else{S=!0;var n=function(e){E||b?t.load(a,e):e()},r=function(){j=!0,S=!1,e();for(var t=0;t'+h+""),oc.renderByHref(e.attr("href"),function(n,r){return!n&&r&&r.html?void T(e,r,t):O.error(n)})})},oc.renderByHref=function(e,n){oc.ready(function(){return""===e?n(f.replace("{1}",s)):void y.ajax({url:e,headers:{"render-mode":"pre-rendered"},crossDomain:!0,async:!0,success:function(e){if("pre-rendered"===e.renderMode)t.load([e.template.src],function(){oc.render(e.template,e.data,function(t,r){return t?n(f.replace("{0}",e.href).replace("{1}",t)):(O.info(m.replace("{0}",e.template.src)),void n(null,{html:r,key:e.template.key,version:e.version}))})});else if("rendered"===e.renderMode){O.info(m.replace("{0}",e.href));var r=e.html.slice(e.html.indexOf(">")+1),o=r.slice(0,r.indexOf("<"));n(null,{html:o,version:e.version})}},error:function(){O.error(d),setTimeout(function(){oc.renderByHref(e,n)},c)}})})},oc.renderUnloadedComponents=function(){oc.ready(function(){var e=E?"div[data-oc-component=true]":l,t=y(e+"[data-rendered!=true]"),n=function(e,t){O.info(v),oc.renderNestedComponent(y(e[t]),function(){t++,t0&&n(t,0)})},oc.setEventListeners=function(e){oc.ready(function(){e.off("reRender"),e.on("reRender",function(e,t){var n=y(e.target);return t&&""!==t&&n.attr("href",t),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")})},oc.load=function(e,t,n){oc.ready(function(){if("function"!=typeof n&&(n=g),y(e)){y(e).html("<"+l+' href="'+t+'" />');var r=y(l,e);oc.renderNestedComponent(r,function(){n(r)})}})},oc.ready(oc.renderUnloadedComponents)}(Handlebars,head,document,window,!0),oc.clientVersion="0.8.3"; \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.jade=e()}}(function(){return function e(t,n,r){function o(i,c){if(!n[i]){if(!t[i]){var l="function"==typeof require&&require;if(!c&&l)return l(i,!0);if(a)return a(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var s=n[i]={exports:{}};t[i][0].call(s.exports,function(e){var n=t[i][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i/g,">").replace(/"/g,""");return t===""+e?e:t},n.rethrow=function i(t,n,r,o){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&n||o))throw t.message+=" on line "+r,t;try{o=o||e("fs").readFileSync(n,"utf8")}catch(a){i(t,null,r)}var c=3,l=o.split("\n"),u=Math.max(r-c,0),s=Math.min(l.length,r+c),c=l.slice(u,s).map(function(e,t){var n=t+u+1;return(n==r?" > ":" ")+n+"| "+e}).join("\n");throw t.path=n,t.message=(n||"Jade")+":"+r+"\n"+c+"\n\n"+t.message,t}},{fs:2}],2:[function(){},{}]},{},[1])(1)});var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var t;return e.prototype.toString=function(){return""+this.string},t=e}(),t=function(e){"use strict";function t(e){return c[e]||"&"}function n(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}function r(e){return e instanceof i?e.toString():e||0===e?(e=""+e,u.test(e)?e.replace(l,t):e):""}function o(e){return e||0===e?d(e)&&0===e.length?!0:!1:!0}var a={},i=e,c={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},l=/[&<>"'`]/g,u=/[&<>"'`]/;a.extend=n;var s=Object.prototype.toString;a.toString=s;var f=function(e){return"function"==typeof e};f(/x/)&&(f=function(e){return"function"==typeof e&&"[object Function]"===s.call(e)});var f;a.isFunction=f;var d=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===s.call(e):!1};return a.isArray=d,a.escapeExpression=r,a.isEmpty=o,a}(e),n=function(){"use strict";function e(e,t){var r;t&&t.firstLine&&(r=t.firstLine,e+=" - "+r+":"+t.firstColumn);for(var o=Error.prototype.constructor.call(this,e),a=0;a0?e.helpers.each(t,n):r(this):o(t)}),e.registerHelper("each",function(e,t){var n,r=t.fn,o=t.inverse,a=0,i="";if(d(e)&&(e=e.call(this)),t.data&&(n=v(t.data)),e&&"object"==typeof e)if(f(e))for(var c=e.length;c>a;a++)n&&(n.index=a,n.first=0===a,n.last=a===e.length-1),i+=r(e[a],{data:n});else for(var l in e)e.hasOwnProperty(l)&&(n&&(n.key=l,n.index=a,n.first=0===a),i+=r(e[l],{data:n}),a++);return 0===a&&(i=o(this)),i}),e.registerHelper("if",function(e,t){return d(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||i.isEmpty(e)?t.inverse(this):t.fn(this)}),e.registerHelper("unless",function(t,n){return e.helpers["if"].call(this,t,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,t){return d(e)&&(e=e.call(this)),i.isEmpty(e)?void 0:t.fn(e)}),e.registerHelper("log",function(t,n){var r=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(r,t)})}function o(e,t){m.log(e,t)}var a={},i=e,c=t,l="1.3.0";a.VERSION=l;var u=4;a.COMPILER_REVISION=u;var s={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};a.REVISION_CHANGES=s;var f=i.isArray,d=i.isFunction,p=i.toString,h="[object Object]";a.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,t,n){if(p.call(e)===h){if(n||t)throw new c("Arg not supported with multiple helpers");i.extend(this.helpers,e)}else n&&(t.not=n),this.helpers[e]=t},registerPartial:function(e,t){p.call(e)===h?i.extend(this.partials,e):this.partials[e]=t}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,t){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,t)}}};a.logger=m,a.log=o;var v=function(e){var t={};return i.extend(t,e),t};return a.createFrame=v,a}(t,n),o=function(e,t,n){"use strict";function r(e){var t=e&&e[0]||1,n=d;if(t!==n){if(n>t){var r=p[n],o=p[t];throw new f("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+r+") or downgrade your runtime to an older version ("+o+").")}throw new f("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,t){if(!t)throw new f("No environment passed to template");var n=function(e,n,r,o,a,i){var c=t.VM.invokePartial.apply(this,arguments);if(null!=c)return c;if(t.compile){var l={helpers:o,partials:a,data:i};return a[n]=t.compile(e,{data:void 0!==i},t),a[n](r,l)}throw new f("The partial "+n+" could not be compiled when running in runtime-only mode")},r={escapeExpression:s.escapeExpression,invokePartial:n,programs:[],program:function(e,t,n){var r=this.programs[e];return n?r=i(e,t,n):r||(r=this.programs[e]=i(e,t)),r},merge:function(e,t){var n=e||t;return e&&t&&e!==t&&(n={},s.extend(n,t),s.extend(n,e)),n},programWithDepth:t.VM.programWithDepth,noop:t.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var a,i,c=o.partial?o:t;o.partial||(a=o.helpers,i=o.partials);var l=e.call(r,c,n,a,i,o.data);return o.partial||t.VM.checkRevision(r.compilerInfo),l}}function a(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},t.apply(this,[e,o.data||n].concat(r))};return o.program=e,o.depth=r.length,o}function i(e,t,n){var r=function(e,r){return r=r||{},t(e,r.data||n)};return r.program=e,r.depth=0,r}function c(e,t,n,r,o,a){var i={partial:!0,helpers:r,partials:o,data:a};if(void 0===e)throw new f("The partial "+t+" could not be found");return e instanceof Function?e(n,i):void 0}function l(){return""}var u={},s=e,f=t,d=n.COMPILER_REVISION,p=n.REVISION_CHANGES;return u.checkRevision=r,u.template=o,u.programWithDepth=a,u.program=i,u.invokePartial=c,u.noop=l,u}(t,n,r),a=function(e,t,n,r,o){"use strict";var a,i=e,c=t,l=n,u=r,s=o,f=function(){var e=new i.HandlebarsEnvironment;return u.extend(e,i),e.SafeString=c,e.Exception=l,e.Utils=u,e.VM=s,e.template=function(t){return s.template(t,e)},e},d=f();return d.create=f,a=d}(r,e,n,t,o);return a}();!function(e,t){"use strict";function n(){}function r(e,t){if(e){"object"==typeof e&&(e=[].slice.call(e));for(var n=0,r=e.length;r>n;n++)t.call(e,e[n],n)}}function o(e,n){var r=Object.prototype.toString.call(n).slice(8,-1);return n!==t&&null!==n&&r===e}function a(e){return o("Function",e)}function i(e){return o("Array",e)}function c(e){var t=e.split("/"),n=t[t.length-1],r=n.indexOf("?");return-1!==r?n.substring(0,r):n}function l(e){e=e||n,e._done||(e(),e._done=1)}function u(e,t,r,o){var a="object"==typeof e?e:{test:e,success:t?i(t)?t:[t]:!1,failure:r?i(r)?r:[r]:!1,callback:o||n},c=!!a.test;return c&&a.success?(a.success.push(a.callback),L.load.apply(null,a.success)):!c&&a.failure?(a.failure.push(a.callback),L.load.apply(null,a.failure)):o(),L}function s(e){var t={};if("object"==typeof e)for(var n in e)e[n]&&(t={name:n,url:e[n]});else t={name:c(e),url:e};var r=M[t.name];return r&&r.url===t.url?r:(M[t.name]=t,t)}function f(e){e=e||M;for(var t in e)if(e.hasOwnProperty(t)&&e[t].state!==C)return!1;return!0}function d(e){e.state=N,r(e.onpreload,function(e){e.call()})}function p(e){e.state===t&&(e.state=k,e.onpreload=[],g({url:e.url,type:"cache"},function(){d(e)}))}function h(){var e=arguments,t=e[e.length-1],n=[].slice.call(e,1),o=n[0];return a(t)||(t=null),i(e[0])?(e[0].push(t),L.load.apply(null,e[0]),L):(o?(r(n,function(e){!a(e)&&e&&p(s(e))}),v(s(e[0]),a(o)?o:function(){L.load.apply(null,n)})):v(s(e[0])),L)}function m(){var e=arguments,t=e[e.length-1],n={};return a(t)||(t=null),i(e[0])?(e[0].push(t),L.load.apply(null,e[0]),L):(r(e,function(e){e!==t&&(e=s(e),n[e.name]=e)}),r(e,function(e){e!==t&&(e=s(e),v(e,function(){f(n)&&l(t)}))}),L)}function v(e,t){return t=t||n,e.state===C?void t():e.state===H?void L.ready(e.name,t):e.state===k?void e.onpreload.push(function(){v(e,t)}):(e.state=H,void g(e,function(){e.state=C,t(),r(T[e.name],function(e){l(e)}),S&&f()&&r(T.ALL,function(e){l(e)})}))}function y(e){e=e||"";var t=e.split("?")[0].split(".");return t[t.length-1].toLowerCase()}function g(t,r){function o(t){t=t||e.event,c.onload=c.onreadystatechange=c.onerror=null,r()}function a(n){n=n||e.event,("load"===n.type||/loaded|complete/.test(c.readyState)&&(!x.documentMode||x.documentMode<9))&&(e.clearTimeout(t.errorTimeout),e.clearTimeout(t.cssTimeout),c.onload=c.onreadystatechange=c.onerror=null,r())}function i(){if(t.state!==C&&t.cssRetries<=20){for(var n=0,r=x.styleSheets.length;r>n;n++)if(x.styleSheets[n].href===c.href)return void a({type:"load"});t.cssRetries++,t.cssTimeout=e.setTimeout(i,250)}}r=r||n;var c,l=y(t.url);"css"===l?(c=x.createElement("link"),c.type="text/"+(t.type||"css"),c.rel="stylesheet",c.href=t.url,t.cssRetries=0,t.cssTimeout=e.setTimeout(i,500)):(c=x.createElement("script"),c.type="text/"+(t.type||"javascript"),c.src=t.url),c.onload=c.onreadystatechange=a,c.onerror=o,c.async=!1,c.defer=!1,t.errorTimeout=e.setTimeout(function(){o({type:"timeout"})},7e3);var u=x.head||x.getElementsByTagName("head")[0];u.insertBefore(c,u.lastChild)}function w(){for(var e=x.getElementsByTagName("script"),t=0,n=e.length;n>t;t++){var r=e[t].getAttribute("data-headjs-load");if(r)return void L.load(r)}}function b(e,t){if(e===x)return S?l(t):O.push(t),L;if(a(e)&&(t=e,e="ALL"),i(e)){var n={};return r(e,function(e){n[e]=M[e],L.ready(e,function(){f(n)&&l(t)})}),L}if("string"!=typeof e||!a(t))return L;var o=M[e];if(o&&o.state===C||"ALL"===e&&f()&&S)return l(t),L;var c=T[e];return c?c.push(t):c=T[e]=[t],L}function E(){return x.body?void(S||(S=!0,w(),r(O,function(e){l(e)}))):(e.clearTimeout(L.readyTimeout),void(L.readyTimeout=e.setTimeout(E,50)))}function j(){x.addEventListener?(x.removeEventListener("DOMContentLoaded",j,!1),E()):"complete"===x.readyState&&(x.detachEvent("onreadystatechange",j),E())}var S,x=e.document,O=[],T={},M={},A="async"in x.createElement("script")||"MozAppearance"in x.documentElement.style||e.opera,I=e.head_conf&&e.head_conf.head||"head",L=e[I]=e[I]||function(){L.ready.apply(null,arguments)},k=1,N=2,H=3,C=4;if("complete"===x.readyState)E();else if(x.addEventListener)x.addEventListener("DOMContentLoaded",j,!1),e.addEventListener("load",E,!1);else{x.attachEvent("onreadystatechange",j),e.attachEvent("onload",E);var R=!1;try{R=!e.frameElement&&x.documentElement}catch(q){}R&&R.doScroll&&!function P(){if(!S){try{R.doScroll("left")}catch(t){return e.clearTimeout(L.readyTimeout),void(L.readyTimeout=e.setTimeout(P,50))}E()}}()}L.load=L.js=A?m:h,L.test=u,L.ready=b,L.ready(x,function(){f()&&r(T.ALL,function(e){l(e)}),L.feature&&L.feature("domloaded",!0)})}(window);var oc=oc||{};!function(e,t,n,r,o){var a="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js",i="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js",c=5e3,l=500,u="oc-component",s="Href parameter missing",f="Error loading {0} component",d="Error rendering component: {0}, error: {1}",p="Failed to retrieve the component. Retrying in {0} seconds...".replace("{0}",c/1e3),h="Error loading component: view engine {0} not supported",m="Loading...",v="Component '{0}' correctly rendered",y="Unrendered component found. Trying to retrieve it...",g="undefined"!=typeof jQuery?jQuery:void 0,w=function(){},b=r.navigator.userAgent,E=!!b.match(/MSIE 8/),j=!!b.match(/MSIE 9/),S=!1,x=!1,O=[],T={error:function(e){return console.log(e)},info:function(e){return o?console.log(e):void 0}},M=function(e,t,n){var r=Math.floor(9999999999*Math.random());e.html(t.html),e.attr("id",r),e.attr("data-rendered",!0),e.attr("data-rendering",!1),e.attr("data-version",t.version),t.key&&(e.attr("data-hash",t.key),oc.setEventListeners(e)),n()};oc.ready=function(e){if(S)return e();if(x)O.push(e);else{x=!0;var n=function(e){E||j?t.load(a,e):e()},r=function(){S=!0,x=!1,e();for(var t=0;t'+m+""),oc.renderByHref(e.attr("href"),function(n,r){return!n&&r&&r.html?void M(e,r,t):T.error(n)}))})},oc.renderByHref=function(e,n){oc.ready(function(){return""===e?n(d.replace("{1}",s)):void g.ajax({url:e,headers:{"render-mode":"pre-rendered"},crossDomain:!0,async:!0,success:function(e){if("pre-rendered"===e.renderMode)t.load([e.template.src],function(){oc.render(e.template,e.data,function(t,r){return t?n(d.replace("{0}",e.href).replace("{1}",t)):(T.info(v.replace("{0}",e.template.src)),void n(null,{html:r,key:e.template.key,version:e.version}))})});else if("rendered"===e.renderMode){T.info(v.replace("{0}",e.href));var r=e.html.slice(e.html.indexOf(">")+1),o=r.slice(0,r.lastIndexOf("<"));n(null,{html:o,version:e.version})}},error:function(){T.error(p),setTimeout(function(){oc.renderByHref(e,n)},c)}})})},oc.renderUnloadedComponents=function(){oc.ready(function(){var e=E?"div[data-oc-component=true]":u,t=g(e+"[data-rendered!=true]"),n=function(e,t){oc.renderNestedComponent(g(e[t]),function(){t++,t0&&n(t,0)})},oc.setEventListeners=function(e){oc.ready(function(){e.off("reRender"),e.on("reRender",function(e,t){var n=g(e.target);return t&&""!==t&&n.attr("href",t),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")})},oc.load=function(e,t,n){oc.ready(function(){if("function"!=typeof n&&(n=w),g(e)){g(e).html("<"+u+' href="'+t+'" />');var r=g(u,e);oc.renderNestedComponent(r,function(){n(r)})}})},oc.ready(oc.renderUnloadedComponents)}(Handlebars,head,document,window,!0),oc.clientVersion="0.8.3"; \ No newline at end of file From b02254c0da2a9c8eb87076d3c2737f97f67d328e Mon Sep 17 00:00:00 2001 From: matteofigus Date: Mon, 16 Feb 2015 18:29:46 +0000 Subject: [PATCH 3/4] Client fix --- client/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/index.js b/client/index.js index 6366ca562..9989aca0f 100644 --- a/client/index.js +++ b/client/index.js @@ -156,10 +156,10 @@ var Client = function(conf){ return format('', href); } - return format('', href); + return format('', href); }; this.getRenderedComponent = function(data){ From 6d99cfb955c627fce4cbc0cc37c5dc10829c80fe Mon Sep 17 00:00:00 2001 From: Matteo Figus Date: Mon, 16 Feb 2015 18:37:27 +0000 Subject: [PATCH 4/4] 0.8.4 --- components/oc-client/_package/package.json | 4 ++-- components/oc-client/_package/src/oc-client.min.js | 2 +- components/oc-client/package.json | 2 +- components/oc-client/src/oc-client.min.js | 2 +- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/oc-client/_package/package.json b/components/oc-client/_package/package.json index 93e467655..358b110f3 100644 --- a/components/oc-client/_package/package.json +++ b/components/oc-client/_package/package.json @@ -1,7 +1,7 @@ { "name": "oc-client", "description": "", - "version": "0.8.3", + "version": "0.8.4", "dependencies": {}, "repository": "", "oc": { @@ -21,6 +21,6 @@ "src": "server.js" } }, - "version": "0.8.3" + "version": "0.8.4" } } diff --git a/components/oc-client/_package/src/oc-client.min.js b/components/oc-client/_package/src/oc-client.min.js index b616f5a49..d676309c2 100644 --- a/components/oc-client/_package/src/oc-client.min.js +++ b/components/oc-client/_package/src/oc-client.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.jade=e()}}(function(){return function e(t,n,r){function o(i,c){if(!n[i]){if(!t[i]){var l="function"==typeof require&&require;if(!c&&l)return l(i,!0);if(a)return a(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var s=n[i]={exports:{}};t[i][0].call(s.exports,function(e){var n=t[i][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i/g,">").replace(/"/g,""");return t===""+e?e:t},n.rethrow=function i(t,n,r,o){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&n||o))throw t.message+=" on line "+r,t;try{o=o||e("fs").readFileSync(n,"utf8")}catch(a){i(t,null,r)}var c=3,l=o.split("\n"),u=Math.max(r-c,0),s=Math.min(l.length,r+c),c=l.slice(u,s).map(function(e,t){var n=t+u+1;return(n==r?" > ":" ")+n+"| "+e}).join("\n");throw t.path=n,t.message=(n||"Jade")+":"+r+"\n"+c+"\n\n"+t.message,t}},{fs:2}],2:[function(){},{}]},{},[1])(1)});var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var t;return e.prototype.toString=function(){return""+this.string},t=e}(),t=function(e){"use strict";function t(e){return c[e]||"&"}function n(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}function r(e){return e instanceof i?e.toString():e||0===e?(e=""+e,u.test(e)?e.replace(l,t):e):""}function o(e){return e||0===e?d(e)&&0===e.length?!0:!1:!0}var a={},i=e,c={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},l=/[&<>"'`]/g,u=/[&<>"'`]/;a.extend=n;var s=Object.prototype.toString;a.toString=s;var f=function(e){return"function"==typeof e};f(/x/)&&(f=function(e){return"function"==typeof e&&"[object Function]"===s.call(e)});var f;a.isFunction=f;var d=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===s.call(e):!1};return a.isArray=d,a.escapeExpression=r,a.isEmpty=o,a}(e),n=function(){"use strict";function e(e,t){var r;t&&t.firstLine&&(r=t.firstLine,e+=" - "+r+":"+t.firstColumn);for(var o=Error.prototype.constructor.call(this,e),a=0;a0?e.helpers.each(t,n):r(this):o(t)}),e.registerHelper("each",function(e,t){var n,r=t.fn,o=t.inverse,a=0,i="";if(d(e)&&(e=e.call(this)),t.data&&(n=v(t.data)),e&&"object"==typeof e)if(f(e))for(var c=e.length;c>a;a++)n&&(n.index=a,n.first=0===a,n.last=a===e.length-1),i+=r(e[a],{data:n});else for(var l in e)e.hasOwnProperty(l)&&(n&&(n.key=l,n.index=a,n.first=0===a),i+=r(e[l],{data:n}),a++);return 0===a&&(i=o(this)),i}),e.registerHelper("if",function(e,t){return d(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||i.isEmpty(e)?t.inverse(this):t.fn(this)}),e.registerHelper("unless",function(t,n){return e.helpers["if"].call(this,t,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,t){return d(e)&&(e=e.call(this)),i.isEmpty(e)?void 0:t.fn(e)}),e.registerHelper("log",function(t,n){var r=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(r,t)})}function o(e,t){m.log(e,t)}var a={},i=e,c=t,l="1.3.0";a.VERSION=l;var u=4;a.COMPILER_REVISION=u;var s={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};a.REVISION_CHANGES=s;var f=i.isArray,d=i.isFunction,p=i.toString,h="[object Object]";a.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,t,n){if(p.call(e)===h){if(n||t)throw new c("Arg not supported with multiple helpers");i.extend(this.helpers,e)}else n&&(t.not=n),this.helpers[e]=t},registerPartial:function(e,t){p.call(e)===h?i.extend(this.partials,e):this.partials[e]=t}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,t){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,t)}}};a.logger=m,a.log=o;var v=function(e){var t={};return i.extend(t,e),t};return a.createFrame=v,a}(t,n),o=function(e,t,n){"use strict";function r(e){var t=e&&e[0]||1,n=d;if(t!==n){if(n>t){var r=p[n],o=p[t];throw new f("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+r+") or downgrade your runtime to an older version ("+o+").")}throw new f("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,t){if(!t)throw new f("No environment passed to template");var n=function(e,n,r,o,a,i){var c=t.VM.invokePartial.apply(this,arguments);if(null!=c)return c;if(t.compile){var l={helpers:o,partials:a,data:i};return a[n]=t.compile(e,{data:void 0!==i},t),a[n](r,l)}throw new f("The partial "+n+" could not be compiled when running in runtime-only mode")},r={escapeExpression:s.escapeExpression,invokePartial:n,programs:[],program:function(e,t,n){var r=this.programs[e];return n?r=i(e,t,n):r||(r=this.programs[e]=i(e,t)),r},merge:function(e,t){var n=e||t;return e&&t&&e!==t&&(n={},s.extend(n,t),s.extend(n,e)),n},programWithDepth:t.VM.programWithDepth,noop:t.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var a,i,c=o.partial?o:t;o.partial||(a=o.helpers,i=o.partials);var l=e.call(r,c,n,a,i,o.data);return o.partial||t.VM.checkRevision(r.compilerInfo),l}}function a(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},t.apply(this,[e,o.data||n].concat(r))};return o.program=e,o.depth=r.length,o}function i(e,t,n){var r=function(e,r){return r=r||{},t(e,r.data||n)};return r.program=e,r.depth=0,r}function c(e,t,n,r,o,a){var i={partial:!0,helpers:r,partials:o,data:a};if(void 0===e)throw new f("The partial "+t+" could not be found");return e instanceof Function?e(n,i):void 0}function l(){return""}var u={},s=e,f=t,d=n.COMPILER_REVISION,p=n.REVISION_CHANGES;return u.checkRevision=r,u.template=o,u.programWithDepth=a,u.program=i,u.invokePartial=c,u.noop=l,u}(t,n,r),a=function(e,t,n,r,o){"use strict";var a,i=e,c=t,l=n,u=r,s=o,f=function(){var e=new i.HandlebarsEnvironment;return u.extend(e,i),e.SafeString=c,e.Exception=l,e.Utils=u,e.VM=s,e.template=function(t){return s.template(t,e)},e},d=f();return d.create=f,a=d}(r,e,n,t,o);return a}();!function(e,t){"use strict";function n(){}function r(e,t){if(e){"object"==typeof e&&(e=[].slice.call(e));for(var n=0,r=e.length;r>n;n++)t.call(e,e[n],n)}}function o(e,n){var r=Object.prototype.toString.call(n).slice(8,-1);return n!==t&&null!==n&&r===e}function a(e){return o("Function",e)}function i(e){return o("Array",e)}function c(e){var t=e.split("/"),n=t[t.length-1],r=n.indexOf("?");return-1!==r?n.substring(0,r):n}function l(e){e=e||n,e._done||(e(),e._done=1)}function u(e,t,r,o){var a="object"==typeof e?e:{test:e,success:t?i(t)?t:[t]:!1,failure:r?i(r)?r:[r]:!1,callback:o||n},c=!!a.test;return c&&a.success?(a.success.push(a.callback),L.load.apply(null,a.success)):!c&&a.failure?(a.failure.push(a.callback),L.load.apply(null,a.failure)):o(),L}function s(e){var t={};if("object"==typeof e)for(var n in e)e[n]&&(t={name:n,url:e[n]});else t={name:c(e),url:e};var r=M[t.name];return r&&r.url===t.url?r:(M[t.name]=t,t)}function f(e){e=e||M;for(var t in e)if(e.hasOwnProperty(t)&&e[t].state!==C)return!1;return!0}function d(e){e.state=N,r(e.onpreload,function(e){e.call()})}function p(e){e.state===t&&(e.state=k,e.onpreload=[],g({url:e.url,type:"cache"},function(){d(e)}))}function h(){var e=arguments,t=e[e.length-1],n=[].slice.call(e,1),o=n[0];return a(t)||(t=null),i(e[0])?(e[0].push(t),L.load.apply(null,e[0]),L):(o?(r(n,function(e){!a(e)&&e&&p(s(e))}),v(s(e[0]),a(o)?o:function(){L.load.apply(null,n)})):v(s(e[0])),L)}function m(){var e=arguments,t=e[e.length-1],n={};return a(t)||(t=null),i(e[0])?(e[0].push(t),L.load.apply(null,e[0]),L):(r(e,function(e){e!==t&&(e=s(e),n[e.name]=e)}),r(e,function(e){e!==t&&(e=s(e),v(e,function(){f(n)&&l(t)}))}),L)}function v(e,t){return t=t||n,e.state===C?void t():e.state===H?void L.ready(e.name,t):e.state===k?void e.onpreload.push(function(){v(e,t)}):(e.state=H,void g(e,function(){e.state=C,t(),r(T[e.name],function(e){l(e)}),S&&f()&&r(T.ALL,function(e){l(e)})}))}function y(e){e=e||"";var t=e.split("?")[0].split(".");return t[t.length-1].toLowerCase()}function g(t,r){function o(t){t=t||e.event,c.onload=c.onreadystatechange=c.onerror=null,r()}function a(n){n=n||e.event,("load"===n.type||/loaded|complete/.test(c.readyState)&&(!x.documentMode||x.documentMode<9))&&(e.clearTimeout(t.errorTimeout),e.clearTimeout(t.cssTimeout),c.onload=c.onreadystatechange=c.onerror=null,r())}function i(){if(t.state!==C&&t.cssRetries<=20){for(var n=0,r=x.styleSheets.length;r>n;n++)if(x.styleSheets[n].href===c.href)return void a({type:"load"});t.cssRetries++,t.cssTimeout=e.setTimeout(i,250)}}r=r||n;var c,l=y(t.url);"css"===l?(c=x.createElement("link"),c.type="text/"+(t.type||"css"),c.rel="stylesheet",c.href=t.url,t.cssRetries=0,t.cssTimeout=e.setTimeout(i,500)):(c=x.createElement("script"),c.type="text/"+(t.type||"javascript"),c.src=t.url),c.onload=c.onreadystatechange=a,c.onerror=o,c.async=!1,c.defer=!1,t.errorTimeout=e.setTimeout(function(){o({type:"timeout"})},7e3);var u=x.head||x.getElementsByTagName("head")[0];u.insertBefore(c,u.lastChild)}function w(){for(var e=x.getElementsByTagName("script"),t=0,n=e.length;n>t;t++){var r=e[t].getAttribute("data-headjs-load");if(r)return void L.load(r)}}function b(e,t){if(e===x)return S?l(t):O.push(t),L;if(a(e)&&(t=e,e="ALL"),i(e)){var n={};return r(e,function(e){n[e]=M[e],L.ready(e,function(){f(n)&&l(t)})}),L}if("string"!=typeof e||!a(t))return L;var o=M[e];if(o&&o.state===C||"ALL"===e&&f()&&S)return l(t),L;var c=T[e];return c?c.push(t):c=T[e]=[t],L}function E(){return x.body?void(S||(S=!0,w(),r(O,function(e){l(e)}))):(e.clearTimeout(L.readyTimeout),void(L.readyTimeout=e.setTimeout(E,50)))}function j(){x.addEventListener?(x.removeEventListener("DOMContentLoaded",j,!1),E()):"complete"===x.readyState&&(x.detachEvent("onreadystatechange",j),E())}var S,x=e.document,O=[],T={},M={},A="async"in x.createElement("script")||"MozAppearance"in x.documentElement.style||e.opera,I=e.head_conf&&e.head_conf.head||"head",L=e[I]=e[I]||function(){L.ready.apply(null,arguments)},k=1,N=2,H=3,C=4;if("complete"===x.readyState)E();else if(x.addEventListener)x.addEventListener("DOMContentLoaded",j,!1),e.addEventListener("load",E,!1);else{x.attachEvent("onreadystatechange",j),e.attachEvent("onload",E);var R=!1;try{R=!e.frameElement&&x.documentElement}catch(q){}R&&R.doScroll&&!function P(){if(!S){try{R.doScroll("left")}catch(t){return e.clearTimeout(L.readyTimeout),void(L.readyTimeout=e.setTimeout(P,50))}E()}}()}L.load=L.js=A?m:h,L.test=u,L.ready=b,L.ready(x,function(){f()&&r(T.ALL,function(e){l(e)}),L.feature&&L.feature("domloaded",!0)})}(window);var oc=oc||{};!function(e,t,n,r,o){var a="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js",i="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js",c=5e3,l=500,u="oc-component",s="Href parameter missing",f="Error loading {0} component",d="Error rendering component: {0}, error: {1}",p="Failed to retrieve the component. Retrying in {0} seconds...".replace("{0}",c/1e3),h="Error loading component: view engine {0} not supported",m="Loading...",v="Component '{0}' correctly rendered",y="Unrendered component found. Trying to retrieve it...",g="undefined"!=typeof jQuery?jQuery:void 0,w=function(){},b=r.navigator.userAgent,E=!!b.match(/MSIE 8/),j=!!b.match(/MSIE 9/),S=!1,x=!1,O=[],T={error:function(e){return console.log(e)},info:function(e){return o?console.log(e):void 0}},M=function(e,t,n){var r=Math.floor(9999999999*Math.random());e.html(t.html),e.attr("id",r),e.attr("data-rendered",!0),e.attr("data-rendering",!1),e.attr("data-version",t.version),t.key&&(e.attr("data-hash",t.key),oc.setEventListeners(e)),n()};oc.ready=function(e){if(S)return e();if(x)O.push(e);else{x=!0;var n=function(e){E||j?t.load(a,e):e()},r=function(){S=!0,x=!1,e();for(var t=0;t'+m+""),oc.renderByHref(e.attr("href"),function(n,r){return!n&&r&&r.html?void M(e,r,t):T.error(n)}))})},oc.renderByHref=function(e,n){oc.ready(function(){return""===e?n(d.replace("{1}",s)):void g.ajax({url:e,headers:{"render-mode":"pre-rendered"},crossDomain:!0,async:!0,success:function(e){if("pre-rendered"===e.renderMode)t.load([e.template.src],function(){oc.render(e.template,e.data,function(t,r){return t?n(d.replace("{0}",e.href).replace("{1}",t)):(T.info(v.replace("{0}",e.template.src)),void n(null,{html:r,key:e.template.key,version:e.version}))})});else if("rendered"===e.renderMode){T.info(v.replace("{0}",e.href));var r=e.html.slice(e.html.indexOf(">")+1),o=r.slice(0,r.lastIndexOf("<"));n(null,{html:o,version:e.version})}},error:function(){T.error(p),setTimeout(function(){oc.renderByHref(e,n)},c)}})})},oc.renderUnloadedComponents=function(){oc.ready(function(){var e=E?"div[data-oc-component=true]":u,t=g(e+"[data-rendered!=true]"),n=function(e,t){oc.renderNestedComponent(g(e[t]),function(){t++,t0&&n(t,0)})},oc.setEventListeners=function(e){oc.ready(function(){e.off("reRender"),e.on("reRender",function(e,t){var n=g(e.target);return t&&""!==t&&n.attr("href",t),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")})},oc.load=function(e,t,n){oc.ready(function(){if("function"!=typeof n&&(n=w),g(e)){g(e).html("<"+u+' href="'+t+'" />');var r=g(u,e);oc.renderNestedComponent(r,function(){n(r)})}})},oc.ready(oc.renderUnloadedComponents)}(Handlebars,head,document,window,!0),oc.clientVersion="0.8.3"; \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.jade=e()}}(function(){return function e(t,n,r){function o(i,c){if(!n[i]){if(!t[i]){var l="function"==typeof require&&require;if(!c&&l)return l(i,!0);if(a)return a(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var s=n[i]={exports:{}};t[i][0].call(s.exports,function(e){var n=t[i][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i/g,">").replace(/"/g,""");return t===""+e?e:t},n.rethrow=function i(t,n,r,o){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&n||o))throw t.message+=" on line "+r,t;try{o=o||e("fs").readFileSync(n,"utf8")}catch(a){i(t,null,r)}var c=3,l=o.split("\n"),u=Math.max(r-c,0),s=Math.min(l.length,r+c),c=l.slice(u,s).map(function(e,t){var n=t+u+1;return(n==r?" > ":" ")+n+"| "+e}).join("\n");throw t.path=n,t.message=(n||"Jade")+":"+r+"\n"+c+"\n\n"+t.message,t}},{fs:2}],2:[function(){},{}]},{},[1])(1)});var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var t;return e.prototype.toString=function(){return""+this.string},t=e}(),t=function(e){"use strict";function t(e){return c[e]||"&"}function n(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}function r(e){return e instanceof i?e.toString():e||0===e?(e=""+e,u.test(e)?e.replace(l,t):e):""}function o(e){return e||0===e?d(e)&&0===e.length?!0:!1:!0}var a={},i=e,c={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},l=/[&<>"'`]/g,u=/[&<>"'`]/;a.extend=n;var s=Object.prototype.toString;a.toString=s;var f=function(e){return"function"==typeof e};f(/x/)&&(f=function(e){return"function"==typeof e&&"[object Function]"===s.call(e)});var f;a.isFunction=f;var d=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===s.call(e):!1};return a.isArray=d,a.escapeExpression=r,a.isEmpty=o,a}(e),n=function(){"use strict";function e(e,t){var r;t&&t.firstLine&&(r=t.firstLine,e+=" - "+r+":"+t.firstColumn);for(var o=Error.prototype.constructor.call(this,e),a=0;a0?e.helpers.each(t,n):r(this):o(t)}),e.registerHelper("each",function(e,t){var n,r=t.fn,o=t.inverse,a=0,i="";if(d(e)&&(e=e.call(this)),t.data&&(n=v(t.data)),e&&"object"==typeof e)if(f(e))for(var c=e.length;c>a;a++)n&&(n.index=a,n.first=0===a,n.last=a===e.length-1),i+=r(e[a],{data:n});else for(var l in e)e.hasOwnProperty(l)&&(n&&(n.key=l,n.index=a,n.first=0===a),i+=r(e[l],{data:n}),a++);return 0===a&&(i=o(this)),i}),e.registerHelper("if",function(e,t){return d(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||i.isEmpty(e)?t.inverse(this):t.fn(this)}),e.registerHelper("unless",function(t,n){return e.helpers["if"].call(this,t,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,t){return d(e)&&(e=e.call(this)),i.isEmpty(e)?void 0:t.fn(e)}),e.registerHelper("log",function(t,n){var r=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(r,t)})}function o(e,t){m.log(e,t)}var a={},i=e,c=t,l="1.3.0";a.VERSION=l;var u=4;a.COMPILER_REVISION=u;var s={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};a.REVISION_CHANGES=s;var f=i.isArray,d=i.isFunction,p=i.toString,h="[object Object]";a.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,t,n){if(p.call(e)===h){if(n||t)throw new c("Arg not supported with multiple helpers");i.extend(this.helpers,e)}else n&&(t.not=n),this.helpers[e]=t},registerPartial:function(e,t){p.call(e)===h?i.extend(this.partials,e):this.partials[e]=t}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,t){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,t)}}};a.logger=m,a.log=o;var v=function(e){var t={};return i.extend(t,e),t};return a.createFrame=v,a}(t,n),o=function(e,t,n){"use strict";function r(e){var t=e&&e[0]||1,n=d;if(t!==n){if(n>t){var r=p[n],o=p[t];throw new f("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+r+") or downgrade your runtime to an older version ("+o+").")}throw new f("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,t){if(!t)throw new f("No environment passed to template");var n=function(e,n,r,o,a,i){var c=t.VM.invokePartial.apply(this,arguments);if(null!=c)return c;if(t.compile){var l={helpers:o,partials:a,data:i};return a[n]=t.compile(e,{data:void 0!==i},t),a[n](r,l)}throw new f("The partial "+n+" could not be compiled when running in runtime-only mode")},r={escapeExpression:s.escapeExpression,invokePartial:n,programs:[],program:function(e,t,n){var r=this.programs[e];return n?r=i(e,t,n):r||(r=this.programs[e]=i(e,t)),r},merge:function(e,t){var n=e||t;return e&&t&&e!==t&&(n={},s.extend(n,t),s.extend(n,e)),n},programWithDepth:t.VM.programWithDepth,noop:t.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var a,i,c=o.partial?o:t;o.partial||(a=o.helpers,i=o.partials);var l=e.call(r,c,n,a,i,o.data);return o.partial||t.VM.checkRevision(r.compilerInfo),l}}function a(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},t.apply(this,[e,o.data||n].concat(r))};return o.program=e,o.depth=r.length,o}function i(e,t,n){var r=function(e,r){return r=r||{},t(e,r.data||n)};return r.program=e,r.depth=0,r}function c(e,t,n,r,o,a){var i={partial:!0,helpers:r,partials:o,data:a};if(void 0===e)throw new f("The partial "+t+" could not be found");return e instanceof Function?e(n,i):void 0}function l(){return""}var u={},s=e,f=t,d=n.COMPILER_REVISION,p=n.REVISION_CHANGES;return u.checkRevision=r,u.template=o,u.programWithDepth=a,u.program=i,u.invokePartial=c,u.noop=l,u}(t,n,r),a=function(e,t,n,r,o){"use strict";var a,i=e,c=t,l=n,u=r,s=o,f=function(){var e=new i.HandlebarsEnvironment;return u.extend(e,i),e.SafeString=c,e.Exception=l,e.Utils=u,e.VM=s,e.template=function(t){return s.template(t,e)},e},d=f();return d.create=f,a=d}(r,e,n,t,o);return a}();!function(e,t){"use strict";function n(){}function r(e,t){if(e){"object"==typeof e&&(e=[].slice.call(e));for(var n=0,r=e.length;r>n;n++)t.call(e,e[n],n)}}function o(e,n){var r=Object.prototype.toString.call(n).slice(8,-1);return n!==t&&null!==n&&r===e}function a(e){return o("Function",e)}function i(e){return o("Array",e)}function c(e){var t=e.split("/"),n=t[t.length-1],r=n.indexOf("?");return-1!==r?n.substring(0,r):n}function l(e){e=e||n,e._done||(e(),e._done=1)}function u(e,t,r,o){var a="object"==typeof e?e:{test:e,success:t?i(t)?t:[t]:!1,failure:r?i(r)?r:[r]:!1,callback:o||n},c=!!a.test;return c&&a.success?(a.success.push(a.callback),L.load.apply(null,a.success)):!c&&a.failure?(a.failure.push(a.callback),L.load.apply(null,a.failure)):o(),L}function s(e){var t={};if("object"==typeof e)for(var n in e)e[n]&&(t={name:n,url:e[n]});else t={name:c(e),url:e};var r=M[t.name];return r&&r.url===t.url?r:(M[t.name]=t,t)}function f(e){e=e||M;for(var t in e)if(e.hasOwnProperty(t)&&e[t].state!==C)return!1;return!0}function d(e){e.state=N,r(e.onpreload,function(e){e.call()})}function p(e){e.state===t&&(e.state=k,e.onpreload=[],g({url:e.url,type:"cache"},function(){d(e)}))}function h(){var e=arguments,t=e[e.length-1],n=[].slice.call(e,1),o=n[0];return a(t)||(t=null),i(e[0])?(e[0].push(t),L.load.apply(null,e[0]),L):(o?(r(n,function(e){!a(e)&&e&&p(s(e))}),v(s(e[0]),a(o)?o:function(){L.load.apply(null,n)})):v(s(e[0])),L)}function m(){var e=arguments,t=e[e.length-1],n={};return a(t)||(t=null),i(e[0])?(e[0].push(t),L.load.apply(null,e[0]),L):(r(e,function(e){e!==t&&(e=s(e),n[e.name]=e)}),r(e,function(e){e!==t&&(e=s(e),v(e,function(){f(n)&&l(t)}))}),L)}function v(e,t){return t=t||n,e.state===C?void t():e.state===H?void L.ready(e.name,t):e.state===k?void e.onpreload.push(function(){v(e,t)}):(e.state=H,void g(e,function(){e.state=C,t(),r(T[e.name],function(e){l(e)}),S&&f()&&r(T.ALL,function(e){l(e)})}))}function y(e){e=e||"";var t=e.split("?")[0].split(".");return t[t.length-1].toLowerCase()}function g(t,r){function o(t){t=t||e.event,c.onload=c.onreadystatechange=c.onerror=null,r()}function a(n){n=n||e.event,("load"===n.type||/loaded|complete/.test(c.readyState)&&(!x.documentMode||x.documentMode<9))&&(e.clearTimeout(t.errorTimeout),e.clearTimeout(t.cssTimeout),c.onload=c.onreadystatechange=c.onerror=null,r())}function i(){if(t.state!==C&&t.cssRetries<=20){for(var n=0,r=x.styleSheets.length;r>n;n++)if(x.styleSheets[n].href===c.href)return void a({type:"load"});t.cssRetries++,t.cssTimeout=e.setTimeout(i,250)}}r=r||n;var c,l=y(t.url);"css"===l?(c=x.createElement("link"),c.type="text/"+(t.type||"css"),c.rel="stylesheet",c.href=t.url,t.cssRetries=0,t.cssTimeout=e.setTimeout(i,500)):(c=x.createElement("script"),c.type="text/"+(t.type||"javascript"),c.src=t.url),c.onload=c.onreadystatechange=a,c.onerror=o,c.async=!1,c.defer=!1,t.errorTimeout=e.setTimeout(function(){o({type:"timeout"})},7e3);var u=x.head||x.getElementsByTagName("head")[0];u.insertBefore(c,u.lastChild)}function w(){for(var e=x.getElementsByTagName("script"),t=0,n=e.length;n>t;t++){var r=e[t].getAttribute("data-headjs-load");if(r)return void L.load(r)}}function b(e,t){if(e===x)return S?l(t):O.push(t),L;if(a(e)&&(t=e,e="ALL"),i(e)){var n={};return r(e,function(e){n[e]=M[e],L.ready(e,function(){f(n)&&l(t)})}),L}if("string"!=typeof e||!a(t))return L;var o=M[e];if(o&&o.state===C||"ALL"===e&&f()&&S)return l(t),L;var c=T[e];return c?c.push(t):c=T[e]=[t],L}function E(){return x.body?void(S||(S=!0,w(),r(O,function(e){l(e)}))):(e.clearTimeout(L.readyTimeout),void(L.readyTimeout=e.setTimeout(E,50)))}function j(){x.addEventListener?(x.removeEventListener("DOMContentLoaded",j,!1),E()):"complete"===x.readyState&&(x.detachEvent("onreadystatechange",j),E())}var S,x=e.document,O=[],T={},M={},A="async"in x.createElement("script")||"MozAppearance"in x.documentElement.style||e.opera,I=e.head_conf&&e.head_conf.head||"head",L=e[I]=e[I]||function(){L.ready.apply(null,arguments)},k=1,N=2,H=3,C=4;if("complete"===x.readyState)E();else if(x.addEventListener)x.addEventListener("DOMContentLoaded",j,!1),e.addEventListener("load",E,!1);else{x.attachEvent("onreadystatechange",j),e.attachEvent("onload",E);var R=!1;try{R=!e.frameElement&&x.documentElement}catch(q){}R&&R.doScroll&&!function P(){if(!S){try{R.doScroll("left")}catch(t){return e.clearTimeout(L.readyTimeout),void(L.readyTimeout=e.setTimeout(P,50))}E()}}()}L.load=L.js=A?m:h,L.test=u,L.ready=b,L.ready(x,function(){f()&&r(T.ALL,function(e){l(e)}),L.feature&&L.feature("domloaded",!0)})}(window);var oc=oc||{};!function(e,t,n,r,o){var a="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js",i="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js",c=5e3,l=500,u="oc-component",s="Href parameter missing",f="Error loading {0} component",d="Error rendering component: {0}, error: {1}",p="Failed to retrieve the component. Retrying in {0} seconds...".replace("{0}",c/1e3),h="Error loading component: view engine {0} not supported",m="Loading...",v="Component '{0}' correctly rendered",y="Unrendered component found. Trying to retrieve it...",g="undefined"!=typeof jQuery?jQuery:void 0,w=function(){},b=r.navigator.userAgent,E=!!b.match(/MSIE 8/),j=!!b.match(/MSIE 9/),S=!1,x=!1,O=[],T={error:function(e){return console.log(e)},info:function(e){return o?console.log(e):void 0}},M=function(e,t,n){var r=Math.floor(9999999999*Math.random());e.html(t.html),e.attr("id",r),e.attr("data-rendered",!0),e.attr("data-rendering",!1),e.attr("data-version",t.version),t.key&&(e.attr("data-hash",t.key),oc.setEventListeners(e)),n()};oc.ready=function(e){if(S)return e();if(x)O.push(e);else{x=!0;var n=function(e){E||j?t.load(a,e):e()},r=function(){S=!0,x=!1,e();for(var t=0;t'+m+""),oc.renderByHref(e.attr("href"),function(n,r){return!n&&r&&r.html?void M(e,r,t):T.error(n)}))})},oc.renderByHref=function(e,n){oc.ready(function(){return""===e?n(d.replace("{1}",s)):void g.ajax({url:e,headers:{"render-mode":"pre-rendered"},crossDomain:!0,async:!0,success:function(e){if("pre-rendered"===e.renderMode)t.load([e.template.src],function(){oc.render(e.template,e.data,function(t,r){return t?n(d.replace("{0}",e.href).replace("{1}",t)):(T.info(v.replace("{0}",e.template.src)),void n(null,{html:r,key:e.template.key,version:e.version}))})});else if("rendered"===e.renderMode){T.info(v.replace("{0}",e.href));var r=e.html.slice(e.html.indexOf(">")+1),o=r.slice(0,r.lastIndexOf("<"));n(null,{html:o,version:e.version})}},error:function(){T.error(p),setTimeout(function(){oc.renderByHref(e,n)},c)}})})},oc.renderUnloadedComponents=function(){oc.ready(function(){var e=E?"div[data-oc-component=true]":u,t=g(e+"[data-rendered!=true]"),n=function(e,t){oc.renderNestedComponent(g(e[t]),function(){t++,t0&&n(t,0)})},oc.setEventListeners=function(e){oc.ready(function(){e.off("reRender"),e.on("reRender",function(e,t){var n=g(e.target);return t&&""!==t&&n.attr("href",t),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")})},oc.load=function(e,t,n){oc.ready(function(){if("function"!=typeof n&&(n=w),g(e)){g(e).html("<"+u+' href="'+t+'" />');var r=g(u,e);oc.renderNestedComponent(r,function(){n(r)})}})},oc.ready(oc.renderUnloadedComponents)}(Handlebars,head,document,window,!0),oc.clientVersion="0.8.4"; \ No newline at end of file diff --git a/components/oc-client/package.json b/components/oc-client/package.json index 749af3eff..8164e54f3 100644 --- a/components/oc-client/package.json +++ b/components/oc-client/package.json @@ -1,7 +1,7 @@ { "name": "oc-client", "description": "", - "version": "0.8.3", + "version": "0.8.4", "dependencies": {}, "repository": "", "oc": { diff --git a/components/oc-client/src/oc-client.min.js b/components/oc-client/src/oc-client.min.js index b616f5a49..d676309c2 100644 --- a/components/oc-client/src/oc-client.min.js +++ b/components/oc-client/src/oc-client.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.jade=e()}}(function(){return function e(t,n,r){function o(i,c){if(!n[i]){if(!t[i]){var l="function"==typeof require&&require;if(!c&&l)return l(i,!0);if(a)return a(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var s=n[i]={exports:{}};t[i][0].call(s.exports,function(e){var n=t[i][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i/g,">").replace(/"/g,""");return t===""+e?e:t},n.rethrow=function i(t,n,r,o){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&n||o))throw t.message+=" on line "+r,t;try{o=o||e("fs").readFileSync(n,"utf8")}catch(a){i(t,null,r)}var c=3,l=o.split("\n"),u=Math.max(r-c,0),s=Math.min(l.length,r+c),c=l.slice(u,s).map(function(e,t){var n=t+u+1;return(n==r?" > ":" ")+n+"| "+e}).join("\n");throw t.path=n,t.message=(n||"Jade")+":"+r+"\n"+c+"\n\n"+t.message,t}},{fs:2}],2:[function(){},{}]},{},[1])(1)});var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var t;return e.prototype.toString=function(){return""+this.string},t=e}(),t=function(e){"use strict";function t(e){return c[e]||"&"}function n(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}function r(e){return e instanceof i?e.toString():e||0===e?(e=""+e,u.test(e)?e.replace(l,t):e):""}function o(e){return e||0===e?d(e)&&0===e.length?!0:!1:!0}var a={},i=e,c={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},l=/[&<>"'`]/g,u=/[&<>"'`]/;a.extend=n;var s=Object.prototype.toString;a.toString=s;var f=function(e){return"function"==typeof e};f(/x/)&&(f=function(e){return"function"==typeof e&&"[object Function]"===s.call(e)});var f;a.isFunction=f;var d=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===s.call(e):!1};return a.isArray=d,a.escapeExpression=r,a.isEmpty=o,a}(e),n=function(){"use strict";function e(e,t){var r;t&&t.firstLine&&(r=t.firstLine,e+=" - "+r+":"+t.firstColumn);for(var o=Error.prototype.constructor.call(this,e),a=0;a0?e.helpers.each(t,n):r(this):o(t)}),e.registerHelper("each",function(e,t){var n,r=t.fn,o=t.inverse,a=0,i="";if(d(e)&&(e=e.call(this)),t.data&&(n=v(t.data)),e&&"object"==typeof e)if(f(e))for(var c=e.length;c>a;a++)n&&(n.index=a,n.first=0===a,n.last=a===e.length-1),i+=r(e[a],{data:n});else for(var l in e)e.hasOwnProperty(l)&&(n&&(n.key=l,n.index=a,n.first=0===a),i+=r(e[l],{data:n}),a++);return 0===a&&(i=o(this)),i}),e.registerHelper("if",function(e,t){return d(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||i.isEmpty(e)?t.inverse(this):t.fn(this)}),e.registerHelper("unless",function(t,n){return e.helpers["if"].call(this,t,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,t){return d(e)&&(e=e.call(this)),i.isEmpty(e)?void 0:t.fn(e)}),e.registerHelper("log",function(t,n){var r=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(r,t)})}function o(e,t){m.log(e,t)}var a={},i=e,c=t,l="1.3.0";a.VERSION=l;var u=4;a.COMPILER_REVISION=u;var s={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};a.REVISION_CHANGES=s;var f=i.isArray,d=i.isFunction,p=i.toString,h="[object Object]";a.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,t,n){if(p.call(e)===h){if(n||t)throw new c("Arg not supported with multiple helpers");i.extend(this.helpers,e)}else n&&(t.not=n),this.helpers[e]=t},registerPartial:function(e,t){p.call(e)===h?i.extend(this.partials,e):this.partials[e]=t}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,t){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,t)}}};a.logger=m,a.log=o;var v=function(e){var t={};return i.extend(t,e),t};return a.createFrame=v,a}(t,n),o=function(e,t,n){"use strict";function r(e){var t=e&&e[0]||1,n=d;if(t!==n){if(n>t){var r=p[n],o=p[t];throw new f("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+r+") or downgrade your runtime to an older version ("+o+").")}throw new f("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,t){if(!t)throw new f("No environment passed to template");var n=function(e,n,r,o,a,i){var c=t.VM.invokePartial.apply(this,arguments);if(null!=c)return c;if(t.compile){var l={helpers:o,partials:a,data:i};return a[n]=t.compile(e,{data:void 0!==i},t),a[n](r,l)}throw new f("The partial "+n+" could not be compiled when running in runtime-only mode")},r={escapeExpression:s.escapeExpression,invokePartial:n,programs:[],program:function(e,t,n){var r=this.programs[e];return n?r=i(e,t,n):r||(r=this.programs[e]=i(e,t)),r},merge:function(e,t){var n=e||t;return e&&t&&e!==t&&(n={},s.extend(n,t),s.extend(n,e)),n},programWithDepth:t.VM.programWithDepth,noop:t.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var a,i,c=o.partial?o:t;o.partial||(a=o.helpers,i=o.partials);var l=e.call(r,c,n,a,i,o.data);return o.partial||t.VM.checkRevision(r.compilerInfo),l}}function a(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},t.apply(this,[e,o.data||n].concat(r))};return o.program=e,o.depth=r.length,o}function i(e,t,n){var r=function(e,r){return r=r||{},t(e,r.data||n)};return r.program=e,r.depth=0,r}function c(e,t,n,r,o,a){var i={partial:!0,helpers:r,partials:o,data:a};if(void 0===e)throw new f("The partial "+t+" could not be found");return e instanceof Function?e(n,i):void 0}function l(){return""}var u={},s=e,f=t,d=n.COMPILER_REVISION,p=n.REVISION_CHANGES;return u.checkRevision=r,u.template=o,u.programWithDepth=a,u.program=i,u.invokePartial=c,u.noop=l,u}(t,n,r),a=function(e,t,n,r,o){"use strict";var a,i=e,c=t,l=n,u=r,s=o,f=function(){var e=new i.HandlebarsEnvironment;return u.extend(e,i),e.SafeString=c,e.Exception=l,e.Utils=u,e.VM=s,e.template=function(t){return s.template(t,e)},e},d=f();return d.create=f,a=d}(r,e,n,t,o);return a}();!function(e,t){"use strict";function n(){}function r(e,t){if(e){"object"==typeof e&&(e=[].slice.call(e));for(var n=0,r=e.length;r>n;n++)t.call(e,e[n],n)}}function o(e,n){var r=Object.prototype.toString.call(n).slice(8,-1);return n!==t&&null!==n&&r===e}function a(e){return o("Function",e)}function i(e){return o("Array",e)}function c(e){var t=e.split("/"),n=t[t.length-1],r=n.indexOf("?");return-1!==r?n.substring(0,r):n}function l(e){e=e||n,e._done||(e(),e._done=1)}function u(e,t,r,o){var a="object"==typeof e?e:{test:e,success:t?i(t)?t:[t]:!1,failure:r?i(r)?r:[r]:!1,callback:o||n},c=!!a.test;return c&&a.success?(a.success.push(a.callback),L.load.apply(null,a.success)):!c&&a.failure?(a.failure.push(a.callback),L.load.apply(null,a.failure)):o(),L}function s(e){var t={};if("object"==typeof e)for(var n in e)e[n]&&(t={name:n,url:e[n]});else t={name:c(e),url:e};var r=M[t.name];return r&&r.url===t.url?r:(M[t.name]=t,t)}function f(e){e=e||M;for(var t in e)if(e.hasOwnProperty(t)&&e[t].state!==C)return!1;return!0}function d(e){e.state=N,r(e.onpreload,function(e){e.call()})}function p(e){e.state===t&&(e.state=k,e.onpreload=[],g({url:e.url,type:"cache"},function(){d(e)}))}function h(){var e=arguments,t=e[e.length-1],n=[].slice.call(e,1),o=n[0];return a(t)||(t=null),i(e[0])?(e[0].push(t),L.load.apply(null,e[0]),L):(o?(r(n,function(e){!a(e)&&e&&p(s(e))}),v(s(e[0]),a(o)?o:function(){L.load.apply(null,n)})):v(s(e[0])),L)}function m(){var e=arguments,t=e[e.length-1],n={};return a(t)||(t=null),i(e[0])?(e[0].push(t),L.load.apply(null,e[0]),L):(r(e,function(e){e!==t&&(e=s(e),n[e.name]=e)}),r(e,function(e){e!==t&&(e=s(e),v(e,function(){f(n)&&l(t)}))}),L)}function v(e,t){return t=t||n,e.state===C?void t():e.state===H?void L.ready(e.name,t):e.state===k?void e.onpreload.push(function(){v(e,t)}):(e.state=H,void g(e,function(){e.state=C,t(),r(T[e.name],function(e){l(e)}),S&&f()&&r(T.ALL,function(e){l(e)})}))}function y(e){e=e||"";var t=e.split("?")[0].split(".");return t[t.length-1].toLowerCase()}function g(t,r){function o(t){t=t||e.event,c.onload=c.onreadystatechange=c.onerror=null,r()}function a(n){n=n||e.event,("load"===n.type||/loaded|complete/.test(c.readyState)&&(!x.documentMode||x.documentMode<9))&&(e.clearTimeout(t.errorTimeout),e.clearTimeout(t.cssTimeout),c.onload=c.onreadystatechange=c.onerror=null,r())}function i(){if(t.state!==C&&t.cssRetries<=20){for(var n=0,r=x.styleSheets.length;r>n;n++)if(x.styleSheets[n].href===c.href)return void a({type:"load"});t.cssRetries++,t.cssTimeout=e.setTimeout(i,250)}}r=r||n;var c,l=y(t.url);"css"===l?(c=x.createElement("link"),c.type="text/"+(t.type||"css"),c.rel="stylesheet",c.href=t.url,t.cssRetries=0,t.cssTimeout=e.setTimeout(i,500)):(c=x.createElement("script"),c.type="text/"+(t.type||"javascript"),c.src=t.url),c.onload=c.onreadystatechange=a,c.onerror=o,c.async=!1,c.defer=!1,t.errorTimeout=e.setTimeout(function(){o({type:"timeout"})},7e3);var u=x.head||x.getElementsByTagName("head")[0];u.insertBefore(c,u.lastChild)}function w(){for(var e=x.getElementsByTagName("script"),t=0,n=e.length;n>t;t++){var r=e[t].getAttribute("data-headjs-load");if(r)return void L.load(r)}}function b(e,t){if(e===x)return S?l(t):O.push(t),L;if(a(e)&&(t=e,e="ALL"),i(e)){var n={};return r(e,function(e){n[e]=M[e],L.ready(e,function(){f(n)&&l(t)})}),L}if("string"!=typeof e||!a(t))return L;var o=M[e];if(o&&o.state===C||"ALL"===e&&f()&&S)return l(t),L;var c=T[e];return c?c.push(t):c=T[e]=[t],L}function E(){return x.body?void(S||(S=!0,w(),r(O,function(e){l(e)}))):(e.clearTimeout(L.readyTimeout),void(L.readyTimeout=e.setTimeout(E,50)))}function j(){x.addEventListener?(x.removeEventListener("DOMContentLoaded",j,!1),E()):"complete"===x.readyState&&(x.detachEvent("onreadystatechange",j),E())}var S,x=e.document,O=[],T={},M={},A="async"in x.createElement("script")||"MozAppearance"in x.documentElement.style||e.opera,I=e.head_conf&&e.head_conf.head||"head",L=e[I]=e[I]||function(){L.ready.apply(null,arguments)},k=1,N=2,H=3,C=4;if("complete"===x.readyState)E();else if(x.addEventListener)x.addEventListener("DOMContentLoaded",j,!1),e.addEventListener("load",E,!1);else{x.attachEvent("onreadystatechange",j),e.attachEvent("onload",E);var R=!1;try{R=!e.frameElement&&x.documentElement}catch(q){}R&&R.doScroll&&!function P(){if(!S){try{R.doScroll("left")}catch(t){return e.clearTimeout(L.readyTimeout),void(L.readyTimeout=e.setTimeout(P,50))}E()}}()}L.load=L.js=A?m:h,L.test=u,L.ready=b,L.ready(x,function(){f()&&r(T.ALL,function(e){l(e)}),L.feature&&L.feature("domloaded",!0)})}(window);var oc=oc||{};!function(e,t,n,r,o){var a="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js",i="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js",c=5e3,l=500,u="oc-component",s="Href parameter missing",f="Error loading {0} component",d="Error rendering component: {0}, error: {1}",p="Failed to retrieve the component. Retrying in {0} seconds...".replace("{0}",c/1e3),h="Error loading component: view engine {0} not supported",m="Loading...",v="Component '{0}' correctly rendered",y="Unrendered component found. Trying to retrieve it...",g="undefined"!=typeof jQuery?jQuery:void 0,w=function(){},b=r.navigator.userAgent,E=!!b.match(/MSIE 8/),j=!!b.match(/MSIE 9/),S=!1,x=!1,O=[],T={error:function(e){return console.log(e)},info:function(e){return o?console.log(e):void 0}},M=function(e,t,n){var r=Math.floor(9999999999*Math.random());e.html(t.html),e.attr("id",r),e.attr("data-rendered",!0),e.attr("data-rendering",!1),e.attr("data-version",t.version),t.key&&(e.attr("data-hash",t.key),oc.setEventListeners(e)),n()};oc.ready=function(e){if(S)return e();if(x)O.push(e);else{x=!0;var n=function(e){E||j?t.load(a,e):e()},r=function(){S=!0,x=!1,e();for(var t=0;t'+m+""),oc.renderByHref(e.attr("href"),function(n,r){return!n&&r&&r.html?void M(e,r,t):T.error(n)}))})},oc.renderByHref=function(e,n){oc.ready(function(){return""===e?n(d.replace("{1}",s)):void g.ajax({url:e,headers:{"render-mode":"pre-rendered"},crossDomain:!0,async:!0,success:function(e){if("pre-rendered"===e.renderMode)t.load([e.template.src],function(){oc.render(e.template,e.data,function(t,r){return t?n(d.replace("{0}",e.href).replace("{1}",t)):(T.info(v.replace("{0}",e.template.src)),void n(null,{html:r,key:e.template.key,version:e.version}))})});else if("rendered"===e.renderMode){T.info(v.replace("{0}",e.href));var r=e.html.slice(e.html.indexOf(">")+1),o=r.slice(0,r.lastIndexOf("<"));n(null,{html:o,version:e.version})}},error:function(){T.error(p),setTimeout(function(){oc.renderByHref(e,n)},c)}})})},oc.renderUnloadedComponents=function(){oc.ready(function(){var e=E?"div[data-oc-component=true]":u,t=g(e+"[data-rendered!=true]"),n=function(e,t){oc.renderNestedComponent(g(e[t]),function(){t++,t0&&n(t,0)})},oc.setEventListeners=function(e){oc.ready(function(){e.off("reRender"),e.on("reRender",function(e,t){var n=g(e.target);return t&&""!==t&&n.attr("href",t),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")})},oc.load=function(e,t,n){oc.ready(function(){if("function"!=typeof n&&(n=w),g(e)){g(e).html("<"+u+' href="'+t+'" />');var r=g(u,e);oc.renderNestedComponent(r,function(){n(r)})}})},oc.ready(oc.renderUnloadedComponents)}(Handlebars,head,document,window,!0),oc.clientVersion="0.8.3"; \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.jade=e()}}(function(){return function e(t,n,r){function o(i,c){if(!n[i]){if(!t[i]){var l="function"==typeof require&&require;if(!c&&l)return l(i,!0);if(a)return a(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var s=n[i]={exports:{}};t[i][0].call(s.exports,function(e){var n=t[i][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i/g,">").replace(/"/g,""");return t===""+e?e:t},n.rethrow=function i(t,n,r,o){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&n||o))throw t.message+=" on line "+r,t;try{o=o||e("fs").readFileSync(n,"utf8")}catch(a){i(t,null,r)}var c=3,l=o.split("\n"),u=Math.max(r-c,0),s=Math.min(l.length,r+c),c=l.slice(u,s).map(function(e,t){var n=t+u+1;return(n==r?" > ":" ")+n+"| "+e}).join("\n");throw t.path=n,t.message=(n||"Jade")+":"+r+"\n"+c+"\n\n"+t.message,t}},{fs:2}],2:[function(){},{}]},{},[1])(1)});var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var t;return e.prototype.toString=function(){return""+this.string},t=e}(),t=function(e){"use strict";function t(e){return c[e]||"&"}function n(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}function r(e){return e instanceof i?e.toString():e||0===e?(e=""+e,u.test(e)?e.replace(l,t):e):""}function o(e){return e||0===e?d(e)&&0===e.length?!0:!1:!0}var a={},i=e,c={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},l=/[&<>"'`]/g,u=/[&<>"'`]/;a.extend=n;var s=Object.prototype.toString;a.toString=s;var f=function(e){return"function"==typeof e};f(/x/)&&(f=function(e){return"function"==typeof e&&"[object Function]"===s.call(e)});var f;a.isFunction=f;var d=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===s.call(e):!1};return a.isArray=d,a.escapeExpression=r,a.isEmpty=o,a}(e),n=function(){"use strict";function e(e,t){var r;t&&t.firstLine&&(r=t.firstLine,e+=" - "+r+":"+t.firstColumn);for(var o=Error.prototype.constructor.call(this,e),a=0;a0?e.helpers.each(t,n):r(this):o(t)}),e.registerHelper("each",function(e,t){var n,r=t.fn,o=t.inverse,a=0,i="";if(d(e)&&(e=e.call(this)),t.data&&(n=v(t.data)),e&&"object"==typeof e)if(f(e))for(var c=e.length;c>a;a++)n&&(n.index=a,n.first=0===a,n.last=a===e.length-1),i+=r(e[a],{data:n});else for(var l in e)e.hasOwnProperty(l)&&(n&&(n.key=l,n.index=a,n.first=0===a),i+=r(e[l],{data:n}),a++);return 0===a&&(i=o(this)),i}),e.registerHelper("if",function(e,t){return d(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||i.isEmpty(e)?t.inverse(this):t.fn(this)}),e.registerHelper("unless",function(t,n){return e.helpers["if"].call(this,t,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,t){return d(e)&&(e=e.call(this)),i.isEmpty(e)?void 0:t.fn(e)}),e.registerHelper("log",function(t,n){var r=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(r,t)})}function o(e,t){m.log(e,t)}var a={},i=e,c=t,l="1.3.0";a.VERSION=l;var u=4;a.COMPILER_REVISION=u;var s={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};a.REVISION_CHANGES=s;var f=i.isArray,d=i.isFunction,p=i.toString,h="[object Object]";a.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,t,n){if(p.call(e)===h){if(n||t)throw new c("Arg not supported with multiple helpers");i.extend(this.helpers,e)}else n&&(t.not=n),this.helpers[e]=t},registerPartial:function(e,t){p.call(e)===h?i.extend(this.partials,e):this.partials[e]=t}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,t){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,t)}}};a.logger=m,a.log=o;var v=function(e){var t={};return i.extend(t,e),t};return a.createFrame=v,a}(t,n),o=function(e,t,n){"use strict";function r(e){var t=e&&e[0]||1,n=d;if(t!==n){if(n>t){var r=p[n],o=p[t];throw new f("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+r+") or downgrade your runtime to an older version ("+o+").")}throw new f("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,t){if(!t)throw new f("No environment passed to template");var n=function(e,n,r,o,a,i){var c=t.VM.invokePartial.apply(this,arguments);if(null!=c)return c;if(t.compile){var l={helpers:o,partials:a,data:i};return a[n]=t.compile(e,{data:void 0!==i},t),a[n](r,l)}throw new f("The partial "+n+" could not be compiled when running in runtime-only mode")},r={escapeExpression:s.escapeExpression,invokePartial:n,programs:[],program:function(e,t,n){var r=this.programs[e];return n?r=i(e,t,n):r||(r=this.programs[e]=i(e,t)),r},merge:function(e,t){var n=e||t;return e&&t&&e!==t&&(n={},s.extend(n,t),s.extend(n,e)),n},programWithDepth:t.VM.programWithDepth,noop:t.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var a,i,c=o.partial?o:t;o.partial||(a=o.helpers,i=o.partials);var l=e.call(r,c,n,a,i,o.data);return o.partial||t.VM.checkRevision(r.compilerInfo),l}}function a(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},t.apply(this,[e,o.data||n].concat(r))};return o.program=e,o.depth=r.length,o}function i(e,t,n){var r=function(e,r){return r=r||{},t(e,r.data||n)};return r.program=e,r.depth=0,r}function c(e,t,n,r,o,a){var i={partial:!0,helpers:r,partials:o,data:a};if(void 0===e)throw new f("The partial "+t+" could not be found");return e instanceof Function?e(n,i):void 0}function l(){return""}var u={},s=e,f=t,d=n.COMPILER_REVISION,p=n.REVISION_CHANGES;return u.checkRevision=r,u.template=o,u.programWithDepth=a,u.program=i,u.invokePartial=c,u.noop=l,u}(t,n,r),a=function(e,t,n,r,o){"use strict";var a,i=e,c=t,l=n,u=r,s=o,f=function(){var e=new i.HandlebarsEnvironment;return u.extend(e,i),e.SafeString=c,e.Exception=l,e.Utils=u,e.VM=s,e.template=function(t){return s.template(t,e)},e},d=f();return d.create=f,a=d}(r,e,n,t,o);return a}();!function(e,t){"use strict";function n(){}function r(e,t){if(e){"object"==typeof e&&(e=[].slice.call(e));for(var n=0,r=e.length;r>n;n++)t.call(e,e[n],n)}}function o(e,n){var r=Object.prototype.toString.call(n).slice(8,-1);return n!==t&&null!==n&&r===e}function a(e){return o("Function",e)}function i(e){return o("Array",e)}function c(e){var t=e.split("/"),n=t[t.length-1],r=n.indexOf("?");return-1!==r?n.substring(0,r):n}function l(e){e=e||n,e._done||(e(),e._done=1)}function u(e,t,r,o){var a="object"==typeof e?e:{test:e,success:t?i(t)?t:[t]:!1,failure:r?i(r)?r:[r]:!1,callback:o||n},c=!!a.test;return c&&a.success?(a.success.push(a.callback),L.load.apply(null,a.success)):!c&&a.failure?(a.failure.push(a.callback),L.load.apply(null,a.failure)):o(),L}function s(e){var t={};if("object"==typeof e)for(var n in e)e[n]&&(t={name:n,url:e[n]});else t={name:c(e),url:e};var r=M[t.name];return r&&r.url===t.url?r:(M[t.name]=t,t)}function f(e){e=e||M;for(var t in e)if(e.hasOwnProperty(t)&&e[t].state!==C)return!1;return!0}function d(e){e.state=N,r(e.onpreload,function(e){e.call()})}function p(e){e.state===t&&(e.state=k,e.onpreload=[],g({url:e.url,type:"cache"},function(){d(e)}))}function h(){var e=arguments,t=e[e.length-1],n=[].slice.call(e,1),o=n[0];return a(t)||(t=null),i(e[0])?(e[0].push(t),L.load.apply(null,e[0]),L):(o?(r(n,function(e){!a(e)&&e&&p(s(e))}),v(s(e[0]),a(o)?o:function(){L.load.apply(null,n)})):v(s(e[0])),L)}function m(){var e=arguments,t=e[e.length-1],n={};return a(t)||(t=null),i(e[0])?(e[0].push(t),L.load.apply(null,e[0]),L):(r(e,function(e){e!==t&&(e=s(e),n[e.name]=e)}),r(e,function(e){e!==t&&(e=s(e),v(e,function(){f(n)&&l(t)}))}),L)}function v(e,t){return t=t||n,e.state===C?void t():e.state===H?void L.ready(e.name,t):e.state===k?void e.onpreload.push(function(){v(e,t)}):(e.state=H,void g(e,function(){e.state=C,t(),r(T[e.name],function(e){l(e)}),S&&f()&&r(T.ALL,function(e){l(e)})}))}function y(e){e=e||"";var t=e.split("?")[0].split(".");return t[t.length-1].toLowerCase()}function g(t,r){function o(t){t=t||e.event,c.onload=c.onreadystatechange=c.onerror=null,r()}function a(n){n=n||e.event,("load"===n.type||/loaded|complete/.test(c.readyState)&&(!x.documentMode||x.documentMode<9))&&(e.clearTimeout(t.errorTimeout),e.clearTimeout(t.cssTimeout),c.onload=c.onreadystatechange=c.onerror=null,r())}function i(){if(t.state!==C&&t.cssRetries<=20){for(var n=0,r=x.styleSheets.length;r>n;n++)if(x.styleSheets[n].href===c.href)return void a({type:"load"});t.cssRetries++,t.cssTimeout=e.setTimeout(i,250)}}r=r||n;var c,l=y(t.url);"css"===l?(c=x.createElement("link"),c.type="text/"+(t.type||"css"),c.rel="stylesheet",c.href=t.url,t.cssRetries=0,t.cssTimeout=e.setTimeout(i,500)):(c=x.createElement("script"),c.type="text/"+(t.type||"javascript"),c.src=t.url),c.onload=c.onreadystatechange=a,c.onerror=o,c.async=!1,c.defer=!1,t.errorTimeout=e.setTimeout(function(){o({type:"timeout"})},7e3);var u=x.head||x.getElementsByTagName("head")[0];u.insertBefore(c,u.lastChild)}function w(){for(var e=x.getElementsByTagName("script"),t=0,n=e.length;n>t;t++){var r=e[t].getAttribute("data-headjs-load");if(r)return void L.load(r)}}function b(e,t){if(e===x)return S?l(t):O.push(t),L;if(a(e)&&(t=e,e="ALL"),i(e)){var n={};return r(e,function(e){n[e]=M[e],L.ready(e,function(){f(n)&&l(t)})}),L}if("string"!=typeof e||!a(t))return L;var o=M[e];if(o&&o.state===C||"ALL"===e&&f()&&S)return l(t),L;var c=T[e];return c?c.push(t):c=T[e]=[t],L}function E(){return x.body?void(S||(S=!0,w(),r(O,function(e){l(e)}))):(e.clearTimeout(L.readyTimeout),void(L.readyTimeout=e.setTimeout(E,50)))}function j(){x.addEventListener?(x.removeEventListener("DOMContentLoaded",j,!1),E()):"complete"===x.readyState&&(x.detachEvent("onreadystatechange",j),E())}var S,x=e.document,O=[],T={},M={},A="async"in x.createElement("script")||"MozAppearance"in x.documentElement.style||e.opera,I=e.head_conf&&e.head_conf.head||"head",L=e[I]=e[I]||function(){L.ready.apply(null,arguments)},k=1,N=2,H=3,C=4;if("complete"===x.readyState)E();else if(x.addEventListener)x.addEventListener("DOMContentLoaded",j,!1),e.addEventListener("load",E,!1);else{x.attachEvent("onreadystatechange",j),e.attachEvent("onload",E);var R=!1;try{R=!e.frameElement&&x.documentElement}catch(q){}R&&R.doScroll&&!function P(){if(!S){try{R.doScroll("left")}catch(t){return e.clearTimeout(L.readyTimeout),void(L.readyTimeout=e.setTimeout(P,50))}E()}}()}L.load=L.js=A?m:h,L.test=u,L.ready=b,L.ready(x,function(){f()&&r(T.ALL,function(e){l(e)}),L.feature&&L.feature("domloaded",!0)})}(window);var oc=oc||{};!function(e,t,n,r,o){var a="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js",i="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js",c=5e3,l=500,u="oc-component",s="Href parameter missing",f="Error loading {0} component",d="Error rendering component: {0}, error: {1}",p="Failed to retrieve the component. Retrying in {0} seconds...".replace("{0}",c/1e3),h="Error loading component: view engine {0} not supported",m="Loading...",v="Component '{0}' correctly rendered",y="Unrendered component found. Trying to retrieve it...",g="undefined"!=typeof jQuery?jQuery:void 0,w=function(){},b=r.navigator.userAgent,E=!!b.match(/MSIE 8/),j=!!b.match(/MSIE 9/),S=!1,x=!1,O=[],T={error:function(e){return console.log(e)},info:function(e){return o?console.log(e):void 0}},M=function(e,t,n){var r=Math.floor(9999999999*Math.random());e.html(t.html),e.attr("id",r),e.attr("data-rendered",!0),e.attr("data-rendering",!1),e.attr("data-version",t.version),t.key&&(e.attr("data-hash",t.key),oc.setEventListeners(e)),n()};oc.ready=function(e){if(S)return e();if(x)O.push(e);else{x=!0;var n=function(e){E||j?t.load(a,e):e()},r=function(){S=!0,x=!1,e();for(var t=0;t'+m+""),oc.renderByHref(e.attr("href"),function(n,r){return!n&&r&&r.html?void M(e,r,t):T.error(n)}))})},oc.renderByHref=function(e,n){oc.ready(function(){return""===e?n(d.replace("{1}",s)):void g.ajax({url:e,headers:{"render-mode":"pre-rendered"},crossDomain:!0,async:!0,success:function(e){if("pre-rendered"===e.renderMode)t.load([e.template.src],function(){oc.render(e.template,e.data,function(t,r){return t?n(d.replace("{0}",e.href).replace("{1}",t)):(T.info(v.replace("{0}",e.template.src)),void n(null,{html:r,key:e.template.key,version:e.version}))})});else if("rendered"===e.renderMode){T.info(v.replace("{0}",e.href));var r=e.html.slice(e.html.indexOf(">")+1),o=r.slice(0,r.lastIndexOf("<"));n(null,{html:o,version:e.version})}},error:function(){T.error(p),setTimeout(function(){oc.renderByHref(e,n)},c)}})})},oc.renderUnloadedComponents=function(){oc.ready(function(){var e=E?"div[data-oc-component=true]":u,t=g(e+"[data-rendered!=true]"),n=function(e,t){oc.renderNestedComponent(g(e[t]),function(){t++,t0&&n(t,0)})},oc.setEventListeners=function(e){oc.ready(function(){e.off("reRender"),e.on("reRender",function(e,t){var n=g(e.target);return t&&""!==t&&n.attr("href",t),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")})},oc.load=function(e,t,n){oc.ready(function(){if("function"!=typeof n&&(n=w),g(e)){g(e).html("<"+u+' href="'+t+'" />');var r=g(u,e);oc.renderNestedComponent(r,function(){n(r)})}})},oc.ready(oc.renderUnloadedComponents)}(Handlebars,head,document,window,!0),oc.clientVersion="0.8.4"; \ No newline at end of file diff --git a/package.json b/package.json index d0878a94b..e19e9495b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oc", - "version": "0.8.3", + "version": "0.8.4", "description": "An experimental framework to develop and distribute html components", "main": "index.js", "bin": {