Commit 8f70a5a1 authored by Antonio's avatar Antonio 🇪🇺

Date Support and empty labels

parent 92b3e094
This diff is collapsed.
......@@ -64,8 +64,15 @@ jQuery(document).ready(function () {
customUploader.open();
}
});
window.datetimeLocalSupported = function () {
let input = document.createElement('input');
input.setAttribute('type', 'datetime-local');
return input.type === 'datetime-local';
};
window.dateSupported = function () {
let input = document.createElement('input');
input.setAttribute('type', 'date');
return input.type === 'date';
};
export default function ( editor ) {
let postfixDateLabel;
let minWidth = 500;
if ( !datetimeLocalSupported() ) {
postfixDateLabel = '(Format: 2019-08-22T10:25)';
minWidth = 800;
}
export default function (editor) {
return {
text : 'Course',
tooltip: 'Adds a Course block to the page.',
onclick: () => {
editor.windowManager.open( {
editor.windowManager.open({
title : 'Featured Snippet Course',
minWidth : minWidth,
minWidth : 500,
height : 500,
autoScroll: true,
classes : 'sc-panel',
......@@ -27,12 +21,12 @@ export default function ( editor ) {
name : 'titleTag',
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
},
......@@ -91,19 +85,19 @@ export default function ( editor ) {
onsubmit : e => {
editor.insertContent(
`[sc_fs_course
html="${ e.data.giveHTML }"
title="${ e.data.title }"
title_tag="${ e.data.titleTag }"
provider_name="${ e.data.providerName }"
provider_same_as="${ e.data.providerSameAs }"
css_class="${ e.data.cssClass }"
html="${e.data.giveHTML}"
title="${e.data.title}"
title_tag="${e.data.titleTag}"
provider_name="${e.data.providerName}"
provider_same_as="${e.data.providerSameAs}"
css_class="${e.data.cssClass}"
]
${ e.data.description }
${e.data.description}
[/sc_fs_course]`
);
}
,
} );
});
},
}
};
export default function (editor) {
let postfixDateLabel;
let minWidth = 500;
let postfixDateLabel = '',
minWidth = 500;
if (!datetimeLocalSupported()) {
postfixDateLabel = '(Format: 2019-08-22T10:25)';
minWidth = 800;
......@@ -244,9 +244,9 @@ export default function (editor) {
,
});
if (datetimeLocalSupported()) {
jQuery('.mce-sc_start_date').prop('type', 'datetime-local');
jQuery('.mce-sc_end_date').prop('type', 'datetime-local');
jQuery('.mce-sc_valid_from').prop('type', 'datetime-local');
document.querySelector('.mce-sc_start_date').type = 'datetime-local';
document.querySelector('.mce-sc_end_date').type = 'datetime-local';
document.querySelector('.mce-sc_valid_from').type = 'datetime-local';
}
},
}
......
export default function (editor) {
let postfixDateLabel = '',
minWidth = 500;
if (!dateSupported()) {
postfixDateLabel = '(Format: 2019-08-22)';
minWidth = 800;
}
return {
text : 'Job',
tooltip: 'Adds a JobPosting block to the page.',
onclick: () => {
editor.windowManager.open({
title : 'Featured Snippet Job',
minWidth : 500,
minWidth : minWidth,
height : 500,
autoScroll: true,
classes : 'sc-panel',
......@@ -181,7 +186,7 @@ export default function (editor) {
{
type : 'textbox',
name : 'validThrough',
label : 'Valid Through',
label : `Valid Through ${postfixDateLabel}`,
classes: 'sc_valid_through',
},
{
......@@ -215,9 +220,10 @@ export default function (editor) {
);
},
});
if (datetimeLocalSupported()) {
jQuery('.mce-sc_valid_through').prop('type', 'date');
if (dateSupported()) {
document.querySelector('.mce-sc_valid_through').type = 'date';
}
},
}
};
......@@ -69,48 +69,46 @@ export default function (editor) {
editor.insertContent(createShortcode(e));
},
});
jQuery('<div id="sc-faq-start"></div>').insertAfter('.mce-sc_elements');
jQuery('#addOne').click(() => {
const id = jQuery('#fields fieldset').length;
let height = jQuery(`#fields #fieldset-${id - 1}`).outerHeight();
height = id === 1 ? height + 30 : height - 30;
document.getElementById('addOne').addEventListener('click', () => {
let id = document.querySelectorAll('#fields fieldset').length,
height = id === 1 ? document.querySelector(`#fields #fieldset-${id - 1}`).offsetHeight + 30 : document.querySelector(`#fields #fieldset-${id - 1}`).offsetHeight - 30;
const template = `
<fieldset id="fieldset-${id}" data-key="${id}">
<hr class="sc-hr">
<div>
<label>Headline-Tag</label>
<select name="headlineTag" id="headlineTag-${id}">
<option value="h2">h2</option>
<option value="h3">h3</option>
<option value="h4">h4</option>
<option value="h5">h5</option>
<option value="h6">h6</option>
<option value="p">p</option>
</select>
</div>
<div>
<label>Frage</label>
<input type="text" id="question-${id}" name="question">
</div>
<div>
<label>Antwort</label>
<textarea id="answer-${id}" rows="5" name="answer"></textarea>
</div>
<div>
<div type="text" id="imageID-${id}" name="imageID"></div>
<div class="mce-btn">
<button type="button" class="mce-select_image" data-target="imageID-${id}">Select Image</button>
<fieldset id="fieldset-${id}" data-key="${id}">
<hr class="sc-hr">
<div>
<label>Headline-Tag</label>
<select name="headlineTag" id="headlineTag-${id}">
<option value="h2">h2</option>
<option value="h3">h3</option>
<option value="h4">h4</option>
<option value="h5">h5</option>
<option value="h6">h6</option>
<option value="p">p</option>
</select>
</div>
</div>
<div class="mce-btn removeLast">
<button type="button" onclick="removeLast()" data-target="bild-${id}">- Remove Last One</button>
</div>
</fieldset>
<div>
<label>Frage</label>
<input type="text" id="question-${id}" name="question">
</div>
<div>
<label>Antwort</label>
<textarea id="answer-${id}" rows="5" name="answer"></textarea>
</div>
<div>
<div type="text" id="imageID-${id}" name="imageID"></div>
<div class="mce-btn">
<button type="button" class="mce-select_image" data-target="imageID-${id}">Select Image</button>
</div>
</div>
<div class="mce-btn removeLast">
<button type="button" onclick="removeLast()" data-target="bild-${id}">- Remove Last One</button>
</div>
</fieldset>
`;
jQuery('.mce-container > .mce-container-body.mce-abs-layout')
.height(jQuery('.mce-container > .mce-container-body.mce-abs-layout').outerHeight() + height);
jQuery(template).insertAfter(`#fields #fieldset-${id - 1}`);
})
});
},
}
};
......
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