Skip to content

Commit

Permalink
Setup helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyzen committed Dec 6, 2023
1 parent ed99f06 commit d0e6e18
Show file tree
Hide file tree
Showing 3 changed files with 508 additions and 382 deletions.
47 changes: 25 additions & 22 deletions assets/admin.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
jQuery(document).ready(function ($) {
const globalAttributes = $('.global_attribute_table');
let uniqueId = Math.random().toString(36).substr(2, 9);
const globalAttributes = $(".global_attribute_table");
let uniqueId = Math.random().toString(36).slice(2, 11);

// product_attributes is an object that contains the product attributes
// product_attributes is an object that contains the product attributes

// deploy-button FROM build_hook
const buildUrl = $('#build_url');
$('#deploy-button').click(function (e) {
const buildUrl = $("#build_url");
$("#deploy-button").click(function (e) {
e.preventDefault();
$.ajax({
url: buildUrl.val(),
type: 'POST',
success: function (data) {
alert('Build triggered successfully');
type: "POST",
success(data) {
alert("Build triggered successfully");
},
});
});

// add global attribute
$('.add_global_attribute').click(function (e) {
$(".add_global_attribute").click(function (e) {
e.preventDefault();
console.log('add global attribute');
console.log("add global attribute");
const newAttribute = `
<tr>
<td>
Expand Down Expand Up @@ -52,37 +52,40 @@ jQuery(document).ready(function ($) {
</tr>
`;

globalAttributes.find('tbody').append(newAttribute);
globalAttributes.find("tbody").append(newAttribute);

uniqueId = Math.random().toString(36).substr(2, 9);
uniqueId = Math.random().toString(36).slice(2, 11);
});

// remove global attribute
$(document).on('click', '.remove_global_attribute', function (e) {
$(document).on("click", ".remove_global_attribute", function (e) {
e.preventDefault();
console.log('remove');
// find parent tr
$(this).closest('tr').remove();
$(this).closest("tr").remove();
});

// move global attribute
$(document).on('click', '.move_global_attribute_up', function (e) {
$(document).on("click", ".move_global_attribute_up", function (e) {
e.preventDefault();
console.log('move up');
const currentRow = $(this).closest('tr');
const currentRow = $(this).closest("tr");
const prevRow = currentRow.prev();
if (prevRow.length) {
currentRow.insertBefore(prevRow);
}
});

$(document).on('click', '.move_global_attribute_down', function (e) {
$(document).on("click", ".move_global_attribute_down", function (e) {
e.preventDefault();
console.log('move down');
const currentRow = $(this).closest('tr');
const currentRow = $(this).closest("tr");
const nextRow = currentRow.next();
if (nextRow.length) {
currentRow.insertAfter(nextRow);
}
});

// Handle color picker
$("#primary-color-setting input").on("change, input", function () {
$("#woonuxt_options\\[primary_color\\]").val($(this).val());
$("#color-preview").css("background-color", $(this).val());
$("#primary_color_picker").val($(this).val());
});
});
6 changes: 3 additions & 3 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "woonuxt Settings",
"version": "1.0.46",
"download_url": "https://github.com/scottyzen/woonuxt-settings/releases/download/1.0.46/woonuxt-settings.zip",
"version": "1.0.47",
"download_url": "https://github.com/scottyzen/woonuxt-settings/releases/download/1.0.47/woonuxt-settings.zip",

"homepage": "https://woonuxt.com/",
"tested": "6.3.2",
Expand All @@ -13,7 +13,7 @@
"sections": {
"description": "WooNuxt is unmatched when it comes to performance and scalability. Reap the benefits of having a online store that out performs all of your competitors.",
"installation": "(Recommended) Installation instructions.",
"changelog": "<h2>1.0.46</h2><p>Add functionality to increase max query amount if there are more than 100 products</p><h2>1.0.45</h2><p>Fix error when WooCommerce is disabled or not installed</p>"
"changelog": "<h2>1.0.47</h2><p>Add functionality to increase max query amount if there are more than 100 products</p><h2>1.0.45</h2><p>Fix error when WooCommerce is disabled or not installed</p>"
},

"icons": {
Expand Down
Loading

0 comments on commit d0e6e18

Please sign in to comment.