!function(a,b){"use strict";function c(a,b,c,d,e,f){this.name=a,this.fields=b,this.form_method=c,this.rel=d,this.enctype=e,this.action=f}function d(a,b,c){this.api=a,this.form=b,this.data=c||{};for(var d in b.fields)b.fields[d].default&&(this.data[d]=[b.fields[d].default])}function e(a){return this.fragments&&this.fragments[a]?Array.isArray(this.fragments[a])?this.fragments[a]:[this.fragments[a]]:[]}function f(a,b,c,d,e,f,g,h){this.page=a,this.results_per_page=b,this.results_size=c,this.total_results_size=d,this.total_pages=e,this.next_page=f,this.prev_page=g,this.results=h}function g(a,b,c,d,e,f){this.id=a,this.type=b,this.href=c,this.tags=d,this.slug=e?e[0]:"-",this.slugs=e,this.fragments=f}function h(a,b,c){this.ref=a,this.label=b,this.isMaster=c}var i=function(a,b,c,d){var e=new i.fn.init(a,c,d);return b&&e.get(b),e},j=function(){return"undefined"!=typeof XMLHttpRequest?function(a,b){var c=new XMLHttpRequest,d=function(){b(null,JSON.parse(c.responseText))},e=function(){var d=c.status;b(new Error("Unexpected status code ["+d+"] on URL "+a))};c.onreadystatechange=function(){4===c.readyState&&(c.status&&200==c.status?d(c):e(c))},c.open("GET",a,!0),c.setRequestHeader("Accept","application/json"),c.send()}:void 0},k=function(){if("function"==typeof require&&require("http")){{var a={},c=require("http"),d=require("https"),e=require("url");require("querystring")}return function(f,g){if(a[f])g(null,a[f]);else{var h=e.parse(f),i="https:"==h.protocol?d:c,j={hostname:h.hostname,path:h.path,query:h.query,headers:{Accept:"application/json"}};i.get(j,function(c){if(c.statusCode&&200==c.statusCode){var d="";c.setEncoding("utf8"),c.on("data",function(a){d+=a}),c.on("end",function(){var e=c.headers["cache-control"],h=e&&/max-age=(\d+)/.test(e)?parseInt(/max-age=(\d+)/.exec(e)[1]):b,i=JSON.parse(d);h&&(a[f]=i),g(null,i)})}else g(new Error("Unexpected status code ["+c.statusCode+"] on URL "+f))})}}}};i.fn=i.prototype={constructor:i,data:null,get:function(a){var b=this;this.requestHandler(this.url,function(c,d){c?a(c):(b.data=b.parse(d),b.bookmarks=b.data.bookmarks,a(null,b,this))})},parse:function(a){var b,d,e,f,g,i,j,k={};for(j in a.forms)a.forms.hasOwnProperty(j)&&(i=a.forms[j],this.accessToken&&(i.fields.accessToken={type:"string","default":this.accessToken}),e=new c(i.name,i.fields,i.form_method,i.rel,i.enctype,i.action),k[j]=e);if(b=a.refs.map(function(a){return new h(a.ref,a.label,a.isMasterRef)})||[],d=b.filter(function(a){return a.isMaster===!0}),f=a.types,g=a.tags,0===d.length)throw"No master ref.";return{bookmarks:a.bookmarks||{},refs:b,forms:k,master:d[0],types:f,tags:g,oauthInitiate:a.oauth_initiate,oauthToken:a.oauth_token}},init:function(a,b,c){return this.url=a+(b?(a.indexOf("?")>-1?"&":"?")+"access_token="+b:""),this.accessToken=b,this.requestHandler=c||j()||k()||function(){throw new Error("No request handler available (tried XMLHttpRequest & NodeJS)")}(),this},forms:function(a){return this.form(a)},form:function(a){var b=this.data.forms[a];return b?new d(this,b,{}):void 0},master:function(){return this.data.master.ref},ref:function(a){for(var b=0;b<this.data.refs.length;b++)if(this.data.refs[b].label==a)return this.data.refs[b].ref}},i.fn.init.prototype=i.fn,c.prototype={},d.prototype={set:function(a,c){var d=this.form.fields[a];if(!d)throw new Error("Unknown field "+a);var e=this.data[a]||[];return(""===c||c===b)&&(c=null),d.multiple?null!=c&&e.push(c):e=null!=c&&[c],this.data[a]=e,this},ref:function(a){return this.set("ref",a)},query:function(a){return this.set("q",a)},pageSize:function(a){return this.set("pageSize",a)},page:function(a){return this.set("page",a)},orderings:function(a){return this.set("orderings",a)},submit:function(a){var b=this.form.action;if(this.data){var c=b.indexOf("?")>-1?"&":"?";for(var d in this.data){var e=this.data[d];if(e)for(var h=0;h<e.length;h++)b+=c+d+"="+encodeURIComponent(e[h]),c="&"}}this.api.requestHandler(b,function(b,c){if(b)return a(b),void 0;var d=c.results.map(function(a){var b={};for(var c in a.data[a.type])b[a.type+"."+c]=a.data[a.type][c];return new g(a.id,a.type,a.href,a.tags,a.slugs,b)});a(null,new f(c.page,c.results_per_page,c.results_size,c.total_results_size,c.total_pages,c.next_page,c.prev_page,d||[]))})}},g.prototype={get:function(b){var c=e.call(this,b);return c.length?a.Prismic.Fragments.initField(c[0]):null},getAll:function(b){return e.call(this,b).map(function(b){return a.Prismic.Fragments.initField(b)},this)},getImage:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Image?c:c instanceof a.Prismic.Fragments.StructuredText?c:null},getAllImages:function(b){var c=this.getAll(b);return c.map(function(b){if(b instanceof a.Prismic.Fragments.Image)return b;if(b instanceof a.Prismic.Fragments.StructuredText)throw new Error("Not done.");return null})},getImageView:function(b,c){var d=this.get(b);if(d instanceof a.Prismic.Fragments.Image)return d.getView(c);if(d instanceof a.Prismic.Fragments.StructuredText)for(var e=0;e<d.blocks.length;e++)if("image"==d.blocks[e].type)return d.blocks[e];return null},getAllImageViews:function(a,b){return this.getAllImages(a).map(function(a){return a.getView(b)})},getDate:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Date?c.value:void 0},getBoolean:function(a){var b=this.get(a);return b.value&&("yes"==b.value.toLowerCase()||"on"==b.value.toLowerCase()||"true"==b.value.toLowerCase())},getText:function(b,c){var d=this.get(b);return d instanceof a.Prismic.Fragments.StructuredText?d.blocks.map(function(a){return a.text?a.text+(c?c:""):void 0}).join("\n"):d instanceof a.Prismic.Fragments.Text&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Number&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Select&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Color&&d.value?d.value+(c?c:""):void 0},getStructuredText:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.StructuredText?c:void 0},getNumber:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Number?c.value:void 0},getGroup:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Group?c:void 0},getHtml:function(a,b){var c=this.get(a);return c&&c.asHtml?c.asHtml(b):void 0},asHtml:function(a){var b=[];for(var c in this.fragments){var d=this.get(c);b.push(d&&d.asHtml?'<section data-field="'+c+'">'+d.asHtml(a)+"</section>":"")}return b.join("")}},h.prototype={},a.Prismic={Api:i}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(a){"use strict";function b(a){this.value=a}function c(a){this.value=a,this.document=a.document,this.isBroken=a.isBroken}function d(a){this.value=a}function e(a){this.value=a}function f(a){this.value=a}function g(a){this.value=a}function h(a){this.value=a}function i(a){this.value=a}function j(a){this.value=new Date(a)}function k(a){this.value=a}function l(a,b){this.main=a,this.views=b||{}}function m(a,b,c){this.url=a,this.width=b,this.height=c}function n(a){this.value=a}function o(a,b){this.tag=a,this.blocks=b}function p(a){this.blocks=a}function q(a,b){var c,d,e=[],f=[];if(Array.isArray(a)){for(var g=0;g<a.length;g++)d=a[g],"list-item"!=d.type&&"o-list-item"!=d.type?(c=new o(d.type,[]),e.push(c)):c&&c.tag!=d.type&&(c=new o(d.type,[]),e.push(c)),c.blocks.push(d);e.forEach(function(a){if("heading1"==a.tag)f.push("<h1>"+r(a.blocks[0].text,a.blocks[0].spans,b)+"</h1>");else if("heading2"==a.tag)f.push("<h2>"+r(a.blocks[0].text,a.blocks[0].spans,b)+"</h2>");else if("heading3"==a.tag)f.push("<h3>"+r(a.blocks[0].text,a.blocks[0].spans,b)+"</h3>");else if("paragraph"==a.tag)f.push("<p>"+r(a.blocks[0].text,a.blocks[0].spans,b)+"</p>");else if("preformatted"==a.tag)f.push("<pre>"+a.blocks[0].text+"</pre>");else if("image"==a.tag)f.push('<p><img src="'+a.blocks[0].url+'"></p>');else if("embed"==a.tag)f.push('<div data-oembed="'+a.blocks[0].embed_url+'" data-oembed-type="'+a.blocks[0].type+'" data-oembed-provider="'+a.blocks[0].provider_name+'">'+a.blocks[0].oembed.html+"</div>");else{if("list-item"!=a.tag&&"o-list-item"!=a.tag)throw new Error(a.tag+" not implemented");f.push("list-item"==a.tag?"<ul>":"<ol>"),a.blocks.forEach(function(a){f.push("<li>"+r(a.text,a.spans,b)+"</li>")}),f.push("list-item"==a.tag?"</ul>":"</ol>")}})}return f.join("")}function r(a,b,c){var d=[],e=[],f=0,g=[];return b.forEach(function(b){return b.end<b.start?a:b.start<f?a:(f=b.end,void 0)}),f=0,b.forEach(function(b){d.push(a.substring(0,b.start-f)),a=a.substring(b.start-f),f=b.start,d.push(a.substring(0,b.end-f)),a=a.substring(b.end-f),e.push(b),f=b.end}),d.push(a),e.forEach(function(a){g.push(d.shift()),"hyperlink"==a.type?(g.push('<a href="'+s(a.data).url(c)+'">'),g.push(d.shift()),g.push("</a>")):(g.push("<"+a.type+">"),g.push(d.shift()),g.push("</"+a.type+">"))}),g.push(d.shift()),g.join("")}function s(a){var o,q;switch(a.type){case"Color":o=new h(a.value);break;case"Number":o=new i(a.value);break;case"Date":o=new j(a.value);break;case"Text":o=new b(a.value);break;case"Embed":o=new k(a.value);break;case"Select":o=new g(a.value);break;case"Image":var q=a.value.main;o=new l(new m(q.url,q.dimensions.width,q.dimensions.height),{});for(var r in a.value.views){var q=a.value.views[r];o.views[r]=new m(q.url,q.dimensions.width,q.dimensions.height)}break;case"StructuredText":o=new p(a.value);break;case"Link.document":o=new c(a.value);break;case"Link.web":o=new d(a.value);break;case"Link.file":o=new e(a.value);break;case"Link.image":o=new f(a.value);break;case"Group":for(var t=[],u=0;u<a.value.length;u++){var v={};for(var w in a.value[u])v[w]=s(a.value[u][w]);t.push(v)}o=new n(t);break;default:console.log("Fragment type not supported: ",a.type)}return o}b.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},c.prototype={asHtml:function(a){return'<a href="'+this.url(a)+'">'+this.url(a)+"</a>"},url:function(a){return a.linkResolver(a,this.document,this.isBroken)}},d.prototype={asHtml:function(){return'<a href="'+this.url()+'">'+this.url()+"</a>"},url:function(){return this.value.url}},e.prototype={asHtml:function(){return'<a href="'+this.url()+'">'+this.value.file.name+"</a>"},url:function(){return this.value.file.url}},f.prototype={asHtml:function(){return'<a href="'+this.url()+'"><img src="'+this.url()+'"</a>'},url:function(){return this.value.image.url}},g.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},h.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},i.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},j.prototype={asText:function(){throw new Error("not implemented")},asHtml:function(){return"<time>"+this.value+"</time>"}},k.prototype={asHtml:function(){return this.value.oembed.html}},l.prototype={getView:function(a){return"main"===a?this.main:this.views[a]},asHtml:function(){return this.main.asHtml()}},m.prototype={ratio:function(){return this.width/this.height},asHtml:function(){return"<img src="+this.url+" width="+this.width+" height="+this.height+">"}},n.prototype={asHtml:function(a){for(var b="",c=0;c<this.value.length;c++)for(var d in this.value[c])b+='<section data-field="'+d+'">',b+=this.value[c][d].asHtml(a),b+="</section>";return b},toArray:function(){return this.value}},p.prototype={getTitle:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if(0==b.type.indexOf("heading"))return b}},getFirstParagraph:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if("paragraph"==b.type)return b}},getParagraphs:function(){for(var a=[],b=0;b<this.blocks.length;b++){var c=this.blocks[b];"paragraph"==c.type&&a.push(c)}return a},getParagraph:function(a){return this.getParagraphs()[a]},getFirstImage:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if("image"==b.type)return new m(b.data.url,b.data.dimensions.width,b.data.dimensions.height)}},asHtml:function(a){return q.call(this,this.blocks,a)}},a.Prismic.Fragments={Image:l,ImageView:m,Text:b,Number:i,Date:j,Select:g,Color:h,StructuredText:p,WebLink:d,DocumentLink:c,ImageLink:f,FileLink:e,Group:n,initField:s}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window);
Esempio n. 2
0
!function(a,b){"use strict";function c(a,b,c,d,e,f){this.name=a,this.fields=b,this.form_method=c,this.rel=d,this.enctype=e,this.action=f}function d(a,b,c){this.api=a,this.form=b,this.data=c||{};for(var d in b.fields)b.fields[d]["default"]&&(this.data[d]=[b.fields[d]["default"]])}function e(a){return this.fragments&&this.fragments[a]?Array.isArray(this.fragments[a])?this.fragments[a]:[this.fragments[a]]:[]}function f(a,b,c,d,e,f,g,h){this.page=a,this.results_per_page=b,this.results_size=c,this.total_results_size=d,this.total_pages=e,this.next_page=f,this.prev_page=g,this.results=h}function g(a,b,c,d){this.id=a,this.slug=b,this.type=c,this.tags=d}function h(a,b,c,d,e,f,g){this.id=a,this.type=b,this.href=c,this.tags=d,this.slug=e?e[0]:"-",this.slugs=e,this.linkedDocuments=f,this.fragments=g}function i(a,b,c,d,e){this.ref=a,this.label=b,this.isMaster=c,this.scheduledAt=d,this.id=e}function j(){this.cache={},this.states={}}var k=function(a,b,c,d,e){var f=new k.fn.init(a,c,d,e);return b&&f.get(b),f},l=function(){return"undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest?function(a,b){var c=new XMLHttpRequest,d=function(){b(null,JSON.parse(c.responseText),c)},e=function(){var d=c.status;b(new Error("Unexpected status code ["+d+"] on URL "+a),null,c)};c.onreadystatechange=function(){4===c.readyState&&(c.status&&200==c.status?d():e())},c.open("GET",a,!0),c.setRequestHeader("Accept","application/json"),c.send()}:void 0},m=function(){return"undefined"!=typeof XDomainRequest?function(a,b){var c=new XDomainRequest,d=function(){b(null,JSON.parse(c.responseText),c)},e=function(a){b(new Error(a),null,c)};c.onload=function(){d(c)},c.onerror=function(){e("Unexpected status code on URL "+a)},c.open("GET",a,!0),c.ontimeout=function(){e("Request timeout")},c.onprogress=function(){},c.send()}:void 0},n=function(){if("function"==typeof require&&require("http")){{var a={},c=require("http"),d=require("https"),e=require("url");require("querystring")}return function(f,g){if(a[f])g(null,a[f]);else{var h=e.parse(f),i="https:"==h.protocol?d:c,j={hostname:h.hostname,path:h.path,query:h.query,headers:{Accept:"application/json"}};i.get(j,function(c){if(c.statusCode&&200==c.statusCode){var d="";c.setEncoding("utf8"),c.on("data",function(a){d+=a}),c.on("end",function(){var e=c.headers["cache-control"],h=e&&/max-age=(\d+)/.test(e)?parseInt(/max-age=(\d+)/.exec(e)[1]):b,i=JSON.parse(d);h&&(a[f]=i),g(null,i,c)})}else g(new Error("Unexpected status code ["+c.statusCode+"] on URL "+f),null,c)})}}}};k.fn=k.prototype={constructor:k,data:null,get:function(a){var b=this,c=this.url+(this.accessToken?"#"+this.accessToken:"");this.apiCache.getOrSet(c,5,function(a){b.requestHandler(b.url,function(c,d,e){c?a&&a(c,null,e):a&&a(null,b.parse(d),e)})},function(c,d,e){c?a&&a(c,null,e):(b.data=d,b.bookmarks=d.bookmarks,a&&a(null,b,e))})},parse:function(a){var b,d,e,f,g,h,j,k={};for(j in a.forms)a.forms.hasOwnProperty(j)&&(h=a.forms[j],this.accessToken&&(h.fields.accessToken={},h.fields.accessToken.type="string",h.fields.accessToken["default"]=this.accessToken),e=new c(h.name,h.fields,h.form_method,h.rel,h.enctype,h.action),k[j]=e);if(b=a.refs.map(function(a){return new i(a.ref,a.label,a.isMasterRef,a.scheduledAt,a.id)})||[],d=b.filter(function(a){return a.isMaster===!0}),f=a.types,g=a.tags,0===d.length)throw"No master ref.";return{bookmarks:a.bookmarks||{},refs:b,forms:k,master:d[0],types:f,tags:g,oauthInitiate:a.oauth_initiate,oauthToken:a.oauth_token}},init:function(a,b,c,d){return this.url=a+(b?(a.indexOf("?")>-1?"&":"?")+"access_token="+b:""),this.accessToken=b,this.requestHandler=c||l()||m()||n()||function(){throw new Error("No request handler available (tried XMLHttpRequest & NodeJS)")}(),this.apiCache=d||new j,this},forms:function(a){return this.form(a)},form:function(a){var b=this.data.forms[a];return b?new d(this,b,{}):void 0},master:function(){return this.data.master.ref},ref:function(a){for(var b=0;b<this.data.refs.length;b++)if(this.data.refs[b].label==a)return this.data.refs[b].ref}},k.fn.init.prototype=k.fn,c.prototype={},d.prototype={set:function(a,c){var d=this.form.fields[a];if(!d)throw new Error("Unknown field "+a);var e=this.data[a]||[];return(""===c||c===b)&&(c=null),d.multiple?null!=c&&e.push(c):e=null!=c&&[c],this.data[a]=e,this},ref:function(a){return this.set("ref",a)},query:function(a){return this.set("q",a)},pageSize:function(a){return this.set("pageSize",a)},page:function(a){return this.set("page",a)},orderings:function(a){return this.set("orderings",a)},submit:function(a){var b=this.form.action;if(this.data){var c=b.indexOf("?")>-1?"&":"?";for(var d in this.data){var e=this.data[d];if(e)for(var i=0;i<e.length;i++)b+=c+d+"="+encodeURIComponent(e[i]),c="&"}}this.api.requestHandler(b,function(b,c,d){if(b)return void a(b,null,d);var e=c.results.map(function(a){var b=[];a.linked_documents&&(b=a.linked_documents.map(function(a){return new g(a.id,a.slug,a.type,a.tags)}));var c={};for(var d in a.data[a.type])c[a.type+"."+d]=a.data[a.type][d];for(var e in c){var f=c[e];if("StructuredText"===f.type)for(var i in f.value){var j=f.value[i],k=[];for(var l in j.spans){var m=j.spans[l];m.start<m.end&&k.push(m)}j.spans=k}}return new h(a.id,a.type,a.href,a.tags,a.slugs,b,c)});a(null,new f(c.page,c.results_per_page,c.results_size,c.total_results_size,c.total_pages,c.next_page,c.prev_page,e||[]),d)})}},h.prototype={get:function(b){var c=e.call(this,b);return c.length?a.Prismic.Fragments.initField(c[0]):null},getAll:function(b){return e.call(this,b).map(function(b){return a.Prismic.Fragments.initField(b)},this)},getImage:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Image?c:c instanceof a.Prismic.Fragments.StructuredText?c:null},getAllImages:function(b){var c=this.getAll(b);return c.map(function(b){if(b instanceof a.Prismic.Fragments.Image)return b;if(b instanceof a.Prismic.Fragments.StructuredText)throw new Error("Not done.");return null})},getImageView:function(b,c){var b=this.get(b);if(b instanceof a.Prismic.Fragments.Image)return b.getView(c);if(b instanceof a.Prismic.Fragments.StructuredText)for(var d=0;d<b.blocks.length;d++)if("image"==b.blocks[d].type)return b.blocks[d];return null},getAllImageViews:function(a,b){return this.getAllImages(a).map(function(a){return a.getView(b)})},getDate:function(b){var b=this.get(b);return b instanceof a.Prismic.Fragments.Date?b.value:void 0},getBoolean:function(a){var a=this.get(a);return a.value&&("yes"==a.value.toLowerCase()||"on"==a.value.toLowerCase()||"true"==a.value.toLowerCase())},getText:function(b,c){var d=this.get(b);return d instanceof a.Prismic.Fragments.StructuredText?d.blocks.map(function(a){return a.text?a.text+(c?c:""):void 0}).join("\n"):d instanceof a.Prismic.Fragments.Text&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Number&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Select&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Color&&d.value?d.value+(c?c:""):void 0},getStructuredText:function(b){var b=this.get(b);return b instanceof a.Prismic.Fragments.StructuredText?b:void 0},getNumber:function(b){var b=this.get(b);return b instanceof a.Prismic.Fragments.Number?b.value:void 0},getColor:function(b){var b=this.get(b);return b instanceof a.Prismic.Fragments.Color?b.value:void 0},getGeoPoint:function(b){var b=this.get(b);return b instanceof a.Prismic.Fragments.GeoPoint?b:void 0},getGroup:function(b){var b=this.get(b);return b instanceof a.Prismic.Fragments.Group?b:void 0},getHtml:function(a,b){var a=this.get(a);return a&&a.asHtml?a.asHtml(b):void 0},asHtml:function(a){var b=[];for(var c in this.fragments){var d=this.get(c);b.push(d&&d.asHtml?'<section data-field="'+c+'">'+d.asHtml(a)+"</section>":"")}return b.join("")},asText:function(a){var b=[];for(var c in this.fragments){var d=this.get(c);b.push(d&&d.asText?d.asText(a):"")}return b.join("")}},i.prototype={},j.prototype={get:function(a){var b=this.cache[a];return b&&(!this.isExpired(a)||this.isExpired(a)&&this.isInProgress(a))?b.data:null},set:function(a,b,c){this.cache[a]={data:b,expiredIn:c?Date.now()+1e3*c:0}},getOrSet:function(a,b,c,d){var e=this.get(a),f=this;if(e)d&&d(null,e);else{this.states[a]="progress";{c(function(c,e,g){f.set(a,e,b),delete f.states[a],d&&d(c,e,g)})}}},isExpired:function(a){var b=this.cache[a];return b?0!=b.expiredIn&&b.expiredIn<Date.now():!1},isInProgress:function(a){return"progress"==this.states[a]},exists:function(a){return!!this.cache[a]},remove:function(a){return delete this.cache[a]},clear:function(){this.cache={}}},a.Prismic={Api:k}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(a){"use strict";function b(a){this.value=a}function c(a){this.value=a,this.document=a.document,this.isBroken=a.isBroken}function d(a){this.value=a}function e(a){this.value=a}function f(a){this.value=a}function g(a){this.value=a}function h(a){this.value=a}function i(a,b){this.latitude=a,this.longitude=b}function j(a){this.value=a}function k(a){this.value=new Date(a)}function l(a){var b=24==a.length?a.substring(0,22)+":"+a.substring(22,24):a;this.value=new Date(b)}function m(a){this.value=a}function n(a,b){this.main=a,this.views=b||{}}function o(a,b,c,d){this.url=a,this.width=b,this.height=c,this.alt=d}function p(a){this.value=a}function q(a,b,c){this.tag=a,this.blocks=b,this.label=c}function r(a){this.blocks=a}function s(a,b){var c,d,e=[],f=[];if(Array.isArray(a)){for(var g=0;g<a.length;g++)d=a[g],"list-item"!=d.type&&"o-list-item"!=d.type?(c=new q(d.type,[],d.label),e.push(c)):c&&c.tag==d.type||(c=new q(d.type,[],d.label),e.push(c)),c.blocks.push(d);var h={heading1:"h1",heading2:"h2",heading3:"h3",paragraph:"p"};e.forEach(function(a){var c=a.label?' class ="'+a.label+'"':"";if(h[a.tag]){var d=h[a.tag];f.push("<"+d+c+">"+t(a.blocks[0].text,a.blocks[0].spans,b)+"</"+d+">")}else if("preformatted"==a.tag)f.push("<pre"+c+">"+a.blocks[0].text+"</pre>");else if("image"==a.tag)f.push("<p"+c+'><img src="'+a.blocks[0].url+'" alt="'+a.blocks[0].alt+'"></p>');else if("embed"==a.tag)f.push('<div data-oembed="'+a.blocks[0].embed_url+'" data-oembed-type="'+a.blocks[0].type+'" data-oembed-provider="'+a.blocks[0].provider_name+c+'">'+a.blocks[0].oembed.html+"</div>");else{if("list-item"!=a.tag&&"o-list-item"!=a.tag)throw new Error(a.tag+" not implemented");f.push("list-item"==a.tag?"<ul>":"<ol>"),a.blocks.forEach(function(a){f.push("<li>"+t(a.text,a.spans,b)+"</li>")}),f.push("list-item"==a.tag?"</ul>":"</ol>")}})}return f.join("")}function t(a,b,c){function d(a,b){if("hyperlink"===a.type){var d=u(a.data);return d?b?'<a href="'+d.url(c)+'">':"</a>":(console&&console.error&&console.error("Impossible to convert span.data as a Fragment",a),"")}return"label"===a.type?b?'<span class="'+a.data.label+'">':"</span>":"<"+(b?"":"/")+a.type+">"}if(!b||!b.length)return a;var e=[],f={},g={};b.forEach(function(a){f[a.start]||(f[a.start]=[]),g[a.end]||(g[a.end]=[]),f[a.start].push(d(a,!0)),g[a.end].unshift(d(a,!1)),e.push(a.start,a.end)}),e=e.filter(function(a,b,c){return c.indexOf(a)===b}).sort(function(a,b){return a-b});var h=[],i=0;return e.forEach(function(b){h.push(a.substring(i,b)),h=h.concat(g[b]||[]),h=h.concat(f[b]||[]),i=b}),h.push(a.substring(i)),h.join("")}function u(a){var q,s;switch(a.type){case"Color":q=new h(a.value);break;case"Number":q=new j(a.value);break;case"Date":q=new k(a.value);break;case"Timestamp":q=new l(a.value);break;case"Text":q=new b(a.value);break;case"Embed":q=new m(a.value);break;case"GeoPoint":q=new i(a.value.latitude,a.value.longitude);break;case"Select":q=new g(a.value);break;case"Image":s=a.value.main,q=new n(new o(s.url,s.dimensions.width,s.dimensions.height,s.alt),{});for(var t in a.value.views)s=a.value.views[t],q.views[t]=new o(s.url,s.dimensions.width,s.dimensions.height,s.alt);break;case"StructuredText":q=new r(a.value);break;case"Link.document":q=new c(a.value);break;case"Link.web":q=new d(a.value);break;case"Link.file":q=new e(a.value);break;case"Link.image":q=new f(a.value);break;case"Group":for(var v=[],w=0;w<a.value.length;w++){var x={};for(var y in a.value[w])x[y]=u(a.value[w][y]);v.push(x)}q=new p(v);break;default:console.log("Fragment type not supported: ",a.type)}return q}b.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},c.prototype={asHtml:function(a){return'<a href="'+this.url(a)+'">'+this.url(a)+"</a>"},url:function(a){return a.linkResolver(a,this.document,this.isBroken)},asText:function(a){return this.url(a)}},d.prototype={asHtml:function(){return'<a href="'+this.url()+'">'+this.url()+"</a>"},url:function(){return this.value.url},asText:function(){return this.url()}},e.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()}},f.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()}},g.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},h.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},i.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+")"}},j.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value.toString()}},k.prototype={asHtml:function(){return"<time>"+this.value+"</time>"},asText:function(){return this.value.toString()}},l.prototype={asHtml:function(){return"<time>"+this.value+"</time>"},asText:function(){return this.value.toString()}},m.prototype={asHtml:function(){return this.value.oembed.html},asText:function(){return""}},n.prototype={getView:function(a){return"main"===a?this.main:this.views[a]},asHtml:function(){return this.main.asHtml()},asText:function(){return""}},o.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""}},p.prototype={asHtml:function(a){for(var b="",c=0;c<this.value.length;c++)for(var d in this.value[c])b+='<section data-field="'+d+'">',b+=this.value[c][d].asHtml(a),b+="</section>";return b},toArray:function(){return this.value},asText:function(a){for(var b="",c=0;c<this.value.length;c++)for(var d in this.value[c])b+=this.value[c][d].asText(a);return b}},r.prototype={getTitle:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if(0==b.type.indexOf("heading"))return b}},getFirstParagraph:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if("paragraph"==b.type)return b}},getParagraphs:function(){for(var a=[],b=0;b<this.blocks.length;b++){var c=this.blocks[b];"paragraph"==c.type&&a.push(c)}return a},getParagraph:function(a){return this.getParagraphs()[a]},getFirstImage:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if("image"==b.type)return new o(b.url,b.dimensions.width,b.dimensions.height,b.alt)}},asHtml:function(a){return s.call(this,this.blocks,a)},asText:function(){for(var a=[],b=0;b<this.blocks.length;b++){var c=this.blocks[b];c.text&&a.push(c.text)}return a.join(" ")}},a.Prismic.Fragments={Image:n,ImageView:o,Text:b,Number:j,Date:k,Timestamp:l,Select:g,Color:h,StructuredText:r,WebLink:d,DocumentLink:c,ImageLink:f,FileLink:e,Group:p,GeoPoint:i,initField:u,insertSpans:t}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window);
!function(a,b){"use strict";function c(a,b,c,d,e,f){this.name=a,this.fields=b,this.form_method=c,this.rel=d,this.enctype=e,this.action=f}function d(a,b,c){this.api=a,this.form=b,this.data=c||{};for(var d in b.fields)b.fields[d]["default"]&&(this.data[d]=[b.fields[d]["default"]])}function e(a){return this.fragments&&this.fragments[a]?Array.isArray(this.fragments[a])?this.fragments[a]:[this.fragments[a]]:[]}function f(a,b,c,d,e,f,g,h){this.page=a,this.results_per_page=b,this.results_size=c,this.total_results_size=d,this.total_pages=e,this.next_page=f,this.prev_page=g,this.results=h}function g(a,b,c,d){this.id=a,this.slug=b,this.type=c,this.tags=d}function h(a,b,c,d,e,f,g){this.id=a,this.type=b,this.href=c,this.tags=d,this.slug=e?e[0]:"-",this.slugs=e,this.linkedDocuments=f,this.fragments=g}function i(a,b,c,d,e){this.ref=a,this.label=b,this.isMaster=c,this.scheduledAt=d,this.id=e}function j(){this.cache={},this.states={}}var k=function(a,b,c,d,e){var f=new k.fn.init(a,c,d,e);return b&&f.get(b),f},l=function(){return"undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest?function(a,b){var c=new XMLHttpRequest,d=function(){b(null,JSON.parse(c.responseText),c)},e=function(){var d=c.status;b(new Error("Unexpected status code ["+d+"] on URL "+a),null,c)};c.onreadystatechange=function(){4===c.readyState&&(c.status&&200==c.status?d():e())},c.open("GET",a,!0),c.setRequestHeader("Accept","application/json"),c.send()}:void 0},m=function(){return"undefined"!=typeof XDomainRequest?function(a,b){var c=new XDomainRequest,d=function(){b(null,JSON.parse(c.responseText),c)},e=function(a){b(new Error(a),null,c)};c.onload=function(){d(c)},c.onerror=function(){e("Unexpected status code on URL "+a)},c.open("GET",a,!0),c.ontimeout=function(){e("Request timeout")},c.onprogress=function(){},c.send()}:void 0},n=function(){if("function"==typeof require&&require("http")){var a={},c=require("http"),d=require("https"),e=require("url"),f=(require("querystring"),require("../package.json"));return function(g,h){if(a[g])h(null,a[g]);else{var i=e.parse(g),j="https:"==i.protocol?d:c,k={hostname:i.hostname,path:i.path,query:i.query,headers:{Accept:"application/json","User-Agent":"Prismic-javascript-kit/"+f.version+" NodeJS/"+process.version}};j.get(k,function(c){if(c.statusCode&&200==c.statusCode){var d="";c.setEncoding("utf8"),c.on("data",function(a){d+=a}),c.on("end",function(){var e=c.headers["cache-control"],f=e&&/max-age=(\d+)/.test(e)?parseInt(/max-age=(\d+)/.exec(e)[1]):b,i=JSON.parse(d);f&&(a[g]=i),h(null,i,c)})}else h(new Error("Unexpected status code ["+c.statusCode+"] on URL "+g),null,c)})}}}};k.fn=k.prototype={AT:"at",ANY:"any",EVERYTHING:"everything",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:k,data:null,get:function(a){var b=this,c=this.url+(this.accessToken?"#"+this.accessToken:"");this.apiCache.getOrSet(c,5,function(a){b.requestHandler(b.url,function(c,d,e){c?a&&a(c,null,e):a&&a(null,b.parse(d),e)})},function(c,d,e){c?a&&a(c,null,e):(b.data=d,b.bookmarks=d.bookmarks,a&&a(null,b,e))})},parse:function(a){var b,d,e,f,g,h,j,k={};for(j in a.forms)a.forms.hasOwnProperty(j)&&(h=a.forms[j],this.accessToken&&(h.fields.access_token={},h.fields.access_token.type="string",h.fields.access_token["default"]=this.accessToken),e=new c(h.name,h.fields,h.form_method,h.rel,h.enctype,h.action),k[j]=e);if(b=a.refs.map(function(a){return new i(a.ref,a.label,a.isMasterRef,a.scheduledAt,a.id)})||[],d=b.filter(function(a){return a.isMaster===!0}),f=a.types,g=a.tags,0===d.length)throw"No master ref.";return{bookmarks:a.bookmarks||{},refs:b,forms:k,master:d[0],types:f,tags:g,oauthInitiate:a.oauth_initiate,oauthToken:a.oauth_token}},init:function(a,b,c,d){return this.url=a+(b?(a.indexOf("?")>-1?"&":"?")+"access_token="+b:""),this.accessToken=b,this.requestHandler=c||l()||m()||n()||function(){throw new Error("No request handler available (tried XMLHttpRequest & NodeJS)")}(),this.apiCache=d||new j,this},forms:function(a){return this.form(a)},form:function(a){var b=this.data.forms[a];return b?new d(this,b,{}):void 0},master:function(){return this.data.master.ref},ref:function(a){for(var b=0;b<this.data.refs.length;b++)if(this.data.refs[b].label==a)return this.data.refs[b].ref}},k.fn.init.prototype=k.fn,c.prototype={},d.prototype={set:function(a,c){var d=this.form.fields[a];if(!d)throw new Error("Unknown field "+a);var e=this.data[a]||[];return(""===c||c===b)&&(c=null),d.multiple?null!=c&&e.push(c):e=null!=c&&[c],this.data[a]=e,this},ref:function(a){return this.set("ref",a)},query:function(a){if("string"==typeof a)return this.set("q",a);var b="string"==typeof a[0]?[a]:a,c=[];return b.forEach(function(a){var b=0==a[1].indexOf("my.")||0==a[1].indexOf("document.")?a[1]:'"'+a[1]+'"';c.push("[:d = "+a[0]+"("+b+", "+function(){return a.slice(2).map(function(a){return"string"==typeof a?'"'+a+'"':Array.isArray(a)?"["+a.map(function(a){return'"'+a+'"'}).join(",")+"]":a}).join(",")}()+")]")}),this.query("["+c.join("")+"]")},pageSize:function(a){return this.set("pageSize",a)},page:function(a){return this.set("page",a)},orderings:function(a){return this.set("orderings",a)},submit:function(a){var b=this.form.action;if(this.data){var c=b.indexOf("?")>-1?"&":"?";for(var d in this.data){var e=this.data[d];if(e)for(var i=0;i<e.length;i++)b+=c+d+"="+encodeURIComponent(e[i]),c="&"}}this.api.requestHandler(b,function(b,c,d){if(b)return void a(b,null,d);var e=c.results.map(function(a){var b=[];a.linked_documents&&(b=a.linked_documents.map(function(a){return new g(a.id,a.slug,a.type,a.tags)}));var c={};for(var d in a.data[a.type])c[a.type+"."+d]=a.data[a.type][d];for(var e in c){var f=c[e];if("StructuredText"===f.type)for(var i in f.value){var j=f.value[i],k=[];for(var l in j.spans){var m=j.spans[l];m.start<m.end&&k.push(m)}j.spans=k}}return new h(a.id,a.type,a.href,a.tags,a.slugs,b,c)});a(null,new f(c.page,c.results_per_page,c.results_size,c.total_results_size,c.total_pages,c.next_page,c.prev_page,e||[]),d)})}},h.prototype={get:function(b){var c=e.call(this,b);return c.length?a.Prismic.Fragments.initField(c[0]):null},getAll:function(b){return e.call(this,b).map(function(b){return a.Prismic.Fragments.initField(b)},this)},getImage:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Image?c:c instanceof a.Prismic.Fragments.StructuredText?c:null},getAllImages:function(b){var c=this.getAll(b);return c.map(function(b){if(b instanceof a.Prismic.Fragments.Image)return b;if(b instanceof a.Prismic.Fragments.StructuredText)throw new Error("Not done.");return null})},getImageView:function(b,c){var d=this.get(b);if(d instanceof a.Prismic.Fragments.Image)return d.getView(c);if(d instanceof a.Prismic.Fragments.StructuredText)for(var e=0;e<d.blocks.length;e++)if("image"==d.blocks[e].type)return d.blocks[e];return null},getAllImageViews:function(a,b){return this.getAllImages(a).map(function(a){return a.getView(b)})},getDate:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Date?c.value:void 0},getBoolean:function(a){var b=this.get(a);return b.value&&("yes"==b.value.toLowerCase()||"on"==b.value.toLowerCase()||"true"==b.value.toLowerCase())},getText:function(b,c){var d=this.get(b);return d instanceof a.Prismic.Fragments.StructuredText?d.blocks.map(function(a){return a.text?a.text+(c?c:""):void 0}).join("\n"):d instanceof a.Prismic.Fragments.Text&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Number&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Select&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Color&&d.value?d.value+(c?c:""):void 0},getStructuredText:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.StructuredText?c:void 0},getNumber:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Number?c.value:void 0},getColor:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Color?c.value:void 0},getGeoPoint:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.GeoPoint?c:void 0},getGroup:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Group?c:void 0},getHtml:function(a,b){var c=this.get(a);return c&&c.asHtml?c.asHtml(b):void 0},asHtml:function(a){var b=[];for(var c in this.fragments){var d=this.get(c);b.push(d&&d.asHtml?'<section data-field="'+c+'">'+d.asHtml(a)+"</section>":"")}return b.join("")},asText:function(a){var b=[];for(var c in this.fragments){var d=this.get(c);b.push(d&&d.asText?d.asText(a):"")}return b.join("")}},i.prototype={},j.prototype={get:function(a){var b=this.cache[a];return b&&(!this.isExpired(a)||this.isExpired(a)&&this.isInProgress(a))?b.data:null},set:function(a,b,c){this.cache[a]={data:b,expiredIn:c?Date.now()+1e3*c:0}},getOrSet:function(a,b,c,d){var e=this.get(a),f=this;if(e)d&&d(null,e);else{this.states[a]="progress";{c(function(c,e,g){f.set(a,e,b),delete f.states[a],d&&d(c,e,g)})}}},isExpired:function(a){var b=this.cache[a];return b?0!=b.expiredIn&&b.expiredIn<Date.now():!1},isInProgress:function(a){return"progress"==this.states[a]},exists:function(a){return!!this.cache[a]},remove:function(a){return delete this.cache[a]},clear:function(){this.cache={}}},a.Prismic={Api:k}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(a){"use strict";function b(a){this.value=a}function c(a){this.value=a,this.document=a.document,this.isBroken=a.isBroken}function d(a){this.value=a}function e(a){this.value=a}function f(a){this.value=a}function g(a){this.value=a}function h(a){this.value=a}function i(a,b){this.latitude=a,this.longitude=b}function j(a){this.value=a}function k(a){this.value=new Date(a)}function l(a){var b=24==a.length?a.substring(0,22)+":"+a.substring(22,24):a;this.value=new Date(b)}function m(a){this.value=a}function n(a,b){this.main=a,this.views=b||{}}function o(a,b,c,d){this.url=a,this.width=b,this.height=c,this.alt=d}function p(a){this.value=a}function q(a){this.blocks=a}function r(a){return a&&a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function s(a,b,c,d){if(!b||!b.length)return r(a);var e={},f={};b.forEach(function(a){e[a.start]||(e[a.start]=[]),f[a.end]||(f[a.end]=[]),e[a.start].push(a),f[a.end].unshift(a)});for(var g,h="",i=[],j=0,k=a.length+1;k>j;j++)f[j]&&f[j].forEach(function(){var a=i.pop(),b=u(a.span,a.text,d);0==i.length?h+=b:i[i.length-1].text+=b}),e[j]&&(e[j].sort(function(a,b){return b.end-b.start-(a.end-a.start)}),e[j].forEach(function(a){var b=null;if("hyperlink"==a.type){var d=t(a.data);if(!d)return console&&console.error&&console.error("Impossible to convert span.data as a Fragment",a),"";b=d.url(c),a.url=b}var e={span:a,text:""};i.push(e)})),j<a.length&&(g=a[j],0==i.length?h+=r(g):i[i.length-1].text+=r(g));return h}function t(a){var r,s;switch(a.type){case"Color":r=new h(a.value);break;case"Number":r=new j(a.value);break;case"Date":r=new k(a.value);break;case"Timestamp":r=new l(a.value);break;case"Text":r=new b(a.value);break;case"Embed":r=new m(a.value);break;case"GeoPoint":r=new i(a.value.latitude,a.value.longitude);break;case"Select":r=new g(a.value);break;case"Image":s=a.value.main,r=new n(new o(s.url,s.dimensions.width,s.dimensions.height,s.alt),{});for(var u in a.value.views)s=a.value.views[u],r.views[u]=new o(s.url,s.dimensions.width,s.dimensions.height,s.alt);break;case"StructuredText":r=new q(a.value);break;case"Link.document":r=new c(a.value);break;case"Link.web":r=new d(a.value);break;case"Link.file":r=new e(a.value);break;case"Link.image":r=new f(a.value);break;case"Group":for(var v=[],w=0;w<a.value.length;w++){var x={};for(var y in a.value[w])x[y]=t(a.value[w][y]);v.push(x)}r=new p(v);break;default:console&&console.log&&console.log("Fragment type not supported: ",a.type)}return r}function u(a,b,c){if(c){var d=c(a,b);if(d)return d}var e={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(e[a.type]){var f=e[a.type],g=a.label?' class="'+a.label+'"':"";return"<"+f+g+">"+b+"</"+f+">"}if("image"==a.type){var h=a.label?" "+a.label:"",i='<img src="'+a.url+'" alt="'+a.alt+'">';return'<p class="block-img'+h+'">'+(a.linkUrl?'<a href="'+a.linkUrl+'">'+i+"</a>":i)+"</p>"}return"embed"==a.type?'<div data-oembed="'+a.embed_url+'" data-oembed-type="'+a.type+'" data-oembed-provider="'+a.provider_name+(a.label?'" class="'+h:"")+'">'+a.oembed.html+"</div>":"hyperlink"===a.type?'<a href="'+a.url+'">'+b+"</a>":"span"===a.type?'<span class="'+span.label+'">'+b+"</span>":"<!-- Warning: "+a.type+" not implemented. Upgrade the Developer Kit. -->"+b}b.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},c.prototype={asHtml:function(a){return'<a href="'+this.url(a)+'">'+this.url(a)+"</a>"},url:function(a){return a.linkResolver(a,this.document,this.isBroken)},asText:function(a){return this.url(a)}},d.prototype={asHtml:function(){return'<a href="'+this.url()+'">'+this.url()+"</a>"},url:function(){return this.value.url},asText:function(){return this.url()}},e.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()}},f.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()}},g.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},h.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},i.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+")"}},j.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value.toString()}},k.prototype={asHtml:function(){return"<time>"+this.value+"</time>"},asText:function(){return this.value.toString()}},l.prototype={asHtml:function(){return"<time>"+this.value+"</time>"},asText:function(){return this.value.toString()}},m.prototype={asHtml:function(){return this.value.oembed.html},asText:function(){return""}},n.prototype={getView:function(a){return"main"===a?this.main:this.views[a]},asHtml:function(){return this.main.asHtml()},asText:function(){return""}},o.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""}},p.prototype={asHtml:function(a){for(var b="",c=0;c<this.value.length;c++)for(var d in this.value[c])b+='<section data-field="'+d+'">',b+=this.value[c][d].asHtml(a),b+="</section>";return b},toArray:function(){return this.value},asText:function(a){for(var b="",c=0;c<this.value.length;c++)for(var d in this.value[c])b+=this.value[c][d].asText(a);return b}},q.prototype={getTitle:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if(0==b.type.indexOf("heading"))return b}},getFirstParagraph:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if("paragraph"==b.type)return b}},getParagraphs:function(){for(var a=[],b=0;b<this.blocks.length;b++){var c=this.blocks[b];"paragraph"==c.type&&a.push(c)}return a},getParagraph:function(a){return this.getParagraphs()[a]},getFirstImage:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if("image"==b.type)return new o(b.url,b.dimensions.width,b.dimensions.height,b.alt)}},asHtml:function(a,b){var c,d,e=[],f=[];if(Array.isArray(this.blocks)){for(var g=0;g<this.blocks.length;g++){if(d=this.blocks[g],"image"==d.type&&d.linkTo){var h=t(d.linkTo);d.linkUrl=h.url(a)}"list-item"!==d.type&&"o-list-item"!==d.type?(e.push(d),c=null):c&&c.type=="group-"+d.type?c.blocks.push(d):(c={type:"group-"+d.type,blocks:[d]},e.push(c))}var i=function(c){var d="";return c.blocks?c.blocks.forEach(function(a){d+=u(a,i(a),b)}):d=s(c.text,c.spans,a,b),d};e.forEach(function(a){f.push(u(a,i(a),b))})}return f.join("")},asText:function(){for(var a=[],b=0;b<this.blocks.length;b++){var c=this.blocks[b];c.text&&a.push(c.text)}return a.join(" ")}},a.Prismic.Fragments={Image:n,ImageView:o,Text:b,Number:j,Date:k,Timestamp:l,Select:g,Color:h,StructuredText:q,WebLink:d,DocumentLink:c,ImageLink:f,FileLink:e,Group:p,GeoPoint:i,initField:t,insertSpans:s}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window);
Esempio n. 4
0
!function(a,b){"use strict";function c(a,b,c,d,e,f){this.name=a,this.fields=b,this.form_method=c,this.rel=d,this.enctype=e,this.action=f}function d(a,b,c){this.api=a,this.form=b,this.data=c||{};for(var d in b.fields)b.fields[d].default&&(this.data[d]=[b.fields[d].default])}function e(a){return this.fragments&&this.fragments[a]?Array.isArray(this.fragments[a])?this.fragments[a]:[this.fragments[a]]:[]}function f(a,b,c,d,e,f){this.id=a,this.type=b,this.href=c,this.tags=d,this.slug=e?e[0]:"-",this.fragments=f}function g(a,b,c){this.ref=a,this.label=b,this.isMaster=c}var h=function(a,b,c,d){var e=new h.fn.init(a,c,d);return b&&e.get(b),e},i=function(){return"undefined"!=typeof XMLHttpRequest?function(a,b){var c=new XMLHttpRequest,d=function(){b(JSON.parse(c.responseText))},e=function(){var a=c.status;throw new Error("Unexpected status code ["+a+"]")};c.onreadystatechange=function(){4===c.readyState&&(c.status&&200==c.status?d(c):e(c))},c.open("GET",a+"#json",!0),c.setRequestHeader("Accept","application/json"),c.send()}:void 0},j=function(){if("function"==typeof require&&require("http")){var a={},c=require("http"),d=require("https"),e=require("url");return require("querystring"),function(f,g){if(a[f])g(a[f]);else{var h=e.parse(f),i="https:"==h.protocol?d:c,j={hostname:h.hostname,path:h.path,query:h.query,headers:{Accept:"application/json"}};i.get(j,function(c){if(!c.statusCode||200!=c.statusCode)throw new Error("Unexpected status code ["+c.statusCode+"]");var d="";c.setEncoding("utf8"),c.on("data",function(a){d+=a}),c.on("end",function(){var e=c.headers["cache-control"],h=e&&/max-age=(\d+)/.test(e)?parseInt(/max-age=(\d+)/.exec(e)[1]):b,i=JSON.parse(d);h&&(a[f]=i),g(i)})})}}}};h.fn=h.prototype={constructor:h,data:null,get:function(a){var b=this;this.requestHandler(this.url,function(c){b.data=b.parse(c),b.bookmarks=b.data.bookmarks,a&&a(b,this)})},parse:function(a){var b,d,e,f,h,i={};for(h in a.forms)a.forms.hasOwnProperty(h)&&(f=a.forms[h],this.accessToken&&(f.fields.accessToken={type:"string","default":this.accessToken}),e=new c(f.name,f.fields,f.form_method,f.rel,f.enctype,f.action),i[h]=e);if(b=a.refs.map(function(a){return new g(a.ref,a.label,a.isMasterRef)})||[],d=b.filter(function(a){return a.isMaster===!0}),0===d.length)throw"No master ref.";return{bookmarks:a.bookmarks||{},refs:b,forms:i,master:d[0],oauthInitiate:a.oauth_initiate,oauthToken:a.oauth_token}},init:function(a,b,c){return this.url=a+(b?(a.indexOf("?")>-1?"&":"?")+"access_token="+b:""),this.accessToken=b,this.requestHandler=c||i()||j()||function(){throw new Error("No request handler available (tried XMLHttpRequest & NodeJS)")}(),this},forms:function(a){return this.form(a)},form:function(a){var b=this.data.forms[a];return b?new d(this,b,{}):void 0},master:function(){return this.data.master.ref},ref:function(a){for(var b=0;b<this.data.refs.length;b++)if(this.data.refs[b].label==a)return this.data.refs[b].ref}},h.fn.init.prototype=h.fn,c.prototype={},d.prototype={set:function(a,b){var c=this.form.fields[a];if(!c)throw new Error("Unknown field "+a);var d=this.data[a]||[];return c.multiple?d.push(b):d=[b],this.data[a]=d,this},ref:function(a){return this.set("ref",a)},query:function(a){return this.form.fields.q.multiple?this.set("q",a):(this.data.q=this.data.q||[],this.data.q.push(a),this)},submit:function(a){var b=this.form.action;if(this.data){var c=b.indexOf("?")>-1?"&":"?";for(var d in this.data){var e=this.data[d];if(e)for(var g=0;g<e.length;g++)b+=c+d+"="+encodeURIComponent(e[g]),c="&"}}this.api.requestHandler(b,function(b){var c=b.results||b,d=c.map(function(a){var b={};for(var c in a.data[a.type])b[a.type+"."+c]=a.data[a.type][c];return new f(a.id,a.type,a.href,a.tags,a.slugs,b)});a&&a(d||[])})}},f.prototype={get:function(b){var c=e.call(this,b);return c.length?a.Prismic.Fragments.initField(c[0]):null},getAll:function(b){return e.call(this,b).map(function(b){return a.Prismic.Fragments.initField(b)},this)},getImage:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Image?c:c instanceof a.Prismic.Fragments.StructuredText?c:null},getAllImages:function(b){var c=this.getAll(b);return c.map(function(b){if(b instanceof a.Prismic.Fragments.Image)return b;if(b instanceof a.Prismic.Fragments.StructuredText)throw new Error("Not done.");return null})},getImageView:function(b,c){var d=this.get(b);if(d instanceof a.Prismic.Fragments.Image)return d.getView(c);if(d instanceof a.Prismic.Fragments.StructuredText)for(var e=0;e<d.blocks.length;e++)if("image"==d.blocks[e].type)return d.blocks[e];return null},getAllImageViews:function(a,b){return this.getAllImages(a).map(function(a){return a.getView(b)})},getDate:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Date?c.value:void 0},getBoolean:function(a){var b=this.get(a);return b.value&&("yes"==b.value.toLowerCase()||"on"==b.value.toLowerCase()||"true"==b.value.toLowerCase())},getText:function(b,c){var d=this.get(b);return d instanceof a.Prismic.Fragments.StructuredText?d.blocks.map(function(a){return a.text?a.text+(c?c:""):void 0}).join("\n"):d instanceof a.Prismic.Fragments.Text&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Number&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Select&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Color&&d.value?d.value+(c?c:""):void 0},getStructuredText:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.StructuredText?c:void 0},getNumber:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Number?c.value:void 0},getHtml:function(a,b){var c=this.get(a);return c&&c.asHtml?c.asHtml(b):void 0},asHtml:function(a){var b=[];for(var c in this.fragments){var d=this.get(c);b.push(d&&d.asHtml?'<section data-field="'+c+'">'+d.asHtml(a)+"</section>":"")}return b.join("")}},g.prototype={},a.Prismic={Api:h}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(a){"use strict";function b(a){this.value=a}function c(a){this.value=a,this.document=a.document,this.isBroken=a.isBroken}function d(a){this.value=a}function e(a){this.value=a}function f(a){this.value=a}function g(a){this.value=new Date(a)}function h(a){this.value=a}function i(a,b){this.main=a,this.views=b||{}}function j(a,b,c){this.url=a,this.width=b,this.height=c}function k(a,b){this.tag=a,this.blocks=b}function l(a){this.blocks=a}function m(a){var b,c=[],d=[];return Array.isArray(a)?(a.forEach(function(a){c.length>0?(c[c.length-1],b=new k(null,[]),b.blocks.push(a),c.push(b)):(b=new k(null,[]),b.blocks.push(a),c.push(b))}),c.forEach(function(a){a.tag?(d.push("<"+a.tag+">"),a.blocks.forEach(function(a){d.push(m(a))}),d.push("</"+a.tag+">")):a.blocks.forEach(function(a){d.push(m(a))})})):("heading1"==a.type&&d.push("<h1>"+a.text+"</h1>"),"heading2"==a.type&&d.push("<h2>"+a.text+"</h2>"),"heading3"==a.type&&d.push("<h3>"+a.text+"</h3>"),"paragraph"==a.type&&d.push("<p>"+a.text+"</p>"),"image"==a.type&&d.push('<p><img src="'+a.url+'"></p>')),d.join("")}function n(a){var h,k;switch(a.type){case"Color":h=new e(a.value);break;case"Number":h=new f(a.value);break;case"Date":h=new g(a.value);break;case"Text":h=new b(a.value);break;case"Embed":throw new Error("not implemented");case"Select":h=new d(a.value);break;case"Image":var k=a.value.main;h=new i(new j(k.url,k.dimensions.width,k.dimensions.height),a.value.views);break;case"StructuredText":h=new l(a.value);break;case"Link.document":h=new c(a.value);break;case"Link.web":throw new Error("not implemented");default:console.log("Type not found:",a.type)}return h}b.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},c.prototype={asHtml:function(){return"<a></a>"}},d.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},e.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},f.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},g.prototype={asText:function(){throw new Error("not implemented")},asHtml:function(){return"<time>"+this.value+"</time>"}},h.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},i.prototype={getView:function(a){return"main"===a?this.main:this.views[a]},asHtml:function(){return this.main.asHtml()}},j.prototype={ratio:function(){return this.width/this.height},asHtml:function(){return"<img src="+this.url+" width="+this.width+" height="+this.height+">"}},l.prototype={getTitle:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if(0==b.type.indexOf("heading"))return b}},getFirstParagraph:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if("paragraph"==b.type)return b}},getParagraphs:function(){for(var a=[],b=0;b<this.blocks.length;b++){var c=this.blocks[b];"paragraph"==c.type&&a.push(c)}return a},getParagraph:function(a){return this.getParagraphs()[a]},getFirstImage:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if("image"==b.type)return new j(b.data.url,b.data.dimensions.width,b.data.dimensions.height)}},asHtml:function(){return m.call(this,this.blocks)}},a.Prismic.Fragments={Image:i,ImageView:j,Text:b,Number:f,Date:g,Select:d,Color:e,StructuredText:l,initField:n}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window);