prismic.io
Advanced tools
Comparing version 1.3.4 to 1.4.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(t,e){var n=new Error(e);return n.status=t,n},r=function(){return"undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest?function(t,e){var r=new XMLHttpRequest,i=function(){var t,n=/max-age\s*=\s*(\d+)/.exec(r.getResponseHeader("Cache-Control"));n&&n.length>1&&(t=parseInt(n[1],10)),e(null,JSON.parse(r.responseText),r,t)},o=function(){var i=r.status;e(n(i,"Unexpected status code ["+i+"] on URL "+t),null,r)};r.onreadystatechange=function(){4===r.readyState&&(r.status&&200==r.status?i():o())},r.open("GET",t,!0),r.setRequestHeader("Accept","application/json"),r.send()}:void 0},i=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},o=function(){if("function"==typeof require&&require("http")){var t=require("http"),r=require("https"),i=require("url"),o=(require("querystring"),require("../package.json"));return function(s,a){var u=i.parse(s),l="https:"==u.protocol?r:t,c={hostname:u.hostname,path:u.path,query:u.query,headers:{Accept:"application/json","User-Agent":"Prismic-javascript-kit/"+o.version+" NodeJS/"+process.version}},f=l.get(c,function(t){if(t.statusCode&&200==t.statusCode){var r="";t.setEncoding("utf8"),t.on("data",function(t){r+=t}),t.on("end",function(){var n=JSON.parse(r),i=t.headers["cache-control"],o=i&&/max-age=(\d+)/.test(i)?parseInt(/max-age=(\d+)/.exec(i)[1],10):e;a(null,n,t,o)})}else a(n(t.statusCode,"Unexpected status code ["+t.statusCode+"] on URL "+s),null,t)});f.on("error",function(t){a(new Error("Unexpected error on URL "+s),null,t)})}}},s=0,a=[],u=function(){if(!(0===a.length||s>=t.Prismic.Utils.MAX_CONNECTIONS)){s++;var e=a.shift(),n=r()||i()||o()||function(){throw new Error("No request handler available (tried XMLHttpRequest & NodeJS)")}();n.call(this,e.url,function(t,n,r,i){s--,e.callback(t,n,r,i),u()})}},l=function(){return function(t,e){a.push({url:t,callback:e}),u()}};t.Prismic.Utils={MAX_CONNECTIONS:20,request:l}}("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})},getFirstImage:function(){var e=this.fragments,n=Object.keys(e).reduce(function(n,r){if(n)return n;var i=e[r];return"function"==typeof i.getFirstImage?i.getFirstImage():i instanceof t.Prismic.Fragments.Image?i:null},null);return n},getFirstTitle:function(){var e=this.fragments,n=Object.keys(e).reduce(function(n,r){if(n)return n;var i=e[r];return"function"==typeof i.getFirstTitle?i.getFirstTitle():i instanceof t.Prismic.Fragments.StructuredText?i.getTitle():null},null);return n},getFirstParagraph:function(){var t=this.fragments,e=Object.keys(t).reduce(function(e,n){if(e)return e;var r=t[n];return"function"==typeof r.getFirstParagraph?r.getFirstParagraph():null},null);return e},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])?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.url=t.url,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=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 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))}this.slices=this.value}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 F(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},getFirstImage:function(){return this.toArray().reduce(function(t,e){return t?t:e.getFirstImage()},null)},getFirstTitle:function(){return this.toArray().reduce(function(t,e){return t?t:e.getFirstTitle()},null)},getFirstParagraph:function(){return this.toArray().reduce(function(t,e){return t?t:e.getFirstParagraph()},null)}},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(!F(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=b(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(" ")}},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()},getFirstImage:function(){var e=this.value;return"function"==typeof e.getFirstImage?e.getFirstImage():e instanceof t.Prismic.Fragments.Image?e:null},getFirstTitle:function(){var e=this.value;return"function"==typeof e.getFirstTitle?e.getFirstTitle():e instanceof t.Prismic.Fragments.StructuredText?e.getTitle():null},getFirstParagraph:function(){var t=this.value;return"function"==typeof t.getFirstParagraph?t.getFirstParagraph():null}},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},getFirstImage:function(){return this.value.reduce(function(t,e){return t?t:e.getFirstImage()},null)},getFirstTitle:function(){return this.value.reduce(function(t,e){return t?t:e.getFirstTitle()},null)},getFirstParagraph:function(){return this.value.reduce(function(t,e){return t?t:e.getFirstParagraph()},null)}},t.Prismic.Fragments={Embed:p,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]},not:function(t,e){return["not",t,e]},missing:function(t){return["missing",t]},has:function(t){return["has",t]},any:function(t,e){return["any",t,e]},"in":function(t,e){return["in",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.4"}("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)},query:function(t,e,n){var r=this.form("everything");for(var i in e)r=r.set(i,e[i]);return e.ref||(r=r.ref(this.master())),r.query(t).submit(n)},getByID:function(e,n,r){var i=t.Prismic.Predicates;return this.query(i.at("document.id",e),n,function(t,e){e&&e.results.length>0?r(t,e.results[0]):r(t,null)})},getByIDs:function(t,e,n){return this.query(["in","document.id",t],e,n)},getByUID:function(e,n,r,i){var o=t.Prismic.Predicates;return this.query(o.at("my."+e+".uid",n),r,function(t,e){e&&e.results.length>0?i(t,e.results[0]):i(t,null)})},getBookmark:function(t,e,n){var r=this.bookmarks[t];r?this.getById(this.bookmarks[t],e,n):n(new Error("Error retrieving bookmarked id"))},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;e=t.constructor===Array&&t.length>0&&t[0].constructor===Array?t:[].slice.apply(arguments);var 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(t,e){var n=new Error(e);return n.status=t,n},r=function(){return"undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest?function(t,e){var r=new XMLHttpRequest,i=function(){var t,n=/max-age\s*=\s*(\d+)/.exec(r.getResponseHeader("Cache-Control"));n&&n.length>1&&(t=parseInt(n[1],10)),e(null,JSON.parse(r.responseText),r,t)},o=function(){var i=r.status;e(n(i,"Unexpected status code ["+i+"] on URL "+t),null,r)};r.onreadystatechange=function(){4===r.readyState&&(r.status&&200==r.status?i():o())},r.open("GET",t,!0),r.setRequestHeader("Accept","application/json"),r.send()}:void 0},i=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},o=function(){if("function"==typeof require&&require("http")){var t=require("http"),r=require("https"),i=require("url"),o=(require("querystring"),require("../package.json"));return function(s,a){var u=i.parse(s),l="https:"==u.protocol?r:t,c={hostname:u.hostname,path:u.path,query:u.query,headers:{Accept:"application/json","User-Agent":"Prismic-javascript-kit/"+o.version+" NodeJS/"+process.version}},f=l.get(c,function(t){if(t.statusCode&&200==t.statusCode){var r="";t.setEncoding("utf8"),t.on("data",function(t){r+=t}),t.on("end",function(){var n=JSON.parse(r),i=t.headers["cache-control"],o=i&&/max-age=(\d+)/.test(i)?parseInt(/max-age=(\d+)/.exec(i)[1],10):e;a(null,n,t,o)})}else a(n(t.statusCode,"Unexpected status code ["+t.statusCode+"] on URL "+s),null,t)});f.on("error",function(t){a(new Error("Unexpected error on URL "+s),null,t)})}}},s=0,a=[],u=function(){if(!(0===a.length||s>=t.Prismic.Utils.MAX_CONNECTIONS)){s++;var e=a.shift(),n=r()||i()||o()||function(){throw new Error("No request handler available (tried XMLHttpRequest & NodeJS)")}();n.call(this,e.url,function(t,n,r,i){s--,e.callback(t,n,r,i),u()})}},l=function(){return function(t,e){a.push({url:t,callback:e}),u()}};t.Prismic.Utils={MAX_CONNECTIONS:20,request:l}}("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})},getFirstImage:function(){var e=this.fragments,n=Object.keys(e).reduce(function(n,r){if(n)return n;var i=e[r];return"function"==typeof i.getFirstImage?i.getFirstImage():i instanceof t.Prismic.Fragments.Image?i:null},null);return n},getFirstTitle:function(){var e=this.fragments,n=Object.keys(e).reduce(function(n,r){if(n)return n;var i=e[r];return"function"==typeof i.getFirstTitle?i.getFirstTitle():i instanceof t.Prismic.Fragments.StructuredText?i.getTitle():null},null);return n},getFirstParagraph:function(){var t=this.fragments,e=Object.keys(t).reduce(function(e,n){if(e)return e;var r=t[n];return"function"==typeof r.getFirstParagraph?r.getFirstParagraph():null},null);return e},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])?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.url=t.url,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=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 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))}this.slices=this.value}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 F(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},getFirstImage:function(){return this.toArray().reduce(function(t,e){return t?t:e.getFirstImage()},null)},getFirstTitle:function(){return this.toArray().reduce(function(t,e){return t?t:e.getFirstTitle()},null)},getFirstParagraph:function(){return this.toArray().reduce(function(t,e){return t?t:e.getFirstParagraph()},null)}},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(!F(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=b(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(" ")}},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()},getFirstImage:function(){var e=this.value;return"function"==typeof e.getFirstImage?e.getFirstImage():e instanceof t.Prismic.Fragments.Image?e:null},getFirstTitle:function(){var e=this.value;return"function"==typeof e.getFirstTitle?e.getFirstTitle():e instanceof t.Prismic.Fragments.StructuredText?e.getTitle():null},getFirstParagraph:function(){var t=this.value;return"function"==typeof t.getFirstParagraph?t.getFirstParagraph():null}},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},getFirstImage:function(){return this.value.reduce(function(t,e){return t?t:e.getFirstImage()},null)},getFirstTitle:function(){return this.value.reduce(function(t,e){return t?t:e.getFirstTitle()},null)},getFirstParagraph:function(){return this.value.reduce(function(t,e){return t?t:e.getFirstParagraph()},null)}},t.Prismic.Fragments={Embed:p,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]},not:function(t,e){return["not",t,e]},missing:function(t){return["missing",t]},has:function(t){return["has",t]},any:function(t,e){return["any",t,e]},"in":function(t,e){return["in",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.4.0"}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window); |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "1.3.4", | ||
"version": "1.4.0", | ||
"devDependencies": { | ||
@@ -34,5 +34,5 @@ "codeclimate-test-reporter": "~0.0.4", | ||
"main": "dist/prismic.io", | ||
"scripts:": { | ||
"scripts": { | ||
"test": "gulp test" | ||
} | ||
} |
@@ -305,2 +305,80 @@ (function (Global, undefined) { | ||
/** | ||
* Query the repository | ||
* @param {string|array|Predicate} the query itself | ||
* @param {object} additional parameters | ||
* @param {function} callback(err, response) | ||
*/ | ||
query: function(q, options, callback) { | ||
var form = this.form('everything'); | ||
for (var key in options) { | ||
form = form.set(key, options[key]); | ||
} | ||
if (!options['ref']) { | ||
form = form.ref(this.master()); | ||
} | ||
return form.query(q).submit(callback); | ||
}, | ||
/** | ||
* Retrieve the document with the given id | ||
* @param {string} id | ||
* @param {object} additional parameters | ||
* @param {function} callback(err, response) | ||
*/ | ||
getByID: function(id, options, callback) { | ||
var Predicates = Global.Prismic.Predicates; | ||
return this.query(Predicates.at('document.id', id), options, function(err, response) { | ||
if (response && response.results.length > 0) { | ||
callback(err, response.results[0]); | ||
} else { | ||
callback(err, null); | ||
} | ||
}); | ||
}, | ||
/** | ||
* Retrieve multiple documents from an array of id | ||
* @param {array} ids | ||
* @param {object} additional parameters | ||
* @param {function} callback(err, response) | ||
*/ | ||
getByIDs: function(ids, options, callback) { | ||
return this.query(['in', 'document.id', ids], options, callback); | ||
}, | ||
/** | ||
* Retrieve the document with the given uid | ||
* @param {string} type the custom type of the document | ||
* @param {string} uid | ||
* @param {object} additional parameters | ||
* @param {function} callback(err, response) | ||
*/ | ||
getByUID: function(type, uid, options, callback) { | ||
var Predicates = Global.Prismic.Predicates; | ||
return this.query(Predicates.at('my.'+type+'.uid', uid), options, function(err, response) { | ||
if (response && response.results.length > 0) { | ||
callback(err, response.results[0]); | ||
} else { | ||
callback(err, null); | ||
} | ||
}); | ||
}, | ||
/** | ||
* Retrieve the document with the given uid | ||
* @param {string} type the custom type of the document | ||
* @param {string} uid | ||
* @param {object} additional parameters | ||
* @param {function} callback(err, response) | ||
*/ | ||
getBookmark: function(bookmark, options, callback) { | ||
var id = this.bookmarks[bookmark]; | ||
if (id) { | ||
this.getById(this.bookmarks[bookmark], options, callback); | ||
} else { | ||
callback(new Error("Error retrieving bookmarked id")); | ||
} | ||
}, | ||
/** | ||
* Return the URL to display a given preview | ||
@@ -479,3 +557,8 @@ * @param {string} token as received from Prismic server to identify the content to preview | ||
} else { | ||
var predicates = [].slice.apply(arguments); // Convert to a real JS array | ||
var predicates; | ||
if (query.constructor === Array && query.length > 0 && query[0].constructor === Array) { | ||
predicates = query; | ||
} else { | ||
predicates = [].slice.apply(arguments); // Convert to a real JS array | ||
} | ||
var stringQueries = []; | ||
@@ -482,0 +565,0 @@ predicates.forEach(function (predicate) { |
@@ -68,14 +68,14 @@ (function(Prismic) { | ||
// Now we'll use this reference for all our calls | ||
Api.form('everything') | ||
.ref(stPatrickRef) | ||
.query(Prismic.Predicates.at("document.type", "product")).submit(function (err, response) { | ||
if (err) { | ||
console.log(err); | ||
done(); | ||
} // gisthide | ||
// The documents object contains a Response object with all documents of type "product" | ||
// including the new "Saint-Patrick's Cupcake" | ||
assert.equal(response.results.length, 17); // gisthide | ||
done(); // gisthide | ||
}); | ||
Api.query(Prismic.Predicates.at("document.type", "product"), { | ||
ref: stPatrickRef | ||
}, function (err, response) { | ||
if (err) { | ||
console.log(err); | ||
done(); | ||
} // gisthide | ||
// The documents object contains a Response object with all documents of type "product" | ||
// including the new "Saint-Patrick's Cupcake" | ||
assert.equal(response.results.length, 17); // gisthide | ||
done(); // gisthide | ||
}); | ||
}, previewToken); | ||
@@ -92,20 +92,18 @@ // endgist | ||
if (err) throw err; // gisthide | ||
Api.form('everything') | ||
.ref(Api.master()) | ||
.query(Prismic.Predicates.at("document.type", "product")).submit(function (err, response) { | ||
if (err) { console.log(err); done(); } // gisthide | ||
// The documents object contains a Response object with all documents of type "product". | ||
var page = response.page; // The current page number, the first one being 1 | ||
assert.equal(page, 1); // gisthide | ||
var results = response.results; // An array containing the results of the current page; | ||
// you may need to retrieve more pages to get all results | ||
assert.equal(results.length, 16); // gisthide | ||
var prev_page = response.prev_page; // the URL of the previous page (may be null) | ||
var next_page = response.next_page; // the URL of the next page (may be null) | ||
var results_per_page = response.results_per_page; // max number of results per page | ||
var results_size = response.results_size; // the size of the current page | ||
var total_pages = response.total_pages; // the number of pages | ||
var total_results_size = response.total_results_size; // the total size of results across all pages | ||
done(); // gisthide | ||
}); | ||
Api.query(Prismic.Predicates.at("document.type", "product"), {}, function (err, response) { | ||
if (err) { console.log(err); done(); } // gisthide | ||
// The documents object contains a Response object with all documents of type "product". | ||
var page = response.page; // The current page number, the first one being 1 | ||
assert.equal(page, 1); // gisthide | ||
var results = response.results; // An array containing the results of the current page; | ||
// you may need to retrieve more pages to get all results | ||
assert.equal(results.length, 16); // gisthide | ||
var prev_page = response.prev_page; // the URL of the previous page (may be null) | ||
var next_page = response.next_page; // the URL of the next page (may be null) | ||
var results_per_page = response.results_per_page; // max number of results per page | ||
var results_size = response.results_size; // the size of the current page | ||
var total_pages = response.total_pages; // the number of pages | ||
var total_results_size = response.total_results_size; // the total size of results across all pages | ||
done(); // gisthide | ||
}); | ||
}); | ||
@@ -112,0 +110,0 @@ // endgist |
@@ -116,2 +116,22 @@ (function(Prismic) { | ||
it('Use getByID', function(done) { | ||
Prismic.Api(testRepository, function (err, Api) { | ||
if (err) throw err; | ||
Api.getByID('UlfoxUnM0wkXYXbt', {}, function (err, document) { | ||
assert.equal(document.id, 'UlfoxUnM0wkXYXbt'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('Use getByIDs', function(done) { | ||
Prismic.Api(testRepository, function (err, Api) { | ||
if (err) throw err; | ||
Api.getByIDs(['UlfoxUnM0wkXYXbt', 'UlfoxUnM0wkXYXbj'], {}, function (err, res) { | ||
assert.equal(res.results.length, 2); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('Submit the `everything` form with an ordering', function (done) { | ||
@@ -118,0 +138,0 @@ Prismic.Api(testRepository, function (err, Api) { |
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
1287503
70
10425
41
127