mirror of
https://github.com/processwire/processwire.git
synced 2025-08-10 16:54:44 +02:00
Add PR #169 which adds alternate behavior option for Inputfield labels as open/close toggles (currently AdminThemeUikit setting)
This commit is contained in:
committed by
Ryan Cramer
parent
32150bd4b7
commit
2911a16604
@@ -19,6 +19,7 @@
|
||||
* @property bool|int $groupNotices Whether or not notices should be grouped by type
|
||||
* @property string $inputSize Size for input/select elements. One of "s" for small, "m" for medium (default), or "l" for large.
|
||||
* @property bool|int $ukGrid When true, use uk-width classes for Inputfields (rather than CSS percentages).
|
||||
* @property int $toggleBehavior (0=Standard, 1=Consistent)
|
||||
*
|
||||
* @method string getUikitCSS()
|
||||
*
|
||||
@@ -78,6 +79,7 @@ class AdminThemeUikit extends AdminThemeFramework implements Module, Configurabl
|
||||
$this->set('layout', '');
|
||||
$this->set('noBorderTypes', array()); // 'InputfieldCKEditor' is a good one for this
|
||||
$this->set('logoAction', 0);
|
||||
$this->set('toggleBehavior', 0);
|
||||
$this->set('userLabel', '{Name}');
|
||||
$this->set('userAvatar', 'icon.user-circle');
|
||||
$this->set('maxWidth', 1600);
|
||||
@@ -1091,11 +1093,13 @@ class AdminThemeUikit extends AdminThemeFramework implements Module, Configurabl
|
||||
*
|
||||
*/
|
||||
public function getHeadJS() {
|
||||
|
||||
$data = $this->wire('config')->js('adminTheme');
|
||||
|
||||
$config = $this->wire()->config;
|
||||
$data = $config->js('adminTheme');
|
||||
if(!is_array($data)) $data = array();
|
||||
$data['logoAction'] = (int) $this->logoAction;
|
||||
$this->wire('config')->js('adminTheme', $data);
|
||||
$data['toggleBehavior'] = (int) $this->toggleBehavior;
|
||||
$config->js('adminTheme', $data);
|
||||
|
||||
return parent::getHeadJS();
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ if(!defined("PROCESSWIRE")) die();
|
||||
/** @var Paths $urls */
|
||||
/** @var string $layout */
|
||||
|
||||
$version = $adminTheme->version . 'e';
|
||||
$version = $adminTheme->version . 'f';
|
||||
$rootUrl = $config->urls->root;
|
||||
$themeUrl = $adminTheme->url();
|
||||
$styles = $config->styles;
|
||||
|
@@ -320,7 +320,25 @@ class AdminThemeUikitConfigHelper extends Wire {
|
||||
}
|
||||
$f->attr('value', $adminTheme->offsetTypes);
|
||||
$fieldset->add($f);
|
||||
|
||||
|
||||
/** @var InputfieldRadios $f */
|
||||
$f = $modules->get('InputfieldRadios');
|
||||
$f->attr('name', 'toggleBehavior');
|
||||
$f->label = $this->_('Inputfield label toggle behavior');
|
||||
$f->icon = 'eye-slash';
|
||||
$f->description =
|
||||
$this->_('Inputfield elements in ProcessWire can have an open or closed state.') . ' ' .
|
||||
$this->_('This setting determines what happens when a user clicks any Inputfield label, which appears as a header above the input.') . ' ' .
|
||||
$this->_('The “Standard” option makes a click of a label on an open Inputfield focus the input element, a standard HTML form behavior.') . ' ' .
|
||||
$this->_('While a click of a closed Inputfield label will open and then focus the Inputfield (and close it when clicked again).') . ' ' .
|
||||
$this->_('The “Consistent” option makes the Inputfield label always behave consistently as an open/close toggle, regardless of what state the Inputfield is in.');
|
||||
$f->notes = $this->_('Regardless of what setting you choose, the toggle icon in the upper right of each Inputfield always toggles the open/closed state.');
|
||||
$f->addOption(0, $this->_('Standard'));
|
||||
$f->addOption(1, $this->_('Consistent'));
|
||||
$f->optionColumns = 1;
|
||||
$f->val($adminTheme->toggleBehavior);
|
||||
$fieldset->add($f);
|
||||
|
||||
/** @var InputfieldCheckboxes $f */
|
||||
/*
|
||||
$f = $modules->get('InputfieldCheckbox');
|
||||
|
@@ -840,6 +840,7 @@ var ProcessWireAdminTheme = {
|
||||
});
|
||||
|
||||
$('body').addClass('InputfieldColumnWidthsInit');
|
||||
Inputfields.toggleBehavior = ProcessWire.config.adminTheme.toggleBehavior;
|
||||
initFormMarkup();
|
||||
},
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@@ -148,7 +148,13 @@ var Inputfields = {
|
||||
* Are we currently toggling collapsed state or visibility?
|
||||
*
|
||||
*/
|
||||
toggling: false,
|
||||
toggling: false,
|
||||
|
||||
/**
|
||||
* Toggle behavior (0=standard, 1=consistent)
|
||||
*
|
||||
*/
|
||||
toggleBehavior: 0,
|
||||
|
||||
/**
|
||||
* Default duration (in MS) for certain visual animations
|
||||
@@ -308,6 +314,28 @@ var Inputfields = {
|
||||
return $inputfield;
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle all given $inputfields open or closed
|
||||
*
|
||||
* Also triggers these events on each $inputfield: openReady, closeReady, opened, closed
|
||||
*
|
||||
* @param object $inputfields jQuery object of one or more Inputfields or selector string that matches Inputfields
|
||||
* @param bool open Boolean true to open, false to close, or null (or omit) for opposite of current state (default=opposite of current state)
|
||||
* @param int duration How many milliseconds for animation? (default=100)
|
||||
* @param function callback Optional function to call upon completion, receives Inputfield object, open and duration as arguments (default=none)
|
||||
* @returns Returns jQuery object of Inputfields
|
||||
* @since 3.0.178
|
||||
*
|
||||
*/
|
||||
toggleAll: function($inputfields, open, duration, callback) {
|
||||
if(typeof $inputfields === "string") $inputfields = jQuery($inputfields);
|
||||
var Inputfields = this;
|
||||
$($inputfields.get().reverse()).each(function(i, el) {
|
||||
Inputfields.toggle($(el), open, duration, callback);
|
||||
});
|
||||
return $inputfields;
|
||||
},
|
||||
|
||||
/**
|
||||
* Open a collapsed Inputfield
|
||||
*
|
||||
@@ -2028,7 +2056,7 @@ function InputfieldStates($target) {
|
||||
});
|
||||
if(isTab) {
|
||||
$header.effect('highlight', 500);
|
||||
} else {
|
||||
} else if(Inputfields.toggleBehavior < 1) {
|
||||
$header.click();
|
||||
}
|
||||
}, 500);
|
||||
@@ -2085,6 +2113,7 @@ function InputfieldStates($target) {
|
||||
var isCollapsed = $li.hasClass("InputfieldStateCollapsed");
|
||||
var wasCollapsed = $li.hasClass("InputfieldStateWasCollapsed");
|
||||
var duration = 100;
|
||||
var isAjax = $li.hasClass('collapsed10') || $li.hasClass('collapsed11');
|
||||
|
||||
if(!$li.length) return;
|
||||
if($li.hasClass('InputfieldAjaxLoading')) return false;
|
||||
@@ -2094,13 +2123,16 @@ function InputfieldStates($target) {
|
||||
if(typeof data.duration != "undefined") duration = data.duration;
|
||||
}
|
||||
|
||||
if(isCollapsed && ($li.hasClass('collapsed10') || $li.hasClass('collapsed11'))) {
|
||||
if(isCollapsed && isAjax) {
|
||||
if(InputfieldStateAjaxClick($li)) return false;
|
||||
}
|
||||
|
||||
if(isCollapsed || wasCollapsed || isIcon) {
|
||||
$li.addClass('InputfieldStateWasCollapsed'); // this class only used here
|
||||
Inputfields.toggle($li, null, duration);
|
||||
} else if(Inputfields.toggleBehavior === 1) {
|
||||
// open/close implied by header label click
|
||||
$icon.click();
|
||||
} else {
|
||||
// Inputfield not collapsible unless toggle icon clicked, so pulsate the toggle icon and focus any inputs
|
||||
if(typeof jQuery.ui != 'undefined') {
|
||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user