Last active
May 20, 2019 19:15
-
-
Save tttimur/97916f4e887720a9ef535bc01d78294d to your computer and use it in GitHub Desktop.
4ye collections
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
1) In your collection.liquid file create a div with the id "collection" | |
2) add collection.css | |
3) add cms.js | |
4) add collectionFetch.js | |
specifically: | |
2-4) in theme.liquid | |
# in head | |
{% if template == 'collection' %} | |
<link rel="stylesheet" href="{{ 'collection.css' | asset_url }}" /> | |
{% endif %} | |
# before footer | |
{% if template == 'collection' %} | |
<script src="{{ 'cms.js' | asset_url }}"></script> | |
<script src="{{ 'collectionFetch.js' | asset_url }}"></script> | |
{% endif %} | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"koZT":[function(require,module,exports) { | |
!function(t){if(!t.fetch){var e={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(e.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],o=function(t){return t&&DataView.prototype.isPrototypeOf(t)},n=ArrayBuffer.isView||function(t){return t&&r.indexOf(Object.prototype.toString.call(t))>-1};u.prototype.append=function(t,e){t=a(t),e=h(e);var r=this.map[t];this.map[t]=r?r+","+e:e},u.prototype.delete=function(t){delete this.map[a(t)]},u.prototype.get=function(t){return t=a(t),this.has(t)?this.map[t]:null},u.prototype.has=function(t){return this.map.hasOwnProperty(a(t))},u.prototype.set=function(t,e){this.map[a(t)]=h(e)},u.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},u.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),f(t)},u.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),f(t)},u.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),f(t)},e.iterable&&(u.prototype[Symbol.iterator]=u.prototype.entries);var i=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},c.call(b.prototype),c.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},w.error=function(){var t=new w(null,{status:0,statusText:""});return t.type="error",t};var s=[301,302,303,307,308];w.redirect=function(t,e){if(-1===s.indexOf(e))throw new RangeError("Invalid status code");return new w(null,{status:e,headers:{location:t}})},t.Headers=u,t.Request=b,t.Response=w,t.fetch=function(t,r){return new Promise(function(o,n){var i=new b(t,r),s=new XMLHttpRequest;s.onload=function(){var t,e,r={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new u,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();e.append(o,n)}}),e)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var n="response"in s?s.response:s.responseText;o(new w(n,r))},s.onerror=function(){n(new TypeError("Network request failed"))},s.ontimeout=function(){n(new TypeError("Network request failed"))},s.open(i.method,i.url,!0),"include"===i.credentials?s.withCredentials=!0:"omit"===i.credentials&&(s.withCredentials=!1),"responseType"in s&&e.blob&&(s.responseType="blob"),i.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),s.send(void 0===i._bodyInit?null:i._bodyInit)})},t.fetch.polyfill=!0}function a(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var r={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return e.iterable&&(r[Symbol.iterator]=function(){return r}),r}function u(t){this.map={},t instanceof u?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function d(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function y(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function l(t){var e=new FileReader,r=y(e);return e.readAsArrayBuffer(t),r}function p(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function c(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if("string"==typeof t)this._bodyText=t;else if(e.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(e.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(e.arrayBuffer&&e.blob&&o(t))this._bodyArrayBuffer=p(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!e.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t)&&!n(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=p(t)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e.blob&&(this.blob=function(){var t=d(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var t,e,r,o=d(this);if(o)return o;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=y(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),o=0;o<e.length;o++)r[o]=String.fromCharCode(e[o]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},e.formData&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}function b(t,e){var r,o,n=(e=e||{}).body;if(t instanceof b){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new u(t.headers)),this.method=t.method,this.mode=t.mode,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new u(e.headers)),this.method=(r=e.method||this.method||"GET",o=r.toUpperCase(),i.indexOf(o)>-1?o:r),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function m(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}}),e}function w(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new u(e.headers),this.url=e.url||"",this._initBody(t)}}("undefined"!=typeof self?self:this); | |
},{}],"3yjD":[function(require,module,exports) { | |
var define; | |
var t;!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("cross-fetch/polyfill")):"function"==typeof t&&t.amd?t("PrismicJS",["cross-fetch/polyfill"],n):"object"==typeof exports?exports.PrismicJS=n(require("cross-fetch/polyfill")):e.PrismicJS=n(e["cross-fetch/polyfill"])}("undefined"!=typeof self?self:this,function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=20)}([function(t,e,n){"use strict";e.a=function(t){var e=this.constructor;return this.then(function(n){return e.resolve(t()).then(function(){return n})},function(n){return e.resolve(t()).then(function(){return e.reject(n)})})}},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";e.__esModule=!0;var r=n(5),i=n(4),o=n(6),u=n(12);e.PREVIEW_COOKIE="io.prismic.preview",e.EXPERIMENT_COOKIE="io.prismic.experiment";var a=function(){function t(t,e,n){this.data=t,this.masterRef=t.refs.filter(function(t){return t.isMasterRef})[0],this.experiments=new r.Experiments(t.experiments),this.bookmarks=t.bookmarks,this.httpClient=e,this.options=n,this.refs=t.refs,this.tags=t.tags,this.types=t.types}return t.prototype.form=function(t){var e=this.data.forms[t];return e?new i.SearchForm(e,this.httpClient):null},t.prototype.everything=function(){var t=this.form("everything");if(!t)throw new Error("Missing everything form");return t},t.prototype.master=function(){return this.masterRef.ref},t.prototype.ref=function(t){var e=this.data.refs.filter(function(e){return e.label===t})[0];return e?e.ref:null},t.prototype.currentExperiment=function(){return this.experiments.current()},t.prototype.query=function(t,n,r){void 0===r&&(r=function(){});var i="function"==typeof n?{options:{},callback:n}:{options:n||{},callback:r},o=i.options,a=i.callback,s=this.everything();for(var f in o)s=s.set(f,o[f]);if(!o.ref){var c="";this.options.req?c=this.options.req.headers.cookie||"":"undefined"!=typeof window&&window.document&&(c=window.document.cookie||"");var l=u.default.parse(c),h=l[e.PREVIEW_COOKIE],p=this.experiments.refFromCookie(l[e.EXPERIMENT_COOKIE]);s=s.ref(h||p||this.masterRef.ref)}return t&&s.query(t),s.submit(a)},t.prototype.queryFirst=function(t,e,n){var r="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:n||function(){}},i=r.options,o=r.callback;return i.page=1,i.pageSize=1,this.query(t,i).then(function(t){var e=t&&t.results&&t.results[0];return o(null,e),e}).catch(function(t){throw o(t),t})},t.prototype.getByID=function(t,e,n){var r=e||{};return r.lang||(r.lang="*"),this.queryFirst(o.default.at("document.id",t),r,n)},t.prototype.getByIDs=function(t,e,n){var r=e||{};return r.lang||(r.lang="*"),this.query(o.default.in("document.id",t),r,n)},t.prototype.getByUID=function(t,e,n,r){var i=n||{};if("*"===i.lang)throw new Error("FORDIDDEN. You can't use getByUID with *, use the predicates instead.");return i.page||(i.page=1),this.queryFirst(o.default.at("my."+t+".uid",e),i,r)},t.prototype.getSingle=function(t,e,n){var r=e||{};return this.queryFirst(o.default.at("document.type",t),r,n)},t.prototype.getBookmark=function(t,e,n){var r=this.data.bookmarks[t];return r?this.getByID(r,e,n):Promise.reject("Error retrieving bookmarked id")},t.prototype.previewSession=function(t,e,n,r){var i=this;return new Promise(function(o,u){i.httpClient.request(t,function(a,s){if(a)r&&r(a),u(a);else if(s){if(s.mainDocument)return i.getByID(s.mainDocument,{ref:t}).then(function(t){if(t){var i=e(t);r&&r(null,i),o(i)}else r&&r(null,n),o(n)}).catch(u);r&&r(null,n),o(n)}})})},t}();e.default=a},function(t,e,n){"use strict";e.__esModule=!0;var r=n(2),i=n(11),o=function(){function t(t,e){if(this.options=e||{},this.url=t,this.options.accessToken){var n="access_token="+this.options.accessToken;this.url+=(t.indexOf("?")>-1?"&":"?")+n}this.apiDataTTL=this.options.apiDataTTL||5,this.httpClient=new i.default(this.options.requestHandler,this.options.apiCache,this.options.proxyAgent)}return t.prototype.get=function(t){var e=this;return this.httpClient.cachedRequest(this.url,{ttl:this.apiDataTTL}).then(function(n){var i=new r.default(n,e.httpClient,e.options);return t&&t(null,i),i}).catch(function(e){throw t&&t(e),e})},t}();e.default=o},function(t,e,n){"use strict";e.__esModule=!0;var r=function(){function t(t,e){this.id=t,this.api=e,this.fields={}}return t.prototype.set=function(t,e){return this.fields[t]=e,this},t.prototype.ref=function(t){return this.set("ref",t)},t.prototype.query=function(t){return this.set("q",t)},t.prototype.pageSize=function(t){return this.set("pageSize",t)},t.prototype.fetch=function(t){return console.warn("Warning: Using Fetch is deprecated. Use the property `graphQuery` instead."),this.set("fetch",t)},t.prototype.fetchLinks=function(t){return console.warn("Warning: Using FetchLinks is deprecated. Use the property `graphQuery` instead."),this.set("fetchLinks",t)},t.prototype.graphQuery=function(t){return this.set("graphQuery",t)},t.prototype.lang=function(t){return this.set("lang",t)},t.prototype.page=function(t){return this.set("page",t)},t.prototype.after=function(t){return this.set("after",t)},t.prototype.orderings=function(t){return this.set("orderings",t)},t.prototype.url=function(){var e=this;return this.api.get().then(function(n){return t.toSearchForm(e,n).url()})},t.prototype.submit=function(e){var n=this;return this.api.get().then(function(r){return t.toSearchForm(n,r).submit(e)})},t.toSearchForm=function(t,e){var n=e.form(t.id);if(n)return Object.keys(t.fields).reduce(function(e,n){var r=t.fields[n];return"q"===n?e.query(r):"pageSize"===n?e.pageSize(r):"fetch"===n?e.fetch(r):"fetchLinks"===n?e.fetchLinks(r):"graphQuery"===n?e.graphQuery(r):"lang"===n?e.lang(r):"page"===n?e.page(r):"after"===n?e.after(r):"orderings"===n?e.orderings(r):e.set(n,r)},n);throw new Error("Unable to access to form "+t.id)},t}();e.LazySearchForm=r;var i=function(){function t(t,e){for(var n in this.httpClient=e,this.form=t,this.data={},t.fields)t.fields[n].default&&(this.data[n]=[t.fields[n].default])}return t.prototype.set=function(t,e){var n=this.form.fields[t];if(!n)throw new Error("Unknown field "+t);var r=""===e||void 0===e?null:e,i=this.data[t]||[];return i=n.multiple?r?i.concat([r]):i:r?[r]:i,this.data[t]=i,this},t.prototype.ref=function(t){return this.set("ref",t)},t.prototype.query=function(t){if("string"==typeof t)return this.query([t]);if(Array.isArray(t))return this.set("q","["+t.join("")+"]");throw new Error("Invalid query : "+t)},t.prototype.pageSize=function(t){return this.set("pageSize",t)},t.prototype.fetch=function(t){console.warn("Warning: Using Fetch is deprecated. Use the property `graphQuery` instead.");var e=Array.isArray(t)?t.join(","):t;return this.set("fetch",e)},t.prototype.fetchLinks=function(t){console.warn("Warning: Using FetchLinks is deprecated. Use the property `graphQuery` instead.");var e=Array.isArray(t)?t.join(","):t;return this.set("fetchLinks",e)},t.prototype.graphQuery=function(t){return this.set("graphQuery",t)},t.prototype.lang=function(t){return this.set("lang",t)},t.prototype.page=function(t){return this.set("page",t)},t.prototype.after=function(t){return this.set("after",t)},t.prototype.orderings=function(t){return t?this.set("orderings","["+t.join(",")+"]"):this},t.prototype.url=function(){var t=this.form.action;if(this.data){var e=t.indexOf("?")>-1?"&":"?";for(var n in this.data)if(this.data.hasOwnProperty(n)){var r=this.data[n];if(r)for(var i=0;i<r.length;i++)t+=e+n+"="+encodeURIComponent(r[i]),e="&"}}return t},t.prototype.submit=function(t){return this.httpClient.cachedRequest(this.url()).then(function(e){return t&&t(null,e),e}).catch(function(e){throw t&&t(e),e})},t}();e.SearchForm=i},function(t,e,n){"use strict";e.__esModule=!0;var r=function(){function t(t){this.data={},this.data=t}return t.prototype.id=function(){return this.data.id},t.prototype.ref=function(){return this.data.ref},t.prototype.label=function(){return this.data.label},t}();e.Variation=r;var i=function(){function t(t){this.data={},this.data=t,this.variations=(t.variations||[]).map(function(t){return new r(t)})}return t.prototype.id=function(){return this.data.id},t.prototype.googleId=function(){return this.data.googleId},t.prototype.name=function(){return this.data.name},t}();e.Experiment=i;var o=function(){function t(t){t&&(this.drafts=(t.drafts||[]).map(function(t){return new i(t)}),this.running=(t.running||[]).map(function(t){return new i(t)}))}return t.prototype.current=function(){return this.running.length>0?this.running[0]:null},t.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},t}();e.Experiments=o},function(t,e,n){"use strict";e.__esModule=!0;function r(t){if("string"==typeof t)return'"'+t+'"';if("number"==typeof t)return t.toString();if(t instanceof Date)return t.getTime().toString();if(Array.isArray(t))return"["+t.map(function(t){return r(t)}).join(",")+"]";throw new Error("Unable to encode "+t+" of type "+typeof t)}var i={near:function(t,e,n,r){return"[geopoint.near("+t+", "+e+", "+n+", "+r+")]"}},o={before:function(t,e){return"[date.before("+t+", "+r(e)+")]"},after:function(t,e){return"[date.after("+t+", "+r(e)+")]"},between:function(t,e,n){return"[date.between("+t+", "+r(e)+", "+r(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+", "+r(e)+")]"},dayOfWeekAfter:function(t,e){return"[date.day-of-week-after("+t+", "+r(e)+")]"},dayOfWeekBefore:function(t,e){return"[date.day-of-week-before("+t+", "+r(e)+")]"},month:function(t,e){return"[date.month("+t+", "+r(e)+")]"},monthBefore:function(t,e){return"[date.month-before("+t+", "+r(e)+")]"},monthAfter:function(t,e){return"[date.month-after("+t+", "+r(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+")]"}},u={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+")]"}};e.default={at:function(t,e){return"[at("+t+", "+r(e)+")]"},not:function(t,e){return"[not("+t+", "+r(e)+")]"},missing:function(t){return"[missing("+t+")]"},has:function(t){return"[has("+t+")]"},any:function(t,e){return"[any("+t+", "+r(e)+")]"},in:function(t,e){return"[in("+t+", "+r(e)+")]"},fulltext:function(t,e){return"[fulltext("+t+", "+r(e)+")]"},similar:function(t,e){return'[similar("'+t+'", '+e+")]"},date:o,dateBefore:o.before,dateAfter:o.after,dateBetween:o.between,dayOfMonth:o.dayOfMonth,dayOfMonthAfter:o.dayOfMonthAfter,dayOfMonthBefore:o.dayOfMonthBefore,dayOfWeek:o.dayOfWeek,dayOfWeekAfter:o.dayOfWeekAfter,dayOfWeekBefore:o.dayOfWeekBefore,month:o.month,monthBefore:o.monthBefore,monthAfter:o.monthAfter,year:o.year,hour:o.hour,hourBefore:o.hourBefore,hourAfter:o.hourAfter,number:u,gt:u.gt,lt:u.lt,inRange:u.inRange,near:i.near,geopoint:i}},function(t,e,n){"use strict";(function(t){var r=n(0),i=setTimeout;function o(){}function u(t){if(!(this instanceof u))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],l(t,this)}function a(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,u._immediateFn(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null!==n){var r;try{r=n(t._value)}catch(t){return void f(e.promise,t)}s(e.promise,r)}else(1===t._state?s:f)(e.promise,t._value)})):t._deferreds.push(e)}function s(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof u)return t._state=3,t._value=e,void c(t);if("function"==typeof n)return void l(function(t,e){return function(){t.apply(e,arguments)}}(n,e),t)}t._state=1,t._value=e,c(t)}catch(e){f(t,e)}}function f(t,e){t._state=2,t._value=e,c(t)}function c(t){2===t._state&&0===t._deferreds.length&&u._immediateFn(function(){t._handled||u._unhandledRejectionFn(t._value)});for(var e=0,n=t._deferreds.length;e<n;e++)a(t,t._deferreds[e]);t._deferreds=null}function l(t,e){var n=!1;try{t(function(t){n||(n=!0,s(e,t))},function(t){n||(n=!0,f(e,t))})}catch(t){if(n)return;n=!0,f(e,t)}}u.prototype.catch=function(t){return this.then(null,t)},u.prototype.then=function(t,e){var n=new this.constructor(o);return a(this,new function(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}(t,e,n)),n},u.prototype.finally=r.a,u.all=function(t){return new u(function(e,n){if(!t||void 0===t.length)throw new TypeError("Promise.all accepts an array");var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);var i=r.length;function o(t,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var a=u.then;if("function"==typeof a)return void a.call(u,function(e){o(t,e)},n)}r[t]=u,0==--i&&e(r)}catch(t){n(t)}}for(var u=0;u<r.length;u++)o(u,r[u])})},u.resolve=function(t){return t&&"object"==typeof t&&t.constructor===u?t:new u(function(e){e(t)})},u.reject=function(t){return new u(function(e,n){n(t)})},u.race=function(t){return new u(function(e,n){for(var r=0,i=t.length;r<i;r++)t[r].then(e,n)})},u._immediateFn="function"==typeof t&&function(e){t(e)}||function(t){i(t,0)},u._unhandledRejectionFn=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)},e.a=u}).call(this,n(18).setImmediate)},function(t,e,n){"use strict";e.__esModule=!0;var r=20,i=0,o=[];var u=function(){function t(t){this.options=t||{}}return t.prototype.request=function(t,e){o.push({url:t,callback:e}),function t(e){if(o.length>0&&i<r){i++;var n=o.shift();n&&function(t,e,n){var r={headers:{Accept:"application/json"}};e&&e.proxyAgent&&(r.agent=e.proxyAgent),fetch(t,r).then(function(e){return~~(e.status/100!=2)?e.text().then(function(){var n=new Error("Unexpected status code ["+e.status+"] on URL "+t);throw n.status=e.status,n}):e.json().then(function(t){var r=e.headers.get("cache-control"),i=r?/max-age=(\d+)/.exec(r):null,o=i?parseInt(i[1],10):void 0;n(null,t,e,o)})}).catch(n)}(n.url,e,function(r,o,u,a){i--,n.callback(r,o,u,a),t(e)})}}(this.options)},t}();e.DefaultRequestHandler=u},function(t,e,n){"use strict";function r(t){this.size=0,this.limit=t,this._keymap={}}e.__esModule=!0,e.MakeLRUCache=function(t){return new r(t)},r.prototype.put=function(t,e){var n={key:t,value:e};if(this._keymap[t]=n,this.tail?(this.tail.newer=n,n.older=this.tail):this.head=n,this.tail=n,this.size===this.limit)return this.shift();this.size++},r.prototype.shift=function(){var t=this.head;return t&&(this.head.newer?(this.head=this.head.newer,this.head.older=void 0):this.head=void 0,t.newer=t.older=void 0,delete this._keymap[t.key]),console.log("purging ",t.key),t},r.prototype.get=function(t,e){var n=this._keymap[t];if(void 0!==n)return n===this.tail?e?n:n.value:(n.newer&&(n===this.head&&(this.head=n.newer),n.newer.older=n.older),n.older&&(n.older.newer=n.newer),n.newer=void 0,n.older=this.tail,this.tail&&(this.tail.newer=n),this.tail=n,e?n:n.value)},r.prototype.find=function(t){return this._keymap[t]},r.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.value),n},r.prototype.remove=function(t){var e=this._keymap[t];if(e)return delete this._keymap[e.key],e.newer&&e.older?(e.older.newer=e.newer,e.newer.older=e.older):e.newer?(e.newer.older=void 0,this.head=e.newer):e.older?(e.older.newer=void 0,this.tail=e.older):this.head=this.tail=void 0,this.size--,e.value},r.prototype.removeAll=function(){this.head=this.tail=void 0,this.size=0,this._keymap={}},"function"==typeof Object.keys?r.prototype.keys=function(){return Object.keys(this._keymap)}:r.prototype.keys=function(){var t=[];for(var e in this._keymap)t.push(e);return t},r.prototype.forEach=function(t,e,n){var r;if(!0===e?(n=!0,e=void 0):"object"!=typeof e&&(e=this),n)for(r=this.tail;r;)t.call(e,r.key,r.value,this),r=r.older;else for(r=this.head;r;)t.call(e,r.key,r.value,this),r=r.newer},r.prototype.toString=function(){for(var t="",e=this.head;e;)t+=String(e.key)+":"+e.value,(e=e.newer)&&(t+=" < ");return t}},function(t,e,n){"use strict";e.__esModule=!0;var r=n(9),i=function(){function t(t){void 0===t&&(t=1e3),this.lru=r.MakeLRUCache(t)}return t.prototype.isExpired=function(t){var e=this.lru.get(t,!1);return!!e&&0!==e.expiredIn&&e.expiredIn<Date.now()},t.prototype.get=function(t,e){var n=this.lru.get(t,!1);n&&!this.isExpired(t)?e(null,n.data):e&&e(null)},t.prototype.set=function(t,e,n,r){this.lru.remove(t),this.lru.put(t,{data:e,expiredIn:n?Date.now()+1e3*n:0}),r&&r(null)},t.prototype.remove=function(t,e){this.lru.remove(t),e&&e(null)},t.prototype.clear=function(t){this.lru.removeAll(),t&&t(null)},t}();e.DefaultApiCache=i},function(t,e,n){"use strict";e.__esModule=!0;var r=n(10),i=n(8),o=function(){function t(t,e,n){this.requestHandler=t||new i.DefaultRequestHandler({proxyAgent:n}),this.cache=e||new r.DefaultApiCache}return t.prototype.request=function(t,e){this.requestHandler.request(t,function(t,n,r,i){t?e&&e(t,null,r,i):n&&e&&e(null,n,r,i)})},t.prototype.cachedRequest=function(t,e){var n=this,r=e||{};return new Promise(function(e,i){!function(e){var i=r.cacheKey||t;n.cache.get(i,function(o,u){o||u?e(o,u):n.request(t,function(t,o,u,a){if(t)e(t,null);else{var s=a||r.ttl;s&&n.cache.set(i,o,s,e),e(null,o)}})})}(function(t,n){t&&i(t),n&&e(n)})})},t}();e.default=o},function(t,e,n){"use strict";e.__esModule=!0;var r=decodeURIComponent;e.default={parse:function(t,e){if("string"!=typeof t)throw new TypeError("argument str must be a string");var n={},i=e||{},o=t.split(/; */),u=i.decode||r;return o.forEach(function(t){var e=t.indexOf("=");if(!(e<0)){var r=t.substr(0,e).trim(),i=t.substr(++e,t.length).trim();'"'==i[0]&&(i=i.slice(1,-1)),null==n[r]&&(n[r]=function(t,e){try{return e(t)}catch(e){return t}}(i,u))}}),n}}},function(t,e,n){"use strict";e.__esModule=!0;var r=n(4),i=n(3),o=function(){function t(t,e){this.api=new i.default(t,e)}return t.prototype.getApi=function(){return this.api.get()},t.prototype.everything=function(){return this.form("everything")},t.prototype.form=function(t){return new r.LazySearchForm(t,this.api)},t.prototype.query=function(t,e,n){return this.getApi().then(function(r){return r.query(t,e,n)})},t.prototype.queryFirst=function(t,e,n){return this.getApi().then(function(r){return r.queryFirst(t,e,n)})},t.prototype.getByID=function(t,e,n){return this.getApi().then(function(r){return r.getByID(t,e,n)})},t.prototype.getByIDs=function(t,e,n){return this.getApi().then(function(r){return r.getByIDs(t,e,n)})},t.prototype.getByUID=function(t,e,n,r){return this.getApi().then(function(i){return i.getByUID(t,e,n,r)})},t.prototype.getSingle=function(t,e,n){return this.getApi().then(function(r){return r.getSingle(t,e,n)})},t.prototype.getBookmark=function(t,e,n){return this.getApi().then(function(r){return r.getBookmark(t,e,n)})},t.prototype.previewSession=function(t,e,n,r){return this.getApi().then(function(i){return i.previewSession(t,e,n,r)})},t.getApi=function(t,e){return new i.default(t,e).get()},t}();e.DefaultClient=o},function(t,e,n){"use strict";var r,i=n(6),o=n(5),u=n(13),a=n(3),s=n(2);!function(t){function e(t,e){return u.DefaultClient.getApi(t,e)}t.experimentCookie=s.EXPERIMENT_COOKIE,t.previewCookie=s.PREVIEW_COOKIE,t.Predicates=i.default,t.Experiments=o.Experiments,t.Api=a.default,t.client=function(t,e){return new u.DefaultClient(t,e)},t.getApi=e,t.api=function(t,n){return e(t,n)}}(r||(r={})),t.exports=r},function(e,n){e.exports=t},function(t,e){var n,r,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(t){r=u}}();var s,f=[],c=!1,l=-1;function h(){c&&s&&(c=!1,s.length?f=s.concat(f):l=-1,f.length&&p())}function p(){if(!c){var t=a(h);c=!0;for(var e=f.length;e;){for(s=f,f=[];++l<e;)s&&s[l].run();l=-1,e=f.length}s=null,c=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function y(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];f.push(new d(t,e)),1!==f.length||c||a(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var r,i=1,o={},u=!1,a=t.document,s=Object.getPrototypeOf&&Object.getPrototypeOf(t);s=s&&s.setTimeout?s:t,"[object process]"==={}.toString.call(t.process)?r=function(t){e.nextTick(function(){c(t)})}:function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?function(){var e="setImmediate$"+Math.random()+"$",n=function(n){n.source===t&&"string"==typeof n.data&&0===n.data.indexOf(e)&&c(+n.data.slice(e.length))};t.addEventListener?t.addEventListener("message",n,!1):t.attachEvent("onmessage",n),r=function(n){t.postMessage(e+n,"*")}}():t.MessageChannel?function(){var t=new MessageChannel;t.port1.onmessage=function(t){c(t.data)},r=function(e){t.port2.postMessage(e)}}():a&&"onreadystatechange"in a.createElement("script")?function(){var t=a.documentElement;r=function(e){var n=a.createElement("script");n.onreadystatechange=function(){c(e),n.onreadystatechange=null,t.removeChild(n),n=null},t.appendChild(n)}}():r=function(t){setTimeout(c,0,t)},s.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n<e.length;n++)e[n]=arguments[n+1];var u={callback:t,args:e};return o[i]=u,r(i),i++},s.clearImmediate=f}function f(t){delete o[t]}function c(t){if(u)setTimeout(c,0,t);else{var e=o[t];if(e){u=!0;try{!function(t){var e=t.callback,r=t.args;switch(r.length){case 0:e();break;case 1:e(r[0]);break;case 2:e(r[0],r[1]);break;case 3:e(r[0],r[1],r[2]);break;default:e.apply(n,r)}}(e)}finally{f(t),u=!1}}}}}("undefined"==typeof self?void 0===t?this:t:self)}).call(this,n(1),n(16))},function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n(17),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(1))},function(t,e,n){"use strict";n.r(e),function(t){var e=n(7),r=n(0),i=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==t)return t;throw new Error("unable to locate global object")}();i.Promise?i.Promise.prototype.finally||(i.Promise.prototype.finally=r.a):i.Promise=e.a}.call(this,n(1))},function(t,e,n){n(19),n(15),t.exports=n(14)}])}); | |
},{"cross-fetch/polyfill":"koZT"}],"Focm":[function(require,module,exports) { | |
var i=require("prismic-javascript"),t="https://fourye56.prismic.io/api/v2";function n(n,e){i.getApi(t).then(function(t){return t.query(i.Predicates.at("my.collection.uid",n))}).then(function(i){e(i)},function(i){e(i)})}window.getPosts=n; | |
},{"prismic-javascript":"3yjD"}]},{},["Focm"], null) | |
//# sourceMappingURL=/index.js.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function initCollection (parentElement, collectionTitle) { | |
var PARENT_ELEMENT = undefined | |
var COLLECTION_TITLE = undefined | |
// check for parent element where the content will write to | |
if (typeof parentElement === 'string') { | |
// if selector, query the element via selector | |
PARENT_ELEMENT = document.querySelector(parentElement) | |
if (!PARENT_ELEMENT) { | |
console.log('parent element not found') | |
return false | |
} | |
} else if (parentElement instanceof Element || parentElement instanceof HTMLDocument) { | |
// if dom element just reference the dom elment | |
PARENT_ELEMENT = parentElement | |
} else { | |
console.log('parent Element not an element!') | |
return false | |
} | |
// check for collection title | |
if (typeof collectionTitle === 'string') { | |
COLLECTION_TITLE = collectionTitle | |
} else { | |
console.log('please specific a collection title, using 2019-durags') | |
COLLECTION_TITLE = '2019-durags' | |
} | |
function init () { | |
if (!window.getPosts) return | |
window.getPosts(COLLECTION_TITLE, compilePosts) | |
} | |
function compilePosts (res) { | |
// if there are results | |
if (res.results.length > 0) { | |
// get first result and create markup | |
res.results[0].data.body.forEach(function (component) { | |
console.log(component, 'COMPONENT') | |
if (component.slice_type == 'image_medium') { | |
createSingleImage(component) | |
} else if (component.slice_type == 'two_images_-_no_margin') { | |
createDoubleImage(component) | |
} else if (component.slice_type == 'three_images') { | |
createTripleImage(component) | |
} else if (component.slice_type == 'text') { | |
createText(component) | |
} | |
}) | |
} else { | |
console.log('post node found!') | |
return false | |
} | |
} | |
function createText (component) { | |
var section = document.createElement('section') | |
section.className = 'text-section c12' | |
component.primary.text.forEach(function (text) { | |
var p = createParagraphRaw(text.text) | |
section.appendChild(p) | |
}) | |
PARENT_ELEMENT.appendChild(section) | |
} | |
function createSingleImage (image) { | |
var section = document.createElement('section') | |
section.className = 'boyyyy c12 image-size-' + image.primary.image_size | |
var imageEl = createImageRaw(image.primary.image.url, 'c12') | |
section.appendChild(imageEl) | |
PARENT_ELEMENT.appendChild(section) | |
} | |
function createDoubleImage (component) { | |
var section = document.createElement('section') | |
section.className = 'boyyyy c12 x xw img-double image-spacing-' + component.primary.image_spacing | |
var imageEl1 = createImageRaw(component.primary.image_1.url, 'c12') | |
var imageEl2 = createImageRaw(component.primary.image_2.url, 'c12') | |
section.appendChild(imageEl1) | |
section.appendChild(imageEl2) | |
PARENT_ELEMENT.appendChild(section) | |
} | |
function createTripleImage (component) { | |
var section = document.createElement('section') | |
section.className = 'boyyyy c12 img-triple x xw image-spacing-' + component.primary.spacing | |
var imageEl1 = createImageRaw(component.primary.image_1.url, 'c12') | |
var imageEl2 = createImageRaw(component.primary.image_2.url, 'c12') | |
var imageEl3 = createImageRaw(component.primary.image_3.url, 'c12') | |
section.appendChild(imageEl1) | |
section.appendChild(imageEl2) | |
section.appendChild(imageEl3) | |
PARENT_ELEMENT.appendChild(section) | |
} | |
function createParagraphRaw (content) { | |
var p = document.createElement('p') | |
p.innerText = content | |
return p | |
} | |
function createImageRaw (src, className) { | |
var parent = document.createElement('div') | |
var image = document.createElement('img') | |
image.setAttribute('src', src) | |
image.className = className | |
parent.appendChild(image) | |
return parent | |
} | |
init() | |
} | |
// get the collection slug from shopify url of /collections/:collection | |
function getCollectionSlugFromURL () { | |
if (window.location.href.indexOf('collections') > -1) { | |
var x = window.location.href.split('collections/') | |
return x[1] | |
} else { | |
return '2019-durags' | |
} | |
} | |
// Update this with your info! | |
/* | |
initCollection(DOMElement || selector: element, String: collectionSlug) | |
*/ | |
initCollection('#container', getCollectionSlugFromURL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body, html { | |
margin: 0; | |
padding: 0; | |
} | |
.image-size-Centered { | |
width: 60vw; | |
margin: 10vw auto; | |
} | |
.image-size-Full { | |
width: 100vw; | |
margin: 10vw auto; | |
} | |
.img-triple, .img-double { | |
display: flex; | |
flex-wrap: wrap; | |
width: 100%; | |
margin: 10vw auto; | |
} | |
.img-triple div {width: 33.33%} | |
.img-double div {width:50%} | |
.img-triple.image-spacing-Small, .img-double.image-spacing-Little { | |
width: 80vw; | |
justify-content: space-between; | |
} | |
.img-triple.image-spacing-Small div { | |
width: 32%; | |
} | |
.img-double.image-spacing-Little div { | |
width: 48.5% | |
} | |
.text-section { | |
width: 80vw; | |
margin: 10vw auto; | |
text-transform: uppercase; | |
font-size: 3rem; | |
font-family: 'Helvetica Neue'; | |
text-align: center; | |
} | |
@media (max-width: 700px) { | |
.image-size-Centered { | |
width: 90vw; | |
margin: 10vw auto; | |
} | |
.img-triple.image-spacing-Small, .img-double.image-spacing-Little { | |
width: 90vw; | |
margin: 10vw auto; | |
} | |
.img-triple.image-spacing-Small div { | |
width: 100%; | |
margin-bottom: 5vw; | |
} | |
.img-double.image-spacing-Little div, .img-double div { | |
width: 100%; | |
} | |
.text-section { | |
/* width: 80vw; */ | |
/* margin: 10vw auto; */ | |
font-size: 1.5rem | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment