-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major refactoring, add an admin page and prepare for first release
- Loading branch information
Showing
33 changed files
with
2,495 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
.c-env-row { | ||
display: grid; | ||
gap: 0 1em; | ||
grid-template-columns: 10px repeat(2, fit-content(300px)) repeat(3, fit-content(200px)) | ||
} | ||
|
||
.c-env-row:only-child { | ||
display: none; | ||
} | ||
|
||
.c-env-cell { | ||
padding: 0.5em 0; | ||
width: 260px; | ||
} | ||
|
||
.c-env-cell--full { | ||
grid-column: 1 / -1; | ||
} | ||
|
||
.c-env-cell:nth-child(1) { | ||
width: auto; | ||
} | ||
|
||
.c-env-cell:nth-child(4), | ||
.c-env-cell:nth-child(5) { | ||
width: 104px; | ||
} | ||
|
||
.c-env-cell--label { | ||
white-space: nowrap; | ||
} | ||
|
||
.c-env-cell input { | ||
display: block; | ||
width: 100%; | ||
} | ||
|
||
.c-env-cell label { | ||
font-weight: bold; | ||
} | ||
|
||
.c-env-row--disabled .wp-picker-container { | ||
pointer-events: none; | ||
} | ||
|
||
/** Color picker overrides */ | ||
.wp-picker-container { | ||
position: relative; | ||
display: flex; | ||
} | ||
|
||
.wp-picker-container .wp-color-result.button { | ||
margin-right: 0; | ||
margin-bottom: 0; | ||
} | ||
|
||
.wp-picker-open + .wp-picker-input-wrap { | ||
position: absolute; | ||
top: 36px; | ||
z-index: 2; | ||
|
||
display: flex; | ||
padding: 6px; | ||
|
||
background: white; | ||
border: 1px solid #dcdcde; | ||
border-bottom: none; | ||
} | ||
|
||
.wp-picker-holder { | ||
position: absolute; | ||
z-index: 1; | ||
top: 72px; | ||
} | ||
|
||
/** Sortable */ | ||
.c-sortable-handle { | ||
display: inline-block; | ||
cursor: grab; | ||
padding: 0.5em 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
; (function ($, document, window) { | ||
'use strict'; | ||
|
||
const $document = $(document); | ||
|
||
$document.ready(function ($) { | ||
// repeater | ||
const $table = $('.js-drgnff-env-table'); | ||
const template = wp.template('drgnff-row'); | ||
|
||
$('.js-drgnff-add-button').on('click', function (e) { | ||
e.preventDefault(); | ||
|
||
const html = template({ index: $table.find('.js-drgnff-row').length }); | ||
$table.append(html); | ||
$table.last().find('.js-drgnff-color-field').wpColorPicker(); | ||
}); | ||
|
||
$table.on('click', '.js-drgnff-row-remove', function (e) { | ||
e.preventDefault(); | ||
|
||
$(this).parents('.js-drgnff-row').remove(); | ||
|
||
updateIndexes($table); | ||
}); | ||
|
||
// reset default environment | ||
$('.js-drgnff-default-reset').on('click', function (e) { | ||
e.preventDefault(); | ||
|
||
$(this).parents('.js-drgnff-row').find('.js-drgnff-input:not(:disabled)').each(function () { | ||
const $input = $(this); | ||
const originalValue = $input.data('original-value'); | ||
|
||
$input.val(originalValue); | ||
|
||
if ($input.hasClass('js-drgnff-color-field')) { | ||
$input.iris('color', originalValue); | ||
} | ||
}); | ||
}); | ||
|
||
// color picker init | ||
$('.js-drgnff-color-field').wpColorPicker(); | ||
|
||
// initialize jquery ui sortable | ||
$('.js-drgnff-sortable').sortable({ | ||
items: '.js-drgnff-row', | ||
handle: '.js-drgnff-sortable-handle', | ||
cursor: 'move', | ||
axis: 'y', | ||
update: function () { | ||
updateIndexes($table); | ||
} | ||
}); | ||
}); | ||
|
||
function updateIndexes($table) { | ||
$table.find('.js-drgnff-row').each(function (index) { | ||
$(this).find('.js-drgnff-input').each(function () { | ||
const $input = $(this); | ||
const name = $input.attr('name'); | ||
|
||
$input.attr('name', name.replace(/\[\d+\]/, `[${index}]`)); | ||
}); | ||
}); | ||
} | ||
|
||
})(jQuery, document, window); | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.