Skip to content

Commit

Permalink
Merge pull request #83 from XjSv/develop
Browse files Browse the repository at this point in the history
Release v1.9.0 Changes
  • Loading branch information
XjSv authored Dec 29, 2024
2 parents c53aa5a + d38bbeb commit 710abf2
Show file tree
Hide file tree
Showing 32 changed files with 1,654 additions and 1,360 deletions.
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.3
version: 1.9.0
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.9 | :white_check_mark: |
| 1.9.0 | :white_check_mark: |
| 1.8.9 | :x: |
| 1.8.8 | :x: |
| 1.8.7 | :x: |
| 1.8.6 | :x: |
Expand Down
162 changes: 91 additions & 71 deletions assets/admin/js/cooked-functions.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/admin/js/cooked-functions.min.js

Large diffs are not rendered by default.

22 changes: 10 additions & 12 deletions assets/admin/js/cooked-widgets.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
;(function ( $, window, document, undefined ) {

$('body').on( 'change', '.cooked-widget-conditional', function(){
$('body').on( 'change', '.cooked-widget-conditional', function() {
var thisConditional = $(this);
cooked_widget_conditional_init( thisConditional );
});

$('body').on( 'click', '.cooked-recipe-finder-show', function(e){

$('body').on( 'click', '.cooked-recipe-finder-show', function(e) {
e.preventDefault();
var thisFinderShowLink = $(this),
thisFinderShow = thisFinderShowLink.attr('id');
Expand All @@ -29,10 +28,10 @@
closeAfterSelect: true,
openOnFocus: false,
options: [],
onInitialize: function(){
onInitialize: function() {
$( '#' + thisFinderID + '-selectized' ).focus();
},
onItemAdd: function(){
onItemAdd: function() {
thisFinder.trigger('change');
},
render: {
Expand Down Expand Up @@ -64,10 +63,10 @@
if (!res.hasOwnProperty(key)) continue;
var obj = res[key];
for (var prop in obj) {
if(!obj.hasOwnProperty(prop)) continue;
if ( prop == 'id' ){
if (!obj.hasOwnProperty(prop)) continue;
if (prop == 'id') {
var id = obj[prop];
} else if ( prop == 'title' ){
} else if (prop == 'title') {
var title = obj[prop].rendered;
}
}
Expand All @@ -83,10 +82,9 @@

})(jQuery, window, document);

function cooked_widget_conditional_init( thisConditional ){

thisConditional_ID = thisConditional.attr('id'),
thisConditional_VAL = jQuery( '#' + thisConditional_ID + ' option:selected').val();
function cooked_widget_conditional_init(thisConditional) {
thisConditional_ID = thisConditional.attr('id');
thisConditional_VAL = jQuery('#' + thisConditional_ID + ' option:selected').val();

jQuery( 'body' ).find( '[data-condition="' + thisConditional_ID + '"]' ).each(function(){
var thisValue = jQuery(this).data('value');
Expand Down
94 changes: 50 additions & 44 deletions assets/admin/js/selectize/selectize.dragdrop.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Plugin: "drag_drop" (selectize.js)
* Copyright (c) 2013 Brian Reavis & contributors
* Copyright (c) 2020-2022 Selectize Team & contributors*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
Expand All @@ -15,53 +16,58 @@
*/

Selectize.define('drag_drop', function(options) {
if (!$.fn.sortable) throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');
if (this.settings.mode !== 'multi') return;
var self = this;
if (!$.fn.sortable) throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');
if (this.settings.mode !== 'multi') return;
var self = this;

self.lock = (function() {
var original = self.lock;
return function() {
var sortable = self.$control.data('sortable');
if (sortable) sortable.disable();
return original.apply(self, arguments);
};
})();
self.lock = (function() {
var original = self.lock;
return function() {
var sortable = self.$control.data('sortable');
if (sortable) sortable.disable();
return original.apply(self, arguments);
};
})();

self.unlock = (function() {
var original = self.unlock;
return function() {
var sortable = self.$control.data('sortable');
if (sortable) sortable.enable();
return original.apply(self, arguments);
};
})();
self.unlock = (function() {
var original = self.unlock;
return function() {
var sortable = self.$control.data('sortable');
if (sortable) sortable.enable();
return original.apply(self, arguments);
};
})();

self.setup = (function() {
var original = self.setup;
return function() {
original.apply(this, arguments);
self.setup = (function() {
var original = self.setup;
return function() {
original.apply(this, arguments);

var $control = self.$control.sortable({
items: '[data-value]',
forcePlaceholderSize: true,
disabled: self.isLocked,
start: function(e, ui) {
ui.placeholder.css('width', ui.helper.css('width'));
$control.css({overflow: 'visible'});
},
stop: function() {
$control.css({overflow: 'hidden'});
var active = self.$activeItems ? self.$activeItems.slice() : null;
var values = [];
$control.children('[data-value]').each(function() {
values.push($(this).attr('data-value'));
});
self.setValue(values);
self.setActiveItem(active);
}
});
};
})();
var $control = self.$control.sortable({
items: '[data-value]',
forcePlaceholderSize: true,
disabled: self.isLocked,
start: function(e, ui) {
ui.placeholder.css('width', ui.helper.css('width'));
// $control.css({overflow: 'visible'});
$control.addClass('dragging');
},
stop: function() {
// $control.css({overflow: 'hidden'});
$control.removeClass('dragging');
var active = self.$activeItems ? self.$activeItems.slice() : null;
var values = [];
$control.children('[data-value]').each(function() {
values.push($(this).attr('data-value'));
});
self.isFocused = false;
self.setValue(values);
self.isFocused = true;
self.setActiveItem(active);
self.positionDropdown();
}
});
};
})();

});
36 changes: 32 additions & 4 deletions assets/admin/js/selectize/selectize.min.js

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions assets/js/cooked-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,56 @@ var cooked_loading = false;
var thisButton = $(this);
thisButton.parents('form').trigger('submit');
});

// Add form submit handler for the Browse Search Form
if ( cooked_js_vars.permalink_structure ) {
$('.cooked-recipe-search form').on('submit', function(e) {
e.preventDefault();

// Get form values
const formValues = {
category: $(this).find('[name="cp_recipe_category"]').val() || '',
method: $(this).find('[name="cp_recipe_cooking_method"]').val() || '',
cuisine: $(this).find('[name="cp_recipe_cuisine"]').val() || '',
tags: $(this).find('[name="cp_recipe_tags"]').val() || '',
diet: $(this).find('[name="cp_recipe_diet"]').val() || '',
search: $(this).find('[name="cooked_search_s"]').val() || '',
sort: $(this).find('[name="cooked_browse_sort_by"]').val() || 'date_desc',
};

// Create URL segments
const urlSegments = [];
urlSegments.push(cooked_js_vars.browse_recipes_slug);

// Add taxonomy segments
const taxonomyFields = [
{ value: formValues.category, prefix: cooked_js_vars.recipe_category_slug },
{ value: formValues.method, prefix: cooked_js_vars.recipe_cooking_method_slug },
{ value: formValues.cuisine, prefix: cooked_js_vars.recipe_cuisine_slug },
{ value: formValues.tags, prefix: cooked_js_vars.recipe_tags_slug },
{ value: formValues.diet, prefix: cooked_js_vars.recipe_diet_slug },
];

taxonomyFields.forEach(field => {
if (field.value) {
urlSegments.push(`${field.prefix}/${encodeURIComponent(field.value)}`);
}
});

// Add search segment
if (formValues.search) {
urlSegments.push(`search/${encodeURIComponent(formValues.search)}`);
}

// Add sort segment
urlSegments.push(`sort/${encodeURIComponent(formValues.sort)}`);

// Build and navigate to URL
const prettyUrl = '/' + urlSegments.filter(Boolean).join('/');

window.location.href = prettyUrl;
});
}
}

/**** 6. Timers ****/
Expand Down
Loading

0 comments on commit 710abf2

Please sign in to comment.