Commit 634bccdf authored by Antonio's avatar Antonio 🇪🇺

no jQuery

parent e5ef435b
This diff is collapsed.
require('./tinymce/helper');
import './tinymce/helper';
import faq from './tinymce/faq';
import job from './tinymce/job';
import multiFaq from './tinymce/multiFaq';
......@@ -27,5 +26,5 @@ import course from './tinymce/course';
});
});
}
})();
......@@ -248,6 +248,7 @@ export default function (editor) {
document.querySelector('.mce-sc_end_date').type = 'datetime-local';
document.querySelector('.mce-sc_valid_from').type = 'datetime-local';
}
bindImageButtons();
},
}
};
export default function ( editor ) {
export default function (editor) {
return {
text : 'Single FAQ',
tooltip: 'Adds a FAQ block to the page.',
onclick: () => {
editor.windowManager.open( {
editor.windowManager.open({
title : 'Featured Snippet FAQ',
minWidth : 500,
height : 500,
......@@ -21,12 +21,12 @@ export default function ( editor ) {
name : 'sc_headline',
label : 'Headline-Tag',
values: [
{ text: 'h2', value: 'h2' },
{ text: 'h3', value: 'h3' },
{ text: 'h4', value: 'h4' },
{ text: 'h5', value: 'h5' },
{ text: 'h6', value: 'h6' },
{ text: 'p', value: 'p' },
{text: 'h2', value: 'h2'},
{text: 'h3', value: 'h3'},
{text: 'h4', value: 'h4'},
{text: 'h5', value: 'h5'},
{text: 'h6', value: 'h6'},
{text: 'p', value: 'p'},
],
value : 'h2', // Sets the default
},
......@@ -78,18 +78,18 @@ export default function ( editor ) {
onsubmit : e => {
editor.insertContent(
`[sc_fs_faq
sc_id="${ 'fs_faq' + Math.random().toString( 36 ).substr( 2, 9 ) }"
html="${ e.data.giveHTML }"
headline="${ e.data.sc_headline }"
img="${ e.data.sc_img }"
question="${ e.data.sc_question }"
img_alt="${ e.data.sc_img_description }"
css_class="${ e.data.sc_css_classes }"
]${ e.data.sc_answer }[/sc_fs_faq]`
sc_id="${'fs_faq' + Math.random().toString(36).substr(2, 9)}"
html="${e.data.giveHTML}"
headline="${e.data.sc_headline}"
img="${e.data.sc_img}"
question="${e.data.sc_question}"
img_alt="${e.data.sc_img_description}"
css_class="${e.data.sc_css_classes}"
]${e.data.sc_answer}[/sc_fs_faq]`
);
}
,
} );
});
bindImageButtons();
},
}
};
jQuery(document).ready(function () {
jQuery(document).on('click', '.mce-select_image', upload_image_tinymce);
function upload_image_tinymce(e) {
e.preventDefault();
let idTarget;
let val = true;
if (typeof e.target.dataset.target === 'undefined') {
idTarget = jQuery('.mce-image');
} else {
idTarget = jQuery(`#${e.target.dataset.target}`);
val = !val;
}
const customUploader = (
wp.media.frames.file_frame = wp.media(
{
title : 'Add Image',
button : {
text: 'Add Image',
},
multiple: false,
}
)
);
customUploader.on('select', () => {
const attachment = customUploader
.state()
.get('selection')
.first()
.toJSON();
window.bindImageButtons = function () {
const imageButtons = document.querySelectorAll('.mce-select_image');
for (let i = 0; i < imageButtons.length; i++) {
imageButtons[i].addEventListener('click', wpsc_upload_image);
}
}
val ? idTarget.val(attachment.id) : idTarget.html(attachment.id);
});
customUploader.open();
window.wpsc_upload_image = function (e) {
e.preventDefault();
let idTarget;
let val = true;
if (typeof e.target.dataset.target === 'undefined') {
idTarget = document.querySelector('.mce-image');
} else {
idTarget = document.getElementById(`${e.target.dataset.target}`);
val = !val;
}
});
console.log(idTarget);
const customUploader = (
wp.media.frames.file_frame = wp.media(
{
title : 'Add Image',
button : {
text: 'Add Image',
},
multiple: false,
}
)
);
customUploader.on('select', () => {
const attachment = customUploader
.state()
.get('selection')
.first()
.toJSON();
val ? idTarget.value = attachment.id : idTarget.innerHTML = attachment.id;
});
customUploader.open();
}
window.datetimeLocalSupported = function () {
let input = document.createElement('input');
......
......@@ -223,7 +223,7 @@ export default function (editor) {
if (dateSupported()) {
document.querySelector('.mce-sc_valid_through').type = 'date';
}
bindImageButtons();
},
}
};
......@@ -111,7 +111,9 @@ export default function (editor) {
`;
setHeight(layoutWrapper, layoutWrapper.offsetHeight + height);
insertAfter(createElementFromHTML(template), nextField);
bindImageButtons();
});
bindImageButtons();
},
}
};
......@@ -121,13 +123,13 @@ window.createShortcode = function (e) {
let shortcode = `[sc_fs_multi_faq `,
fieldsets = document.querySelectorAll('#sc-start-point fieldset');
for (const fieldset of fieldsets) {
for (let i = 0; i < fieldsets.length; i++) {
const key = fieldset.dataset.key,
const key = fieldsets[i].dataset.key,
headlineTag = document.getElementById('headlineTag-' + key).value,
question = document.getElementById('question-' + key).value,
answer = document.getElementById('answer-' + key).value,
imageID = document.getElementById('imageID-' + key).value;
imageID = document.getElementById('imageID-' + key).innerHTML;
shortcode += `headline-${key}="${headlineTag}" question-${key}="${question}" answer-${key}="${answer}" image-${key}="${imageID}" `;
}
......
......@@ -167,6 +167,7 @@ export default function ( editor ) {
);
},
} );
bindImageButtons();
},
}
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment