mirror of
https://ghproxy.net/https://github.com/AlxMedia/curver.git
synced 2025-08-28 18:39:44 +08:00
Update to Kirki 4.2.0
This commit is contained in:
parent
cbfd4f27e4
commit
77ecd4ca69
440 changed files with 6230 additions and 5211 deletions
21
functions/kirki/kirki-packages/control-sortable/LICENSE
Normal file
21
functions/kirki/kirki-packages/control-sortable/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 kirki-framework
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
2
functions/kirki/kirki-packages/control-sortable/dist/control.css
vendored
Normal file
2
functions/kirki/kirki-packages/control-sortable/dist/control.css
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
.customize-control-kirki-sortable ul.ui-sortable li{background:#fff;border:1px solid #333;padding:5px 10px}.customize-control-kirki-sortable ul.ui-sortable li .dashicons.dashicons-menu{float:right}.customize-control-kirki-sortable ul.ui-sortable li .dashicons.visibility{margin-right:10px}.customize-control-kirki-sortable ul.ui-sortable li.invisible{border:1px dashed #aaa;color:#aaa}.customize-control-kirki-sortable ul.ui-sortable li.invisible .dashicons.visibility{color:#aaa}
|
||||
/*# sourceMappingURL=control.css.map */
|
1
functions/kirki/kirki-packages/control-sortable/dist/control.css.map
vendored
Normal file
1
functions/kirki/kirki-packages/control-sortable/dist/control.css.map
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"mappings":"AAEI,oDAGE,eAAA,CADA,qBAAA,CADA,gBCCN,CDIQ,8EACE,WCFV,CDKQ,0EACE,iBCHV,CDOM,8DAEE,sBAAA,CADA,UCJR,CDOQ,oFACE,UCLV","sources":["src/control.scss","%3Cinput%20css%20lYUSJ4%3E"],"sourcesContent":[".customize-control-kirki-sortable {\r\n ul.ui-sortable {\r\n li {\r\n padding: 5px 10px;\r\n border: 1px solid #333;\r\n background: #fff;\r\n\r\n .dashicons {\r\n &.dashicons-menu {\r\n float: right;\r\n }\r\n\r\n &.visibility {\r\n margin-right: 10px;\r\n }\r\n }\r\n\r\n &.invisible {\r\n color: #aaa;\r\n border: 1px dashed #aaa;\r\n\r\n .dashicons.visibility {\r\n color: #aaa;\r\n }\r\n }\r\n }\r\n }\r\n}\r\n",".customize-control-kirki-sortable ul.ui-sortable li {\n padding: 5px 10px;\n border: 1px solid #333;\n background: #fff;\n}\n.customize-control-kirki-sortable ul.ui-sortable li .dashicons.dashicons-menu {\n float: right;\n}\n.customize-control-kirki-sortable ul.ui-sortable li .dashicons.visibility {\n margin-right: 10px;\n}\n.customize-control-kirki-sortable ul.ui-sortable li.invisible {\n color: #aaa;\n border: 1px dashed #aaa;\n}\n.customize-control-kirki-sortable ul.ui-sortable li.invisible .dashicons.visibility {\n color: #aaa;\n}\n/*# sourceMappingURL=control.css.map */\n"],"names":[],"version":3,"file":"control.css.map"}
|
2
functions/kirki/kirki-packages/control-sortable/dist/control.js
vendored
Normal file
2
functions/kirki/kirki-packages/control-sortable/dist/control.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
wp.customize.controlConstructor["kirki-sortable"]=wp.customize.Control.extend({ready:function(){var i=this;jQuery(i.container.find("ul.sortable").first()).sortable({update:function(){i.setting.set(i.getNewVal())}}).disableSelection().find("li").each((function(){jQuery(this).find("i.visibility").click((function(){jQuery(this).toggleClass("dashicons-visibility-faint").parents("li:eq(0)").toggleClass("invisible")}))})).click((function(){i.setting.set(i.getNewVal())}))},getNewVal:function(){var i=jQuery(this.container.find("li")),t=[];return _.each(i,(function(i){jQuery(i).hasClass("invisible")||t.push(jQuery(i).data("value"))})),t}});
|
||||
//# sourceMappingURL=control.js.map
|
1
functions/kirki/kirki-packages/control-sortable/dist/control.js.map
vendored
Normal file
1
functions/kirki/kirki-packages/control-sortable/dist/control.js.map
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"mappings":"AAEAA,GAAGC,UAAUC,mBAAkB,kBAAqBF,GAAGC,UAAUE,QAAQC,OAAM,CAG9EC,MAAK,WAEJ,IAAIC,EAAOC,KAGXC,OAAQF,EAAQG,UAAUC,KAAI,eAAkBC,SAAUC,SAAQ,CAGjEC,OAAM,WACLP,EAAQQ,QAAQC,IAAKT,EAAQU,gBAE5BC,mBAAmBP,KAAI,MAASQ,MAAI,WAGtCV,OAAMD,MAASG,KAAI,gBAAmBS,OAAK,WAC1CX,OAAMD,MAASa,YAAW,8BAAiCC,QAAO,YAAeD,YAAW,mBAE3FD,OAAK,WAGPb,EAAQQ,QAAQC,IAAKT,EAAQU,iBAU/BA,UAAS,WACR,IAAIM,EAASd,OAAMD,KAAOE,UAAUC,KAAI,OACvCa,EAAM,UACPC,EAAEN,KAAMI,GAAK,SAAYG,GACjBjB,OAAQiB,GAAOC,SAAQ,cAC7BH,EAAOI,KAAMnB,OAAQiB,GAAOG,KAAI,aAG3BL","sources":["src/control.js"],"sourcesContent":["import \"./control.scss\";\n\nwp.customize.controlConstructor['kirki-sortable'] = wp.customize.Control.extend({\n\n\t// When we're finished loading continue processing\n\tready: function() {\n\n\t\tvar control = this;\n\n\t\t// Init sortable.\n\t\tjQuery( control.container.find( 'ul.sortable' ).first() ).sortable({\n\n\t\t\t// Update value when we stop sorting.\n\t\t\tupdate: function() {\n\t\t\t\tcontrol.setting.set( control.getNewVal() );\n\t\t\t}\n\t\t}).disableSelection().find( 'li' ).each( function() {\n\n\t\t\t// Enable/disable options when we click on the eye of Thundera.\n\t\t\tjQuery( this ).find( 'i.visibility' ).click( function() {\n\t\t\t\tjQuery( this ).toggleClass( 'dashicons-visibility-faint' ).parents( 'li:eq(0)' ).toggleClass( 'invisible' );\n\t\t\t});\n\t\t}).click( function() {\n\n\t\t\t// Update value on click.\n\t\t\tcontrol.setting.set( control.getNewVal() );\n\t\t});\n\t},\n\n\t/**\n\t * Getss thhe new vvalue.\n\t *\n\t * @since 3.0.35\n\t * @returns {Array} - Returns the value as an array.\n\t */\n\tgetNewVal: function() {\n\t\tvar items = jQuery( this.container.find( 'li' ) ),\n\t\t\tnewVal = [];\n\t\t_.each( items, function( item ) {\n\t\t\tif ( ! jQuery( item ).hasClass( 'invisible' ) ) {\n\t\t\t\tnewVal.push( jQuery( item ).data( 'value' ) );\n\t\t\t}\n\t\t});\n\t\treturn newVal;\n\t}\n});\n"],"names":["wp","customize","controlConstructor","Control","extend","ready","control","this","jQuery","container","find","first","sortable","update","setting","set","getNewVal","disableSelection","each","click","toggleClass","parents","items","newVal","_","item","hasClass","push","data"],"version":3,"file":"control.js.map"}
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
/**
|
||||
* Customizer Control: sortable.
|
||||
*
|
||||
* @package kirki-framework/control-sortable
|
||||
* @copyright Copyright (c) 2023, Themeum
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Control;
|
||||
|
||||
use Kirki\URL;
|
||||
use Kirki\Control\Base;
|
||||
|
||||
/**
|
||||
* Sortable control (uses checkboxes).
|
||||
*/
|
||||
class Sortable extends Base {
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-sortable';
|
||||
|
||||
/**
|
||||
* The version. Used in scripts & styles for cache-busting.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public static $control_ver = '1.0';
|
||||
|
||||
/**
|
||||
* Enqueue control related scripts/styles.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
parent::enqueue();
|
||||
|
||||
// Enqueue the script.
|
||||
wp_enqueue_script( 'kirki-control-sortable', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base' ], self::$control_ver, false );
|
||||
|
||||
// Enqueue the style.
|
||||
wp_enqueue_style( 'kirki-control-sortable-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver );
|
||||
}
|
||||
|
||||
/**
|
||||
* An Underscore (JS) template for this control's content (but not its container).
|
||||
*
|
||||
* Class variables for this control class are available in the `data` JS object;
|
||||
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
|
||||
*
|
||||
* @see WP_Customize_Control::print_template()
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
protected function content_template() {
|
||||
?>
|
||||
<label class='kirki-sortable'>
|
||||
<span class="customize-control-title">
|
||||
{{{ data.label }}}
|
||||
</span>
|
||||
<# if ( data.description ) { #>
|
||||
<span class="description customize-control-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
|
||||
<ul class="sortable">
|
||||
<# _.each( data.value, function( choiceID ) { #>
|
||||
<# if ( data.choices[ choiceID ] ) { #>
|
||||
<li {{{ data.inputAttrs }}} class='kirki-sortable-item' data-value='{{ choiceID }}'>
|
||||
<i class='dashicons dashicons-menu'></i>
|
||||
<i class="dashicons dashicons-visibility visibility"></i>
|
||||
{{{ data.choices[ choiceID ] }}}
|
||||
</li>
|
||||
<# } #>
|
||||
<# }); #>
|
||||
<# _.each( data.choices, function( choiceLabel, choiceID ) { #>
|
||||
<# if ( -1 === data.value.indexOf( choiceID ) ) { #>
|
||||
<li {{{ data.inputAttrs }}} class='kirki-sortable-item invisible' data-value='{{ choiceID }}'>
|
||||
<i class='dashicons dashicons-menu'></i>
|
||||
<i class="dashicons dashicons-visibility visibility"></i>
|
||||
{{{ data.choices[ choiceID ] }}}
|
||||
</li>
|
||||
<# } #>
|
||||
<# }); #>
|
||||
</ul>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/**
|
||||
* Override field methods
|
||||
*
|
||||
* @package kirki-framework/control-sortable
|
||||
* @copyright Copyright (c) 2023, Themeum
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Field;
|
||||
|
||||
use Kirki\Field;
|
||||
|
||||
/**
|
||||
* Field overrides.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Sortable extends Field {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-sortable';
|
||||
|
||||
/**
|
||||
* The control class-name.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var string
|
||||
*/
|
||||
protected $control_class = '\Kirki\Control\Sortable';
|
||||
|
||||
/**
|
||||
* Whether we should register the control class for JS-templating or not.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var bool
|
||||
*/
|
||||
protected $control_has_js_template = true;
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the setting.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @param array $args The field arguments.
|
||||
* @param WP_Customize_Manager $wp_customize The customizer instance.
|
||||
* @return array
|
||||
*/
|
||||
public function filter_setting_args( $args, $wp_customize ) {
|
||||
if ( $args['settings'] === $this->args['settings'] ) {
|
||||
$args = parent::filter_setting_args( $args, $wp_customize );
|
||||
|
||||
// Set the sanitize-callback if none is defined.
|
||||
if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) {
|
||||
$args['sanitize_callback'] = [ $this, 'sanitize' ];
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the control.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @param array $args The field arguments.
|
||||
* @param WP_Customize_Manager $wp_customize The customizer instance.
|
||||
* @return array
|
||||
*/
|
||||
public function filter_control_args( $args, $wp_customize ) {
|
||||
if ( $args['settings'] === $this->args['settings'] ) {
|
||||
$args = parent::filter_control_args( $args, $wp_customize );
|
||||
$args['type'] = 'kirki-sortable';
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes sortable values.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @param array $value The checkbox value.
|
||||
* @return array
|
||||
*/
|
||||
public function sanitize( $value = [] ) {
|
||||
$value = (array) $value;
|
||||
|
||||
foreach ( $value as $key => $sub_value ) {
|
||||
$value[ $key ] = sanitize_text_field( $sub_value );
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
import "./control.scss";
|
||||
|
||||
wp.customize.controlConstructor['kirki-sortable'] = wp.customize.Control.extend({
|
||||
|
||||
// When we're finished loading continue processing
|
||||
ready: function() {
|
||||
|
||||
var control = this;
|
||||
|
||||
// Init sortable.
|
||||
jQuery( control.container.find( 'ul.sortable' ).first() ).sortable({
|
||||
|
||||
// Update value when we stop sorting.
|
||||
update: function() {
|
||||
control.setting.set( control.getNewVal() );
|
||||
}
|
||||
}).disableSelection().find( 'li' ).each( function() {
|
||||
|
||||
// Enable/disable options when we click on the eye of Thundera.
|
||||
jQuery( this ).find( 'i.visibility' ).click( function() {
|
||||
jQuery( this ).toggleClass( 'dashicons-visibility-faint' ).parents( 'li:eq(0)' ).toggleClass( 'invisible' );
|
||||
});
|
||||
}).click( function() {
|
||||
|
||||
// Update value on click.
|
||||
control.setting.set( control.getNewVal() );
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Getss thhe new vvalue.
|
||||
*
|
||||
* @since 3.0.35
|
||||
* @returns {Array} - Returns the value as an array.
|
||||
*/
|
||||
getNewVal: function() {
|
||||
var items = jQuery( this.container.find( 'li' ) ),
|
||||
newVal = [];
|
||||
_.each( items, function( item ) {
|
||||
if ( ! jQuery( item ).hasClass( 'invisible' ) ) {
|
||||
newVal.push( jQuery( item ).data( 'value' ) );
|
||||
}
|
||||
});
|
||||
return newVal;
|
||||
}
|
||||
});
|
|
@ -0,0 +1,28 @@
|
|||
.customize-control-kirki-sortable {
|
||||
ul.ui-sortable {
|
||||
li {
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #333;
|
||||
background: #fff;
|
||||
|
||||
.dashicons {
|
||||
&.dashicons-menu {
|
||||
float: right;
|
||||
}
|
||||
|
||||
&.visibility {
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
&.invisible {
|
||||
color: #aaa;
|
||||
border: 1px dashed #aaa;
|
||||
|
||||
.dashicons.visibility {
|
||||
color: #aaa;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue