Commit b9dbf07a authored by alain's avatar alain 🐙
Browse files

update plugins

parent fa69e04f
/***************************************
Tabs on the settings page
***************************************/
.wrap.ws-ame-too-many-tabs .ws-ame-nav-tab-list {
&.nav-tab-wrapper {
border-bottom-color: transparent;
}
.nav-tab {
border-bottom: 1px solid #c3c4c7;
margin-bottom: 10px;
margin-top: 0;
}
}
/* Spacing between the page heading and the tab list.
Normally, this is handled by .nav-tab styles, but WordPress changes the margins at smaller screen sizes
and the tabs end up without a left margin. Let's put that margin on the heading instead and remove it
from the first tab. */
#ws_ame_editor_heading {
margin-right: 0.305em;
}
.ws-ame-nav-tab-list {
a.nav-tab:first-of-type {
margin-left: 0;
}
}
/* When in "too many tabs" mode, there's too much space between the bottom of the tab list and the rest
of the page. I haven't found a good way to change the margins of just the last row, so here's a partial fix. */
.ws-ame-too-many-tabs #ws_actor_selector {
margin-top: 0;
}
\ No newline at end of file
...@@ -51,7 +51,8 @@ hr.ws-submenu-separator { ...@@ -51,7 +51,8 @@ hr.ws-submenu-separator {
} }
/* No colored bar/marker when hovering over a separator. */ /* No colored bar/marker when hovering over a separator. */
#adminmenu li.ws-submenu-separator-wrap a:hover { #adminmenu li.ws-submenu-separator-wrap a:hover,
#adminmenu li.ws-submenu-separator-wrap a:focus {
box-shadow: none; box-shadow: none;
} }
...@@ -118,25 +119,3 @@ hr.ws-submenu-separator { ...@@ -118,25 +119,3 @@ hr.ws-submenu-separator {
opacity: 1; opacity: 1;
filter: alpha(opacity=100); filter: alpha(opacity=100);
} }
/*
* Third level menus.
*/
#adminmenu .ame-deep-submenu {
}
#adminmenu li.menu-top.opensub .ame-deep-submenu {
top: -1000em;
}
#adminmenu .wp-submenu li.opensub > ul.ame-deep-submenu {
top: -1px;
}
.folded #adminmenu li.opensub > ul.ame-deep-submenu,
.folded #adminmenu .wp-has-current-submenu.opensub > ul.ame-deep-submenu,
.no-js.folded #adminmenu .ame-has-deep-submenu:hover > ul.ame-deep-submenu {
top: 0;
left: 160px;
}
\ No newline at end of file
...@@ -740,7 +740,7 @@ a.ws_button.ws_button_disabled:hover { ...@@ -740,7 +740,7 @@ a.ws_button.ws_button_disabled:hover {
width: 5px; width: 5px;
} }
#ws_toggle_toolbar { #ws_toggle_toolbar, .ws_toggle_toolbar_button {
margin-right: 0; margin-right: 0;
} }
...@@ -1968,6 +1968,10 @@ $userSelectionPanelPadding: 10px; ...@@ -1968,6 +1968,10 @@ $userSelectionPanelPadding: 10px;
vertical-align: bottom; vertical-align: bottom;
} }
.ws_tooltip_trigger.ame-warning-tooltip {
color: orange;
}
.ws_wide_tooltip { .ws_wide_tooltip {
max-width: 450px; max-width: 450px;
} }
...@@ -2256,4 +2260,6 @@ span.description { ...@@ -2256,4 +2260,6 @@ span.description {
padding: 8px; padding: 8px;
} }
@import "test-access-screen"; @import "test-access-screen";
\ No newline at end of file
@import "main-tabs";
\ No newline at end of file
...@@ -4,7 +4,7 @@ jQuery(function($) { ...@@ -4,7 +4,7 @@ jQuery(function($) {
$submitButton = $importForm.find(':submit'); $submitButton = $importForm.find(':submit');
//Enable the "next" button when the user selects a file. //Enable the "next" button when the user selects a file.
$importFile.change(function () { $importFile.on('change', function () {
$submitButton.prop('disabled', !$importFile.val()); $submitButton.prop('disabled', !$importFile.val());
}); });
......
...@@ -178,6 +178,8 @@ class wsAmeImportExportFeature { ...@@ -178,6 +178,8 @@ class wsAmeImportExportFeature {
} }
} }
//todo: Consider adding some buffer space at the end to avoid truncation when other plugins add superfluous whitespace.
$data = $this->export_data(); $data = $this->export_data();
$data['settings'] = array_intersect_key($data['settings'], $enabledOptions); $data['settings'] = array_intersect_key($data['settings'], $enabledOptions);
$json = json_encode($data); $json = json_encode($data);
......
...@@ -185,7 +185,7 @@ ko.bindingHandlers.ameColorPicker = { ...@@ -185,7 +185,7 @@ ko.bindingHandlers.ameColorPicker = {
if (newValue === '') { if (newValue === '') {
//Programmatically click the "Clear" button. It's not elegant, but I haven't found //Programmatically click the "Clear" button. It's not elegant, but I haven't found
//a way to do this using the Iris API. //a way to do this using the Iris API.
jQuery(element).closest('.wp-picker-input-wrap').find('.wp-picker-clear').click(); jQuery(element).closest('.wp-picker-input-wrap').find('.wp-picker-clear').trigger('click');
} }
else { else {
jQuery(element).iris('color', newValue); jQuery(element).iris('color', newValue);
......
...@@ -231,7 +231,7 @@ ko.bindingHandlers.ameColorPicker = { ...@@ -231,7 +231,7 @@ ko.bindingHandlers.ameColorPicker = {
if (newValue === '') { if (newValue === '') {
//Programmatically click the "Clear" button. It's not elegant, but I haven't found //Programmatically click the "Clear" button. It's not elegant, but I haven't found
//a way to do this using the Iris API. //a way to do this using the Iris API.
jQuery(element).closest('.wp-picker-input-wrap').find('.wp-picker-clear').click(); jQuery(element).closest('.wp-picker-input-wrap').find('.wp-picker-clear').trigger('click');
} else { } else {
jQuery(element).iris('color', newValue); jQuery(element).iris('color', newValue);
} }
......
'use strict'; 'use strict';
jQuery(function ($) { jQuery(function ($) {
const menuEditorNode = $('#ws_menu_editor');
$(document).on('filterMenuFields.adminMenuEditor', function (event, knownMenuFields, baseField) { $(document).on('filterMenuFields.adminMenuEditor', function (event, knownMenuFields, baseField) {
var scrollCheckboxField = $.extend({}, baseField, { var scrollCheckboxField = $.extend({}, baseField, {
caption: 'Hide the frame scrollbar', caption: 'Hide the frame scrollbar',
...@@ -48,79 +50,134 @@ jQuery(function ($) { ...@@ -48,79 +50,134 @@ jQuery(function ($) {
}); });
//The "Reset permissions" toolbar button. //The "Reset permissions" toolbar button.
$('#ws_reset_actor_permissions').on('click', function (event) { menuEditorNode.on(
event.preventDefault(); 'adminMenuEditor:action-reset-permissions',
function (event) {
var selectedActor = AmeEditorApi.actorSelectorWidget.selectedActor; event.preventDefault();
if (selectedActor === null) {
alert( var selectedActor = AmeEditorApi.actorSelectorWidget.selectedActor;
'This button resets all permissions for the selected role. ' if (selectedActor === null) {
+ 'To use it, click a role and then click this button again.' alert(
); 'This button resets all permissions for the selected role. '
return; + 'To use it, click a role and then click this button again.'
} );
return;
var displayName = AmeEditorApi.actorSelectorWidget.selectedDisplayName;
if (!confirm('Reset all permissions for "' + displayName + '"?')) {
return;
}
//Reset CPT/taxonomy permissions and other directly granted capabilities.
var hadGrantedCaps = AmeCapabilityManager.resetActorCaps(selectedActor);
//Reset permissions and visibility for all menu items.
AmeEditorApi.forEachMenuItem(function (menuItem, containerNode) {
var wasModified = hadGrantedCaps;
//Reset the "hide without changing permissions" settings (aka "cosmetically hidden").
if (
menuItem.hidden_from_actor
&& $.isPlainObject(menuItem.hidden_from_actor)
&& menuItem.hidden_from_actor.hasOwnProperty(selectedActor)
) {
delete menuItem.hidden_from_actor[selectedActor];
wasModified = true;
} }
//Reset permissions. var displayName = AmeEditorApi.actorSelectorWidget.selectedDisplayName;
if ( if (!confirm('Reset all permissions for "' + displayName + '"?')) {
menuItem.grant_access return;
&& $.isPlainObject(menuItem.grant_access)
&& menuItem.grant_access.hasOwnProperty(selectedActor)
) {
delete menuItem.grant_access[selectedActor];
wasModified = true;
} }
if (wasModified) { //Reset CPT/taxonomy permissions and other directly granted capabilities.
AmeEditorApi.updateItemEditor(containerNode); var hadGrantedCaps = AmeCapabilityManager.resetActorCaps(selectedActor);
AmeEditorApi.updateParentAccessUi(containerNode);
} //Reset permissions and visibility for all menu items.
}); AmeEditorApi.forEachMenuItem(function (menuItem, containerNode) {
}); var wasModified = hadGrantedCaps;
//Reset the "hide without changing permissions" settings (aka "cosmetically hidden").
if (
menuItem.hidden_from_actor
&& $.isPlainObject(menuItem.hidden_from_actor)
&& menuItem.hidden_from_actor.hasOwnProperty(selectedActor)
) {
delete menuItem.hidden_from_actor[selectedActor];
wasModified = true;
}
//Reset permissions.
if (
menuItem.grant_access
&& $.isPlainObject(menuItem.grant_access)
&& menuItem.grant_access.hasOwnProperty(selectedActor)
) {
delete menuItem.grant_access[selectedActor];
wasModified = true;
}
if (wasModified) {
AmeEditorApi.updateItemEditor(containerNode);
AmeEditorApi.updateParentAccessUi(containerNode);
}
});
}
);
//"New heading" toolbar button. //"New heading" toolbar button.
let headingCount = 0; let headingCount = 0;
$('#ws_new_heading').on('click', function (event) { menuEditorNode.on(
event.preventDefault(); 'adminMenuEditor:action-new-heading',
headingCount++; /**
* @param event
//The new menu starts out rather bare * @param {JQuery|null} selectedItem
const randomId = AmeEditorApi.randomMenuId('heading-'); * @param {AmeEditorColumn} column
let menu = $.extend(true, {}, wsEditorData.blankMenuItem, { */
sub_type: 'heading', function (event, selectedItem, column) {
menu_title: 'Heading ' + headingCount, headingCount++;
custom: true,
template_id: '', //The new menu starts out rather bare
css_class: 'menu-top ame-menu-heading-item', const randomId = AmeEditorApi.randomMenuId('heading-');
file: randomId, let menu = $.extend(true, {}, wsEditorData.blankMenuItem, {
hookname: randomId, sub_type: 'heading',
access_level: 'read', menu_title: 'Heading ' + headingCount,
items: [] custom: true,
}); template_id: '',
css_class: 'menu-top ame-menu-heading-item',
file: randomId,
hookname: randomId,
access_level: 'read',
items: []
});
column.outputItem(menu, selectedItem);
$(document).trigger('adminMenuEditor:newHeadingCreated');
}
);
AmeEditorApi.insertMenu(menu); //Three level menu confirmation dialog.
let $deepNestingDialog;
function initNestingDialog() {
if ($deepNestingDialog) {
return;
}
$(document).trigger('adminMenuEditor:newHeadingCreated'); $deepNestingDialog = $('#ws_ame_deep_nesting_dialog');
}); $deepNestingDialog.dialog({
autoOpen: false,
closeText: ' ',
draggable: false,
modal: true,
minHeight: 300,
minWidth: 400
});
}
menuEditorNode.on(
'adminMenuEditor:queryDeepNesting',
/**
* @param event
* @param {Array} queue
*/
function(event, queue) {
let isEnabled = $.Deferred();
queue.push(isEnabled);
initNestingDialog();
$deepNestingDialog.dialog('open');
$deepNestingDialog.find('#ame_allow_deep_nesting').one('click', function() {
isEnabled.resolve();
$deepNestingDialog.dialog('close');
return false;
});
$deepNestingDialog.find('#ame_reject_deep_nesting').one('click', function() {
isEnabled.reject();
$deepNestingDialog.dialog('close');
return false;
});
}
);
}); });
\ No newline at end of file
...@@ -214,6 +214,11 @@ class ameMenuHeadingStyler { ...@@ -214,6 +214,11 @@ class ameMenuHeadingStyler {
['&.ame-collapsible-heading a'], ['&.ame-collapsible-heading a'],
['cursor' => 'pointer'] ['cursor' => 'pointer']
), ),
//Remove the colored bar from item unless the heading is clickable.
$this->makeCssRule(
['&:not(.ame-collapsible-heading) a'],
['box-shadow' => 'none']
),
]; ];
//Some rules might be empty if we have no custom settings for their properties, //Some rules might be empty if we have no custom settings for their properties,
......
...@@ -374,7 +374,6 @@ class ameWidgetCollection { ...@@ -374,7 +374,6 @@ class ameWidgetCollection {
'Cannot decompress dashboard widget data. This site may be missing the Zlib extension.' 'Cannot decompress dashboard widget data. This site may be missing the Zlib extension.'
); );
} }
/** @noinspection PhpComposerExtensionStubsInspection */
$data = gzuncompress($data); $data = gzuncompress($data);
} }
......
...@@ -24,7 +24,7 @@ class ameWidgetEditor extends ameModule implements ameExportableModule { ...@@ -24,7 +24,7 @@ class ameWidgetEditor extends ameModule implements ameExportableModule {
return; return;
} }
add_action('wp_dashboard_setup', array($this, 'setupDashboard'), 200); add_action('wp_dashboard_setup', array($this, 'setupDashboard'), 20000);
add_action('admin_menu_editor-header', array($this, 'handleFormSubmission'), 10, 2); add_action('admin_menu_editor-header', array($this, 'handleFormSubmission'), 10, 2);
...@@ -107,7 +107,7 @@ class ameWidgetEditor extends ameModule implements ameExportableModule { ...@@ -107,7 +107,7 @@ class ameWidgetEditor extends ameModule implements ameExportableModule {
plugins_url('dashboard-widget-editor.js', __FILE__), plugins_url('dashboard-widget-editor.js', __FILE__),
array( array(
'ame-lodash', 'ame-dashboard-widget', 'knockout', 'ame-actor-selector', 'ame-lodash', 'ame-dashboard-widget', 'knockout', 'ame-actor-selector',
'ame-jquery-form', 'jquery-ui-dialog', 'jquery-json', 'ame-ko-extensions', 'ame-jquery-form', 'jquery-ui-dialog', 'ame-ko-extensions',
) )
); );
......
...@@ -125,7 +125,7 @@ var AmeDashboardWidgetEditor = /** @class */ (function () { ...@@ -125,7 +125,7 @@ var AmeDashboardWidgetEditor = /** @class */ (function () {
AmeDashboardWidgetEditor.prototype.saveChanges = function () { AmeDashboardWidgetEditor.prototype.saveChanges = function () {
var settings = this.getCurrentSettings(); var settings = this.getCurrentSettings();
//Set the hidden form fields. //Set the hidden form fields.
this.widgetData(jQuery.toJSON(settings)); this.widgetData(JSON.stringify(settings));
this.widgetDataLength(this.widgetData().length); this.widgetDataLength(this.widgetData().length);
//Submit the form. //Submit the form.
return true; return true;
...@@ -158,7 +158,7 @@ var AmeDashboardWidgetEditor = /** @class */ (function () { ...@@ -158,7 +158,7 @@ var AmeDashboardWidgetEditor = /** @class */ (function () {
var _this = this; var _this = this;
//Temporarily disable the export button to prevent accidental repeated clicks. //Temporarily disable the export button to prevent accidental repeated clicks.
this.isExportButtonEnabled(false); this.isExportButtonEnabled(false);
this.widgetData(jQuery.toJSON(this.getCurrentSettings())); this.widgetData(JSON.stringify(this.getCurrentSettings()));
//Re-enable the export button after a few seconds. //Re-enable the export button after a few seconds.
window.setTimeout(function () { window.setTimeout(function () {
_this.isExportButtonEnabled(true); _this.isExportButtonEnabled(true);
...@@ -246,7 +246,7 @@ var AmeDashboardWidgetEditor = /** @class */ (function () { ...@@ -246,7 +246,7 @@ var AmeDashboardWidgetEditor = /** @class */ (function () {
handleUnexpectedImportError(xhr, errorMessage); handleUnexpectedImportError(xhr, errorMessage);
} }
}); });
this.importDialog.find('#ame-cancel-widget-import').click(function () { this.importDialog.find('#ame-cancel-widget-import').on('click', function () {
_this.importDialog.dialog('close'); _this.importDialog.dialog('close');
}); });
}; };
......
...@@ -190,7 +190,7 @@ class AmeDashboardWidgetEditor { ...@@ -190,7 +190,7 @@ class AmeDashboardWidgetEditor {
let settings = this.getCurrentSettings(); let settings = this.getCurrentSettings();
//Set the hidden form fields. //Set the hidden form fields.
this.widgetData(jQuery.toJSON(settings)); this.widgetData(JSON.stringify(settings));
this.widgetDataLength(this.widgetData().length); this.widgetDataLength(this.widgetData().length);
//Submit the form. //Submit the form.
...@@ -229,7 +229,7 @@ class AmeDashboardWidgetEditor { ...@@ -229,7 +229,7 @@ class AmeDashboardWidgetEditor {
//Temporarily disable the export button to prevent accidental repeated clicks. //Temporarily disable the export button to prevent accidental repeated clicks.
this.isExportButtonEnabled(false); this.isExportButtonEnabled(false);
this.widgetData(jQuery.toJSON(this.getCurrentSettings())); this.widgetData(JSON.stringify(this.getCurrentSettings()));
//Re-enable the export button after a few seconds. //Re-enable the export button after a few seconds.
window.setTimeout(() => { window.setTimeout(() => {
...@@ -334,7 +334,7 @@ class AmeDashboardWidgetEditor { ...@@ -334,7 +334,7 @@ class AmeDashboardWidgetEditor {
} }
}); });
this.importDialog.find('#ame-cancel-widget-import').click(() => { this.importDialog.find('#ame-cancel-widget-import').on('click', () => {
this.importDialog.dialog('close'); this.importDialog.dialog('close');
}); });
} }
......
...@@ -10,6 +10,8 @@ var __extends = (this && this.__extends) || (function () { ...@@ -10,6 +10,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b); return extendStatics(d, b);
}; };
return function (d, b) { return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b); extendStatics(d, b);
function __() { this.constructor = d; } function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
......
...@@ -62,6 +62,13 @@ class ameMetaBoxCollection { ...@@ -62,6 +62,13 @@ class ameMetaBoxCollection {