Skip to content
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.11.2
version: 1.12.0
doi: 10.5281/zenodo.1171250
date-released: 2017-05-08
url: "https://github.com/XjSv/cooked"
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Versions that are currently being supported with security updates.

| Version | Supported |
| ----------- | ------------------ |
| 1.11.2 | :white_check_mark: |
| <= 1.11.1 | :x: |
| 1.12.0 | :white_check_mark: |
| <= 1.11.4 | :x: |

## Reporting a Vulnerability

Expand Down
65 changes: 58 additions & 7 deletions assets/admin/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ body.post-type-cp_recipe #titlediv #title-prompt-text { font-size:15px; color:#8
#cooked-ingredients-builder .cooked-ingredient-block > .cooked-heading-element select,
#cooked-directions-builder .cooked-direction-block > .cooked-heading-element select {
color: #0685ba;
width: 100%;
}

#cooked-ingredients-builder .cooked-ingredient-block > .cooked-heading-element label,
Expand All @@ -225,6 +226,18 @@ body.post-type-cp_recipe #titlediv #title-prompt-text { font-size:15px; color:#8
display: block;
}

#cooked-ingredients-builder .cooked-ingredient-block .cooked-show-substitution { opacity:0; cursor:pointer; font-size:14px; position:absolute; top:15px; right:58px; }
#cooked-ingredients-builder .cooked-ingredient-block .cooked-show-substitution .cooked-icon { color:#888; }
#cooked-ingredients-builder .cooked-ingredient-block:hover .cooked-show-substitution,
#cooked-ingredients-builder .cooked-ingredient-block.cooked-expanded .cooked-show-substitution,
#cooked-ingredients-builder .cooked-ingredient-block.cooked-has-substitution .cooked-show-substitution { opacity:1; right:50px; }
#cooked-ingredients-builder .cooked-ingredient-block .cooked-show-substitution .cooked-icon:hover,
#cooked-ingredients-builder .cooked-ingredient-block.cooked-expanded .cooked-show-substitution .cooked-icon,
#cooked-ingredients-builder .cooked-ingredient-block.cooked-has-substitution .cooked-show-substitution .cooked-icon { color:#0685ba; }

#cooked-ingredients-builder .cooked-ingredient-block:hover > .cooked-ingredient-name,
#cooked-ingredients-builder .cooked-ingredient-block.cooked-expanded > .cooked-ingredient-name,
#cooked-ingredients-builder .cooked-ingredient-block.cooked-has-substitution > .cooked-ingredient-name { padding-right:32px; }

/* Switchery */
body.post-type-cp_recipe .switchery-small,
Expand All @@ -240,11 +253,15 @@ body.post-type-cp_recipe .switchery-small > small,
.cooked-progress.cooked-active, .cooked-progress-text.cooked-active { display:block; }
.cooked-progress .cooked-progress-bar { display:block; position:absolute; background:#0085ba; width:0%; height:6px; top:0; left:0; border-radius:3px; }

#cooked-migration-progress.cooked-progress, #cooked-import-progress.cooked-progress { background:#ccc; margin:25px 0 0 0; border-radius:6px; height:12px; max-width:600px; }
#cooked-migration-progress.cooked-progress .cooked-progress-bar, #cooked-import-progress.cooked-progress .cooked-progress-bar { border-radius:6px; height:12px; }
#cooked-migration-progress-text.cooked-progress-text, #cooked-import-progress-text.cooked-progress-text { font-size:11px; color:#888; max-width:600px; }
#cooked-migration-completed, #cooked-import-completed { display:none; }
#cooked-migration-completed.cooked-active, #cooked-import-completed.cooked-active { display:block; }
#cooked-migration-progress.cooked-progress, #cooked-import-progress.cooked-progress, #cooked-related-progress.cooked-progress { background:#ccc; margin:25px 0 0 0; border-radius:6px; height:12px; max-width:600px; }
#cooked-migration-progress.cooked-progress .cooked-progress-bar, #cooked-import-progress.cooked-progress .cooked-progress-bar, #cooked-related-progress.cooked-progress .cooked-progress-bar { border-radius:6px; height:12px; }
#cooked-migration-progress-text.cooked-progress-text, #cooked-import-progress-text.cooked-progress-text, #cooked-related-progress-text.cooked-progress-text { font-size:11px; color:#888; max-width:600px; }
#cooked-migration-completed, #cooked-import-completed, #cooked-related-completed { display:none; }
#cooked-migration-completed.cooked-active, #cooked-import-completed.cooked-active, #cooked-related-completed.cooked-active { display:block; }

/* Related Recipes Tools status (last run + completed) */
.cooked-related-status { margin:0 0 12px 0; padding:8px 12px; font-size:13px; line-height:1.4; border-radius:4px; border-left:3px solid #00a878; background:#f0f9f6; color:#2d4a42; max-width:480px; }
#cooked-related-last-done.cooked-related-status { border-left-color:#8c9b99; background:#f6f8f7; color:#5c6b69; }

/* Save as Default */
#cooked_recipe_settings .cooked-layout-save-default { position:relative; top:-2px; z-index:10; margin:0 0 0 15px; padding:0 8px 1px; }
Expand All @@ -260,7 +277,7 @@ body .button.button-cooked-reset:hover { color:#555; }
#cooked_recipe_settings .cooked-ingredient-headers span.cooked-ingredient-header-measurement { width:20%; }
#cooked_recipe_settings .cooked-ingredient-headers span.cooked-ingredient-header-item { width:65%; }
#cooked-ingredients-builder { margin:0 0 20px; }
#cooked-ingredients-builder .cooked-ingredient-block { display:block; padding:5px 25px 5px 35px; }
#cooked-ingredients-builder .cooked-ingredient-block { display:block; padding:5px 45px 5px 35px; }
#cooked-ingredients-builder .cooked-ingredient-block:hover { background:#eee; }
#cooked-ingredients-builder .cooked-ingredient-block input[type="text"],
#cooked-ingredients-builder .cooked-ingredient-block input[type="number"],
Expand All @@ -271,6 +288,8 @@ body .button.button-cooked-reset:hover { color:#555; }
#cooked-ingredients-builder .cooked-ingredient-block > .cooked-ingredient-measurement { width:20%; }
#cooked-ingredients-builder .cooked-ingredient-block > .cooked-ingredient-measurement .cooked-select-wrapper { width:100%; }
#cooked-ingredients-builder .cooked-ingredient-block > .cooked-ingredient-measurement .cooked-select-wrapper select { width:100%; }
#cooked-ingredients-builder .cooked-ingredient-block .cooked-substitution-fields > .cooked-ingredient-measurement .cooked-select-wrapper { width:100%; }
#cooked-ingredients-builder .cooked-ingredient-block .cooked-substitution-fields > .cooked-ingredient-measurement .cooked-select-wrapper select { width:100%; }
#cooked-ingredients-builder .cooked-ingredient-block > .cooked-ingredient-name { width:65%; }
#cooked-ingredients-builder .cooked-ingredient-block > .cooked-heading-name { width:100%; }
#cooked-ingredients-builder .cooked-ingredient-block > div small.cooked-input-ex { display:block; padding:5px 0 0 2px; }
Expand Down Expand Up @@ -605,6 +624,7 @@ body .button.button-cooked-reset:hover { color:#555; }
#cooked_recipe_settings select,
#cooked-directions-builder .cooked-direction-block > .cooked-direction-image .cooked-direction-img-placeholder,
#cooked-migration-progress.cooked-progress .cooked-progress-bar,
#cooked-related-progress.cooked-progress .cooked-progress-bar,
#cooked_recipe_settings .cooked-select-wrapper:before { -webkit-transition: all .15s ease-out; -moz-transition: all .15s ease-out; transition: all .15s ease-out; }
#cooked-recipe-image-gallery .cooked-recipe-gallery-item { -webkit-transition: transform .15s ease-out; -moz-transition: all .15s ease-out; transition: transform .15s ease-out; }
#cooked-recipe-tabs li.cooked-loading { -webkit-transition: opacity .15s ease-out; -moz-transition: all .15s ease-out; transition: opacity .15s ease-out; }
Expand Down Expand Up @@ -637,4 +657,35 @@ body .button.button-cooked-reset:hover { color:#555; }

@media screen and ( max-width: 960px ) {
#cooked_recipe_settings.stuck #cooked-recipe-tabs { margin-left:36px; }
}
}

/* Substitution Fields */
#cooked-ingredients-builder .cooked-ingredient-block > .cooked-substitution-fields {
width: 100%;
float: left;
clear: both;
margin-top: 10px;
padding-top: 10px;
padding-right: 0;
padding-left: 0;
margin-left: 0;
box-sizing: border-box;
padding-bottom: 5px;
position: relative;
}

#cooked-ingredients-builder .cooked-ingredient-block > .cooked-substitution-fields .cooked-ingredient-amount { width: 15%; }
#cooked-ingredients-builder .cooked-ingredient-block > .cooked-substitution-fields .cooked-ingredient-measurement { width: 20%; }
#cooked-ingredients-builder .cooked-ingredient-block > .cooked-substitution-fields .cooked-ingredient-name { width: 65%; }
#cooked-ingredients-builder .cooked-ingredient-block > .cooked-substitution-fields .cooked-sub-label {
color: #7c7c7c;
font-size: 14px;
font-weight: 300;
}

#cooked-ingredients-builder .cooked-ingredient-block > .cooked-substitution-fields > div {
display: inline-block;
float: left;
box-sizing: border-box;
padding-right: 10px;
}
2 changes: 1 addition & 1 deletion assets/admin/css/style.min.css

Large diffs are not rendered by default.

135 changes: 131 additions & 4 deletions assets/admin/js/cooked-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ var $_CookedConditionalTimeout = false;
$_CookedRecipeGallery = $('#cooked-recipe-image-gallery'),
$_CookedNutritionFactsTab = $('#cooked-recipe-tab-content-nutrition'),
$_CookedSettingsPanel = $('#cooked-settings-panel'),
$_CookedSettingsTabs = $('#cooked-settings-tabs');
$_CookedSettingsTabs = $('#cooked-settings-tabs'),
$_CookedCalculateRelatedButton = $('#cooked-calculate-related-button');

// Cooked Color Pickers
if ($_CookedColorPickers.length) {
Expand Down Expand Up @@ -229,6 +230,48 @@ var $_CookedConditionalTimeout = false;
});
}

// Calculate Related Recipes Button (Settings > Tools)
if ($_CookedCalculateRelatedButton.length) {
$_CookedCalculateRelatedButton.on('click', function(e) {
e.preventDefault();
var thisButton = $(this),
msg = cooked_functions_js_vars.i18n_confirm_calculate_related;

if (!confirm(msg) || thisButton.hasClass('disabled')) { return; }

thisButton.addClass('disabled').attr('disabled', true);
thisButton.hide();

// Get related recipes IDs
$.post(cooked_functions_js_vars.ajax_url, { action: 'cooked_get_related_recipes_ids' }, function(data) {
var response;
try {
response = typeof data === 'string' ? JSON.parse(data) : data;
} catch (e) {
thisButton.removeClass('disabled').attr('disabled', false).show();
return;
}
var ids = (response && response.ids) ? response.ids : [];
var total = (response && typeof response.total === 'number') ? response.total : 0;

if (total === 0 || ids.length === 0) {
thisButton.removeClass('disabled').attr('disabled', false).show();
return;
}
var progress = $('#cooked-related-progress'),
progress_bar = progress.find('.cooked-progress-bar'),
progress_text = $('#cooked-related-progress-text');
progress.addClass('cooked-active');
progress_text.addClass('cooked-active');
progress_bar.css('width', '0%');
progress_text.text('0 / ' + total);
cooked_calculate_related_recipes(ids, total, 0);
}).fail(function() {
thisButton.removeClass('disabled').attr('disabled', false).show();
});
});
}

// Conditional Fields (Recipes and Settings Pages)
if ($_CookedConditionals.length) {
var conditionalFields = [];
Expand Down Expand Up @@ -409,14 +452,25 @@ var $_CookedConditionalTimeout = false;
}
});

$_CookedIngredientBuilder.parent().on('click', '.cooked-show-heading-element', function(e) {
$_CookedIngredientBuilder.parent().on('click', '.cooked-show-substitution', function(e) {
e.preventDefault();
var thisParent = $(this).parent();
if ( thisParent.hasClass('cooked-expanded') ) {
thisParent.removeClass('cooked-expanded');
} else {
thisParent.addClass('cooked-expanded');
thisParent.find('input[data-ingredient-part="section_heading_element"]').focus();
thisParent.find('input[data-ingredient-part="sub_amount"]').focus();
}
});
Comment thread
XjSv marked this conversation as resolved.

$_CookedIngredientBuilder.on('keyup change', 'input[data-ingredient-part="sub_amount"], input[data-ingredient-part="sub_name"], select[data-ingredient-part="sub_measurement"]', function(e) {
var parentBlock = $(this).parents('.recipe-setting-block'),
subName = parentBlock.find('input[data-ingredient-part="sub_name"]').val();

if (subName && subName.trim()){
parentBlock.addClass('cooked-has-substitution');
} else {
parentBlock.removeClass('cooked-has-substitution');
}
});

Expand Down Expand Up @@ -687,6 +741,79 @@ var $_CookedConditionalTimeout = false;

var cooked_recipe_update_counter = 0;

function cooked_calculate_related_recipes(recipe_ids, total_recipes, processed_count) {
processed_count = processed_count || 0;

if (total_recipes <= 0 || !recipe_ids || recipe_ids.length === 0) {
jQuery('#cooked-related-progress').hide();
jQuery('#cooked-related-progress-text').hide();
jQuery('.recipe-setting-block.calculate_related_button').find('h3').hide();
jQuery('.recipe-setting-block.calculate_related_button').find('p:nth-child(2)').hide();
jQuery('#cooked-related-completed').addClass('cooked-active').show();
return;
}
var progress = jQuery('#cooked-related-progress'),
progress_bar = progress.find('.cooked-progress-bar'),
progress_text = jQuery('#cooked-related-progress-text');

if (!progress.hasClass('cooked-active')) {
progress.addClass('cooked-active');
progress_text.addClass('cooked-active');
}

jQuery.post(
cooked_functions_js_vars.ajax_url,
{
action: 'cooked_calculate_related_recipes',
recipe_ids: JSON.stringify(recipe_ids),
total_recipes: total_recipes,
processed_count: processed_count
},
function(response) {
var newProcessedCount = processed_count + 1;
var doneMeta = null;
var leftover = [];

// Backend returns either: { complete: true, count, date_formatted } or an array of remaining IDs (possibly as JSON string).
if (response && typeof response === 'object' && response.complete === true) {
doneMeta = { count: response.count, date_formatted: response.date_formatted };
} else {
try {
leftover = Array.isArray(response) ? response : JSON.parse(response);
} catch (e) {}
}

var done = newProcessedCount;
var pct = total_recipes > 0 ? Math.min(100, Math.round((done / total_recipes) * 100)) : 100;
if (pct < 2) { pct = 2; }
progress_bar.css('width', pct + '%');
progress_text.text(done + ' / ' + total_recipes);

if (!Array.isArray(leftover) || leftover.length === 0) {
progress.hide();
progress_text.hide();
jQuery('.recipe-setting-block.calculate_related_button').find('h3').hide();
jQuery('.recipe-setting-block.calculate_related_button').find('p:nth-child(2)').hide();
$_CookedCalculateRelatedButton.hide();
jQuery('#cooked-related-completed').addClass('cooked-active').show();
if (doneMeta && doneMeta.date_formatted != null && doneMeta.count != null) {
var tpl = cooked_functions_js_vars.i18n_last_calculated;
var msg = tpl.replace(/%1\$s/g, doneMeta.date_formatted).replace(/%2\$s/g, String(doneMeta.count));
jQuery('#cooked-related-last-done').text(msg).show();
}
} else {
cooked_calculate_related_recipes(leftover, total_recipes, newProcessedCount);
}
}
).fail(function() {
progress.removeClass('cooked-active').hide();
progress_text.removeClass('cooked-active').hide();
jQuery('.recipe-setting-block.calculate_related_button').find('h3').show();
jQuery('.recipe-setting-block.calculate_related_button').find('p:nth-child(2)').show();
$_CookedCalculateRelatedButton.removeClass('disabled').attr('disabled', false).show();
});
}

function cooked_set_default_template(recipe_ids, total_recipes, content, nonce, instance) {
var temp_counter = 0,
total_counter = 0,
Expand Down Expand Up @@ -978,4 +1105,4 @@ function cooked_init_conditional_field(thisID) {

}, 25);
});
}
}
2 changes: 1 addition & 1 deletion assets/admin/js/cooked-functions.min.js

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,21 @@ body .cooked-post-featured-image img {
opacity: 0.5;
}

/* Substitution Styles */
.cooked-ingredient-substitution {
font-style: italic;
color: #777;
margin-left: 5px;
display: inline-block;
}
.cooked-ing-sub-label {
font-style: normal;
font-weight: 600;
font-size: 0.85em;
color: #999;
margin-right: 2px;
}

/* Directions */
.cooked-recipe-directions {
display: block;
Expand Down Expand Up @@ -1882,3 +1897,59 @@ body.cooked-fsm-active #wpadminbar {
-o-transition: all 100ms cubic-bezier(0.42, 0, 0.15, 1);
transition: all 100ms cubic-bezier(0.42, 0, 0.15, 1);
}

/* Related Recipes Styles */
.cooked-related-recipes-title {
margin: 0 0 20px 0;
font-size: 1.5em;
font-weight: 600;
color: #333;
}

.cooked-related-recipes-grid {
margin: 20px 0;
}

.cooked-related-recipes-error,
.cooked-related-recipes-empty {
padding: 15px;
margin: 20px 0;
background: #f9f9f9;
border-left: 4px solid #d63638;
color: #666;
font-style: italic;
}

.cooked-related-recipes-empty {
border-left-color: #0073aa;
text-align: center;
}

/* Ensure related recipes grid uses existing Cooked styles */
.cooked-related-recipes-grid .cooked-recipe-card {
margin-bottom: 20px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
.cooked-related-recipes-grid.cooked-columns-3,
.cooked-related-recipes-grid.cooked-columns-4 {
margin-left: -1.5%;
width: 103%;
}

.cooked-related-recipes-grid.cooked-columns-3 .cooked-recipe,
.cooked-related-recipes-grid.cooked-columns-4 .cooked-recipe {
width: 47%;
min-width: 47%;
}
}

@media (max-width: 480px) {
.cooked-related-recipes-grid.cooked-columns-2 .cooked-recipe,
.cooked-related-recipes-grid.cooked-columns-3 .cooked-recipe,
.cooked-related-recipes-grid.cooked-columns-4 .cooked-recipe {
width: 97%;
min-width: 97%;
}
}
2 changes: 1 addition & 1 deletion assets/css/style.min.css

Large diffs are not rendered by default.

Loading
Loading