prismic.io
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -1,1 +0,1 @@ | ||
!function(){"function"!=typeof Object.create&&(Object.create=function(){var t=function(){};return function(e){if(arguments.length>1)throw Error("Second argument not supported");if("object"!=typeof e)throw TypeError("Argument must be an object");t.prototype=e;var n={};return t.prototype=null,n}}())}(),function(t,e){"use strict";function n(t,e,n,r,i,o){this.name=t,this.fields=e,this.form_method=n,this.rel=r,this.enctype=i,this.action=o}function r(t,e,n){this.api=t,this.form=e,this.data=n||{};for(var r in e.fields)e.fields[r]["default"]&&(this.data[r]=[e.fields[r]["default"]])}function i(t,e,n,r,i,o,s,a){this.page=t,this.results_per_page=e,this.results_size=n,this.total_results_size=r,this.total_pages=i,this.next_page=o,this.prev_page=s,this.results=a}function o(t,e,n,r,i){this.ref=t,this.label=e,this.isMaster=n,this.scheduledAt=r,this.id=i}function s(){var e;return e="object"==typeof global?global:window,e.prismicCache||(e.prismicCache=new t.Prismic.ApiCache),e.prismicCache}var a=function(e,n,r,i,o,s){var u=new a.fn.init(e,r,i,o,s);return u.get(function(e,r){return n&&e?n(e):(r&&(u.data=r,u.bookmarks=r.bookmarks,u.experiments=new t.Prismic.Experiments(r.experiments)),n?n(null,u):void 0)}),u};a.fn=a.prototype={AT:"at",ANY:"any",SIMILAR:"similar",FULLTEXT:"fulltext",NUMBER:{GT:"number.gt",LT:"number.lt"},DATE:{AFTER:"date.after",BEFORE:"date.before",BETWEEN:"date.between"},DOCUMENT:{ID:"document.id",TYPE:"document.type",TAGS:"document.tags"},constructor:a,data:null,get:function(t){var e=this,n=this.apiCacheKey;this.apiCache.get(n,function(r,i){return r?t(r):i?t(null,i):void e.requestHandler(e.url,function(r,i,o,s){if(r)return t(r,null,o);var a=e.parse(i);s=s||e.apiDataTTL,e.apiCache.set(n,a,s,function(e){return e?t(e,null,o):t(null,a,o)})})})},refresh:function(e){var n=this,r=this.apiCacheKey;this.apiCache.remove(r,function(r){if(e&&r)return e(r);if(!e&&r)throw r;n.get(function(r,i,o){if(e&&r)return e(r);if(!e&&r)throw r;return n.data=i,n.bookmarks=i.bookmarks,n.experiments=new t.Prismic.Experiments(i.experiments),e?e():void 0})})},parse:function(t){var e,r,i,s,a,u,l,c={};for(l in t.forms)t.forms.hasOwnProperty(l)&&(u=t.forms[l],this.accessToken&&(u.fields.access_token={},u.fields.access_token.type="string",u.fields.access_token["default"]=this.accessToken),i=new n(u.name,u.fields,u.form_method,u.rel,u.enctype,u.action),c[l]=i);if(e=t.refs.map(function(t){return new o(t.ref,t.label,t.isMasterRef,t.scheduledAt,t.id)})||[],r=e.filter(function(t){return t.isMaster===!0}),s=t.types,a=t.tags,0===r.length)throw"No master ref.";return{bookmarks:t.bookmarks||{},refs:e,forms:c,master:r[0],types:s,tags:a,experiments:t.experiments,oauthInitiate:t.oauth_initiate,oauthToken:t.oauth_token}},init:function(e,n,r,i,o){return this.url=e+(n?(e.indexOf("?")>-1?"&":"?")+"access_token="+n:""),this.accessToken=n,this.apiCache=i||s(),this.requestHandler=r||t.Prismic.Utils.request(),this.apiCacheKey=this.url+(this.accessToken?"#"+this.accessToken:""),this.apiDataTTL=o||5,this},forms:function(t){return this.form(t)},form:function(t){var e=this.data.forms[t];return e?new r(this,e,{}):void 0},master:function(){return this.data.master.ref},ref:function(t){for(var e=0;e<this.data.refs.length;e++)if(this.data.refs[e].label==t)return this.data.refs[e].ref},currentExperiment:function(){return this.experiments.current()},parseDoc:function(n){var r={};for(var i in n.data[n.type])r[n.type+"."+i]=n.data[n.type][i];var o=[];if(n.slugs!==e)for(var s=0;s<n.slugs.length;s++)o.push(decodeURIComponent(n.slugs[s]));return new t.Prismic.Document(n.id,n.uid||null,n.type,n.href,n.tags,o,r)},previewSession:function(e,n,r,i){var o=this,s=t.Prismic.Predicates;this.requestHandler(e,function(t,a,u){if(t)return console.log("Error from the request"),void i(t,r,u);try{var l=a.mainDocument;l?o.form("everything").query(s.at("document.id",l)).ref(e).submit(function(t,e){t&&i(t);try{0===e.results.length?i(null,r,u):i(null,n(e.results[0]),u)}catch(o){i(o)}}):i(null,r,u)}catch(c){console.log("Caught e ",c),i(c,r,u)}})},request:function(t,e){var n=this,r=t+(this.accessToken?"#"+this.accessToken:""),o=this.apiCache;o.get(r,function(s,u){return s?e(s):u?e(null,u):void n.requestHandler(t,function(t,n,s,u){if(t)return void e(t,null,s);var l=n.results.map(a.fn.parseDoc),c=new i(n.page,n.results_per_page,n.results_size,n.total_results_size,n.total_pages,n.next_page,n.prev_page,l||[]);return u?void o.set(r,c,u,function(t){return t?e(t):e(null,c)}):e(null,c)})})}},a.fn.init.prototype=a.fn,n.prototype={},r.prototype={set:function(t,n){var r=this.form.fields[t];if(!r)throw new Error("Unknown field "+t);var i=this.data[t]||[];return(""===n||n===e)&&(n=null),r.multiple?n&&i.push(n):i=n&&[n],this.data[t]=i,this},ref:function(t){return this.set("ref",t)},query:function(t){if("string"==typeof t)return this.set("q",t);var e=[].slice.apply(arguments),n=[];return e.forEach(function(t){var e=0===t[1].indexOf("my.")||0===t[1].indexOf("document")?t[1]:'"'+t[1]+'"';n.push("[:d = "+t[0]+"("+e+(t.length>2?", ":"")+function(){return t.slice(2).map(function(t){return"string"==typeof t?'"'+t+'"':Array.isArray(t)?"["+t.map(function(t){return'"'+t+'"'}).join(",")+"]":t instanceof Date?t.getTime():t}).join(",")}()+")]")}),this.query("["+n.join("")+"]")},pageSize:function(t){return this.set("pageSize",t)},fetch:function(t){return t instanceof Array&&(t=t.join(",")),this.set("fetch",t)},fetchLinks:function(t){return t instanceof Array&&(t=t.join(",")),this.set("fetchLinks",t)},page:function(t){return this.set("page",t)},orderings:function(t){return"string"==typeof t?this.set("orderings",t):t?this.set("orderings","["+t.join(",")+"]"):this},submit:function(t){var e=this.form.action;if(this.data){var n=e.indexOf("?")>-1?"&":"?";for(var r in this.data)if(this.data.hasOwnProperty(r)){var i=this.data[r];if(i)for(var o=0;o<i.length;o++)e+=n+r+"="+encodeURIComponent(i[o]),n="&"}}this.api.request(e,t)}},o.prototype={},t.Prismic={experimentCookie:"io.prismic.experiment",previewCookie:"io.prismic.preview",Api:a}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){function n(t){this.size=0,this.limit=t,this._keymap={}}n.prototype.put=function(t,e){var n={key:t,value:e};return this._keymap[t]=n,this.tail?(this.tail.newer=n,n.older=this.tail):this.head=n,this.tail=n,this.size===this.limit?this.shift():void this.size++},n.prototype.shift=function(){var t=this.head;return t&&(this.head.newer?(this.head=this.head.newer,this.head.older=e):this.head=e,t.newer=t.older=e,delete this._keymap[t.key]),t},n.prototype.get=function(t,n){var r=this._keymap[t];if(r!==e)return r===this.tail?n?r:r.value:(r.newer&&(r===this.head&&(this.head=r.newer),r.newer.older=r.older),r.older&&(r.older.newer=r.newer),r.newer=e,r.older=this.tail,this.tail&&(this.tail.newer=r),this.tail=r,n?r:r.value)},n.prototype.find=function(t){return this._keymap[t]},n.prototype.set=function(t,e){var n,r=this.get(t,!0);return r?(n=r.value,r.value=e):(n=this.put(t,e),n&&(n=n.value)),n},n.prototype.remove=function(t){var n=this._keymap[t];if(n)return delete this._keymap[n.key],n.newer&&n.older?(n.older.newer=n.newer,n.newer.older=n.older):n.newer?(n.newer.older=e,this.head=n.newer):n.older?(n.older.newer=e,this.tail=n.older):this.head=this.tail=e,this.size--,n.value},n.prototype.removeAll=function(){this.head=this.tail=e,this.size=0,this._keymap={}},n.prototype.keys="function"==typeof Object.keys?function(){return Object.keys(this._keymap)}:function(){var t=[];for(var e in this._keymap)t.push(e);return t},n.prototype.forEach=function(t,n,r){var i;if(n===!0?(r=!0,n=e):"object"!=typeof n&&(n=this),r)for(i=this.tail;i;)t.call(n,i.key,i.value,this),i=i.older;else for(i=this.head;i;)t.call(n,i.key,i.value,this),i=i.newer},n.prototype.toJSON=function(){for(var t=[],e=this.head;e;)t.push({key:e.key.toJSON(),value:e.value.toJSON()}),e=e.newer;return t},n.prototype.toString=function(){for(var t="",e=this.head;e;)t+=String(e.key)+":"+e.value,e=e.newer,e&&(t+=" < ");return t},t.Prismic.LRUCache=n}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){"use strict";function n(e){this.lru=new t.Prismic.LRUCache(e)}n.prototype={get:function(t,e){var n=this.lru.get(t);return n&&!this.isExpired(t)?e(null,n.data):e()},set:function(t,e,n,r){return this.lru.remove(t),this.lru.put(t,{data:e,expiredIn:n?Date.now()+1e3*n:0}),r()},isExpired:function(t){var e=this.lru.get(t);return e?0!==e.expiredIn&&e.expiredIn<Date.now():!1},remove:function(t,e){return this.lru.remove(t),e()},clear:function(t){return this.lru.removeAll(),t()}},t.Prismic.ApiCache=n}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){"use strict";var n=function(){return"undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest?function(t,e){var n=new XMLHttpRequest,r=function(){var t,r=/max-age\s*=\s*(\d+)/.exec(n.getResponseHeader("Cache-Control"));r&&r.length>1&&(t=parseInt(r[1],10)),e(null,JSON.parse(n.responseText),n,t)},i=function(){var r=n.status;e(new Error("Unexpected status code ["+r+"] on URL "+t),null,n)};n.onreadystatechange=function(){4===n.readyState&&(n.status&&200==n.status?r():i())},n.open("GET",t,!0),n.setRequestHeader("Accept","application/json"),n.send()}:void 0},r=function(){return"undefined"!=typeof XDomainRequest?function(t,e){var n=new XDomainRequest,r=function(){e(null,JSON.parse(n.responseText),n,0)},i=function(t){e(new Error(t),null,n)};n.onload=function(){r(n)},n.onerror=function(){i("Unexpected status code on URL "+t)},n.open("GET",t,!0),n.ontimeout=function(){i("Request timeout")},n.onprogress=function(){},n.send()}:void 0},i=function(){if("function"==typeof require&&require("http")){var t=require("http"),n=require("https"),r=require("url"),i=(require("querystring"),require("../package.json"));return function(o,s){var a=r.parse(o),u="https:"==a.protocol?n:t,l={hostname:a.hostname,path:a.path,query:a.query,headers:{Accept:"application/json","User-Agent":"Prismic-javascript-kit/"+i.version+" NodeJS/"+process.version}},c=u.get(l,function(t){if(t.statusCode&&200==t.statusCode){var n="";t.setEncoding("utf8"),t.on("data",function(t){n+=t}),t.on("end",function(){var r=JSON.parse(n),i=t.headers["cache-control"],o=i&&/max-age=(\d+)/.test(i)?parseInt(/max-age=(\d+)/.exec(i)[1],10):e;s(null,r,t,o)})}else s(new Error("Unexpected status code ["+t.statusCode+"] on URL "+o),null,t)});c.on("error",function(t){s(new Error("Unexpected error on URL "+o),null,t)})}}},o=0,s=[],a=function(){if(!(0===s.length||o>=t.Prismic.Utils.MAX_CONNECTIONS)){o++;var e=s.shift(),u=n()||r()||i()||function(){throw new Error("No request handler available (tried XMLHttpRequest & NodeJS)")}();u.call(this,e.url,function(t,n,r,i){o--,e.callback(t,n,r,i),a()})}},u=function(){return function(t,e){s.push({url:t,callback:e}),a()}};t.Prismic.Utils={MAX_CONNECTIONS:20,request:u}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){"use strict";function n(){}function r(t,e,n,r,i,o,s){this.id=t,this.uid=e,this.type=n,this.href=r,this.tags=i,this.slug=o?o[0]:"-",this.slugs=o,this.fragments=s}function i(t){this.fragments=t}function o(t){var e={};return t&&"[object Function]"===e.toString.call(t)}n.prototype={get:function(e){var n=this._getFragments(e);return n.length?t.Prismic.Fragments.initField(n[0]):null},getAll:function(e){return this._getFragments(e).map(function(e){return t.Prismic.Fragments.initField(e)},this)},getImage:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.Image?n:n instanceof t.Prismic.Fragments.StructuredText?n:null},getAllImages:function(e){var n=this.getAll(e);return n.map(function(e){if(e instanceof t.Prismic.Fragments.Image)return e;if(e instanceof t.Prismic.Fragments.StructuredText)throw new Error("Not done.");return null})},getImageView:function(e,n){var r=this.get(e);if(r instanceof t.Prismic.Fragments.Image)return r.getView(n);if(r instanceof t.Prismic.Fragments.StructuredText)for(var i=0;i<r.blocks.length;i++)if("image"==r.blocks[i].type)return r.blocks[i];return null},getAllImageViews:function(t,e){return this.getAllImages(t).map(function(t){return t.getView(e)})},getTimestamp:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.Timestamp?n.value:void 0},getDate:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.Date?n.value:void 0},getBoolean:function(t){var e=this.get(t);return e.value&&("yes"==e.value.toLowerCase()||"on"==e.value.toLowerCase()||"true"==e.value.toLowerCase())},getText:function(e,n){var r=this.get(e);return r instanceof t.Prismic.Fragments.StructuredText?r.blocks.map(function(t){return t.text?t.text+(n?n:""):void 0}).join("\n"):r instanceof t.Prismic.Fragments.Text&&r.value?r.value+(n?n:""):r instanceof t.Prismic.Fragments.Number&&r.value?r.value+(n?n:""):r instanceof t.Prismic.Fragments.Select&&r.value?r.value+(n?n:""):r instanceof t.Prismic.Fragments.Color&&r.value?r.value+(n?n:""):void 0},getStructuredText:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.StructuredText?n:null},getLink:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.WebLink||n instanceof t.Prismic.Fragments.DocumentLink||n instanceof t.Prismic.Fragments.ImageLink?n:null},getNumber:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.Number?n.value:null},getColor:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.Color?n.value:null},getGeoPoint:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.GeoPoint?n:null},getGroup:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.Group?n:null},getSliceZone:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.SliceZone?n:null},getHtml:function(t,e){if(!o(e)){var n=e;e=function(t,e){return n.linkResolver(n,t,e)}}var r=this.get(t);return r&&r.asHtml?r.asHtml(e):null},asHtml:function(t){if(!o(t)){var e=t;t=function(t,n){return e.linkResolver(e,t,n)}}var n=[];for(var r in this.fragments){var i=this.get(r);n.push(i&&i.asHtml?'<section data-field="'+r+'">'+i.asHtml(t)+"</section>":"")}return n.join("")},asText:function(t){if(!o(t)){var e=t;t=function(t,n){return e.linkResolver(e,t,n)}}var n=[];for(var r in this.fragments){var i=this.get(r);n.push(i&&i.asText?i.asText(t):"")}return n.join("")},linkedDocuments:function(){var e,n,r,i=[];for(var o in this.fragments){var s=this.get(o);if(s instanceof t.Prismic.Fragments.DocumentLink&&i.push(s),s instanceof t.Prismic.Fragments.StructuredText)for(e=0;e<s.blocks.length;e++){var a=s.blocks[e];"image"==a.type&&a.linkTo&&(r=t.Prismic.Fragments.initField(a.linkTo),r instanceof DocumentLink&&i.push(r));var u=a.spans||[];for(n=0;n<u.length;n++){var l=u[n];"hyperlink"==l.type&&(r=t.Prismic.Fragments.initField(l.data),r instanceof t.Prismic.Fragments.DocumentLink&&i.push(r))}}if(s instanceof t.Prismic.Fragments.Group)for(e=0;e<s.value.length;e++)i=i.concat(s.value[e].linkedDocuments())}return i},_getFragments:function(t){return this.fragments&&this.fragments[t]?Array.isArray(this.fragments[t])?this.fragments[t]:[this.fragments[t]]:[]}},r.prototype=Object.create(n.prototype),i.prototype=Object.create(n.prototype),t.Prismic.WithFragments=n,t.Prismic.Document=r,t.Prismic.GroupDoc=i}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){"use strict";function n(t){this.value=t}function r(t){this.value=t,this.document=t.document,this.id=t.document.id,this.uid=t.document.uid,this.tags=t.document.tags,this.slug=t.document.slug,this.type=t.document.type;var e={};if(t.document.data)for(var n in t.document.data[t.document.type])e[t.document.type+"."+n]=t.document.data[t.document.type][n];this.fragments=e,this.isBroken=t.isBroken}function i(t){this.value=t}function o(t){this.value=t}function s(t){this.value=t}function a(t){this.value=t}function u(t){this.value=t}function l(t){this.latitude=t.latitude,this.longitude=t.longitude}function c(t){this.value=t}function f(t){this.value=new Date(t)}function h(t){var e=24==t.length?t.substring(0,22)+":"+t.substring(22,24):t;this.value=new Date(e)}function p(t){this.value=t}function m(t,e){this.main=t,this.views=e||{}}function d(t,e,n,r){this.url=t,this.width=e,this.height=n,this.alt=r}function g(e){this.value=[];for(var n=0;n<e.length;n++)this.value.push(new t.Prismic.GroupDoc(e[n]))}function v(t){this.blocks=t}function y(t){return t&&t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>")}function x(t,e,n,r){if(!e||!e.length)return y(t);var i={},o={};e.forEach(function(t){i[t.start]||(i[t.start]=[]),o[t.end]||(o[t.end]=[]),i[t.start].push(t),o[t.end].unshift(t)});for(var s,a="",u=[],l=0,c=t.length+1;c>l;l++)o[l]&&o[l].forEach(function(){var t=u.pop();if("undefined"!=typeof t){var e=P(t.span,t.text,r);0===u.length?a+=e:u[u.length-1].text+=e}}),i[l]&&(i[l].sort(function(t,e){return e.end-e.start-(t.end-t.start)}),i[l].forEach(function(t){var e=null;if("hyperlink"==t.type){var r=w(t.data);if(!r)return console&&console.error&&console.error("Impossible to convert span.data as a Fragment",t),"";e=r.url(n),t.url=e}var i={span:t,text:""};u.push(i)})),l<t.length&&(s=t[l],0===u.length?a+=y(s):u[u.length-1].text+=y(s));return a}function b(t,e,n){this.sliceType=t,this.label=e,this.value=n}function k(t){this.value=[];for(var e=0;e<t.length;e++){var n=t[e].slice_type,r=w(t[e].value),i=t[e].slice_label||null;n&&r&&this.value.push(new b(n,i,r))}}function w(t){var e={Color:u,Number:c,Date:f,Timestamp:h,Text:n,Embed:p,GeoPoint:l,Select:a,StructuredText:v,"Link.document":r,"Link.web":i,"Link.file":o,"Link.image":s,Group:g,SliceZone:k};if(e[t.type])return new e[t.type](t.value);if("Image"===t.type){var y=t.value.main,x=new m(new d(y.url,y.dimensions.width,y.dimensions.height,y.alt),{});for(var b in t.value.views)y=t.value.views[b],x.views[b]=new d(y.url,y.dimensions.width,y.dimensions.height,y.alt);return x}console&&console.log&&console.log("Fragment type not supported: ",t.type)}function T(t){var e={};return t&&"[object Function]"===e.toString.call(t)}function P(t,e,n){if(n){var r=n(t,e);if(r)return r}var i={heading1:"h1",heading2:"h2",heading3:"h3",heading4:"h4",heading5:"h5",heading6:"h6",paragraph:"p",preformatted:"pre","list-item":"li","o-list-item":"li","group-list-item":"ul","group-o-list-item":"ol",strong:"strong",em:"em"};if(i[t.type]){var o=i[t.type],s=t.label?' class="'+t.label+'"':"";return"<"+o+s+">"+e+"</"+o+">"}if("image"==t.type){var a=t.label?" "+t.label:"",u='<img src="'+t.url+'" alt="'+t.alt+'">';return'<p class="block-img'+a+'">'+(t.linkUrl?'<a href="'+t.linkUrl+'">'+u+"</a>":u)+"</p>"}return"embed"==t.type?'<div data-oembed="'+t.embed_url+'" data-oembed-type="'+t.type+'" data-oembed-provider="'+t.provider_name+(t.label?'" class="'+t.label:"")+'">'+t.oembed.html+"</div>":"hyperlink"===t.type?'<a href="'+t.url+'">'+e+"</a>":"label"===t.type?'<span class="'+t.data.label+'">'+e+"</span>":"<!-- Warning: "+t.type+" not implemented. Upgrade the Developer Kit. -->"+e}n.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},r.prototype=Object.create(t.Prismic.WithFragments.prototype),r.prototype.asHtml=function(t){return'<a href="'+this.url(t)+'">'+this.url(t)+"</a>"},r.prototype.url=function(t){return t(this,this.isBroken)},r.prototype.asText=function(t){return this.url(t)},i.prototype={asHtml:function(){return'<a href="'+this.url()+'">'+this.url()+"</a>"},url:function(){return this.value.url},asText:function(){return this.url()}},o.prototype={asHtml:function(){return'<a href="'+this.url()+'">'+this.value.file.name+"</a>"},url:function(){return this.value.file.url},asText:function(){return this.url()}},s.prototype={asHtml:function(){return'<a href="'+this.url()+'"><img src="'+this.url()+'" alt="'+this.alt+'"></a>'},url:function(){return this.value.image.url},asText:function(){return this.url()}},a.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},u.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},l.prototype={asHtml:function(){return'<div class="geopoint"><span class="latitude">'+this.latitude+'</span><span class="longitude">'+this.longitude+"</span></div>"},asText:function(){return"("+this.latitude+","+this.longitude+")"}},c.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value.toString()}},f.prototype={asHtml:function(){return"<time>"+this.value+"</time>"},asText:function(){return this.value.toString()}},h.prototype={asHtml:function(){return"<time>"+this.value+"</time>"},asText:function(){return this.value.toString()}},p.prototype={asHtml:function(){return this.value.oembed.html},asText:function(){return""}},m.prototype={getView:function(t){return"main"===t?this.main:this.views[t]},asHtml:function(){return this.main.asHtml()},asText:function(){return""}},d.prototype={ratio:function(){return this.width/this.height},asHtml:function(){return'<img src="'+this.url+'" width="'+this.width+'" height="'+this.height+'" alt="'+this.alt+'">'},asText:function(){return""}},g.prototype={asHtml:function(t){for(var e="",n=0;n<this.value.length;n++)e+=this.value[n].asHtml(t);return e},toArray:function(){return this.value},asText:function(t){for(var e="",n=0;n<this.value.length;n++)e+=this.value[n].asText(t)+"\n";return e}},v.prototype={getTitle:function(){for(var t=0;t<this.blocks.length;t++){var e=this.blocks[t];if(0===e.type.indexOf("heading"))return e}},getFirstParagraph:function(){for(var t=0;t<this.blocks.length;t++){var e=this.blocks[t];if("paragraph"==e.type)return e}},getParagraphs:function(){for(var t=[],e=0;e<this.blocks.length;e++){var n=this.blocks[e];"paragraph"==n.type&&t.push(n)}return t},getParagraph:function(t){return this.getParagraphs()[t]},getFirstImage:function(){for(var t=0;t<this.blocks.length;t++){var e=this.blocks[t];if("image"==e.type)return new d(e.url,e.dimensions.width,e.dimensions.height,e.alt)}},asHtml:function(t,e){var n,r,i=[],o=[];if(!T(t)){var s=t;t=function(t,e){return s.linkResolver(s,t,e)}}if(Array.isArray(this.blocks)){for(var a=0;a<this.blocks.length;a++){if(r=this.blocks[a],"image"==r.type&&r.linkTo){var u=w(r.linkTo);r.linkUrl=u.url(t)}"list-item"!==r.type&&"o-list-item"!==r.type?(i.push(r),n=null):n&&n.type=="group-"+r.type?n.blocks.push(r):(n={type:"group-"+r.type,blocks:[r]},i.push(n))}var l=function(n){var r="";return n.blocks?n.blocks.forEach(function(t){r+=P(t,l(t),e)}):r=x(n.text,n.spans,t,e),r};i.forEach(function(t){o.push(P(t,l(t),e))})}return o.join("")},asText:function(){for(var t=[],e=0;e<this.blocks.length;e++){var n=this.blocks[e];n.text&&t.push(n.text)}return t.join(" ")}},b.prototype={asHtml:function(t){var e=["slice"];return this.label&&e.push(this.label),'<div data-slicetype="'+this.sliceType+'" class="'+e.join(" ")+'">'+this.value.asHtml(t)+"</div>"},asText:function(){return this.value.asText()}},k.prototype={asHtml:function(t){for(var e="",n=0;n<this.value.length;n++)e+=this.value[n].asHtml(t);return e},asText:function(){for(var t="",e=0;e<this.value.length;e++)t+=this.value[e].asText()+"\n";return t}},t.Prismic.Fragments={Image:m,ImageView:d,Text:n,Number:c,Date:f,Timestamp:h,Select:a,Color:u,StructuredText:v,WebLink:i,DocumentLink:r,ImageLink:s,FileLink:o,Group:g,GeoPoint:l,Slice:b,SliceZone:k,initField:w,insertSpans:x}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){"use strict";var n={at:function(t,e){return["at",t,e]},missing:function(t){return["missing",t]},has:function(t){return["has",t]},any:function(t,e){return["any",t,e]},fulltext:function(t,e){return["fulltext",t,e]},similar:function(t,e){return["similar",t,e]},gt:function(t,e){return["number.gt",t,e]},lt:function(t,e){return["number.lt",t,e]},inRange:function(t,e,n){return["number.inRange",t,e,n]},dateBefore:function(t,e){return["date.before",t,e]},dateAfter:function(t,e){return["date.after",t,e]},dateBetween:function(t,e,n){return["date.between",t,e,n]},dayOfMonth:function(t,e){return["date.day-of-month",t,e]},dayOfMonthAfter:function(t,e){return["date.day-of-month-after",t,e]},dayOfMonthBefore:function(t,e){return["date.day-of-month-before",t,e]},dayOfWeek:function(t,e){return["date.day-of-week",t,e]},dayOfWeekAfter:function(t,e){return["date.day-of-week-after",t,e]},dayOfWeekBefore:function(t,e){return["date.day-of-week-before",t,e]},month:function(t,e){return["date.month",t,e]},monthBefore:function(t,e){return["date.month-before",t,e]},monthAfter:function(t,e){return["date.month-after",t,e]},year:function(t,e){return["date.year",t,e]},hour:function(t,e){return["date.hour",t,e]},hourBefore:function(t,e){return["date.hour-before",t,e]},hourAfter:function(t,e){return["date.hour-after",t,e]},near:function(t,e,n,r){return["geopoint.near",t,e,n,r]}};t.Prismic.Predicates=n}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){"use strict";function n(t){var e=[],n=[];t&&(t.drafts&&t.drafts.forEach(function(t){e.push(new r(t))}),t.running&&t.running.forEach(function(t){n.push(new r(t))})),this.drafts=e,this.running=n}function r(t){this.data=t;var e=[];t.variations&&t.variations.forEach(function(t){e.push(new i(t))}),this.variations=e}function i(t){this.data=t}n.prototype.current=function(){return this.running.length>0?this.running[0]:null},n.prototype.refFromCookie=function(t){if(!t||""===t.trim())return null;var e=t.trim().split(" ");if(e.length<2)return null;var n=e[0],r=parseInt(e[1],10),i=this.running.filter(function(t){return t.googleId()==n&&t.variations.length>r})[0];return i?i.variations[r].ref():null},r.prototype.id=function(){return this.data.id},r.prototype.googleId=function(){return this.data.googleId},r.prototype.name=function(){return this.data.name},i.prototype.id=function(){return this.data.id},i.prototype.ref=function(){return this.data.ref},i.prototype.label=function(){return this.data.label},t.Prismic.Experiments=n,t.Prismic.Experiment=r,t.Prismic.Variation=i}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){t.Prismic.version="1.2.1"}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window); | ||
!function(){"function"!=typeof Object.create&&(Object.create=function(){var t=function(){};return function(e){if(arguments.length>1)throw Error("Second argument not supported");if("object"!=typeof e)throw TypeError("Argument must be an object");t.prototype=e;var n={};return t.prototype=null,n}}())}(),function(t,e){"use strict";function n(t,e,n,r,i,o){this.name=t,this.fields=e,this.form_method=n,this.rel=r,this.enctype=i,this.action=o}function r(t,e,n){this.api=t,this.form=e,this.data=n||{};for(var r in e.fields)e.fields[r]["default"]&&(this.data[r]=[e.fields[r]["default"]])}function i(t,e,n,r,i,o,s,a){this.page=t,this.results_per_page=e,this.results_size=n,this.total_results_size=r,this.total_pages=i,this.next_page=o,this.prev_page=s,this.results=a}function o(t,e,n,r,i){this.ref=t,this.label=e,this.isMaster=n,this.scheduledAt=r,this.id=i}function s(){var e;return e="object"==typeof global?global:window,e.prismicCache||(e.prismicCache=new t.Prismic.ApiCache),e.prismicCache}var a=function(e,n,r,i,o,s){var u=new a.fn.init(e,r,i,o,s);return u.get(function(e,r){return n&&e?n(e):(r&&(u.data=r,u.bookmarks=r.bookmarks,u.experiments=new t.Prismic.Experiments(r.experiments)),n?n(null,u):void 0)}),u};a.fn=a.prototype={AT:"at",ANY:"any",SIMILAR:"similar",FULLTEXT:"fulltext",NUMBER:{GT:"number.gt",LT:"number.lt"},DATE:{AFTER:"date.after",BEFORE:"date.before",BETWEEN:"date.between"},DOCUMENT:{ID:"document.id",TYPE:"document.type",TAGS:"document.tags"},constructor:a,data:null,get:function(t){var e=this,n=this.apiCacheKey;this.apiCache.get(n,function(r,i){return r?t(r):i?t(null,i):void e.requestHandler(e.url,function(r,i,o,s){if(r)return t(r,null,o);var a=e.parse(i);s=s||e.apiDataTTL,e.apiCache.set(n,a,s,function(e){return e?t(e,null,o):t(null,a,o)})})})},refresh:function(e){var n=this,r=this.apiCacheKey;this.apiCache.remove(r,function(r){if(e&&r)return e(r);if(!e&&r)throw r;n.get(function(r,i,o){if(e&&r)return e(r);if(!e&&r)throw r;return n.data=i,n.bookmarks=i.bookmarks,n.experiments=new t.Prismic.Experiments(i.experiments),e?e():void 0})})},parse:function(t){var e,r,i,s,a,u,l,c={};for(l in t.forms)t.forms.hasOwnProperty(l)&&(u=t.forms[l],this.accessToken&&(u.fields.access_token={},u.fields.access_token.type="string",u.fields.access_token["default"]=this.accessToken),i=new n(u.name,u.fields,u.form_method,u.rel,u.enctype,u.action),c[l]=i);if(e=t.refs.map(function(t){return new o(t.ref,t.label,t.isMasterRef,t.scheduledAt,t.id)})||[],r=e.filter(function(t){return t.isMaster===!0}),s=t.types,a=t.tags,0===r.length)throw"No master ref.";return{bookmarks:t.bookmarks||{},refs:e,forms:c,master:r[0],types:s,tags:a,experiments:t.experiments,oauthInitiate:t.oauth_initiate,oauthToken:t.oauth_token}},init:function(e,n,r,i,o){return this.url=e+(n?(e.indexOf("?")>-1?"&":"?")+"access_token="+n:""),this.accessToken=n,this.apiCache=i||s(),this.requestHandler=r||t.Prismic.Utils.request(),this.apiCacheKey=this.url+(this.accessToken?"#"+this.accessToken:""),this.apiDataTTL=o||5,this},forms:function(t){return this.form(t)},form:function(t){var e=this.data.forms[t];return e?new r(this,e,{}):void 0},master:function(){return this.data.master.ref},ref:function(t){for(var e=0;e<this.data.refs.length;e++)if(this.data.refs[e].label==t)return this.data.refs[e].ref},currentExperiment:function(){return this.experiments.current()},parseDoc:function(n){var r={};for(var i in n.data[n.type])r[n.type+"."+i]=n.data[n.type][i];var o=[];if(n.slugs!==e)for(var s=0;s<n.slugs.length;s++)o.push(decodeURIComponent(n.slugs[s]));return new t.Prismic.Document(n.id,n.uid||null,n.type,n.href,n.tags,o,r)},previewSession:function(e,n,r,i){var o=this,s=t.Prismic.Predicates;this.requestHandler(e,function(t,a,u){if(t)return console.log("Error from the request"),void i(t,r,u);try{var l=a.mainDocument;l?o.form("everything").query(s.at("document.id",l)).ref(e).submit(function(t,e){t&&i(t);try{0===e.results.length?i(null,r,u):i(null,n(e.results[0]),u)}catch(o){i(o)}}):i(null,r,u)}catch(c){console.log("Caught e ",c),i(c,r,u)}})},request:function(t,e){var n=this,r=t+(this.accessToken?"#"+this.accessToken:""),o=this.apiCache;o.get(r,function(s,u){return s?e(s):u?e(null,u):void n.requestHandler(t,function(t,n,s,u){if(t)return void e(t,null,s);var l=n.results.map(a.fn.parseDoc),c=new i(n.page,n.results_per_page,n.results_size,n.total_results_size,n.total_pages,n.next_page,n.prev_page,l||[]);return u?void o.set(r,c,u,function(t){return t?e(t):e(null,c)}):e(null,c)})})}},a.fn.init.prototype=a.fn,n.prototype={},r.prototype={set:function(t,n){var r=this.form.fields[t];if(!r)throw new Error("Unknown field "+t);var i=this.data[t]||[];return(""===n||n===e)&&(n=null),r.multiple?n&&i.push(n):i=n&&[n],this.data[t]=i,this},ref:function(t){return this.set("ref",t)},query:function(t){if("string"==typeof t)return this.set("q",t);var e=[].slice.apply(arguments),n=[];return e.forEach(function(t){var e=0===t[1].indexOf("my.")||0===t[1].indexOf("document")?t[1]:'"'+t[1]+'"';n.push("[:d = "+t[0]+"("+e+(t.length>2?", ":"")+function(){return t.slice(2).map(function(t){return"string"==typeof t?'"'+t+'"':Array.isArray(t)?"["+t.map(function(t){return'"'+t+'"'}).join(",")+"]":t instanceof Date?t.getTime():t}).join(",")}()+")]")}),this.query("["+n.join("")+"]")},pageSize:function(t){return this.set("pageSize",t)},fetch:function(t){return t instanceof Array&&(t=t.join(",")),this.set("fetch",t)},fetchLinks:function(t){return t instanceof Array&&(t=t.join(",")),this.set("fetchLinks",t)},page:function(t){return this.set("page",t)},orderings:function(t){return"string"==typeof t?this.set("orderings",t):t?this.set("orderings","["+t.join(",")+"]"):this},submit:function(t){var e=this.form.action;if(this.data){var n=e.indexOf("?")>-1?"&":"?";for(var r in this.data)if(this.data.hasOwnProperty(r)){var i=this.data[r];if(i)for(var o=0;o<i.length;o++)e+=n+r+"="+encodeURIComponent(i[o]),n="&"}}this.api.request(e,t)}},o.prototype={},t.Prismic={experimentCookie:"io.prismic.experiment",previewCookie:"io.prismic.preview",Api:a}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){function n(t){this.size=0,this.limit=t,this._keymap={}}n.prototype.put=function(t,e){var n={key:t,value:e};return this._keymap[t]=n,this.tail?(this.tail.newer=n,n.older=this.tail):this.head=n,this.tail=n,this.size===this.limit?this.shift():void this.size++},n.prototype.shift=function(){var t=this.head;return t&&(this.head.newer?(this.head=this.head.newer,this.head.older=e):this.head=e,t.newer=t.older=e,delete this._keymap[t.key]),t},n.prototype.get=function(t,n){var r=this._keymap[t];if(r!==e)return r===this.tail?n?r:r.value:(r.newer&&(r===this.head&&(this.head=r.newer),r.newer.older=r.older),r.older&&(r.older.newer=r.newer),r.newer=e,r.older=this.tail,this.tail&&(this.tail.newer=r),this.tail=r,n?r:r.value)},n.prototype.find=function(t){return this._keymap[t]},n.prototype.set=function(t,e){var n,r=this.get(t,!0);return r?(n=r.value,r.value=e):(n=this.put(t,e),n&&(n=n.value)),n},n.prototype.remove=function(t){var n=this._keymap[t];if(n)return delete this._keymap[n.key],n.newer&&n.older?(n.older.newer=n.newer,n.newer.older=n.older):n.newer?(n.newer.older=e,this.head=n.newer):n.older?(n.older.newer=e,this.tail=n.older):this.head=this.tail=e,this.size--,n.value},n.prototype.removeAll=function(){this.head=this.tail=e,this.size=0,this._keymap={}},n.prototype.keys="function"==typeof Object.keys?function(){return Object.keys(this._keymap)}:function(){var t=[];for(var e in this._keymap)t.push(e);return t},n.prototype.forEach=function(t,n,r){var i;if(n===!0?(r=!0,n=e):"object"!=typeof n&&(n=this),r)for(i=this.tail;i;)t.call(n,i.key,i.value,this),i=i.older;else for(i=this.head;i;)t.call(n,i.key,i.value,this),i=i.newer},n.prototype.toJSON=function(){for(var t=[],e=this.head;e;)t.push({key:e.key.toJSON(),value:e.value.toJSON()}),e=e.newer;return t},n.prototype.toString=function(){for(var t="",e=this.head;e;)t+=String(e.key)+":"+e.value,e=e.newer,e&&(t+=" < ");return t},t.Prismic.LRUCache=n}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){"use strict";function n(e){this.lru=new t.Prismic.LRUCache(e)}n.prototype={get:function(t,e){var n=this.lru.get(t);return n&&!this.isExpired(t)?e(null,n.data):e()},set:function(t,e,n,r){return this.lru.remove(t),this.lru.put(t,{data:e,expiredIn:n?Date.now()+1e3*n:0}),r()},isExpired:function(t){var e=this.lru.get(t);return e?0!==e.expiredIn&&e.expiredIn<Date.now():!1},remove:function(t,e){return this.lru.remove(t),e()},clear:function(t){return this.lru.removeAll(),t()}},t.Prismic.ApiCache=n}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){"use strict";var n=function(){return"undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest?function(t,e){var n=new XMLHttpRequest,r=function(){var t,r=/max-age\s*=\s*(\d+)/.exec(n.getResponseHeader("Cache-Control"));r&&r.length>1&&(t=parseInt(r[1],10)),e(null,JSON.parse(n.responseText),n,t)},i=function(){var r=n.status;e(new Error("Unexpected status code ["+r+"] on URL "+t),null,n)};n.onreadystatechange=function(){4===n.readyState&&(n.status&&200==n.status?r():i())},n.open("GET",t,!0),n.setRequestHeader("Accept","application/json"),n.send()}:void 0},r=function(){return"undefined"!=typeof XDomainRequest?function(t,e){var n=new XDomainRequest,r=function(){e(null,JSON.parse(n.responseText),n,0)},i=function(t){e(new Error(t),null,n)};n.onload=function(){r(n)},n.onerror=function(){i("Unexpected status code on URL "+t)},n.open("GET",t,!0),n.ontimeout=function(){i("Request timeout")},n.onprogress=function(){},n.send()}:void 0},i=function(){if("function"==typeof require&&require("http")){var t=require("http"),n=require("https"),r=require("url"),i=(require("querystring"),require("../package.json"));return function(o,s){var a=r.parse(o),u="https:"==a.protocol?n:t,l={hostname:a.hostname,path:a.path,query:a.query,headers:{Accept:"application/json","User-Agent":"Prismic-javascript-kit/"+i.version+" NodeJS/"+process.version}},c=u.get(l,function(t){if(t.statusCode&&200==t.statusCode){var n="";t.setEncoding("utf8"),t.on("data",function(t){n+=t}),t.on("end",function(){var r=JSON.parse(n),i=t.headers["cache-control"],o=i&&/max-age=(\d+)/.test(i)?parseInt(/max-age=(\d+)/.exec(i)[1],10):e;s(null,r,t,o)})}else s(new Error("Unexpected status code ["+t.statusCode+"] on URL "+o),null,t)});c.on("error",function(t){s(new Error("Unexpected error on URL "+o),null,t)})}}},o=0,s=[],a=function(){if(!(0===s.length||o>=t.Prismic.Utils.MAX_CONNECTIONS)){o++;var e=s.shift(),u=n()||r()||i()||function(){throw new Error("No request handler available (tried XMLHttpRequest & NodeJS)")}();u.call(this,e.url,function(t,n,r,i){o--,e.callback(t,n,r,i),a()})}},u=function(){return function(t,e){s.push({url:t,callback:e}),a()}};t.Prismic.Utils={MAX_CONNECTIONS:20,request:u}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){"use strict";function n(){}function r(e,n,r,i,o,s,a){this.id=e,this.uid=n,this.type=r,this.href=i,this.tags=o,this.slug=s?s[0]:"-",this.slugs=s,this.data=a,this.fragments=t.Prismic.Fragments.parseFragments(a)}function i(e){this.data=e,this.fragments=t.Prismic.Fragments.parseFragments(e)}function o(t){var e={};return t&&"[object Function]"===e.toString.call(t)}n.prototype={get:function(t){var e=this._getFragments(t);return e.length?e[0]:null},getAll:function(t){return this._getFragments(t)},getImage:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.Image?n:n instanceof t.Prismic.Fragments.StructuredText?n:null},getAllImages:function(e){var n=this.getAll(e);return n.map(function(e){if(e instanceof t.Prismic.Fragments.Image)return e;if(e instanceof t.Prismic.Fragments.StructuredText)throw new Error("Not done.");return null})},getImageView:function(e,n){var r=this.get(e);if(r instanceof t.Prismic.Fragments.Image)return r.getView(n);if(r instanceof t.Prismic.Fragments.StructuredText)for(var i=0;i<r.blocks.length;i++)if("image"==r.blocks[i].type)return r.blocks[i];return null},getAllImageViews:function(t,e){return this.getAllImages(t).map(function(t){return t.getView(e)})},getTimestamp:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.Timestamp?n.value:void 0},getDate:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.Date?n.value:void 0},getBoolean:function(t){var e=this.get(t);return e.value&&("yes"==e.value.toLowerCase()||"on"==e.value.toLowerCase()||"true"==e.value.toLowerCase())},getText:function(e,n){var r=this.get(e);return r instanceof t.Prismic.Fragments.StructuredText?r.blocks.map(function(t){return t.text?t.text+(n?n:""):void 0}).join("\n"):r instanceof t.Prismic.Fragments.Text&&r.value?r.value+(n?n:""):r instanceof t.Prismic.Fragments.Number&&r.value?r.value+(n?n:""):r instanceof t.Prismic.Fragments.Select&&r.value?r.value+(n?n:""):r instanceof t.Prismic.Fragments.Color&&r.value?r.value+(n?n:""):void 0},getStructuredText:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.StructuredText?n:null},getLink:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.WebLink||n instanceof t.Prismic.Fragments.DocumentLink||n instanceof t.Prismic.Fragments.ImageLink?n:null},getNumber:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.Number?n.value:null},getColor:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.Color?n.value:null},getGeoPoint:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.GeoPoint?n:null},getGroup:function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.Group?n:null},getHtml:function(t,e){if(!o(e)){var n=e;e=function(t,e){return n.linkResolver(n,t,e)}}var r=this.get(t);return r&&r.asHtml?r.asHtml(e):null},asHtml:function(t){if(!o(t)){var e=t;t=function(t,n){return e.linkResolver(e,t,n)}}var n=[];for(var r in this.fragments){var i=this.get(r);n.push(i&&i.asHtml?'<section data-field="'+r+'">'+i.asHtml(t)+"</section>":"")}return n.join("")},asText:function(t){if(!o(t)){var e=t;t=function(t,n){return e.linkResolver(e,t,n)}}var n=[];for(var r in this.fragments){var i=this.get(r);n.push(i&&i.asText?i.asText(t):"")}return n.join("")},linkedDocuments:function(){var e,n,r,i=[];for(var o in this.data){var s=this.get(o);if(s instanceof t.Prismic.Fragments.DocumentLink&&i.push(s),s instanceof t.Prismic.Fragments.StructuredText)for(e=0;e<s.blocks.length;e++){var a=s.blocks[e];"image"==a.type&&a.linkTo&&(r=t.Prismic.Fragments.initField(a.linkTo),r instanceof DocumentLink&&i.push(r));var u=a.spans||[];for(n=0;n<u.length;n++){var l=u[n];"hyperlink"==l.type&&(r=t.Prismic.Fragments.initField(l.data),r instanceof t.Prismic.Fragments.DocumentLink&&i.push(r))}}if(s instanceof t.Prismic.Fragments.Group)for(e=0;e<s.value.length;e++)i=i.concat(s.value[e].linkedDocuments())}return i},_getFragments:function(t){return this.fragments&&this.fragments[t]?Array.isArray(this.fragments[t])?("blog-post.author"===t&&console.log("yes array"),this.fragments[t]):("blog-post.author"===t&&console.log("no narray: ",this.fragments[t]),[this.fragments[t]]):[]}},r.prototype=Object.create(n.prototype),r.prototype.getSliceZone=function(e){var n=this.get(e);return n instanceof t.Prismic.Fragments.SliceZone?n:null},i.prototype=Object.create(n.prototype),t.Prismic.WithFragments=n,t.Prismic.Document=r,t.Prismic.GroupDoc=i}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){"use strict";function n(t){this.value=t}function r(t){this.value=t,this.document=t.document,this.id=t.document.id,this.uid=t.document.uid,this.tags=t.document.tags,this.slug=t.document.slug,this.type=t.document.type;var e={};if(t.document.data)for(var n in t.document.data[t.document.type])e[t.document.type+"."+n]=t.document.data[t.document.type][n];this.fragments=T(e),this.isBroken=t.isBroken}function i(t){this.value=t}function o(t){this.value=t}function s(t){this.value=t}function a(t){this.value=t}function u(t){this.value=t}function l(t){this.latitude=t.latitude,this.longitude=t.longitude}function c(t){this.value=t}function f(t){this.value=new Date(t)}function h(t){var e=24==t.length?t.substring(0,22)+":"+t.substring(22,24):t;this.value=new Date(e)}function p(t){this.value=t}function m(t,e){this.main=t,this.views=e||{}}function d(t,e,n,r){this.url=t,this.width=e,this.height=n,this.alt=r}function g(e){this.value=[];for(var n=0;n<e.length;n++)this.value.push(new t.Prismic.GroupDoc(e[n]))}function v(t){this.blocks=t}function y(t){return t&&t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>")}function b(t,e,n,r){if(!e||!e.length)return y(t);var i={},o={};e.forEach(function(t){i[t.start]||(i[t.start]=[]),o[t.end]||(o[t.end]=[]),i[t.start].push(t),o[t.end].unshift(t)});for(var s,a="",u=[],l=0,c=t.length+1;c>l;l++)o[l]&&o[l].forEach(function(){var t=u.pop();if("undefined"!=typeof t){var e=j(t.span,t.text,r);0===u.length?a+=e:u[u.length-1].text+=e}}),i[l]&&(i[l].sort(function(t,e){return e.end-e.start-(t.end-t.start)}),i[l].forEach(function(t){var e=null;if("hyperlink"==t.type){var r=w(t.data);if(!r)return void(console&&console.error&&console.error("Impossible to convert span.data as a Fragment",t));e=r.url(n),t.url=e}var i={span:t,text:""};u.push(i)})),l<t.length&&(s=t[l],0===u.length?a+=y(s):u[u.length-1].text+=y(s));return a}function x(t,e,n){this.sliceType=t,this.label=e,this.value=n}function k(t){this.value=[];for(var e=0;e<t.length;e++){var n=t[e].slice_type,r=w(t[e].value),i=t[e].slice_label||null;n&&r&&this.value.push(new x(n,i,r))}}function w(t){var e={Color:u,Number:c,Date:f,Timestamp:h,Text:n,Embed:p,GeoPoint:l,Select:a,StructuredText:v,"Link.document":r,"Link.web":i,"Link.file":o,"Link.image":s,Group:g,SliceZone:k};if(e[t.type])return new e[t.type](t.value);if("Image"===t.type){var y=t.value.main,b=new m(new d(y.url,y.dimensions.width,y.dimensions.height,y.alt),{});for(var x in t.value.views)y=t.value.views[x],b.views[x]=new d(y.url,y.dimensions.width,y.dimensions.height,y.alt);return b}return console&&console.log&&console.log("Fragment type not supported: ",t.type),null}function T(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[n]=Array.isArray(t[n])?t[n].map(function(t){return w(t)}):w(t[n]));return e}function P(t){var e={};return t&&"[object Function]"===e.toString.call(t)}function j(t,e,n){if(n){var r=n(t,e);if(r)return r}var i={heading1:"h1",heading2:"h2",heading3:"h3",heading4:"h4",heading5:"h5",heading6:"h6",paragraph:"p",preformatted:"pre","list-item":"li","o-list-item":"li","group-list-item":"ul","group-o-list-item":"ol",strong:"strong",em:"em"};if(i[t.type]){var o=i[t.type],s=t.label?' class="'+t.label+'"':"";return"<"+o+s+">"+e+"</"+o+">"}if("image"==t.type){var a=t.label?" "+t.label:"",u='<img src="'+t.url+'" alt="'+t.alt+'">';return'<p class="block-img'+a+'">'+(t.linkUrl?'<a href="'+t.linkUrl+'">'+u+"</a>":u)+"</p>"}return"embed"==t.type?'<div data-oembed="'+t.embed_url+'" data-oembed-type="'+t.type+'" data-oembed-provider="'+t.provider_name+(t.label?'" class="'+t.label:"")+'">'+t.oembed.html+"</div>":"hyperlink"===t.type?'<a href="'+t.url+'">'+e+"</a>":"label"===t.type?'<span class="'+t.data.label+'">'+e+"</span>":"<!-- Warning: "+t.type+" not implemented. Upgrade the Developer Kit. -->"+e}n.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},r.prototype=Object.create(t.Prismic.WithFragments.prototype),r.prototype.asHtml=function(t){return'<a href="'+this.url(t)+'">'+this.url(t)+"</a>"},r.prototype.url=function(t){return t(this,this.isBroken)},r.prototype.asText=function(t){return this.url(t)},i.prototype={asHtml:function(){return'<a href="'+this.url()+'">'+this.url()+"</a>"},url:function(){return this.value.url},asText:function(){return this.url()}},o.prototype={asHtml:function(){return'<a href="'+this.url()+'">'+this.value.file.name+"</a>"},url:function(){return this.value.file.url},asText:function(){return this.url()}},s.prototype={asHtml:function(){return'<a href="'+this.url()+'"><img src="'+this.url()+'" alt="'+this.alt+'"></a>'},url:function(){return this.value.image.url},asText:function(){return this.url()}},a.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},u.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},l.prototype={asHtml:function(){return'<div class="geopoint"><span class="latitude">'+this.latitude+'</span><span class="longitude">'+this.longitude+"</span></div>"},asText:function(){return"("+this.latitude+","+this.longitude+")"}},c.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value.toString()}},f.prototype={asHtml:function(){return"<time>"+this.value+"</time>"},asText:function(){return this.value.toString()}},h.prototype={asHtml:function(){return"<time>"+this.value+"</time>"},asText:function(){return this.value.toString()}},p.prototype={asHtml:function(){return this.value.oembed.html},asText:function(){return""}},m.prototype={getView:function(t){return"main"===t?this.main:this.views[t]},asHtml:function(){return this.main.asHtml()},asText:function(){return""}},d.prototype={ratio:function(){return this.width/this.height},asHtml:function(){return'<img src="'+this.url+'" width="'+this.width+'" height="'+this.height+'" alt="'+this.alt+'">'},asText:function(){return""}},g.prototype={asHtml:function(t){for(var e="",n=0;n<this.value.length;n++)e+=this.value[n].asHtml(t);return e},toArray:function(){return this.value},asText:function(t){for(var e="",n=0;n<this.value.length;n++)e+=this.value[n].asText(t)+"\n";return e}},v.prototype={getTitle:function(){for(var t=0;t<this.blocks.length;t++){var e=this.blocks[t];if(0===e.type.indexOf("heading"))return e}return null},getFirstParagraph:function(){for(var t=0;t<this.blocks.length;t++){var e=this.blocks[t];if("paragraph"==e.type)return e}return null},getParagraphs:function(){for(var t=[],e=0;e<this.blocks.length;e++){var n=this.blocks[e];"paragraph"==n.type&&t.push(n)}return t},getParagraph:function(t){return this.getParagraphs()[t]},getFirstImage:function(){for(var t=0;t<this.blocks.length;t++){var e=this.blocks[t];if("image"==e.type)return new d(e.url,e.dimensions.width,e.dimensions.height,e.alt)}return null},asHtml:function(t,e){var n,r,i=[],o=[];if(!P(t)){var s=t;t=function(t,e){return s.linkResolver(s,t,e)}}if(Array.isArray(this.blocks)){for(var a=0;a<this.blocks.length;a++){if(r=this.blocks[a],"image"==r.type&&r.linkTo){var u=w(r.linkTo);r.linkUrl=u.url(t)}"list-item"!==r.type&&"o-list-item"!==r.type?(i.push(r),n=null):n&&n.type=="group-"+r.type?n.blocks.push(r):(n={type:"group-"+r.type,blocks:[r]},i.push(n))}var l=function(n){var r="";return n.blocks?n.blocks.forEach(function(t){r+=j(t,l(t),e)}):r=b(n.text,n.spans,t,e),r};i.forEach(function(t){o.push(j(t,l(t),e))})}return o.join("")},asText:function(){for(var t=[],e=0;e<this.blocks.length;e++){var n=this.blocks[e];n.text&&t.push(n.text)}return t.join(" ")}},x.prototype={asHtml:function(t){var e=["slice"];return this.label&&e.push(this.label),'<div data-slicetype="'+this.sliceType+'" class="'+e.join(" ")+'">'+this.value.asHtml(t)+"</div>"},asText:function(){return this.value.asText()}},k.prototype={asHtml:function(t){for(var e="",n=0;n<this.value.length;n++)e+=this.value[n].asHtml(t);return e},asText:function(){for(var t="",e=0;e<this.value.length;e++)t+=this.value[e].asText()+"\n";return t}},t.Prismic.Fragments={Image:m,ImageView:d,Text:n,Number:c,Date:f,Timestamp:h,Select:a,Color:u,StructuredText:v,WebLink:i,DocumentLink:r,ImageLink:s,FileLink:o,Group:g,GeoPoint:l,Slice:x,SliceZone:k,initField:w,parseFragments:T,insertSpans:b}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){"use strict";var n={at:function(t,e){return["at",t,e]},missing:function(t){return["missing",t]},has:function(t){return["has",t]},any:function(t,e){return["any",t,e]},fulltext:function(t,e){return["fulltext",t,e]},similar:function(t,e){return["similar",t,e]},gt:function(t,e){return["number.gt",t,e]},lt:function(t,e){return["number.lt",t,e]},inRange:function(t,e,n){return["number.inRange",t,e,n]},dateBefore:function(t,e){return["date.before",t,e]},dateAfter:function(t,e){return["date.after",t,e]},dateBetween:function(t,e,n){return["date.between",t,e,n]},dayOfMonth:function(t,e){return["date.day-of-month",t,e]},dayOfMonthAfter:function(t,e){return["date.day-of-month-after",t,e]},dayOfMonthBefore:function(t,e){return["date.day-of-month-before",t,e]},dayOfWeek:function(t,e){return["date.day-of-week",t,e]},dayOfWeekAfter:function(t,e){return["date.day-of-week-after",t,e]},dayOfWeekBefore:function(t,e){return["date.day-of-week-before",t,e]},month:function(t,e){return["date.month",t,e]},monthBefore:function(t,e){return["date.month-before",t,e]},monthAfter:function(t,e){return["date.month-after",t,e]},year:function(t,e){return["date.year",t,e]},hour:function(t,e){return["date.hour",t,e]},hourBefore:function(t,e){return["date.hour-before",t,e]},hourAfter:function(t,e){return["date.hour-after",t,e]},near:function(t,e,n,r){return["geopoint.near",t,e,n,r]}};t.Prismic.Predicates=n}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){"use strict";function n(t){var e=[],n=[];t&&(t.drafts&&t.drafts.forEach(function(t){e.push(new r(t))}),t.running&&t.running.forEach(function(t){n.push(new r(t))})),this.drafts=e,this.running=n}function r(t){this.data=t;var e=[];t.variations&&t.variations.forEach(function(t){e.push(new i(t))}),this.variations=e}function i(t){this.data=t}n.prototype.current=function(){return this.running.length>0?this.running[0]:null},n.prototype.refFromCookie=function(t){if(!t||""===t.trim())return null;var e=t.trim().split(" ");if(e.length<2)return null;var n=e[0],r=parseInt(e[1],10),i=this.running.filter(function(t){return t.googleId()==n&&t.variations.length>r})[0];return i?i.variations[r].ref():null},r.prototype.id=function(){return this.data.id},r.prototype.googleId=function(){return this.data.googleId},r.prototype.name=function(){return this.data.name},i.prototype.id=function(){return this.data.id},i.prototype.ref=function(){return this.data.ref},i.prototype.label=function(){return this.data.label},t.Prismic.Experiments=n,t.Prismic.Experiment=r,t.Prismic.Variation=i}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(t,e){t.Prismic.version="1.3.0"}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window); |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"devDependencies": { | ||
@@ -23,3 +23,3 @@ "codeclimate-test-reporter": "~0.0.4", | ||
"mocha": "*", | ||
"gulp-mocha-phantomjs": "~0.8.1", | ||
"gulp-mocha-phantomjs": "git://github.com/erwan/gulp-mocha-phantomjs.git#phantomjs198", | ||
"gulp-jsdoc": "~0.1.4", | ||
@@ -26,0 +26,0 @@ "gulp-jshint": "~1.11.2", |
@@ -22,3 +22,3 @@ (function (Global, undefined) { | ||
var frags = this._getFragments(name); | ||
return frags.length ? Global.Prismic.Fragments.initField(frags[0]) : null; | ||
return frags.length ? frags[0] : null; | ||
}, | ||
@@ -33,5 +33,3 @@ | ||
getAll: function(name) { | ||
return this._getFragments(name).map(function (fragment) { | ||
return Global.Prismic.Fragments.initField(fragment); | ||
}, this); | ||
return this._getFragments(name); | ||
}, | ||
@@ -296,19 +294,2 @@ | ||
/** | ||
* Gets the SliceZone fragment in the current Document object, for further manipulation. | ||
* | ||
* @example document.getSliceZone('product.gallery').asHtml(linkResolver). | ||
* | ||
* @param {string} name - The name of the fragment to get, with its type; for instance, "product.gallery" | ||
* @returns {Group} - The SliceZone fragment to manipulate. | ||
*/ | ||
getSliceZone: function(name) { | ||
var fragment = this.get(name); | ||
if (fragment instanceof Global.Prismic.Fragments.SliceZone) { | ||
return fragment; | ||
} | ||
return null; | ||
}, | ||
/** | ||
* Shortcut to get the HTML output of the fragment in the current document. | ||
@@ -390,3 +371,3 @@ * This is the same as writing document.get(fragment).asHtml(linkResolver); | ||
var result = []; | ||
for (var field in this.fragments) { | ||
for (var field in this.data) { | ||
var fragment = this.get(field); | ||
@@ -437,4 +418,6 @@ if (fragment instanceof Global.Prismic.Fragments.DocumentLink) { | ||
if (Array.isArray(this.fragments[name])) { | ||
if (name === 'blog-post.author') console.log("yes array"); | ||
return this.fragments[name]; | ||
} else { | ||
if (name === 'blog-post.author') console.log("no narray: ", this.fragments[name]); | ||
return [this.fragments[name]]; | ||
@@ -447,3 +430,2 @@ } | ||
/** | ||
@@ -456,4 +438,3 @@ * Embodies a document as returned by the API. | ||
*/ | ||
function Document(id, uid, type, href, tags, slugs, fragments) { | ||
function Document(id, uid, type, href, tags, slugs, data) { | ||
/** | ||
@@ -494,4 +475,10 @@ * The ID of the document | ||
this.slugs = slugs; | ||
this.fragments = fragments; | ||
/** | ||
* The original JSON data from the API | ||
*/ | ||
this.data = data; | ||
/** | ||
* Fragments, converted to business objects | ||
*/ | ||
this.fragments = Global.Prismic.Fragments.parseFragments(data); | ||
} | ||
@@ -501,4 +488,28 @@ | ||
function GroupDoc(fragments) { | ||
this.fragments = fragments; | ||
/** | ||
* Gets the SliceZone fragment in the current Document object, for further manipulation. | ||
* | ||
* @example document.getSliceZone('product.gallery').asHtml(linkResolver). | ||
* | ||
* @param {string} name - The name of the fragment to get, with its type; for instance, "product.gallery" | ||
* @returns {Group} - The SliceZone fragment to manipulate. | ||
*/ | ||
Document.prototype.getSliceZone = function(name) { | ||
var fragment = this.get(name); | ||
if (fragment instanceof Global.Prismic.Fragments.SliceZone) { | ||
return fragment; | ||
} | ||
return null; | ||
}; | ||
function GroupDoc(data) { | ||
/** | ||
* The original JSON data from the API | ||
*/ | ||
this.data = data; | ||
/** | ||
* Fragments, converted to business objects | ||
*/ | ||
this.fragments = Global.Prismic.Fragments.parseFragments(data); | ||
} | ||
@@ -505,0 +516,0 @@ |
@@ -71,6 +71,6 @@ (function (Global, undefined) { | ||
var fragments = {}; | ||
var fragmentsData = {}; | ||
if (data.document.data) { | ||
for (var field in data.document.data[data.document.type]) { | ||
fragments[data.document.type + '.' + field] = data.document.data[data.document.type][field]; | ||
fragmentsData[data.document.type + '.' + field] = data.document.data[data.document.type][field]; | ||
} | ||
@@ -82,3 +82,3 @@ } | ||
*/ | ||
this.fragments = fragments; | ||
this.fragments = parseFragments(fragmentsData); | ||
/** | ||
@@ -678,2 +678,3 @@ * @field | ||
} | ||
return null; | ||
}, | ||
@@ -691,2 +692,3 @@ | ||
} | ||
return null; | ||
}, | ||
@@ -730,2 +732,3 @@ | ||
} | ||
return null; | ||
}, | ||
@@ -887,3 +890,3 @@ | ||
if (console && console.error) console.error('Impossible to convert span.data as a Fragment', span); | ||
return ''; | ||
return; | ||
} | ||
@@ -997,2 +1000,3 @@ span.url = url; | ||
} | ||
}; | ||
@@ -1055,5 +1059,23 @@ | ||
if (console && console.log) console.log("Fragment type not supported: ", field.type); | ||
return null; | ||
} | ||
function parseFragments(json) { | ||
var result = {}; | ||
for (var key in json) { | ||
if (json.hasOwnProperty(key)) { | ||
if (Array.isArray(json[key])) { | ||
result[key] = json[key].map(function (fragment) { | ||
return initField(fragment); | ||
}); | ||
} else { | ||
result[key] = initField(json[key]); | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
function isFunction(f) { | ||
@@ -1143,2 +1165,3 @@ var getType = {}; | ||
initField: initField, | ||
parseFragments: parseFragments, | ||
insertSpans: insertSpans | ||
@@ -1145,0 +1168,0 @@ }; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1136902
64
9611
37
115