Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for v1.8.1 #44

Merged
merged 9 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors:
given-names: Justin
- family-names: Tresova
given-names: Armand
version: 1.8.0
version: 1.8.1
doi: 10.5281/zenodo.1171250
date-released: 2017-05-08
url: "https://github.com/XjSv/cooked"
3 changes: 2 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Versions that are currently being supported with security updates.

| Version | Supported |
| ------- | ------------------ |
| 1.8.0 | :white_check_mark: |
| 1.8.1 | :white_check_mark: |
| 1.8.0 | :x: |
| <= 1.7.15.4 | :x: |

## Reporting a Vulnerability
Expand Down
48 changes: 25 additions & 23 deletions assets/admin/js/cooked-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,31 +424,31 @@ var $_CookedConditionalTimeout = false;

}

if ($_CookedDirectionBuilder.length){
if ($_CookedDirectionBuilder.length) {

cooked_reset_direction_builder();

$_CookedDirectionBuilder.parent().on('click','.cooked-add-direction-button',function(e){
$_CookedDirectionBuilder.parent().on('click', '.cooked-add-direction-button',function(e) {
e.preventDefault();
var clonedDirectionTemplate = $_CookedDirectionBuilder.parent().find('.cooked-direction-template').clone().removeClass('cooked-template cooked-direction-template').addClass('cooked-direction-block');
$_CookedDirectionBuilder.append(clonedDirectionTemplate);
cooked_reset_direction_builder();
});

$_CookedDirectionBuilder.parent().on('click','.cooked-add-heading-button',function(e){
$_CookedDirectionBuilder.parent().on('click','.cooked-add-heading-button',function(e) {
e.preventDefault();
var clonedHeadingTemplate = $_CookedDirectionBuilder.parent().find('.cooked-heading-template').clone().removeClass('cooked-template cooked-heading-template').addClass('cooked-direction-block cooked-direction-heading');
$_CookedDirectionBuilder.append(clonedHeadingTemplate);
cooked_reset_direction_builder();
});

$_CookedDirectionBuilder.parent().on('click','.cooked-delete-direction',function(e){
$_CookedDirectionBuilder.parent().on('click','.cooked-delete-direction',function(e) {
e.preventDefault();
$(this).parent().remove();
cooked_reset_direction_builder();
});

$_CookedDirectionBuilder.parent().on('click','.remove-image-button',function(e){
$_CookedDirectionBuilder.parent().on('click', '.remove-image-button',function(e) {
e.preventDefault();
$(this).parent().removeClass('cooked-has-image');
$(this).parent().find('img').remove();
Expand All @@ -459,14 +459,14 @@ var $_CookedConditionalTimeout = false;
// Instantiates the variable that holds the media library frame.
var direction_image_frame,directionID;

$('body').on('click','.cooked-direction-img-placeholder, .cooked-direction-img',function(e){
$('body').on('click','.cooked-direction-img-placeholder, .cooked-direction-img',function(e) {
e.preventDefault();
var thisButton = $(this).parent().find('.direction-image-button');
thisButton.trigger('click');
});

// Runs when the image button is clicked.
$('body').on('click','.direction-image-button',function(e){
$('body').on('click', '.direction-image-button',function(e) {

var thisButton = $(this);
directionID = thisButton.data('id');
Expand All @@ -487,22 +487,26 @@ var $_CookedConditionalTimeout = false;
});

// Runs when an image is selected.
direction_image_frame.on('select', function(){
direction_image_frame.on('select', function() {

// Grabs the attachment selection and creates a JSON representation of the model.
var media_attachment = direction_image_frame.state().get('selection').first().toJSON();

// Sends the attachment URL to our custom image input field.
$('#direction-'+directionID+'-image-src').attr('src',media_attachment.sizes.thumbnail.url).parent().addClass('cooked-has-image');
$('input[name="_recipe_settings[directions]['+directionID+'][image]"]').val( media_attachment.id );
$('.direction-image-button[data-id="'+directionID+'"]').prop( 'value',cooked_js_vars.i18n_image_change );
$('.direction-image-button[data-id="'+directionID+'"]').prop( 'value', cooked_js_vars.i18n_image_change );

});

// Opens the media library frame.
direction_image_frame.open();
});

if ($(".cooked-wysiwyg-editor").length) {
$(".cooked-wysiwyg-editor").attr('data-direction-part', 'content');
}

}

if ( $_CookedRecipeGallery.length ){
Expand Down Expand Up @@ -788,45 +792,43 @@ function cooked_reset_ingredient_builder() {
}

// Reset Time Picker Settings & Names
function cooked_reset_direction_builder(){
function cooked_reset_direction_builder() {

var directionBlocks = jQuery('.cooked-direction-block'),
total_blocks = 0;

directionBlocks.each(function(){

directionBlocks.each(function() {
var randomKeyForInterval = cooked_get_random_int(10000000,99999999);
total_blocks++;

// Set the input "name" values.
var $_this = jQuery(this);

$_this.find("[data-direction-part]").each(function(){

$_this.find("[data-direction-part]").each(function() {
var thisField = jQuery(this);
if ( thisField.attr('name') == ''){

if ( thisField.attr('name') == '') {
var directionPartName = thisField.data('direction-part');
thisField.attr( 'name','_recipe_settings[directions][' + randomKeyForInterval + '][' + directionPartName + ']' );
}
if ( thisField.attr('data-id') == ''){

if ( thisField.attr('data-id') == '') {
thisField.attr( 'data-id',randomKeyForInterval );
}
if ( thisField.attr('id') == ''){

if ( thisField.attr('id') == '') {
var directionPartName = thisField.data( 'direction-part' );
directionPartName = directionPartName.replace( '_', '-' );
thisField.attr( 'id','direction-'+randomKeyForInterval+'-'+directionPartName);
}

});

});

if ( total_blocks ){
jQuery('#cooked-directions-builder').css( { 'margin-bottom':'20px' } );
if ( total_blocks ) {
jQuery('#cooked-directions-builder').css( { 'margin-bottom': '20px' } );
} else {
jQuery('#cooked-directions-builder').css( { 'margin-bottom':'12px' } );
jQuery('#cooked-directions-builder').css( { 'margin-bottom': '12px' } );
}

}

// Get random integer for sortable lists (ingredients and directions)
Expand Down
2 changes: 1 addition & 1 deletion assets/admin/js/cooked-functions.min.js

Large diffs are not rendered by default.

118 changes: 79 additions & 39 deletions assets/js/cooked-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,32 +116,28 @@ var cooked_loading = false;
}

/**** 6. Timers ****/

function init_cooked_timers( Cooked_Timers ){

Cooked_Timers.on( 'click', function(e) {

function init_cooked_timers(Cooked_Timers) {
Cooked_Timers.on('click', function(e) {
e.preventDefault();

var thisTimer = $(this),
timerID = 'cookedTimer-' + thisTimer.data('timer-id'),
totalTimers = $('#cooked-timers-wrap').find('.cooked-timer-block').length,
visibleClass, newHeight;

// This timer is already here, let's just flash it.
if ( $( 'div#' + timerID ).length ){
if ($('div#' + timerID).length) {
$('div#' + timerID).css({ 'background' : '#eeeeee' });
setTimeout(function() {
$('div#' + timerID).css({ 'background' : '' });
}, 200);

$( 'div#' + timerID ).css({ 'background' : '#eeeeee' });
setTimeout(function(){
$( 'div#' + timerID ).css({ 'background' : '' });
},200);
return;

} else {

// Only 4 timers allowed at a time.
if ( totalTimers == 4 ){
if (totalTimers == 4) {
$('#cooked-timers-wrap').css({ 'transform' : 'translate3d(0,0.5em,0)' });
setTimeout(function(){
setTimeout(function() {
$('#cooked-timers-wrap').css({ 'transform' : '' });
},200);
return;
Expand All @@ -150,59 +146,103 @@ var cooked_loading = false;
// Okay we're good to go, let's add this timer!
totalTimers = totalTimers + 1;
newHeight = totalTimers * 7.5;
if ( thisTimer.parents('.cooked-single-direction').length ){
if (thisTimer.parents('.cooked-single-direction').length) {
var thisStep = thisTimer.parents('.cooked-single-direction').data('step');
} else {
var thisStep = cooked_js_vars.i18n_timer;
}
var Timer = { id:timerID, seconds:thisTimer.data('seconds'), step:thisStep, desc:thisTimer.data('desc') };

// Timers wrap already there?
if ( $( '#cooked-timers-wrap' ).length ){
var Timer = {
id: timerID,
seconds: thisTimer.data('seconds'),
step: thisStep,
desc: thisTimer.data('desc')
};

if ( totalTimers == 1 ){
// Timers wrap already there?
if ($('#cooked-timers-wrap').length) {
if (totalTimers == 1) {
visibleClass = ' cooked-visible';
} else {
visibleClass = '';
}

if ( totalTimers > multiplesTrigger ){
if (totalTimers > multiplesTrigger) {
$('#cooked-timers-wrap').addClass('cooked-multiples');
} else {
$('#cooked-timers-wrap').removeClass('cooked-multiples');
}

$('#cooked-timers-wrap').addClass('cooked-visible');
$( '#cooked-timers-wrap' ).append('<div id="' + Timer.id + '" class="cooked-timer-block' + visibleClass + '"><span class="cooked-timer-step">' + Timer.step + '</span><span class="cooked-timer-desc">' + Timer.desc + '</span><div class="cooked-timer-obj" data-seconds-left="' + Timer.seconds + '"></div><i class="cooked-icon cooked-icon-times"></i><div class="cooked-progress"><span></span></div></div>');
var thisTimerObj = $( '#' + Timer.id ).find('.cooked-timer-obj');
cookedTimer( thisTimerObj, false );
setTimeout( function(){
let timerBlock = cookedTimerBlock(Timer, visibleClass);
$('#cooked-timers-wrap').append(timerBlock);

var thisTimerObj = $('#' + Timer.id).find('.cooked-timer-obj');

cookedTimer(thisTimerObj, false);

setTimeout(function() {
$('#cooked-timers-wrap').css({ 'height' : newHeight + 'em' });
$('.cooked-timer-block').addClass('cooked-visible');
},50);

}, 50);
} else {
let timerWrap = $('<div>', { id: 'cooked-timers-wrap' });
let timerBlock = cookedTimerBlock(Timer);
timerWrap.append(timerBlock);

$('body').append('<div id="cooked-timers-wrap"><div id="' + Timer.id + '" class="cooked-timer-block cooked-visible"><span class="cooked-timer-step">' + Timer.step + '</span><span class="cooked-timer-desc">' + Timer.desc + '</span><div class="cooked-timer-obj" data-seconds-left="' + Timer.seconds + '"></div><i class="cooked-icon cooked-icon-times"></i><div class="cooked-progress"><span></span></div></div></div>');
var thisTimerObj = $( '#' + Timer.id ).find('.cooked-timer-obj');
cookedTimer( thisTimerObj, false );
setTimeout( function(){
$('#cooked-timers-wrap').addClass('cooked-visible');
},50);
$('body').append(timerWrap);
var thisTimerObj = $('#' + Timer.id).find('.cooked-timer-obj');
cookedTimer(thisTimerObj, false);

setTimeout(function() {
$('#cooked-timers-wrap').addClass('cooked-visible');
}, 50);
}


}
});
}

function cookedTimerBlock(Timer, visibleClass = 'cooked-visible') {
// Create the second div with dynamic id and classes
let timerBlock = $('<div>', {
id: Timer.id,
class: 'cooked-timer-block ' + visibleClass
});

// Create and append the step span
$('<span>', {
class: 'cooked-timer-step',
text: Timer.step
}).appendTo(timerBlock);

// Create and append the description span
$('<span>', {
class: 'cooked-timer-desc',
text: Timer.desc
}).appendTo(timerBlock);

// Create and append the timer object div
$('<div>', {
class: 'cooked-timer-obj',
'data-seconds-left': Timer.seconds
}).appendTo(timerBlock);

// Create and append the icon
$('<i>', {
class: 'cooked-icon cooked-icon-times'
}).appendTo(timerBlock);

// Create and append the progress bar
let progress = $('<div>', { class: 'cooked-progress' });
$('<span>').appendTo(progress);
progress.appendTo(timerBlock);

return timerBlock;
}

function cookedTimer( timerObj, startPaused ){

function cookedTimer(timerObj, startPaused) {
var timer_sound = cooked_js_vars.timer_sound;
var audio = new Audio( timer_sound );
var audio = new Audio(timer_sound);

var thisTimerID = timerObj.parents('.cooked-timer-block').attr('id'),
secondsLeft = timerObj.data('seconds-left'),
Expand All @@ -216,9 +256,9 @@ var cooked_loading = false;
clearDiv: 'cooked-timer-clearDiv',
timeout: 'cooked-timer-timeout'
},
onComplete: function(){
onComplete: function() {
audio.play();
timerObj.addClass( 'cooked-timer-complete' );
timerObj.addClass('cooked-timer-complete');
}
});

Expand Down
Loading