Changeset 3422142
- Timestamp:
- 12/17/2025 05:28:41 PM (4 months ago)
- Location:
- groundhogg
- Files:
-
- 50 edited
- 1 copied
-
tags/4.2.10 (copied) (copied from groundhogg/trunk)
-
tags/4.2.10/README.txt (modified) (2 diffs)
-
tags/4.2.10/assets/js/admin/components.js (modified) (2 diffs)
-
tags/4.2.10/assets/js/admin/components.min.js (modified) (1 diff)
-
tags/4.2.10/assets/js/admin/element.min.js (modified) (12 diffs)
-
tags/4.2.10/assets/js/admin/filters/contacts.js (modified) (1 diff)
-
tags/4.2.10/assets/js/admin/filters/contacts.min.js (modified) (1 diff)
-
tags/4.2.10/assets/js/admin/formatting.js (modified) (1 diff)
-
tags/4.2.10/assets/js/admin/formatting.min.js (modified) (1 diff)
-
tags/4.2.10/assets/js/admin/make-el.js (modified) (1 diff)
-
tags/4.2.10/assets/js/admin/make-el.min.js (modified) (1 diff)
-
tags/4.2.10/blocks/gutenberg/build/index.js (modified) (1 diff)
-
tags/4.2.10/blocks/gutenberg/build/index.js.map (modified) (1 diff)
-
tags/4.2.10/db/tag-relationships.php (modified) (4 diffs)
-
tags/4.2.10/groundhogg.php (modified) (2 diffs)
-
tags/4.2.10/includes/better-meta-compat.php (modified) (1 diff)
-
tags/4.2.10/includes/classes/contact.php (modified) (6 diffs)
-
tags/4.2.10/includes/classes/event.php (modified) (2 diffs)
-
tags/4.2.10/includes/classes/step.php (modified) (1 diff)
-
tags/4.2.10/includes/functions.php (modified) (1 diff)
-
tags/4.2.10/includes/main-updater.php (modified) (1 diff)
-
tags/4.2.10/includes/steps/premium/actions/advanced-timer.php (modified) (1 diff)
-
tags/4.2.10/includes/utils/date-time-helper.php (modified) (1 diff)
-
tags/4.2.10/templates/archive/campaign.php (modified) (1 diff)
-
tags/4.2.10/templates/archive/campaigns.php (modified) (1 diff)
-
tags/4.2.10/templates/archive/events.php (modified) (2 diffs)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/assets/js/admin/components.js (modified) (2 diffs)
-
trunk/assets/js/admin/components.min.js (modified) (1 diff)
-
trunk/assets/js/admin/element.min.js (modified) (12 diffs)
-
trunk/assets/js/admin/filters/contacts.js (modified) (1 diff)
-
trunk/assets/js/admin/filters/contacts.min.js (modified) (1 diff)
-
trunk/assets/js/admin/formatting.js (modified) (1 diff)
-
trunk/assets/js/admin/formatting.min.js (modified) (1 diff)
-
trunk/assets/js/admin/make-el.js (modified) (1 diff)
-
trunk/assets/js/admin/make-el.min.js (modified) (1 diff)
-
trunk/blocks/gutenberg/build/index.js (modified) (1 diff)
-
trunk/blocks/gutenberg/build/index.js.map (modified) (1 diff)
-
trunk/db/tag-relationships.php (modified) (4 diffs)
-
trunk/groundhogg.php (modified) (2 diffs)
-
trunk/includes/better-meta-compat.php (modified) (1 diff)
-
trunk/includes/classes/contact.php (modified) (6 diffs)
-
trunk/includes/classes/event.php (modified) (2 diffs)
-
trunk/includes/classes/step.php (modified) (1 diff)
-
trunk/includes/functions.php (modified) (1 diff)
-
trunk/includes/main-updater.php (modified) (1 diff)
-
trunk/includes/steps/premium/actions/advanced-timer.php (modified) (1 diff)
-
trunk/includes/utils/date-time-helper.php (modified) (1 diff)
-
trunk/templates/archive/campaign.php (modified) (1 diff)
-
trunk/templates/archive/campaigns.php (modified) (1 diff)
-
trunk/templates/archive/events.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
groundhogg/tags/4.2.10/README.txt
r3400645 r3422142 5 5 Donate link: https://www.groundhogg.io/pricing/ 6 6 Requires at least: 5.9 7 Tested up to: 6. 87 Tested up to: 6.9 8 8 Requires PHP: 7.1 9 Stable tag: 4.2. 99 Stable tag: 4.2.10 10 10 License: GPLv3 11 11 License URI: https://www.gnu.org/licenses/gpl.md … … 378 378 379 379 == Changelog == 380 381 = 4.2.10 (2025-12-12) = 382 * ADDED Start tracking the date when a tag is added to a contact. *Not* retroactive. 383 * ADDED Developer filters to modify queries for the email archive. 384 * FIXED UI issue in The Flow History filter. 385 * FIXED Form selection in the Form Block not working unless a form was already selected. 386 * FIXED Description formatting for the Advanced Timer action. 387 * FIXED PHP Notice if a custom field tab was not configured correctly. 380 388 381 389 = 4.2.9 (2025-11-21) = -
groundhogg/tags/4.2.10/assets/js/admin/components.js
r3400645 r3422142 124 124 removeTags = [], 125 125 addTags = [], 126 dates = {}, 126 127 onChange = (changes) => { 127 128 … … 139 140 ${ selected.map(tag => `<span class="gh-tag${ removeTags.includes(tag.ID) 140 141 ? ' remove' 141 : '' }">${ tag.data.tag_name } <span data-id="${ tag.ID }" class="remove-tag dashicons dashicons-no-alt"></span></span>`).142 : '' }">${ tag.data.tag_name } ${dates.hasOwnProperty(tag.ID) ? `<span class="gh-tooltip top">${dates[tag.ID]}</span>` : ''}<span data-id="${ tag.ID }" class="remove-tag dashicons dashicons-no-alt"></span></span>`). 142 143 join('') } 143 144 ${ addTags.map(id => TagsStore.get(id)). -
groundhogg/tags/4.2.10/assets/js/admin/components.min.js
r3400645 r3422142 1 ($=>{const{modal,errorDialog,loadingDots,select,uuid,addMediaToBasicTinyMCE,specialChars,tinymceElement,searchOptionsWidget,input,isNumeric,icons,dialog,tooltip,regexp,isValidEmail,loadingModal,textarea,spinner,skeleton,adminPageURL}=Groundhogg.element;const{Div,H2,H4,Toggle,Img,An,Span,ModalFrame,Iframe,makeEl,Button,Modal,ModalWithHeader,Dashicon,ToolTip,Input,TinyMCE,Label,Fragment,ItemPicker,Skeleton,Pg,Form,Textarea,InputGroup}=MakeEl;const{contacts:ContactsStore,tags:TagsStore,forms:FormsStore,emails:EmailsStore}=Groundhogg.stores;const{post,routes,postFormData}=Groundhogg.api;const{tagPicker}=Groundhogg.pickers;const{userHasCap,getOwner}=Groundhogg.user;const{sprintf,__,_x,_n}=wp.i18n;const{formatDateTime}=Groundhogg.formatting;const{currentUser}=Groundhogg;const{maybeCall,debounce,jsonCopy}=Groundhogg.functions;const selectContactModal=({onSelect=()=>{},onClose=()=>{},exclude=[]})=>{Modal({dialogClasses:"no-padding",width:"400px",onOpen:e=>{document.getElementById("quick-search-input").focus()}},({close})=>QuickSearch({itemProps:contact=>({onClick:e=>{onSelect(contact);close()}}),queryOverrides:{limit:15,exclude:exclude}}))};const betterTagPicker=(el,{selected=[],removeTags=[],addTags=[], onChange=changes=>{}})=>{const $el=$(el);let timeout;const template=()=>{return`1 ($=>{const{modal,errorDialog,loadingDots,select,uuid,addMediaToBasicTinyMCE,specialChars,tinymceElement,searchOptionsWidget,input,isNumeric,icons,dialog,tooltip,regexp,isValidEmail,loadingModal,textarea,spinner,skeleton,adminPageURL}=Groundhogg.element;const{Div,H2,H4,Toggle,Img,An,Span,ModalFrame,Iframe,makeEl,Button,Modal,ModalWithHeader,Dashicon,ToolTip,Input,TinyMCE,Label,Fragment,ItemPicker,Skeleton,Pg,Form,Textarea,InputGroup}=MakeEl;const{contacts:ContactsStore,tags:TagsStore,forms:FormsStore,emails:EmailsStore}=Groundhogg.stores;const{post,routes,postFormData}=Groundhogg.api;const{tagPicker}=Groundhogg.pickers;const{userHasCap,getOwner}=Groundhogg.user;const{sprintf,__,_x,_n}=wp.i18n;const{formatDateTime}=Groundhogg.formatting;const{currentUser}=Groundhogg;const{maybeCall,debounce,jsonCopy}=Groundhogg.functions;const selectContactModal=({onSelect=()=>{},onClose=()=>{},exclude=[]})=>{Modal({dialogClasses:"no-padding",width:"400px",onOpen:e=>{document.getElementById("quick-search-input").focus()}},({close})=>QuickSearch({itemProps:contact=>({onClick:e=>{onSelect(contact);close()}}),queryOverrides:{limit:15,exclude:exclude}}))};const betterTagPicker=(el,{selected=[],removeTags=[],addTags=[],dates={},onChange=changes=>{}})=>{const $el=$(el);let timeout;const template=()=>{return` 2 2 <div class="gh-tags"> 3 ${selected.map(tag=>`<span class="gh-tag${removeTags.includes(tag.ID)?" remove":""}">${tag.data.tag_name} <span data-id="${tag.ID}" class="remove-tag dashicons dashicons-no-alt"></span></span>`).join("")}3 ${selected.map(tag=>`<span class="gh-tag${removeTags.includes(tag.ID)?" remove":""}">${tag.data.tag_name} ${dates.hasOwnProperty(tag.ID)?`<span class="gh-tooltip top">${dates[tag.ID]}</span>`:""}<span data-id="${tag.ID}" class="remove-tag dashicons dashicons-no-alt"></span></span>`).join("")} 4 4 ${addTags.map(id=>TagsStore.get(id)).map(tag=>`<span class="gh-tag adding">${tag.data.tag_name} <span data-id="${tag.ID}" class="remove-adding-tag dashicons dashicons-no-alt"></span></span>`).join("")} 5 5 <button class="add-tag"> -
groundhogg/tags/4.2.10/assets/js/admin/element.min.js
r3343709 r3422142 1 (function($){var $doc=$(document);const{sprintf,__,_x,_n}=wp.i18n;function insertAtCursor(field,value){if(document.selection){field.focus();var sel=document.selection.createRange();sel.text=value}else if(field.selectionStart||field.selectionStart=="0"){var startPos=field.selectionStart;var endPos=field.selectionEnd;field.value=field.value.substring(0,startPos)+value+field.value.substring(endPos,field.value.length);field.selectionStart=startPos+value.length;field.selectionEnd=startPos+value.length}else{field.value+=value}let input=new Event("input");let change=new Event("change");field.dispatchEvent(input);field.dispatchEvent(change)}const Insert={active:null,text:"",to_mce:false,init:function(){var self=this;$doc.on("ghClearInsertTarget",function(){self.to_mce=false;self.active=false});$doc.on("to_mce",function(){self.to_mce=true;$doc.trigger("ghInsertTargetChanged")});$doc.on("focus","input:not(.no-insert), textarea:not(.no-insert)",function(){self.active=this;self.to_mce=false;$doc.trigger("ghInsertTargetChanged")})},setActive(el){this.active=el},inserting(){return this.active||this.to_mce},insert:function(text){if(typeof tinymce!="undefined"&&tinymce.activeEditor!=null&&this.to_mce){tinymce.activeEditor.execCommand("mceInsertContent",false,text)}if(this.active!=null&&!this.to_mce){insertAtCursor(this.active,text);return this.active}}};$(()=>{Insert.init()});window.InsertAtCursor=Insert;Object.filter=function(obj,predicate){let result={},key;for(key in obj){if(obj.hasOwnProperty(key)&&predicate(key,obj[key])){result[key]=obj[key]}}return result};const tooltip=(selector,{content :content="",position:position="bottom"})=>{const $el=$(selector);if($el.hasClass("gh-has-tooltip")){return}const $tip=$(`1 (function($){var $doc=$(document);const{sprintf,__,_x,_n}=wp.i18n;function insertAtCursor(field,value){if(document.selection){field.focus();var sel=document.selection.createRange();sel.text=value}else if(field.selectionStart||field.selectionStart=="0"){var startPos=field.selectionStart;var endPos=field.selectionEnd;field.value=field.value.substring(0,startPos)+value+field.value.substring(endPos,field.value.length);field.selectionStart=startPos+value.length;field.selectionEnd=startPos+value.length}else{field.value+=value}let input=new Event("input");let change=new Event("change");field.dispatchEvent(input);field.dispatchEvent(change)}const Insert={active:null,text:"",to_mce:false,init:function(){var self=this;$doc.on("ghClearInsertTarget",function(){self.to_mce=false;self.active=false});$doc.on("to_mce",function(){self.to_mce=true;$doc.trigger("ghInsertTargetChanged")});$doc.on("focus","input:not(.no-insert), textarea:not(.no-insert)",function(){self.active=this;self.to_mce=false;$doc.trigger("ghInsertTargetChanged")})},setActive(el){this.active=el},inserting(){return this.active||this.to_mce},insert:function(text){if(typeof tinymce!="undefined"&&tinymce.activeEditor!=null&&this.to_mce){tinymce.activeEditor.execCommand("mceInsertContent",false,text)}if(this.active!=null&&!this.to_mce){insertAtCursor(this.active,text);return this.active}}};$(()=>{Insert.init()});window.InsertAtCursor=Insert;Object.filter=function(obj,predicate){let result={},key;for(key in obj){if(obj.hasOwnProperty(key)&&predicate(key,obj[key])){result[key]=obj[key]}}return result};const tooltip=(selector,{content="",position="bottom"})=>{const $el=$(selector);if($el.hasClass("gh-has-tooltip")){return}const $tip=$(` 2 2 <div class="gh-tooltip ${position}"> 3 3 ${content} … … 14 14 <div class="gh-step-nav"> 15 15 ${labels.map((l,i)=>stepNum(l,i)).join(`<hr class="gh-step-nav-join"/>`)} 16 </div>`};const stepNavHandler=(selector,{currentStep :currentStep=0,steps:steps=[],onStepChange:onStepChange=step=>{console.log(step)},showNav:showNav=true,labels})=>{this.currStep=currentStep;const mountStep=()=>{const step=steps[this.currStep];const html=`16 </div>`};const stepNavHandler=(selector,{currentStep=0,steps=[],onStepChange=step=>{console.log(step)},showNav=true,labels})=>{this.currStep=currentStep;const mountStep=()=>{const step=steps[this.currStep];const html=` 17 17 <div class="step-nav-handler"> 18 18 ${showNav?stepNav({labels:labels,currentStep:this.currStep}):""} … … 25 25 <span class="fill-amount">0%</span> 26 26 </div> 27 </div>`;const $bar=$(html);const $fill=$bar.find(".gh-progress-bar-fill");const $el=$(selector);$el.html($bar);const setProgress=progress=>{if(progress<=1){progress=progress*100}if(progress>=100){progress=100}if(progress===100){$bar.addClass("complete")}else{$bar.removeClass("complete")}$fill.css({width:progress+"%"}).html(`<span class="fill-amount">${Math.ceil(progress)}%</span>`)};return{setProgress:setProgress}};const createSlotFillProvider=()=>({fills:[],_slotsMounted:[],_slotsDemounted:[],slot(slotName,...args){this._slotsMounted.push({name:slotName,args:args});return this.fills.filter(fill=>fill.slot===slotName).map(fill=>fill.render(...args)).join("")},slotsMounted(){let slot;while(this._slotsMounted.length>0){slot=this._slotsMounted.pop();this.fills.filter(fill=>fill.slot===slot.name).forEach(fill=>{fill.onMount(...slot.args)});this._slotsDemounted.push(slot)}},slotsDemounted(){let slot;while(this._slotsDemounted.length>0){slot=this._slotsDemounted.pop();this.fills.filter(fill=>fill.slot===slot.name).forEach(fill=>{fill.onDemount(...slot.args)})}},fill(slot,component){this.fills.push({slot:slot,...{render(){},onMount(){},onDemount(){},...component}})}});function isString(string){return typeof string==="string"}function isNumeric(n){return!isNaN(parseFloat(n))&&isFinite(n)}const specialChars=string=>{if(!isString(string)){return string}return string.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/"/g,""")};const escHTML=string=>specialChars(string);const kebabize=str=>{return str.split("").map((letter,idx)=>{return letter.toUpperCase()===letter?`${idx!==0?"-":""}${letter.toLowerCase()}`:letter}).join("")};const objectToStyle=object=>{const props=[];for(const prop in object){if(object.hasOwnProperty(prop)){let attr=kebabize(prop);let val=object[prop];if(typeof val==="undefined"||val===null||val===""||val==="null"){continue}switch(attr){case"font-size":case"height":case"width":case"margin":case"padding":case"margin-top":if(isNumeric(val)){val+="px"}break}props.push(`${attr}:${val}`)}}if(props.length){return props.join(";")+";"}return""};function uuid(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,c=>(c^crypto.getRandomValues(new Uint8Array(1))[0]&15>>c/4).toString(16))}const objectToProps=object=>{const props=[];for(const prop in object){if(object.hasOwnProperty(prop)&&typeof object[prop]!=="undefined"&&object[prop]!==false){switch(prop){case"className":props.push(`class="${specialChars(object[prop])}"`);break;case"style":props.push(`style="${specialChars(objectToStyle(object[prop]))}"`);break;default:props.push(`${kebabize(prop)}="${specialChars(object[prop])}"`);break}}}return props.join(" ")};const Elements={toggle({id,name,className,value :value="1",onLabel:onLabel="on",offLabel:offLabel="off",checked,...props}){return`27 </div>`;const $bar=$(html);const $fill=$bar.find(".gh-progress-bar-fill");const $el=$(selector);$el.html($bar);const setProgress=progress=>{if(progress<=1){progress=progress*100}if(progress>=100){progress=100}if(progress===100){$bar.addClass("complete")}else{$bar.removeClass("complete")}$fill.css({width:progress+"%"}).html(`<span class="fill-amount">${Math.ceil(progress)}%</span>`)};return{setProgress:setProgress}};const createSlotFillProvider=()=>({fills:[],_slotsMounted:[],_slotsDemounted:[],slot(slotName,...args){this._slotsMounted.push({name:slotName,args:args});return this.fills.filter(fill=>fill.slot===slotName).map(fill=>fill.render(...args)).join("")},slotsMounted(){let slot;while(this._slotsMounted.length>0){slot=this._slotsMounted.pop();this.fills.filter(fill=>fill.slot===slot.name).forEach(fill=>{fill.onMount(...slot.args)});this._slotsDemounted.push(slot)}},slotsDemounted(){let slot;while(this._slotsDemounted.length>0){slot=this._slotsDemounted.pop();this.fills.filter(fill=>fill.slot===slot.name).forEach(fill=>{fill.onDemount(...slot.args)})}},fill(slot,component){this.fills.push({slot:slot,...{render(){},onMount(){},onDemount(){},...component}})}});function isString(string){return typeof string==="string"}function isNumeric(n){return!isNaN(parseFloat(n))&&isFinite(n)}const specialChars=string=>{if(!isString(string)){return string}return string.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/"/g,""")};const escHTML=string=>specialChars(string);const kebabize=str=>{return str.split("").map((letter,idx)=>{return letter.toUpperCase()===letter?`${idx!==0?"-":""}${letter.toLowerCase()}`:letter}).join("")};const objectToStyle=object=>{const props=[];for(const prop in object){if(object.hasOwnProperty(prop)){let attr=kebabize(prop);let val=object[prop];if(typeof val==="undefined"||val===null||val===""||val==="null"){continue}switch(attr){case"font-size":case"height":case"width":case"margin":case"padding":case"margin-top":if(isNumeric(val)){val+="px"}break}props.push(`${attr}:${val}`)}}if(props.length){return props.join(";")+";"}return""};function uuid(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,c=>(c^crypto.getRandomValues(new Uint8Array(1))[0]&15>>c/4).toString(16))}const objectToProps=object=>{const props=[];for(const prop in object){if(object.hasOwnProperty(prop)&&typeof object[prop]!=="undefined"&&object[prop]!==false){switch(prop){case"className":props.push(`class="${specialChars(object[prop])}"`);break;case"style":props.push(`style="${specialChars(objectToStyle(object[prop]))}"`);break;default:props.push(`${kebabize(prop)}="${specialChars(object[prop])}"`);break}}}return props.join(" ")};const Elements={toggle({id,name,className,value="1",onLabel="on",offLabel="off",checked,...props}){return` 28 28 <label class="gh-switch ${className}"> 29 29 ${Elements.input({name:name,id:id,value:value,checked:checked,...props,type:"checkbox"})} … … 31 31 <span class="on">${onLabel}</span> 32 32 <span class="off">${offLabel}</span> 33 </label>`},input(props){props={type:"text",className:"input regular-text",...props};return`<input ${objectToProps(props)}/>`},select(_props,_options={},_selected=false){let{options :options=_options,selected:selected=_selected,value,...props}=_props;if(value&&!selected){selected=value}return`<select ${objectToProps(props)}>${createOptions(options,selected)}</select>`},option:function(value,text,selected){return`33 </label>`},input(props){props={type:"text",className:"input regular-text",...props};return`<input ${objectToProps(props)}/>`},select(_props,_options={},_selected=false){let{options=_options,selected=_selected,value,...props}=_props;if(value&&!selected){selected=value}return`<select ${objectToProps(props)}>${createOptions(options,selected)}</select>`},option:function(value,text,selected){return` 34 34 <option value="${specialChars(value)}" ${selected?"selected":""}> 35 35 ${text} … … 51 51 </button>`:""} 52 52 </div> 53 </div>`},textAreaWithReplacements:function(atts){return Elements.textAreaWithReplacementsAndEmojis(atts,true,false)},textAreaWithEmojis:function(atts){return Elements.textAreaWithReplacementsAndEmojis(atts,false,true)}};var codeMirror;var codeMirrorIsFocused;$doc.on("ghInsertReplacement",function(e,insert){if(codeMirrorIsFocused){codeMirror.doc.replaceSelection(insert)}});$doc.on("ghReplacementTargetChanged",function(){codeMirrorIsFocused=false});const codeEditor=({selector :selector="",onChange:onChange=content=>{},initialContent:initialContent="",height:height=500})=>{var editorSettings=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{};editorSettings.codemirror=_.extend({},editorSettings.codemirror,{indentUnit:4,tabSize:4});codeMirror=wp.codeEditor.initialize($(selector),editorSettings).codemirror;codeMirror.on("change",function(){onChange(codeMirror.doc.getValue())});codeMirror.on("focus",function(){codeMirrorIsFocused=true;$doc.trigger("ghClearReplacementTarget")});codeMirror.doc.setValue(html_beautify(initialContent,{indent_with_tabs:true}));codeMirror.setSize(null,height);return{editor:codeMirror}};const addReplacementsToolbarTinyMCE=(event,editor)=>{editor.settings.toolbar1+=",gh_replacements";editor.addButton("gh_replacements",{title:"Replacements",image:"",onclick:e=>{InsertAtCursor.to_mce=true;Groundhogg.element.replacementsWidget({target:e.target}).mount()}});$(document).off("tinymce-editor-setup",addReplacementsToolbarTinyMCE)};const addTemplateButtonTinyMCE=(event,editor,config)=>{const{note_type:note_type="",plural}=config;const buttonId=`gh_${note_type}`;editor.settings.toolbar1+=","+buttonId;editor.addButton(buttonId,{title:plural,image:"",onclick:async e=>{let replies=await Groundhogg.stores.replies.fetchItems({type:note_type});return searchOptionsWidget({position:"fixed",target:e.target,options:[{manage:1,data:{summary:`📝 Manage ${plural.toLowerCase()}`}},...replies],filterOption:({data},search)=>data.summary.match(regexp(search)),renderOption:option=>option.data.summary,onSelect:option=>{if(option.manage===1){Groundhogg.SavedRepliesModal(config);return}editor.execCommand("mceInsertContent",false,option.data.content)}}).mount()}})};const addSavedRepliesToolbarTinyMCE=(event,editor)=>{addTemplateButtonTinyMCE(event,editor,{single:"Saved Reply",plural:"Saved Replies",note_type:"saved_reply"});$(document).off("tinymce-editor-setup",addSavedRepliesToolbarTinyMCE)};const addNoteTemplatesToolbarTinyMCE=(event,editor)=>{addTemplateButtonTinyMCE(event,editor,{single:"Note Template",plural:"Note Templates",note_type:"note_template"});$(document).off("tinymce-editor-setup",addNoteTemplatesToolbarTinyMCE)};const addTaskTemplatesToolbarTinyMCE=(event,editor)=>{addTemplateButtonTinyMCE(event,editor,{single:"Task Template",plural:"Task Templates",note_type:"task_template"});$(document).off("tinymce-editor-setup",addTaskTemplatesToolbarTinyMCE)};const addMediaButtonToTinyMCE=(event,editor)=>{editor.settings.toolbar1+=",wp_add_media";$(document).off("tinymce-editor-setup",addMediaButtonToTinyMCE)};const addPostMergeTagsToTinyMCE=(event,editor)=>{editor.settings.toolbar1+=",gh_post_merge_tags";editor.addButton("gh_post_merge_tags",{title:"Post Merge Tags",image:"",onclick:async e=>{return searchOptionsWidget({position:"fixed",target:e.target,options:Groundhogg.emailEditor.PostTagReference,filterOption:({desc},search)=>desc.match(regexp(search)),renderOption:option=>option.desc,onSelect:option=>{editor.execCommand("mceInsertContent",false,`#${option.tag}#`)}}).mount()}});$(document).off("tinymce-editor-setup",addPostMergeTagsToTinyMCE)};const tinymceElement=(editor_id,config={},onChange=v=>{console.log(v)})=>{if(config.replacements===true){$(document).on("tinymce-editor-setup",addReplacementsToolbarTinyMCE);delete config.replacements}if(config.posttags===true){$(document).on("tinymce-editor-setup",addPostMergeTagsToTinyMCE);delete config.posttags}if(config.media===true){$(document).on("tinymce-editor-setup",addMediaButtonToTinyMCE);delete config.media}if(config.savedReplies===true){$(document).on("tinymce-editor-setup",addSavedRepliesToolbarTinyMCE);delete config.savedReplies}if(config.taskTemplates===true){$(document).on("tinymce-editor-setup",addTaskTemplatesToolbarTinyMCE);delete config.taskTemplates}if(config.noteTemplates===true){$(document).on("tinymce-editor-setup",addNoteTemplatesToolbarTinyMCE);delete config.noteTemplates}wp.editor.initialize(editor_id,{tinymce:true,quicktags:true,...config});let editor=tinyMCE.get(editor_id);editor.on("keyup",e=>{Insert.to_mce=true;if(e.type=="keyup"&&e.ctrlKey&&e.shiftKey&&e.which==219){if(GlobalReplacementsWidget&&GlobalReplacementsWidget.isOpen()){return}editor.execCommand("mceInsertContent",false,'<span id="rep-here">{</span>');GlobalReplacementsWidget=replacementsWidget({target:editor.iframeElement.contentWindow.document.getElementById("rep-here"),offset:editor.iframeElement.getBoundingClientRect(),onClose:()=>{editor.dom.remove("rep-here")}});GlobalReplacementsWidget.mount()}});editor.on("Change",e=>{onChange(editor.getContent())});return editor};function addMediaToBasicTinyMCE(){if(typeof this.flag!=="undefined"){return}$doc.on("tinymce-editor-setup",function(event,editor){editor.settings.toolbar1="bold,italic,bullist,numlist,alignleft,aligncenter,alignright,link,wp_add_media";editor.on("click",function(ed,e){$doc.trigger("to_mce")})});this.flag="improved"}function improveTinyMCE(settings={}){const{height:height=0}=settings;if(typeof this.flag!=="undefined"){return}$doc.on("tinymce-editor-setup",function(event,editor){editor.settings.toolbar1="formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,spellchecker,wp_adv,wp_add_media,dfw";editor.settings.toolbar2="strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help";if(height>0){editor.settings.height=height}editor.on("click",function(ed,e){$doc.trigger("to_mce")})});this.flag="improved"}const progressModal=({beforeProgress:beforeProgress=()=>"",afterProgress:afterProgress=()=>"",onOpen:onOpen=()=>{},...rest})=>{return modal({canClose:false,width:500,content:`53 </div>`},textAreaWithReplacements:function(atts){return Elements.textAreaWithReplacementsAndEmojis(atts,true,false)},textAreaWithEmojis:function(atts){return Elements.textAreaWithReplacementsAndEmojis(atts,false,true)}};var codeMirror;var codeMirrorIsFocused;$doc.on("ghInsertReplacement",function(e,insert){if(codeMirrorIsFocused){codeMirror.doc.replaceSelection(insert)}});$doc.on("ghReplacementTargetChanged",function(){codeMirrorIsFocused=false});const codeEditor=({selector="",onChange=content=>{},initialContent="",height=500})=>{var editorSettings=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{};editorSettings.codemirror=_.extend({},editorSettings.codemirror,{indentUnit:4,tabSize:4});codeMirror=wp.codeEditor.initialize($(selector),editorSettings).codemirror;codeMirror.on("change",function(){onChange(codeMirror.doc.getValue())});codeMirror.on("focus",function(){codeMirrorIsFocused=true;$doc.trigger("ghClearReplacementTarget")});codeMirror.doc.setValue(html_beautify(initialContent,{indent_with_tabs:true}));codeMirror.setSize(null,height);return{editor:codeMirror}};const addReplacementsToolbarTinyMCE=(event,editor)=>{editor.settings.toolbar1+=",gh_replacements";editor.addButton("gh_replacements",{title:"Replacements",image:"",onclick:e=>{InsertAtCursor.to_mce=true;Groundhogg.element.replacementsWidget({target:e.target}).mount()}});$(document).off("tinymce-editor-setup",addReplacementsToolbarTinyMCE)};const addTemplateButtonTinyMCE=(event,editor,config)=>{const{note_type="",plural}=config;const buttonId=`gh_${note_type}`;editor.settings.toolbar1+=","+buttonId;editor.addButton(buttonId,{title:plural,image:"",onclick:async e=>{let replies=await Groundhogg.stores.replies.fetchItems({type:note_type});return searchOptionsWidget({position:"fixed",target:e.target,options:[{manage:1,data:{summary:`📝 Manage ${plural.toLowerCase()}`}},...replies],filterOption:({data},search)=>data.summary.match(regexp(search)),renderOption:option=>option.data.summary,onSelect:option=>{if(option.manage===1){Groundhogg.SavedRepliesModal(config);return}editor.execCommand("mceInsertContent",false,option.data.content)}}).mount()}})};const addSavedRepliesToolbarTinyMCE=(event,editor)=>{addTemplateButtonTinyMCE(event,editor,{single:"Saved Reply",plural:"Saved Replies",note_type:"saved_reply"});$(document).off("tinymce-editor-setup",addSavedRepliesToolbarTinyMCE)};const addNoteTemplatesToolbarTinyMCE=(event,editor)=>{addTemplateButtonTinyMCE(event,editor,{single:"Note Template",plural:"Note Templates",note_type:"note_template"});$(document).off("tinymce-editor-setup",addNoteTemplatesToolbarTinyMCE)};const addTaskTemplatesToolbarTinyMCE=(event,editor)=>{addTemplateButtonTinyMCE(event,editor,{single:"Task Template",plural:"Task Templates",note_type:"task_template"});$(document).off("tinymce-editor-setup",addTaskTemplatesToolbarTinyMCE)};const addMediaButtonToTinyMCE=(event,editor)=>{editor.settings.toolbar1+=",wp_add_media";$(document).off("tinymce-editor-setup",addMediaButtonToTinyMCE)};const addPostMergeTagsToTinyMCE=(event,editor)=>{editor.settings.toolbar1+=",gh_post_merge_tags";editor.addButton("gh_post_merge_tags",{title:"Post Merge Tags",image:"",onclick:async e=>{return searchOptionsWidget({position:"fixed",target:e.target,options:Groundhogg.emailEditor.PostTagReference,filterOption:({desc},search)=>desc.match(regexp(search)),renderOption:option=>option.desc,onSelect:option=>{editor.execCommand("mceInsertContent",false,`#${option.tag}#`)}}).mount()}});$(document).off("tinymce-editor-setup",addPostMergeTagsToTinyMCE)};const tinymceElement=(editor_id,config={},onChange=v=>{console.log(v)})=>{if(config.replacements===true){$(document).on("tinymce-editor-setup",addReplacementsToolbarTinyMCE);delete config.replacements}if(config.posttags===true){$(document).on("tinymce-editor-setup",addPostMergeTagsToTinyMCE);delete config.posttags}if(config.media===true){$(document).on("tinymce-editor-setup",addMediaButtonToTinyMCE);delete config.media}if(config.savedReplies===true){$(document).on("tinymce-editor-setup",addSavedRepliesToolbarTinyMCE);delete config.savedReplies}if(config.taskTemplates===true){$(document).on("tinymce-editor-setup",addTaskTemplatesToolbarTinyMCE);delete config.taskTemplates}if(config.noteTemplates===true){$(document).on("tinymce-editor-setup",addNoteTemplatesToolbarTinyMCE);delete config.noteTemplates}wp.editor.initialize(editor_id,{tinymce:true,quicktags:true,...config});let editor=tinyMCE.get(editor_id);editor.on("keyup",e=>{Insert.to_mce=true;if(e.type=="keyup"&&e.ctrlKey&&e.shiftKey&&e.which==219){if(GlobalReplacementsWidget&&GlobalReplacementsWidget.isOpen()){return}editor.execCommand("mceInsertContent",false,'<span id="rep-here">{</span>');GlobalReplacementsWidget=replacementsWidget({target:editor.iframeElement.contentWindow.document.getElementById("rep-here"),offset:editor.iframeElement.getBoundingClientRect(),onClose:()=>{editor.dom.remove("rep-here")}});GlobalReplacementsWidget.mount()}});editor.on("Change",e=>{onChange(editor.getContent())});return editor};function addMediaToBasicTinyMCE(){if(typeof this.flag!=="undefined"){return}$doc.on("tinymce-editor-setup",function(event,editor){editor.settings.toolbar1="bold,italic,bullist,numlist,alignleft,aligncenter,alignright,link,wp_add_media";editor.on("click",function(ed,e){$doc.trigger("to_mce")})});this.flag="improved"}function improveTinyMCE(settings={}){const{height=0}=settings;if(typeof this.flag!=="undefined"){return}$doc.on("tinymce-editor-setup",function(event,editor){editor.settings.toolbar1="formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,spellchecker,wp_adv,wp_add_media,dfw";editor.settings.toolbar2="strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help";if(height>0){editor.settings.height=height}editor.on("click",function(ed,e){$doc.trigger("to_mce")})});this.flag="improved"}const progressModal=({beforeProgress=()=>"",afterProgress=()=>"",onOpen=()=>{},...rest})=>{return modal({canClose:false,width:500,content:` 54 54 ${beforeProgress()} 55 55 <div id="progress-modal"></div> … … 60 60 width="150" 61 61 height="150"/> 62 </div>`};const skeleton=()=>{if(typeof MakeEl!=="undefined"){return MakeEl.Skeleton({style:{padding:"10px"}},["full","full","full"]).outerHTML}return""};const savingModal=()=>{return loadingModal("Saving")};const dangerConfirmationModal=props=>{return confirmationModal({...props,confirmButtonType:"danger",cancelButtonType:"primary text"})};const dangerDeleteModal=({name,...props})=>dangerConfirmationModal({alert:`<p>${sprintf(__("Are you sure you want to delete %s? This action cannot be undone.","groundhogg"),name)}</p>`,confirmText:__("Delete"),...props});const dangerModalLink=(e,alert="",props={})=>{e.preventDefault();if(e.currentTarget.dataset.alert){alert=e.currentTarget.dataset.alert}dangerConfirmationModal({alert:`<p>${alert}</p>`,onConfirm:()=>{window.location.href=e.target.closest("a").href},...props})};$(document).on("submit","form.danger-permanent",e=>{e.preventDefault();dangerModalLink(e,__("Are you sure? This action cannot be undone.","groundhogg"),{onConfirm:()=>{e.currentTarget.submit()}})});$(document).on("click","a.danger-confirm",e=>dangerModalLink(e,__("Are you sure?","groundhogg")));$(document).on("click","a.danger-permanent",e=>dangerModalLink(e,__("Are you sure? This action cannot be undone.","groundhogg")));$(document).on("click","a.danger-delete",e=>{let msg=__("Are you sure? This action cannot be undone.","groundhogg");if(e.currentTarget.dataset.name){msg=sprintf(__("Are you sure you want to delete %s? This action cannot be undone.","groundhogg"),bold(e.currentTarget.dataset.name))}dangerModalLink(e,msg,{confirmText:__("Delete")})});const confirmationModal=({alert :alert="",confirmText:confirmText=_x("Confirm","verb","groundhogg"),closeText:closeText=__("Cancel","groundhogg"),onConfirm:onConfirm=()=>{},onCancel:onCancel=()=>{},onClose:onClose=()=>{},confirmButtonType:confirmButtonType="primary",cancelButtonType:cancelButtonType="danger text",buttonSize:buttonSize="medium",...rest})=>{let confirmed=false;const content=`62 </div>`};const skeleton=()=>{if(typeof MakeEl!=="undefined"){return MakeEl.Skeleton({style:{padding:"10px"}},["full","full","full"]).outerHTML}return""};const savingModal=()=>{return loadingModal("Saving")};const dangerConfirmationModal=props=>{return confirmationModal({...props,confirmButtonType:"danger",cancelButtonType:"primary text"})};const dangerDeleteModal=({name,...props})=>dangerConfirmationModal({alert:`<p>${sprintf(__("Are you sure you want to delete %s? This action cannot be undone.","groundhogg"),name)}</p>`,confirmText:__("Delete"),...props});const dangerModalLink=(e,alert="",props={})=>{e.preventDefault();if(e.currentTarget.dataset.alert){alert=e.currentTarget.dataset.alert}dangerConfirmationModal({alert:`<p>${alert}</p>`,onConfirm:()=>{window.location.href=e.target.closest("a").href},...props})};$(document).on("submit","form.danger-permanent",e=>{e.preventDefault();dangerModalLink(e,__("Are you sure? This action cannot be undone.","groundhogg"),{onConfirm:()=>{e.currentTarget.submit()}})});$(document).on("click","a.danger-confirm",e=>dangerModalLink(e,__("Are you sure?","groundhogg")));$(document).on("click","a.danger-permanent",e=>dangerModalLink(e,__("Are you sure? This action cannot be undone.","groundhogg")));$(document).on("click","a.danger-delete",e=>{let msg=__("Are you sure? This action cannot be undone.","groundhogg");if(e.currentTarget.dataset.name){msg=sprintf(__("Are you sure you want to delete %s? This action cannot be undone.","groundhogg"),bold(e.currentTarget.dataset.name))}dangerModalLink(e,msg,{confirmText:__("Delete")})});const confirmationModal=({alert="",confirmText=_x("Confirm","verb","groundhogg"),closeText=__("Cancel","groundhogg"),onConfirm=()=>{},onCancel=()=>{},onClose=()=>{},confirmButtonType="primary",cancelButtonType="danger text",buttonSize="medium",...rest})=>{let confirmed=false;const content=` 63 63 <button type="button" 64 64 class="dashicon-button gh-modal-button-close-top gh-modal-button-close"> … … 77 77 ${confirmText} 78 78 </button> 79 </div>`;const handleClose=()=>{if(!confirmed){onCancel()}onClose()};const{close,$modal}=modal({content:content,onClose:handleClose,dialogClasses:"gh-modal-confirmation",...rest});const confirm=()=>{confirmed=true;onConfirm();close()};const handleConfirm=()=>{confirm()};$(".gh-modal-button-confirm").on("click",handleConfirm);return{close:close,confirm:confirm,$modal:$modal}};const miniModal=(selector,{content :content="",onSetContent:onSetContent=()=>{},onClose:onClose=()=>{},onOpen:onOpen=()=>{},dialogClasses:dialogClasses="",closeOnFocusout:closeOnFocusout=true})=>{const html=`79 </div>`;const handleClose=()=>{if(!confirmed){onCancel()}onClose()};const{close,$modal}=modal({content:content,onClose:handleClose,dialogClasses:"gh-modal-confirmation",...rest});const confirm=()=>{confirmed=true;onConfirm();close()};const handleConfirm=()=>{confirm()};$(".gh-modal-button-confirm").on("click",handleConfirm);return{close:close,confirm:confirm,$modal:$modal}};const miniModal=(selector,{content="",onSetContent=()=>{},onClose=()=>{},onOpen=()=>{},dialogClasses="",closeOnFocusout=true})=>{const html=` 80 80 <div class="gh-modal mini gh-panel" tabindex="0"> 81 81 <div class="gh-modal-dialog ${dialogClasses}"> … … 86 86 ${content} 87 87 </div> 88 </div>`;const $modal=$(html);const close=()=>{$modal.remove();$("body").removeClass("modal-open");onClose()};const handleClose=()=>{close()};const setContent=content=>{$modal.find(".gh-modal-dialog-content").html(content);onSetContent()};const $el=$(selector);$("body").append($modal);const{left,right,top,bottom}=$el[0].getBoundingClientRect();$modal.css({top:Math.min(bottom,window.innerHeight-$modal.height()-20)+"px",left:right-$modal.outerWidth()+"px"});onOpen();$modal.find(".gh-modal-button-close").on("click",handleClose);if(closeOnFocusout){$modal.on("focusout",e=>{if(!e.relatedTarget||!clickedIn(e.relatedTarget,".gh-modal.mini")){handleClose()}})}$modal.focus();return{$modal:$modal,close:close,setContent:setContent}};const modal=({content :content="",onSetContent:onSetContent=()=>{},onClose:onClose=()=>{},beforeClose:beforeClose=()=>true,canClose:canClose=true,onOpen:onOpen=()=>{},width:width=false,className:className="",dialogClasses:dialogClasses="",overlay:overlay=true,disableScrolling:disableScrolling=true})=>{const html=`88 </div>`;const $modal=$(html);const close=()=>{$modal.remove();$("body").removeClass("modal-open");onClose()};const handleClose=()=>{close()};const setContent=content=>{$modal.find(".gh-modal-dialog-content").html(content);onSetContent()};const $el=$(selector);$("body").append($modal);const{left,right,top,bottom}=$el[0].getBoundingClientRect();$modal.css({top:Math.min(bottom,window.innerHeight-$modal.height()-20)+"px",left:right-$modal.outerWidth()+"px"});onOpen();$modal.find(".gh-modal-button-close").on("click",handleClose);if(closeOnFocusout){$modal.on("focusout",e=>{if(!e.relatedTarget||!clickedIn(e.relatedTarget,".gh-modal.mini")){handleClose()}})}$modal.focus();return{$modal:$modal,close:close,setContent:setContent}};const modal=({content="",onSetContent=()=>{},onClose=()=>{},beforeClose=()=>true,canClose=true,onOpen=()=>{},width=false,className="",dialogClasses="",overlay=true,disableScrolling=true})=>{const html=` 89 89 <div class="gh-modal ${className} ${disableScrolling?"disabled-scrolling":""}"> 90 90 ${overlay?`<div class="gh-modal-overlay"></div>`:""} … … 98 98 </div> 99 99 </div> 100 </div>`;const $modal=$(html);const close=()=>{if(!beforeClose(close)){return}$modal.remove();if(disableScrolling&&$(".gh-modal.disabled-scrolling").length===0){$("body").removeClass("modal-open")}onClose()};const handleClose=()=>{close()};const maybeMoveHeader=()=>{$modal.find(".gh-modal-dialog > .gh-header").remove();let $header=$modal.find(".gh-modal-dialog-content .gh-header");if($header){$header.insertBefore($modal.find(".gh-modal-dialog-content"))}};const setContent=content=>{$modal.find(".gh-modal-dialog-content").html(content);maybeMoveHeader();onSetContent()};$("body").append($modal).addClass(disableScrolling?"modal-open":"");maybeMoveHeader();onOpen({close:close,setContent:setContent});if(canClose){$modal.find(".gh-modal-overlay, .gh-modal-button-close").on("click",handleClose)}return{$modal:$modal,close:close,setContent:setContent}};const wpErrorDialog=(error,props)=>{let message;if(Array.isArray(error)){message=error[0].message}if(typeof error==="object"&&error.message){message=error.message}return errorDialog({message:message,...props})};const errorDialog=props=>{return dialog({...props,type:"error"})};const dialog=({message :message="",animationDuration:animationDuration=300,ttl:ttl=3e3,type:type="success"})=>{const $dialog=$(`<div class="gh-dialog gh-dialog-${type}">${message}</div>`);$("body").append($dialog).addClass("dialog-open");$dialog.animate({top:40},animationDuration,"swing",()=>{setTimeout(()=>{$dialog.animate({top:-100},animationDuration,"swing",()=>{$dialog.remove()})},ttl)});return{$dialog:$dialog}};const loadingDots=selector=>{const $el=$('<span class="loading-dots"></span>');$(selector).append($el);const stop=()=>{clearInterval(interval);$el.remove()};const interval=setInterval(()=>{if($el.html().length>=3){$el.html(".")}else{$el.html($el.html()+".")}},500);return{stop:stop}};const createOptions=(options,selected)=>{const optionsString=[];if(Array.isArray(options)){options.forEach(option=>{if(typeof option!=="object"){option={value:option,text:option}}optionsString.push(Elements.option(option.value,option.text,Array.isArray(selected)?selected.indexOf(option.value)!==-1:option.value==selected))})}else{for(const option in options){if(options.hasOwnProperty(option)){optionsString.push(Elements.option(option,options[option],Array.isArray(selected)?selected.indexOf(option)!==-1:option==selected))}}}return optionsString.join("")};const regexp=str=>{return new RegExp(escapeRegex(str),"i")};function escapeRegex(string){return string.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}if(!Element.prototype.matches){Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(s){var matches=(this.document||this.ownerDocument).querySelectorAll(s),i=matches.length;while(--i>=0&&matches.item(i)!==this){}return i>-1}}const clickedIn=(e,selector)=>{return clickInsideElement(e,selector)};function clickInsideElement(e,selector){var el=e.tagName?e:e.srcElement||e.target;if(el&&el.matches(selector)){return el}else{while(el=el.parentNode){if(typeof el.matches!=="undefined"&&el.matches(selector)){return el}}}return false}const searchOptionsWidget=({selector:selector=".search-options-widget-wrap",target:target=null,offset:offset=null,position:position="inline",options:options=[],groups:groups={},filterOption:filterOption=(option,search)=>option.match(regexp(search)),renderOption:renderOption=option=>option,noOptions:noOptions=__("No options...","groundhogg"),onSelect:onSelect=option=>{},onInput:onInput=search=>{},onClose:onClose=()=>{},onOpen:onOpen=()=>{},filterOptions:filterOptions=(opts,search)=>opts})=>({selector:selector,options:options,onInput:onInput,filterOption:filterOption,renderOption:renderOption,onClose:onClose,onSelect:onSelect,groups:groups,_open:false,search:"",focusedOptionId:-1,previousFocusedOptionId:false,focusedOption:false,render(){return`100 </div>`;const $modal=$(html);const close=()=>{if(!beforeClose(close)){return}$modal.remove();if(disableScrolling&&$(".gh-modal.disabled-scrolling").length===0){$("body").removeClass("modal-open")}onClose()};const handleClose=()=>{close()};const maybeMoveHeader=()=>{$modal.find(".gh-modal-dialog > .gh-header").remove();let $header=$modal.find(".gh-modal-dialog-content .gh-header");if($header){$header.insertBefore($modal.find(".gh-modal-dialog-content"))}};const setContent=content=>{$modal.find(".gh-modal-dialog-content").html(content);maybeMoveHeader();onSetContent()};$("body").append($modal).addClass(disableScrolling?"modal-open":"");maybeMoveHeader();onOpen({close:close,setContent:setContent});if(canClose){$modal.find(".gh-modal-overlay, .gh-modal-button-close").on("click",handleClose)}return{$modal:$modal,close:close,setContent:setContent}};const wpErrorDialog=(error,props)=>{let message;if(Array.isArray(error)){message=error[0].message}if(typeof error==="object"&&error.message){message=error.message}return errorDialog({message:message,...props})};const errorDialog=props=>{return dialog({...props,type:"error"})};const dialog=({message="",animationDuration=300,ttl=3e3,type="success"})=>{const $dialog=$(`<div class="gh-dialog gh-dialog-${type}">${message}</div>`);$("body").append($dialog).addClass("dialog-open");$dialog.animate({top:40},animationDuration,"swing",()=>{setTimeout(()=>{$dialog.animate({top:-100},animationDuration,"swing",()=>{$dialog.remove()})},ttl)});return{$dialog:$dialog}};const loadingDots=selector=>{const $el=$('<span class="loading-dots"></span>');$(selector).append($el);const stop=()=>{clearInterval(interval);$el.remove()};const interval=setInterval(()=>{if($el.html().length>=3){$el.html(".")}else{$el.html($el.html()+".")}},500);return{stop:stop}};const createOptions=(options,selected)=>{const optionsString=[];if(Array.isArray(options)){options.forEach(option=>{if(typeof option!=="object"){option={value:option,text:option}}optionsString.push(Elements.option(option.value,option.text,Array.isArray(selected)?selected.indexOf(option.value)!==-1:option.value==selected))})}else{for(const option in options){if(options.hasOwnProperty(option)){optionsString.push(Elements.option(option,options[option],Array.isArray(selected)?selected.indexOf(option)!==-1:option==selected))}}}return optionsString.join("")};const regexp=str=>{return new RegExp(escapeRegex(str),"i")};function escapeRegex(string){return string.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}if(!Element.prototype.matches){Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(s){var matches=(this.document||this.ownerDocument).querySelectorAll(s),i=matches.length;while(--i>=0&&matches.item(i)!==this){}return i>-1}}const clickedIn=(e,selector)=>{return clickInsideElement(e,selector)};function clickInsideElement(e,selector){var el=e.tagName?e:e.srcElement||e.target;if(el&&el.matches(selector)){return el}else{while(el=el.parentNode){if(typeof el.matches!=="undefined"&&el.matches(selector)){return el}}}return false}const searchOptionsWidget=({selector=".search-options-widget-wrap",target=null,offset=null,position="inline",options=[],groups={},filterOption=(option,search)=>option.match(regexp(search)),renderOption=option=>option,noOptions=__("No options...","groundhogg"),onSelect=option=>{},onInput=search=>{},onClose=()=>{},onOpen=()=>{},filterOptions=(opts,search)=>opts})=>({selector:selector,options:options,onInput:onInput,filterOption:filterOption,renderOption:renderOption,onClose:onClose,onSelect:onSelect,groups:groups,_open:false,search:"",focusedOptionId:-1,previousFocusedOptionId:false,focusedOption:false,render(){return` 101 101 <div class="search-options-widget-wrap"> 102 102 <div class="search-options-widget ${position}" tabindex="0"> … … 109 109 <div class="search-options ${this.hasGroups()?"has-groups":"no-groups"}"></div> 110 110 </div> 111 </div>`},getOptions(){return filterOptions(this.options.filter((option,i)=>{if(this.search){return filterOption(option,this.search)}return true}),this.search)},hasGroups(){return Object.keys(groups).length>0},renderSearchOptions(){const searchOptions=[];let focusedIndex=0;var self=this;const optionDiv=(option,group,id,index)=>{return`<div class="option ${index===this.focusedOptionId?"focused":""}" data-option="${id}" data-group="${group}">${renderOption(option)}</div>`};if(Object.keys(groups).length>0){Object.keys(groups).forEach((group,g)=>{const options=[];this.getOptions().filter(option=>option.group===group).forEach((option,o)=>{options.push(optionDiv(option,group,o,focusedIndex));focusedIndex++});if(options.length>0){searchOptions.push(`<div class="option-group" data-group="${group}">${groups[group]}</div>`,...options)}})}else{this.getOptions().forEach((option,o)=>{searchOptions.push(optionDiv(option,null,o,focusedIndex));focusedIndex++})}return searchOptions.length?searchOptions.join(""):`<div class="no-options">${noOptions}</div>`},close(){this._open=false;$(".search-options-widget-wrap").remove()},isOpen(){return this._open},isClosed(){return!this._open},selectOption(optionId,groupId){if(!this.hasGroups()){onSelect(this.getOptions()[optionId]);this.close();onClose()}else{Object.keys(groups).forEach((group,g)=>{this.getOptions().filter(option=>option.group==group).forEach((option,o)=>{if(group==groupId&&o==optionId){onSelect(option);this.close();onClose();return}})})}},mountOptions(){var self=this;const $options=$(`${selector} .search-options`);$options.html(this.renderSearchOptions());$(`${selector} .option`).on("click",function(e){const optionId=parseInt($(this).data("option"));const groupId=$(this).data("group");self.selectOption(optionId,groupId)});const $focused=$(`${selector} .option.focused`);let offset;if(this.focusedOptionId>this.previousFocusedOptionId){offset=$focused.height()*($focused.index()+1);if(offset>$options.height()){$options.scrollTop(offset-$options.height())}}else if(this.focusedOptionId<this.previousFocusedOptionId){offset=$focused.height()*$focused.index();if(offset<$options.scrollTop()){$options.scrollTop(offset)}}this.repositionFixed()},repositionFixed(){if(position!=="fixed"||!this.$widget){return}let{left,top,right,bottom}=target.getBoundingClientRect();if(offset){left+=offset.left;top+=offset.top}this.$widget.css({top:top+this.$widget.outerHeight()>window.innerHeight?"initial":top,bottom:top+this.$widget.outerHeight()>window.innerHeight?5:"initial",right:left+this.$widget.outerWidth()>window.innerWidth?5:"initial",left:left+this.$widget.outerWidth()>window.innerWidth?"initial":left})},mount(){var self=this;switch(position){default:case"inline":const $el=$(selector);$el.html(self.render());this.mountOptions();break;case"fixed":const $picker=$(self.render());$("body").append($picker);this.mountOptions();const $widget=$picker.find(".search-options-widget");this.$widget=$widget;this.repositionFixed();break}const el=document.querySelector(".search-options-widget");if(!el){return}const handleClose=()=>{this.close();onClose()};$(`${selector} input.search-for-options`).on("input",e=>{this.search=$(e.target).val();this.focusedOptionId=-1;this.previousFocusedOptionId=-1;onInput(this.search,this);this.mountOptions()}).focus();if(el.getBoundingClientRect().y+$(el).height()>window.innerHeight){el.classList.add("mount-from-bottom")}$(`${selector} button.close`).on("click",function(e){handleClose()});const handleKeyDown=e=>{const{type,key,keyCode}=e;switch(key){case"Esc":case"Escape":handleClose();break;case"Down":case"ArrowDown":e.preventDefault();if(this.focusedOptionId===this.getOptions().length-1){return}this.previousFocusedOptionId=this.focusedOptionId;this.focusedOptionId++;this.mountOptions();break;case"Up":case"ArrowUp":e.preventDefault();if(this.focusedOptionId===0){return}this.previousFocusedOptionId=this.focusedOptionId;this.focusedOptionId--;this.mountOptions();break;case"Enter":e.preventDefault();const $focused=$(`${selector} .option.focused`);this.selectOption(parseInt($focused.data("option")),$focused.data("group"));break}};$(".search-options-widget").on("keydown",handleKeyDown);this._open=true;onOpen(this)}});const replacementsWidget=more=>{const{groups,codes}=Groundhogg.replacements;return searchOptionsWidget({position:"fixed",options:Object.values(codes).filter(r=>!r.hidden),groups:groups,filterOption:({name,code},search)=>name.match(regexp(search))||code.match(regexp(search)),renderOption:option=>option.name,onSelect:option=>{let el=InsertAtCursor.insert(option.insert);$(el).focus()},...more})};let GlobalReplacementsWidget;$(()=>{const openWidget=more=>{GlobalReplacementsWidget=replacementsWidget(more);GlobalReplacementsWidget.mount()};window.addEventListener("keyup",e=>{if(e.ctrlKey&&e.shiftKey&&e.which==219){if(Insert.to_mce){return}let $el=$('<div id="rep-here"></div>');$el.insertAfter(e.target);openWidget({target:document.getElementById("rep-here"),onClose:()=>{$el.remove()}})}});$doc.on("click",e=>{if(GlobalReplacementsWidget&&GlobalReplacementsWidget.isOpen()&&!clickedIn(e,".search-options-widget")){GlobalReplacementsWidget.close()}if(clickedIn(e,".replacements-picker-start")){openWidget({target:e.target.closest(".replacements-picker-start")})}})});const inputRepeater=(selector,{rows :rows=[],sortable:sortable=false,cells:cells=[],onMount:onMount=()=>{},addRow:addRow=()=>Array(cells.length).fill(""),onChange:onChange=rows=>{},onRemove:onRemove=row=>{}})=>({rows:rows,mount(){$(selector).html(this.render());this.onMount()},onMount(){$(`${selector} .remove-row`).on("click",e=>{const row=parseInt(e.currentTarget.dataset.row);onRemove(this.rows[row]);this.rows.splice(row,1);onChange(this.rows);this.mount()});$(`${selector} .add-row`).on("click",e=>{this.rows.push(addRow());onChange(this.rows);this.mount();$(`${selector} .add-row`).focus()});$(`${selector} [data-cell][data-row]`).on("change",e=>{const row=parseInt(e.target.dataset.row);const cell=parseInt(e.target.dataset.cell);this.rows[row][cell]=$(e.target).val();onChange(this.rows)});if(sortable){$(`${selector} .gh-input-repeater`).sortable({handle:".handle",update:(e,ui)=>{let $row=$(ui.item);let oldIndex=parseInt($row.data("row"));let curIndex=$row.index();let row=this.rows[oldIndex];this.rows.splice(oldIndex,1);this.rows.splice(curIndex,0,row);onChange(this.rows);this.mount()}})}onMount()},render(){const renderRow=(row,rowIndex)=>{return`111 </div>`},getOptions(){return filterOptions(this.options.filter((option,i)=>{if(this.search){return filterOption(option,this.search)}return true}),this.search)},hasGroups(){return Object.keys(groups).length>0},renderSearchOptions(){const searchOptions=[];let focusedIndex=0;var self=this;const optionDiv=(option,group,id,index)=>{return`<div class="option ${index===this.focusedOptionId?"focused":""}" data-option="${id}" data-group="${group}">${renderOption(option)}</div>`};if(Object.keys(groups).length>0){Object.keys(groups).forEach((group,g)=>{const options=[];this.getOptions().filter(option=>option.group===group).forEach((option,o)=>{options.push(optionDiv(option,group,o,focusedIndex));focusedIndex++});if(options.length>0){searchOptions.push(`<div class="option-group" data-group="${group}">${groups[group]}</div>`,...options)}})}else{this.getOptions().forEach((option,o)=>{searchOptions.push(optionDiv(option,null,o,focusedIndex));focusedIndex++})}return searchOptions.length?searchOptions.join(""):`<div class="no-options">${noOptions}</div>`},close(){this._open=false;$(".search-options-widget-wrap").remove()},isOpen(){return this._open},isClosed(){return!this._open},selectOption(optionId,groupId){if(!this.hasGroups()){onSelect(this.getOptions()[optionId]);this.close();onClose()}else{Object.keys(groups).forEach((group,g)=>{this.getOptions().filter(option=>option.group==group).forEach((option,o)=>{if(group==groupId&&o==optionId){onSelect(option);this.close();onClose();return}})})}},mountOptions(){var self=this;const $options=$(`${selector} .search-options`);$options.html(this.renderSearchOptions());$(`${selector} .option`).on("click",function(e){const optionId=parseInt($(this).data("option"));const groupId=$(this).data("group");self.selectOption(optionId,groupId)});const $focused=$(`${selector} .option.focused`);let offset;if(this.focusedOptionId>this.previousFocusedOptionId){offset=$focused.height()*($focused.index()+1);if(offset>$options.height()){$options.scrollTop(offset-$options.height())}}else if(this.focusedOptionId<this.previousFocusedOptionId){offset=$focused.height()*$focused.index();if(offset<$options.scrollTop()){$options.scrollTop(offset)}}this.repositionFixed()},repositionFixed(){if(position!=="fixed"||!this.$widget){return}let{left,top,right,bottom}=target.getBoundingClientRect();if(offset){left+=offset.left;top+=offset.top}this.$widget.css({top:top+this.$widget.outerHeight()>window.innerHeight?"initial":top,bottom:top+this.$widget.outerHeight()>window.innerHeight?5:"initial",right:left+this.$widget.outerWidth()>window.innerWidth?5:"initial",left:left+this.$widget.outerWidth()>window.innerWidth?"initial":left})},mount(){var self=this;switch(position){default:case"inline":const $el=$(selector);$el.html(self.render());this.mountOptions();break;case"fixed":const $picker=$(self.render());$("body").append($picker);this.mountOptions();const $widget=$picker.find(".search-options-widget");this.$widget=$widget;this.repositionFixed();break}const el=document.querySelector(".search-options-widget");if(!el){return}const handleClose=()=>{this.close();onClose()};$(`${selector} input.search-for-options`).on("input",e=>{this.search=$(e.target).val();this.focusedOptionId=-1;this.previousFocusedOptionId=-1;onInput(this.search,this);this.mountOptions()}).focus();if(el.getBoundingClientRect().y+$(el).height()>window.innerHeight){el.classList.add("mount-from-bottom")}$(`${selector} button.close`).on("click",function(e){handleClose()});const handleKeyDown=e=>{const{type,key,keyCode}=e;switch(key){case"Esc":case"Escape":handleClose();break;case"Down":case"ArrowDown":e.preventDefault();if(this.focusedOptionId===this.getOptions().length-1){return}this.previousFocusedOptionId=this.focusedOptionId;this.focusedOptionId++;this.mountOptions();break;case"Up":case"ArrowUp":e.preventDefault();if(this.focusedOptionId===0){return}this.previousFocusedOptionId=this.focusedOptionId;this.focusedOptionId--;this.mountOptions();break;case"Enter":e.preventDefault();const $focused=$(`${selector} .option.focused`);this.selectOption(parseInt($focused.data("option")),$focused.data("group"));break}};$(".search-options-widget").on("keydown",handleKeyDown);this._open=true;onOpen(this)}});const replacementsWidget=more=>{const{groups,codes}=Groundhogg.replacements;return searchOptionsWidget({position:"fixed",options:Object.values(codes).filter(r=>!r.hidden),groups:groups,filterOption:({name,code},search)=>name.match(regexp(search))||code.match(regexp(search)),renderOption:option=>option.name,onSelect:option=>{let el=InsertAtCursor.insert(option.insert);$(el).focus()},...more})};let GlobalReplacementsWidget;$(()=>{const openWidget=more=>{GlobalReplacementsWidget=replacementsWidget(more);GlobalReplacementsWidget.mount()};window.addEventListener("keyup",e=>{if(e.ctrlKey&&e.shiftKey&&e.which==219){if(Insert.to_mce){return}let $el=$('<div id="rep-here"></div>');$el.insertAfter(e.target);openWidget({target:document.getElementById("rep-here"),onClose:()=>{$el.remove()}})}});$doc.on("click",e=>{if(GlobalReplacementsWidget&&GlobalReplacementsWidget.isOpen()&&!clickedIn(e,".search-options-widget")){GlobalReplacementsWidget.close()}if(clickedIn(e,".replacements-picker-start")){openWidget({target:e.target.closest(".replacements-picker-start")})}})});const inputRepeater=(selector,{rows=[],sortable=false,cells=[],onMount=()=>{},addRow=()=>Array(cells.length).fill(""),onChange=rows=>{},onRemove=row=>{}})=>({rows:rows,mount(){$(selector).html(this.render());this.onMount()},onMount(){$(`${selector} .remove-row`).on("click",e=>{const row=parseInt(e.currentTarget.dataset.row);onRemove(this.rows[row]);this.rows.splice(row,1);onChange(this.rows);this.mount()});$(`${selector} .add-row`).on("click",e=>{this.rows.push(addRow());onChange(this.rows);this.mount();$(`${selector} .add-row`).focus()});$(`${selector} [data-cell][data-row]`).on("change",e=>{const row=parseInt(e.target.dataset.row);const cell=parseInt(e.target.dataset.cell);this.rows[row][cell]=$(e.target).val();onChange(this.rows)});if(sortable){$(`${selector} .gh-input-repeater`).sortable({handle:".handle",update:(e,ui)=>{let $row=$(ui.item);let oldIndex=parseInt($row.data("row"));let curIndex=$row.index();let row=this.rows[oldIndex];this.rows.splice(oldIndex,1);this.rows.splice(curIndex,0,row);onChange(this.rows);this.mount()}})}onMount()},render(){const renderRow=(row,rowIndex)=>{return` 112 112 <div class="gh-input-repeater-row" data-row="${rowIndex}"> 113 113 ${row.map((cell,cellIndex)=>cells[cellIndex]({value:cell,dataRow:rowIndex,dataCell:cellIndex},row)).join("")} … … 126 126 </button> 127 127 </div> 128 </div>`}});const inputRepeaterWidget=({selector :selector="",rows:rows=[],cellProps:cellProps=[],sortable:sortable=false,cellCallbacks:cellCallbacks=[],onMount:onMount=()=>{},onChange:onChange=rows=>{},onRemove:onRemove=row=>{}})=>({rows:rows,mount(){$(selector).html(this.render());this.onMount()},onMount(){$(`${selector} .remove-row`).on("click",e=>{const row=parseInt(e.currentTarget.dataset.row);onRemove(this.rows[row]);this.rows.splice(row,1);onChange(this.rows);this.mount()});$(`${selector} #add-row`).on("click",e=>{this.rows.push(Array(cellProps.length).fill(""));onChange(this.rows);this.mount();$(`${selector} #add-row`).focus()});$(`${selector} input`).on("change",e=>{const row=parseInt(e.target.dataset.row);const cell=parseInt(e.target.dataset.cell);this.rows[row][cell]=e.target.value;onChange(this.rows)});if(sortable){$(`${selector} .gh-input-repeater`).sortable({handle:".handle",update:(e,ui)=>{let $row=$(ui.item);let oldIndex=parseInt($row.data("row"));let curIndex=$row.index();let row=this.rows[oldIndex];this.rows.splice(oldIndex,1);this.rows.splice(curIndex,0,row);onChange(this.rows);this.mount()}})}onMount()},render(){const renderRow=(row,rowIndex)=>{return`128 </div>`}});const inputRepeaterWidget=({selector="",rows=[],cellProps=[],sortable=false,cellCallbacks=[],onMount=()=>{},onChange=rows=>{},onRemove=row=>{}})=>({rows:rows,mount(){$(selector).html(this.render());this.onMount()},onMount(){$(`${selector} .remove-row`).on("click",e=>{const row=parseInt(e.currentTarget.dataset.row);onRemove(this.rows[row]);this.rows.splice(row,1);onChange(this.rows);this.mount()});$(`${selector} #add-row`).on("click",e=>{this.rows.push(Array(cellProps.length).fill(""));onChange(this.rows);this.mount();$(`${selector} #add-row`).focus()});$(`${selector} input`).on("change",e=>{const row=parseInt(e.target.dataset.row);const cell=parseInt(e.target.dataset.cell);this.rows[row][cell]=e.target.value;onChange(this.rows)});if(sortable){$(`${selector} .gh-input-repeater`).sortable({handle:".handle",update:(e,ui)=>{let $row=$(ui.item);let oldIndex=parseInt($row.data("row"));let curIndex=$row.index();let row=this.rows[oldIndex];this.rows.splice(oldIndex,1);this.rows.splice(curIndex,0,row);onChange(this.rows);this.mount()}})}onMount()},render(){const renderRow=(row,rowIndex)=>{return` 129 129 <div class="gh-input-repeater-row" data-row="${rowIndex}"> 130 130 ${row.map((cell,cellIndex)=>cellCallbacks[cellIndex]({...cellProps[cellIndex],value:cell,dataRow:rowIndex,dataCell:cellIndex})).join("")} … … 143 143 </button> 144 144 </div> 145 </div>`}});const flattenObject=(obj,parent_key="")=>{if(typeof obj!=="object"){return{}}const flattened={};let key_prefix=parent_key?parent_key+".":"";for(const key in obj){if(obj.hasOwnProperty(key)){let value=obj[key];if(typeof value!=="object"){flattened[key_prefix+key]=value}else{Object.assign(flattened,flattenObject(value,key_prefix+key))}}}return flattened};function objectEquals(a,b){return JSON.stringify(a)===JSON.stringify(b)}const isValidEmail=email=>{const re=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return re.test(String(email).toLowerCase())};const primaryButton=({className,...props})=>{return button({className:"gh-button primary"+(className?" "+className:""),...props})};const secondaryButton=({className,...props})=>{return button({className:"gh-button secondary"+(className?" "+className:""),...props})};const dangerButton=({className,...props})=>{return button({className:"gh-button danger"+(className?" "+className:""),...props})};const button=({text :text="",className:className="",...props})=>{return`145 </div>`}});const flattenObject=(obj,parent_key="")=>{if(typeof obj!=="object"){return{}}const flattened={};let key_prefix=parent_key?parent_key+".":"";for(const key in obj){if(obj.hasOwnProperty(key)){let value=obj[key];if(typeof value!=="object"){flattened[key_prefix+key]=value}else{Object.assign(flattened,flattenObject(value,key_prefix+key))}}}return flattened};function objectEquals(a,b){return JSON.stringify(a)===JSON.stringify(b)}const isValidEmail=email=>{const re=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return re.test(String(email).toLowerCase())};const primaryButton=({className,...props})=>{return button({className:"gh-button primary"+(className?" "+className:""),...props})};const secondaryButton=({className,...props})=>{return button({className:"gh-button secondary"+(className?" "+className:""),...props})};const dangerButton=({className,...props})=>{return button({className:"gh-button danger"+(className?" "+className:""),...props})};const button=({text="",className="",...props})=>{return` 146 146 <button ${objectToProps({className:"gh-button"+(className?" "+className:""),...props})}>${text} 147 </button>`};const setFrameContent=(frame,content)=>{let blob=new Blob([content],{type:"text/html; charset=utf-8"});frame.src=URL.createObjectURL(blob)};const moreMenu=(selector,args)=>{let selectHandler=false;let items=[];if(Array.isArray(args)){items=args}else{items=args.items??[];let onSelect=args.onSelect??false;if(onSelect!==false){selectHandler=onSelect}}if(selectHandler===false){selectHandler=key=>{let item=items.find(i=>i.key==key);const{onSelect :onSelect=()=>{}}=item;onSelect()}}const menu=`147 </button>`};const setFrameContent=(frame,content)=>{let blob=new Blob([content],{type:"text/html; charset=utf-8"});frame.src=URL.createObjectURL(blob)};const moreMenu=(selector,args)=>{let selectHandler=false;let items=[];if(Array.isArray(args)){items=args}else{items=args.items??[];let onSelect=args.onSelect??false;if(onSelect!==false){selectHandler=onSelect}}if(selectHandler===false){selectHandler=key=>{let item=items.find(i=>i.key==key);const{onSelect=()=>{}}=item;onSelect()}}const menu=` 148 148 <div role="menu" class="gh-dropdown-menu" tabindex="0"> 149 149 ${items.filter(i=>i&&true).map(({key,text})=>`<div class="gh-dropdown-menu-item" data-key="${key}">${text}</div>`).join("")} 150 </div>`;const $menu=$(menu);const close=()=>{$menu.remove()};$menu.on("click",".gh-dropdown-menu-item",e=>{selectHandler(e.currentTarget.dataset.key);close()});$menu.on("blur",()=>{close()});const $el=$(selector);$("body").append($menu);const{left,right,top,bottom}=$el[0].getBoundingClientRect();$menu.css({top:Math.min(bottom,window.innerHeight-$menu.height()-20)+"px",left:right-$menu.outerWidth()+"px"});$menu.focus()};const moreMenuAbsolute=(selector,args)=>{let selectHandler=false;let items=[];if(Array.isArray(args)){items=args}else{items=args.items??[];let onSelect=args.onSelect??false;if(onSelect!==false){selectHandler=onSelect}}if(selectHandler===false){selectHandler=key=>{let item=items.find(i=>i.key==key);const{onSelect :onSelect=()=>{}}=item;onSelect()}}const menu=`150 </div>`;const $menu=$(menu);const close=()=>{$menu.remove()};$menu.on("click",".gh-dropdown-menu-item",e=>{selectHandler(e.currentTarget.dataset.key);close()});$menu.on("blur",()=>{close()});const $el=$(selector);$("body").append($menu);const{left,right,top,bottom}=$el[0].getBoundingClientRect();$menu.css({top:Math.min(bottom,window.innerHeight-$menu.height()-20)+"px",left:right-$menu.outerWidth()+"px"});$menu.focus()};const moreMenuAbsolute=(selector,args)=>{let selectHandler=false;let items=[];if(Array.isArray(args)){items=args}else{items=args.items??[];let onSelect=args.onSelect??false;if(onSelect!==false){selectHandler=onSelect}}if(selectHandler===false){selectHandler=key=>{let item=items.find(i=>i.key==key);const{onSelect=()=>{}}=item;onSelect()}}const menu=` 151 151 <div role="menu" class="gh-dropdown-menu absolute" tabindex="0"> 152 152 ${items.filter(i=>i&&true).map(({key,text})=>`<div class="gh-dropdown-menu-item" data-key="${key}">${text}</div>`).join("")} -
groundhogg/tags/4.2.10/assets/js/admin/filters/contacts.js
r3400645 r3422142 1638 1638 _x('Flows', 'noun meaning automation', 'groundhogg')) 1639 1639 1640 registerFilter('funnel_history', 'funnels', 1641 __('Flow History', 'groundhogg'), { 1642 view ({ 1643 status = 'complete', 1644 funnel_id = 0, 1645 step_id = 0, 1646 date_range = 'any', 1647 before, 1648 after, 1649 ...rest 1650 }) { 1651 1652 let prepend 1653 1654 if (funnel_id) { 1655 1656 const funnel = FunnelsStore.get(funnel_id) 1657 const step = funnel.steps.find(s => s.ID === step_id) 1658 1659 prepend = status === 'complete' ? sprintf( 1660 step ? __('Completed %2$s in %1$s', 'groundhogg') : __( 1661 'Completed any step in %1$s', 'groundhogg'), 1662 `<b>${ funnel.data.title }</b>`, 1663 step ? `<b>${ step.data.step_title }</b>` : '') : sprintf( 1664 step ? __('Will complete %2$s in %1$s', 'groundhogg') : __( 1665 'Will complete any step in %1$s', 'groundhogg'), 1666 `<b>${ funnel.data.title }</b>`, 1667 step ? `<b>${ step.data.step_title }</b>` : '') 1668 1669 if (status === 'waiting') { 1670 return prepend 1640 ContactFilterRegistry.registerFilter(createPastDateFilter('funnel_history', __('Flow History', 'groundhogg'), 'funnels', { 1641 display: ({ 1642 funnel_id = false, 1643 step_id = false, 1644 status = 'complete' 1645 }) => { 1646 1647 let text = __('Completed any step in any flow', 'groundhogg') 1648 1649 if (funnel_id) { 1650 1651 const funnel = FunnelsStore.get(funnel_id) 1652 const step = funnel.steps.find(s => s.ID === step_id) 1653 1654 text = status === 'complete' ? sprintf( 1655 step ? __('Completed %2$s in %1$s', 'groundhogg') : __( 1656 'Completed any step in %1$s', 'groundhogg'), 1657 `<b>${ funnel.data.title }</b>`, 1658 step ? `<b>${ step.data.step_title }</b>` : '') : sprintf( 1659 step ? __('Will complete %2$s in %1$s', 'groundhogg') : __( 1660 'Will complete any step in %1$s', 'groundhogg'), 1661 `<b>${ funnel.data.title }</b>`, 1662 step ? `<b>${ step.data.step_title }</b>` : '') 1663 1664 if (status === 'waiting') { 1665 return text 1666 } 1667 } 1668 1669 return text 1670 }, 1671 edit : ({ 1672 funnel_id = false, 1673 step_id = false, 1674 updateFilter, 1675 }) => Fragment([ 1676 ItemPicker({ 1677 id : `select-a-funnel`, 1678 noneSelected: __('Select a flow...', 'groundhogg'), 1679 selected : funnel_id ? { 1680 id : funnel_id, 1681 text: FunnelsStore.get(funnel_id).data.title, 1682 } : [], 1683 multiple : false, 1684 style : { 1685 flexGrow: 1, 1686 }, 1687 fetchOptions: (search) => { 1688 return FunnelsStore.fetchItems({ 1689 search, 1690 }). 1691 then(funnels => funnels.map(({ 1692 ID, 1693 data, 1694 }) => ( { 1695 id : ID, 1696 text: data.title, 1697 } ))) 1698 }, 1699 onChange : item => { 1700 if (!item) { 1701 updateFilter({ 1702 funnel_id: null, 1703 step_id : null, 1704 }, true) 1705 return 1671 1706 } 1672 1707 1673 }1674 else {1675 prepend = __('Completed any step in any flow', 'groundhogg')1676 }1677 1678 return standardActivityDateTitle(prepend, {1679 date_range,1680 before,1681 after,1682 ...rest1683 })1684 },1685 edit ({1686 funnel_id,1687 step_id,1688 date_range,1689 before,1690 after,1691 ...rest1692 }) {1693 1694 return `1695 ${ select({1696 id: 'filter-funnel',1697 name: 'funnel_id',1698 }, FunnelsStore.getItems().1699 map(f => ( {1700 value: f.ID,1701 text: f.data.title,1702 } )), funnel_id) }1703 ${ select({1704 id: 'filter-step',1705 name: 'step_id',1706 }, funnel_id ? FunnelsStore.get(funnel_id).steps.map(s => ( {1707 value: s.ID,1708 text: s.data.step_title,1709 } )) : [], step_id) }1710 ${ standardActivityDateOptions({1711 date_range,1712 before,1713 after,1714 ...rest1715 }) }`1716 },1717 onMount (filter, updateFilter) {1718 funnelPicker('#filter-funnel', false, (items) => {1719 FunnelsStore.itemsFetched(items)1720 }, {}, {1721 placeholder: __('Select a flow', 'groundhogg'),1722 }).on('select2:select', ({ target }) => {1723 1708 updateFilter({ 1724 funnel_id: parseInt($(target).val()),1725 step_id : 0,1709 funnel_id: item.id, 1710 step_id : FunnelsStore.get(item.id).steps[0].ID, 1726 1711 }, true) 1727 }) 1728 1729 $('#filter-step').select2({ 1730 placeholder: __('Select a step or leave empty for any step', 1731 'groundhogg'), 1732 }).on('select2:select', ({ target }) => { 1712 }, 1713 }), 1714 funnel_id ? ItemPicker({ 1715 id : `select-step-from-${ funnel_id }`, 1716 noneSelected: __('Select a step...', 'groundhogg'), 1717 selected : step_id ? { 1718 id : step_id, 1719 text: FunnelsStore.get(funnel_id).steps.find(s => s.ID === step_id).data.step_title, 1720 } : [], 1721 multiple : false, 1722 style : { 1723 flexGrow: 1, 1724 }, 1725 fetchOptions: async (search) => FunnelsStore.get(funnel_id) 1726 .steps 1727 // only actions and triggers can be "completed" 1728 .filter( s => s.data.step_group === 'action' || s.data.step_group === 'benchmark' ) 1729 .map(({ 1730 ID, 1731 data, 1732 }) => ( { 1733 id : ID, 1734 text: data.step_title, 1735 } )) 1736 .filter(opt => opt.text.match(new RegExp(search, 'i'))), 1737 onChange : item => { 1738 if (!item) { 1739 updateFilter({ 1740 step_id: null, 1741 }) 1742 return 1743 } 1744 1733 1745 updateFilter({ 1734 step_id: parseInt($(target).val()),1746 step_id: item.id, 1735 1747 }) 1736 }) 1737 1738 standardActivityDateFilterOnMount(filter, updateFilter) 1739 }, 1740 defaults: { 1741 funnel_id: 0, 1742 step_id : 0, 1743 status : 'complete', ...standardActivityDateDefaults, 1744 }, 1745 preload : ({ funnel_id }) => { 1746 if (funnel_id) { 1747 return FunnelsStore.maybeFetchItem(funnel_id) 1748 } 1749 }, 1750 }) 1748 }, 1749 }) : null, 1750 ]), 1751 preload: ({ funnel_id }) => { 1752 if (funnel_id) { 1753 return FunnelsStore.maybeFetchItem(funnel_id) 1754 } 1755 }, 1756 }, { 1757 funnel_id: 0, 1758 step_id : 0, 1759 status : 'complete', 1760 })) 1761 1762 // registerFilter('funnel_history', 'funnels', 1763 // __('Flow History', 'groundhogg'), { 1764 // view ({ 1765 // status = 'complete', 1766 // funnel_id = 0, 1767 // step_id = 0, 1768 // date_range = 'any', 1769 // before, 1770 // after, 1771 // ...rest 1772 // }) { 1773 // 1774 // let prepend 1775 // 1776 // if (funnel_id) { 1777 // 1778 // const funnel = FunnelsStore.get(funnel_id) 1779 // const step = funnel.steps.find(s => s.ID === step_id) 1780 // 1781 // prepend = status === 'complete' ? sprintf( 1782 // step ? __('Completed %2$s in %1$s', 'groundhogg') : __( 1783 // 'Completed any step in %1$s', 'groundhogg'), 1784 // `<b>${ funnel.data.title }</b>`, 1785 // step ? `<b>${ step.data.step_title }</b>` : '') : sprintf( 1786 // step ? __('Will complete %2$s in %1$s', 'groundhogg') : __( 1787 // 'Will complete any step in %1$s', 'groundhogg'), 1788 // `<b>${ funnel.data.title }</b>`, 1789 // step ? `<b>${ step.data.step_title }</b>` : '') 1790 // 1791 // if (status === 'waiting') { 1792 // return prepend 1793 // } 1794 // 1795 // } 1796 // else { 1797 // prepend = __('Completed any step in any flow', 'groundhogg') 1798 // } 1799 // 1800 // return standardActivityDateTitle(prepend, { 1801 // date_range, 1802 // before, 1803 // after, 1804 // ...rest 1805 // }) 1806 // }, 1807 // edit ({ 1808 // funnel_id, 1809 // step_id, 1810 // date_range, 1811 // before, 1812 // after, 1813 // ...rest 1814 // }) { 1815 // 1816 // return ` 1817 // ${ select({ 1818 // id: 'filter-funnel', 1819 // name: 'funnel_id', 1820 // }, FunnelsStore.getItems(). 1821 // map(f => ( { 1822 // value: f.ID, 1823 // text: f.data.title, 1824 // } )), funnel_id) } 1825 // ${ select({ 1826 // id: 'filter-step', 1827 // name: 'step_id', 1828 // }, funnel_id ? FunnelsStore.get(funnel_id).steps.map(s => ( { 1829 // value: s.ID, 1830 // text: s.data.step_title, 1831 // } )) : [], step_id) } 1832 // ${ standardActivityDateOptions({ 1833 // date_range, 1834 // before, 1835 // after, 1836 // ...rest 1837 // }) }` 1838 // }, 1839 // onMount (filter, updateFilter) { 1840 // funnelPicker('#filter-funnel', false, (items) => { 1841 // FunnelsStore.itemsFetched(items) 1842 // }, {}, { 1843 // placeholder: __('Select a flow', 'groundhogg'), 1844 // }).on('select2:select', ({ target }) => { 1845 // updateFilter({ 1846 // funnel_id: parseInt($(target).val()), 1847 // step_id: 0, 1848 // }, true) 1849 // }) 1850 // 1851 // $('#filter-step').select2({ 1852 // placeholder: __('Select a step or leave empty for any step', 1853 // 'groundhogg'), 1854 // }).on('select2:select', ({ target }) => { 1855 // updateFilter({ 1856 // step_id: parseInt($(target).val()), 1857 // }) 1858 // }) 1859 // 1860 // standardActivityDateFilterOnMount(filter, updateFilter) 1861 // }, 1862 // defaults: { 1863 // funnel_id: 0, 1864 // step_id : 0, 1865 // status : 'complete', ...standardActivityDateDefaults, 1866 // }, 1867 // preload : ({ funnel_id }) => { 1868 // if (funnel_id) { 1869 // return FunnelsStore.maybeFetchItem(funnel_id) 1870 // } 1871 // }, 1872 // }) 1751 1873 1752 1874 registerFilterGroup('broadcast', -
groundhogg/tags/4.2.10/assets/js/admin/filters/contacts.min.js
r3400645 r3422142 49 49 ${filterCount(rest)} 50 50 51 ${standardActivityDateOptions(rest)}`},onMount(filter,updateFilter){linkPicker("#filter-link").on("change input blur",({target})=>{updateFilter({link:target.value})});filterCountOnMount(updateFilter);standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults,...filterCountDefaults,link:""}});registerFilter("logged_in","activity",__("Logged In","groundhogg"),{view(filter){let prefix=filterCountTitle(`<b>${__("Logged in","groundhogg")}</b>`,filter);return standardActivityDateTitle(prefix,filter)},edit(filter){return filterCount(filter)+standardActivityDateOptions(filter)},onMount(filter,updateFilter){filterCountOnMount(updateFilter);standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults,...filterCountDefaults}});registerFilter("logged_out","activity",__("Logged Out","groundhogg"),{view(filter){return standardActivityDateTitle(filterCountTitle(`<b>${__("Logged out","groundhogg")}</b>`,filter),filter)},edit(filter){return filterCount(filter)+standardActivityDateOptions(filter)},onMount(filter,updateFilter){filterCountOnMount(updateFilter);standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...filterCountDefaults,...standardActivityDateDefaults}});registerFilter("not_logged_in","activity",__("Has Not Logged In","groundhogg"),{view(filter){return standardActivityDateTitle(`<b>${__("Has not logged in","groundhogg")}</b>`,filter)},edit(filter){return standardActivityDateOptions(filter)},onMount(filter,updateFilter){standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults}});registerFilter("was_active","activity",__("Was Active","groundhogg"),{view(filter){return standardActivityDateTitle(`<b>${__("Was active","groundhogg")}</b>`,filter)},edit(filter){return standardActivityDateOptions(filter)},onMount(filter,updateFilter){standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults}});registerFilter("was_not_active","activity",__("Was Inactive","groundhogg"),{view(filter){return standardActivityDateTitle(`<b>${__("Was inactive","groundhogg")}</b>`,filter)},edit(filter){return standardActivityDateOptions(filter)},onMount(filter,updateFilter){standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults}});registerFilterGroup("funnels",_x("Flows","noun meaning automation","groundhogg"));registerFilter("funnel_history","funnels",__("Flow History","groundhogg"),{view({status="complete",funnel_id=0,step_id=0,date_range="any",before,after,...rest}){let prepend;if(funnel_id){const funnel=FunnelsStore.get(funnel_id);const step=funnel.steps.find(s=>s.ID===step_id);prepend=status==="complete"?sprintf(step?__("Completed %2$s in %1$s","groundhogg"):__("Completed any step in %1$s","groundhogg"),`<b>${funnel.data.title}</b>`,step?`<b>${step.data.step_title}</b>`:""):sprintf(step?__("Will complete %2$s in %1$s","groundhogg"):__("Will complete any step in %1$s","groundhogg"),`<b>${funnel.data.title}</b>`,step?`<b>${step.data.step_title}</b>`:"");if(status==="waiting"){return prepend}}else{prepend=__("Completed any step in any flow","groundhogg")}return standardActivityDateTitle(prepend,{date_range:date_range,before:before,after:after,...rest})},edit({funnel_id,step_id,date_range,before,after,...rest}){return` 52 ${select({id:"filter-funnel",name:"funnel_id"},FunnelsStore.getItems().map(f=>({value:f.ID,text:f.data.title})),funnel_id)} 53 ${select({id:"filter-step",name:"step_id"},funnel_id?FunnelsStore.get(funnel_id).steps.map(s=>({value:s.ID,text:s.data.step_title})):[],step_id)} 54 ${standardActivityDateOptions({date_range:date_range,before:before,after:after,...rest})}`},onMount(filter,updateFilter){funnelPicker("#filter-funnel",false,items=>{FunnelsStore.itemsFetched(items)},{},{placeholder:__("Select a flow","groundhogg")}).on("select2:select",({target})=>{updateFilter({funnel_id:parseInt($(target).val()),step_id:0},true)});$("#filter-step").select2({placeholder:__("Select a step or leave empty for any step","groundhogg")}).on("select2:select",({target})=>{updateFilter({step_id:parseInt($(target).val())})});standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{funnel_id:0,step_id:0,status:"complete",...standardActivityDateDefaults},preload:({funnel_id})=>{if(funnel_id){return FunnelsStore.maybeFetchItem(funnel_id)}}});registerFilterGroup("broadcast",_x("Broadcast","noun meaning email blast","groundhogg"));registerFilter("broadcast_received","broadcast",__("Received Broadcast","groundhogg"),{view({broadcast_id,status="complete"}){if(!broadcast_id){return __("Received any broadcast","groundhogg")}const broadcast=BroadcastsStore.get(broadcast_id);return status==="complete"?sprintf(broadcast?__("Received %1$s on %2$s","groundhogg"):__("Will receive a broadcast","groundhogg"),`<b>${broadcast.object.data.title}</b>`,`<b>${formatDateTime(broadcast.data.send_time*1e3)}</b>`):sprintf(broadcast?__("Will receive %1$s on %2$s","groundhogg"):__("Received a broadcast","groundhogg"),`<b>${broadcast.object.data.title}</b>`,`<b>${formatDateTime(broadcast.data.send_time*1e3)}</b>`)},edit({broadcast_id}){return select({id:"filter-broadcast",name:"broadcast_id"},BroadcastsStore.getItems().map(b=>({value:b.ID,text:`${b.object.data.title} (${b.date_sent_pretty})`})),broadcast_id)},onMount(filter,updateFilter){broadcastPicker("#filter-broadcast",false,items=>{BroadcastsStore.itemsFetched(items)},{},{placeholder:__("Select a broadcast","groundhogg")}).on("select2:select",({target})=>{updateFilter({broadcast_id:parseInt($(target).val())})})},defaults:{broadcast_id:0,status:"complete"},preload:({broadcast_id})=>{if(broadcast_id){return BroadcastsStore.maybeFetchItem(broadcast_id)}}});registerFilter("broadcast_opened","broadcast",__("Opened Broadcast","groundhogg"),{view({broadcast_id}){if(!broadcast_id){return __("Opened any broadcast","groundhogg")}const broadcast=BroadcastsStore.get(broadcast_id);return sprintf(broadcast?__("Opened %1$s after %2$s","groundhogg"):__("Will receive a broadcast","groundhogg"),`<b>${broadcast.object.data.title}</b>`,`<b>${formatDateTime(broadcast.data.send_time*1e3)}</b>`)},edit({broadcast_id}){return select({id:"filter-broadcast",name:"broadcast_id"},BroadcastsStore.getItems().map(b=>({value:b.ID,text:`${b.object.data.title} (${b.date_sent_pretty})`})),broadcast_id)},onMount(filter,updateFilter){broadcastPicker("#filter-broadcast",false,items=>{BroadcastsStore.itemsFetched(items)},{},{placeholder:__("Select a broadcast","groundhogg")}).on("select2:select",({target})=>{updateFilter({broadcast_id:parseInt($(target).val())})})},defaults:{broadcast_id:0},preload:({broadcast_id})=>{if(broadcast_id){return BroadcastsStore.maybeFetchItem(broadcast_id)}}});registerFilter("broadcast_link_clicked","broadcast",__("Broadcast Link Clicked","groundhogg"),{view({broadcast_id,link}){if(!broadcast_id&&!link){return __("Clicked any link in any broadcast","groundhogg")}if(!broadcast_id&&link){return sprintf(__("Clicked %s in any broadcast","groundhogg"),bold(link))}const broadcast=BroadcastsStore.get(broadcast_id);if(broadcast_id&&!link){return sprintf(__("Clicked any link in %1$s after %2$s","groundhogg"),bold(broadcast.object.data.title),bold(formatDateTime(broadcast.data.send_time*1e3)))}return sprintf(__("Clicked %1$s in %2$s after %3$s","groundhogg"),bold(link),bold(broadcast.object.data.title),bold(formatDateTime(broadcast.data.send_time*1e3)))},edit({broadcast_id,link}){return` 51 ${standardActivityDateOptions(rest)}`},onMount(filter,updateFilter){linkPicker("#filter-link").on("change input blur",({target})=>{updateFilter({link:target.value})});filterCountOnMount(updateFilter);standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults,...filterCountDefaults,link:""}});registerFilter("logged_in","activity",__("Logged In","groundhogg"),{view(filter){let prefix=filterCountTitle(`<b>${__("Logged in","groundhogg")}</b>`,filter);return standardActivityDateTitle(prefix,filter)},edit(filter){return filterCount(filter)+standardActivityDateOptions(filter)},onMount(filter,updateFilter){filterCountOnMount(updateFilter);standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults,...filterCountDefaults}});registerFilter("logged_out","activity",__("Logged Out","groundhogg"),{view(filter){return standardActivityDateTitle(filterCountTitle(`<b>${__("Logged out","groundhogg")}</b>`,filter),filter)},edit(filter){return filterCount(filter)+standardActivityDateOptions(filter)},onMount(filter,updateFilter){filterCountOnMount(updateFilter);standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...filterCountDefaults,...standardActivityDateDefaults}});registerFilter("not_logged_in","activity",__("Has Not Logged In","groundhogg"),{view(filter){return standardActivityDateTitle(`<b>${__("Has not logged in","groundhogg")}</b>`,filter)},edit(filter){return standardActivityDateOptions(filter)},onMount(filter,updateFilter){standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults}});registerFilter("was_active","activity",__("Was Active","groundhogg"),{view(filter){return standardActivityDateTitle(`<b>${__("Was active","groundhogg")}</b>`,filter)},edit(filter){return standardActivityDateOptions(filter)},onMount(filter,updateFilter){standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults}});registerFilter("was_not_active","activity",__("Was Inactive","groundhogg"),{view(filter){return standardActivityDateTitle(`<b>${__("Was inactive","groundhogg")}</b>`,filter)},edit(filter){return standardActivityDateOptions(filter)},onMount(filter,updateFilter){standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults}});registerFilterGroup("funnels",_x("Flows","noun meaning automation","groundhogg"));ContactFilterRegistry.registerFilter(createPastDateFilter("funnel_history",__("Flow History","groundhogg"),"funnels",{display:({funnel_id=false,step_id=false,status="complete"})=>{let text=__("Completed any step in any flow","groundhogg");if(funnel_id){const funnel=FunnelsStore.get(funnel_id);const step=funnel.steps.find(s=>s.ID===step_id);text=status==="complete"?sprintf(step?__("Completed %2$s in %1$s","groundhogg"):__("Completed any step in %1$s","groundhogg"),`<b>${funnel.data.title}</b>`,step?`<b>${step.data.step_title}</b>`:""):sprintf(step?__("Will complete %2$s in %1$s","groundhogg"):__("Will complete any step in %1$s","groundhogg"),`<b>${funnel.data.title}</b>`,step?`<b>${step.data.step_title}</b>`:"");if(status==="waiting"){return text}}return text},edit:({funnel_id=false,step_id=false,updateFilter})=>Fragment([ItemPicker({id:`select-a-funnel`,noneSelected:__("Select a flow...","groundhogg"),selected:funnel_id?{id:funnel_id,text:FunnelsStore.get(funnel_id).data.title}:[],multiple:false,style:{flexGrow:1},fetchOptions:search=>{return FunnelsStore.fetchItems({search:search}).then(funnels=>funnels.map(({ID,data})=>({id:ID,text:data.title})))},onChange:item=>{if(!item){updateFilter({funnel_id:null,step_id:null},true);return}updateFilter({funnel_id:item.id,step_id:FunnelsStore.get(item.id).steps[0].ID},true)}}),funnel_id?ItemPicker({id:`select-step-from-${funnel_id}`,noneSelected:__("Select a step...","groundhogg"),selected:step_id?{id:step_id,text:FunnelsStore.get(funnel_id).steps.find(s=>s.ID===step_id).data.step_title}:[],multiple:false,style:{flexGrow:1},fetchOptions:async search=>FunnelsStore.get(funnel_id).steps.filter(s=>s.data.step_group==="action"||s.data.step_group==="benchmark").map(({ID,data})=>({id:ID,text:data.step_title})).filter(opt=>opt.text.match(new RegExp(search,"i"))),onChange:item=>{if(!item){updateFilter({step_id:null});return}updateFilter({step_id:item.id})}}):null]),preload:({funnel_id})=>{if(funnel_id){return FunnelsStore.maybeFetchItem(funnel_id)}}},{funnel_id:0,step_id:0,status:"complete"}));registerFilterGroup("broadcast",_x("Broadcast","noun meaning email blast","groundhogg"));registerFilter("broadcast_received","broadcast",__("Received Broadcast","groundhogg"),{view({broadcast_id,status="complete"}){if(!broadcast_id){return __("Received any broadcast","groundhogg")}const broadcast=BroadcastsStore.get(broadcast_id);return status==="complete"?sprintf(broadcast?__("Received %1$s on %2$s","groundhogg"):__("Will receive a broadcast","groundhogg"),`<b>${broadcast.object.data.title}</b>`,`<b>${formatDateTime(broadcast.data.send_time*1e3)}</b>`):sprintf(broadcast?__("Will receive %1$s on %2$s","groundhogg"):__("Received a broadcast","groundhogg"),`<b>${broadcast.object.data.title}</b>`,`<b>${formatDateTime(broadcast.data.send_time*1e3)}</b>`)},edit({broadcast_id}){return select({id:"filter-broadcast",name:"broadcast_id"},BroadcastsStore.getItems().map(b=>({value:b.ID,text:`${b.object.data.title} (${b.date_sent_pretty})`})),broadcast_id)},onMount(filter,updateFilter){broadcastPicker("#filter-broadcast",false,items=>{BroadcastsStore.itemsFetched(items)},{},{placeholder:__("Select a broadcast","groundhogg")}).on("select2:select",({target})=>{updateFilter({broadcast_id:parseInt($(target).val())})})},defaults:{broadcast_id:0,status:"complete"},preload:({broadcast_id})=>{if(broadcast_id){return BroadcastsStore.maybeFetchItem(broadcast_id)}}});registerFilter("broadcast_opened","broadcast",__("Opened Broadcast","groundhogg"),{view({broadcast_id}){if(!broadcast_id){return __("Opened any broadcast","groundhogg")}const broadcast=BroadcastsStore.get(broadcast_id);return sprintf(broadcast?__("Opened %1$s after %2$s","groundhogg"):__("Will receive a broadcast","groundhogg"),`<b>${broadcast.object.data.title}</b>`,`<b>${formatDateTime(broadcast.data.send_time*1e3)}</b>`)},edit({broadcast_id}){return select({id:"filter-broadcast",name:"broadcast_id"},BroadcastsStore.getItems().map(b=>({value:b.ID,text:`${b.object.data.title} (${b.date_sent_pretty})`})),broadcast_id)},onMount(filter,updateFilter){broadcastPicker("#filter-broadcast",false,items=>{BroadcastsStore.itemsFetched(items)},{},{placeholder:__("Select a broadcast","groundhogg")}).on("select2:select",({target})=>{updateFilter({broadcast_id:parseInt($(target).val())})})},defaults:{broadcast_id:0},preload:({broadcast_id})=>{if(broadcast_id){return BroadcastsStore.maybeFetchItem(broadcast_id)}}});registerFilter("broadcast_link_clicked","broadcast",__("Broadcast Link Clicked","groundhogg"),{view({broadcast_id,link}){if(!broadcast_id&&!link){return __("Clicked any link in any broadcast","groundhogg")}if(!broadcast_id&&link){return sprintf(__("Clicked %s in any broadcast","groundhogg"),bold(link))}const broadcast=BroadcastsStore.get(broadcast_id);if(broadcast_id&&!link){return sprintf(__("Clicked any link in %1$s after %2$s","groundhogg"),bold(broadcast.object.data.title),bold(formatDateTime(broadcast.data.send_time*1e3)))}return sprintf(__("Clicked %1$s in %2$s after %3$s","groundhogg"),bold(link),bold(broadcast.object.data.title),bold(formatDateTime(broadcast.data.send_time*1e3)))},edit({broadcast_id,link}){return` 55 52 ${select({id:"filter-broadcast",name:"broadcast_id"},BroadcastsStore.getItems().map(b=>({value:b.ID,text:`${b.object.data.title} (${b.date_sent_pretty})`})),broadcast_id)} 56 53 -
groundhogg/tags/4.2.10/assets/js/admin/formatting.js
r3264477 r3422142 4 4 5 5 // return wp.date.format( 'h:i a', time ) 6 console.log(time);7 6 8 7 return Intl.DateTimeFormat(Groundhogg.locale, { -
groundhogg/tags/4.2.10/assets/js/admin/formatting.min.js
r3264477 r3422142 1 (()=>{const formatTime=time=>{ console.log(time);return Intl.DateTimeFormat(Groundhogg.locale,{timeStyle:"short"}).format(new Date(time))};const formatDateTime=(date,opts)=>{return Intl.DateTimeFormat(Groundhogg.locale,{timeStyle:"short",dateStyle:"medium",...opts}).format(new Date(date))};const formatDate=date=>{return Intl.DateTimeFormat(Groundhogg.locale,{dateStyle:"medium",timeZone:"UTC"}).format(new Date(date))};const formatNumber=num=>{return Intl.NumberFormat(Groundhogg.locale,{}).format(num)};Groundhogg.formatting={formatTime:formatTime,formatDate:formatDate,formatDateTime:formatDateTime,formatNumber:formatNumber}})();1 (()=>{const formatTime=time=>{return Intl.DateTimeFormat(Groundhogg.locale,{timeStyle:"short"}).format(new Date(time))};const formatDateTime=(date,opts)=>{return Intl.DateTimeFormat(Groundhogg.locale,{timeStyle:"short",dateStyle:"medium",...opts}).format(new Date(date))};const formatDate=date=>{return Intl.DateTimeFormat(Groundhogg.locale,{dateStyle:"medium",timeZone:"UTC"}).format(new Date(date))};const formatNumber=num=>{return Intl.NumberFormat(Groundhogg.locale,{}).format(num)};Groundhogg.formatting={formatTime:formatTime,formatDate:formatDate,formatDateTime:formatDateTime,formatNumber:formatNumber}})(); -
groundhogg/tags/4.2.10/assets/js/admin/make-el.js
r3395861 r3422142 490 490 onChange: e => onCellChange(rowIndex, cellIndex, e.target.value), 491 491 setValue: value => onCellChange(rowIndex, cellIndex, value), 492 onCellChange 492 493 }, row)), 493 494 // Sortable Handle -
groundhogg/tags/4.2.10/assets/js/admin/make-el.min.js
r3395861 r3422142 2 2 <span class="on">${onLabel}</span> 3 3 <span class="off">${offLabel}</span> 4 `])};const Div=(attributes={},children=[])=>{return makeEl("div",attributes,children)};const Nav=(attributes={},children=[])=>{return makeEl("nav",attributes,children)};const Dashicon=(icon,children=null)=>{return makeEl("span",{className:`dashicons dashicons-${icon}`},children)};const Fragment=(children,atts={})=>{return makeEl("fragment",atts,children)};const Span=(attributes={},children=[])=>{return makeEl("span",attributes,children)};const Label=(attributes={},children=[])=>{return makeEl("label",attributes,children)};const InputRepeater=({id="",onChange=()=>{},rows=[],cells=[],sortable=false,fillRow=()=>Array(cells.length).fill(""),maxRows=0})=>{const handleChange=rows=>{onChange(rows);morphdom(document.getElementById(id),Repeater())};const removeRow=rowIndex=>{rows.splice(rowIndex,1);handleChange(rows)};const addRow=()=>{rows.push(fillRow());handleChange(rows)};const onCellChange=(rowIndex,cellIndex,value)=>{rows[rowIndex][cellIndex]=value;handleChange(rows)};const RepeaterRow=(row,rowIndex)=>Div({className:"gh-input-repeater-row",dataRow:rowIndex},[...cells.map((cellCallback,cellIndex)=>cellCallback({id:`${id}-cell-${rowIndex}-${cellIndex}`,name:`${id}[${rowIndex}][${cellIndex}]`,value:row[cellIndex]??"",dataRow:rowIndex,dataCell:cellIndex,onChange:e=>onCellChange(rowIndex,cellIndex,e.target.value),setValue:value=>onCellChange(rowIndex,cellIndex,value) },row)),sortable?makeEl("span",{className:"handle",dataRow:rowIndex},Dashicon("move")):null,Button({className:"gh-button dashicon remove-row",dataRow:rowIndex,type:"button",onClick:e=>removeRow(rowIndex)},Dashicon("no-alt"))]);const Repeater=()=>Div({id:id,className:"gh-input-repeater",onCreate:el=>{if(!sortable){return}$(el).sortable({handle:".handle",update:(e,ui)=>{let $row=$(ui.item);let oldIndex=parseInt($row.data("row"));let curIndex=$row.index();let row=rows[oldIndex];rows.splice(oldIndex,1);rows.splice(curIndex,0,row);onChange(rows)}})}},[...rows.map((row,i)=>RepeaterRow(row,i)),maxRows===0||rows.length<maxRows?Div({className:"gh-input-repeater-row-add"},[`<div class="spacer"></div>`,Button({id:`${id}-add-row`,className:"add-row gh-button dashicon",onClick:e=>addRow(),type:"button"},Dashicon("plus-alt2"))]):null]);return Repeater()};const InputWithReplacements=({inputCallback=Input,...attributes})=>{return Div({className:"input-wrap"},[inputCallback(attributes),Button({className:"replacements-picker-start gh-button dashicon"},Dashicon("admin-users"))])};const Table=(atts,children)=>makeEl("table",atts,children);const THead=(atts,children)=>makeEl("thead",atts,children);const TBody=(atts,children)=>makeEl("tbody",atts,children);const TFoot=(atts,children)=>makeEl("tfoot",atts,children);const Tr=(atts,children)=>makeEl("tr",atts,children);const Td=(atts,children)=>makeEl("td",atts,children);const Th=(atts,children)=>makeEl("th",atts,children);const Modal=({dialogClasses="",className="",onOpen=()=>{},onClose=()=>{},width,closeButton=true,closeOnOverlayClick=true,overlay=true},children)=>{const Dialog=({header=null,content=null})=>Div({className:`gh-modal-dialog ${dialogClasses}`,style:{width:width}},[header,Div({className:"gh-modal-dialog-content"},content),closeButton&&!header?Button({className:"dashicon-button gh-modal-button-close-top gh-modal-button-close",onClick:e=>{close()}},Dashicon("no-alt")):null]);let modal=Div({className:`gh-modal ${className}`,tabindex:0},[overlay?Div({className:"gh-modal-overlay",onClick:e=>{if(closeOnOverlayClick){close()}}}):null,Dialog({header:null,content:null})]);const close=()=>{onClose(modal);modal.remove()};const morph=(args={})=>{let content=getContent();let header=content.querySelector(".modal-header");morphdom(modal.querySelector(".gh-modal-dialog"),Dialog({header:header,content:content}),args)};const getContent=()=>maybeCall(children,{close:close,modal:modal,morph:morph});document.body.appendChild(modal);morph();onOpen({modal:modal,close:close,morph:morph});if(!modal.contains(document.activeElement)){modal.focus()}return modal};const ModalWithHeader=({header="",...args},children)=>Modal(args,methods=>Div({},[Div({className:"gh-header modal-header"},[MakeEl.H3({},header),MakeEl.Button({className:"gh-button icon secondary text",onClick:methods.close},MakeEl.Dashicon("no-alt"))]),maybeCall(children,methods)]));const ModalFrame=({onOpen=()=>{},onClose=()=>{},frameAttributes={},closeOnOverlayClick=true,closeOnEscape=true},children)=>{let modal=Div({className:"gh-modal",tabindex:0,onKeydown:e=>{if(closeOnEscape){if(e.key==="Esc"||e.key==="Escape"){close()}}}},[Div({className:"gh-modal-overlay",onClick:e=>{if(closeOnOverlayClick){close()}}}),Div({className:`gh-modal-frame`,...frameAttributes},[])]);const close=()=>{onClose();modal.remove()};modal.querySelector(".gh-modal-frame").appendChild(Fragment(maybeCall(children,{close:close})));document.body.appendChild(modal);onOpen({close:close});modal.focus();return modal};const MiniModal=({selector="",target=null,from="right",dialogClasses="",onOpen=()=>{},onClose=()=>{},closeOnFocusout=true},children)=>{let modal=Div({className:"gh-modal mini gh-panel",tabindex:0,onFocusout:e=>{if(closeOnFocusout){if(!e.relatedTarget||!clickedIn(e.relatedTarget,".gh-modal.mini")){setTimeout(()=>{if(!clickedIn(document.activeElement,".gh-modal.mini")){close()}},10)}}},onCreate:el=>{el.focus()}},Div({className:`gh-modal-dialog ${dialogClasses}`},[Button({className:"dashicon-button gh-modal-button-close-top gh-modal-button-close",onClick:e=>{close()}},Dashicon("no-alt"))]));const close=()=>{onClose();modal.remove()};modal.querySelector(".gh-modal-dialog").appendChild(Fragment(maybeCall(children,{close:close})));document.body.appendChild(modal);onOpen();let targetElement=selector&&target===null?document.querySelector(selector):target;let{right,left,bottom,top}=targetElement.getBoundingClientRect();let{width,height}=modal.getBoundingClientRect();switch(from){case"left":modal.style.left=left+"px";break;case"right":modal.style.left=right-width+"px";break}if(top+height>window.innerHeight){modal.style.top=window.innerHeight-height-20+"px"}else{modal.style.top=top+"px"}modal.focus();return modal};const Autocomplete=({fetchResults=async search=>{},onInput,...attributes})=>{let timeout;const State={pointer:0,results:[],input:null};const setValue=()=>{let item=State.results[State.pointer];State.input.value=item.id;State.input.dispatchEvent(new Event("change"));closeResults()};const updateResults=()=>{if(!State.results.length){closeResults();return}let resultsContainer=document.querySelector(".gh-autocomplete-results");let newResults=Results();if(!resultsContainer){document.body.appendChild(newResults)}else{morphdom(resultsContainer,newResults)}};const closeResults=()=>{let resultsContainer=document.querySelector(".gh-autocomplete-results");if(resultsContainer){resultsContainer.remove()}};const Results=()=>{const{results,input}=State;let{height,width,top,left}=input.getBoundingClientRect();return Div({className:"gh-autocomplete-results",style:{zIndex:999999,top:`${top+height}px`,left:`${left}px`,width:`${width}px`}},results.map(({id,text},index)=>makeEl("a",{className:`${index===State.pointer?"pointer":""}`,href:id,onClick:e=>{e.preventDefault();setValue()},onMouseenter:e=>{State.pointer=[...e.target.parentNode.children].indexOf(e.target);updateResults()}},text)))};return Input({...attributes,onFocusout:e=>{const input=e.target;input.classList.remove("has-results");if(e.relatedTarget&&clickedIn(e.relatedTarget,"a.pointer")){setValue()}closeResults()},onKeydown:e=>{const input=e.target;switch(e.key){case"Esc":case"Escape":e.preventDefault();closeResults();return;case"Down":case"ArrowDown":e.preventDefault();if(State.pointer<State.results.length){State.pointer++}break;case"Up":case"ArrowUp":e.preventDefault();if(State.pointer>0){State.pointer--}break;case"Enter":e.preventDefault();setValue();break;default:return}updateResults()},onInput:e=>{if(timeout){clearTimeout(timeout)}timeout=setTimeout(async()=>{const input=e.target;let search=input.value;State.results=await fetchResults(search);State.input=input;State.pointer=0;updateResults();input.classList.add("gh-autocomplete","has-results")},500);onInput(e)}})};const Ellipses=(content,atts={})=>Span({...atts,onCreate:el=>{let ellipses="";let count=0;let interval=setInterval(()=>{if(!el.parentNode){clearInterval(interval);return}count=(count+1)%4;ellipses=".".repeat(count);el.textContent=content+ellipses},500)}},content+"...");const ItemPicker=({id="",label="",placeholder="Type to search...",fetchOptions=(search,resolve)=>{},selected=[],onChange=()=>{},onSelect=()=>{},onCreate=()=>{},onUnselect=()=>{},createOption=val=>Promise.resolve({id:val,text:val}),tags=false,noneSelected="Any",isValidSelection=string=>Boolean(string),multiple=true,clearable=true,...attributes})=>{const state=Groundhogg.createState({search:"",searching:false,choosing:false,options:[],focused:false,morphing:false,clicked:false});const optionsVisible=()=>{return multiple?state.focused&&(state.searching||state.options.length||tags&&isValidSelection(state.search)):state.focused};if(!multiple&&!Array.isArray(selected)){selected=[selected]}let timeout;const setState=(newState,trigger)=>{state.set(newState);morph()};const handleOnChange=selected=>{if(timeout){clearTimeout(timeout)}if(multiple){onChange(selected);return}if(!selected.length){onChange(null);return}onChange(selected[0])};const morph=()=>{if(state.morphing){return}state.set({morphing:true});morphdom(document.getElementById(id),Render());state.set({morphing:false})};const focusSearch=()=>document.getElementById(id)?.querySelector(`input[type=search]`)?.focus();const focusPicker=()=>document.getElementById(id)?.focus();const focusParent=()=>document.getElementById(id)?.parentElement.focus();const handleCreateOption=value=>{state.options.unshift({id:value,text:value,create:true});handleSelectOption(value)};const handleSelectOption=async id=>{let option={...state.options.find(opt=>opt.id==id)};if(option.create){option.text=option.id}if(multiple){selected.push(option)}else{selected=[option]}if(option.create){await createOption(option.id).then(opt=>{selected=selected.map(item=>item.id==id?opt:item);option=opt})}onSelect(option);handleOnChange(selected);if(!multiple){state.set({focused:false})}setState({search:""});morph();if(multiple){focusSearch()}else{focusPicker()}};const handleUnselectOption=id=>{let opt=selected.find(opt=>opt.id===id);selected=selected.filter(opt=>opt.id!=id);onUnselect(opt);handleOnChange(selected);morph();if(multiple){focusSearch()}};const itemPickerItem=({id,text},index)=>{return Div({className:`gh-picker-item ${isValidSelection(id)?"":"is-invalid"}`,id:`item-${id}-${index}`},[Span({className:"gh-picker-item-text"},text),selected.length>1||clearable?Span({id:`delete-${id}-${index}`,className:"gh-picker-item-delete",tabindex:"0",dataId:id,onClick:e=>{handleUnselectOption(id)}},"×"):null])};const itemPickerOption=({id,text},index)=>{return Div({className:"gh-picker-option",dataId:id,tabindex:"0",id:`option-${index}-${id}`,onClick:e=>{handleSelectOption(id)}},text)};const itemPickerOptions=()=>{let picker=document.getElementById(id);let style={};if(picker){const{left,right,top,bottom,width}=picker.getBoundingClientRect();let maxHeight=window.innerHeight-bottom-20;if(maxHeight>100){style.top=bottom+"px";style.left=left+"px";style.width=width+"px";style.maxHeight=maxHeight+"px"}else{style.bottom=window.innerHeight-top+"px";style.left=left+"px";style.width=width+"px";style.maxHeight=top-20+"px"}}state.options=state.options.filter(opt=>!opt.create);if(!state.searching&&tags&&isValidSelection(state.search)){if(!state.options.find(opt=>opt.id==state.search||opt.text==state.search)){state.options.unshift({id:state.search,text:`Add "${state.search}"`,create:true})}}let options=state.options.filter(opt=>!selected.some(_opt=>opt.id==_opt.id));return Div({className:"gh-picker-options",style:style,onCreate:el=>{setTimeout(()=>{let picker=document.getElementById(id);let optionsContainer=picker.querySelector(".gh-picker-options");const{left,right,top,bottom,width}=picker.getBoundingClientRect();let maxHeight=window.innerHeight-bottom-20;if(maxHeight>100){optionsContainer.style.top=bottom+"px";optionsContainer.style.left=left+"px";optionsContainer.style.width=width+"px";optionsContainer.style.maxHeight=maxHeight+"px"}else{optionsContainer.style.bottom=window.innerHeight-top+"px";optionsContainer.style.left=left+"px";optionsContainer.style.width=width+"px";optionsContainer.style.maxHeight=top-20+"px"}if(!multiple){focusSearch()}},0)}},[multiple||!selected.length?null:SearchInput(),state.searching?Div({className:"gh-picker-no-options"},Ellipses(wp.i18n.__("Searching"))):null,...options.map((opt,i)=>itemPickerOption(opt,i)),options.length||state.searching?null:Div({className:"gh-picker-no-options"},"No results found.")])};const startSearch=search=>{setState({search:search,searching:true},"start search");if(timeout){clearTimeout(timeout)}timeout=setTimeout(()=>{fetchOptions(search).then(options=>{if(search!==state.search){return}setState({searching:false,options:options},"options fetched")})},500)};const SearchInput=()=>Input({className:"gh-picker-search",value:state.search,name:"search",type:"search",autocomplete:"off",id:`${id}-search-input`,placeholder:selected.length?placeholder:noneSelected,onInput:e=>startSearch(e.target.value),onFocus:e=>{startSearch(e.target.value)},onKeydown:e=>{if(tags){if(e.key!=="Enter"&&e.key!==","){return}handleCreateOption(e.target.value)}}});const Render=()=>Div({id:id,className:`gh-picker-container`,tabindex:"0",...attributes},Div({id:`${id}-picker`,className:`gh-picker ${optionsVisible()?"options-visible":""}`,tabindex:"0",onKeydown:e=>{if(e.key==="Escape"){setState({searching:false,focused:false});morph()}},onCreate:el=>{el.addEventListener("focusout",e=>{setTimeout(()=>{if(state.morphing||document.getElementById(id).contains(document.activeElement)){return}setState({search:"",options:[],searching:false,focused:false},"picker focusout")},10)});el.addEventListener("focusin",e=>{if(state.focused){return}setState({focused:true},"picker focused")})}},[Div({className:`gh-picker-selected ${multiple?"multiple":"single"}`},[selected.length&&label?Span({className:"gh-picker-label"},label):null,...selected.map((item,i)=>itemPickerItem(item,i)),multiple||!selected.length?SearchInput():null]),optionsVisible()?itemPickerOptions():null]));return Render()};const InputGroup=inputs=>Div({className:"gh-input-group"},inputs);const Iframe=({onCreate=()=>{},...attributes},content=null)=>{let blob=new Blob([content],{type:"text/html; charset=utf-8"});let src=URL.createObjectURL(blob);return makeEl("iframe",{...attributes,src:src})};const ToolTip=(content,position="bottom")=>{return Div({className:`gh-tooltip ${position}`},content)};const ButtonToggle=({id="",options=[],selected="",onChange=value=>{}})=>{const render=()=>Div({id:id,className:"gh-input-group"},options.map(opt=>ButtonOption(opt)));const ButtonOption=option=>Button({id:`${id}-opt-${option.id}`,className:`gh-button gh-button small ${selected===option.id?"dark":"grey"}`,onClick:e=>{selected=option.id;morphdom(document.getElementById(id),render());onChange(option.id)}},[option.text,option.tooltip?ToolTip(option.tooltip):null]);return render()};const ProgressBar=({percent=100,error=false,className=""})=>{return Div({className:`gh-progress-bar ${error?"gh-error":""} ${className}`},Div({className:"gh-progress-bar-fill",style:{width:`${percent||1}%`}},Span({className:"fill-amount"},`${Math.ceil(percent)}%`)))};const Img=props=>makeEl("img",props);const Pg=(props,children)=>makeEl("p",props,children);const Bold=(props,children)=>makeEl("b",props,children);const An=(props,children)=>{props={href:"javascript:void(0)",...props};return makeEl("a",props,children)};const Ul=(props,children)=>makeEl("ul",props,children);const Ol=(props,children)=>makeEl("ol",props,children);const Li=(props,children)=>makeEl("li",props,children);const H1=(props,children)=>makeEl("h1",props,children);const H2=(props,children)=>makeEl("h2",props,children);const H3=(props,children)=>makeEl("h3",props,children);const H4=(props,children)=>makeEl("h4",props,children);const Hr=(props,children)=>makeEl("hr",props,children);const Skeleton=(attributes,pieces)=>Div({className:"display-grid gap-10",...attributes},pieces.map(span=>Div({className:`${span} skeleton-loading`,style:{height:`40px`}})));const useState=(initialState,id)=>{const el=document.getElementById(id);if(el&&el.State){return el.State}return Groundhogg.createState(initialState)};const Accordion=({id,items,outlined=false,multiple=false})=>{const State=useState({expanded:null},id);const isExpanded=index=>multiple?State.get(`expand${index+1}`):State.expanded===index;const toggleExpand=index=>{if(multiple){State.set({[`expand${index+1}`]:!isExpanded(index)})}else{State.set({expanded:index})}};return Div({id:id,className:"gh-accordion",State:State},morph=>Fragment(items.map(({title,content},i)=>Div({className:`gh-accordion-item gh-accordion-row ${isExpanded(i)?"expanded":"collapsed"} ${outlined?"outlined":"has-box-shadow"}`,id:`${id}-item-${i+1}`},[Div({id:`${id}-item-toggle-${i+1}`,className:"display-flex gap-10 align-center",onClick:e=>{toggleExpand(i);morph()}},[Pg({className:"gh-accordion-item-title"},title),isExpanded(i)?Dashicon("arrow-up-alt2"):Dashicon("arrow-down-alt2")]),isExpanded(i)?content:null]))))};const TinyMCE=({id="",content="",config={},onChange=content=>{},...props})=>{let openEditor=document.getElementById(id);let height=300;if(openEditor&&openEditor.tinyMceInitialized){height=openEditor.previousElementSibling.getBoundingClientRect().height}return Div({id:`tiny-mce-${id}`,className:"tiny-mce-wrap"},Textarea({id:id,name:id.replaceAll("-","_"),value:content,style:{height:`${height}px`},onCreate:el=>{setTimeout(()=>{Groundhogg.element.tinymceElement(el.id,config,onChange);el.tinyMceInitialized=true})},...props}))};window.MakeEl={Skeleton:Skeleton,TinyMCE:TinyMCE,InputGroup:InputGroup,Ellipses:Ellipses,Input:Input,InputWithReplacements:InputWithReplacements,Textarea:Textarea,Select:Select,Form:Form,ToolTip:ToolTip,Button:Button,Toggle:Toggle,Div:Div,Span:Span,Label:Label,InputRepeater:InputRepeater,Fragment:Fragment,Table:Table,TBody:TBody,THead:THead,TFoot:TFoot,Tr:Tr,Td:Td,Th:Th,Modal:Modal,ModalWithHeader:ModalWithHeader,MiniModal:MiniModal,ModalFrame:ModalFrame,ItemPicker:ItemPicker,Iframe:Iframe,Dashicon:Dashicon,ButtonToggle:ButtonToggle,Autocomplete:Autocomplete,ProgressBar:ProgressBar,Accordion:Accordion,Pg:Pg,Bold:Bold,Img:Img,An:An,Ul:Ul,Ol:Ol,Li:Li,H1:H1,H2:H2,H3:H3,H4:H4,Hr:Hr,Nav:Nav,maybeCall:maybeCall,forDom:forDom,forReact:forReact,makeEl:makeEl,makeElForReact:makeElForReact,htmlToReact:htmlToReact,htmlToElement:htmlToElement,htmlToElements:htmlToElements,domElementToReact:domElementToReact,useState:useState}})(jQuery??function(){throw new Error("jQuery was not loaded.")});4 `])};const Div=(attributes={},children=[])=>{return makeEl("div",attributes,children)};const Nav=(attributes={},children=[])=>{return makeEl("nav",attributes,children)};const Dashicon=(icon,children=null)=>{return makeEl("span",{className:`dashicons dashicons-${icon}`},children)};const Fragment=(children,atts={})=>{return makeEl("fragment",atts,children)};const Span=(attributes={},children=[])=>{return makeEl("span",attributes,children)};const Label=(attributes={},children=[])=>{return makeEl("label",attributes,children)};const InputRepeater=({id="",onChange=()=>{},rows=[],cells=[],sortable=false,fillRow=()=>Array(cells.length).fill(""),maxRows=0})=>{const handleChange=rows=>{onChange(rows);morphdom(document.getElementById(id),Repeater())};const removeRow=rowIndex=>{rows.splice(rowIndex,1);handleChange(rows)};const addRow=()=>{rows.push(fillRow());handleChange(rows)};const onCellChange=(rowIndex,cellIndex,value)=>{rows[rowIndex][cellIndex]=value;handleChange(rows)};const RepeaterRow=(row,rowIndex)=>Div({className:"gh-input-repeater-row",dataRow:rowIndex},[...cells.map((cellCallback,cellIndex)=>cellCallback({id:`${id}-cell-${rowIndex}-${cellIndex}`,name:`${id}[${rowIndex}][${cellIndex}]`,value:row[cellIndex]??"",dataRow:rowIndex,dataCell:cellIndex,onChange:e=>onCellChange(rowIndex,cellIndex,e.target.value),setValue:value=>onCellChange(rowIndex,cellIndex,value),onCellChange:onCellChange},row)),sortable?makeEl("span",{className:"handle",dataRow:rowIndex},Dashicon("move")):null,Button({className:"gh-button dashicon remove-row",dataRow:rowIndex,type:"button",onClick:e=>removeRow(rowIndex)},Dashicon("no-alt"))]);const Repeater=()=>Div({id:id,className:"gh-input-repeater",onCreate:el=>{if(!sortable){return}$(el).sortable({handle:".handle",update:(e,ui)=>{let $row=$(ui.item);let oldIndex=parseInt($row.data("row"));let curIndex=$row.index();let row=rows[oldIndex];rows.splice(oldIndex,1);rows.splice(curIndex,0,row);onChange(rows)}})}},[...rows.map((row,i)=>RepeaterRow(row,i)),maxRows===0||rows.length<maxRows?Div({className:"gh-input-repeater-row-add"},[`<div class="spacer"></div>`,Button({id:`${id}-add-row`,className:"add-row gh-button dashicon",onClick:e=>addRow(),type:"button"},Dashicon("plus-alt2"))]):null]);return Repeater()};const InputWithReplacements=({inputCallback=Input,...attributes})=>{return Div({className:"input-wrap"},[inputCallback(attributes),Button({className:"replacements-picker-start gh-button dashicon"},Dashicon("admin-users"))])};const Table=(atts,children)=>makeEl("table",atts,children);const THead=(atts,children)=>makeEl("thead",atts,children);const TBody=(atts,children)=>makeEl("tbody",atts,children);const TFoot=(atts,children)=>makeEl("tfoot",atts,children);const Tr=(atts,children)=>makeEl("tr",atts,children);const Td=(atts,children)=>makeEl("td",atts,children);const Th=(atts,children)=>makeEl("th",atts,children);const Modal=({dialogClasses="",className="",onOpen=()=>{},onClose=()=>{},width,closeButton=true,closeOnOverlayClick=true,overlay=true},children)=>{const Dialog=({header=null,content=null})=>Div({className:`gh-modal-dialog ${dialogClasses}`,style:{width:width}},[header,Div({className:"gh-modal-dialog-content"},content),closeButton&&!header?Button({className:"dashicon-button gh-modal-button-close-top gh-modal-button-close",onClick:e=>{close()}},Dashicon("no-alt")):null]);let modal=Div({className:`gh-modal ${className}`,tabindex:0},[overlay?Div({className:"gh-modal-overlay",onClick:e=>{if(closeOnOverlayClick){close()}}}):null,Dialog({header:null,content:null})]);const close=()=>{onClose(modal);modal.remove()};const morph=(args={})=>{let content=getContent();let header=content.querySelector(".modal-header");morphdom(modal.querySelector(".gh-modal-dialog"),Dialog({header:header,content:content}),args)};const getContent=()=>maybeCall(children,{close:close,modal:modal,morph:morph});document.body.appendChild(modal);morph();onOpen({modal:modal,close:close,morph:morph});if(!modal.contains(document.activeElement)){modal.focus()}return modal};const ModalWithHeader=({header="",...args},children)=>Modal(args,methods=>Div({},[Div({className:"gh-header modal-header"},[MakeEl.H3({},header),MakeEl.Button({className:"gh-button icon secondary text",onClick:methods.close},MakeEl.Dashicon("no-alt"))]),maybeCall(children,methods)]));const ModalFrame=({onOpen=()=>{},onClose=()=>{},frameAttributes={},closeOnOverlayClick=true,closeOnEscape=true},children)=>{let modal=Div({className:"gh-modal",tabindex:0,onKeydown:e=>{if(closeOnEscape){if(e.key==="Esc"||e.key==="Escape"){close()}}}},[Div({className:"gh-modal-overlay",onClick:e=>{if(closeOnOverlayClick){close()}}}),Div({className:`gh-modal-frame`,...frameAttributes},[])]);const close=()=>{onClose();modal.remove()};modal.querySelector(".gh-modal-frame").appendChild(Fragment(maybeCall(children,{close:close})));document.body.appendChild(modal);onOpen({close:close});modal.focus();return modal};const MiniModal=({selector="",target=null,from="right",dialogClasses="",onOpen=()=>{},onClose=()=>{},closeOnFocusout=true},children)=>{let modal=Div({className:"gh-modal mini gh-panel",tabindex:0,onFocusout:e=>{if(closeOnFocusout){if(!e.relatedTarget||!clickedIn(e.relatedTarget,".gh-modal.mini")){setTimeout(()=>{if(!clickedIn(document.activeElement,".gh-modal.mini")){close()}},10)}}},onCreate:el=>{el.focus()}},Div({className:`gh-modal-dialog ${dialogClasses}`},[Button({className:"dashicon-button gh-modal-button-close-top gh-modal-button-close",onClick:e=>{close()}},Dashicon("no-alt"))]));const close=()=>{onClose();modal.remove()};modal.querySelector(".gh-modal-dialog").appendChild(Fragment(maybeCall(children,{close:close})));document.body.appendChild(modal);onOpen();let targetElement=selector&&target===null?document.querySelector(selector):target;let{right,left,bottom,top}=targetElement.getBoundingClientRect();let{width,height}=modal.getBoundingClientRect();switch(from){case"left":modal.style.left=left+"px";break;case"right":modal.style.left=right-width+"px";break}if(top+height>window.innerHeight){modal.style.top=window.innerHeight-height-20+"px"}else{modal.style.top=top+"px"}modal.focus();return modal};const Autocomplete=({fetchResults=async search=>{},onInput,...attributes})=>{let timeout;const State={pointer:0,results:[],input:null};const setValue=()=>{let item=State.results[State.pointer];State.input.value=item.id;State.input.dispatchEvent(new Event("change"));closeResults()};const updateResults=()=>{if(!State.results.length){closeResults();return}let resultsContainer=document.querySelector(".gh-autocomplete-results");let newResults=Results();if(!resultsContainer){document.body.appendChild(newResults)}else{morphdom(resultsContainer,newResults)}};const closeResults=()=>{let resultsContainer=document.querySelector(".gh-autocomplete-results");if(resultsContainer){resultsContainer.remove()}};const Results=()=>{const{results,input}=State;let{height,width,top,left}=input.getBoundingClientRect();return Div({className:"gh-autocomplete-results",style:{zIndex:999999,top:`${top+height}px`,left:`${left}px`,width:`${width}px`}},results.map(({id,text},index)=>makeEl("a",{className:`${index===State.pointer?"pointer":""}`,href:id,onClick:e=>{e.preventDefault();setValue()},onMouseenter:e=>{State.pointer=[...e.target.parentNode.children].indexOf(e.target);updateResults()}},text)))};return Input({...attributes,onFocusout:e=>{const input=e.target;input.classList.remove("has-results");if(e.relatedTarget&&clickedIn(e.relatedTarget,"a.pointer")){setValue()}closeResults()},onKeydown:e=>{const input=e.target;switch(e.key){case"Esc":case"Escape":e.preventDefault();closeResults();return;case"Down":case"ArrowDown":e.preventDefault();if(State.pointer<State.results.length){State.pointer++}break;case"Up":case"ArrowUp":e.preventDefault();if(State.pointer>0){State.pointer--}break;case"Enter":e.preventDefault();setValue();break;default:return}updateResults()},onInput:e=>{if(timeout){clearTimeout(timeout)}timeout=setTimeout(async()=>{const input=e.target;let search=input.value;State.results=await fetchResults(search);State.input=input;State.pointer=0;updateResults();input.classList.add("gh-autocomplete","has-results")},500);onInput(e)}})};const Ellipses=(content,atts={})=>Span({...atts,onCreate:el=>{let ellipses="";let count=0;let interval=setInterval(()=>{if(!el.parentNode){clearInterval(interval);return}count=(count+1)%4;ellipses=".".repeat(count);el.textContent=content+ellipses},500)}},content+"...");const ItemPicker=({id="",label="",placeholder="Type to search...",fetchOptions=(search,resolve)=>{},selected=[],onChange=()=>{},onSelect=()=>{},onCreate=()=>{},onUnselect=()=>{},createOption=val=>Promise.resolve({id:val,text:val}),tags=false,noneSelected="Any",isValidSelection=string=>Boolean(string),multiple=true,clearable=true,...attributes})=>{const state=Groundhogg.createState({search:"",searching:false,choosing:false,options:[],focused:false,morphing:false,clicked:false});const optionsVisible=()=>{return multiple?state.focused&&(state.searching||state.options.length||tags&&isValidSelection(state.search)):state.focused};if(!multiple&&!Array.isArray(selected)){selected=[selected]}let timeout;const setState=(newState,trigger)=>{state.set(newState);morph()};const handleOnChange=selected=>{if(timeout){clearTimeout(timeout)}if(multiple){onChange(selected);return}if(!selected.length){onChange(null);return}onChange(selected[0])};const morph=()=>{if(state.morphing){return}state.set({morphing:true});morphdom(document.getElementById(id),Render());state.set({morphing:false})};const focusSearch=()=>document.getElementById(id)?.querySelector(`input[type=search]`)?.focus();const focusPicker=()=>document.getElementById(id)?.focus();const focusParent=()=>document.getElementById(id)?.parentElement.focus();const handleCreateOption=value=>{state.options.unshift({id:value,text:value,create:true});handleSelectOption(value)};const handleSelectOption=async id=>{let option={...state.options.find(opt=>opt.id==id)};if(option.create){option.text=option.id}if(multiple){selected.push(option)}else{selected=[option]}if(option.create){await createOption(option.id).then(opt=>{selected=selected.map(item=>item.id==id?opt:item);option=opt})}onSelect(option);handleOnChange(selected);if(!multiple){state.set({focused:false})}setState({search:""});morph();if(multiple){focusSearch()}else{focusPicker()}};const handleUnselectOption=id=>{let opt=selected.find(opt=>opt.id===id);selected=selected.filter(opt=>opt.id!=id);onUnselect(opt);handleOnChange(selected);morph();if(multiple){focusSearch()}};const itemPickerItem=({id,text},index)=>{return Div({className:`gh-picker-item ${isValidSelection(id)?"":"is-invalid"}`,id:`item-${id}-${index}`},[Span({className:"gh-picker-item-text"},text),selected.length>1||clearable?Span({id:`delete-${id}-${index}`,className:"gh-picker-item-delete",tabindex:"0",dataId:id,onClick:e=>{handleUnselectOption(id)}},"×"):null])};const itemPickerOption=({id,text},index)=>{return Div({className:"gh-picker-option",dataId:id,tabindex:"0",id:`option-${index}-${id}`,onClick:e=>{handleSelectOption(id)}},text)};const itemPickerOptions=()=>{let picker=document.getElementById(id);let style={};if(picker){const{left,right,top,bottom,width}=picker.getBoundingClientRect();let maxHeight=window.innerHeight-bottom-20;if(maxHeight>100){style.top=bottom+"px";style.left=left+"px";style.width=width+"px";style.maxHeight=maxHeight+"px"}else{style.bottom=window.innerHeight-top+"px";style.left=left+"px";style.width=width+"px";style.maxHeight=top-20+"px"}}state.options=state.options.filter(opt=>!opt.create);if(!state.searching&&tags&&isValidSelection(state.search)){if(!state.options.find(opt=>opt.id==state.search||opt.text==state.search)){state.options.unshift({id:state.search,text:`Add "${state.search}"`,create:true})}}let options=state.options.filter(opt=>!selected.some(_opt=>opt.id==_opt.id));return Div({className:"gh-picker-options",style:style,onCreate:el=>{setTimeout(()=>{let picker=document.getElementById(id);let optionsContainer=picker.querySelector(".gh-picker-options");const{left,right,top,bottom,width}=picker.getBoundingClientRect();let maxHeight=window.innerHeight-bottom-20;if(maxHeight>100){optionsContainer.style.top=bottom+"px";optionsContainer.style.left=left+"px";optionsContainer.style.width=width+"px";optionsContainer.style.maxHeight=maxHeight+"px"}else{optionsContainer.style.bottom=window.innerHeight-top+"px";optionsContainer.style.left=left+"px";optionsContainer.style.width=width+"px";optionsContainer.style.maxHeight=top-20+"px"}if(!multiple){focusSearch()}},0)}},[multiple||!selected.length?null:SearchInput(),state.searching?Div({className:"gh-picker-no-options"},Ellipses(wp.i18n.__("Searching"))):null,...options.map((opt,i)=>itemPickerOption(opt,i)),options.length||state.searching?null:Div({className:"gh-picker-no-options"},"No results found.")])};const startSearch=search=>{setState({search:search,searching:true},"start search");if(timeout){clearTimeout(timeout)}timeout=setTimeout(()=>{fetchOptions(search).then(options=>{if(search!==state.search){return}setState({searching:false,options:options},"options fetched")})},500)};const SearchInput=()=>Input({className:"gh-picker-search",value:state.search,name:"search",type:"search",autocomplete:"off",id:`${id}-search-input`,placeholder:selected.length?placeholder:noneSelected,onInput:e=>startSearch(e.target.value),onFocus:e=>{startSearch(e.target.value)},onKeydown:e=>{if(tags){if(e.key!=="Enter"&&e.key!==","){return}handleCreateOption(e.target.value)}}});const Render=()=>Div({id:id,className:`gh-picker-container`,tabindex:"0",...attributes},Div({id:`${id}-picker`,className:`gh-picker ${optionsVisible()?"options-visible":""}`,tabindex:"0",onKeydown:e=>{if(e.key==="Escape"){setState({searching:false,focused:false});morph()}},onCreate:el=>{el.addEventListener("focusout",e=>{setTimeout(()=>{if(state.morphing||document.getElementById(id).contains(document.activeElement)){return}setState({search:"",options:[],searching:false,focused:false},"picker focusout")},10)});el.addEventListener("focusin",e=>{if(state.focused){return}setState({focused:true},"picker focused")})}},[Div({className:`gh-picker-selected ${multiple?"multiple":"single"}`},[selected.length&&label?Span({className:"gh-picker-label"},label):null,...selected.map((item,i)=>itemPickerItem(item,i)),multiple||!selected.length?SearchInput():null]),optionsVisible()?itemPickerOptions():null]));return Render()};const InputGroup=inputs=>Div({className:"gh-input-group"},inputs);const Iframe=({onCreate=()=>{},...attributes},content=null)=>{let blob=new Blob([content],{type:"text/html; charset=utf-8"});let src=URL.createObjectURL(blob);return makeEl("iframe",{...attributes,src:src})};const ToolTip=(content,position="bottom")=>{return Div({className:`gh-tooltip ${position}`},content)};const ButtonToggle=({id="",options=[],selected="",onChange=value=>{}})=>{const render=()=>Div({id:id,className:"gh-input-group"},options.map(opt=>ButtonOption(opt)));const ButtonOption=option=>Button({id:`${id}-opt-${option.id}`,className:`gh-button gh-button small ${selected===option.id?"dark":"grey"}`,onClick:e=>{selected=option.id;morphdom(document.getElementById(id),render());onChange(option.id)}},[option.text,option.tooltip?ToolTip(option.tooltip):null]);return render()};const ProgressBar=({percent=100,error=false,className=""})=>{return Div({className:`gh-progress-bar ${error?"gh-error":""} ${className}`},Div({className:"gh-progress-bar-fill",style:{width:`${percent||1}%`}},Span({className:"fill-amount"},`${Math.ceil(percent)}%`)))};const Img=props=>makeEl("img",props);const Pg=(props,children)=>makeEl("p",props,children);const Bold=(props,children)=>makeEl("b",props,children);const An=(props,children)=>{props={href:"javascript:void(0)",...props};return makeEl("a",props,children)};const Ul=(props,children)=>makeEl("ul",props,children);const Ol=(props,children)=>makeEl("ol",props,children);const Li=(props,children)=>makeEl("li",props,children);const H1=(props,children)=>makeEl("h1",props,children);const H2=(props,children)=>makeEl("h2",props,children);const H3=(props,children)=>makeEl("h3",props,children);const H4=(props,children)=>makeEl("h4",props,children);const Hr=(props,children)=>makeEl("hr",props,children);const Skeleton=(attributes,pieces)=>Div({className:"display-grid gap-10",...attributes},pieces.map(span=>Div({className:`${span} skeleton-loading`,style:{height:`40px`}})));const useState=(initialState,id)=>{const el=document.getElementById(id);if(el&&el.State){return el.State}return Groundhogg.createState(initialState)};const Accordion=({id,items,outlined=false,multiple=false})=>{const State=useState({expanded:null},id);const isExpanded=index=>multiple?State.get(`expand${index+1}`):State.expanded===index;const toggleExpand=index=>{if(multiple){State.set({[`expand${index+1}`]:!isExpanded(index)})}else{State.set({expanded:index})}};return Div({id:id,className:"gh-accordion",State:State},morph=>Fragment(items.map(({title,content},i)=>Div({className:`gh-accordion-item gh-accordion-row ${isExpanded(i)?"expanded":"collapsed"} ${outlined?"outlined":"has-box-shadow"}`,id:`${id}-item-${i+1}`},[Div({id:`${id}-item-toggle-${i+1}`,className:"display-flex gap-10 align-center",onClick:e=>{toggleExpand(i);morph()}},[Pg({className:"gh-accordion-item-title"},title),isExpanded(i)?Dashicon("arrow-up-alt2"):Dashicon("arrow-down-alt2")]),isExpanded(i)?content:null]))))};const TinyMCE=({id="",content="",config={},onChange=content=>{},...props})=>{let openEditor=document.getElementById(id);let height=300;if(openEditor&&openEditor.tinyMceInitialized){height=openEditor.previousElementSibling.getBoundingClientRect().height}return Div({id:`tiny-mce-${id}`,className:"tiny-mce-wrap"},Textarea({id:id,name:id.replaceAll("-","_"),value:content,style:{height:`${height}px`},onCreate:el=>{setTimeout(()=>{Groundhogg.element.tinymceElement(el.id,config,onChange);el.tinyMceInitialized=true})},...props}))};window.MakeEl={Skeleton:Skeleton,TinyMCE:TinyMCE,InputGroup:InputGroup,Ellipses:Ellipses,Input:Input,InputWithReplacements:InputWithReplacements,Textarea:Textarea,Select:Select,Form:Form,ToolTip:ToolTip,Button:Button,Toggle:Toggle,Div:Div,Span:Span,Label:Label,InputRepeater:InputRepeater,Fragment:Fragment,Table:Table,TBody:TBody,THead:THead,TFoot:TFoot,Tr:Tr,Td:Td,Th:Th,Modal:Modal,ModalWithHeader:ModalWithHeader,MiniModal:MiniModal,ModalFrame:ModalFrame,ItemPicker:ItemPicker,Iframe:Iframe,Dashicon:Dashicon,ButtonToggle:ButtonToggle,Autocomplete:Autocomplete,ProgressBar:ProgressBar,Accordion:Accordion,Pg:Pg,Bold:Bold,Img:Img,An:An,Ul:Ul,Ol:Ol,Li:Li,H1:H1,H2:H2,H3:H3,H4:H4,Hr:Hr,Nav:Nav,maybeCall:maybeCall,forDom:forDom,forReact:forReact,makeEl:makeEl,makeElForReact:makeElForReact,htmlToReact:htmlToReact,htmlToElement:htmlToElement,htmlToElements:htmlToElements,domElementToReact:domElementToReact,useState:useState}})(jQuery??function(){throw new Error("jQuery was not loaded.")}); -
groundhogg/tags/4.2.10/blocks/gutenberg/build/index.js
r3395861 r3422142 166 166 options: forms, 167 167 onChange: value => { 168 const form = window.Groundhogg.stores.forms.get(parseInt( formId));168 const form = window.Groundhogg.stores.forms.get(parseInt(value)); 169 169 setAttributes({ 170 170 formId: value, -
groundhogg/tags/4.2.10/blocks/gutenberg/build/index.js.map
r3395861 r3422142 1 {"version":3,"file":"index.js","mappings":"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rCH;;;;;;;;;;;ACAA,0C;;;;;;;;;;ACAA,6C;;;;;;;;;;ACAA,wC;;;;;;;;;;ACAA,4C;;;;;;;;;;ACAA,yC;;;;;;;;;;ACAA,sC;;;;;;;;;;ACAA,2C;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;UAEA;UACA;;;;;WCzBA;WACA;WACA;WACA;WACA,+BAA+B,wCAAwC;WACvE;WACA;WACA;WACA;WACA,iBAAiB,qBAAqB;WACtC;WACA;WACA,kBAAkB,qBAAqB;WACvC;WACA;WACA,KAAK;WACL;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,E;;;;;WC3BA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA,E;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA,E;;;;;WCPA,wF;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D,E;;;;;WCNA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA,4G;;;;;UEjDA;UACA;UACA;UACA;UACA","sources":["webpack://gh-form-shortcode/./src/edit.js","webpack://gh-form-shortcode/./src/editor.scss","webpack://gh-form-shortcode/./src/index.js","webpack://gh-form-shortcode/./src/style.scss","webpack://gh-form-shortcode/external window [\"wp\",\"apiFetch\"]","webpack://gh-form-shortcode/external window [\"wp\",\"blockEditor\"]","webpack://gh-form-shortcode/external window [\"wp\",\"blocks\"]","webpack://gh-form-shortcode/external window [\"wp\",\"components\"]","webpack://gh-form-shortcode/external window [\"wp\",\"element\"]","webpack://gh-form-shortcode/external window [\"wp\",\"i18n\"]","webpack://gh-form-shortcode/external window \"ReactJSXRuntime\"","webpack://gh-form-shortcode/webpack/bootstrap","webpack://gh-form-shortcode/webpack/runtime/chunk loaded","webpack://gh-form-shortcode/webpack/runtime/compat get default export","webpack://gh-form-shortcode/webpack/runtime/define property getters","webpack://gh-form-shortcode/webpack/runtime/hasOwnProperty shorthand","webpack://gh-form-shortcode/webpack/runtime/make namespace object","webpack://gh-form-shortcode/webpack/runtime/jsonp chunk loading","webpack://gh-form-shortcode/webpack/before-startup","webpack://gh-form-shortcode/webpack/startup","webpack://gh-form-shortcode/webpack/after-startup"],"sourcesContent":["/**\n * Retrieves the translation of text.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-i18n/\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * React hook that is used to mark the block wrapper element.\n * It provides all the necessary props like the class name.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#useblockprops\n */\nimport { useBlockProps, InspectorControls } from '@wordpress/block-editor';\n\n/**\n * WordPress dependencies\n */\nimport { PanelBody, Spinner, SelectControl } from '@wordpress/components';\nimport { useEffect, useState } from '@wordpress/element';\nimport apiFetch from '@wordpress/api-fetch';\nimport { ColorPalette } from '@wordpress/block-editor';\n\n/**\n * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.\n * Those files can contain any CSS code that gets applied to the editor.\n *\n * @see https://www.npmjs.com/package/@wordpress/scripts#using-css\n */\nimport './editor.scss';\n\n/**\n * The edit function describes the structure of your block in the context of the\n * editor. This represents what the editor will render when the block is used.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit\n *\n * @param {Object} props Block properties.\n * @param {Object} props.attributes Block attributes.\n * @param {Function} props.setAttributes Function to update block attributes.\n *\n * @return {Element} Element to render.\n */\nexport default function Edit( { attributes, setAttributes } ) {\n\tconst { formId, theme, accentColor } = attributes;\n\tconst [ preview, setPreview ] = useState( '' );\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ forms, setForms ] = useState( [] );\n\tconst [ isLoadingForms, setIsLoadingForms ] = useState( true );\n\n\tconst blockProps = useBlockProps();\n\n\t// Fetch available forms\n\tuseEffect( () => {\n\t\tsetIsLoadingForms( true );\n\n\t\twindow.Groundhogg.stores.forms.fetchItems().then( items => {\n\t\t\tconst formOptions = items.map( form => ( {\n\t\t\t\tlabel: `${form.name} (#${form.ID})`,\n\t\t\t\tvalue: String( form.ID ),\n\t\t\t} ) );\n\t\t\tsetForms( [\n\t\t\t\t{ label: __( 'Select a form', 'gh-form-shortcode' ), value: '' },\n\t\t\t\t...formOptions,\n\t\t\t] );\n\t\t\tsetIsLoadingForms( false );\n\t\t}).catch( () => {\n\t\t\tsetForms( [\n\t\t\t\t{ label: __( 'No forms found', 'gh-form-shortcode' ), value: '' },\n\t\t\t] );\n\t\t\tsetIsLoadingForms( false );\n\t\t} );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! formId ) {\n\t\t\tsetPreview( '' );\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsLoading( true );\n\n\t\t// Fetch the rendered shortcode preview\n\t\tapiFetch( {\n\t\t\tpath: '/wp/v2/block-renderer/groundhogg/forms',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tattributes: {\n\t\t\t\t\tformId,\n\t\t\t\t\ttheme,\n\t\t\t\t\taccentColor,\n\t\t\t\t},\n\t\t\t\tcontext: 'edit'\n\t\t\t},\n\t\t} )\n\t\t\t.then( ( response ) => {\n\t\t\t\tsetPreview( response.rendered );\n\t\t\t\tsetIsLoading( false );\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tsetPreview( '' );\n\t\t\t\tsetIsLoading( false );\n\t\t\t} );\n\t}, [ formId, theme, accentColor ] );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ __( 'Form Settings', 'gh-form-shortcode' ) }\n\t\t\t\t\tinitialOpen={ true }\n\t\t\t\t>\n\t\t\t\t\t{ isLoadingForms ? (\n\t\t\t\t\t\t<div style={{ padding: '12px', textAlign: 'center' }}>\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t<p style={{ marginTop: '8px', fontSize: '13px', color: '#757575' }}>\n\t\t\t\t\t\t\t\t{ __( 'Loading forms...', 'groundhogg' ) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t <SelectControl\n\t\t\t\t\t\t\t label={ __( 'Form', 'groundhogg' ) }\n\t\t\t\t\t\t\t value={ formId }\n\t\t\t\t\t\t\t options={ forms }\n\t\t\t\t\t\t\t onChange={ ( value ) => {\n\n\t\t\t\t\t\t\t\t\tconst form = window.Groundhogg.stores.forms.get( parseInt( formId ) )\n\n\t\t\t\t\t\t\t\t setAttributes( {\n\t\t\t\t\t\t\t\t\t formId: value,\n\t\t\t\t\t\t\t\t\t accentColor: form.settings.accentColor,\n\t\t\t\t\t\t\t\t\t theme: form.settings.theme\n\t\t\t\t\t\t\t\t } )\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t help={ __(\n\t\t\t\t\t\t\t\t 'Select the form to embed',\n\t\t\t\t\t\t\t\t 'groundhogg'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t />\n\t\t\t\t\t ) }\n\t\t\t\t</PanelBody>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ __( 'Appearance', 'groundhogg' ) }\n\t\t\t\t\tinitialOpen={ true }\n\t\t\t\t>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\tlabel={ __( 'Theme', 'groundhogg' ) }\n\t\t\t\t\t\tvalue={ theme }\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Default', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'default',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Simple', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'simple',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Modern', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'modern',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Classic', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'classic',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { theme: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Select the visual theme for the form',\n\t\t\t\t\t\t\t'groundhogg'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<p style={{ marginTop: '16px', marginBottom: '8px' }}>\n\t\t\t\t\t\t{ __( 'Accent Color', 'groundhogg' ) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\tvalue={ accentColor }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { accentColor: value || '#0073aa' } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ ! formId ? (\n\t\t\t\t\t<div className=\"gh-form-shortcode-placeholder\">\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ sprintf( __(\n\t\t\t\t\t\t\t\t'Embed a %s Form',\n\t\t\t\t\t\t\t\t'groundhogg'\n\t\t\t\t\t\t\t), window.Groundhogg.whiteLabelName ) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Select a form in the block settings to get started.',\n\t\t\t\t\t\t\t\t'groundhogg'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<div className=\"gh-form-shortcode-preview\">\n\t\t\t\t\t\t{ isLoading ? (\n\t\t\t\t\t\t\t<div className=\"gh-form-shortcode-loading\">\n\t\t\t\t\t\t\t\t{ __( 'Loading form preview...', 'groundhogg' ) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t\t\t__html: preview,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n","// extracted by mini-css-extract-plugin\nexport {};","/**\n * Registers a new block provided a unique name and an object defining its behavior.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/\n */\nimport { registerBlockType } from '@wordpress/blocks';\nimport { createElement } from '@wordpress/element';\n\n/**\n * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.\n * All files containing `style` keyword are bundled together. The code used\n * gets applied both to the front of your site and to the editor.\n *\n * @see https://www.npmjs.com/package/@wordpress/scripts#using-css\n */\nimport './style.scss';\n\n/**\n * Internal dependencies\n */\nimport Edit from './edit';\nimport metadata from './block.json';\n\nlet icon = window.MakeEl.htmlToReact( window.Groundhogg.element.icons.groundhogg )\n\n/**\n * Every block starts by registering a new block type definition.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/\n */\nregisterBlockType( metadata.name, {\n\t/**\n\t * @see ./edit.js\n\t */\n\tedit: Edit,\n\ttitle: `${window.Groundhogg.whiteLabelName} Form`,\n\ticon\n} );\n","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"wp\"][\"apiFetch\"];","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"blocks\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"ReactJSXRuntime\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t\"index\": 0,\n\t\"./style-index\": 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunkgh_form_shortcode\"] = globalThis[\"webpackChunkgh_form_shortcode\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [\"./style-index\"], () => (__webpack_require__(\"./src/index.js\")))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n",""],"names":["__","sprintf","useBlockProps","InspectorControls","PanelBody","Spinner","SelectControl","useEffect","useState","apiFetch","ColorPalette","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","Edit","attributes","setAttributes","formId","theme","accentColor","preview","setPreview","isLoading","setIsLoading","forms","setForms","isLoadingForms","setIsLoadingForms","blockProps","window","Groundhogg","stores","fetchItems","then","items","formOptions","map","form","label","name","ID","value","String","catch","path","method","data","context","response","rendered","children","title","initialOpen","style","padding","textAlign","marginTop","fontSize","color","options","onChange","get","parseInt","settings","help","marginBottom","className","whiteLabelName","dangerouslySetInnerHTML","__html","registerBlockType","createElement","metadata","icon","MakeEl","htmlToReact","element","icons","groundhogg","edit"],"sourceRoot":""}1 {"version":3,"file":"index.js","mappings":"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K,CAACC,UAAW,CAAC;;AAElF;AACA;AACA;AACA;AACA;AACAR,oEAAiB,CAAEE,6CAAa,EAAE;EACjC;AACD;AACA;EACCO,IAAI,EAAEjE,6CAAI;EACVqC,KAAK,EAAE,GAAGtB,MAAM,CAACC,UAAU,CAACqC,cAAc,OAAO;EACjDM;AACD,CAAE,CAAC,C;;;;;;;;;;;ACrCH;;;;;;;;;;;ACAA,0C;;;;;;;;;;ACAA,6C;;;;;;;;;;ACAA,wC;;;;;;;;;;ACAA,4C;;;;;;;;;;ACAA,yC;;;;;;;;;;ACAA,sC;;;;;;;;;;ACAA,2C;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;UAEA;UACA;;;;;WCzBA;WACA;WACA;WACA;WACA,+BAA+B,wCAAwC;WACvE;WACA;WACA;WACA;WACA,iBAAiB,qBAAqB;WACtC;WACA;WACA,kBAAkB,qBAAqB;WACvC;WACA;WACA,KAAK;WACL;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,E;;;;;WC3BA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA,E;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA,E;;;;;WCPA,wF;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D,E;;;;;WCNA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA,4G;;;;;UEjDA;UACA;UACA;UACA;UACA","sources":["webpack://gh-form-shortcode/./src/edit.js","webpack://gh-form-shortcode/./src/editor.scss","webpack://gh-form-shortcode/./src/index.js","webpack://gh-form-shortcode/./src/style.scss","webpack://gh-form-shortcode/external window [\"wp\",\"apiFetch\"]","webpack://gh-form-shortcode/external window [\"wp\",\"blockEditor\"]","webpack://gh-form-shortcode/external window [\"wp\",\"blocks\"]","webpack://gh-form-shortcode/external window [\"wp\",\"components\"]","webpack://gh-form-shortcode/external window [\"wp\",\"element\"]","webpack://gh-form-shortcode/external window [\"wp\",\"i18n\"]","webpack://gh-form-shortcode/external window \"ReactJSXRuntime\"","webpack://gh-form-shortcode/webpack/bootstrap","webpack://gh-form-shortcode/webpack/runtime/chunk loaded","webpack://gh-form-shortcode/webpack/runtime/compat get default export","webpack://gh-form-shortcode/webpack/runtime/define property getters","webpack://gh-form-shortcode/webpack/runtime/hasOwnProperty shorthand","webpack://gh-form-shortcode/webpack/runtime/make namespace object","webpack://gh-form-shortcode/webpack/runtime/jsonp chunk loading","webpack://gh-form-shortcode/webpack/before-startup","webpack://gh-form-shortcode/webpack/startup","webpack://gh-form-shortcode/webpack/after-startup"],"sourcesContent":["/**\n * Retrieves the translation of text.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-i18n/\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * React hook that is used to mark the block wrapper element.\n * It provides all the necessary props like the class name.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#useblockprops\n */\nimport { useBlockProps, InspectorControls } from '@wordpress/block-editor';\n\n/**\n * WordPress dependencies\n */\nimport { PanelBody, Spinner, SelectControl } from '@wordpress/components';\nimport { useEffect, useState } from '@wordpress/element';\nimport apiFetch from '@wordpress/api-fetch';\nimport { ColorPalette } from '@wordpress/block-editor';\n\n/**\n * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.\n * Those files can contain any CSS code that gets applied to the editor.\n *\n * @see https://www.npmjs.com/package/@wordpress/scripts#using-css\n */\nimport './editor.scss';\n\n/**\n * The edit function describes the structure of your block in the context of the\n * editor. This represents what the editor will render when the block is used.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit\n *\n * @param {Object} props Block properties.\n * @param {Object} props.attributes Block attributes.\n * @param {Function} props.setAttributes Function to update block attributes.\n *\n * @return {Element} Element to render.\n */\nexport default function Edit( { attributes, setAttributes } ) {\n\tconst { formId, theme, accentColor } = attributes;\n\tconst [ preview, setPreview ] = useState( '' );\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ forms, setForms ] = useState( [] );\n\tconst [ isLoadingForms, setIsLoadingForms ] = useState( true );\n\n\tconst blockProps = useBlockProps();\n\n\t// Fetch available forms\n\tuseEffect( () => {\n\t\tsetIsLoadingForms( true );\n\n\t\twindow.Groundhogg.stores.forms.fetchItems().then( items => {\n\t\t\tconst formOptions = items.map( form => ( {\n\t\t\t\tlabel: `${form.name} (#${form.ID})`,\n\t\t\t\tvalue: String( form.ID ),\n\t\t\t} ) );\n\t\t\tsetForms( [\n\t\t\t\t{ label: __( 'Select a form', 'gh-form-shortcode' ), value: '' },\n\t\t\t\t...formOptions,\n\t\t\t] );\n\t\t\tsetIsLoadingForms( false );\n\t\t}).catch( () => {\n\t\t\tsetForms( [\n\t\t\t\t{ label: __( 'No forms found', 'gh-form-shortcode' ), value: '' },\n\t\t\t] );\n\t\t\tsetIsLoadingForms( false );\n\t\t} );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! formId ) {\n\t\t\tsetPreview( '' );\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsLoading( true );\n\n\t\t// Fetch the rendered shortcode preview\n\t\tapiFetch( {\n\t\t\tpath: '/wp/v2/block-renderer/groundhogg/forms',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tattributes: {\n\t\t\t\t\tformId,\n\t\t\t\t\ttheme,\n\t\t\t\t\taccentColor,\n\t\t\t\t},\n\t\t\t\tcontext: 'edit'\n\t\t\t},\n\t\t} )\n\t\t\t.then( ( response ) => {\n\t\t\t\tsetPreview( response.rendered );\n\t\t\t\tsetIsLoading( false );\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tsetPreview( '' );\n\t\t\t\tsetIsLoading( false );\n\t\t\t} );\n\t}, [ formId, theme, accentColor ] );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ __( 'Form Settings', 'gh-form-shortcode' ) }\n\t\t\t\t\tinitialOpen={ true }\n\t\t\t\t>\n\t\t\t\t\t{ isLoadingForms ? (\n\t\t\t\t\t\t<div style={{ padding: '12px', textAlign: 'center' }}>\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t<p style={{ marginTop: '8px', fontSize: '13px', color: '#757575' }}>\n\t\t\t\t\t\t\t\t{ __( 'Loading forms...', 'groundhogg' ) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t <SelectControl\n\t\t\t\t\t\t\t label={ __( 'Form', 'groundhogg' ) }\n\t\t\t\t\t\t\t value={ formId }\n\t\t\t\t\t\t\t options={ forms }\n\t\t\t\t\t\t\t onChange={ ( value ) => {\n\t\t\t\t\t\t\t\t const form = window.Groundhogg.stores.forms.get( parseInt( value ) )\n\t\t\t\t\t\t\t\t setAttributes( {\n\t\t\t\t\t\t\t\t\t formId: value,\n\t\t\t\t\t\t\t\t\t accentColor: form.settings.accentColor,\n\t\t\t\t\t\t\t\t\t theme: form.settings.theme\n\t\t\t\t\t\t\t\t } )\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t help={ __(\n\t\t\t\t\t\t\t\t 'Select the form to embed',\n\t\t\t\t\t\t\t\t 'groundhogg'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t />\n\t\t\t\t\t ) }\n\t\t\t\t</PanelBody>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ __( 'Appearance', 'groundhogg' ) }\n\t\t\t\t\tinitialOpen={ true }\n\t\t\t\t>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\tlabel={ __( 'Theme', 'groundhogg' ) }\n\t\t\t\t\t\tvalue={ theme }\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Default', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'default',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Simple', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'simple',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Modern', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'modern',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Classic', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'classic',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { theme: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Select the visual theme for the form',\n\t\t\t\t\t\t\t'groundhogg'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<p style={{ marginTop: '16px', marginBottom: '8px' }}>\n\t\t\t\t\t\t{ __( 'Accent Color', 'groundhogg' ) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\tvalue={ accentColor }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { accentColor: value || '#0073aa' } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ ! formId ? (\n\t\t\t\t\t<div className=\"gh-form-shortcode-placeholder\">\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ sprintf( __(\n\t\t\t\t\t\t\t\t'Embed a %s Form',\n\t\t\t\t\t\t\t\t'groundhogg'\n\t\t\t\t\t\t\t), window.Groundhogg.whiteLabelName ) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Select a form in the block settings to get started.',\n\t\t\t\t\t\t\t\t'groundhogg'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<div className=\"gh-form-shortcode-preview\">\n\t\t\t\t\t\t{ isLoading ? (\n\t\t\t\t\t\t\t<div className=\"gh-form-shortcode-loading\">\n\t\t\t\t\t\t\t\t{ __( 'Loading form preview...', 'groundhogg' ) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t\t\t__html: preview,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n","// extracted by mini-css-extract-plugin\nexport {};","/**\n * Registers a new block provided a unique name and an object defining its behavior.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/\n */\nimport { registerBlockType } from '@wordpress/blocks';\nimport { createElement } from '@wordpress/element';\n\n/**\n * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.\n * All files containing `style` keyword are bundled together. The code used\n * gets applied both to the front of your site and to the editor.\n *\n * @see https://www.npmjs.com/package/@wordpress/scripts#using-css\n */\nimport './style.scss';\n\n/**\n * Internal dependencies\n */\nimport Edit from './edit';\nimport metadata from './block.json';\n\nlet icon = window.MakeEl.htmlToReact( window.Groundhogg.element.icons.groundhogg )\n\n/**\n * Every block starts by registering a new block type definition.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/\n */\nregisterBlockType( metadata.name, {\n\t/**\n\t * @see ./edit.js\n\t */\n\tedit: Edit,\n\ttitle: `${window.Groundhogg.whiteLabelName} Form`,\n\ticon\n} );\n","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"wp\"][\"apiFetch\"];","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"blocks\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"ReactJSXRuntime\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t\"index\": 0,\n\t\"./style-index\": 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunkgh_form_shortcode\"] = globalThis[\"webpackChunkgh_form_shortcode\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [\"./style-index\"], () => (__webpack_require__(\"./src/index.js\")))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n",""],"names":["__","sprintf","useBlockProps","InspectorControls","PanelBody","Spinner","SelectControl","useEffect","useState","apiFetch","ColorPalette","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","Edit","attributes","setAttributes","formId","theme","accentColor","preview","setPreview","isLoading","setIsLoading","forms","setForms","isLoadingForms","setIsLoadingForms","blockProps","window","Groundhogg","stores","fetchItems","then","items","formOptions","map","form","label","name","ID","value","String","catch","path","method","data","context","response","rendered","children","title","initialOpen","style","padding","textAlign","marginTop","fontSize","color","options","onChange","get","parseInt","settings","help","marginBottom","className","whiteLabelName","dangerouslySetInnerHTML","__html","registerBlockType","createElement","metadata","icon","MakeEl","htmlToReact","element","icons","groundhogg","edit"],"sourceRoot":""} -
groundhogg/tags/4.2.10/db/tag-relationships.php
r3343709 r3422142 6 6 use Groundhogg\DB\Traits\Insert_Ignore; 7 7 use function Groundhogg\get_db; 8 use function Groundhogg\Ymd_His; 8 9 9 10 if ( ! defined( 'ABSPATH' ) ) { … … 82 83 'tag_id' => '%d', 83 84 'contact_id' => '%d', 85 'date_created' => '%s', 84 86 ]; 85 87 } … … 95 97 'tag_id' => 0, 96 98 'contact_id' => 0, 99 'date_created' => Ymd_His(), 97 100 ); 98 101 } … … 261 264 tag_id bigint(20) unsigned NOT NULL, 262 265 contact_id bigint(20) unsigned NOT NULL, 266 date_created datetime NOT NULL, 263 267 PRIMARY KEY (tag_id,contact_id), 264 268 KEY tag_id (tag_id), -
groundhogg/tags/4.2.10/groundhogg.php
r3400645 r3422142 4 4 * Plugin URI: https://www.groundhogg.io/?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash 5 5 * Description: CRM and marketing automation for WordPress 6 * Version: 4.2. 96 * Version: 4.2.10 7 7 * Author: Groundhogg Inc. 8 8 * Author URI: https://www.groundhogg.io/?utm_source=wp-plugins&utm_campaign=author-uri&utm_medium=wp-dash … … 25 25 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly 26 26 27 define( 'GROUNDHOGG_VERSION', '4.2. 9' );28 define( 'GROUNDHOGG_PREVIOUS_STABLE_VERSION', '4.2. 8' );27 define( 'GROUNDHOGG_VERSION', '4.2.10' ); 28 define( 'GROUNDHOGG_PREVIOUS_STABLE_VERSION', '4.2.9' ); 29 29 30 30 define( 'GROUNDHOGG__FILE__', __FILE__ ); -
groundhogg/tags/4.2.10/includes/better-meta-compat.php
r3386122 r3422142 420 420 $tab = Properties::instance()->get_group_tab( $group['id'] ); 421 421 422 if ( ! $tab ) {422 if ( ! $tab || ! isset( $tab['name'] ) || ! isset( $group['name'] ) ) { 423 423 continue; 424 424 } -
groundhogg/tags/4.2.10/includes/classes/contact.php
r3320187 r3422142 8 8 use Groundhogg\DB\DB; 9 9 use Groundhogg\DB\Meta_DB; 10 use Groundhogg\DB\Query\Table_Query; 10 11 use Groundhogg\DB\Tag_Relationships; 11 12 use Groundhogg\DB\Tags; … … 50 51 */ 51 52 protected $owner; 53 /** 54 * @var object[] 55 */ 56 protected array $tag_relationships = []; 52 57 53 58 /** … … 233 238 */ 234 239 protected function post_setup() { 235 $this->tags = wp_parse_id_list( $this->get_tag_rel_db()->get_relationships( $this->ID ) ); 236 $this->user = get_userdata( $this->get_user_id() ); 237 $this->owner = get_userdata( $this->get_owner_id() ); 240 241 $query = new Table_Query( db()->tag_relationships ); 242 $query->setSelect( 'tag_id', 'date_created' ); 243 $query->where( 'contact_id', $this->ID ); 244 245 $relationships = $query->get_results(); 246 247 $this->tags = wp_parse_id_list( wp_list_pluck( $relationships, 'tag_id' ) ); 248 $this->tag_relationships = array_reduce( $relationships, function ( $carry, $item ) { 249 250 if ( $item->date_created === null || $item->date_created === DateTimeHelper::ZERODATETIME ) { 251 return $carry; 252 } 253 254 $carry[ absint( $item->tag_id ) ] = $item->date_created; 255 256 return $carry; 257 }, [] ); 258 259 $this->user = get_userdata( $this->get_user_id() ); 260 $this->owner = get_userdata( $this->get_owner_id() ); 238 261 239 262 $this->ID = absint( $this->ID ); … … 843 866 foreach ( $apply as $tag_id ) { 844 867 845 $this->tags[] = $tag_id; 868 $this->tags[] = $tag_id; 869 $this->tag_relationships[ $tag_id ] = Ymd_His(); 846 870 847 871 $this->get_tag_rel_db()->batch_insert( [ … … 913 937 914 938 foreach ( $remove as $tag_id ) { 939 940 unset( $this->tag_relationships[ $tag_id ] ); 941 915 942 /** 916 943 * When a tag relationship is removed … … 1216 1243 'is_deliverable' => $this->is_deliverable(), 1217 1244 'i18n' => [ 1218 'created' => human_time_diff( time(), $this->get_date_created( true )->getTimestamp() ) 1245 'created' => human_time_diff( time(), $this->get_date_created( true )->getTimestamp() ), 1246 'tagDates' => array_map( fn($date) => (new DateTimeHelper($date))->wpDateTimeFormat(), $this->tag_relationships ) 1219 1247 ] 1220 1248 ] -
groundhogg/tags/4.2.10/includes/classes/event.php
r3343709 r3422142 208 208 209 209 /** 210 * @return Contact 211 */ 212 public function get_contact() { 213 214 if ( ! $this->contact ){ 215 $this->contact = new Contact( $this->get_contact_id() ); 216 } 217 218 return $this->contact; 219 } 220 221 /** 210 222 * @return String 211 223 */ 212 224 public function get_failure_reason() { 213 225 return $this->get_error_code() . ': ' . $this->get_error_message(); 214 }215 216 /**217 * @return Contact218 */219 public function get_contact() {220 return $this->contact;221 226 } 222 227 … … 339 344 $this->args = []; // default to using an array if empty 340 345 } 341 $this->contact = new Contact( $this->get_contact_id() );342 346 343 347 self::maybe_register_step_setup_callbacks(); -
groundhogg/tags/4.2.10/includes/classes/step.php
r3386122 r3422142 2282 2282 'meta' => $this->meta, 2283 2283 'export' => $this->export(), 2284 'is_starting' => $this->is_starting(), 2285 2284 2286 ] ); 2285 2287 } -
groundhogg/tags/4.2.10/includes/functions.php
r3394550 r3422142 3691 3691 } 3692 3692 3693 // for some reason when body is false or null it breaks, just make it am empty array instead 3694 if ( is_null( $body ) || $body === false ){ 3695 $body = []; 3696 } 3697 3693 3698 switch ( $method ) { 3694 3699 case 'POST': -
groundhogg/tags/4.2.10/includes/main-updater.php
r3386122 r3422142 254 254 maybe_install_safe_mode_plugin(); 255 255 } 256 ], 257 '4.2.10' => [ 258 'automatic' => true, 259 'description' => __( 'Update the tag relationships table.', 'groundhogg' ), 260 'callback' => function () { 261 db()->tag_relationships->create_table(); // add the date_created column 262 } 256 263 ] 257 264 ]; -
groundhogg/tags/4.2.10/includes/steps/premium/actions/advanced-timer.php
r3343709 r3422142 33 33 */ 34 34 public function get_description() { 35 return _x( 'Use a <code>strtotime</code>friendly string to create a delay.', 'step_description', 'groundhogg' );35 return _x( 'Use a `strtotime()` friendly string to create a delay.', 'step_description', 'groundhogg' ); 36 36 } 37 37 -
groundhogg/tags/4.2.10/includes/utils/date-time-helper.php
r3352676 r3422142 8 8 9 9 class DateTimeHelper extends \DateTime { 10 11 const ZERODATE = "0000-00-00"; 12 const ZEROTIME = "00:00:00"; 13 const ZERODATETIME = "0000-00-00 00:00:00"; 10 14 11 15 public function __construct( $datetime = 'now', \DateTimeZone $timezone = null ) { -
groundhogg/tags/4.2.10/templates/archive/campaign.php
r3343709 r3422142 111 111 ->contains( "$join->alias.plain_text", $search ); 112 112 } 113 114 /** 115 * Allow modifying the broadcast query, perhaps to restrict what can appear in the archive. 116 * 117 * @param $query Table_Query 118 */ 119 do_action_ref_array( 'groundhogg/archive/broadcast_query', [ &$broadcastQuery ] ); 113 120 114 121 $items = $broadcastQuery->get_objects(); -
groundhogg/tags/4.2.10/templates/archive/campaigns.php
r3343709 r3422142 69 69 } 70 70 71 /** 72 * Allow modifying the campaigns query, perhaps to restrict what can appear in the archive. 73 * 74 * @param $query Table_Query 75 */ 76 do_action_ref_array( 'groundhogg/archive/campaigns_query', [ &$campaignsQuery ] ); 77 71 78 $items = $campaignsQuery->get_objects(); 72 79 $total_items = $campaignsQuery->get_found_rows(); -
groundhogg/tags/4.2.10/templates/archive/events.php
r3343709 r3422142 3 3 namespace Groundhogg; 4 4 5 use Groundhogg\Cli\Table; 5 6 use Groundhogg\DB\Query\Table_Query; 6 7 use Groundhogg\Utils\DateTimeHelper; … … 105 106 } 106 107 108 /** 109 * Allow modifying the events query, perhaps to restrict what can appear in the archive. 110 * 111 * @param $query Table_Query 112 */ 113 do_action_ref_array( 'groundhogg/archive/events_query', [ &$eventsQuery ] ); 114 107 115 $events = $eventsQuery->get_results(); 108 116 -
groundhogg/trunk/README.txt
r3400645 r3422142 5 5 Donate link: https://www.groundhogg.io/pricing/ 6 6 Requires at least: 5.9 7 Tested up to: 6. 87 Tested up to: 6.9 8 8 Requires PHP: 7.1 9 Stable tag: 4.2. 99 Stable tag: 4.2.10 10 10 License: GPLv3 11 11 License URI: https://www.gnu.org/licenses/gpl.md … … 378 378 379 379 == Changelog == 380 381 = 4.2.10 (2025-12-12) = 382 * ADDED Start tracking the date when a tag is added to a contact. *Not* retroactive. 383 * ADDED Developer filters to modify queries for the email archive. 384 * FIXED UI issue in The Flow History filter. 385 * FIXED Form selection in the Form Block not working unless a form was already selected. 386 * FIXED Description formatting for the Advanced Timer action. 387 * FIXED PHP Notice if a custom field tab was not configured correctly. 380 388 381 389 = 4.2.9 (2025-11-21) = -
groundhogg/trunk/assets/js/admin/components.js
r3400645 r3422142 124 124 removeTags = [], 125 125 addTags = [], 126 dates = {}, 126 127 onChange = (changes) => { 127 128 … … 139 140 ${ selected.map(tag => `<span class="gh-tag${ removeTags.includes(tag.ID) 140 141 ? ' remove' 141 : '' }">${ tag.data.tag_name } <span data-id="${ tag.ID }" class="remove-tag dashicons dashicons-no-alt"></span></span>`).142 : '' }">${ tag.data.tag_name } ${dates.hasOwnProperty(tag.ID) ? `<span class="gh-tooltip top">${dates[tag.ID]}</span>` : ''}<span data-id="${ tag.ID }" class="remove-tag dashicons dashicons-no-alt"></span></span>`). 142 143 join('') } 143 144 ${ addTags.map(id => TagsStore.get(id)). -
groundhogg/trunk/assets/js/admin/components.min.js
r3400645 r3422142 1 ($=>{const{modal,errorDialog,loadingDots,select,uuid,addMediaToBasicTinyMCE,specialChars,tinymceElement,searchOptionsWidget,input,isNumeric,icons,dialog,tooltip,regexp,isValidEmail,loadingModal,textarea,spinner,skeleton,adminPageURL}=Groundhogg.element;const{Div,H2,H4,Toggle,Img,An,Span,ModalFrame,Iframe,makeEl,Button,Modal,ModalWithHeader,Dashicon,ToolTip,Input,TinyMCE,Label,Fragment,ItemPicker,Skeleton,Pg,Form,Textarea,InputGroup}=MakeEl;const{contacts:ContactsStore,tags:TagsStore,forms:FormsStore,emails:EmailsStore}=Groundhogg.stores;const{post,routes,postFormData}=Groundhogg.api;const{tagPicker}=Groundhogg.pickers;const{userHasCap,getOwner}=Groundhogg.user;const{sprintf,__,_x,_n}=wp.i18n;const{formatDateTime}=Groundhogg.formatting;const{currentUser}=Groundhogg;const{maybeCall,debounce,jsonCopy}=Groundhogg.functions;const selectContactModal=({onSelect=()=>{},onClose=()=>{},exclude=[]})=>{Modal({dialogClasses:"no-padding",width:"400px",onOpen:e=>{document.getElementById("quick-search-input").focus()}},({close})=>QuickSearch({itemProps:contact=>({onClick:e=>{onSelect(contact);close()}}),queryOverrides:{limit:15,exclude:exclude}}))};const betterTagPicker=(el,{selected=[],removeTags=[],addTags=[], onChange=changes=>{}})=>{const $el=$(el);let timeout;const template=()=>{return`1 ($=>{const{modal,errorDialog,loadingDots,select,uuid,addMediaToBasicTinyMCE,specialChars,tinymceElement,searchOptionsWidget,input,isNumeric,icons,dialog,tooltip,regexp,isValidEmail,loadingModal,textarea,spinner,skeleton,adminPageURL}=Groundhogg.element;const{Div,H2,H4,Toggle,Img,An,Span,ModalFrame,Iframe,makeEl,Button,Modal,ModalWithHeader,Dashicon,ToolTip,Input,TinyMCE,Label,Fragment,ItemPicker,Skeleton,Pg,Form,Textarea,InputGroup}=MakeEl;const{contacts:ContactsStore,tags:TagsStore,forms:FormsStore,emails:EmailsStore}=Groundhogg.stores;const{post,routes,postFormData}=Groundhogg.api;const{tagPicker}=Groundhogg.pickers;const{userHasCap,getOwner}=Groundhogg.user;const{sprintf,__,_x,_n}=wp.i18n;const{formatDateTime}=Groundhogg.formatting;const{currentUser}=Groundhogg;const{maybeCall,debounce,jsonCopy}=Groundhogg.functions;const selectContactModal=({onSelect=()=>{},onClose=()=>{},exclude=[]})=>{Modal({dialogClasses:"no-padding",width:"400px",onOpen:e=>{document.getElementById("quick-search-input").focus()}},({close})=>QuickSearch({itemProps:contact=>({onClick:e=>{onSelect(contact);close()}}),queryOverrides:{limit:15,exclude:exclude}}))};const betterTagPicker=(el,{selected=[],removeTags=[],addTags=[],dates={},onChange=changes=>{}})=>{const $el=$(el);let timeout;const template=()=>{return` 2 2 <div class="gh-tags"> 3 ${selected.map(tag=>`<span class="gh-tag${removeTags.includes(tag.ID)?" remove":""}">${tag.data.tag_name} <span data-id="${tag.ID}" class="remove-tag dashicons dashicons-no-alt"></span></span>`).join("")}3 ${selected.map(tag=>`<span class="gh-tag${removeTags.includes(tag.ID)?" remove":""}">${tag.data.tag_name} ${dates.hasOwnProperty(tag.ID)?`<span class="gh-tooltip top">${dates[tag.ID]}</span>`:""}<span data-id="${tag.ID}" class="remove-tag dashicons dashicons-no-alt"></span></span>`).join("")} 4 4 ${addTags.map(id=>TagsStore.get(id)).map(tag=>`<span class="gh-tag adding">${tag.data.tag_name} <span data-id="${tag.ID}" class="remove-adding-tag dashicons dashicons-no-alt"></span></span>`).join("")} 5 5 <button class="add-tag"> -
groundhogg/trunk/assets/js/admin/element.min.js
r3343709 r3422142 1 (function($){var $doc=$(document);const{sprintf,__,_x,_n}=wp.i18n;function insertAtCursor(field,value){if(document.selection){field.focus();var sel=document.selection.createRange();sel.text=value}else if(field.selectionStart||field.selectionStart=="0"){var startPos=field.selectionStart;var endPos=field.selectionEnd;field.value=field.value.substring(0,startPos)+value+field.value.substring(endPos,field.value.length);field.selectionStart=startPos+value.length;field.selectionEnd=startPos+value.length}else{field.value+=value}let input=new Event("input");let change=new Event("change");field.dispatchEvent(input);field.dispatchEvent(change)}const Insert={active:null,text:"",to_mce:false,init:function(){var self=this;$doc.on("ghClearInsertTarget",function(){self.to_mce=false;self.active=false});$doc.on("to_mce",function(){self.to_mce=true;$doc.trigger("ghInsertTargetChanged")});$doc.on("focus","input:not(.no-insert), textarea:not(.no-insert)",function(){self.active=this;self.to_mce=false;$doc.trigger("ghInsertTargetChanged")})},setActive(el){this.active=el},inserting(){return this.active||this.to_mce},insert:function(text){if(typeof tinymce!="undefined"&&tinymce.activeEditor!=null&&this.to_mce){tinymce.activeEditor.execCommand("mceInsertContent",false,text)}if(this.active!=null&&!this.to_mce){insertAtCursor(this.active,text);return this.active}}};$(()=>{Insert.init()});window.InsertAtCursor=Insert;Object.filter=function(obj,predicate){let result={},key;for(key in obj){if(obj.hasOwnProperty(key)&&predicate(key,obj[key])){result[key]=obj[key]}}return result};const tooltip=(selector,{content :content="",position:position="bottom"})=>{const $el=$(selector);if($el.hasClass("gh-has-tooltip")){return}const $tip=$(`1 (function($){var $doc=$(document);const{sprintf,__,_x,_n}=wp.i18n;function insertAtCursor(field,value){if(document.selection){field.focus();var sel=document.selection.createRange();sel.text=value}else if(field.selectionStart||field.selectionStart=="0"){var startPos=field.selectionStart;var endPos=field.selectionEnd;field.value=field.value.substring(0,startPos)+value+field.value.substring(endPos,field.value.length);field.selectionStart=startPos+value.length;field.selectionEnd=startPos+value.length}else{field.value+=value}let input=new Event("input");let change=new Event("change");field.dispatchEvent(input);field.dispatchEvent(change)}const Insert={active:null,text:"",to_mce:false,init:function(){var self=this;$doc.on("ghClearInsertTarget",function(){self.to_mce=false;self.active=false});$doc.on("to_mce",function(){self.to_mce=true;$doc.trigger("ghInsertTargetChanged")});$doc.on("focus","input:not(.no-insert), textarea:not(.no-insert)",function(){self.active=this;self.to_mce=false;$doc.trigger("ghInsertTargetChanged")})},setActive(el){this.active=el},inserting(){return this.active||this.to_mce},insert:function(text){if(typeof tinymce!="undefined"&&tinymce.activeEditor!=null&&this.to_mce){tinymce.activeEditor.execCommand("mceInsertContent",false,text)}if(this.active!=null&&!this.to_mce){insertAtCursor(this.active,text);return this.active}}};$(()=>{Insert.init()});window.InsertAtCursor=Insert;Object.filter=function(obj,predicate){let result={},key;for(key in obj){if(obj.hasOwnProperty(key)&&predicate(key,obj[key])){result[key]=obj[key]}}return result};const tooltip=(selector,{content="",position="bottom"})=>{const $el=$(selector);if($el.hasClass("gh-has-tooltip")){return}const $tip=$(` 2 2 <div class="gh-tooltip ${position}"> 3 3 ${content} … … 14 14 <div class="gh-step-nav"> 15 15 ${labels.map((l,i)=>stepNum(l,i)).join(`<hr class="gh-step-nav-join"/>`)} 16 </div>`};const stepNavHandler=(selector,{currentStep :currentStep=0,steps:steps=[],onStepChange:onStepChange=step=>{console.log(step)},showNav:showNav=true,labels})=>{this.currStep=currentStep;const mountStep=()=>{const step=steps[this.currStep];const html=`16 </div>`};const stepNavHandler=(selector,{currentStep=0,steps=[],onStepChange=step=>{console.log(step)},showNav=true,labels})=>{this.currStep=currentStep;const mountStep=()=>{const step=steps[this.currStep];const html=` 17 17 <div class="step-nav-handler"> 18 18 ${showNav?stepNav({labels:labels,currentStep:this.currStep}):""} … … 25 25 <span class="fill-amount">0%</span> 26 26 </div> 27 </div>`;const $bar=$(html);const $fill=$bar.find(".gh-progress-bar-fill");const $el=$(selector);$el.html($bar);const setProgress=progress=>{if(progress<=1){progress=progress*100}if(progress>=100){progress=100}if(progress===100){$bar.addClass("complete")}else{$bar.removeClass("complete")}$fill.css({width:progress+"%"}).html(`<span class="fill-amount">${Math.ceil(progress)}%</span>`)};return{setProgress:setProgress}};const createSlotFillProvider=()=>({fills:[],_slotsMounted:[],_slotsDemounted:[],slot(slotName,...args){this._slotsMounted.push({name:slotName,args:args});return this.fills.filter(fill=>fill.slot===slotName).map(fill=>fill.render(...args)).join("")},slotsMounted(){let slot;while(this._slotsMounted.length>0){slot=this._slotsMounted.pop();this.fills.filter(fill=>fill.slot===slot.name).forEach(fill=>{fill.onMount(...slot.args)});this._slotsDemounted.push(slot)}},slotsDemounted(){let slot;while(this._slotsDemounted.length>0){slot=this._slotsDemounted.pop();this.fills.filter(fill=>fill.slot===slot.name).forEach(fill=>{fill.onDemount(...slot.args)})}},fill(slot,component){this.fills.push({slot:slot,...{render(){},onMount(){},onDemount(){},...component}})}});function isString(string){return typeof string==="string"}function isNumeric(n){return!isNaN(parseFloat(n))&&isFinite(n)}const specialChars=string=>{if(!isString(string)){return string}return string.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/"/g,""")};const escHTML=string=>specialChars(string);const kebabize=str=>{return str.split("").map((letter,idx)=>{return letter.toUpperCase()===letter?`${idx!==0?"-":""}${letter.toLowerCase()}`:letter}).join("")};const objectToStyle=object=>{const props=[];for(const prop in object){if(object.hasOwnProperty(prop)){let attr=kebabize(prop);let val=object[prop];if(typeof val==="undefined"||val===null||val===""||val==="null"){continue}switch(attr){case"font-size":case"height":case"width":case"margin":case"padding":case"margin-top":if(isNumeric(val)){val+="px"}break}props.push(`${attr}:${val}`)}}if(props.length){return props.join(";")+";"}return""};function uuid(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,c=>(c^crypto.getRandomValues(new Uint8Array(1))[0]&15>>c/4).toString(16))}const objectToProps=object=>{const props=[];for(const prop in object){if(object.hasOwnProperty(prop)&&typeof object[prop]!=="undefined"&&object[prop]!==false){switch(prop){case"className":props.push(`class="${specialChars(object[prop])}"`);break;case"style":props.push(`style="${specialChars(objectToStyle(object[prop]))}"`);break;default:props.push(`${kebabize(prop)}="${specialChars(object[prop])}"`);break}}}return props.join(" ")};const Elements={toggle({id,name,className,value :value="1",onLabel:onLabel="on",offLabel:offLabel="off",checked,...props}){return`27 </div>`;const $bar=$(html);const $fill=$bar.find(".gh-progress-bar-fill");const $el=$(selector);$el.html($bar);const setProgress=progress=>{if(progress<=1){progress=progress*100}if(progress>=100){progress=100}if(progress===100){$bar.addClass("complete")}else{$bar.removeClass("complete")}$fill.css({width:progress+"%"}).html(`<span class="fill-amount">${Math.ceil(progress)}%</span>`)};return{setProgress:setProgress}};const createSlotFillProvider=()=>({fills:[],_slotsMounted:[],_slotsDemounted:[],slot(slotName,...args){this._slotsMounted.push({name:slotName,args:args});return this.fills.filter(fill=>fill.slot===slotName).map(fill=>fill.render(...args)).join("")},slotsMounted(){let slot;while(this._slotsMounted.length>0){slot=this._slotsMounted.pop();this.fills.filter(fill=>fill.slot===slot.name).forEach(fill=>{fill.onMount(...slot.args)});this._slotsDemounted.push(slot)}},slotsDemounted(){let slot;while(this._slotsDemounted.length>0){slot=this._slotsDemounted.pop();this.fills.filter(fill=>fill.slot===slot.name).forEach(fill=>{fill.onDemount(...slot.args)})}},fill(slot,component){this.fills.push({slot:slot,...{render(){},onMount(){},onDemount(){},...component}})}});function isString(string){return typeof string==="string"}function isNumeric(n){return!isNaN(parseFloat(n))&&isFinite(n)}const specialChars=string=>{if(!isString(string)){return string}return string.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/"/g,""")};const escHTML=string=>specialChars(string);const kebabize=str=>{return str.split("").map((letter,idx)=>{return letter.toUpperCase()===letter?`${idx!==0?"-":""}${letter.toLowerCase()}`:letter}).join("")};const objectToStyle=object=>{const props=[];for(const prop in object){if(object.hasOwnProperty(prop)){let attr=kebabize(prop);let val=object[prop];if(typeof val==="undefined"||val===null||val===""||val==="null"){continue}switch(attr){case"font-size":case"height":case"width":case"margin":case"padding":case"margin-top":if(isNumeric(val)){val+="px"}break}props.push(`${attr}:${val}`)}}if(props.length){return props.join(";")+";"}return""};function uuid(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,c=>(c^crypto.getRandomValues(new Uint8Array(1))[0]&15>>c/4).toString(16))}const objectToProps=object=>{const props=[];for(const prop in object){if(object.hasOwnProperty(prop)&&typeof object[prop]!=="undefined"&&object[prop]!==false){switch(prop){case"className":props.push(`class="${specialChars(object[prop])}"`);break;case"style":props.push(`style="${specialChars(objectToStyle(object[prop]))}"`);break;default:props.push(`${kebabize(prop)}="${specialChars(object[prop])}"`);break}}}return props.join(" ")};const Elements={toggle({id,name,className,value="1",onLabel="on",offLabel="off",checked,...props}){return` 28 28 <label class="gh-switch ${className}"> 29 29 ${Elements.input({name:name,id:id,value:value,checked:checked,...props,type:"checkbox"})} … … 31 31 <span class="on">${onLabel}</span> 32 32 <span class="off">${offLabel}</span> 33 </label>`},input(props){props={type:"text",className:"input regular-text",...props};return`<input ${objectToProps(props)}/>`},select(_props,_options={},_selected=false){let{options :options=_options,selected:selected=_selected,value,...props}=_props;if(value&&!selected){selected=value}return`<select ${objectToProps(props)}>${createOptions(options,selected)}</select>`},option:function(value,text,selected){return`33 </label>`},input(props){props={type:"text",className:"input regular-text",...props};return`<input ${objectToProps(props)}/>`},select(_props,_options={},_selected=false){let{options=_options,selected=_selected,value,...props}=_props;if(value&&!selected){selected=value}return`<select ${objectToProps(props)}>${createOptions(options,selected)}</select>`},option:function(value,text,selected){return` 34 34 <option value="${specialChars(value)}" ${selected?"selected":""}> 35 35 ${text} … … 51 51 </button>`:""} 52 52 </div> 53 </div>`},textAreaWithReplacements:function(atts){return Elements.textAreaWithReplacementsAndEmojis(atts,true,false)},textAreaWithEmojis:function(atts){return Elements.textAreaWithReplacementsAndEmojis(atts,false,true)}};var codeMirror;var codeMirrorIsFocused;$doc.on("ghInsertReplacement",function(e,insert){if(codeMirrorIsFocused){codeMirror.doc.replaceSelection(insert)}});$doc.on("ghReplacementTargetChanged",function(){codeMirrorIsFocused=false});const codeEditor=({selector :selector="",onChange:onChange=content=>{},initialContent:initialContent="",height:height=500})=>{var editorSettings=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{};editorSettings.codemirror=_.extend({},editorSettings.codemirror,{indentUnit:4,tabSize:4});codeMirror=wp.codeEditor.initialize($(selector),editorSettings).codemirror;codeMirror.on("change",function(){onChange(codeMirror.doc.getValue())});codeMirror.on("focus",function(){codeMirrorIsFocused=true;$doc.trigger("ghClearReplacementTarget")});codeMirror.doc.setValue(html_beautify(initialContent,{indent_with_tabs:true}));codeMirror.setSize(null,height);return{editor:codeMirror}};const addReplacementsToolbarTinyMCE=(event,editor)=>{editor.settings.toolbar1+=",gh_replacements";editor.addButton("gh_replacements",{title:"Replacements",image:"",onclick:e=>{InsertAtCursor.to_mce=true;Groundhogg.element.replacementsWidget({target:e.target}).mount()}});$(document).off("tinymce-editor-setup",addReplacementsToolbarTinyMCE)};const addTemplateButtonTinyMCE=(event,editor,config)=>{const{note_type:note_type="",plural}=config;const buttonId=`gh_${note_type}`;editor.settings.toolbar1+=","+buttonId;editor.addButton(buttonId,{title:plural,image:"",onclick:async e=>{let replies=await Groundhogg.stores.replies.fetchItems({type:note_type});return searchOptionsWidget({position:"fixed",target:e.target,options:[{manage:1,data:{summary:`📝 Manage ${plural.toLowerCase()}`}},...replies],filterOption:({data},search)=>data.summary.match(regexp(search)),renderOption:option=>option.data.summary,onSelect:option=>{if(option.manage===1){Groundhogg.SavedRepliesModal(config);return}editor.execCommand("mceInsertContent",false,option.data.content)}}).mount()}})};const addSavedRepliesToolbarTinyMCE=(event,editor)=>{addTemplateButtonTinyMCE(event,editor,{single:"Saved Reply",plural:"Saved Replies",note_type:"saved_reply"});$(document).off("tinymce-editor-setup",addSavedRepliesToolbarTinyMCE)};const addNoteTemplatesToolbarTinyMCE=(event,editor)=>{addTemplateButtonTinyMCE(event,editor,{single:"Note Template",plural:"Note Templates",note_type:"note_template"});$(document).off("tinymce-editor-setup",addNoteTemplatesToolbarTinyMCE)};const addTaskTemplatesToolbarTinyMCE=(event,editor)=>{addTemplateButtonTinyMCE(event,editor,{single:"Task Template",plural:"Task Templates",note_type:"task_template"});$(document).off("tinymce-editor-setup",addTaskTemplatesToolbarTinyMCE)};const addMediaButtonToTinyMCE=(event,editor)=>{editor.settings.toolbar1+=",wp_add_media";$(document).off("tinymce-editor-setup",addMediaButtonToTinyMCE)};const addPostMergeTagsToTinyMCE=(event,editor)=>{editor.settings.toolbar1+=",gh_post_merge_tags";editor.addButton("gh_post_merge_tags",{title:"Post Merge Tags",image:"",onclick:async e=>{return searchOptionsWidget({position:"fixed",target:e.target,options:Groundhogg.emailEditor.PostTagReference,filterOption:({desc},search)=>desc.match(regexp(search)),renderOption:option=>option.desc,onSelect:option=>{editor.execCommand("mceInsertContent",false,`#${option.tag}#`)}}).mount()}});$(document).off("tinymce-editor-setup",addPostMergeTagsToTinyMCE)};const tinymceElement=(editor_id,config={},onChange=v=>{console.log(v)})=>{if(config.replacements===true){$(document).on("tinymce-editor-setup",addReplacementsToolbarTinyMCE);delete config.replacements}if(config.posttags===true){$(document).on("tinymce-editor-setup",addPostMergeTagsToTinyMCE);delete config.posttags}if(config.media===true){$(document).on("tinymce-editor-setup",addMediaButtonToTinyMCE);delete config.media}if(config.savedReplies===true){$(document).on("tinymce-editor-setup",addSavedRepliesToolbarTinyMCE);delete config.savedReplies}if(config.taskTemplates===true){$(document).on("tinymce-editor-setup",addTaskTemplatesToolbarTinyMCE);delete config.taskTemplates}if(config.noteTemplates===true){$(document).on("tinymce-editor-setup",addNoteTemplatesToolbarTinyMCE);delete config.noteTemplates}wp.editor.initialize(editor_id,{tinymce:true,quicktags:true,...config});let editor=tinyMCE.get(editor_id);editor.on("keyup",e=>{Insert.to_mce=true;if(e.type=="keyup"&&e.ctrlKey&&e.shiftKey&&e.which==219){if(GlobalReplacementsWidget&&GlobalReplacementsWidget.isOpen()){return}editor.execCommand("mceInsertContent",false,'<span id="rep-here">{</span>');GlobalReplacementsWidget=replacementsWidget({target:editor.iframeElement.contentWindow.document.getElementById("rep-here"),offset:editor.iframeElement.getBoundingClientRect(),onClose:()=>{editor.dom.remove("rep-here")}});GlobalReplacementsWidget.mount()}});editor.on("Change",e=>{onChange(editor.getContent())});return editor};function addMediaToBasicTinyMCE(){if(typeof this.flag!=="undefined"){return}$doc.on("tinymce-editor-setup",function(event,editor){editor.settings.toolbar1="bold,italic,bullist,numlist,alignleft,aligncenter,alignright,link,wp_add_media";editor.on("click",function(ed,e){$doc.trigger("to_mce")})});this.flag="improved"}function improveTinyMCE(settings={}){const{height:height=0}=settings;if(typeof this.flag!=="undefined"){return}$doc.on("tinymce-editor-setup",function(event,editor){editor.settings.toolbar1="formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,spellchecker,wp_adv,wp_add_media,dfw";editor.settings.toolbar2="strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help";if(height>0){editor.settings.height=height}editor.on("click",function(ed,e){$doc.trigger("to_mce")})});this.flag="improved"}const progressModal=({beforeProgress:beforeProgress=()=>"",afterProgress:afterProgress=()=>"",onOpen:onOpen=()=>{},...rest})=>{return modal({canClose:false,width:500,content:`53 </div>`},textAreaWithReplacements:function(atts){return Elements.textAreaWithReplacementsAndEmojis(atts,true,false)},textAreaWithEmojis:function(atts){return Elements.textAreaWithReplacementsAndEmojis(atts,false,true)}};var codeMirror;var codeMirrorIsFocused;$doc.on("ghInsertReplacement",function(e,insert){if(codeMirrorIsFocused){codeMirror.doc.replaceSelection(insert)}});$doc.on("ghReplacementTargetChanged",function(){codeMirrorIsFocused=false});const codeEditor=({selector="",onChange=content=>{},initialContent="",height=500})=>{var editorSettings=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{};editorSettings.codemirror=_.extend({},editorSettings.codemirror,{indentUnit:4,tabSize:4});codeMirror=wp.codeEditor.initialize($(selector),editorSettings).codemirror;codeMirror.on("change",function(){onChange(codeMirror.doc.getValue())});codeMirror.on("focus",function(){codeMirrorIsFocused=true;$doc.trigger("ghClearReplacementTarget")});codeMirror.doc.setValue(html_beautify(initialContent,{indent_with_tabs:true}));codeMirror.setSize(null,height);return{editor:codeMirror}};const addReplacementsToolbarTinyMCE=(event,editor)=>{editor.settings.toolbar1+=",gh_replacements";editor.addButton("gh_replacements",{title:"Replacements",image:"",onclick:e=>{InsertAtCursor.to_mce=true;Groundhogg.element.replacementsWidget({target:e.target}).mount()}});$(document).off("tinymce-editor-setup",addReplacementsToolbarTinyMCE)};const addTemplateButtonTinyMCE=(event,editor,config)=>{const{note_type="",plural}=config;const buttonId=`gh_${note_type}`;editor.settings.toolbar1+=","+buttonId;editor.addButton(buttonId,{title:plural,image:"",onclick:async e=>{let replies=await Groundhogg.stores.replies.fetchItems({type:note_type});return searchOptionsWidget({position:"fixed",target:e.target,options:[{manage:1,data:{summary:`📝 Manage ${plural.toLowerCase()}`}},...replies],filterOption:({data},search)=>data.summary.match(regexp(search)),renderOption:option=>option.data.summary,onSelect:option=>{if(option.manage===1){Groundhogg.SavedRepliesModal(config);return}editor.execCommand("mceInsertContent",false,option.data.content)}}).mount()}})};const addSavedRepliesToolbarTinyMCE=(event,editor)=>{addTemplateButtonTinyMCE(event,editor,{single:"Saved Reply",plural:"Saved Replies",note_type:"saved_reply"});$(document).off("tinymce-editor-setup",addSavedRepliesToolbarTinyMCE)};const addNoteTemplatesToolbarTinyMCE=(event,editor)=>{addTemplateButtonTinyMCE(event,editor,{single:"Note Template",plural:"Note Templates",note_type:"note_template"});$(document).off("tinymce-editor-setup",addNoteTemplatesToolbarTinyMCE)};const addTaskTemplatesToolbarTinyMCE=(event,editor)=>{addTemplateButtonTinyMCE(event,editor,{single:"Task Template",plural:"Task Templates",note_type:"task_template"});$(document).off("tinymce-editor-setup",addTaskTemplatesToolbarTinyMCE)};const addMediaButtonToTinyMCE=(event,editor)=>{editor.settings.toolbar1+=",wp_add_media";$(document).off("tinymce-editor-setup",addMediaButtonToTinyMCE)};const addPostMergeTagsToTinyMCE=(event,editor)=>{editor.settings.toolbar1+=",gh_post_merge_tags";editor.addButton("gh_post_merge_tags",{title:"Post Merge Tags",image:"",onclick:async e=>{return searchOptionsWidget({position:"fixed",target:e.target,options:Groundhogg.emailEditor.PostTagReference,filterOption:({desc},search)=>desc.match(regexp(search)),renderOption:option=>option.desc,onSelect:option=>{editor.execCommand("mceInsertContent",false,`#${option.tag}#`)}}).mount()}});$(document).off("tinymce-editor-setup",addPostMergeTagsToTinyMCE)};const tinymceElement=(editor_id,config={},onChange=v=>{console.log(v)})=>{if(config.replacements===true){$(document).on("tinymce-editor-setup",addReplacementsToolbarTinyMCE);delete config.replacements}if(config.posttags===true){$(document).on("tinymce-editor-setup",addPostMergeTagsToTinyMCE);delete config.posttags}if(config.media===true){$(document).on("tinymce-editor-setup",addMediaButtonToTinyMCE);delete config.media}if(config.savedReplies===true){$(document).on("tinymce-editor-setup",addSavedRepliesToolbarTinyMCE);delete config.savedReplies}if(config.taskTemplates===true){$(document).on("tinymce-editor-setup",addTaskTemplatesToolbarTinyMCE);delete config.taskTemplates}if(config.noteTemplates===true){$(document).on("tinymce-editor-setup",addNoteTemplatesToolbarTinyMCE);delete config.noteTemplates}wp.editor.initialize(editor_id,{tinymce:true,quicktags:true,...config});let editor=tinyMCE.get(editor_id);editor.on("keyup",e=>{Insert.to_mce=true;if(e.type=="keyup"&&e.ctrlKey&&e.shiftKey&&e.which==219){if(GlobalReplacementsWidget&&GlobalReplacementsWidget.isOpen()){return}editor.execCommand("mceInsertContent",false,'<span id="rep-here">{</span>');GlobalReplacementsWidget=replacementsWidget({target:editor.iframeElement.contentWindow.document.getElementById("rep-here"),offset:editor.iframeElement.getBoundingClientRect(),onClose:()=>{editor.dom.remove("rep-here")}});GlobalReplacementsWidget.mount()}});editor.on("Change",e=>{onChange(editor.getContent())});return editor};function addMediaToBasicTinyMCE(){if(typeof this.flag!=="undefined"){return}$doc.on("tinymce-editor-setup",function(event,editor){editor.settings.toolbar1="bold,italic,bullist,numlist,alignleft,aligncenter,alignright,link,wp_add_media";editor.on("click",function(ed,e){$doc.trigger("to_mce")})});this.flag="improved"}function improveTinyMCE(settings={}){const{height=0}=settings;if(typeof this.flag!=="undefined"){return}$doc.on("tinymce-editor-setup",function(event,editor){editor.settings.toolbar1="formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,spellchecker,wp_adv,wp_add_media,dfw";editor.settings.toolbar2="strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help";if(height>0){editor.settings.height=height}editor.on("click",function(ed,e){$doc.trigger("to_mce")})});this.flag="improved"}const progressModal=({beforeProgress=()=>"",afterProgress=()=>"",onOpen=()=>{},...rest})=>{return modal({canClose:false,width:500,content:` 54 54 ${beforeProgress()} 55 55 <div id="progress-modal"></div> … … 60 60 width="150" 61 61 height="150"/> 62 </div>`};const skeleton=()=>{if(typeof MakeEl!=="undefined"){return MakeEl.Skeleton({style:{padding:"10px"}},["full","full","full"]).outerHTML}return""};const savingModal=()=>{return loadingModal("Saving")};const dangerConfirmationModal=props=>{return confirmationModal({...props,confirmButtonType:"danger",cancelButtonType:"primary text"})};const dangerDeleteModal=({name,...props})=>dangerConfirmationModal({alert:`<p>${sprintf(__("Are you sure you want to delete %s? This action cannot be undone.","groundhogg"),name)}</p>`,confirmText:__("Delete"),...props});const dangerModalLink=(e,alert="",props={})=>{e.preventDefault();if(e.currentTarget.dataset.alert){alert=e.currentTarget.dataset.alert}dangerConfirmationModal({alert:`<p>${alert}</p>`,onConfirm:()=>{window.location.href=e.target.closest("a").href},...props})};$(document).on("submit","form.danger-permanent",e=>{e.preventDefault();dangerModalLink(e,__("Are you sure? This action cannot be undone.","groundhogg"),{onConfirm:()=>{e.currentTarget.submit()}})});$(document).on("click","a.danger-confirm",e=>dangerModalLink(e,__("Are you sure?","groundhogg")));$(document).on("click","a.danger-permanent",e=>dangerModalLink(e,__("Are you sure? This action cannot be undone.","groundhogg")));$(document).on("click","a.danger-delete",e=>{let msg=__("Are you sure? This action cannot be undone.","groundhogg");if(e.currentTarget.dataset.name){msg=sprintf(__("Are you sure you want to delete %s? This action cannot be undone.","groundhogg"),bold(e.currentTarget.dataset.name))}dangerModalLink(e,msg,{confirmText:__("Delete")})});const confirmationModal=({alert :alert="",confirmText:confirmText=_x("Confirm","verb","groundhogg"),closeText:closeText=__("Cancel","groundhogg"),onConfirm:onConfirm=()=>{},onCancel:onCancel=()=>{},onClose:onClose=()=>{},confirmButtonType:confirmButtonType="primary",cancelButtonType:cancelButtonType="danger text",buttonSize:buttonSize="medium",...rest})=>{let confirmed=false;const content=`62 </div>`};const skeleton=()=>{if(typeof MakeEl!=="undefined"){return MakeEl.Skeleton({style:{padding:"10px"}},["full","full","full"]).outerHTML}return""};const savingModal=()=>{return loadingModal("Saving")};const dangerConfirmationModal=props=>{return confirmationModal({...props,confirmButtonType:"danger",cancelButtonType:"primary text"})};const dangerDeleteModal=({name,...props})=>dangerConfirmationModal({alert:`<p>${sprintf(__("Are you sure you want to delete %s? This action cannot be undone.","groundhogg"),name)}</p>`,confirmText:__("Delete"),...props});const dangerModalLink=(e,alert="",props={})=>{e.preventDefault();if(e.currentTarget.dataset.alert){alert=e.currentTarget.dataset.alert}dangerConfirmationModal({alert:`<p>${alert}</p>`,onConfirm:()=>{window.location.href=e.target.closest("a").href},...props})};$(document).on("submit","form.danger-permanent",e=>{e.preventDefault();dangerModalLink(e,__("Are you sure? This action cannot be undone.","groundhogg"),{onConfirm:()=>{e.currentTarget.submit()}})});$(document).on("click","a.danger-confirm",e=>dangerModalLink(e,__("Are you sure?","groundhogg")));$(document).on("click","a.danger-permanent",e=>dangerModalLink(e,__("Are you sure? This action cannot be undone.","groundhogg")));$(document).on("click","a.danger-delete",e=>{let msg=__("Are you sure? This action cannot be undone.","groundhogg");if(e.currentTarget.dataset.name){msg=sprintf(__("Are you sure you want to delete %s? This action cannot be undone.","groundhogg"),bold(e.currentTarget.dataset.name))}dangerModalLink(e,msg,{confirmText:__("Delete")})});const confirmationModal=({alert="",confirmText=_x("Confirm","verb","groundhogg"),closeText=__("Cancel","groundhogg"),onConfirm=()=>{},onCancel=()=>{},onClose=()=>{},confirmButtonType="primary",cancelButtonType="danger text",buttonSize="medium",...rest})=>{let confirmed=false;const content=` 63 63 <button type="button" 64 64 class="dashicon-button gh-modal-button-close-top gh-modal-button-close"> … … 77 77 ${confirmText} 78 78 </button> 79 </div>`;const handleClose=()=>{if(!confirmed){onCancel()}onClose()};const{close,$modal}=modal({content:content,onClose:handleClose,dialogClasses:"gh-modal-confirmation",...rest});const confirm=()=>{confirmed=true;onConfirm();close()};const handleConfirm=()=>{confirm()};$(".gh-modal-button-confirm").on("click",handleConfirm);return{close:close,confirm:confirm,$modal:$modal}};const miniModal=(selector,{content :content="",onSetContent:onSetContent=()=>{},onClose:onClose=()=>{},onOpen:onOpen=()=>{},dialogClasses:dialogClasses="",closeOnFocusout:closeOnFocusout=true})=>{const html=`79 </div>`;const handleClose=()=>{if(!confirmed){onCancel()}onClose()};const{close,$modal}=modal({content:content,onClose:handleClose,dialogClasses:"gh-modal-confirmation",...rest});const confirm=()=>{confirmed=true;onConfirm();close()};const handleConfirm=()=>{confirm()};$(".gh-modal-button-confirm").on("click",handleConfirm);return{close:close,confirm:confirm,$modal:$modal}};const miniModal=(selector,{content="",onSetContent=()=>{},onClose=()=>{},onOpen=()=>{},dialogClasses="",closeOnFocusout=true})=>{const html=` 80 80 <div class="gh-modal mini gh-panel" tabindex="0"> 81 81 <div class="gh-modal-dialog ${dialogClasses}"> … … 86 86 ${content} 87 87 </div> 88 </div>`;const $modal=$(html);const close=()=>{$modal.remove();$("body").removeClass("modal-open");onClose()};const handleClose=()=>{close()};const setContent=content=>{$modal.find(".gh-modal-dialog-content").html(content);onSetContent()};const $el=$(selector);$("body").append($modal);const{left,right,top,bottom}=$el[0].getBoundingClientRect();$modal.css({top:Math.min(bottom,window.innerHeight-$modal.height()-20)+"px",left:right-$modal.outerWidth()+"px"});onOpen();$modal.find(".gh-modal-button-close").on("click",handleClose);if(closeOnFocusout){$modal.on("focusout",e=>{if(!e.relatedTarget||!clickedIn(e.relatedTarget,".gh-modal.mini")){handleClose()}})}$modal.focus();return{$modal:$modal,close:close,setContent:setContent}};const modal=({content :content="",onSetContent:onSetContent=()=>{},onClose:onClose=()=>{},beforeClose:beforeClose=()=>true,canClose:canClose=true,onOpen:onOpen=()=>{},width:width=false,className:className="",dialogClasses:dialogClasses="",overlay:overlay=true,disableScrolling:disableScrolling=true})=>{const html=`88 </div>`;const $modal=$(html);const close=()=>{$modal.remove();$("body").removeClass("modal-open");onClose()};const handleClose=()=>{close()};const setContent=content=>{$modal.find(".gh-modal-dialog-content").html(content);onSetContent()};const $el=$(selector);$("body").append($modal);const{left,right,top,bottom}=$el[0].getBoundingClientRect();$modal.css({top:Math.min(bottom,window.innerHeight-$modal.height()-20)+"px",left:right-$modal.outerWidth()+"px"});onOpen();$modal.find(".gh-modal-button-close").on("click",handleClose);if(closeOnFocusout){$modal.on("focusout",e=>{if(!e.relatedTarget||!clickedIn(e.relatedTarget,".gh-modal.mini")){handleClose()}})}$modal.focus();return{$modal:$modal,close:close,setContent:setContent}};const modal=({content="",onSetContent=()=>{},onClose=()=>{},beforeClose=()=>true,canClose=true,onOpen=()=>{},width=false,className="",dialogClasses="",overlay=true,disableScrolling=true})=>{const html=` 89 89 <div class="gh-modal ${className} ${disableScrolling?"disabled-scrolling":""}"> 90 90 ${overlay?`<div class="gh-modal-overlay"></div>`:""} … … 98 98 </div> 99 99 </div> 100 </div>`;const $modal=$(html);const close=()=>{if(!beforeClose(close)){return}$modal.remove();if(disableScrolling&&$(".gh-modal.disabled-scrolling").length===0){$("body").removeClass("modal-open")}onClose()};const handleClose=()=>{close()};const maybeMoveHeader=()=>{$modal.find(".gh-modal-dialog > .gh-header").remove();let $header=$modal.find(".gh-modal-dialog-content .gh-header");if($header){$header.insertBefore($modal.find(".gh-modal-dialog-content"))}};const setContent=content=>{$modal.find(".gh-modal-dialog-content").html(content);maybeMoveHeader();onSetContent()};$("body").append($modal).addClass(disableScrolling?"modal-open":"");maybeMoveHeader();onOpen({close:close,setContent:setContent});if(canClose){$modal.find(".gh-modal-overlay, .gh-modal-button-close").on("click",handleClose)}return{$modal:$modal,close:close,setContent:setContent}};const wpErrorDialog=(error,props)=>{let message;if(Array.isArray(error)){message=error[0].message}if(typeof error==="object"&&error.message){message=error.message}return errorDialog({message:message,...props})};const errorDialog=props=>{return dialog({...props,type:"error"})};const dialog=({message :message="",animationDuration:animationDuration=300,ttl:ttl=3e3,type:type="success"})=>{const $dialog=$(`<div class="gh-dialog gh-dialog-${type}">${message}</div>`);$("body").append($dialog).addClass("dialog-open");$dialog.animate({top:40},animationDuration,"swing",()=>{setTimeout(()=>{$dialog.animate({top:-100},animationDuration,"swing",()=>{$dialog.remove()})},ttl)});return{$dialog:$dialog}};const loadingDots=selector=>{const $el=$('<span class="loading-dots"></span>');$(selector).append($el);const stop=()=>{clearInterval(interval);$el.remove()};const interval=setInterval(()=>{if($el.html().length>=3){$el.html(".")}else{$el.html($el.html()+".")}},500);return{stop:stop}};const createOptions=(options,selected)=>{const optionsString=[];if(Array.isArray(options)){options.forEach(option=>{if(typeof option!=="object"){option={value:option,text:option}}optionsString.push(Elements.option(option.value,option.text,Array.isArray(selected)?selected.indexOf(option.value)!==-1:option.value==selected))})}else{for(const option in options){if(options.hasOwnProperty(option)){optionsString.push(Elements.option(option,options[option],Array.isArray(selected)?selected.indexOf(option)!==-1:option==selected))}}}return optionsString.join("")};const regexp=str=>{return new RegExp(escapeRegex(str),"i")};function escapeRegex(string){return string.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}if(!Element.prototype.matches){Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(s){var matches=(this.document||this.ownerDocument).querySelectorAll(s),i=matches.length;while(--i>=0&&matches.item(i)!==this){}return i>-1}}const clickedIn=(e,selector)=>{return clickInsideElement(e,selector)};function clickInsideElement(e,selector){var el=e.tagName?e:e.srcElement||e.target;if(el&&el.matches(selector)){return el}else{while(el=el.parentNode){if(typeof el.matches!=="undefined"&&el.matches(selector)){return el}}}return false}const searchOptionsWidget=({selector:selector=".search-options-widget-wrap",target:target=null,offset:offset=null,position:position="inline",options:options=[],groups:groups={},filterOption:filterOption=(option,search)=>option.match(regexp(search)),renderOption:renderOption=option=>option,noOptions:noOptions=__("No options...","groundhogg"),onSelect:onSelect=option=>{},onInput:onInput=search=>{},onClose:onClose=()=>{},onOpen:onOpen=()=>{},filterOptions:filterOptions=(opts,search)=>opts})=>({selector:selector,options:options,onInput:onInput,filterOption:filterOption,renderOption:renderOption,onClose:onClose,onSelect:onSelect,groups:groups,_open:false,search:"",focusedOptionId:-1,previousFocusedOptionId:false,focusedOption:false,render(){return`100 </div>`;const $modal=$(html);const close=()=>{if(!beforeClose(close)){return}$modal.remove();if(disableScrolling&&$(".gh-modal.disabled-scrolling").length===0){$("body").removeClass("modal-open")}onClose()};const handleClose=()=>{close()};const maybeMoveHeader=()=>{$modal.find(".gh-modal-dialog > .gh-header").remove();let $header=$modal.find(".gh-modal-dialog-content .gh-header");if($header){$header.insertBefore($modal.find(".gh-modal-dialog-content"))}};const setContent=content=>{$modal.find(".gh-modal-dialog-content").html(content);maybeMoveHeader();onSetContent()};$("body").append($modal).addClass(disableScrolling?"modal-open":"");maybeMoveHeader();onOpen({close:close,setContent:setContent});if(canClose){$modal.find(".gh-modal-overlay, .gh-modal-button-close").on("click",handleClose)}return{$modal:$modal,close:close,setContent:setContent}};const wpErrorDialog=(error,props)=>{let message;if(Array.isArray(error)){message=error[0].message}if(typeof error==="object"&&error.message){message=error.message}return errorDialog({message:message,...props})};const errorDialog=props=>{return dialog({...props,type:"error"})};const dialog=({message="",animationDuration=300,ttl=3e3,type="success"})=>{const $dialog=$(`<div class="gh-dialog gh-dialog-${type}">${message}</div>`);$("body").append($dialog).addClass("dialog-open");$dialog.animate({top:40},animationDuration,"swing",()=>{setTimeout(()=>{$dialog.animate({top:-100},animationDuration,"swing",()=>{$dialog.remove()})},ttl)});return{$dialog:$dialog}};const loadingDots=selector=>{const $el=$('<span class="loading-dots"></span>');$(selector).append($el);const stop=()=>{clearInterval(interval);$el.remove()};const interval=setInterval(()=>{if($el.html().length>=3){$el.html(".")}else{$el.html($el.html()+".")}},500);return{stop:stop}};const createOptions=(options,selected)=>{const optionsString=[];if(Array.isArray(options)){options.forEach(option=>{if(typeof option!=="object"){option={value:option,text:option}}optionsString.push(Elements.option(option.value,option.text,Array.isArray(selected)?selected.indexOf(option.value)!==-1:option.value==selected))})}else{for(const option in options){if(options.hasOwnProperty(option)){optionsString.push(Elements.option(option,options[option],Array.isArray(selected)?selected.indexOf(option)!==-1:option==selected))}}}return optionsString.join("")};const regexp=str=>{return new RegExp(escapeRegex(str),"i")};function escapeRegex(string){return string.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}if(!Element.prototype.matches){Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(s){var matches=(this.document||this.ownerDocument).querySelectorAll(s),i=matches.length;while(--i>=0&&matches.item(i)!==this){}return i>-1}}const clickedIn=(e,selector)=>{return clickInsideElement(e,selector)};function clickInsideElement(e,selector){var el=e.tagName?e:e.srcElement||e.target;if(el&&el.matches(selector)){return el}else{while(el=el.parentNode){if(typeof el.matches!=="undefined"&&el.matches(selector)){return el}}}return false}const searchOptionsWidget=({selector=".search-options-widget-wrap",target=null,offset=null,position="inline",options=[],groups={},filterOption=(option,search)=>option.match(regexp(search)),renderOption=option=>option,noOptions=__("No options...","groundhogg"),onSelect=option=>{},onInput=search=>{},onClose=()=>{},onOpen=()=>{},filterOptions=(opts,search)=>opts})=>({selector:selector,options:options,onInput:onInput,filterOption:filterOption,renderOption:renderOption,onClose:onClose,onSelect:onSelect,groups:groups,_open:false,search:"",focusedOptionId:-1,previousFocusedOptionId:false,focusedOption:false,render(){return` 101 101 <div class="search-options-widget-wrap"> 102 102 <div class="search-options-widget ${position}" tabindex="0"> … … 109 109 <div class="search-options ${this.hasGroups()?"has-groups":"no-groups"}"></div> 110 110 </div> 111 </div>`},getOptions(){return filterOptions(this.options.filter((option,i)=>{if(this.search){return filterOption(option,this.search)}return true}),this.search)},hasGroups(){return Object.keys(groups).length>0},renderSearchOptions(){const searchOptions=[];let focusedIndex=0;var self=this;const optionDiv=(option,group,id,index)=>{return`<div class="option ${index===this.focusedOptionId?"focused":""}" data-option="${id}" data-group="${group}">${renderOption(option)}</div>`};if(Object.keys(groups).length>0){Object.keys(groups).forEach((group,g)=>{const options=[];this.getOptions().filter(option=>option.group===group).forEach((option,o)=>{options.push(optionDiv(option,group,o,focusedIndex));focusedIndex++});if(options.length>0){searchOptions.push(`<div class="option-group" data-group="${group}">${groups[group]}</div>`,...options)}})}else{this.getOptions().forEach((option,o)=>{searchOptions.push(optionDiv(option,null,o,focusedIndex));focusedIndex++})}return searchOptions.length?searchOptions.join(""):`<div class="no-options">${noOptions}</div>`},close(){this._open=false;$(".search-options-widget-wrap").remove()},isOpen(){return this._open},isClosed(){return!this._open},selectOption(optionId,groupId){if(!this.hasGroups()){onSelect(this.getOptions()[optionId]);this.close();onClose()}else{Object.keys(groups).forEach((group,g)=>{this.getOptions().filter(option=>option.group==group).forEach((option,o)=>{if(group==groupId&&o==optionId){onSelect(option);this.close();onClose();return}})})}},mountOptions(){var self=this;const $options=$(`${selector} .search-options`);$options.html(this.renderSearchOptions());$(`${selector} .option`).on("click",function(e){const optionId=parseInt($(this).data("option"));const groupId=$(this).data("group");self.selectOption(optionId,groupId)});const $focused=$(`${selector} .option.focused`);let offset;if(this.focusedOptionId>this.previousFocusedOptionId){offset=$focused.height()*($focused.index()+1);if(offset>$options.height()){$options.scrollTop(offset-$options.height())}}else if(this.focusedOptionId<this.previousFocusedOptionId){offset=$focused.height()*$focused.index();if(offset<$options.scrollTop()){$options.scrollTop(offset)}}this.repositionFixed()},repositionFixed(){if(position!=="fixed"||!this.$widget){return}let{left,top,right,bottom}=target.getBoundingClientRect();if(offset){left+=offset.left;top+=offset.top}this.$widget.css({top:top+this.$widget.outerHeight()>window.innerHeight?"initial":top,bottom:top+this.$widget.outerHeight()>window.innerHeight?5:"initial",right:left+this.$widget.outerWidth()>window.innerWidth?5:"initial",left:left+this.$widget.outerWidth()>window.innerWidth?"initial":left})},mount(){var self=this;switch(position){default:case"inline":const $el=$(selector);$el.html(self.render());this.mountOptions();break;case"fixed":const $picker=$(self.render());$("body").append($picker);this.mountOptions();const $widget=$picker.find(".search-options-widget");this.$widget=$widget;this.repositionFixed();break}const el=document.querySelector(".search-options-widget");if(!el){return}const handleClose=()=>{this.close();onClose()};$(`${selector} input.search-for-options`).on("input",e=>{this.search=$(e.target).val();this.focusedOptionId=-1;this.previousFocusedOptionId=-1;onInput(this.search,this);this.mountOptions()}).focus();if(el.getBoundingClientRect().y+$(el).height()>window.innerHeight){el.classList.add("mount-from-bottom")}$(`${selector} button.close`).on("click",function(e){handleClose()});const handleKeyDown=e=>{const{type,key,keyCode}=e;switch(key){case"Esc":case"Escape":handleClose();break;case"Down":case"ArrowDown":e.preventDefault();if(this.focusedOptionId===this.getOptions().length-1){return}this.previousFocusedOptionId=this.focusedOptionId;this.focusedOptionId++;this.mountOptions();break;case"Up":case"ArrowUp":e.preventDefault();if(this.focusedOptionId===0){return}this.previousFocusedOptionId=this.focusedOptionId;this.focusedOptionId--;this.mountOptions();break;case"Enter":e.preventDefault();const $focused=$(`${selector} .option.focused`);this.selectOption(parseInt($focused.data("option")),$focused.data("group"));break}};$(".search-options-widget").on("keydown",handleKeyDown);this._open=true;onOpen(this)}});const replacementsWidget=more=>{const{groups,codes}=Groundhogg.replacements;return searchOptionsWidget({position:"fixed",options:Object.values(codes).filter(r=>!r.hidden),groups:groups,filterOption:({name,code},search)=>name.match(regexp(search))||code.match(regexp(search)),renderOption:option=>option.name,onSelect:option=>{let el=InsertAtCursor.insert(option.insert);$(el).focus()},...more})};let GlobalReplacementsWidget;$(()=>{const openWidget=more=>{GlobalReplacementsWidget=replacementsWidget(more);GlobalReplacementsWidget.mount()};window.addEventListener("keyup",e=>{if(e.ctrlKey&&e.shiftKey&&e.which==219){if(Insert.to_mce){return}let $el=$('<div id="rep-here"></div>');$el.insertAfter(e.target);openWidget({target:document.getElementById("rep-here"),onClose:()=>{$el.remove()}})}});$doc.on("click",e=>{if(GlobalReplacementsWidget&&GlobalReplacementsWidget.isOpen()&&!clickedIn(e,".search-options-widget")){GlobalReplacementsWidget.close()}if(clickedIn(e,".replacements-picker-start")){openWidget({target:e.target.closest(".replacements-picker-start")})}})});const inputRepeater=(selector,{rows :rows=[],sortable:sortable=false,cells:cells=[],onMount:onMount=()=>{},addRow:addRow=()=>Array(cells.length).fill(""),onChange:onChange=rows=>{},onRemove:onRemove=row=>{}})=>({rows:rows,mount(){$(selector).html(this.render());this.onMount()},onMount(){$(`${selector} .remove-row`).on("click",e=>{const row=parseInt(e.currentTarget.dataset.row);onRemove(this.rows[row]);this.rows.splice(row,1);onChange(this.rows);this.mount()});$(`${selector} .add-row`).on("click",e=>{this.rows.push(addRow());onChange(this.rows);this.mount();$(`${selector} .add-row`).focus()});$(`${selector} [data-cell][data-row]`).on("change",e=>{const row=parseInt(e.target.dataset.row);const cell=parseInt(e.target.dataset.cell);this.rows[row][cell]=$(e.target).val();onChange(this.rows)});if(sortable){$(`${selector} .gh-input-repeater`).sortable({handle:".handle",update:(e,ui)=>{let $row=$(ui.item);let oldIndex=parseInt($row.data("row"));let curIndex=$row.index();let row=this.rows[oldIndex];this.rows.splice(oldIndex,1);this.rows.splice(curIndex,0,row);onChange(this.rows);this.mount()}})}onMount()},render(){const renderRow=(row,rowIndex)=>{return`111 </div>`},getOptions(){return filterOptions(this.options.filter((option,i)=>{if(this.search){return filterOption(option,this.search)}return true}),this.search)},hasGroups(){return Object.keys(groups).length>0},renderSearchOptions(){const searchOptions=[];let focusedIndex=0;var self=this;const optionDiv=(option,group,id,index)=>{return`<div class="option ${index===this.focusedOptionId?"focused":""}" data-option="${id}" data-group="${group}">${renderOption(option)}</div>`};if(Object.keys(groups).length>0){Object.keys(groups).forEach((group,g)=>{const options=[];this.getOptions().filter(option=>option.group===group).forEach((option,o)=>{options.push(optionDiv(option,group,o,focusedIndex));focusedIndex++});if(options.length>0){searchOptions.push(`<div class="option-group" data-group="${group}">${groups[group]}</div>`,...options)}})}else{this.getOptions().forEach((option,o)=>{searchOptions.push(optionDiv(option,null,o,focusedIndex));focusedIndex++})}return searchOptions.length?searchOptions.join(""):`<div class="no-options">${noOptions}</div>`},close(){this._open=false;$(".search-options-widget-wrap").remove()},isOpen(){return this._open},isClosed(){return!this._open},selectOption(optionId,groupId){if(!this.hasGroups()){onSelect(this.getOptions()[optionId]);this.close();onClose()}else{Object.keys(groups).forEach((group,g)=>{this.getOptions().filter(option=>option.group==group).forEach((option,o)=>{if(group==groupId&&o==optionId){onSelect(option);this.close();onClose();return}})})}},mountOptions(){var self=this;const $options=$(`${selector} .search-options`);$options.html(this.renderSearchOptions());$(`${selector} .option`).on("click",function(e){const optionId=parseInt($(this).data("option"));const groupId=$(this).data("group");self.selectOption(optionId,groupId)});const $focused=$(`${selector} .option.focused`);let offset;if(this.focusedOptionId>this.previousFocusedOptionId){offset=$focused.height()*($focused.index()+1);if(offset>$options.height()){$options.scrollTop(offset-$options.height())}}else if(this.focusedOptionId<this.previousFocusedOptionId){offset=$focused.height()*$focused.index();if(offset<$options.scrollTop()){$options.scrollTop(offset)}}this.repositionFixed()},repositionFixed(){if(position!=="fixed"||!this.$widget){return}let{left,top,right,bottom}=target.getBoundingClientRect();if(offset){left+=offset.left;top+=offset.top}this.$widget.css({top:top+this.$widget.outerHeight()>window.innerHeight?"initial":top,bottom:top+this.$widget.outerHeight()>window.innerHeight?5:"initial",right:left+this.$widget.outerWidth()>window.innerWidth?5:"initial",left:left+this.$widget.outerWidth()>window.innerWidth?"initial":left})},mount(){var self=this;switch(position){default:case"inline":const $el=$(selector);$el.html(self.render());this.mountOptions();break;case"fixed":const $picker=$(self.render());$("body").append($picker);this.mountOptions();const $widget=$picker.find(".search-options-widget");this.$widget=$widget;this.repositionFixed();break}const el=document.querySelector(".search-options-widget");if(!el){return}const handleClose=()=>{this.close();onClose()};$(`${selector} input.search-for-options`).on("input",e=>{this.search=$(e.target).val();this.focusedOptionId=-1;this.previousFocusedOptionId=-1;onInput(this.search,this);this.mountOptions()}).focus();if(el.getBoundingClientRect().y+$(el).height()>window.innerHeight){el.classList.add("mount-from-bottom")}$(`${selector} button.close`).on("click",function(e){handleClose()});const handleKeyDown=e=>{const{type,key,keyCode}=e;switch(key){case"Esc":case"Escape":handleClose();break;case"Down":case"ArrowDown":e.preventDefault();if(this.focusedOptionId===this.getOptions().length-1){return}this.previousFocusedOptionId=this.focusedOptionId;this.focusedOptionId++;this.mountOptions();break;case"Up":case"ArrowUp":e.preventDefault();if(this.focusedOptionId===0){return}this.previousFocusedOptionId=this.focusedOptionId;this.focusedOptionId--;this.mountOptions();break;case"Enter":e.preventDefault();const $focused=$(`${selector} .option.focused`);this.selectOption(parseInt($focused.data("option")),$focused.data("group"));break}};$(".search-options-widget").on("keydown",handleKeyDown);this._open=true;onOpen(this)}});const replacementsWidget=more=>{const{groups,codes}=Groundhogg.replacements;return searchOptionsWidget({position:"fixed",options:Object.values(codes).filter(r=>!r.hidden),groups:groups,filterOption:({name,code},search)=>name.match(regexp(search))||code.match(regexp(search)),renderOption:option=>option.name,onSelect:option=>{let el=InsertAtCursor.insert(option.insert);$(el).focus()},...more})};let GlobalReplacementsWidget;$(()=>{const openWidget=more=>{GlobalReplacementsWidget=replacementsWidget(more);GlobalReplacementsWidget.mount()};window.addEventListener("keyup",e=>{if(e.ctrlKey&&e.shiftKey&&e.which==219){if(Insert.to_mce){return}let $el=$('<div id="rep-here"></div>');$el.insertAfter(e.target);openWidget({target:document.getElementById("rep-here"),onClose:()=>{$el.remove()}})}});$doc.on("click",e=>{if(GlobalReplacementsWidget&&GlobalReplacementsWidget.isOpen()&&!clickedIn(e,".search-options-widget")){GlobalReplacementsWidget.close()}if(clickedIn(e,".replacements-picker-start")){openWidget({target:e.target.closest(".replacements-picker-start")})}})});const inputRepeater=(selector,{rows=[],sortable=false,cells=[],onMount=()=>{},addRow=()=>Array(cells.length).fill(""),onChange=rows=>{},onRemove=row=>{}})=>({rows:rows,mount(){$(selector).html(this.render());this.onMount()},onMount(){$(`${selector} .remove-row`).on("click",e=>{const row=parseInt(e.currentTarget.dataset.row);onRemove(this.rows[row]);this.rows.splice(row,1);onChange(this.rows);this.mount()});$(`${selector} .add-row`).on("click",e=>{this.rows.push(addRow());onChange(this.rows);this.mount();$(`${selector} .add-row`).focus()});$(`${selector} [data-cell][data-row]`).on("change",e=>{const row=parseInt(e.target.dataset.row);const cell=parseInt(e.target.dataset.cell);this.rows[row][cell]=$(e.target).val();onChange(this.rows)});if(sortable){$(`${selector} .gh-input-repeater`).sortable({handle:".handle",update:(e,ui)=>{let $row=$(ui.item);let oldIndex=parseInt($row.data("row"));let curIndex=$row.index();let row=this.rows[oldIndex];this.rows.splice(oldIndex,1);this.rows.splice(curIndex,0,row);onChange(this.rows);this.mount()}})}onMount()},render(){const renderRow=(row,rowIndex)=>{return` 112 112 <div class="gh-input-repeater-row" data-row="${rowIndex}"> 113 113 ${row.map((cell,cellIndex)=>cells[cellIndex]({value:cell,dataRow:rowIndex,dataCell:cellIndex},row)).join("")} … … 126 126 </button> 127 127 </div> 128 </div>`}});const inputRepeaterWidget=({selector :selector="",rows:rows=[],cellProps:cellProps=[],sortable:sortable=false,cellCallbacks:cellCallbacks=[],onMount:onMount=()=>{},onChange:onChange=rows=>{},onRemove:onRemove=row=>{}})=>({rows:rows,mount(){$(selector).html(this.render());this.onMount()},onMount(){$(`${selector} .remove-row`).on("click",e=>{const row=parseInt(e.currentTarget.dataset.row);onRemove(this.rows[row]);this.rows.splice(row,1);onChange(this.rows);this.mount()});$(`${selector} #add-row`).on("click",e=>{this.rows.push(Array(cellProps.length).fill(""));onChange(this.rows);this.mount();$(`${selector} #add-row`).focus()});$(`${selector} input`).on("change",e=>{const row=parseInt(e.target.dataset.row);const cell=parseInt(e.target.dataset.cell);this.rows[row][cell]=e.target.value;onChange(this.rows)});if(sortable){$(`${selector} .gh-input-repeater`).sortable({handle:".handle",update:(e,ui)=>{let $row=$(ui.item);let oldIndex=parseInt($row.data("row"));let curIndex=$row.index();let row=this.rows[oldIndex];this.rows.splice(oldIndex,1);this.rows.splice(curIndex,0,row);onChange(this.rows);this.mount()}})}onMount()},render(){const renderRow=(row,rowIndex)=>{return`128 </div>`}});const inputRepeaterWidget=({selector="",rows=[],cellProps=[],sortable=false,cellCallbacks=[],onMount=()=>{},onChange=rows=>{},onRemove=row=>{}})=>({rows:rows,mount(){$(selector).html(this.render());this.onMount()},onMount(){$(`${selector} .remove-row`).on("click",e=>{const row=parseInt(e.currentTarget.dataset.row);onRemove(this.rows[row]);this.rows.splice(row,1);onChange(this.rows);this.mount()});$(`${selector} #add-row`).on("click",e=>{this.rows.push(Array(cellProps.length).fill(""));onChange(this.rows);this.mount();$(`${selector} #add-row`).focus()});$(`${selector} input`).on("change",e=>{const row=parseInt(e.target.dataset.row);const cell=parseInt(e.target.dataset.cell);this.rows[row][cell]=e.target.value;onChange(this.rows)});if(sortable){$(`${selector} .gh-input-repeater`).sortable({handle:".handle",update:(e,ui)=>{let $row=$(ui.item);let oldIndex=parseInt($row.data("row"));let curIndex=$row.index();let row=this.rows[oldIndex];this.rows.splice(oldIndex,1);this.rows.splice(curIndex,0,row);onChange(this.rows);this.mount()}})}onMount()},render(){const renderRow=(row,rowIndex)=>{return` 129 129 <div class="gh-input-repeater-row" data-row="${rowIndex}"> 130 130 ${row.map((cell,cellIndex)=>cellCallbacks[cellIndex]({...cellProps[cellIndex],value:cell,dataRow:rowIndex,dataCell:cellIndex})).join("")} … … 143 143 </button> 144 144 </div> 145 </div>`}});const flattenObject=(obj,parent_key="")=>{if(typeof obj!=="object"){return{}}const flattened={};let key_prefix=parent_key?parent_key+".":"";for(const key in obj){if(obj.hasOwnProperty(key)){let value=obj[key];if(typeof value!=="object"){flattened[key_prefix+key]=value}else{Object.assign(flattened,flattenObject(value,key_prefix+key))}}}return flattened};function objectEquals(a,b){return JSON.stringify(a)===JSON.stringify(b)}const isValidEmail=email=>{const re=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return re.test(String(email).toLowerCase())};const primaryButton=({className,...props})=>{return button({className:"gh-button primary"+(className?" "+className:""),...props})};const secondaryButton=({className,...props})=>{return button({className:"gh-button secondary"+(className?" "+className:""),...props})};const dangerButton=({className,...props})=>{return button({className:"gh-button danger"+(className?" "+className:""),...props})};const button=({text :text="",className:className="",...props})=>{return`145 </div>`}});const flattenObject=(obj,parent_key="")=>{if(typeof obj!=="object"){return{}}const flattened={};let key_prefix=parent_key?parent_key+".":"";for(const key in obj){if(obj.hasOwnProperty(key)){let value=obj[key];if(typeof value!=="object"){flattened[key_prefix+key]=value}else{Object.assign(flattened,flattenObject(value,key_prefix+key))}}}return flattened};function objectEquals(a,b){return JSON.stringify(a)===JSON.stringify(b)}const isValidEmail=email=>{const re=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return re.test(String(email).toLowerCase())};const primaryButton=({className,...props})=>{return button({className:"gh-button primary"+(className?" "+className:""),...props})};const secondaryButton=({className,...props})=>{return button({className:"gh-button secondary"+(className?" "+className:""),...props})};const dangerButton=({className,...props})=>{return button({className:"gh-button danger"+(className?" "+className:""),...props})};const button=({text="",className="",...props})=>{return` 146 146 <button ${objectToProps({className:"gh-button"+(className?" "+className:""),...props})}>${text} 147 </button>`};const setFrameContent=(frame,content)=>{let blob=new Blob([content],{type:"text/html; charset=utf-8"});frame.src=URL.createObjectURL(blob)};const moreMenu=(selector,args)=>{let selectHandler=false;let items=[];if(Array.isArray(args)){items=args}else{items=args.items??[];let onSelect=args.onSelect??false;if(onSelect!==false){selectHandler=onSelect}}if(selectHandler===false){selectHandler=key=>{let item=items.find(i=>i.key==key);const{onSelect :onSelect=()=>{}}=item;onSelect()}}const menu=`147 </button>`};const setFrameContent=(frame,content)=>{let blob=new Blob([content],{type:"text/html; charset=utf-8"});frame.src=URL.createObjectURL(blob)};const moreMenu=(selector,args)=>{let selectHandler=false;let items=[];if(Array.isArray(args)){items=args}else{items=args.items??[];let onSelect=args.onSelect??false;if(onSelect!==false){selectHandler=onSelect}}if(selectHandler===false){selectHandler=key=>{let item=items.find(i=>i.key==key);const{onSelect=()=>{}}=item;onSelect()}}const menu=` 148 148 <div role="menu" class="gh-dropdown-menu" tabindex="0"> 149 149 ${items.filter(i=>i&&true).map(({key,text})=>`<div class="gh-dropdown-menu-item" data-key="${key}">${text}</div>`).join("")} 150 </div>`;const $menu=$(menu);const close=()=>{$menu.remove()};$menu.on("click",".gh-dropdown-menu-item",e=>{selectHandler(e.currentTarget.dataset.key);close()});$menu.on("blur",()=>{close()});const $el=$(selector);$("body").append($menu);const{left,right,top,bottom}=$el[0].getBoundingClientRect();$menu.css({top:Math.min(bottom,window.innerHeight-$menu.height()-20)+"px",left:right-$menu.outerWidth()+"px"});$menu.focus()};const moreMenuAbsolute=(selector,args)=>{let selectHandler=false;let items=[];if(Array.isArray(args)){items=args}else{items=args.items??[];let onSelect=args.onSelect??false;if(onSelect!==false){selectHandler=onSelect}}if(selectHandler===false){selectHandler=key=>{let item=items.find(i=>i.key==key);const{onSelect :onSelect=()=>{}}=item;onSelect()}}const menu=`150 </div>`;const $menu=$(menu);const close=()=>{$menu.remove()};$menu.on("click",".gh-dropdown-menu-item",e=>{selectHandler(e.currentTarget.dataset.key);close()});$menu.on("blur",()=>{close()});const $el=$(selector);$("body").append($menu);const{left,right,top,bottom}=$el[0].getBoundingClientRect();$menu.css({top:Math.min(bottom,window.innerHeight-$menu.height()-20)+"px",left:right-$menu.outerWidth()+"px"});$menu.focus()};const moreMenuAbsolute=(selector,args)=>{let selectHandler=false;let items=[];if(Array.isArray(args)){items=args}else{items=args.items??[];let onSelect=args.onSelect??false;if(onSelect!==false){selectHandler=onSelect}}if(selectHandler===false){selectHandler=key=>{let item=items.find(i=>i.key==key);const{onSelect=()=>{}}=item;onSelect()}}const menu=` 151 151 <div role="menu" class="gh-dropdown-menu absolute" tabindex="0"> 152 152 ${items.filter(i=>i&&true).map(({key,text})=>`<div class="gh-dropdown-menu-item" data-key="${key}">${text}</div>`).join("")} -
groundhogg/trunk/assets/js/admin/filters/contacts.js
r3400645 r3422142 1638 1638 _x('Flows', 'noun meaning automation', 'groundhogg')) 1639 1639 1640 registerFilter('funnel_history', 'funnels', 1641 __('Flow History', 'groundhogg'), { 1642 view ({ 1643 status = 'complete', 1644 funnel_id = 0, 1645 step_id = 0, 1646 date_range = 'any', 1647 before, 1648 after, 1649 ...rest 1650 }) { 1651 1652 let prepend 1653 1654 if (funnel_id) { 1655 1656 const funnel = FunnelsStore.get(funnel_id) 1657 const step = funnel.steps.find(s => s.ID === step_id) 1658 1659 prepend = status === 'complete' ? sprintf( 1660 step ? __('Completed %2$s in %1$s', 'groundhogg') : __( 1661 'Completed any step in %1$s', 'groundhogg'), 1662 `<b>${ funnel.data.title }</b>`, 1663 step ? `<b>${ step.data.step_title }</b>` : '') : sprintf( 1664 step ? __('Will complete %2$s in %1$s', 'groundhogg') : __( 1665 'Will complete any step in %1$s', 'groundhogg'), 1666 `<b>${ funnel.data.title }</b>`, 1667 step ? `<b>${ step.data.step_title }</b>` : '') 1668 1669 if (status === 'waiting') { 1670 return prepend 1640 ContactFilterRegistry.registerFilter(createPastDateFilter('funnel_history', __('Flow History', 'groundhogg'), 'funnels', { 1641 display: ({ 1642 funnel_id = false, 1643 step_id = false, 1644 status = 'complete' 1645 }) => { 1646 1647 let text = __('Completed any step in any flow', 'groundhogg') 1648 1649 if (funnel_id) { 1650 1651 const funnel = FunnelsStore.get(funnel_id) 1652 const step = funnel.steps.find(s => s.ID === step_id) 1653 1654 text = status === 'complete' ? sprintf( 1655 step ? __('Completed %2$s in %1$s', 'groundhogg') : __( 1656 'Completed any step in %1$s', 'groundhogg'), 1657 `<b>${ funnel.data.title }</b>`, 1658 step ? `<b>${ step.data.step_title }</b>` : '') : sprintf( 1659 step ? __('Will complete %2$s in %1$s', 'groundhogg') : __( 1660 'Will complete any step in %1$s', 'groundhogg'), 1661 `<b>${ funnel.data.title }</b>`, 1662 step ? `<b>${ step.data.step_title }</b>` : '') 1663 1664 if (status === 'waiting') { 1665 return text 1666 } 1667 } 1668 1669 return text 1670 }, 1671 edit : ({ 1672 funnel_id = false, 1673 step_id = false, 1674 updateFilter, 1675 }) => Fragment([ 1676 ItemPicker({ 1677 id : `select-a-funnel`, 1678 noneSelected: __('Select a flow...', 'groundhogg'), 1679 selected : funnel_id ? { 1680 id : funnel_id, 1681 text: FunnelsStore.get(funnel_id).data.title, 1682 } : [], 1683 multiple : false, 1684 style : { 1685 flexGrow: 1, 1686 }, 1687 fetchOptions: (search) => { 1688 return FunnelsStore.fetchItems({ 1689 search, 1690 }). 1691 then(funnels => funnels.map(({ 1692 ID, 1693 data, 1694 }) => ( { 1695 id : ID, 1696 text: data.title, 1697 } ))) 1698 }, 1699 onChange : item => { 1700 if (!item) { 1701 updateFilter({ 1702 funnel_id: null, 1703 step_id : null, 1704 }, true) 1705 return 1671 1706 } 1672 1707 1673 }1674 else {1675 prepend = __('Completed any step in any flow', 'groundhogg')1676 }1677 1678 return standardActivityDateTitle(prepend, {1679 date_range,1680 before,1681 after,1682 ...rest1683 })1684 },1685 edit ({1686 funnel_id,1687 step_id,1688 date_range,1689 before,1690 after,1691 ...rest1692 }) {1693 1694 return `1695 ${ select({1696 id: 'filter-funnel',1697 name: 'funnel_id',1698 }, FunnelsStore.getItems().1699 map(f => ( {1700 value: f.ID,1701 text: f.data.title,1702 } )), funnel_id) }1703 ${ select({1704 id: 'filter-step',1705 name: 'step_id',1706 }, funnel_id ? FunnelsStore.get(funnel_id).steps.map(s => ( {1707 value: s.ID,1708 text: s.data.step_title,1709 } )) : [], step_id) }1710 ${ standardActivityDateOptions({1711 date_range,1712 before,1713 after,1714 ...rest1715 }) }`1716 },1717 onMount (filter, updateFilter) {1718 funnelPicker('#filter-funnel', false, (items) => {1719 FunnelsStore.itemsFetched(items)1720 }, {}, {1721 placeholder: __('Select a flow', 'groundhogg'),1722 }).on('select2:select', ({ target }) => {1723 1708 updateFilter({ 1724 funnel_id: parseInt($(target).val()),1725 step_id : 0,1709 funnel_id: item.id, 1710 step_id : FunnelsStore.get(item.id).steps[0].ID, 1726 1711 }, true) 1727 }) 1728 1729 $('#filter-step').select2({ 1730 placeholder: __('Select a step or leave empty for any step', 1731 'groundhogg'), 1732 }).on('select2:select', ({ target }) => { 1712 }, 1713 }), 1714 funnel_id ? ItemPicker({ 1715 id : `select-step-from-${ funnel_id }`, 1716 noneSelected: __('Select a step...', 'groundhogg'), 1717 selected : step_id ? { 1718 id : step_id, 1719 text: FunnelsStore.get(funnel_id).steps.find(s => s.ID === step_id).data.step_title, 1720 } : [], 1721 multiple : false, 1722 style : { 1723 flexGrow: 1, 1724 }, 1725 fetchOptions: async (search) => FunnelsStore.get(funnel_id) 1726 .steps 1727 // only actions and triggers can be "completed" 1728 .filter( s => s.data.step_group === 'action' || s.data.step_group === 'benchmark' ) 1729 .map(({ 1730 ID, 1731 data, 1732 }) => ( { 1733 id : ID, 1734 text: data.step_title, 1735 } )) 1736 .filter(opt => opt.text.match(new RegExp(search, 'i'))), 1737 onChange : item => { 1738 if (!item) { 1739 updateFilter({ 1740 step_id: null, 1741 }) 1742 return 1743 } 1744 1733 1745 updateFilter({ 1734 step_id: parseInt($(target).val()),1746 step_id: item.id, 1735 1747 }) 1736 }) 1737 1738 standardActivityDateFilterOnMount(filter, updateFilter) 1739 }, 1740 defaults: { 1741 funnel_id: 0, 1742 step_id : 0, 1743 status : 'complete', ...standardActivityDateDefaults, 1744 }, 1745 preload : ({ funnel_id }) => { 1746 if (funnel_id) { 1747 return FunnelsStore.maybeFetchItem(funnel_id) 1748 } 1749 }, 1750 }) 1748 }, 1749 }) : null, 1750 ]), 1751 preload: ({ funnel_id }) => { 1752 if (funnel_id) { 1753 return FunnelsStore.maybeFetchItem(funnel_id) 1754 } 1755 }, 1756 }, { 1757 funnel_id: 0, 1758 step_id : 0, 1759 status : 'complete', 1760 })) 1761 1762 // registerFilter('funnel_history', 'funnels', 1763 // __('Flow History', 'groundhogg'), { 1764 // view ({ 1765 // status = 'complete', 1766 // funnel_id = 0, 1767 // step_id = 0, 1768 // date_range = 'any', 1769 // before, 1770 // after, 1771 // ...rest 1772 // }) { 1773 // 1774 // let prepend 1775 // 1776 // if (funnel_id) { 1777 // 1778 // const funnel = FunnelsStore.get(funnel_id) 1779 // const step = funnel.steps.find(s => s.ID === step_id) 1780 // 1781 // prepend = status === 'complete' ? sprintf( 1782 // step ? __('Completed %2$s in %1$s', 'groundhogg') : __( 1783 // 'Completed any step in %1$s', 'groundhogg'), 1784 // `<b>${ funnel.data.title }</b>`, 1785 // step ? `<b>${ step.data.step_title }</b>` : '') : sprintf( 1786 // step ? __('Will complete %2$s in %1$s', 'groundhogg') : __( 1787 // 'Will complete any step in %1$s', 'groundhogg'), 1788 // `<b>${ funnel.data.title }</b>`, 1789 // step ? `<b>${ step.data.step_title }</b>` : '') 1790 // 1791 // if (status === 'waiting') { 1792 // return prepend 1793 // } 1794 // 1795 // } 1796 // else { 1797 // prepend = __('Completed any step in any flow', 'groundhogg') 1798 // } 1799 // 1800 // return standardActivityDateTitle(prepend, { 1801 // date_range, 1802 // before, 1803 // after, 1804 // ...rest 1805 // }) 1806 // }, 1807 // edit ({ 1808 // funnel_id, 1809 // step_id, 1810 // date_range, 1811 // before, 1812 // after, 1813 // ...rest 1814 // }) { 1815 // 1816 // return ` 1817 // ${ select({ 1818 // id: 'filter-funnel', 1819 // name: 'funnel_id', 1820 // }, FunnelsStore.getItems(). 1821 // map(f => ( { 1822 // value: f.ID, 1823 // text: f.data.title, 1824 // } )), funnel_id) } 1825 // ${ select({ 1826 // id: 'filter-step', 1827 // name: 'step_id', 1828 // }, funnel_id ? FunnelsStore.get(funnel_id).steps.map(s => ( { 1829 // value: s.ID, 1830 // text: s.data.step_title, 1831 // } )) : [], step_id) } 1832 // ${ standardActivityDateOptions({ 1833 // date_range, 1834 // before, 1835 // after, 1836 // ...rest 1837 // }) }` 1838 // }, 1839 // onMount (filter, updateFilter) { 1840 // funnelPicker('#filter-funnel', false, (items) => { 1841 // FunnelsStore.itemsFetched(items) 1842 // }, {}, { 1843 // placeholder: __('Select a flow', 'groundhogg'), 1844 // }).on('select2:select', ({ target }) => { 1845 // updateFilter({ 1846 // funnel_id: parseInt($(target).val()), 1847 // step_id: 0, 1848 // }, true) 1849 // }) 1850 // 1851 // $('#filter-step').select2({ 1852 // placeholder: __('Select a step or leave empty for any step', 1853 // 'groundhogg'), 1854 // }).on('select2:select', ({ target }) => { 1855 // updateFilter({ 1856 // step_id: parseInt($(target).val()), 1857 // }) 1858 // }) 1859 // 1860 // standardActivityDateFilterOnMount(filter, updateFilter) 1861 // }, 1862 // defaults: { 1863 // funnel_id: 0, 1864 // step_id : 0, 1865 // status : 'complete', ...standardActivityDateDefaults, 1866 // }, 1867 // preload : ({ funnel_id }) => { 1868 // if (funnel_id) { 1869 // return FunnelsStore.maybeFetchItem(funnel_id) 1870 // } 1871 // }, 1872 // }) 1751 1873 1752 1874 registerFilterGroup('broadcast', -
groundhogg/trunk/assets/js/admin/filters/contacts.min.js
r3400645 r3422142 49 49 ${filterCount(rest)} 50 50 51 ${standardActivityDateOptions(rest)}`},onMount(filter,updateFilter){linkPicker("#filter-link").on("change input blur",({target})=>{updateFilter({link:target.value})});filterCountOnMount(updateFilter);standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults,...filterCountDefaults,link:""}});registerFilter("logged_in","activity",__("Logged In","groundhogg"),{view(filter){let prefix=filterCountTitle(`<b>${__("Logged in","groundhogg")}</b>`,filter);return standardActivityDateTitle(prefix,filter)},edit(filter){return filterCount(filter)+standardActivityDateOptions(filter)},onMount(filter,updateFilter){filterCountOnMount(updateFilter);standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults,...filterCountDefaults}});registerFilter("logged_out","activity",__("Logged Out","groundhogg"),{view(filter){return standardActivityDateTitle(filterCountTitle(`<b>${__("Logged out","groundhogg")}</b>`,filter),filter)},edit(filter){return filterCount(filter)+standardActivityDateOptions(filter)},onMount(filter,updateFilter){filterCountOnMount(updateFilter);standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...filterCountDefaults,...standardActivityDateDefaults}});registerFilter("not_logged_in","activity",__("Has Not Logged In","groundhogg"),{view(filter){return standardActivityDateTitle(`<b>${__("Has not logged in","groundhogg")}</b>`,filter)},edit(filter){return standardActivityDateOptions(filter)},onMount(filter,updateFilter){standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults}});registerFilter("was_active","activity",__("Was Active","groundhogg"),{view(filter){return standardActivityDateTitle(`<b>${__("Was active","groundhogg")}</b>`,filter)},edit(filter){return standardActivityDateOptions(filter)},onMount(filter,updateFilter){standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults}});registerFilter("was_not_active","activity",__("Was Inactive","groundhogg"),{view(filter){return standardActivityDateTitle(`<b>${__("Was inactive","groundhogg")}</b>`,filter)},edit(filter){return standardActivityDateOptions(filter)},onMount(filter,updateFilter){standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults}});registerFilterGroup("funnels",_x("Flows","noun meaning automation","groundhogg"));registerFilter("funnel_history","funnels",__("Flow History","groundhogg"),{view({status="complete",funnel_id=0,step_id=0,date_range="any",before,after,...rest}){let prepend;if(funnel_id){const funnel=FunnelsStore.get(funnel_id);const step=funnel.steps.find(s=>s.ID===step_id);prepend=status==="complete"?sprintf(step?__("Completed %2$s in %1$s","groundhogg"):__("Completed any step in %1$s","groundhogg"),`<b>${funnel.data.title}</b>`,step?`<b>${step.data.step_title}</b>`:""):sprintf(step?__("Will complete %2$s in %1$s","groundhogg"):__("Will complete any step in %1$s","groundhogg"),`<b>${funnel.data.title}</b>`,step?`<b>${step.data.step_title}</b>`:"");if(status==="waiting"){return prepend}}else{prepend=__("Completed any step in any flow","groundhogg")}return standardActivityDateTitle(prepend,{date_range:date_range,before:before,after:after,...rest})},edit({funnel_id,step_id,date_range,before,after,...rest}){return` 52 ${select({id:"filter-funnel",name:"funnel_id"},FunnelsStore.getItems().map(f=>({value:f.ID,text:f.data.title})),funnel_id)} 53 ${select({id:"filter-step",name:"step_id"},funnel_id?FunnelsStore.get(funnel_id).steps.map(s=>({value:s.ID,text:s.data.step_title})):[],step_id)} 54 ${standardActivityDateOptions({date_range:date_range,before:before,after:after,...rest})}`},onMount(filter,updateFilter){funnelPicker("#filter-funnel",false,items=>{FunnelsStore.itemsFetched(items)},{},{placeholder:__("Select a flow","groundhogg")}).on("select2:select",({target})=>{updateFilter({funnel_id:parseInt($(target).val()),step_id:0},true)});$("#filter-step").select2({placeholder:__("Select a step or leave empty for any step","groundhogg")}).on("select2:select",({target})=>{updateFilter({step_id:parseInt($(target).val())})});standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{funnel_id:0,step_id:0,status:"complete",...standardActivityDateDefaults},preload:({funnel_id})=>{if(funnel_id){return FunnelsStore.maybeFetchItem(funnel_id)}}});registerFilterGroup("broadcast",_x("Broadcast","noun meaning email blast","groundhogg"));registerFilter("broadcast_received","broadcast",__("Received Broadcast","groundhogg"),{view({broadcast_id,status="complete"}){if(!broadcast_id){return __("Received any broadcast","groundhogg")}const broadcast=BroadcastsStore.get(broadcast_id);return status==="complete"?sprintf(broadcast?__("Received %1$s on %2$s","groundhogg"):__("Will receive a broadcast","groundhogg"),`<b>${broadcast.object.data.title}</b>`,`<b>${formatDateTime(broadcast.data.send_time*1e3)}</b>`):sprintf(broadcast?__("Will receive %1$s on %2$s","groundhogg"):__("Received a broadcast","groundhogg"),`<b>${broadcast.object.data.title}</b>`,`<b>${formatDateTime(broadcast.data.send_time*1e3)}</b>`)},edit({broadcast_id}){return select({id:"filter-broadcast",name:"broadcast_id"},BroadcastsStore.getItems().map(b=>({value:b.ID,text:`${b.object.data.title} (${b.date_sent_pretty})`})),broadcast_id)},onMount(filter,updateFilter){broadcastPicker("#filter-broadcast",false,items=>{BroadcastsStore.itemsFetched(items)},{},{placeholder:__("Select a broadcast","groundhogg")}).on("select2:select",({target})=>{updateFilter({broadcast_id:parseInt($(target).val())})})},defaults:{broadcast_id:0,status:"complete"},preload:({broadcast_id})=>{if(broadcast_id){return BroadcastsStore.maybeFetchItem(broadcast_id)}}});registerFilter("broadcast_opened","broadcast",__("Opened Broadcast","groundhogg"),{view({broadcast_id}){if(!broadcast_id){return __("Opened any broadcast","groundhogg")}const broadcast=BroadcastsStore.get(broadcast_id);return sprintf(broadcast?__("Opened %1$s after %2$s","groundhogg"):__("Will receive a broadcast","groundhogg"),`<b>${broadcast.object.data.title}</b>`,`<b>${formatDateTime(broadcast.data.send_time*1e3)}</b>`)},edit({broadcast_id}){return select({id:"filter-broadcast",name:"broadcast_id"},BroadcastsStore.getItems().map(b=>({value:b.ID,text:`${b.object.data.title} (${b.date_sent_pretty})`})),broadcast_id)},onMount(filter,updateFilter){broadcastPicker("#filter-broadcast",false,items=>{BroadcastsStore.itemsFetched(items)},{},{placeholder:__("Select a broadcast","groundhogg")}).on("select2:select",({target})=>{updateFilter({broadcast_id:parseInt($(target).val())})})},defaults:{broadcast_id:0},preload:({broadcast_id})=>{if(broadcast_id){return BroadcastsStore.maybeFetchItem(broadcast_id)}}});registerFilter("broadcast_link_clicked","broadcast",__("Broadcast Link Clicked","groundhogg"),{view({broadcast_id,link}){if(!broadcast_id&&!link){return __("Clicked any link in any broadcast","groundhogg")}if(!broadcast_id&&link){return sprintf(__("Clicked %s in any broadcast","groundhogg"),bold(link))}const broadcast=BroadcastsStore.get(broadcast_id);if(broadcast_id&&!link){return sprintf(__("Clicked any link in %1$s after %2$s","groundhogg"),bold(broadcast.object.data.title),bold(formatDateTime(broadcast.data.send_time*1e3)))}return sprintf(__("Clicked %1$s in %2$s after %3$s","groundhogg"),bold(link),bold(broadcast.object.data.title),bold(formatDateTime(broadcast.data.send_time*1e3)))},edit({broadcast_id,link}){return` 51 ${standardActivityDateOptions(rest)}`},onMount(filter,updateFilter){linkPicker("#filter-link").on("change input blur",({target})=>{updateFilter({link:target.value})});filterCountOnMount(updateFilter);standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults,...filterCountDefaults,link:""}});registerFilter("logged_in","activity",__("Logged In","groundhogg"),{view(filter){let prefix=filterCountTitle(`<b>${__("Logged in","groundhogg")}</b>`,filter);return standardActivityDateTitle(prefix,filter)},edit(filter){return filterCount(filter)+standardActivityDateOptions(filter)},onMount(filter,updateFilter){filterCountOnMount(updateFilter);standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults,...filterCountDefaults}});registerFilter("logged_out","activity",__("Logged Out","groundhogg"),{view(filter){return standardActivityDateTitle(filterCountTitle(`<b>${__("Logged out","groundhogg")}</b>`,filter),filter)},edit(filter){return filterCount(filter)+standardActivityDateOptions(filter)},onMount(filter,updateFilter){filterCountOnMount(updateFilter);standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...filterCountDefaults,...standardActivityDateDefaults}});registerFilter("not_logged_in","activity",__("Has Not Logged In","groundhogg"),{view(filter){return standardActivityDateTitle(`<b>${__("Has not logged in","groundhogg")}</b>`,filter)},edit(filter){return standardActivityDateOptions(filter)},onMount(filter,updateFilter){standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults}});registerFilter("was_active","activity",__("Was Active","groundhogg"),{view(filter){return standardActivityDateTitle(`<b>${__("Was active","groundhogg")}</b>`,filter)},edit(filter){return standardActivityDateOptions(filter)},onMount(filter,updateFilter){standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults}});registerFilter("was_not_active","activity",__("Was Inactive","groundhogg"),{view(filter){return standardActivityDateTitle(`<b>${__("Was inactive","groundhogg")}</b>`,filter)},edit(filter){return standardActivityDateOptions(filter)},onMount(filter,updateFilter){standardActivityDateFilterOnMount(filter,updateFilter)},defaults:{...standardActivityDateDefaults}});registerFilterGroup("funnels",_x("Flows","noun meaning automation","groundhogg"));ContactFilterRegistry.registerFilter(createPastDateFilter("funnel_history",__("Flow History","groundhogg"),"funnels",{display:({funnel_id=false,step_id=false,status="complete"})=>{let text=__("Completed any step in any flow","groundhogg");if(funnel_id){const funnel=FunnelsStore.get(funnel_id);const step=funnel.steps.find(s=>s.ID===step_id);text=status==="complete"?sprintf(step?__("Completed %2$s in %1$s","groundhogg"):__("Completed any step in %1$s","groundhogg"),`<b>${funnel.data.title}</b>`,step?`<b>${step.data.step_title}</b>`:""):sprintf(step?__("Will complete %2$s in %1$s","groundhogg"):__("Will complete any step in %1$s","groundhogg"),`<b>${funnel.data.title}</b>`,step?`<b>${step.data.step_title}</b>`:"");if(status==="waiting"){return text}}return text},edit:({funnel_id=false,step_id=false,updateFilter})=>Fragment([ItemPicker({id:`select-a-funnel`,noneSelected:__("Select a flow...","groundhogg"),selected:funnel_id?{id:funnel_id,text:FunnelsStore.get(funnel_id).data.title}:[],multiple:false,style:{flexGrow:1},fetchOptions:search=>{return FunnelsStore.fetchItems({search:search}).then(funnels=>funnels.map(({ID,data})=>({id:ID,text:data.title})))},onChange:item=>{if(!item){updateFilter({funnel_id:null,step_id:null},true);return}updateFilter({funnel_id:item.id,step_id:FunnelsStore.get(item.id).steps[0].ID},true)}}),funnel_id?ItemPicker({id:`select-step-from-${funnel_id}`,noneSelected:__("Select a step...","groundhogg"),selected:step_id?{id:step_id,text:FunnelsStore.get(funnel_id).steps.find(s=>s.ID===step_id).data.step_title}:[],multiple:false,style:{flexGrow:1},fetchOptions:async search=>FunnelsStore.get(funnel_id).steps.filter(s=>s.data.step_group==="action"||s.data.step_group==="benchmark").map(({ID,data})=>({id:ID,text:data.step_title})).filter(opt=>opt.text.match(new RegExp(search,"i"))),onChange:item=>{if(!item){updateFilter({step_id:null});return}updateFilter({step_id:item.id})}}):null]),preload:({funnel_id})=>{if(funnel_id){return FunnelsStore.maybeFetchItem(funnel_id)}}},{funnel_id:0,step_id:0,status:"complete"}));registerFilterGroup("broadcast",_x("Broadcast","noun meaning email blast","groundhogg"));registerFilter("broadcast_received","broadcast",__("Received Broadcast","groundhogg"),{view({broadcast_id,status="complete"}){if(!broadcast_id){return __("Received any broadcast","groundhogg")}const broadcast=BroadcastsStore.get(broadcast_id);return status==="complete"?sprintf(broadcast?__("Received %1$s on %2$s","groundhogg"):__("Will receive a broadcast","groundhogg"),`<b>${broadcast.object.data.title}</b>`,`<b>${formatDateTime(broadcast.data.send_time*1e3)}</b>`):sprintf(broadcast?__("Will receive %1$s on %2$s","groundhogg"):__("Received a broadcast","groundhogg"),`<b>${broadcast.object.data.title}</b>`,`<b>${formatDateTime(broadcast.data.send_time*1e3)}</b>`)},edit({broadcast_id}){return select({id:"filter-broadcast",name:"broadcast_id"},BroadcastsStore.getItems().map(b=>({value:b.ID,text:`${b.object.data.title} (${b.date_sent_pretty})`})),broadcast_id)},onMount(filter,updateFilter){broadcastPicker("#filter-broadcast",false,items=>{BroadcastsStore.itemsFetched(items)},{},{placeholder:__("Select a broadcast","groundhogg")}).on("select2:select",({target})=>{updateFilter({broadcast_id:parseInt($(target).val())})})},defaults:{broadcast_id:0,status:"complete"},preload:({broadcast_id})=>{if(broadcast_id){return BroadcastsStore.maybeFetchItem(broadcast_id)}}});registerFilter("broadcast_opened","broadcast",__("Opened Broadcast","groundhogg"),{view({broadcast_id}){if(!broadcast_id){return __("Opened any broadcast","groundhogg")}const broadcast=BroadcastsStore.get(broadcast_id);return sprintf(broadcast?__("Opened %1$s after %2$s","groundhogg"):__("Will receive a broadcast","groundhogg"),`<b>${broadcast.object.data.title}</b>`,`<b>${formatDateTime(broadcast.data.send_time*1e3)}</b>`)},edit({broadcast_id}){return select({id:"filter-broadcast",name:"broadcast_id"},BroadcastsStore.getItems().map(b=>({value:b.ID,text:`${b.object.data.title} (${b.date_sent_pretty})`})),broadcast_id)},onMount(filter,updateFilter){broadcastPicker("#filter-broadcast",false,items=>{BroadcastsStore.itemsFetched(items)},{},{placeholder:__("Select a broadcast","groundhogg")}).on("select2:select",({target})=>{updateFilter({broadcast_id:parseInt($(target).val())})})},defaults:{broadcast_id:0},preload:({broadcast_id})=>{if(broadcast_id){return BroadcastsStore.maybeFetchItem(broadcast_id)}}});registerFilter("broadcast_link_clicked","broadcast",__("Broadcast Link Clicked","groundhogg"),{view({broadcast_id,link}){if(!broadcast_id&&!link){return __("Clicked any link in any broadcast","groundhogg")}if(!broadcast_id&&link){return sprintf(__("Clicked %s in any broadcast","groundhogg"),bold(link))}const broadcast=BroadcastsStore.get(broadcast_id);if(broadcast_id&&!link){return sprintf(__("Clicked any link in %1$s after %2$s","groundhogg"),bold(broadcast.object.data.title),bold(formatDateTime(broadcast.data.send_time*1e3)))}return sprintf(__("Clicked %1$s in %2$s after %3$s","groundhogg"),bold(link),bold(broadcast.object.data.title),bold(formatDateTime(broadcast.data.send_time*1e3)))},edit({broadcast_id,link}){return` 55 52 ${select({id:"filter-broadcast",name:"broadcast_id"},BroadcastsStore.getItems().map(b=>({value:b.ID,text:`${b.object.data.title} (${b.date_sent_pretty})`})),broadcast_id)} 56 53 -
groundhogg/trunk/assets/js/admin/formatting.js
r3264477 r3422142 4 4 5 5 // return wp.date.format( 'h:i a', time ) 6 console.log(time);7 6 8 7 return Intl.DateTimeFormat(Groundhogg.locale, { -
groundhogg/trunk/assets/js/admin/formatting.min.js
r3264477 r3422142 1 (()=>{const formatTime=time=>{ console.log(time);return Intl.DateTimeFormat(Groundhogg.locale,{timeStyle:"short"}).format(new Date(time))};const formatDateTime=(date,opts)=>{return Intl.DateTimeFormat(Groundhogg.locale,{timeStyle:"short",dateStyle:"medium",...opts}).format(new Date(date))};const formatDate=date=>{return Intl.DateTimeFormat(Groundhogg.locale,{dateStyle:"medium",timeZone:"UTC"}).format(new Date(date))};const formatNumber=num=>{return Intl.NumberFormat(Groundhogg.locale,{}).format(num)};Groundhogg.formatting={formatTime:formatTime,formatDate:formatDate,formatDateTime:formatDateTime,formatNumber:formatNumber}})();1 (()=>{const formatTime=time=>{return Intl.DateTimeFormat(Groundhogg.locale,{timeStyle:"short"}).format(new Date(time))};const formatDateTime=(date,opts)=>{return Intl.DateTimeFormat(Groundhogg.locale,{timeStyle:"short",dateStyle:"medium",...opts}).format(new Date(date))};const formatDate=date=>{return Intl.DateTimeFormat(Groundhogg.locale,{dateStyle:"medium",timeZone:"UTC"}).format(new Date(date))};const formatNumber=num=>{return Intl.NumberFormat(Groundhogg.locale,{}).format(num)};Groundhogg.formatting={formatTime:formatTime,formatDate:formatDate,formatDateTime:formatDateTime,formatNumber:formatNumber}})(); -
groundhogg/trunk/assets/js/admin/make-el.js
r3395861 r3422142 490 490 onChange: e => onCellChange(rowIndex, cellIndex, e.target.value), 491 491 setValue: value => onCellChange(rowIndex, cellIndex, value), 492 onCellChange 492 493 }, row)), 493 494 // Sortable Handle -
groundhogg/trunk/assets/js/admin/make-el.min.js
r3395861 r3422142 2 2 <span class="on">${onLabel}</span> 3 3 <span class="off">${offLabel}</span> 4 `])};const Div=(attributes={},children=[])=>{return makeEl("div",attributes,children)};const Nav=(attributes={},children=[])=>{return makeEl("nav",attributes,children)};const Dashicon=(icon,children=null)=>{return makeEl("span",{className:`dashicons dashicons-${icon}`},children)};const Fragment=(children,atts={})=>{return makeEl("fragment",atts,children)};const Span=(attributes={},children=[])=>{return makeEl("span",attributes,children)};const Label=(attributes={},children=[])=>{return makeEl("label",attributes,children)};const InputRepeater=({id="",onChange=()=>{},rows=[],cells=[],sortable=false,fillRow=()=>Array(cells.length).fill(""),maxRows=0})=>{const handleChange=rows=>{onChange(rows);morphdom(document.getElementById(id),Repeater())};const removeRow=rowIndex=>{rows.splice(rowIndex,1);handleChange(rows)};const addRow=()=>{rows.push(fillRow());handleChange(rows)};const onCellChange=(rowIndex,cellIndex,value)=>{rows[rowIndex][cellIndex]=value;handleChange(rows)};const RepeaterRow=(row,rowIndex)=>Div({className:"gh-input-repeater-row",dataRow:rowIndex},[...cells.map((cellCallback,cellIndex)=>cellCallback({id:`${id}-cell-${rowIndex}-${cellIndex}`,name:`${id}[${rowIndex}][${cellIndex}]`,value:row[cellIndex]??"",dataRow:rowIndex,dataCell:cellIndex,onChange:e=>onCellChange(rowIndex,cellIndex,e.target.value),setValue:value=>onCellChange(rowIndex,cellIndex,value) },row)),sortable?makeEl("span",{className:"handle",dataRow:rowIndex},Dashicon("move")):null,Button({className:"gh-button dashicon remove-row",dataRow:rowIndex,type:"button",onClick:e=>removeRow(rowIndex)},Dashicon("no-alt"))]);const Repeater=()=>Div({id:id,className:"gh-input-repeater",onCreate:el=>{if(!sortable){return}$(el).sortable({handle:".handle",update:(e,ui)=>{let $row=$(ui.item);let oldIndex=parseInt($row.data("row"));let curIndex=$row.index();let row=rows[oldIndex];rows.splice(oldIndex,1);rows.splice(curIndex,0,row);onChange(rows)}})}},[...rows.map((row,i)=>RepeaterRow(row,i)),maxRows===0||rows.length<maxRows?Div({className:"gh-input-repeater-row-add"},[`<div class="spacer"></div>`,Button({id:`${id}-add-row`,className:"add-row gh-button dashicon",onClick:e=>addRow(),type:"button"},Dashicon("plus-alt2"))]):null]);return Repeater()};const InputWithReplacements=({inputCallback=Input,...attributes})=>{return Div({className:"input-wrap"},[inputCallback(attributes),Button({className:"replacements-picker-start gh-button dashicon"},Dashicon("admin-users"))])};const Table=(atts,children)=>makeEl("table",atts,children);const THead=(atts,children)=>makeEl("thead",atts,children);const TBody=(atts,children)=>makeEl("tbody",atts,children);const TFoot=(atts,children)=>makeEl("tfoot",atts,children);const Tr=(atts,children)=>makeEl("tr",atts,children);const Td=(atts,children)=>makeEl("td",atts,children);const Th=(atts,children)=>makeEl("th",atts,children);const Modal=({dialogClasses="",className="",onOpen=()=>{},onClose=()=>{},width,closeButton=true,closeOnOverlayClick=true,overlay=true},children)=>{const Dialog=({header=null,content=null})=>Div({className:`gh-modal-dialog ${dialogClasses}`,style:{width:width}},[header,Div({className:"gh-modal-dialog-content"},content),closeButton&&!header?Button({className:"dashicon-button gh-modal-button-close-top gh-modal-button-close",onClick:e=>{close()}},Dashicon("no-alt")):null]);let modal=Div({className:`gh-modal ${className}`,tabindex:0},[overlay?Div({className:"gh-modal-overlay",onClick:e=>{if(closeOnOverlayClick){close()}}}):null,Dialog({header:null,content:null})]);const close=()=>{onClose(modal);modal.remove()};const morph=(args={})=>{let content=getContent();let header=content.querySelector(".modal-header");morphdom(modal.querySelector(".gh-modal-dialog"),Dialog({header:header,content:content}),args)};const getContent=()=>maybeCall(children,{close:close,modal:modal,morph:morph});document.body.appendChild(modal);morph();onOpen({modal:modal,close:close,morph:morph});if(!modal.contains(document.activeElement)){modal.focus()}return modal};const ModalWithHeader=({header="",...args},children)=>Modal(args,methods=>Div({},[Div({className:"gh-header modal-header"},[MakeEl.H3({},header),MakeEl.Button({className:"gh-button icon secondary text",onClick:methods.close},MakeEl.Dashicon("no-alt"))]),maybeCall(children,methods)]));const ModalFrame=({onOpen=()=>{},onClose=()=>{},frameAttributes={},closeOnOverlayClick=true,closeOnEscape=true},children)=>{let modal=Div({className:"gh-modal",tabindex:0,onKeydown:e=>{if(closeOnEscape){if(e.key==="Esc"||e.key==="Escape"){close()}}}},[Div({className:"gh-modal-overlay",onClick:e=>{if(closeOnOverlayClick){close()}}}),Div({className:`gh-modal-frame`,...frameAttributes},[])]);const close=()=>{onClose();modal.remove()};modal.querySelector(".gh-modal-frame").appendChild(Fragment(maybeCall(children,{close:close})));document.body.appendChild(modal);onOpen({close:close});modal.focus();return modal};const MiniModal=({selector="",target=null,from="right",dialogClasses="",onOpen=()=>{},onClose=()=>{},closeOnFocusout=true},children)=>{let modal=Div({className:"gh-modal mini gh-panel",tabindex:0,onFocusout:e=>{if(closeOnFocusout){if(!e.relatedTarget||!clickedIn(e.relatedTarget,".gh-modal.mini")){setTimeout(()=>{if(!clickedIn(document.activeElement,".gh-modal.mini")){close()}},10)}}},onCreate:el=>{el.focus()}},Div({className:`gh-modal-dialog ${dialogClasses}`},[Button({className:"dashicon-button gh-modal-button-close-top gh-modal-button-close",onClick:e=>{close()}},Dashicon("no-alt"))]));const close=()=>{onClose();modal.remove()};modal.querySelector(".gh-modal-dialog").appendChild(Fragment(maybeCall(children,{close:close})));document.body.appendChild(modal);onOpen();let targetElement=selector&&target===null?document.querySelector(selector):target;let{right,left,bottom,top}=targetElement.getBoundingClientRect();let{width,height}=modal.getBoundingClientRect();switch(from){case"left":modal.style.left=left+"px";break;case"right":modal.style.left=right-width+"px";break}if(top+height>window.innerHeight){modal.style.top=window.innerHeight-height-20+"px"}else{modal.style.top=top+"px"}modal.focus();return modal};const Autocomplete=({fetchResults=async search=>{},onInput,...attributes})=>{let timeout;const State={pointer:0,results:[],input:null};const setValue=()=>{let item=State.results[State.pointer];State.input.value=item.id;State.input.dispatchEvent(new Event("change"));closeResults()};const updateResults=()=>{if(!State.results.length){closeResults();return}let resultsContainer=document.querySelector(".gh-autocomplete-results");let newResults=Results();if(!resultsContainer){document.body.appendChild(newResults)}else{morphdom(resultsContainer,newResults)}};const closeResults=()=>{let resultsContainer=document.querySelector(".gh-autocomplete-results");if(resultsContainer){resultsContainer.remove()}};const Results=()=>{const{results,input}=State;let{height,width,top,left}=input.getBoundingClientRect();return Div({className:"gh-autocomplete-results",style:{zIndex:999999,top:`${top+height}px`,left:`${left}px`,width:`${width}px`}},results.map(({id,text},index)=>makeEl("a",{className:`${index===State.pointer?"pointer":""}`,href:id,onClick:e=>{e.preventDefault();setValue()},onMouseenter:e=>{State.pointer=[...e.target.parentNode.children].indexOf(e.target);updateResults()}},text)))};return Input({...attributes,onFocusout:e=>{const input=e.target;input.classList.remove("has-results");if(e.relatedTarget&&clickedIn(e.relatedTarget,"a.pointer")){setValue()}closeResults()},onKeydown:e=>{const input=e.target;switch(e.key){case"Esc":case"Escape":e.preventDefault();closeResults();return;case"Down":case"ArrowDown":e.preventDefault();if(State.pointer<State.results.length){State.pointer++}break;case"Up":case"ArrowUp":e.preventDefault();if(State.pointer>0){State.pointer--}break;case"Enter":e.preventDefault();setValue();break;default:return}updateResults()},onInput:e=>{if(timeout){clearTimeout(timeout)}timeout=setTimeout(async()=>{const input=e.target;let search=input.value;State.results=await fetchResults(search);State.input=input;State.pointer=0;updateResults();input.classList.add("gh-autocomplete","has-results")},500);onInput(e)}})};const Ellipses=(content,atts={})=>Span({...atts,onCreate:el=>{let ellipses="";let count=0;let interval=setInterval(()=>{if(!el.parentNode){clearInterval(interval);return}count=(count+1)%4;ellipses=".".repeat(count);el.textContent=content+ellipses},500)}},content+"...");const ItemPicker=({id="",label="",placeholder="Type to search...",fetchOptions=(search,resolve)=>{},selected=[],onChange=()=>{},onSelect=()=>{},onCreate=()=>{},onUnselect=()=>{},createOption=val=>Promise.resolve({id:val,text:val}),tags=false,noneSelected="Any",isValidSelection=string=>Boolean(string),multiple=true,clearable=true,...attributes})=>{const state=Groundhogg.createState({search:"",searching:false,choosing:false,options:[],focused:false,morphing:false,clicked:false});const optionsVisible=()=>{return multiple?state.focused&&(state.searching||state.options.length||tags&&isValidSelection(state.search)):state.focused};if(!multiple&&!Array.isArray(selected)){selected=[selected]}let timeout;const setState=(newState,trigger)=>{state.set(newState);morph()};const handleOnChange=selected=>{if(timeout){clearTimeout(timeout)}if(multiple){onChange(selected);return}if(!selected.length){onChange(null);return}onChange(selected[0])};const morph=()=>{if(state.morphing){return}state.set({morphing:true});morphdom(document.getElementById(id),Render());state.set({morphing:false})};const focusSearch=()=>document.getElementById(id)?.querySelector(`input[type=search]`)?.focus();const focusPicker=()=>document.getElementById(id)?.focus();const focusParent=()=>document.getElementById(id)?.parentElement.focus();const handleCreateOption=value=>{state.options.unshift({id:value,text:value,create:true});handleSelectOption(value)};const handleSelectOption=async id=>{let option={...state.options.find(opt=>opt.id==id)};if(option.create){option.text=option.id}if(multiple){selected.push(option)}else{selected=[option]}if(option.create){await createOption(option.id).then(opt=>{selected=selected.map(item=>item.id==id?opt:item);option=opt})}onSelect(option);handleOnChange(selected);if(!multiple){state.set({focused:false})}setState({search:""});morph();if(multiple){focusSearch()}else{focusPicker()}};const handleUnselectOption=id=>{let opt=selected.find(opt=>opt.id===id);selected=selected.filter(opt=>opt.id!=id);onUnselect(opt);handleOnChange(selected);morph();if(multiple){focusSearch()}};const itemPickerItem=({id,text},index)=>{return Div({className:`gh-picker-item ${isValidSelection(id)?"":"is-invalid"}`,id:`item-${id}-${index}`},[Span({className:"gh-picker-item-text"},text),selected.length>1||clearable?Span({id:`delete-${id}-${index}`,className:"gh-picker-item-delete",tabindex:"0",dataId:id,onClick:e=>{handleUnselectOption(id)}},"×"):null])};const itemPickerOption=({id,text},index)=>{return Div({className:"gh-picker-option",dataId:id,tabindex:"0",id:`option-${index}-${id}`,onClick:e=>{handleSelectOption(id)}},text)};const itemPickerOptions=()=>{let picker=document.getElementById(id);let style={};if(picker){const{left,right,top,bottom,width}=picker.getBoundingClientRect();let maxHeight=window.innerHeight-bottom-20;if(maxHeight>100){style.top=bottom+"px";style.left=left+"px";style.width=width+"px";style.maxHeight=maxHeight+"px"}else{style.bottom=window.innerHeight-top+"px";style.left=left+"px";style.width=width+"px";style.maxHeight=top-20+"px"}}state.options=state.options.filter(opt=>!opt.create);if(!state.searching&&tags&&isValidSelection(state.search)){if(!state.options.find(opt=>opt.id==state.search||opt.text==state.search)){state.options.unshift({id:state.search,text:`Add "${state.search}"`,create:true})}}let options=state.options.filter(opt=>!selected.some(_opt=>opt.id==_opt.id));return Div({className:"gh-picker-options",style:style,onCreate:el=>{setTimeout(()=>{let picker=document.getElementById(id);let optionsContainer=picker.querySelector(".gh-picker-options");const{left,right,top,bottom,width}=picker.getBoundingClientRect();let maxHeight=window.innerHeight-bottom-20;if(maxHeight>100){optionsContainer.style.top=bottom+"px";optionsContainer.style.left=left+"px";optionsContainer.style.width=width+"px";optionsContainer.style.maxHeight=maxHeight+"px"}else{optionsContainer.style.bottom=window.innerHeight-top+"px";optionsContainer.style.left=left+"px";optionsContainer.style.width=width+"px";optionsContainer.style.maxHeight=top-20+"px"}if(!multiple){focusSearch()}},0)}},[multiple||!selected.length?null:SearchInput(),state.searching?Div({className:"gh-picker-no-options"},Ellipses(wp.i18n.__("Searching"))):null,...options.map((opt,i)=>itemPickerOption(opt,i)),options.length||state.searching?null:Div({className:"gh-picker-no-options"},"No results found.")])};const startSearch=search=>{setState({search:search,searching:true},"start search");if(timeout){clearTimeout(timeout)}timeout=setTimeout(()=>{fetchOptions(search).then(options=>{if(search!==state.search){return}setState({searching:false,options:options},"options fetched")})},500)};const SearchInput=()=>Input({className:"gh-picker-search",value:state.search,name:"search",type:"search",autocomplete:"off",id:`${id}-search-input`,placeholder:selected.length?placeholder:noneSelected,onInput:e=>startSearch(e.target.value),onFocus:e=>{startSearch(e.target.value)},onKeydown:e=>{if(tags){if(e.key!=="Enter"&&e.key!==","){return}handleCreateOption(e.target.value)}}});const Render=()=>Div({id:id,className:`gh-picker-container`,tabindex:"0",...attributes},Div({id:`${id}-picker`,className:`gh-picker ${optionsVisible()?"options-visible":""}`,tabindex:"0",onKeydown:e=>{if(e.key==="Escape"){setState({searching:false,focused:false});morph()}},onCreate:el=>{el.addEventListener("focusout",e=>{setTimeout(()=>{if(state.morphing||document.getElementById(id).contains(document.activeElement)){return}setState({search:"",options:[],searching:false,focused:false},"picker focusout")},10)});el.addEventListener("focusin",e=>{if(state.focused){return}setState({focused:true},"picker focused")})}},[Div({className:`gh-picker-selected ${multiple?"multiple":"single"}`},[selected.length&&label?Span({className:"gh-picker-label"},label):null,...selected.map((item,i)=>itemPickerItem(item,i)),multiple||!selected.length?SearchInput():null]),optionsVisible()?itemPickerOptions():null]));return Render()};const InputGroup=inputs=>Div({className:"gh-input-group"},inputs);const Iframe=({onCreate=()=>{},...attributes},content=null)=>{let blob=new Blob([content],{type:"text/html; charset=utf-8"});let src=URL.createObjectURL(blob);return makeEl("iframe",{...attributes,src:src})};const ToolTip=(content,position="bottom")=>{return Div({className:`gh-tooltip ${position}`},content)};const ButtonToggle=({id="",options=[],selected="",onChange=value=>{}})=>{const render=()=>Div({id:id,className:"gh-input-group"},options.map(opt=>ButtonOption(opt)));const ButtonOption=option=>Button({id:`${id}-opt-${option.id}`,className:`gh-button gh-button small ${selected===option.id?"dark":"grey"}`,onClick:e=>{selected=option.id;morphdom(document.getElementById(id),render());onChange(option.id)}},[option.text,option.tooltip?ToolTip(option.tooltip):null]);return render()};const ProgressBar=({percent=100,error=false,className=""})=>{return Div({className:`gh-progress-bar ${error?"gh-error":""} ${className}`},Div({className:"gh-progress-bar-fill",style:{width:`${percent||1}%`}},Span({className:"fill-amount"},`${Math.ceil(percent)}%`)))};const Img=props=>makeEl("img",props);const Pg=(props,children)=>makeEl("p",props,children);const Bold=(props,children)=>makeEl("b",props,children);const An=(props,children)=>{props={href:"javascript:void(0)",...props};return makeEl("a",props,children)};const Ul=(props,children)=>makeEl("ul",props,children);const Ol=(props,children)=>makeEl("ol",props,children);const Li=(props,children)=>makeEl("li",props,children);const H1=(props,children)=>makeEl("h1",props,children);const H2=(props,children)=>makeEl("h2",props,children);const H3=(props,children)=>makeEl("h3",props,children);const H4=(props,children)=>makeEl("h4",props,children);const Hr=(props,children)=>makeEl("hr",props,children);const Skeleton=(attributes,pieces)=>Div({className:"display-grid gap-10",...attributes},pieces.map(span=>Div({className:`${span} skeleton-loading`,style:{height:`40px`}})));const useState=(initialState,id)=>{const el=document.getElementById(id);if(el&&el.State){return el.State}return Groundhogg.createState(initialState)};const Accordion=({id,items,outlined=false,multiple=false})=>{const State=useState({expanded:null},id);const isExpanded=index=>multiple?State.get(`expand${index+1}`):State.expanded===index;const toggleExpand=index=>{if(multiple){State.set({[`expand${index+1}`]:!isExpanded(index)})}else{State.set({expanded:index})}};return Div({id:id,className:"gh-accordion",State:State},morph=>Fragment(items.map(({title,content},i)=>Div({className:`gh-accordion-item gh-accordion-row ${isExpanded(i)?"expanded":"collapsed"} ${outlined?"outlined":"has-box-shadow"}`,id:`${id}-item-${i+1}`},[Div({id:`${id}-item-toggle-${i+1}`,className:"display-flex gap-10 align-center",onClick:e=>{toggleExpand(i);morph()}},[Pg({className:"gh-accordion-item-title"},title),isExpanded(i)?Dashicon("arrow-up-alt2"):Dashicon("arrow-down-alt2")]),isExpanded(i)?content:null]))))};const TinyMCE=({id="",content="",config={},onChange=content=>{},...props})=>{let openEditor=document.getElementById(id);let height=300;if(openEditor&&openEditor.tinyMceInitialized){height=openEditor.previousElementSibling.getBoundingClientRect().height}return Div({id:`tiny-mce-${id}`,className:"tiny-mce-wrap"},Textarea({id:id,name:id.replaceAll("-","_"),value:content,style:{height:`${height}px`},onCreate:el=>{setTimeout(()=>{Groundhogg.element.tinymceElement(el.id,config,onChange);el.tinyMceInitialized=true})},...props}))};window.MakeEl={Skeleton:Skeleton,TinyMCE:TinyMCE,InputGroup:InputGroup,Ellipses:Ellipses,Input:Input,InputWithReplacements:InputWithReplacements,Textarea:Textarea,Select:Select,Form:Form,ToolTip:ToolTip,Button:Button,Toggle:Toggle,Div:Div,Span:Span,Label:Label,InputRepeater:InputRepeater,Fragment:Fragment,Table:Table,TBody:TBody,THead:THead,TFoot:TFoot,Tr:Tr,Td:Td,Th:Th,Modal:Modal,ModalWithHeader:ModalWithHeader,MiniModal:MiniModal,ModalFrame:ModalFrame,ItemPicker:ItemPicker,Iframe:Iframe,Dashicon:Dashicon,ButtonToggle:ButtonToggle,Autocomplete:Autocomplete,ProgressBar:ProgressBar,Accordion:Accordion,Pg:Pg,Bold:Bold,Img:Img,An:An,Ul:Ul,Ol:Ol,Li:Li,H1:H1,H2:H2,H3:H3,H4:H4,Hr:Hr,Nav:Nav,maybeCall:maybeCall,forDom:forDom,forReact:forReact,makeEl:makeEl,makeElForReact:makeElForReact,htmlToReact:htmlToReact,htmlToElement:htmlToElement,htmlToElements:htmlToElements,domElementToReact:domElementToReact,useState:useState}})(jQuery??function(){throw new Error("jQuery was not loaded.")});4 `])};const Div=(attributes={},children=[])=>{return makeEl("div",attributes,children)};const Nav=(attributes={},children=[])=>{return makeEl("nav",attributes,children)};const Dashicon=(icon,children=null)=>{return makeEl("span",{className:`dashicons dashicons-${icon}`},children)};const Fragment=(children,atts={})=>{return makeEl("fragment",atts,children)};const Span=(attributes={},children=[])=>{return makeEl("span",attributes,children)};const Label=(attributes={},children=[])=>{return makeEl("label",attributes,children)};const InputRepeater=({id="",onChange=()=>{},rows=[],cells=[],sortable=false,fillRow=()=>Array(cells.length).fill(""),maxRows=0})=>{const handleChange=rows=>{onChange(rows);morphdom(document.getElementById(id),Repeater())};const removeRow=rowIndex=>{rows.splice(rowIndex,1);handleChange(rows)};const addRow=()=>{rows.push(fillRow());handleChange(rows)};const onCellChange=(rowIndex,cellIndex,value)=>{rows[rowIndex][cellIndex]=value;handleChange(rows)};const RepeaterRow=(row,rowIndex)=>Div({className:"gh-input-repeater-row",dataRow:rowIndex},[...cells.map((cellCallback,cellIndex)=>cellCallback({id:`${id}-cell-${rowIndex}-${cellIndex}`,name:`${id}[${rowIndex}][${cellIndex}]`,value:row[cellIndex]??"",dataRow:rowIndex,dataCell:cellIndex,onChange:e=>onCellChange(rowIndex,cellIndex,e.target.value),setValue:value=>onCellChange(rowIndex,cellIndex,value),onCellChange:onCellChange},row)),sortable?makeEl("span",{className:"handle",dataRow:rowIndex},Dashicon("move")):null,Button({className:"gh-button dashicon remove-row",dataRow:rowIndex,type:"button",onClick:e=>removeRow(rowIndex)},Dashicon("no-alt"))]);const Repeater=()=>Div({id:id,className:"gh-input-repeater",onCreate:el=>{if(!sortable){return}$(el).sortable({handle:".handle",update:(e,ui)=>{let $row=$(ui.item);let oldIndex=parseInt($row.data("row"));let curIndex=$row.index();let row=rows[oldIndex];rows.splice(oldIndex,1);rows.splice(curIndex,0,row);onChange(rows)}})}},[...rows.map((row,i)=>RepeaterRow(row,i)),maxRows===0||rows.length<maxRows?Div({className:"gh-input-repeater-row-add"},[`<div class="spacer"></div>`,Button({id:`${id}-add-row`,className:"add-row gh-button dashicon",onClick:e=>addRow(),type:"button"},Dashicon("plus-alt2"))]):null]);return Repeater()};const InputWithReplacements=({inputCallback=Input,...attributes})=>{return Div({className:"input-wrap"},[inputCallback(attributes),Button({className:"replacements-picker-start gh-button dashicon"},Dashicon("admin-users"))])};const Table=(atts,children)=>makeEl("table",atts,children);const THead=(atts,children)=>makeEl("thead",atts,children);const TBody=(atts,children)=>makeEl("tbody",atts,children);const TFoot=(atts,children)=>makeEl("tfoot",atts,children);const Tr=(atts,children)=>makeEl("tr",atts,children);const Td=(atts,children)=>makeEl("td",atts,children);const Th=(atts,children)=>makeEl("th",atts,children);const Modal=({dialogClasses="",className="",onOpen=()=>{},onClose=()=>{},width,closeButton=true,closeOnOverlayClick=true,overlay=true},children)=>{const Dialog=({header=null,content=null})=>Div({className:`gh-modal-dialog ${dialogClasses}`,style:{width:width}},[header,Div({className:"gh-modal-dialog-content"},content),closeButton&&!header?Button({className:"dashicon-button gh-modal-button-close-top gh-modal-button-close",onClick:e=>{close()}},Dashicon("no-alt")):null]);let modal=Div({className:`gh-modal ${className}`,tabindex:0},[overlay?Div({className:"gh-modal-overlay",onClick:e=>{if(closeOnOverlayClick){close()}}}):null,Dialog({header:null,content:null})]);const close=()=>{onClose(modal);modal.remove()};const morph=(args={})=>{let content=getContent();let header=content.querySelector(".modal-header");morphdom(modal.querySelector(".gh-modal-dialog"),Dialog({header:header,content:content}),args)};const getContent=()=>maybeCall(children,{close:close,modal:modal,morph:morph});document.body.appendChild(modal);morph();onOpen({modal:modal,close:close,morph:morph});if(!modal.contains(document.activeElement)){modal.focus()}return modal};const ModalWithHeader=({header="",...args},children)=>Modal(args,methods=>Div({},[Div({className:"gh-header modal-header"},[MakeEl.H3({},header),MakeEl.Button({className:"gh-button icon secondary text",onClick:methods.close},MakeEl.Dashicon("no-alt"))]),maybeCall(children,methods)]));const ModalFrame=({onOpen=()=>{},onClose=()=>{},frameAttributes={},closeOnOverlayClick=true,closeOnEscape=true},children)=>{let modal=Div({className:"gh-modal",tabindex:0,onKeydown:e=>{if(closeOnEscape){if(e.key==="Esc"||e.key==="Escape"){close()}}}},[Div({className:"gh-modal-overlay",onClick:e=>{if(closeOnOverlayClick){close()}}}),Div({className:`gh-modal-frame`,...frameAttributes},[])]);const close=()=>{onClose();modal.remove()};modal.querySelector(".gh-modal-frame").appendChild(Fragment(maybeCall(children,{close:close})));document.body.appendChild(modal);onOpen({close:close});modal.focus();return modal};const MiniModal=({selector="",target=null,from="right",dialogClasses="",onOpen=()=>{},onClose=()=>{},closeOnFocusout=true},children)=>{let modal=Div({className:"gh-modal mini gh-panel",tabindex:0,onFocusout:e=>{if(closeOnFocusout){if(!e.relatedTarget||!clickedIn(e.relatedTarget,".gh-modal.mini")){setTimeout(()=>{if(!clickedIn(document.activeElement,".gh-modal.mini")){close()}},10)}}},onCreate:el=>{el.focus()}},Div({className:`gh-modal-dialog ${dialogClasses}`},[Button({className:"dashicon-button gh-modal-button-close-top gh-modal-button-close",onClick:e=>{close()}},Dashicon("no-alt"))]));const close=()=>{onClose();modal.remove()};modal.querySelector(".gh-modal-dialog").appendChild(Fragment(maybeCall(children,{close:close})));document.body.appendChild(modal);onOpen();let targetElement=selector&&target===null?document.querySelector(selector):target;let{right,left,bottom,top}=targetElement.getBoundingClientRect();let{width,height}=modal.getBoundingClientRect();switch(from){case"left":modal.style.left=left+"px";break;case"right":modal.style.left=right-width+"px";break}if(top+height>window.innerHeight){modal.style.top=window.innerHeight-height-20+"px"}else{modal.style.top=top+"px"}modal.focus();return modal};const Autocomplete=({fetchResults=async search=>{},onInput,...attributes})=>{let timeout;const State={pointer:0,results:[],input:null};const setValue=()=>{let item=State.results[State.pointer];State.input.value=item.id;State.input.dispatchEvent(new Event("change"));closeResults()};const updateResults=()=>{if(!State.results.length){closeResults();return}let resultsContainer=document.querySelector(".gh-autocomplete-results");let newResults=Results();if(!resultsContainer){document.body.appendChild(newResults)}else{morphdom(resultsContainer,newResults)}};const closeResults=()=>{let resultsContainer=document.querySelector(".gh-autocomplete-results");if(resultsContainer){resultsContainer.remove()}};const Results=()=>{const{results,input}=State;let{height,width,top,left}=input.getBoundingClientRect();return Div({className:"gh-autocomplete-results",style:{zIndex:999999,top:`${top+height}px`,left:`${left}px`,width:`${width}px`}},results.map(({id,text},index)=>makeEl("a",{className:`${index===State.pointer?"pointer":""}`,href:id,onClick:e=>{e.preventDefault();setValue()},onMouseenter:e=>{State.pointer=[...e.target.parentNode.children].indexOf(e.target);updateResults()}},text)))};return Input({...attributes,onFocusout:e=>{const input=e.target;input.classList.remove("has-results");if(e.relatedTarget&&clickedIn(e.relatedTarget,"a.pointer")){setValue()}closeResults()},onKeydown:e=>{const input=e.target;switch(e.key){case"Esc":case"Escape":e.preventDefault();closeResults();return;case"Down":case"ArrowDown":e.preventDefault();if(State.pointer<State.results.length){State.pointer++}break;case"Up":case"ArrowUp":e.preventDefault();if(State.pointer>0){State.pointer--}break;case"Enter":e.preventDefault();setValue();break;default:return}updateResults()},onInput:e=>{if(timeout){clearTimeout(timeout)}timeout=setTimeout(async()=>{const input=e.target;let search=input.value;State.results=await fetchResults(search);State.input=input;State.pointer=0;updateResults();input.classList.add("gh-autocomplete","has-results")},500);onInput(e)}})};const Ellipses=(content,atts={})=>Span({...atts,onCreate:el=>{let ellipses="";let count=0;let interval=setInterval(()=>{if(!el.parentNode){clearInterval(interval);return}count=(count+1)%4;ellipses=".".repeat(count);el.textContent=content+ellipses},500)}},content+"...");const ItemPicker=({id="",label="",placeholder="Type to search...",fetchOptions=(search,resolve)=>{},selected=[],onChange=()=>{},onSelect=()=>{},onCreate=()=>{},onUnselect=()=>{},createOption=val=>Promise.resolve({id:val,text:val}),tags=false,noneSelected="Any",isValidSelection=string=>Boolean(string),multiple=true,clearable=true,...attributes})=>{const state=Groundhogg.createState({search:"",searching:false,choosing:false,options:[],focused:false,morphing:false,clicked:false});const optionsVisible=()=>{return multiple?state.focused&&(state.searching||state.options.length||tags&&isValidSelection(state.search)):state.focused};if(!multiple&&!Array.isArray(selected)){selected=[selected]}let timeout;const setState=(newState,trigger)=>{state.set(newState);morph()};const handleOnChange=selected=>{if(timeout){clearTimeout(timeout)}if(multiple){onChange(selected);return}if(!selected.length){onChange(null);return}onChange(selected[0])};const morph=()=>{if(state.morphing){return}state.set({morphing:true});morphdom(document.getElementById(id),Render());state.set({morphing:false})};const focusSearch=()=>document.getElementById(id)?.querySelector(`input[type=search]`)?.focus();const focusPicker=()=>document.getElementById(id)?.focus();const focusParent=()=>document.getElementById(id)?.parentElement.focus();const handleCreateOption=value=>{state.options.unshift({id:value,text:value,create:true});handleSelectOption(value)};const handleSelectOption=async id=>{let option={...state.options.find(opt=>opt.id==id)};if(option.create){option.text=option.id}if(multiple){selected.push(option)}else{selected=[option]}if(option.create){await createOption(option.id).then(opt=>{selected=selected.map(item=>item.id==id?opt:item);option=opt})}onSelect(option);handleOnChange(selected);if(!multiple){state.set({focused:false})}setState({search:""});morph();if(multiple){focusSearch()}else{focusPicker()}};const handleUnselectOption=id=>{let opt=selected.find(opt=>opt.id===id);selected=selected.filter(opt=>opt.id!=id);onUnselect(opt);handleOnChange(selected);morph();if(multiple){focusSearch()}};const itemPickerItem=({id,text},index)=>{return Div({className:`gh-picker-item ${isValidSelection(id)?"":"is-invalid"}`,id:`item-${id}-${index}`},[Span({className:"gh-picker-item-text"},text),selected.length>1||clearable?Span({id:`delete-${id}-${index}`,className:"gh-picker-item-delete",tabindex:"0",dataId:id,onClick:e=>{handleUnselectOption(id)}},"×"):null])};const itemPickerOption=({id,text},index)=>{return Div({className:"gh-picker-option",dataId:id,tabindex:"0",id:`option-${index}-${id}`,onClick:e=>{handleSelectOption(id)}},text)};const itemPickerOptions=()=>{let picker=document.getElementById(id);let style={};if(picker){const{left,right,top,bottom,width}=picker.getBoundingClientRect();let maxHeight=window.innerHeight-bottom-20;if(maxHeight>100){style.top=bottom+"px";style.left=left+"px";style.width=width+"px";style.maxHeight=maxHeight+"px"}else{style.bottom=window.innerHeight-top+"px";style.left=left+"px";style.width=width+"px";style.maxHeight=top-20+"px"}}state.options=state.options.filter(opt=>!opt.create);if(!state.searching&&tags&&isValidSelection(state.search)){if(!state.options.find(opt=>opt.id==state.search||opt.text==state.search)){state.options.unshift({id:state.search,text:`Add "${state.search}"`,create:true})}}let options=state.options.filter(opt=>!selected.some(_opt=>opt.id==_opt.id));return Div({className:"gh-picker-options",style:style,onCreate:el=>{setTimeout(()=>{let picker=document.getElementById(id);let optionsContainer=picker.querySelector(".gh-picker-options");const{left,right,top,bottom,width}=picker.getBoundingClientRect();let maxHeight=window.innerHeight-bottom-20;if(maxHeight>100){optionsContainer.style.top=bottom+"px";optionsContainer.style.left=left+"px";optionsContainer.style.width=width+"px";optionsContainer.style.maxHeight=maxHeight+"px"}else{optionsContainer.style.bottom=window.innerHeight-top+"px";optionsContainer.style.left=left+"px";optionsContainer.style.width=width+"px";optionsContainer.style.maxHeight=top-20+"px"}if(!multiple){focusSearch()}},0)}},[multiple||!selected.length?null:SearchInput(),state.searching?Div({className:"gh-picker-no-options"},Ellipses(wp.i18n.__("Searching"))):null,...options.map((opt,i)=>itemPickerOption(opt,i)),options.length||state.searching?null:Div({className:"gh-picker-no-options"},"No results found.")])};const startSearch=search=>{setState({search:search,searching:true},"start search");if(timeout){clearTimeout(timeout)}timeout=setTimeout(()=>{fetchOptions(search).then(options=>{if(search!==state.search){return}setState({searching:false,options:options},"options fetched")})},500)};const SearchInput=()=>Input({className:"gh-picker-search",value:state.search,name:"search",type:"search",autocomplete:"off",id:`${id}-search-input`,placeholder:selected.length?placeholder:noneSelected,onInput:e=>startSearch(e.target.value),onFocus:e=>{startSearch(e.target.value)},onKeydown:e=>{if(tags){if(e.key!=="Enter"&&e.key!==","){return}handleCreateOption(e.target.value)}}});const Render=()=>Div({id:id,className:`gh-picker-container`,tabindex:"0",...attributes},Div({id:`${id}-picker`,className:`gh-picker ${optionsVisible()?"options-visible":""}`,tabindex:"0",onKeydown:e=>{if(e.key==="Escape"){setState({searching:false,focused:false});morph()}},onCreate:el=>{el.addEventListener("focusout",e=>{setTimeout(()=>{if(state.morphing||document.getElementById(id).contains(document.activeElement)){return}setState({search:"",options:[],searching:false,focused:false},"picker focusout")},10)});el.addEventListener("focusin",e=>{if(state.focused){return}setState({focused:true},"picker focused")})}},[Div({className:`gh-picker-selected ${multiple?"multiple":"single"}`},[selected.length&&label?Span({className:"gh-picker-label"},label):null,...selected.map((item,i)=>itemPickerItem(item,i)),multiple||!selected.length?SearchInput():null]),optionsVisible()?itemPickerOptions():null]));return Render()};const InputGroup=inputs=>Div({className:"gh-input-group"},inputs);const Iframe=({onCreate=()=>{},...attributes},content=null)=>{let blob=new Blob([content],{type:"text/html; charset=utf-8"});let src=URL.createObjectURL(blob);return makeEl("iframe",{...attributes,src:src})};const ToolTip=(content,position="bottom")=>{return Div({className:`gh-tooltip ${position}`},content)};const ButtonToggle=({id="",options=[],selected="",onChange=value=>{}})=>{const render=()=>Div({id:id,className:"gh-input-group"},options.map(opt=>ButtonOption(opt)));const ButtonOption=option=>Button({id:`${id}-opt-${option.id}`,className:`gh-button gh-button small ${selected===option.id?"dark":"grey"}`,onClick:e=>{selected=option.id;morphdom(document.getElementById(id),render());onChange(option.id)}},[option.text,option.tooltip?ToolTip(option.tooltip):null]);return render()};const ProgressBar=({percent=100,error=false,className=""})=>{return Div({className:`gh-progress-bar ${error?"gh-error":""} ${className}`},Div({className:"gh-progress-bar-fill",style:{width:`${percent||1}%`}},Span({className:"fill-amount"},`${Math.ceil(percent)}%`)))};const Img=props=>makeEl("img",props);const Pg=(props,children)=>makeEl("p",props,children);const Bold=(props,children)=>makeEl("b",props,children);const An=(props,children)=>{props={href:"javascript:void(0)",...props};return makeEl("a",props,children)};const Ul=(props,children)=>makeEl("ul",props,children);const Ol=(props,children)=>makeEl("ol",props,children);const Li=(props,children)=>makeEl("li",props,children);const H1=(props,children)=>makeEl("h1",props,children);const H2=(props,children)=>makeEl("h2",props,children);const H3=(props,children)=>makeEl("h3",props,children);const H4=(props,children)=>makeEl("h4",props,children);const Hr=(props,children)=>makeEl("hr",props,children);const Skeleton=(attributes,pieces)=>Div({className:"display-grid gap-10",...attributes},pieces.map(span=>Div({className:`${span} skeleton-loading`,style:{height:`40px`}})));const useState=(initialState,id)=>{const el=document.getElementById(id);if(el&&el.State){return el.State}return Groundhogg.createState(initialState)};const Accordion=({id,items,outlined=false,multiple=false})=>{const State=useState({expanded:null},id);const isExpanded=index=>multiple?State.get(`expand${index+1}`):State.expanded===index;const toggleExpand=index=>{if(multiple){State.set({[`expand${index+1}`]:!isExpanded(index)})}else{State.set({expanded:index})}};return Div({id:id,className:"gh-accordion",State:State},morph=>Fragment(items.map(({title,content},i)=>Div({className:`gh-accordion-item gh-accordion-row ${isExpanded(i)?"expanded":"collapsed"} ${outlined?"outlined":"has-box-shadow"}`,id:`${id}-item-${i+1}`},[Div({id:`${id}-item-toggle-${i+1}`,className:"display-flex gap-10 align-center",onClick:e=>{toggleExpand(i);morph()}},[Pg({className:"gh-accordion-item-title"},title),isExpanded(i)?Dashicon("arrow-up-alt2"):Dashicon("arrow-down-alt2")]),isExpanded(i)?content:null]))))};const TinyMCE=({id="",content="",config={},onChange=content=>{},...props})=>{let openEditor=document.getElementById(id);let height=300;if(openEditor&&openEditor.tinyMceInitialized){height=openEditor.previousElementSibling.getBoundingClientRect().height}return Div({id:`tiny-mce-${id}`,className:"tiny-mce-wrap"},Textarea({id:id,name:id.replaceAll("-","_"),value:content,style:{height:`${height}px`},onCreate:el=>{setTimeout(()=>{Groundhogg.element.tinymceElement(el.id,config,onChange);el.tinyMceInitialized=true})},...props}))};window.MakeEl={Skeleton:Skeleton,TinyMCE:TinyMCE,InputGroup:InputGroup,Ellipses:Ellipses,Input:Input,InputWithReplacements:InputWithReplacements,Textarea:Textarea,Select:Select,Form:Form,ToolTip:ToolTip,Button:Button,Toggle:Toggle,Div:Div,Span:Span,Label:Label,InputRepeater:InputRepeater,Fragment:Fragment,Table:Table,TBody:TBody,THead:THead,TFoot:TFoot,Tr:Tr,Td:Td,Th:Th,Modal:Modal,ModalWithHeader:ModalWithHeader,MiniModal:MiniModal,ModalFrame:ModalFrame,ItemPicker:ItemPicker,Iframe:Iframe,Dashicon:Dashicon,ButtonToggle:ButtonToggle,Autocomplete:Autocomplete,ProgressBar:ProgressBar,Accordion:Accordion,Pg:Pg,Bold:Bold,Img:Img,An:An,Ul:Ul,Ol:Ol,Li:Li,H1:H1,H2:H2,H3:H3,H4:H4,Hr:Hr,Nav:Nav,maybeCall:maybeCall,forDom:forDom,forReact:forReact,makeEl:makeEl,makeElForReact:makeElForReact,htmlToReact:htmlToReact,htmlToElement:htmlToElement,htmlToElements:htmlToElements,domElementToReact:domElementToReact,useState:useState}})(jQuery??function(){throw new Error("jQuery was not loaded.")}); -
groundhogg/trunk/blocks/gutenberg/build/index.js
r3395861 r3422142 166 166 options: forms, 167 167 onChange: value => { 168 const form = window.Groundhogg.stores.forms.get(parseInt( formId));168 const form = window.Groundhogg.stores.forms.get(parseInt(value)); 169 169 setAttributes({ 170 170 formId: value, -
groundhogg/trunk/blocks/gutenberg/build/index.js.map
r3395861 r3422142 1 {"version":3,"file":"index.js","mappings":"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rCH;;;;;;;;;;;ACAA,0C;;;;;;;;;;ACAA,6C;;;;;;;;;;ACAA,wC;;;;;;;;;;ACAA,4C;;;;;;;;;;ACAA,yC;;;;;;;;;;ACAA,sC;;;;;;;;;;ACAA,2C;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;UAEA;UACA;;;;;WCzBA;WACA;WACA;WACA;WACA,+BAA+B,wCAAwC;WACvE;WACA;WACA;WACA;WACA,iBAAiB,qBAAqB;WACtC;WACA;WACA,kBAAkB,qBAAqB;WACvC;WACA;WACA,KAAK;WACL;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,E;;;;;WC3BA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA,E;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA,E;;;;;WCPA,wF;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D,E;;;;;WCNA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA,4G;;;;;UEjDA;UACA;UACA;UACA;UACA","sources":["webpack://gh-form-shortcode/./src/edit.js","webpack://gh-form-shortcode/./src/editor.scss","webpack://gh-form-shortcode/./src/index.js","webpack://gh-form-shortcode/./src/style.scss","webpack://gh-form-shortcode/external window [\"wp\",\"apiFetch\"]","webpack://gh-form-shortcode/external window [\"wp\",\"blockEditor\"]","webpack://gh-form-shortcode/external window [\"wp\",\"blocks\"]","webpack://gh-form-shortcode/external window [\"wp\",\"components\"]","webpack://gh-form-shortcode/external window [\"wp\",\"element\"]","webpack://gh-form-shortcode/external window [\"wp\",\"i18n\"]","webpack://gh-form-shortcode/external window \"ReactJSXRuntime\"","webpack://gh-form-shortcode/webpack/bootstrap","webpack://gh-form-shortcode/webpack/runtime/chunk loaded","webpack://gh-form-shortcode/webpack/runtime/compat get default export","webpack://gh-form-shortcode/webpack/runtime/define property getters","webpack://gh-form-shortcode/webpack/runtime/hasOwnProperty shorthand","webpack://gh-form-shortcode/webpack/runtime/make namespace object","webpack://gh-form-shortcode/webpack/runtime/jsonp chunk loading","webpack://gh-form-shortcode/webpack/before-startup","webpack://gh-form-shortcode/webpack/startup","webpack://gh-form-shortcode/webpack/after-startup"],"sourcesContent":["/**\n * Retrieves the translation of text.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-i18n/\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * React hook that is used to mark the block wrapper element.\n * It provides all the necessary props like the class name.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#useblockprops\n */\nimport { useBlockProps, InspectorControls } from '@wordpress/block-editor';\n\n/**\n * WordPress dependencies\n */\nimport { PanelBody, Spinner, SelectControl } from '@wordpress/components';\nimport { useEffect, useState } from '@wordpress/element';\nimport apiFetch from '@wordpress/api-fetch';\nimport { ColorPalette } from '@wordpress/block-editor';\n\n/**\n * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.\n * Those files can contain any CSS code that gets applied to the editor.\n *\n * @see https://www.npmjs.com/package/@wordpress/scripts#using-css\n */\nimport './editor.scss';\n\n/**\n * The edit function describes the structure of your block in the context of the\n * editor. This represents what the editor will render when the block is used.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit\n *\n * @param {Object} props Block properties.\n * @param {Object} props.attributes Block attributes.\n * @param {Function} props.setAttributes Function to update block attributes.\n *\n * @return {Element} Element to render.\n */\nexport default function Edit( { attributes, setAttributes } ) {\n\tconst { formId, theme, accentColor } = attributes;\n\tconst [ preview, setPreview ] = useState( '' );\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ forms, setForms ] = useState( [] );\n\tconst [ isLoadingForms, setIsLoadingForms ] = useState( true );\n\n\tconst blockProps = useBlockProps();\n\n\t// Fetch available forms\n\tuseEffect( () => {\n\t\tsetIsLoadingForms( true );\n\n\t\twindow.Groundhogg.stores.forms.fetchItems().then( items => {\n\t\t\tconst formOptions = items.map( form => ( {\n\t\t\t\tlabel: `${form.name} (#${form.ID})`,\n\t\t\t\tvalue: String( form.ID ),\n\t\t\t} ) );\n\t\t\tsetForms( [\n\t\t\t\t{ label: __( 'Select a form', 'gh-form-shortcode' ), value: '' },\n\t\t\t\t...formOptions,\n\t\t\t] );\n\t\t\tsetIsLoadingForms( false );\n\t\t}).catch( () => {\n\t\t\tsetForms( [\n\t\t\t\t{ label: __( 'No forms found', 'gh-form-shortcode' ), value: '' },\n\t\t\t] );\n\t\t\tsetIsLoadingForms( false );\n\t\t} );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! formId ) {\n\t\t\tsetPreview( '' );\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsLoading( true );\n\n\t\t// Fetch the rendered shortcode preview\n\t\tapiFetch( {\n\t\t\tpath: '/wp/v2/block-renderer/groundhogg/forms',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tattributes: {\n\t\t\t\t\tformId,\n\t\t\t\t\ttheme,\n\t\t\t\t\taccentColor,\n\t\t\t\t},\n\t\t\t\tcontext: 'edit'\n\t\t\t},\n\t\t} )\n\t\t\t.then( ( response ) => {\n\t\t\t\tsetPreview( response.rendered );\n\t\t\t\tsetIsLoading( false );\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tsetPreview( '' );\n\t\t\t\tsetIsLoading( false );\n\t\t\t} );\n\t}, [ formId, theme, accentColor ] );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ __( 'Form Settings', 'gh-form-shortcode' ) }\n\t\t\t\t\tinitialOpen={ true }\n\t\t\t\t>\n\t\t\t\t\t{ isLoadingForms ? (\n\t\t\t\t\t\t<div style={{ padding: '12px', textAlign: 'center' }}>\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t<p style={{ marginTop: '8px', fontSize: '13px', color: '#757575' }}>\n\t\t\t\t\t\t\t\t{ __( 'Loading forms...', 'groundhogg' ) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t <SelectControl\n\t\t\t\t\t\t\t label={ __( 'Form', 'groundhogg' ) }\n\t\t\t\t\t\t\t value={ formId }\n\t\t\t\t\t\t\t options={ forms }\n\t\t\t\t\t\t\t onChange={ ( value ) => {\n\n\t\t\t\t\t\t\t\t\tconst form = window.Groundhogg.stores.forms.get( parseInt( formId ) )\n\n\t\t\t\t\t\t\t\t setAttributes( {\n\t\t\t\t\t\t\t\t\t formId: value,\n\t\t\t\t\t\t\t\t\t accentColor: form.settings.accentColor,\n\t\t\t\t\t\t\t\t\t theme: form.settings.theme\n\t\t\t\t\t\t\t\t } )\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t help={ __(\n\t\t\t\t\t\t\t\t 'Select the form to embed',\n\t\t\t\t\t\t\t\t 'groundhogg'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t />\n\t\t\t\t\t ) }\n\t\t\t\t</PanelBody>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ __( 'Appearance', 'groundhogg' ) }\n\t\t\t\t\tinitialOpen={ true }\n\t\t\t\t>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\tlabel={ __( 'Theme', 'groundhogg' ) }\n\t\t\t\t\t\tvalue={ theme }\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Default', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'default',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Simple', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'simple',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Modern', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'modern',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Classic', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'classic',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { theme: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Select the visual theme for the form',\n\t\t\t\t\t\t\t'groundhogg'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<p style={{ marginTop: '16px', marginBottom: '8px' }}>\n\t\t\t\t\t\t{ __( 'Accent Color', 'groundhogg' ) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\tvalue={ accentColor }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { accentColor: value || '#0073aa' } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ ! formId ? (\n\t\t\t\t\t<div className=\"gh-form-shortcode-placeholder\">\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ sprintf( __(\n\t\t\t\t\t\t\t\t'Embed a %s Form',\n\t\t\t\t\t\t\t\t'groundhogg'\n\t\t\t\t\t\t\t), window.Groundhogg.whiteLabelName ) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Select a form in the block settings to get started.',\n\t\t\t\t\t\t\t\t'groundhogg'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<div className=\"gh-form-shortcode-preview\">\n\t\t\t\t\t\t{ isLoading ? (\n\t\t\t\t\t\t\t<div className=\"gh-form-shortcode-loading\">\n\t\t\t\t\t\t\t\t{ __( 'Loading form preview...', 'groundhogg' ) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t\t\t__html: preview,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n","// extracted by mini-css-extract-plugin\nexport {};","/**\n * Registers a new block provided a unique name and an object defining its behavior.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/\n */\nimport { registerBlockType } from '@wordpress/blocks';\nimport { createElement } from '@wordpress/element';\n\n/**\n * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.\n * All files containing `style` keyword are bundled together. The code used\n * gets applied both to the front of your site and to the editor.\n *\n * @see https://www.npmjs.com/package/@wordpress/scripts#using-css\n */\nimport './style.scss';\n\n/**\n * Internal dependencies\n */\nimport Edit from './edit';\nimport metadata from './block.json';\n\nlet icon = window.MakeEl.htmlToReact( window.Groundhogg.element.icons.groundhogg )\n\n/**\n * Every block starts by registering a new block type definition.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/\n */\nregisterBlockType( metadata.name, {\n\t/**\n\t * @see ./edit.js\n\t */\n\tedit: Edit,\n\ttitle: `${window.Groundhogg.whiteLabelName} Form`,\n\ticon\n} );\n","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"wp\"][\"apiFetch\"];","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"blocks\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"ReactJSXRuntime\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t\"index\": 0,\n\t\"./style-index\": 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunkgh_form_shortcode\"] = globalThis[\"webpackChunkgh_form_shortcode\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [\"./style-index\"], () => (__webpack_require__(\"./src/index.js\")))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n",""],"names":["__","sprintf","useBlockProps","InspectorControls","PanelBody","Spinner","SelectControl","useEffect","useState","apiFetch","ColorPalette","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","Edit","attributes","setAttributes","formId","theme","accentColor","preview","setPreview","isLoading","setIsLoading","forms","setForms","isLoadingForms","setIsLoadingForms","blockProps","window","Groundhogg","stores","fetchItems","then","items","formOptions","map","form","label","name","ID","value","String","catch","path","method","data","context","response","rendered","children","title","initialOpen","style","padding","textAlign","marginTop","fontSize","color","options","onChange","get","parseInt","settings","help","marginBottom","className","whiteLabelName","dangerouslySetInnerHTML","__html","registerBlockType","createElement","metadata","icon","MakeEl","htmlToReact","element","icons","groundhogg","edit"],"sourceRoot":""}1 {"version":3,"file":"index.js","mappings":"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K,CAACC,UAAW,CAAC;;AAElF;AACA;AACA;AACA;AACA;AACAR,oEAAiB,CAAEE,6CAAa,EAAE;EACjC;AACD;AACA;EACCO,IAAI,EAAEjE,6CAAI;EACVqC,KAAK,EAAE,GAAGtB,MAAM,CAACC,UAAU,CAACqC,cAAc,OAAO;EACjDM;AACD,CAAE,CAAC,C;;;;;;;;;;;ACrCH;;;;;;;;;;;ACAA,0C;;;;;;;;;;ACAA,6C;;;;;;;;;;ACAA,wC;;;;;;;;;;ACAA,4C;;;;;;;;;;ACAA,yC;;;;;;;;;;ACAA,sC;;;;;;;;;;ACAA,2C;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;UAEA;UACA;;;;;WCzBA;WACA;WACA;WACA;WACA,+BAA+B,wCAAwC;WACvE;WACA;WACA;WACA;WACA,iBAAiB,qBAAqB;WACtC;WACA;WACA,kBAAkB,qBAAqB;WACvC;WACA;WACA,KAAK;WACL;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,E;;;;;WC3BA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA,E;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA,E;;;;;WCPA,wF;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D,E;;;;;WCNA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA,4G;;;;;UEjDA;UACA;UACA;UACA;UACA","sources":["webpack://gh-form-shortcode/./src/edit.js","webpack://gh-form-shortcode/./src/editor.scss","webpack://gh-form-shortcode/./src/index.js","webpack://gh-form-shortcode/./src/style.scss","webpack://gh-form-shortcode/external window [\"wp\",\"apiFetch\"]","webpack://gh-form-shortcode/external window [\"wp\",\"blockEditor\"]","webpack://gh-form-shortcode/external window [\"wp\",\"blocks\"]","webpack://gh-form-shortcode/external window [\"wp\",\"components\"]","webpack://gh-form-shortcode/external window [\"wp\",\"element\"]","webpack://gh-form-shortcode/external window [\"wp\",\"i18n\"]","webpack://gh-form-shortcode/external window \"ReactJSXRuntime\"","webpack://gh-form-shortcode/webpack/bootstrap","webpack://gh-form-shortcode/webpack/runtime/chunk loaded","webpack://gh-form-shortcode/webpack/runtime/compat get default export","webpack://gh-form-shortcode/webpack/runtime/define property getters","webpack://gh-form-shortcode/webpack/runtime/hasOwnProperty shorthand","webpack://gh-form-shortcode/webpack/runtime/make namespace object","webpack://gh-form-shortcode/webpack/runtime/jsonp chunk loading","webpack://gh-form-shortcode/webpack/before-startup","webpack://gh-form-shortcode/webpack/startup","webpack://gh-form-shortcode/webpack/after-startup"],"sourcesContent":["/**\n * Retrieves the translation of text.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-i18n/\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * React hook that is used to mark the block wrapper element.\n * It provides all the necessary props like the class name.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#useblockprops\n */\nimport { useBlockProps, InspectorControls } from '@wordpress/block-editor';\n\n/**\n * WordPress dependencies\n */\nimport { PanelBody, Spinner, SelectControl } from '@wordpress/components';\nimport { useEffect, useState } from '@wordpress/element';\nimport apiFetch from '@wordpress/api-fetch';\nimport { ColorPalette } from '@wordpress/block-editor';\n\n/**\n * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.\n * Those files can contain any CSS code that gets applied to the editor.\n *\n * @see https://www.npmjs.com/package/@wordpress/scripts#using-css\n */\nimport './editor.scss';\n\n/**\n * The edit function describes the structure of your block in the context of the\n * editor. This represents what the editor will render when the block is used.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit\n *\n * @param {Object} props Block properties.\n * @param {Object} props.attributes Block attributes.\n * @param {Function} props.setAttributes Function to update block attributes.\n *\n * @return {Element} Element to render.\n */\nexport default function Edit( { attributes, setAttributes } ) {\n\tconst { formId, theme, accentColor } = attributes;\n\tconst [ preview, setPreview ] = useState( '' );\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ forms, setForms ] = useState( [] );\n\tconst [ isLoadingForms, setIsLoadingForms ] = useState( true );\n\n\tconst blockProps = useBlockProps();\n\n\t// Fetch available forms\n\tuseEffect( () => {\n\t\tsetIsLoadingForms( true );\n\n\t\twindow.Groundhogg.stores.forms.fetchItems().then( items => {\n\t\t\tconst formOptions = items.map( form => ( {\n\t\t\t\tlabel: `${form.name} (#${form.ID})`,\n\t\t\t\tvalue: String( form.ID ),\n\t\t\t} ) );\n\t\t\tsetForms( [\n\t\t\t\t{ label: __( 'Select a form', 'gh-form-shortcode' ), value: '' },\n\t\t\t\t...formOptions,\n\t\t\t] );\n\t\t\tsetIsLoadingForms( false );\n\t\t}).catch( () => {\n\t\t\tsetForms( [\n\t\t\t\t{ label: __( 'No forms found', 'gh-form-shortcode' ), value: '' },\n\t\t\t] );\n\t\t\tsetIsLoadingForms( false );\n\t\t} );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! formId ) {\n\t\t\tsetPreview( '' );\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsLoading( true );\n\n\t\t// Fetch the rendered shortcode preview\n\t\tapiFetch( {\n\t\t\tpath: '/wp/v2/block-renderer/groundhogg/forms',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tattributes: {\n\t\t\t\t\tformId,\n\t\t\t\t\ttheme,\n\t\t\t\t\taccentColor,\n\t\t\t\t},\n\t\t\t\tcontext: 'edit'\n\t\t\t},\n\t\t} )\n\t\t\t.then( ( response ) => {\n\t\t\t\tsetPreview( response.rendered );\n\t\t\t\tsetIsLoading( false );\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tsetPreview( '' );\n\t\t\t\tsetIsLoading( false );\n\t\t\t} );\n\t}, [ formId, theme, accentColor ] );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ __( 'Form Settings', 'gh-form-shortcode' ) }\n\t\t\t\t\tinitialOpen={ true }\n\t\t\t\t>\n\t\t\t\t\t{ isLoadingForms ? (\n\t\t\t\t\t\t<div style={{ padding: '12px', textAlign: 'center' }}>\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t<p style={{ marginTop: '8px', fontSize: '13px', color: '#757575' }}>\n\t\t\t\t\t\t\t\t{ __( 'Loading forms...', 'groundhogg' ) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t <SelectControl\n\t\t\t\t\t\t\t label={ __( 'Form', 'groundhogg' ) }\n\t\t\t\t\t\t\t value={ formId }\n\t\t\t\t\t\t\t options={ forms }\n\t\t\t\t\t\t\t onChange={ ( value ) => {\n\t\t\t\t\t\t\t\t const form = window.Groundhogg.stores.forms.get( parseInt( value ) )\n\t\t\t\t\t\t\t\t setAttributes( {\n\t\t\t\t\t\t\t\t\t formId: value,\n\t\t\t\t\t\t\t\t\t accentColor: form.settings.accentColor,\n\t\t\t\t\t\t\t\t\t theme: form.settings.theme\n\t\t\t\t\t\t\t\t } )\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t help={ __(\n\t\t\t\t\t\t\t\t 'Select the form to embed',\n\t\t\t\t\t\t\t\t 'groundhogg'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t />\n\t\t\t\t\t ) }\n\t\t\t\t</PanelBody>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ __( 'Appearance', 'groundhogg' ) }\n\t\t\t\t\tinitialOpen={ true }\n\t\t\t\t>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\tlabel={ __( 'Theme', 'groundhogg' ) }\n\t\t\t\t\t\tvalue={ theme }\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Default', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'default',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Simple', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'simple',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Modern', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'modern',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Classic', 'groundhogg' ),\n\t\t\t\t\t\t\t\tvalue: 'classic',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { theme: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Select the visual theme for the form',\n\t\t\t\t\t\t\t'groundhogg'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<p style={{ marginTop: '16px', marginBottom: '8px' }}>\n\t\t\t\t\t\t{ __( 'Accent Color', 'groundhogg' ) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\tvalue={ accentColor }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { accentColor: value || '#0073aa' } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ ! formId ? (\n\t\t\t\t\t<div className=\"gh-form-shortcode-placeholder\">\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ sprintf( __(\n\t\t\t\t\t\t\t\t'Embed a %s Form',\n\t\t\t\t\t\t\t\t'groundhogg'\n\t\t\t\t\t\t\t), window.Groundhogg.whiteLabelName ) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Select a form in the block settings to get started.',\n\t\t\t\t\t\t\t\t'groundhogg'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<div className=\"gh-form-shortcode-preview\">\n\t\t\t\t\t\t{ isLoading ? (\n\t\t\t\t\t\t\t<div className=\"gh-form-shortcode-loading\">\n\t\t\t\t\t\t\t\t{ __( 'Loading form preview...', 'groundhogg' ) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t\t\t__html: preview,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n","// extracted by mini-css-extract-plugin\nexport {};","/**\n * Registers a new block provided a unique name and an object defining its behavior.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/\n */\nimport { registerBlockType } from '@wordpress/blocks';\nimport { createElement } from '@wordpress/element';\n\n/**\n * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.\n * All files containing `style` keyword are bundled together. The code used\n * gets applied both to the front of your site and to the editor.\n *\n * @see https://www.npmjs.com/package/@wordpress/scripts#using-css\n */\nimport './style.scss';\n\n/**\n * Internal dependencies\n */\nimport Edit from './edit';\nimport metadata from './block.json';\n\nlet icon = window.MakeEl.htmlToReact( window.Groundhogg.element.icons.groundhogg )\n\n/**\n * Every block starts by registering a new block type definition.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/\n */\nregisterBlockType( metadata.name, {\n\t/**\n\t * @see ./edit.js\n\t */\n\tedit: Edit,\n\ttitle: `${window.Groundhogg.whiteLabelName} Form`,\n\ticon\n} );\n","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"wp\"][\"apiFetch\"];","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"blocks\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"ReactJSXRuntime\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t\"index\": 0,\n\t\"./style-index\": 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunkgh_form_shortcode\"] = globalThis[\"webpackChunkgh_form_shortcode\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [\"./style-index\"], () => (__webpack_require__(\"./src/index.js\")))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n",""],"names":["__","sprintf","useBlockProps","InspectorControls","PanelBody","Spinner","SelectControl","useEffect","useState","apiFetch","ColorPalette","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","Edit","attributes","setAttributes","formId","theme","accentColor","preview","setPreview","isLoading","setIsLoading","forms","setForms","isLoadingForms","setIsLoadingForms","blockProps","window","Groundhogg","stores","fetchItems","then","items","formOptions","map","form","label","name","ID","value","String","catch","path","method","data","context","response","rendered","children","title","initialOpen","style","padding","textAlign","marginTop","fontSize","color","options","onChange","get","parseInt","settings","help","marginBottom","className","whiteLabelName","dangerouslySetInnerHTML","__html","registerBlockType","createElement","metadata","icon","MakeEl","htmlToReact","element","icons","groundhogg","edit"],"sourceRoot":""} -
groundhogg/trunk/db/tag-relationships.php
r3343709 r3422142 6 6 use Groundhogg\DB\Traits\Insert_Ignore; 7 7 use function Groundhogg\get_db; 8 use function Groundhogg\Ymd_His; 8 9 9 10 if ( ! defined( 'ABSPATH' ) ) { … … 82 83 'tag_id' => '%d', 83 84 'contact_id' => '%d', 85 'date_created' => '%s', 84 86 ]; 85 87 } … … 95 97 'tag_id' => 0, 96 98 'contact_id' => 0, 99 'date_created' => Ymd_His(), 97 100 ); 98 101 } … … 261 264 tag_id bigint(20) unsigned NOT NULL, 262 265 contact_id bigint(20) unsigned NOT NULL, 266 date_created datetime NOT NULL, 263 267 PRIMARY KEY (tag_id,contact_id), 264 268 KEY tag_id (tag_id), -
groundhogg/trunk/groundhogg.php
r3400645 r3422142 4 4 * Plugin URI: https://www.groundhogg.io/?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash 5 5 * Description: CRM and marketing automation for WordPress 6 * Version: 4.2. 96 * Version: 4.2.10 7 7 * Author: Groundhogg Inc. 8 8 * Author URI: https://www.groundhogg.io/?utm_source=wp-plugins&utm_campaign=author-uri&utm_medium=wp-dash … … 25 25 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly 26 26 27 define( 'GROUNDHOGG_VERSION', '4.2. 9' );28 define( 'GROUNDHOGG_PREVIOUS_STABLE_VERSION', '4.2. 8' );27 define( 'GROUNDHOGG_VERSION', '4.2.10' ); 28 define( 'GROUNDHOGG_PREVIOUS_STABLE_VERSION', '4.2.9' ); 29 29 30 30 define( 'GROUNDHOGG__FILE__', __FILE__ ); -
groundhogg/trunk/includes/better-meta-compat.php
r3386122 r3422142 420 420 $tab = Properties::instance()->get_group_tab( $group['id'] ); 421 421 422 if ( ! $tab ) {422 if ( ! $tab || ! isset( $tab['name'] ) || ! isset( $group['name'] ) ) { 423 423 continue; 424 424 } -
groundhogg/trunk/includes/classes/contact.php
r3320187 r3422142 8 8 use Groundhogg\DB\DB; 9 9 use Groundhogg\DB\Meta_DB; 10 use Groundhogg\DB\Query\Table_Query; 10 11 use Groundhogg\DB\Tag_Relationships; 11 12 use Groundhogg\DB\Tags; … … 50 51 */ 51 52 protected $owner; 53 /** 54 * @var object[] 55 */ 56 protected array $tag_relationships = []; 52 57 53 58 /** … … 233 238 */ 234 239 protected function post_setup() { 235 $this->tags = wp_parse_id_list( $this->get_tag_rel_db()->get_relationships( $this->ID ) ); 236 $this->user = get_userdata( $this->get_user_id() ); 237 $this->owner = get_userdata( $this->get_owner_id() ); 240 241 $query = new Table_Query( db()->tag_relationships ); 242 $query->setSelect( 'tag_id', 'date_created' ); 243 $query->where( 'contact_id', $this->ID ); 244 245 $relationships = $query->get_results(); 246 247 $this->tags = wp_parse_id_list( wp_list_pluck( $relationships, 'tag_id' ) ); 248 $this->tag_relationships = array_reduce( $relationships, function ( $carry, $item ) { 249 250 if ( $item->date_created === null || $item->date_created === DateTimeHelper::ZERODATETIME ) { 251 return $carry; 252 } 253 254 $carry[ absint( $item->tag_id ) ] = $item->date_created; 255 256 return $carry; 257 }, [] ); 258 259 $this->user = get_userdata( $this->get_user_id() ); 260 $this->owner = get_userdata( $this->get_owner_id() ); 238 261 239 262 $this->ID = absint( $this->ID ); … … 843 866 foreach ( $apply as $tag_id ) { 844 867 845 $this->tags[] = $tag_id; 868 $this->tags[] = $tag_id; 869 $this->tag_relationships[ $tag_id ] = Ymd_His(); 846 870 847 871 $this->get_tag_rel_db()->batch_insert( [ … … 913 937 914 938 foreach ( $remove as $tag_id ) { 939 940 unset( $this->tag_relationships[ $tag_id ] ); 941 915 942 /** 916 943 * When a tag relationship is removed … … 1216 1243 'is_deliverable' => $this->is_deliverable(), 1217 1244 'i18n' => [ 1218 'created' => human_time_diff( time(), $this->get_date_created( true )->getTimestamp() ) 1245 'created' => human_time_diff( time(), $this->get_date_created( true )->getTimestamp() ), 1246 'tagDates' => array_map( fn($date) => (new DateTimeHelper($date))->wpDateTimeFormat(), $this->tag_relationships ) 1219 1247 ] 1220 1248 ] -
groundhogg/trunk/includes/classes/event.php
r3343709 r3422142 208 208 209 209 /** 210 * @return Contact 211 */ 212 public function get_contact() { 213 214 if ( ! $this->contact ){ 215 $this->contact = new Contact( $this->get_contact_id() ); 216 } 217 218 return $this->contact; 219 } 220 221 /** 210 222 * @return String 211 223 */ 212 224 public function get_failure_reason() { 213 225 return $this->get_error_code() . ': ' . $this->get_error_message(); 214 }215 216 /**217 * @return Contact218 */219 public function get_contact() {220 return $this->contact;221 226 } 222 227 … … 339 344 $this->args = []; // default to using an array if empty 340 345 } 341 $this->contact = new Contact( $this->get_contact_id() );342 346 343 347 self::maybe_register_step_setup_callbacks(); -
groundhogg/trunk/includes/classes/step.php
r3386122 r3422142 2282 2282 'meta' => $this->meta, 2283 2283 'export' => $this->export(), 2284 'is_starting' => $this->is_starting(), 2285 2284 2286 ] ); 2285 2287 } -
groundhogg/trunk/includes/functions.php
r3394550 r3422142 3691 3691 } 3692 3692 3693 // for some reason when body is false or null it breaks, just make it am empty array instead 3694 if ( is_null( $body ) || $body === false ){ 3695 $body = []; 3696 } 3697 3693 3698 switch ( $method ) { 3694 3699 case 'POST': -
groundhogg/trunk/includes/main-updater.php
r3386122 r3422142 254 254 maybe_install_safe_mode_plugin(); 255 255 } 256 ], 257 '4.2.10' => [ 258 'automatic' => true, 259 'description' => __( 'Update the tag relationships table.', 'groundhogg' ), 260 'callback' => function () { 261 db()->tag_relationships->create_table(); // add the date_created column 262 } 256 263 ] 257 264 ]; -
groundhogg/trunk/includes/steps/premium/actions/advanced-timer.php
r3343709 r3422142 33 33 */ 34 34 public function get_description() { 35 return _x( 'Use a <code>strtotime</code>friendly string to create a delay.', 'step_description', 'groundhogg' );35 return _x( 'Use a `strtotime()` friendly string to create a delay.', 'step_description', 'groundhogg' ); 36 36 } 37 37 -
groundhogg/trunk/includes/utils/date-time-helper.php
r3352676 r3422142 8 8 9 9 class DateTimeHelper extends \DateTime { 10 11 const ZERODATE = "0000-00-00"; 12 const ZEROTIME = "00:00:00"; 13 const ZERODATETIME = "0000-00-00 00:00:00"; 10 14 11 15 public function __construct( $datetime = 'now', \DateTimeZone $timezone = null ) { -
groundhogg/trunk/templates/archive/campaign.php
r3343709 r3422142 111 111 ->contains( "$join->alias.plain_text", $search ); 112 112 } 113 114 /** 115 * Allow modifying the broadcast query, perhaps to restrict what can appear in the archive. 116 * 117 * @param $query Table_Query 118 */ 119 do_action_ref_array( 'groundhogg/archive/broadcast_query', [ &$broadcastQuery ] ); 113 120 114 121 $items = $broadcastQuery->get_objects(); -
groundhogg/trunk/templates/archive/campaigns.php
r3343709 r3422142 69 69 } 70 70 71 /** 72 * Allow modifying the campaigns query, perhaps to restrict what can appear in the archive. 73 * 74 * @param $query Table_Query 75 */ 76 do_action_ref_array( 'groundhogg/archive/campaigns_query', [ &$campaignsQuery ] ); 77 71 78 $items = $campaignsQuery->get_objects(); 72 79 $total_items = $campaignsQuery->get_found_rows(); -
groundhogg/trunk/templates/archive/events.php
r3343709 r3422142 3 3 namespace Groundhogg; 4 4 5 use Groundhogg\Cli\Table; 5 6 use Groundhogg\DB\Query\Table_Query; 6 7 use Groundhogg\Utils\DateTimeHelper; … … 105 106 } 106 107 108 /** 109 * Allow modifying the events query, perhaps to restrict what can appear in the archive. 110 * 111 * @param $query Table_Query 112 */ 113 do_action_ref_array( 'groundhogg/archive/events_query', [ &$eventsQuery ] ); 114 107 115 $events = $eventsQuery->get_results(); 108 116
Note: See TracChangeset
for help on using the changeset viewer.