From 1f1c611afe317da2812f614ab3c17fda2a290015 Mon Sep 17 00:00:00 2001 From: Ro Date: Wed, 30 Jun 2021 14:06:13 -0700 Subject: [PATCH] fixed token check, fixed empty image page post --- brain/controller/APIControl.inc.php | 14 ++- brain/data/Book.inc.php | 2 +- public/assets/scripts/dash.min.js | 4 +- src/com/actions/PageActions.js | 154 +++++++++++++++------------- src/libraries/FipamoAdminAPI.js | 1 + 5 files changed, 95 insertions(+), 80 deletions(-) diff --git a/brain/controller/APIControl.inc.php b/brain/controller/APIControl.inc.php index 821f7ef..447b70f 100644 --- a/brain/controller/APIControl.inc.php +++ b/brain/controller/APIControl.inc.php @@ -153,14 +153,22 @@ class APIControl case "page": $token = $request->getHeader("fipamo-access-token"); //Verify token for admin tasks - if (Session::verifyToken($token[0])) { - $result = PagesAPI::handlePageTask($request, $args); + if (isset($token[0])) { + if (Session::verifyToken($token[0])) { + $result = PagesAPI::handlePageTask($request, $args); + } else { + $result = [ + "message" => "Invalid token, API access denied, homie", + "type" => "API_ERROR", + ]; + } } else { $result = [ - "message" => "API access denied, homie", + "message" => "No token, API access denied, homie", "type" => "API_ERROR", ]; } + break; case "settings": $token = $request->getHeader("fipamo-access-token"); diff --git a/brain/data/Book.inc.php b/brain/data/Book.inc.php index 07e6f0a..ff3e578 100644 --- a/brain/data/Book.inc.php +++ b/brain/data/Book.inc.php @@ -92,7 +92,7 @@ class Book "/" . $url[8]; } else { - $feature = $body["feature"]; + $task == "create" ? ($feature = "") : ($feature = $body["feature"]); } } diff --git a/public/assets/scripts/dash.min.js b/public/assets/scripts/dash.min.js index 5fb45cf..f9c5e79 100644 --- a/public/assets/scripts/dash.min.js +++ b/public/assets/scripts/dash.min.js @@ -1,5 +1,5 @@ -!function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e(this,t),this.percentComplete=0,this.token=null,this.baseURL=null,this.key=null,o&&(this.key=o),r&&(this.baseURL=r),this._request(this.baseURL?this.baseURL+c+"?key="+this.key:c+"?key="+this.key).then((function(e){e.type===k&&(n.token=e.token)}))}return n(t,[{key:"login",value:function(e){var t=this;return new Promise((function(n,r){t.baseURL?e.remote=!0:e.remote=!1,t.key?e.key=t.key:e.key=null,t._request(t.baseURL?t.baseURL+m:m,"getAuthStatus",s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"syncSettings",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+d+"?key="+t.key:d+"?key="+t.key,v,s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"publishSite",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+f:f,y,s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"pageActions",value:function(e,t){var n,r,o,i=this;switch(e){case b:n="/api/v1/page/create",r=b,o=u;break;case w:n="/api/v1/page/write",r=w,o=u;break;case E:n="/api/v1/page/delete",r=E,o=l}return this.baseURL?(t.key=this.key,t.remote=!0):t.remote=!1,new Promise((function(e,a){i._request(i.baseURL?i.baseURL+n:n,r,s,o,t).then((function(t){e(t)})).catch((function(e){a(e)}))}))}},{key:"syncNav",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+h:h,v,s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"sendMail",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+g:g,"sendMail",s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"reindexPages",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+p:p,I,s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"_request",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"GET",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=this;return new Promise((function(a,c){var d=new XMLHttpRequest;if(d.upload.onprogress=i.handleLoadProgress,d.open(n,e,!0),d.onload=function(){if(200==d.status){var e=JSON.parse(d.response);a(e)}else{var t=JSON.parse(d.response);c(t)}},"PUT"==n||n==s)switch(t!==v&&t!==w&&t!==E&&t!==y&&t!==I||d.setRequestHeader("fipamo-access-token",i.token),r){case l:d.setRequestHeader("Content-type","application/"+r),d.send(JSON.stringify(o));break;case u:d.send(o)}else d.send()}))}},{key:"handleLoadProgress",value:function(e){this.percentComplete=Math.ceil(e.loaded/e.total*100)}}]),t}(),T="POST",x="json",D="x-www-form-urlencoded",P=function(){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e(this,t),this.baseURL=null,this.key=null,r&&(this.key=r),n&&(this.baseURL=n)}return n(t,[{key:"create",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/init","blogInit",T,x,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"restore",value:function(e){var t=this;return new Promise((function(n,r){var o;o=new FormData(e),t._request("/api/v1/restore","restoreBackup","POST","x-www-form-urlencoded",o).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"backup",value:function(){var e=this;return new Promise((function(t,n){var r;r={task:"create_backup"},e._request("/api/v1/backup","createBackup","POST","json",r).then((function(e){t(e)})).catch((function(e){n(e)}))}))}},{key:"secret",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/get-secret","retrieveSecret",T,x,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"newPass",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/reset-password","resetPassword",T,x,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"imageUpload",value:function(e,t){var n=this;return new Promise((function(r,o){var i="";switch(e){case"avatar-upload":i="/api/v1/settings/add-avatar";break;case"background-upload":i="/api/v1/settings/add-feature-background";break;default:i="/api/v1/page/add-entry-image"}var a=new FormData;n.baseURL?(a.append("key",n.key),a.append("remote",!0)):a.append("remote",!1);for(var s=0;s2&&void 0!==arguments[2]?arguments[2]:"GET",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:x,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=this;return new Promise((function(t,a){var s=new XMLHttpRequest;if(s.upload.onprogress=i.handleLoadProgress,s.open(n,e,!0),s.onload=function(){if(200==s.status){var e=JSON.parse(s.response);t(e)}else{var n=JSON.parse(s.response);a(n)}},"PUT"==n||n==T)switch(r){case x:s.setRequestHeader("Content-type","application/"+r),s.send(JSON.stringify(o));break;case D:s.send(o)}else s.send()}))}},{key:"handleLoadProgress",value:function(e){this.percentComplete=Math.ceil(e.loaded/e.total*100)}}]),t}(),_=function(){function t(){e(this,t)}return n(t,[{key:"imgLoad",value:function(e){return new Promise((function(t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){200===r.status?t(r.response):n(new Error("Image didn't load successfully; error code:"+r.statusText))},r.onerror=function(){n(new Error("There was a network error."))},r.send()}))}},{key:"loadImage",value:function(e){var t=this;return new Promise((function(n,r){(new Image).crossOrigin="",t.imgLoad(e).then((function(e){var t=window.URL.createObjectURL(e);n(t)}),(function(e){r(e)}))}))}},{key:"formDataToJSON",value:function(e){var t={};return new FormData(e).forEach((function(e,n){t.hasOwnProperty(n)?(Array.isArray(t[n])||(t[n]=[t[n]]),t[n].push(e)):t[n]=e})),t}}]),t}(),B="requestLame",A="postUpdated";new function t(){e(this,t)};var C=function(){function t(){e(this,t)}return n(t,[{key:"cleanString",value:function(e){return e.replace(/(^\-+|[^a-zA-Z0-9\/_| -]+|\-+$)/g,"").toLowerCase().replace(/[\/_| -]+/g,"-")}},{key:"decodeHTML",value:function(e,t){var n=0,r=0,o=!1;void 0===t&&(t=2),e=e.toString().replace(/</g,"<").replace(/>/g,">");var i={ENT_NOQUOTES:0,ENT_HTML_QUOTE_SINGLE:1,ENT_HTML_QUOTE_DOUBLE:2,ENT_COMPAT:2,ENT_QUOTES:3,ENT_IGNORE:4};if(0===t&&(o=!0),"number"!=typeof t){for(t=[].concat(t),r=0;r]*>/g,"\n"),r.append("id",document.getElementById("post-edit-index").getAttribute("data-index")),r.append("uuid",document.getElementById("post-edit-index").getAttribute("data-uuid")),r.append("layout",document.getElementById("post-edit-index").getAttribute("data-layout")),r.append("current_title",document.getElementById("post-edit-index").getAttribute("data-slug")),r.append("content",i),r.append("title",document.getElementById("post_title").value),r.append("created",document.getElementById("post-date").getAttribute("data-raw")),r.append("slug",(new C).cleanString(document.getElementById("post_title").value)),r.append("tags",document.getElementById("post_tags").value),r.append("menu",document.getElementById("option-menu-pin").getAttribute("data-active")),r.append("featured",document.getElementById("option-feature").getAttribute("data-active")),r.append("published",document.getElementById("option-published").getAttribute("data-active")),null!=e||null!=e)e.type.match("image.*")?r.append("feature_image",e,e.name):n("Not an image file");else{var a=document.getElementById("featured-image").src;null!=a||null!=a?r.append("feature_image",a):r.append("feature_image",null)}t(r)}))}}]),t}(),L="editorDelete",M="editorUploadImage",N="editorSave",R="editorUpdate";new function t(){e(this,t)};var U=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","boxSizing","fontFamily","fontSize","fontWeight","height","letterSpacing","lineHeight","marginBottom","marginLeft","marginRight","marginTop","outlineWidth","overflow","overflowX","overflowY","paddingBottom","paddingLeft","paddingRight","paddingTop","textAlign","textOverflow","textTransform","whiteSpace","wordBreak","wordWrap"],H=function(e,t){var n=document.createElement("div");return function(t){var r=function(){var t={position:"absolute",left:-9999,top:0,zIndex:-2e3};return"TEXTAREA"===e.tagName&&U.push("width"),U.forEach((function(n){t[n]=getComputedStyle(e)[n]})),t}();Object.keys(r).forEach((function(e){n.style[e]=r[e]})),n.innerHTML=t,e.parentNode.insertBefore(n,e.nextSibling)}(t),{rect:function(){var e=n.ownerDocument.getElementById("caret-position-marker"),t={left:e.offsetLeft,top:e.offsetTop,height:e.offsetHeight};return n.parentNode.removeChild(n),t}}};function F(e){return(F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var X=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.customPos,n=e.iframe,r=e.noShadowCaret;return n?{iframe:n,window:n.contentWindow,document:n.contentDocument||n.contentWindow.document,noShadowCaret:r,customPos:t}:{window:window,document:document,noShadowCaret:r,customPos:t}},q=function(e){return"object"===F(e)&&null!==e},Y=function(e,t){var n=function(){return e.selectionStart},r=function(r){var o=function(e){return e.replace(/<|>|`|"|&/g,"?").replace(/\r\n|\r|\n/g,"
")};(t.customPos||0===t.customPos)&&(r=t.customPos);var i=void 0===r?n():r,a=e.value.slice(0,i),s=e.value.slice(i),l=''.concat(o(a),"");l+='|',l+=''.concat(o(s),"");var u=H(e,l).rect();return u.pos=n(),u};return{getPos:n,setPos:function(t){return e.setSelectionRange(t,t),e},getOffset:function(n){var o=function(e,t){var n=t&&t.window||window,r=t&&t.document||document,o=e.getBoundingClientRect(),i=r.documentElement,a=n.pageXOffset||i.scrollLeft,s=n.pageYOffset||i.scrollTop;return{top:o.top+s,left:o.left+a}}(e),i=r(n);return{top:o.top+i.top+t.document.body.scrollTop,left:o.left+i.left+t.document.body.scrollLeft,height:i.height}},getPosition:r}},j=function(e,t){return function(e){return!!(e.contentEditable?"true"===e.contentEditable:"true"===e.getAttribute("contenteditable"))}(e)?function(e,t){var n=function(){var n=r(),o={height:0,left:0,right:0};if(!n)return o;var i=t.customPos||0===t.customPos;if(n.endOffset-1>0&&n.endContainer!==e||i){var a=n.cloneRange(),s=i?t.customPos:n.endOffset;a.setStart(n.endContainer,s-1<0?0:s-1),a.setEnd(n.endContainer,s);var l=a.getBoundingClientRect();o={height:l.height,left:l.left+l.width,top:l.top},a.detach()}if((!o||o&&0===o.height)&&!t.noShadowCaret){var u=n.cloneRange(),c=t.document.createTextNode("|");u.insertNode(c),u.selectNode(c);var d=u.getBoundingClientRect();o={height:d.height,left:d.left,top:d.top},c.parentNode.removeChild(c),u.detach()}if(o){var f=t.document.documentElement;o.top+=t.window.pageYOffset-(f.clientTop||0),o.left+=t.window.pageXOffset-(f.clientLeft||0)}return o},r=function(){if(t.window.getSelection){var e=t.window.getSelection();return e.rangeCount>0?e.getRangeAt(0):null}},o=function(){var t=r(),n=t.cloneRange();n.selectNodeContents(e),n.setEnd(t.endContainer,t.endOffset);var o=n.toString().length;return n.detach(),o};return{getPos:o,setPos:function(n){var r=t.window.getSelection();if(r){var o=0,i=!1;!function e(a,s){for(var l=0;l=a){i=!0;var c=t.document.createRange();c.setStart(u,a-o),r.removeAllRanges(),r.addRange(c);break}o+=u.length}else e(n,u)}}(n,e)}return e},getPosition:function(){var r=n(),i=o(),a=e.getBoundingClientRect(),s=a.top+t.document.body.scrollTop,l=a.left+t.document.body.scrollLeft;return r.left-=l,r.top-=s,r.pos=i,r},getOffset:n,getRange:r}}(e,t):Y(e,t)},W=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n;q(t)&&(r=t,t=null);var o=X(r),i=j(e,o);return t||0===t?i.setPos(t):i.getPosition()},z=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(i,t);var r=a(i);function i(t,n){var o;return e(this,i),(o=r.call(this)).textEditor=t,o.fixLimit=n,o.caretPos=null,o.url="",o.setInputs(),window.addEventListener("scroll",(function(){})),o.refresh(),o}return n(i,[{key:"setInputs",value:function(){for(var e=this,t=this,n=document.querySelectorAll(".editor-button"),r=0,o=n.length;r/g)>-1){var o=W(e.textEditor).pos;t.refresh(),W(e.textEditor,o)}}))}},{key:"refresh",value:function(){var e=this.textEditor.innerText;e=e.replace(new RegExp("\r?\n","g"),"
");var t=document.createElement("div");t.innerText=e,this.textEditor.innerHTML=t.innerText,this.textEditor.style.maxWidth="900px"}},{key:"notify",value:function(e,t){switch(e){case A:document.getElementById("submit-update").classList.add("icon-hide"),document.getElementById("submit-good").classList.remove("icon-hide"),document.getElementById("edit-update").classList.remove("submit-start"),document.getElementById("edit-update").classList.add("submit-cool"),setTimeout((function(){document.getElementById("submit-update").classList.remove("icon-hide"),document.getElementById("submit-good").classList.add("icon-hide"),document.getElementById("edit-update").classList.add("submit-start"),document.getElementById("edit-update").classList.remove("submit-cool")}),2e3);break;case"postAdded":break;case M:var n,r;W(this.textEditor,this.caretPos),(n=window.getSelection()).rangeCount&&((r=n.getRangeAt(0)).deleteContents(),r.insertNode(document.createTextNode("![image alt text]("+t+" 'image title')"))),this.refresh()}}},{key:"handleEditorOption",value:function(e){var t,n,r;if(e.preventDefault(),(t=window.getSelection()).rangeCount)switch(n=t.getRangeAt(0),r=t.getRangeAt(0).toString(),n.deleteContents(),e.target.id){case"edit-bold":n.insertNode(document.createTextNode("**"+r+"**"));break;case"edit-italic":n.insertNode(document.createTextNode("*"+r+"*"));break;case"edit-strikethrough":n.insertNode(document.createTextNode(""+r+""));break;case"edit-header1":n.insertNode(document.createTextNode("# "+r));break;case"edit-header2":n.insertNode(document.createTextNode("## "+r));break;case"edit-header3":n.insertNode(document.createTextNode("### "+r));break;case"edit-image":this.caretPos=W(this.textEditor).pos,this.emitEvent(M);break;case"submit-save":case"edit-save":this.emitEvent(N);break;case"submit-update":case"edit-update":this.emitEvent(R);break;case"edit-link":n.insertNode(document.createTextNode("["+r+"](PASTE URL HERE)"));break;case"edit-delete":this.emitEvent(L)}this.refresh()}}]),i}(function(){function t(){e(this,t),this.listeners=new Map}return n(t,[{key:"addListener",value:function(e,t){this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t)}},{key:"removeListener",value:function(e,t){var n,r=this.listeners.get(e);return!!(r&&r.length&&(n=r.reduce((function(e,n,r){return"function"==typeof n&&n===t?e=r:e}),-1))>-1)&&(r.splice(n,1),this.listeners.set(e,r),!0)}},{key:"emitEvent",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r-1}function K(e,t){return e.apply(null,t)}var ee={arr:function(e){return Array.isArray(e)},obj:function(e){return Z(Object.prototype.toString.call(e),"Object")},pth:function(e){return ee.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return e.nodeType||ee.svg(e)},str:function(e){return"string"==typeof e},fnc:function(e){return"function"==typeof e},und:function(e){return void 0===e},nil:function(e){return ee.und(e)||null===e},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return ee.hex(e)||ee.rgb(e)||ee.hsl(e)},key:function(e){return!G.hasOwnProperty(e)&&!Q.hasOwnProperty(e)&&"targets"!==e&&"keyframes"!==e}};function te(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map((function(e){return parseFloat(e)})):[]}function ne(e,t){var n=te(e),r=$(ee.und(n[0])?1:n[0],.1,100),o=$(ee.und(n[1])?100:n[1],.1,100),i=$(ee.und(n[2])?10:n[2],.1,100),a=$(ee.und(n[3])?0:n[3],.1,100),s=Math.sqrt(o/r),l=i/(2*Math.sqrt(o*r)),u=l<1?s*Math.sqrt(1-l*l):0,c=l<1?(l*s-a)/u:-a+s;function d(e){var n=t?t*e/1e3:e;return n=l<1?Math.exp(-n*l*s)*(1*Math.cos(u*n)+c*Math.sin(u*n)):(1+c*n)*Math.exp(-n*s),0===e||1===e?e:1-n}return t?d:function(){var t=J.springs[e];if(t)return t;for(var n=1/6,r=0,o=0;;)if(1===d(r+=n)){if(++o>=16)break}else o=0;var i=r*n*1e3;return J.springs[e]=i,i}}function re(e){return void 0===e&&(e=10),function(t){return Math.ceil($(t,1e-6,1)*e)*(1/e)}}var oe,ie,ae=function(){var e=.1;function t(e,t){return 1-3*t+3*e}function n(e,t){return 3*t-6*e}function r(e){return 3*e}function o(e,o,i){return((t(o,i)*e+n(o,i))*e+r(o))*e}function i(e,o,i){return 3*t(o,i)*e*e+2*n(o,i)*e+r(o)}return function(t,n,r,a){if(0<=t&&t<=1&&0<=r&&r<=1){var s=new Float32Array(11);if(t!==n||r!==a)for(var l=0;l<11;++l)s[l]=o(l*e,t,r);return function(e){return t===n&&r===a||0===e||1===e?e:o(u(e),n,a)}}function u(n){for(var a=0,l=1;10!==l&&s[l]<=n;++l)a+=e;--l;var u=a+(n-s[l])/(s[l+1]-s[l])*e,c=i(u,t,r);return c>=.001?function(e,t,n,r){for(var a=0;a<4;++a){var s=i(t,n,r);if(0===s)return t;t-=(o(t,n,r)-e)/s}return t}(n,u,t,r):0===c?u:function(e,t,n,r,i){var a,s,l=0;do{(a=o(s=t+(n-t)/2,r,i)-e)>0?n=s:t=s}while(Math.abs(a)>1e-7&&++l<10);return s}(n,a,a+e,t,r)}}}(),se=(oe={linear:function(){return function(e){return e}}},ie={Sine:function(){return function(e){return 1-Math.cos(e*Math.PI/2)}},Circ:function(){return function(e){return 1-Math.sqrt(1-e*e)}},Back:function(){return function(e){return e*e*(3*e-2)}},Bounce:function(){return function(e){for(var t,n=4;e<((t=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*t-2)/22-e,2)}},Elastic:function(e,t){void 0===e&&(e=1),void 0===t&&(t=.5);var n=$(e,1,10),r=$(t,.1,2);return function(e){return 0===e||1===e?e:-n*Math.pow(2,10*(e-1))*Math.sin((e-1-r/(2*Math.PI)*Math.asin(1/n))*(2*Math.PI)/r)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach((function(e,t){ie[e]=function(){return function(e){return Math.pow(e,t+2)}}})),Object.keys(ie).forEach((function(e){var t=ie[e];oe["easeIn"+e]=t,oe["easeOut"+e]=function(e,n){return function(r){return 1-t(e,n)(1-r)}},oe["easeInOut"+e]=function(e,n){return function(r){return r<.5?t(e,n)(2*r)/2:1-t(e,n)(-2*r+2)/2}},oe["easeOutIn"+e]=function(e,n){return function(r){return r<.5?(1-t(e,n)(1-2*r))/2:(t(e,n)(2*r-1)+1)/2}}})),oe);function le(e,t){if(ee.fnc(e))return e;var n=e.split("(")[0],r=se[n],o=te(e);switch(n){case"spring":return ne(e,t);case"cubicBezier":return K(ae,o);case"steps":return K(re,o);default:return K(r,o)}}function ue(e){try{return document.querySelectorAll(e)}catch(e){return}}function ce(e,t){for(var n=e.length,r=arguments.length>=2?t:void 0,o=[],i=0;i1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(0==a)t=n=r=s;else{var c=s<.5?s*(1+a):s+a-s*a,d=2*s-c;t=u(d,c,i+1/3),n=u(d,c,i),r=u(d,c,i-1/3)}return"rgba("+255*t+","+255*n+","+255*r+","+l+")"}(e):void 0;var t,n}function ye(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function be(e,t){return ee.fnc(e)?e(t.target,t.id,t.total):e}function we(e,t){return e.getAttribute(t)}function Ee(e,t,n){if(he([n,"deg","rad","turn"],ye(t)))return t;var r=J.CSS[t+n];if(!ee.und(r))return r;var o=document.createElement(e.tagName),i=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;i.appendChild(o),o.style.position="absolute",o.style.width=100+n;var a=100/o.offsetWidth;i.removeChild(o);var s=a*parseFloat(t);return J.CSS[t+n]=s,s}function Ie(e,t,n){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return n?Ee(e,o,n):o}}function ke(e,t){return ee.dom(e)&&!ee.inp(e)&&(!ee.nil(we(e,t))||ee.svg(e)&&e[t])?"attribute":ee.dom(e)&&he(V,t)?"transform":ee.dom(e)&&"transform"!==t&&Ie(e,t)?"css":null!=e[t]?"object":void 0}function Se(e){if(ee.dom(e)){for(var t,n=e.style.transform||"",r=/(\w+)\(([^)]*)\)/g,o=new Map;t=r.exec(n);)o.set(t[1],t[2]);return o}}function Te(e,t,n,r){var o=Z(t,"scale")?1:0+function(e){return Z(e,"translate")||"perspective"===e?"px":Z(e,"rotate")||Z(e,"skew")?"deg":void 0}(t),i=Se(e).get(t)||o;return n&&(n.transforms.list.set(t,i),n.transforms.last=t),r?Ee(e,i,r):i}function xe(e,t,n,r){switch(ke(e,t)){case"transform":return Te(e,t,r,n);case"css":return Ie(e,t,n);case"attribute":return we(e,t);default:return e[t]||0}}function De(e,t){var n=/^(\*=|\+=|-=)/.exec(e);if(!n)return e;var r=ye(e)||0,o=parseFloat(t),i=parseFloat(e.replace(n[0],""));switch(n[0][0]){case"+":return o+i+r;case"-":return o-i+r;case"*":return o*i+r}}function Pe(e,t){if(ee.col(e))return ve(e);if(/\s/g.test(e))return e;var n=ye(e),r=n?e.substr(0,e.length-n.length):e;return t?r+t:r}function _e(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Be(e){for(var t,n=e.points,r=0,o=0;o0&&(r+=_e(t,i)),t=i}return r}function Ae(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return function(e){return 2*Math.PI*we(e,"r")}(e);case"rect":return function(e){return 2*we(e,"width")+2*we(e,"height")}(e);case"line":return function(e){return _e({x:we(e,"x1"),y:we(e,"y1")},{x:we(e,"x2"),y:we(e,"y2")})}(e);case"polyline":return Be(e);case"polygon":return function(e){var t=e.points;return Be(e)+_e(t.getItem(t.numberOfItems-1),t.getItem(0))}(e)}}function Ce(e,t){var n=t||{},r=n.el||function(e){for(var t=e.parentNode;ee.svg(t)&&ee.svg(t.parentNode);)t=t.parentNode;return t}(e),o=r.getBoundingClientRect(),i=we(r,"viewBox"),a=o.width,s=o.height,l=n.viewBox||(i?i.split(" "):[0,0,a,s]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:a,h:s,vW:l[2],vH:l[3]}}function Oe(e,t,n){function r(n){void 0===n&&(n=0);var r=t+n>=1?t+n:0;return e.el.getPointAtLength(r)}var o=Ce(e.el,e.svg),i=r(),a=r(-1),s=r(1),l=n?1:o.w/o.vW,u=n?1:o.h/o.vH;switch(e.property){case"x":return(i.x-o.x)*l;case"y":return(i.y-o.y)*u;case"angle":return 180*Math.atan2(s.y-a.y,s.x-a.x)/Math.PI}}function Le(e,t){var n=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=Pe(ee.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(n)?r.match(n).map(Number):[0],strings:ee.str(e)||t?r.split(n):[]}}function Me(e){return ce(e?de(ee.arr(e)?e.map(fe):fe(e)):[],(function(e,t,n){return n.indexOf(e)===t}))}function Ne(e){var t=Me(e);return t.map((function(e,n){return{target:e,id:n,total:t.length,transforms:{list:Se(e)}}}))}function Re(e,t){var n=pe(t);if(/^spring/.test(n.easing)&&(n.duration=ne(n.easing)),ee.arr(e)){var r=e.length;2===r&&!ee.obj(e[0])?e={value:e}:ee.fnc(t.duration)||(n.duration=t.duration/r)}var o=ee.arr(e)?e:[e];return o.map((function(e,n){var r=ee.obj(e)&&!ee.pth(e)?e:{value:e};return ee.und(r.delay)&&(r.delay=n?0:t.delay),ee.und(r.endDelay)&&(r.endDelay=n===o.length-1?t.endDelay:0),r})).map((function(e){return me(e,n)}))}function Ue(e,t){var n=[],r=t.keyframes;for(var o in r&&(t=me(function(e){for(var t=ce(de(e.map((function(e){return Object.keys(e)}))),(function(e){return ee.key(e)})).reduce((function(e,t){return e.indexOf(t)<0&&e.push(t),e}),[]),n={},r=function(r){var o=t[r];n[o]=e.map((function(e){var t={};for(var n in e)ee.key(n)?n==o&&(t.value=e[n]):t[n]=e[n];return t}))},o=0;o0?requestAnimationFrame(t):void 0}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",(function(){Qe.suspendWhenDocumentHidden&&(Ge()?e=cancelAnimationFrame(e):(We.forEach((function(e){return e._onDocumentVisibility()})),ze()))})),function(){e||Ge()&&Qe.suspendWhenDocumentHidden||!(We.length>0)||(e=requestAnimationFrame(t))}}();function Ge(){return!!document&&document.hidden}function Qe(e){void 0===e&&(e={});var t,n=0,r=0,o=0,i=0,a=null;function s(e){var t=window.Promise&&new Promise((function(e){return a=e}));return e.finished=t,t}var l=function(e){var t=ge(G,e),n=ge(Q,e),r=Ue(n,e),o=Ne(e.targets),i=qe(o,r),a=Ye(i,n),s=je;return je++,me(t,{id:s,children:[],animatables:o,animations:i,duration:a.duration,delay:a.delay,endDelay:a.endDelay})}(e);function u(){var e=l.direction;"alternate"!==e&&(l.direction="normal"!==e?"normal":"reverse"),l.reversed=!l.reversed,t.forEach((function(e){return e.reversed=l.reversed}))}function c(e){return l.reversed?l.duration-e:e}function d(){n=0,r=c(l.currentTime)*(1/Qe.speed)}function f(e,t){t&&t.seek(e-t.timelineOffset)}function h(e){for(var t=0,n=l.animations,r=n.length;t2||(y=Math.round(y*h)/h)),p.push(y)}var E=f.length;if(E){m=f[0];for(var I=0;I0&&(l.began=!0,p("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,p("loopBegin")),v<=g&&0!==l.currentTime&&h(0),(v>=m&&l.currentTime!==d||!d)&&h(d),v>g&&v=d&&(r=0,l.remaining&&!0!==l.remaining&&l.remaining--,l.remaining?(n=o,p("loopComplete"),l.loopBegan=!1,"alternate"===l.direction&&u()):(l.paused=!0,l.completed||(l.completed=!0,p("loopComplete"),p("complete"),!l.passThrough&&"Promise"in window&&(a(),s(l)))))}return s(l),l.reset=function(){var e=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed="reverse"===e,l.remaining=l.loop,t=l.children;for(var n=i=t.length;n--;)l.children[n].reset();(l.reversed&&!0!==l.loop||"alternate"===e&&1===l.loop)&&l.remaining++,h(l.reversed?l.duration:0)},l._onDocumentVisibility=d,l.set=function(e,t){return Xe(e,t),l},l.tick=function(e){o=e,n||(n=o),g((o+(r-n))*Qe.speed)},l.seek=function(e){g(c(e))},l.pause=function(){l.paused=!0,d()},l.play=function(){l.paused&&(l.completed&&l.reset(),l.paused=!1,We.push(l),d(),ze())},l.reverse=function(){u(),l.completed=!l.reversed,d()},l.restart=function(){l.reset(),l.play()},l.remove=function(e){Je(Me(e),l)},l.reset(),l.autoplay&&l.play(),l}function Ve(e,t){for(var n=t.length;n--;)he(e,t[n].animatable.target)&&t.splice(n,1)}function Je(e,t){var n=t.animations,r=t.children;Ve(e,n);for(var o=r.length;o--;){var i=r[o],a=i.animations;Ve(e,a),a.length||i.children.length||r.splice(o,1)}n.length||r.length||t.pause()}Qe.version="3.2.1",Qe.speed=1,Qe.suspendWhenDocumentHidden=!0,Qe.running=We,Qe.remove=function(e){for(var t=Me(e),n=We.length;n--;){Je(t,We[n])}},Qe.get=xe,Qe.set=Xe,Qe.convertPx=Ee,Qe.path=function(e,t){var n=ee.str(e)?ue(e)[0]:e,r=t||100;return function(e){return{property:e,el:n,svg:Ce(n),totalLength:Ae(n)*(r/100)}}},Qe.setDashoffset=function(e){var t=Ae(e);return e.setAttribute("stroke-dasharray",t),t},Qe.stagger=function(e,t){void 0===t&&(t={});var n=t.direction||"normal",r=t.easing?le(t.easing):null,o=t.grid,i=t.axis,a=t.from||0,s="first"===a,l="center"===a,u="last"===a,c=ee.arr(e),d=c?parseFloat(e[0]):parseFloat(e),f=c?parseFloat(e[1]):0,h=ye(c?e[1]:e)||0,p=t.start||0+(c?d:0),g=[],m=0;return function(e,t,v){if(s&&(a=0),l&&(a=(v-1)/2),u&&(a=v-1),!g.length){for(var y=0;y-1&&We.splice(o,1);for(var s=0;s'].join(""),document.getElementById("featured-image-drop").innerHTML="",document.getElementById("featured-image-drop").appendChild(n)}}(n),o.readAsDataURL(n)}}}},{key:"handleImageUpload",value:function(e,t){var n=this;ot.alert("Uploading Image",null),(new P).imageUpload(e,t).then((function(e){"postImageAdded"==e.type&&n.editor.notify(M,e.url),ot.alert("Image Added to Entry",!0)})).catch((function(){ot.alert("Uh oh. Image not added",!1)}))}}]),t}();it.uploadFiles=[];var at=function(){function t(n){e(this,t),this.currentPage=null,this.choosePage(n),this.start()}return n(t,[{key:"start",value:function(){}},{key:"choosePage",value:function(e){switch(this.currentPage="",e){case"edit":case"add":this.currentPage=new it}}}]),t}(),st=function(){function t(){e(this,t)}return n(t,[{key:"getInfo",value:function(){var e,t,n=document.getElementById("settings-handle").value,r=document.getElementById("settings-email").value,o=document.getElementById("settings-url").value,i=document.getElementById("settings-title").value,a=document.getElementById("settings-desc").value,s=document.getElementById("background").src,l="",u=document.querySelectorAll(".theme-select"),c=document.getElementById("smtp-domain").value,d=document.getElementById("smtp-email").value,f=document.getElementById("smtp-pass").value,h=document.getElementById("mg-domain").value,p=document.getElementById("mg-key").value,g="",m=document.querySelectorAll(".mail-option"),v=document.getElementById("api-access-toggle").getAttribute("data-enabled");for(e=0,t=u.length;e0&&void 0!==arguments[0]?arguments[0]:null,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e(this,t),this.percentComplete=0,this.token=null,this.baseURL=null,this.key=null,o&&(this.key=o),r&&(this.baseURL=r),this._request(this.baseURL?this.baseURL+c+"?key="+this.key:c+"?key="+this.key).then((function(e){e.type===k&&(n.token=e.token)}))}return n(t,[{key:"login",value:function(e){var t=this;return new Promise((function(n,r){t.baseURL?e.remote=!0:e.remote=!1,t.key?e.key=t.key:e.key=null,t._request(t.baseURL?t.baseURL+m:m,"getAuthStatus",s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"syncSettings",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+d+"?key="+t.key:d+"?key="+t.key,v,s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"publishSite",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+f:f,y,s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"pageActions",value:function(e,t){var n,r,o,i=this;switch(e){case b:n="/api/v1/page/create",r=b,o=u;break;case w:n="/api/v1/page/write",r=w,o=u;break;case E:n="/api/v1/page/delete",r=E,o=l}return this.baseURL?(t.key=this.key,t.remote=!0):t.remote=!1,new Promise((function(e,a){i._request(i.baseURL?i.baseURL+n:n,r,s,o,t).then((function(t){e(t)})).catch((function(e){a(e)}))}))}},{key:"syncNav",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+h:h,v,s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"sendMail",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+g:g,"sendMail",s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"reindexPages",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+p:p,I,s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"_request",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"GET",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=this;return new Promise((function(a,c){var d=new XMLHttpRequest;if(d.upload.onprogress=i.handleLoadProgress,d.open(n,e,!0),d.onload=function(){if(200==d.status){var e=JSON.parse(d.response);a(e)}else{var t=JSON.parse(d.response);c(t)}},"PUT"==n||n==s)switch(t!==v&&t!==w&&t!==b&&t!==E&&t!==y&&t!==I||d.setRequestHeader("fipamo-access-token",i.token),r){case l:d.setRequestHeader("Content-type","application/"+r),d.send(JSON.stringify(o));break;case u:d.send(o)}else d.send()}))}},{key:"handleLoadProgress",value:function(e){this.percentComplete=Math.ceil(e.loaded/e.total*100)}}]),t}(),T="POST",x="json",D="x-www-form-urlencoded",P=function(){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e(this,t),this.baseURL=null,this.key=null,r&&(this.key=r),n&&(this.baseURL=n)}return n(t,[{key:"create",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/init","blogInit",T,x,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"restore",value:function(e){var t=this;return new Promise((function(n,r){var o;o=new FormData(e),t._request("/api/v1/restore","restoreBackup","POST","x-www-form-urlencoded",o).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"backup",value:function(){var e=this;return new Promise((function(t,n){var r;r={task:"create_backup"},e._request("/api/v1/backup","createBackup","POST","json",r).then((function(e){t(e)})).catch((function(e){n(e)}))}))}},{key:"secret",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/get-secret","retrieveSecret",T,x,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"newPass",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/reset-password","resetPassword",T,x,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"imageUpload",value:function(e,t){var n=this;return new Promise((function(r,o){var i="";switch(e){case"avatar-upload":i="/api/v1/settings/add-avatar";break;case"background-upload":i="/api/v1/settings/add-feature-background";break;default:i="/api/v1/page/add-entry-image"}var a=new FormData;n.baseURL?(a.append("key",n.key),a.append("remote",!0)):a.append("remote",!1);for(var s=0;s2&&void 0!==arguments[2]?arguments[2]:"GET",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:x,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=this;return new Promise((function(t,a){var s=new XMLHttpRequest;if(s.upload.onprogress=i.handleLoadProgress,s.open(n,e,!0),s.onload=function(){if(200==s.status){var e=JSON.parse(s.response);t(e)}else{var n=JSON.parse(s.response);a(n)}},"PUT"==n||n==T)switch(r){case x:s.setRequestHeader("Content-type","application/"+r),s.send(JSON.stringify(o));break;case D:s.send(o)}else s.send()}))}},{key:"handleLoadProgress",value:function(e){this.percentComplete=Math.ceil(e.loaded/e.total*100)}}]),t}(),_=function(){function t(){e(this,t)}return n(t,[{key:"imgLoad",value:function(e){return new Promise((function(t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){200===r.status?t(r.response):n(new Error("Image didn't load successfully; error code:"+r.statusText))},r.onerror=function(){n(new Error("There was a network error."))},r.send()}))}},{key:"loadImage",value:function(e){var t=this;return new Promise((function(n,r){(new Image).crossOrigin="",t.imgLoad(e).then((function(e){var t=window.URL.createObjectURL(e);n(t)}),(function(e){r(e)}))}))}},{key:"formDataToJSON",value:function(e){var t={};return new FormData(e).forEach((function(e,n){t.hasOwnProperty(n)?(Array.isArray(t[n])||(t[n]=[t[n]]),t[n].push(e)):t[n]=e})),t}}]),t}(),B="requestLame",A="postUpdated";new function t(){e(this,t)};var C=function(){function t(){e(this,t)}return n(t,[{key:"cleanString",value:function(e){return e.replace(/(^\-+|[^a-zA-Z0-9\/_| -]+|\-+$)/g,"").toLowerCase().replace(/[\/_| -]+/g,"-")}},{key:"decodeHTML",value:function(e,t){var n=0,r=0,o=!1;void 0===t&&(t=2),e=e.toString().replace(/</g,"<").replace(/>/g,">");var i={ENT_NOQUOTES:0,ENT_HTML_QUOTE_SINGLE:1,ENT_HTML_QUOTE_DOUBLE:2,ENT_COMPAT:2,ENT_QUOTES:3,ENT_IGNORE:4};if(0===t&&(o=!0),"number"!=typeof t){for(t=[].concat(t),r=0;r]*>/g,"\n"),r.append("id",document.getElementById("post-edit-index").getAttribute("data-index")),r.append("uuid",document.getElementById("post-edit-index").getAttribute("data-uuid")),r.append("layout",document.getElementById("post-edit-index").getAttribute("data-layout")),r.append("current_title",document.getElementById("post-edit-index").getAttribute("data-slug")),r.append("content",i),r.append("title",document.getElementById("post_title").value),r.append("created",document.getElementById("post-date").getAttribute("data-raw")),r.append("slug",(new C).cleanString(document.getElementById("post_title").value)),r.append("tags",document.getElementById("post_tags").value),r.append("menu",document.getElementById("option-menu-pin").getAttribute("data-active")),r.append("featured",document.getElementById("option-feature").getAttribute("data-active")),r.append("published",document.getElementById("option-published").getAttribute("data-active")),null!=e||null!=e)e.type.match("image.*")?r.append("feature_image",e,e.name):n("Not an image file");else if(document.getElementById("featured-image")){var a=document.getElementById("featured-image").src;null!=a||null!=a?r.append("feature_image",a):r.append("feature_image",null)}t(r)}))}}]),t}(),L="editorDelete",M="editorUploadImage",N="editorSave",R="editorUpdate";new function t(){e(this,t)};var U=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","boxSizing","fontFamily","fontSize","fontWeight","height","letterSpacing","lineHeight","marginBottom","marginLeft","marginRight","marginTop","outlineWidth","overflow","overflowX","overflowY","paddingBottom","paddingLeft","paddingRight","paddingTop","textAlign","textOverflow","textTransform","whiteSpace","wordBreak","wordWrap"],H=function(e,t){var n=document.createElement("div");return function(t){var r=function(){var t={position:"absolute",left:-9999,top:0,zIndex:-2e3};return"TEXTAREA"===e.tagName&&U.push("width"),U.forEach((function(n){t[n]=getComputedStyle(e)[n]})),t}();Object.keys(r).forEach((function(e){n.style[e]=r[e]})),n.innerHTML=t,e.parentNode.insertBefore(n,e.nextSibling)}(t),{rect:function(){var e=n.ownerDocument.getElementById("caret-position-marker"),t={left:e.offsetLeft,top:e.offsetTop,height:e.offsetHeight};return n.parentNode.removeChild(n),t}}};function F(e){return(F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var X=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.customPos,n=e.iframe,r=e.noShadowCaret;return n?{iframe:n,window:n.contentWindow,document:n.contentDocument||n.contentWindow.document,noShadowCaret:r,customPos:t}:{window:window,document:document,noShadowCaret:r,customPos:t}},q=function(e){return"object"===F(e)&&null!==e},Y=function(e,t){var n=function(){return e.selectionStart},r=function(r){var o=function(e){return e.replace(/<|>|`|"|&/g,"?").replace(/\r\n|\r|\n/g,"
")};(t.customPos||0===t.customPos)&&(r=t.customPos);var i=void 0===r?n():r,a=e.value.slice(0,i),s=e.value.slice(i),l=''.concat(o(a),"");l+='|',l+=''.concat(o(s),"");var u=H(e,l).rect();return u.pos=n(),u};return{getPos:n,setPos:function(t){return e.setSelectionRange(t,t),e},getOffset:function(n){var o=function(e,t){var n=t&&t.window||window,r=t&&t.document||document,o=e.getBoundingClientRect(),i=r.documentElement,a=n.pageXOffset||i.scrollLeft,s=n.pageYOffset||i.scrollTop;return{top:o.top+s,left:o.left+a}}(e),i=r(n);return{top:o.top+i.top+t.document.body.scrollTop,left:o.left+i.left+t.document.body.scrollLeft,height:i.height}},getPosition:r}},j=function(e,t){return function(e){return!!(e.contentEditable?"true"===e.contentEditable:"true"===e.getAttribute("contenteditable"))}(e)?function(e,t){var n=function(){var n=r(),o={height:0,left:0,right:0};if(!n)return o;var i=t.customPos||0===t.customPos;if(n.endOffset-1>0&&n.endContainer!==e||i){var a=n.cloneRange(),s=i?t.customPos:n.endOffset;a.setStart(n.endContainer,s-1<0?0:s-1),a.setEnd(n.endContainer,s);var l=a.getBoundingClientRect();o={height:l.height,left:l.left+l.width,top:l.top},a.detach()}if((!o||o&&0===o.height)&&!t.noShadowCaret){var u=n.cloneRange(),c=t.document.createTextNode("|");u.insertNode(c),u.selectNode(c);var d=u.getBoundingClientRect();o={height:d.height,left:d.left,top:d.top},c.parentNode.removeChild(c),u.detach()}if(o){var f=t.document.documentElement;o.top+=t.window.pageYOffset-(f.clientTop||0),o.left+=t.window.pageXOffset-(f.clientLeft||0)}return o},r=function(){if(t.window.getSelection){var e=t.window.getSelection();return e.rangeCount>0?e.getRangeAt(0):null}},o=function(){var t=r(),n=t.cloneRange();n.selectNodeContents(e),n.setEnd(t.endContainer,t.endOffset);var o=n.toString().length;return n.detach(),o};return{getPos:o,setPos:function(n){var r=t.window.getSelection();if(r){var o=0,i=!1;!function e(a,s){for(var l=0;l=a){i=!0;var c=t.document.createRange();c.setStart(u,a-o),r.removeAllRanges(),r.addRange(c);break}o+=u.length}else e(n,u)}}(n,e)}return e},getPosition:function(){var r=n(),i=o(),a=e.getBoundingClientRect(),s=a.top+t.document.body.scrollTop,l=a.left+t.document.body.scrollLeft;return r.left-=l,r.top-=s,r.pos=i,r},getOffset:n,getRange:r}}(e,t):Y(e,t)},W=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n;q(t)&&(r=t,t=null);var o=X(r),i=j(e,o);return t||0===t?i.setPos(t):i.getPosition()},z=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(i,t);var r=a(i);function i(t,n){var o;return e(this,i),(o=r.call(this)).textEditor=t,o.fixLimit=n,o.caretPos=null,o.url="",o.setInputs(),window.addEventListener("scroll",(function(){})),o.refresh(),o}return n(i,[{key:"setInputs",value:function(){for(var e=this,t=this,n=document.querySelectorAll(".editor-button"),r=0,o=n.length;r/g)>-1){var o=W(e.textEditor).pos;t.refresh(),W(e.textEditor,o)}}))}},{key:"refresh",value:function(){var e=this.textEditor.innerText;e=e.replace(new RegExp("\r?\n","g"),"
");var t=document.createElement("div");t.innerText=e,this.textEditor.innerHTML=t.innerText,this.textEditor.style.maxWidth="900px"}},{key:"notify",value:function(e,t){switch(e){case A:document.getElementById("submit-update").classList.add("icon-hide"),document.getElementById("submit-good").classList.remove("icon-hide"),document.getElementById("edit-update").classList.remove("submit-start"),document.getElementById("edit-update").classList.add("submit-cool"),setTimeout((function(){document.getElementById("submit-update").classList.remove("icon-hide"),document.getElementById("submit-good").classList.add("icon-hide"),document.getElementById("edit-update").classList.add("submit-start"),document.getElementById("edit-update").classList.remove("submit-cool")}),2e3);break;case"postAdded":break;case M:var n,r;W(this.textEditor,this.caretPos),(n=window.getSelection()).rangeCount&&((r=n.getRangeAt(0)).deleteContents(),r.insertNode(document.createTextNode("![image alt text]("+t+" 'image title')"))),this.refresh()}}},{key:"handleEditorOption",value:function(e){var t,n,r;if(e.preventDefault(),(t=window.getSelection()).rangeCount)switch(n=t.getRangeAt(0),r=t.getRangeAt(0).toString(),n.deleteContents(),e.target.id){case"edit-bold":n.insertNode(document.createTextNode("**"+r+"**"));break;case"edit-italic":n.insertNode(document.createTextNode("*"+r+"*"));break;case"edit-strikethrough":n.insertNode(document.createTextNode(""+r+""));break;case"edit-header1":n.insertNode(document.createTextNode("# "+r));break;case"edit-header2":n.insertNode(document.createTextNode("## "+r));break;case"edit-header3":n.insertNode(document.createTextNode("### "+r));break;case"edit-image":this.caretPos=W(this.textEditor).pos,this.emitEvent(M);break;case"submit-save":case"edit-save":this.emitEvent(N);break;case"submit-update":case"edit-update":this.emitEvent(R);break;case"edit-link":n.insertNode(document.createTextNode("["+r+"](PASTE URL HERE)"));break;case"edit-delete":this.emitEvent(L)}this.refresh()}}]),i}(function(){function t(){e(this,t),this.listeners=new Map}return n(t,[{key:"addListener",value:function(e,t){this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t)}},{key:"removeListener",value:function(e,t){var n,r=this.listeners.get(e);return!!(r&&r.length&&(n=r.reduce((function(e,n,r){return"function"==typeof n&&n===t?e=r:e}),-1))>-1)&&(r.splice(n,1),this.listeners.set(e,r),!0)}},{key:"emitEvent",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r-1}function K(e,t){return e.apply(null,t)}var ee={arr:function(e){return Array.isArray(e)},obj:function(e){return Z(Object.prototype.toString.call(e),"Object")},pth:function(e){return ee.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return e.nodeType||ee.svg(e)},str:function(e){return"string"==typeof e},fnc:function(e){return"function"==typeof e},und:function(e){return void 0===e},nil:function(e){return ee.und(e)||null===e},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return ee.hex(e)||ee.rgb(e)||ee.hsl(e)},key:function(e){return!G.hasOwnProperty(e)&&!Q.hasOwnProperty(e)&&"targets"!==e&&"keyframes"!==e}};function te(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map((function(e){return parseFloat(e)})):[]}function ne(e,t){var n=te(e),r=$(ee.und(n[0])?1:n[0],.1,100),o=$(ee.und(n[1])?100:n[1],.1,100),i=$(ee.und(n[2])?10:n[2],.1,100),a=$(ee.und(n[3])?0:n[3],.1,100),s=Math.sqrt(o/r),l=i/(2*Math.sqrt(o*r)),u=l<1?s*Math.sqrt(1-l*l):0,c=l<1?(l*s-a)/u:-a+s;function d(e){var n=t?t*e/1e3:e;return n=l<1?Math.exp(-n*l*s)*(1*Math.cos(u*n)+c*Math.sin(u*n)):(1+c*n)*Math.exp(-n*s),0===e||1===e?e:1-n}return t?d:function(){var t=J.springs[e];if(t)return t;for(var n=1/6,r=0,o=0;;)if(1===d(r+=n)){if(++o>=16)break}else o=0;var i=r*n*1e3;return J.springs[e]=i,i}}function re(e){return void 0===e&&(e=10),function(t){return Math.ceil($(t,1e-6,1)*e)*(1/e)}}var oe,ie,ae=function(){var e=.1;function t(e,t){return 1-3*t+3*e}function n(e,t){return 3*t-6*e}function r(e){return 3*e}function o(e,o,i){return((t(o,i)*e+n(o,i))*e+r(o))*e}function i(e,o,i){return 3*t(o,i)*e*e+2*n(o,i)*e+r(o)}return function(t,n,r,a){if(0<=t&&t<=1&&0<=r&&r<=1){var s=new Float32Array(11);if(t!==n||r!==a)for(var l=0;l<11;++l)s[l]=o(l*e,t,r);return function(e){return t===n&&r===a||0===e||1===e?e:o(u(e),n,a)}}function u(n){for(var a=0,l=1;10!==l&&s[l]<=n;++l)a+=e;--l;var u=a+(n-s[l])/(s[l+1]-s[l])*e,c=i(u,t,r);return c>=.001?function(e,t,n,r){for(var a=0;a<4;++a){var s=i(t,n,r);if(0===s)return t;t-=(o(t,n,r)-e)/s}return t}(n,u,t,r):0===c?u:function(e,t,n,r,i){var a,s,l=0;do{(a=o(s=t+(n-t)/2,r,i)-e)>0?n=s:t=s}while(Math.abs(a)>1e-7&&++l<10);return s}(n,a,a+e,t,r)}}}(),se=(oe={linear:function(){return function(e){return e}}},ie={Sine:function(){return function(e){return 1-Math.cos(e*Math.PI/2)}},Circ:function(){return function(e){return 1-Math.sqrt(1-e*e)}},Back:function(){return function(e){return e*e*(3*e-2)}},Bounce:function(){return function(e){for(var t,n=4;e<((t=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*t-2)/22-e,2)}},Elastic:function(e,t){void 0===e&&(e=1),void 0===t&&(t=.5);var n=$(e,1,10),r=$(t,.1,2);return function(e){return 0===e||1===e?e:-n*Math.pow(2,10*(e-1))*Math.sin((e-1-r/(2*Math.PI)*Math.asin(1/n))*(2*Math.PI)/r)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach((function(e,t){ie[e]=function(){return function(e){return Math.pow(e,t+2)}}})),Object.keys(ie).forEach((function(e){var t=ie[e];oe["easeIn"+e]=t,oe["easeOut"+e]=function(e,n){return function(r){return 1-t(e,n)(1-r)}},oe["easeInOut"+e]=function(e,n){return function(r){return r<.5?t(e,n)(2*r)/2:1-t(e,n)(-2*r+2)/2}},oe["easeOutIn"+e]=function(e,n){return function(r){return r<.5?(1-t(e,n)(1-2*r))/2:(t(e,n)(2*r-1)+1)/2}}})),oe);function le(e,t){if(ee.fnc(e))return e;var n=e.split("(")[0],r=se[n],o=te(e);switch(n){case"spring":return ne(e,t);case"cubicBezier":return K(ae,o);case"steps":return K(re,o);default:return K(r,o)}}function ue(e){try{return document.querySelectorAll(e)}catch(e){return}}function ce(e,t){for(var n=e.length,r=arguments.length>=2?t:void 0,o=[],i=0;i1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(0==a)t=n=r=s;else{var c=s<.5?s*(1+a):s+a-s*a,d=2*s-c;t=u(d,c,i+1/3),n=u(d,c,i),r=u(d,c,i-1/3)}return"rgba("+255*t+","+255*n+","+255*r+","+l+")"}(e):void 0;var t,n}function ye(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function be(e,t){return ee.fnc(e)?e(t.target,t.id,t.total):e}function we(e,t){return e.getAttribute(t)}function Ee(e,t,n){if(he([n,"deg","rad","turn"],ye(t)))return t;var r=J.CSS[t+n];if(!ee.und(r))return r;var o=document.createElement(e.tagName),i=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;i.appendChild(o),o.style.position="absolute",o.style.width=100+n;var a=100/o.offsetWidth;i.removeChild(o);var s=a*parseFloat(t);return J.CSS[t+n]=s,s}function Ie(e,t,n){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return n?Ee(e,o,n):o}}function ke(e,t){return ee.dom(e)&&!ee.inp(e)&&(!ee.nil(we(e,t))||ee.svg(e)&&e[t])?"attribute":ee.dom(e)&&he(V,t)?"transform":ee.dom(e)&&"transform"!==t&&Ie(e,t)?"css":null!=e[t]?"object":void 0}function Se(e){if(ee.dom(e)){for(var t,n=e.style.transform||"",r=/(\w+)\(([^)]*)\)/g,o=new Map;t=r.exec(n);)o.set(t[1],t[2]);return o}}function Te(e,t,n,r){var o=Z(t,"scale")?1:0+function(e){return Z(e,"translate")||"perspective"===e?"px":Z(e,"rotate")||Z(e,"skew")?"deg":void 0}(t),i=Se(e).get(t)||o;return n&&(n.transforms.list.set(t,i),n.transforms.last=t),r?Ee(e,i,r):i}function xe(e,t,n,r){switch(ke(e,t)){case"transform":return Te(e,t,r,n);case"css":return Ie(e,t,n);case"attribute":return we(e,t);default:return e[t]||0}}function De(e,t){var n=/^(\*=|\+=|-=)/.exec(e);if(!n)return e;var r=ye(e)||0,o=parseFloat(t),i=parseFloat(e.replace(n[0],""));switch(n[0][0]){case"+":return o+i+r;case"-":return o-i+r;case"*":return o*i+r}}function Pe(e,t){if(ee.col(e))return ve(e);if(/\s/g.test(e))return e;var n=ye(e),r=n?e.substr(0,e.length-n.length):e;return t?r+t:r}function _e(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Be(e){for(var t,n=e.points,r=0,o=0;o0&&(r+=_e(t,i)),t=i}return r}function Ae(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return function(e){return 2*Math.PI*we(e,"r")}(e);case"rect":return function(e){return 2*we(e,"width")+2*we(e,"height")}(e);case"line":return function(e){return _e({x:we(e,"x1"),y:we(e,"y1")},{x:we(e,"x2"),y:we(e,"y2")})}(e);case"polyline":return Be(e);case"polygon":return function(e){var t=e.points;return Be(e)+_e(t.getItem(t.numberOfItems-1),t.getItem(0))}(e)}}function Ce(e,t){var n=t||{},r=n.el||function(e){for(var t=e.parentNode;ee.svg(t)&&ee.svg(t.parentNode);)t=t.parentNode;return t}(e),o=r.getBoundingClientRect(),i=we(r,"viewBox"),a=o.width,s=o.height,l=n.viewBox||(i?i.split(" "):[0,0,a,s]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:a,h:s,vW:l[2],vH:l[3]}}function Oe(e,t,n){function r(n){void 0===n&&(n=0);var r=t+n>=1?t+n:0;return e.el.getPointAtLength(r)}var o=Ce(e.el,e.svg),i=r(),a=r(-1),s=r(1),l=n?1:o.w/o.vW,u=n?1:o.h/o.vH;switch(e.property){case"x":return(i.x-o.x)*l;case"y":return(i.y-o.y)*u;case"angle":return 180*Math.atan2(s.y-a.y,s.x-a.x)/Math.PI}}function Le(e,t){var n=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=Pe(ee.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(n)?r.match(n).map(Number):[0],strings:ee.str(e)||t?r.split(n):[]}}function Me(e){return ce(e?de(ee.arr(e)?e.map(fe):fe(e)):[],(function(e,t,n){return n.indexOf(e)===t}))}function Ne(e){var t=Me(e);return t.map((function(e,n){return{target:e,id:n,total:t.length,transforms:{list:Se(e)}}}))}function Re(e,t){var n=pe(t);if(/^spring/.test(n.easing)&&(n.duration=ne(n.easing)),ee.arr(e)){var r=e.length;2===r&&!ee.obj(e[0])?e={value:e}:ee.fnc(t.duration)||(n.duration=t.duration/r)}var o=ee.arr(e)?e:[e];return o.map((function(e,n){var r=ee.obj(e)&&!ee.pth(e)?e:{value:e};return ee.und(r.delay)&&(r.delay=n?0:t.delay),ee.und(r.endDelay)&&(r.endDelay=n===o.length-1?t.endDelay:0),r})).map((function(e){return me(e,n)}))}function Ue(e,t){var n=[],r=t.keyframes;for(var o in r&&(t=me(function(e){for(var t=ce(de(e.map((function(e){return Object.keys(e)}))),(function(e){return ee.key(e)})).reduce((function(e,t){return e.indexOf(t)<0&&e.push(t),e}),[]),n={},r=function(r){var o=t[r];n[o]=e.map((function(e){var t={};for(var n in e)ee.key(n)?n==o&&(t.value=e[n]):t[n]=e[n];return t}))},o=0;o0?requestAnimationFrame(t):void 0}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",(function(){Qe.suspendWhenDocumentHidden&&(Ge()?e=cancelAnimationFrame(e):(We.forEach((function(e){return e._onDocumentVisibility()})),ze()))})),function(){e||Ge()&&Qe.suspendWhenDocumentHidden||!(We.length>0)||(e=requestAnimationFrame(t))}}();function Ge(){return!!document&&document.hidden}function Qe(e){void 0===e&&(e={});var t,n=0,r=0,o=0,i=0,a=null;function s(e){var t=window.Promise&&new Promise((function(e){return a=e}));return e.finished=t,t}var l=function(e){var t=ge(G,e),n=ge(Q,e),r=Ue(n,e),o=Ne(e.targets),i=qe(o,r),a=Ye(i,n),s=je;return je++,me(t,{id:s,children:[],animatables:o,animations:i,duration:a.duration,delay:a.delay,endDelay:a.endDelay})}(e);function u(){var e=l.direction;"alternate"!==e&&(l.direction="normal"!==e?"normal":"reverse"),l.reversed=!l.reversed,t.forEach((function(e){return e.reversed=l.reversed}))}function c(e){return l.reversed?l.duration-e:e}function d(){n=0,r=c(l.currentTime)*(1/Qe.speed)}function f(e,t){t&&t.seek(e-t.timelineOffset)}function h(e){for(var t=0,n=l.animations,r=n.length;t2||(y=Math.round(y*h)/h)),p.push(y)}var E=f.length;if(E){m=f[0];for(var I=0;I0&&(l.began=!0,p("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,p("loopBegin")),v<=g&&0!==l.currentTime&&h(0),(v>=m&&l.currentTime!==d||!d)&&h(d),v>g&&v=d&&(r=0,l.remaining&&!0!==l.remaining&&l.remaining--,l.remaining?(n=o,p("loopComplete"),l.loopBegan=!1,"alternate"===l.direction&&u()):(l.paused=!0,l.completed||(l.completed=!0,p("loopComplete"),p("complete"),!l.passThrough&&"Promise"in window&&(a(),s(l)))))}return s(l),l.reset=function(){var e=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed="reverse"===e,l.remaining=l.loop,t=l.children;for(var n=i=t.length;n--;)l.children[n].reset();(l.reversed&&!0!==l.loop||"alternate"===e&&1===l.loop)&&l.remaining++,h(l.reversed?l.duration:0)},l._onDocumentVisibility=d,l.set=function(e,t){return Xe(e,t),l},l.tick=function(e){o=e,n||(n=o),g((o+(r-n))*Qe.speed)},l.seek=function(e){g(c(e))},l.pause=function(){l.paused=!0,d()},l.play=function(){l.paused&&(l.completed&&l.reset(),l.paused=!1,We.push(l),d(),ze())},l.reverse=function(){u(),l.completed=!l.reversed,d()},l.restart=function(){l.reset(),l.play()},l.remove=function(e){Je(Me(e),l)},l.reset(),l.autoplay&&l.play(),l}function Ve(e,t){for(var n=t.length;n--;)he(e,t[n].animatable.target)&&t.splice(n,1)}function Je(e,t){var n=t.animations,r=t.children;Ve(e,n);for(var o=r.length;o--;){var i=r[o],a=i.animations;Ve(e,a),a.length||i.children.length||r.splice(o,1)}n.length||r.length||t.pause()}Qe.version="3.2.1",Qe.speed=1,Qe.suspendWhenDocumentHidden=!0,Qe.running=We,Qe.remove=function(e){for(var t=Me(e),n=We.length;n--;){Je(t,We[n])}},Qe.get=xe,Qe.set=Xe,Qe.convertPx=Ee,Qe.path=function(e,t){var n=ee.str(e)?ue(e)[0]:e,r=t||100;return function(e){return{property:e,el:n,svg:Ce(n),totalLength:Ae(n)*(r/100)}}},Qe.setDashoffset=function(e){var t=Ae(e);return e.setAttribute("stroke-dasharray",t),t},Qe.stagger=function(e,t){void 0===t&&(t={});var n=t.direction||"normal",r=t.easing?le(t.easing):null,o=t.grid,i=t.axis,a=t.from||0,s="first"===a,l="center"===a,u="last"===a,c=ee.arr(e),d=c?parseFloat(e[0]):parseFloat(e),f=c?parseFloat(e[1]):0,h=ye(c?e[1]:e)||0,p=t.start||0+(c?d:0),g=[],m=0;return function(e,t,v){if(s&&(a=0),l&&(a=(v-1)/2),u&&(a=v-1),!g.length){for(var y=0;y-1&&We.splice(o,1);for(var s=0;s'].join(""),document.getElementById("featured-image-drop").innerHTML="",document.getElementById("featured-image-drop").appendChild(n)}}(n),o.readAsDataURL(n)}}}},{key:"handleImageUpload",value:function(e,t){var n=this;ot.alert("Uploading Image",null),(new P).imageUpload(e,t).then((function(e){"postImageAdded"==e.type&&n.editor.notify(M,e.url),ot.alert("Image Added to Entry",!0)})).catch((function(){ot.alert("Uh oh. Image not added",!1)}))}}]),t}();it.uploadFiles=[];var at=function(){function t(n){e(this,t),this.currentPage=null,this.choosePage(n),this.start()}return n(t,[{key:"start",value:function(){}},{key:"choosePage",value:function(e){switch(this.currentPage="",e){case"edit":case"add":this.currentPage=new it}}}]),t}(),st=function(){function t(){e(this,t)}return n(t,[{key:"getInfo",value:function(){var e,t,n=document.getElementById("settings-handle").value,r=document.getElementById("settings-email").value,o=document.getElementById("settings-url").value,i=document.getElementById("settings-title").value,a=document.getElementById("settings-desc").value,s=document.getElementById("background").src,l="",u=document.querySelectorAll(".theme-select"),c=document.getElementById("smtp-domain").value,d=document.getElementById("smtp-email").value,f=document.getElementById("smtp-pass").value,h=document.getElementById("mg-domain").value,p=document.getElementById("mg-key").value,g="",m=document.querySelectorAll(".mail-option"),v=document.getElementById("api-access-toggle").getAttribute("data-enabled");for(e=0,t=u.length;e diff --git a/src/com/actions/PageActions.js b/src/com/actions/PageActions.js index 4eafca9..7c4a640 100644 --- a/src/com/actions/PageActions.js +++ b/src/com/actions/PageActions.js @@ -1,77 +1,83 @@ -import StringUtils from '../utils/StringUtils'; +import StringUtils from "../utils/StringUtils"; export default class PostActions { - //-------------------------- - // constructor - //-------------------------- - constructor() {} - //-------------------------- - // methods - //-------------------------- - collectInfo(image) { - return new Promise((resolve, reject) => { - let pageInfo = new FormData(); - let txt = document.createElement('textarea'); - txt.innerHTML = document.getElementById('edit-post-text').innerHTML; - let html = txt.value; - //html = html.replace(/<\/?span[^>]*>/g, ''); //removes highightjs styling - html = html.replace(/<\/?br[^>]*>/g, '\n'); //convert back to encoded line break for storage - pageInfo.append( - 'id', - document.getElementById('post-edit-index').getAttribute('data-index') - ); - pageInfo.append( - 'uuid', - document.getElementById('post-edit-index').getAttribute('data-uuid') - ); - pageInfo.append( - 'layout', - document.getElementById('post-edit-index').getAttribute('data-layout') - ); - pageInfo.append( - 'current_title', - document.getElementById('post-edit-index').getAttribute('data-slug') - ); - pageInfo.append('content', html); - pageInfo.append('title', document.getElementById('post_title').value); - pageInfo.append( - 'created', - document.getElementById('post-date').getAttribute('data-raw') - ); - pageInfo.append( - 'slug', - new StringUtils().cleanString(document.getElementById('post_title').value) - ); - pageInfo.append('tags', document.getElementById('post_tags').value); - pageInfo.append( - 'menu', - document.getElementById('option-menu-pin').getAttribute('data-active') - ); - pageInfo.append( - 'featured', - document.getElementById('option-feature').getAttribute('data-active') - ); - pageInfo.append( - 'published', - document.getElementById('option-published').getAttribute('data-active') - ); - if (image != null || image != undefined) { - if (image.type.match('image.*')) { - pageInfo.append('feature_image', image, image.name); - } else { - reject('Not an image file'); - } - } else { - //check to see if image exists - var imageURL = document.getElementById('featured-image').src; - imageURL != null || imageURL != undefined - ? pageInfo.append('feature_image', imageURL) - : pageInfo.append('feature_image', null); - } + //-------------------------- + // constructor + //-------------------------- + constructor() {} + //-------------------------- + // methods + //-------------------------- + collectInfo(image) { + return new Promise((resolve, reject) => { + let pageInfo = new FormData(); + let txt = document.createElement("textarea"); + txt.innerHTML = document.getElementById("edit-post-text").innerHTML; + let html = txt.value; + //html = html.replace(/<\/?span[^>]*>/g, ''); //removes highightjs styling + html = html.replace(/<\/?br[^>]*>/g, "\n"); //convert back to encoded line break for storage + pageInfo.append( + "id", + document.getElementById("post-edit-index").getAttribute("data-index") + ); + pageInfo.append( + "uuid", + document.getElementById("post-edit-index").getAttribute("data-uuid") + ); + pageInfo.append( + "layout", + document.getElementById("post-edit-index").getAttribute("data-layout") + ); + pageInfo.append( + "current_title", + document.getElementById("post-edit-index").getAttribute("data-slug") + ); + pageInfo.append("content", html); + pageInfo.append("title", document.getElementById("post_title").value); + pageInfo.append( + "created", + document.getElementById("post-date").getAttribute("data-raw") + ); + pageInfo.append( + "slug", + new StringUtils().cleanString( + document.getElementById("post_title").value + ) + ); + pageInfo.append("tags", document.getElementById("post_tags").value); + pageInfo.append( + "menu", + document.getElementById("option-menu-pin").getAttribute("data-active") + ); + pageInfo.append( + "featured", + document.getElementById("option-feature").getAttribute("data-active") + ); + pageInfo.append( + "published", + document.getElementById("option-published").getAttribute("data-active") + ); + if (image != null || image != undefined) { + if (image.type.match("image.*")) { + pageInfo.append("feature_image", image, image.name); + } else { + reject("Not an image file"); + } + } else { + //check to see if image exists + if (document.getElementById("featured-image")) { + var imageURL = document.getElementById("featured-image").src; + imageURL != null || imageURL != undefined + ? pageInfo.append("feature_image", imageURL) + : pageInfo.append("feature_image", null); + } else { + //pageInfo.append("feature_image", null); + } + } - resolve(pageInfo); - }); - } - //-------------------------- - // event handlers - //-------------------------- + resolve(pageInfo); + }); + } + //-------------------------- + // event handlers + //-------------------------- } diff --git a/src/libraries/FipamoAdminAPI.js b/src/libraries/FipamoAdminAPI.js index 69fe685..90f8774 100644 --- a/src/libraries/FipamoAdminAPI.js +++ b/src/libraries/FipamoAdminAPI.js @@ -313,6 +313,7 @@ class FipamoAdminAPI { if ( eventType === TASK_SETTINGS_WRITE || eventType === TASK_PAGE_EDIT || + eventType === TASK_PAGE_CREATE || eventType === TASK_PAGE_DELETE || eventType === TASK_PUBLISH_SITE || eventType === TASK_REINDEX_PAGE