Version Description
- Modified custom display check when rendering Ditty
- Resolved current Item(s) bug in Ditty Editor
- Resolved current Item Type bug in Ditty Editor
- Modified Default Post Layout and increased version number
- Added init trigger for Ditty_Item_Editor_Panel js file
- Removed jQuery document ready in all js files
- Added link options to Posts Feed Lite
- Added content options to Posts Feed Lite
- Radio field update
- Asset loading optimization
- Added file field type
- Added item_value to layout tag filters
- Removed auto-draft checks
- Customized plugin updater file and references
- Resolved bug in extension updater
Download this release
Release Info
Developer | metaphorcreations |
Plugin | Ditty News Ticker |
Version | 3.0.12 |
Comparing to | |
See all releases |
Code changes from version 3.0.11 to 3.0.12
- ditty-news-ticker.php +2 -2
- includes/admin/{EDD_SL_Plugin_Updater.php → Ditty_Plugin_Updater.php} +2 -2
- includes/class-ditty-extensions.php +8 -5
- includes/class-ditty-item-type-posts-lite.php +105 -4
- includes/class-ditty-item.php +1 -17
- includes/class-ditty-items.php +1 -1
- includes/class-ditty-layout.php +14 -14
- includes/class-ditty-layouts.php +4 -3
- includes/class-ditty-singles.php +18 -17
- includes/class-ditty.php +76 -67
- includes/css/ditty-admin.css +18 -0
- includes/css/ditty.css +10 -2
- includes/fields/ditty-field-file.php +56 -0
- includes/fields/ditty-field-radio.php +3 -3
- includes/fields/helpers.php +4 -1
- includes/fields/js/ditty-fields.js +1 -0
- includes/fields/js/ditty-fields.min.js +89 -8
- includes/fields/js/fields/clone.js +1 -1
- includes/fields/js/fields/code.js +1 -1
- includes/fields/js/fields/color.js +1 -1
- includes/fields/js/fields/date.js +1 -1
- includes/fields/js/fields/file.js +79 -0
- includes/fields/js/fields/group.js +1 -1
- includes/fields/js/fields/image.js +1 -1
- includes/fields/js/fields/slider.js +1 -1
- includes/fields/js/fields/wysiwyg.js +1 -1
- includes/helpers.php +6 -6
- includes/js/admin/ditty-displays.js +1 -1
- includes/js/admin/ditty-extensions.js +1 -1
- includes/js/ditty-admin.js +1 -1
- includes/js/ditty-admin.min.js +888 -1
- includes/js/ditty-editor.js +4 -7
- includes/js/ditty-editor.min.js +3 -3
- includes/js/ditty.js +1 -1
- includes/js/ditty.min.js +1 -1
- includes/js/editor/class-ditty-item-editor-panel.js +8 -2
- includes/js/editor/class-ditty-item-types-panel.js +2 -3
- includes/js/editor/class-ditty-items-panel.js +2 -2
- includes/js/editor/class-ditty-layout-variations-panel.js +3 -2
- includes/js/editor/ditty-item-edit-editor.js +38 -0
- includes/js/editor/ditty-list-display-editor.js +1 -1
- includes/js/editor/ditty-ticker-display-editor.js +1 -1
- includes/layout-tag-helpers.php +9 -5
- includes/layout-tag-hooks-posts.php +31 -15
- includes/layout-tag-hooks.php +5 -3
- includes/layout-tags.php +3 -3
- includes/layout-templates.php +6 -3
- includes/sass/admin/_fields.scss +21 -0
- includes/sass/editor/_editor.scss +14 -2
- languages/ditty-news-ticker.pot +7 -7
- legacy/eddsl/eddsl.php +4 -4
- legacy/inc/static.php +2 -2
- legacy/inc/static/js/partials/admin-general.js +1 -1
- legacy/inc/static/js/script-admin.min.js +752 -1
- readme.txt +19 -2
- vendor/composer/InstalledVersions.php +8 -8
- vendor/composer/installed.json +15 -15
- vendor/composer/installed.php +8 -8
- vendor/scssphp/scssphp/bin/pscss +2 -2
- vendor/scssphp/scssphp/composer.json +13 -10
- vendor/scssphp/scssphp/src/Base/Range.php +4 -4
- vendor/scssphp/scssphp/src/Block.php +6 -6
- vendor/scssphp/scssphp/src/Block/AtRootBlock.php +37 -0
- vendor/scssphp/scssphp/src/Block/CallableBlock.php +45 -0
- vendor/scssphp/scssphp/src/Block/ContentBlock.php +38 -0
- vendor/scssphp/scssphp/src/Block/DirectiveBlock.php +37 -0
- vendor/scssphp/scssphp/src/Block/EachBlock.php +37 -0
- vendor/scssphp/scssphp/src/Block/ElseBlock.php +27 -0
- vendor/scssphp/scssphp/src/Block/ElseifBlock.php +32 -0
- vendor/scssphp/scssphp/src/Block/ForBlock.php +47 -0
- vendor/scssphp/scssphp/src/Block/IfBlock.php +37 -0
- vendor/scssphp/scssphp/src/Block/MediaBlock.php +37 -0
- vendor/scssphp/scssphp/src/Block/NestedPropertyBlock.php +37 -0
- vendor/scssphp/scssphp/src/Block/WhileBlock.php +32 -0
- vendor/scssphp/scssphp/src/Colors.php +4 -4
- vendor/scssphp/scssphp/src/Compiler.php +191 -106
- vendor/scssphp/scssphp/src/Compiler/Environment.php +21 -1
- vendor/scssphp/scssphp/src/Formatter.php +5 -5
- vendor/scssphp/scssphp/src/Formatter/Compressed.php +0 -2
- vendor/scssphp/scssphp/src/Formatter/Nested.php +2 -2
- vendor/scssphp/scssphp/src/Formatter/OutputBlock.php +3 -3
- vendor/scssphp/scssphp/src/Node.php +1 -1
- vendor/scssphp/scssphp/src/Node/Number.php +8 -8
- vendor/scssphp/scssphp/src/Parser.php +168 -120
- vendor/scssphp/scssphp/src/SourceMap/Base64.php +2 -2
- vendor/scssphp/scssphp/src/SourceMap/Base64VLQ.php +7 -7
- vendor/scssphp/scssphp/src/SourceMap/SourceMapGenerator.php +8 -8
- vendor/scssphp/scssphp/src/Type.php +135 -3
- vendor/scssphp/scssphp/src/Util.php +1 -1
- vendor/scssphp/scssphp/src/Version.php +1 -1
- vendor/thunderer/shortcode/.github/workflows/test.yaml +47 -0
- vendor/thunderer/shortcode/.gitignore +2 -0
- vendor/thunderer/shortcode/.symfony.insight.yaml +0 -4
- vendor/thunderer/shortcode/.travis.yml +0 -34
- vendor/thunderer/shortcode/LICENSE +1 -1
- vendor/thunderer/shortcode/Makefile +57 -10
- vendor/thunderer/shortcode/README.md +7 -9
- vendor/thunderer/shortcode/docker-compose.yaml +15 -15
- vendor/thunderer/shortcode/docker/php-5.4/Dockerfile +0 -3
- vendor/thunderer/shortcode/docker/php-5.x/Dockerfile +11 -0
- vendor/thunderer/shortcode/docker/php/Dockerfile +12 -0
- vendor/thunderer/shortcode/docker/php/php.ini +1 -0
- vendor/thunderer/shortcode/infection.json +12 -0
- vendor/thunderer/shortcode/phpunit.xml.dist +11 -11
- vendor/thunderer/shortcode/psalm.xml +19 -0
- vendor/thunderer/shortcode/src/Event/FilterShortcodesEvent.php +16 -4
- vendor/thunderer/shortcode/src/Event/ReplaceShortcodesEvent.php +24 -1
- vendor/thunderer/shortcode/src/EventContainer/EventContainer.php +17 -0
- vendor/thunderer/shortcode/src/EventHandler/ReplaceJoinEventHandler.php +2 -1
- vendor/thunderer/shortcode/src/Events.php +1 -0
- vendor/thunderer/shortcode/src/Handler/DeclareHandler.php +4 -1
- vendor/thunderer/shortcode/src/Handler/EmailHandler.php +1 -1
- vendor/thunderer/shortcode/src/Handler/PlaceholderHandler.php +4 -1
- vendor/thunderer/shortcode/src/Handler/UrlHandler.php +1 -1
- vendor/thunderer/shortcode/src/Handler/WrapHandler.php +8 -1
- vendor/thunderer/shortcode/src/HandlerContainer/HandlerContainer.php +48 -5
- vendor/thunderer/shortcode/src/HandlerContainer/HandlerContainerInterface.php +3 -0
- vendor/thunderer/shortcode/src/HandlerContainer/ImmutableHandlerContainer.php +9 -0
- vendor/thunderer/shortcode/src/Parser/RegexParser.php +31 -0
- vendor/thunderer/shortcode/src/Parser/RegularParser.php +67 -9
- vendor/thunderer/shortcode/src/Parser/WordpressParser.php +22 -3
- vendor/thunderer/shortcode/src/Processor/Processor.php +41 -12
- vendor/thunderer/shortcode/src/Processor/ProcessorContext.php +33 -4
- vendor/thunderer/shortcode/src/Serializer/JsonSerializer.php +3 -0
- vendor/thunderer/shortcode/src/Serializer/SerializerInterface.php +1 -1
- vendor/thunderer/shortcode/src/Serializer/TextSerializer.php +14 -2
- vendor/thunderer/shortcode/src/Serializer/XmlSerializer.php +26 -2
- vendor/thunderer/shortcode/src/Serializer/YamlSerializer.php +4 -1
- vendor/thunderer/shortcode/src/Shortcode/AbstractShortcode.php +26 -0
- vendor/thunderer/shortcode/src/Shortcode/ParsedShortcode.php +8 -0
- vendor/thunderer/shortcode/src/Shortcode/ProcessedShortcode.php +52 -24
- vendor/thunderer/shortcode/src/Shortcode/ReplacedShortcode.php +7 -0
- vendor/thunderer/shortcode/src/Shortcode/Shortcode.php +9 -0
- vendor/thunderer/shortcode/src/Shortcode/ShortcodeInterface.php +2 -1
- vendor/thunderer/shortcode/src/ShortcodeFacade.php +70 -5
- vendor/thunderer/shortcode/src/Syntax/CommonSyntax.php +5 -0
- vendor/thunderer/shortcode/src/Syntax/Syntax.php +17 -0
- vendor/thunderer/shortcode/src/Syntax/SyntaxBuilder.php +31 -0
- vendor/thunderer/shortcode/src/Syntax/SyntaxInterface.php +5 -0
- vendor/thunderer/shortcode/src/Utility/RegexBuilderUtility.php +10 -0
ditty-news-ticker.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Ditty (formerly Ditty News Ticker)
|
5 |
* Plugin URI: https://www.metaphorcreations.com/ditty
|
6 |
* Description: Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
|
7 |
-
* Version: 3.0.
|
8 |
* Author: Metaphor Creations
|
9 |
* Author URI: https://www.metaphorcreations.com
|
10 |
* License: GPL-2.0+
|
@@ -20,7 +20,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
20 |
|
21 |
// Plugin version.
|
22 |
if ( ! defined( 'DITTY_VERSION' ) ) {
|
23 |
-
define( 'DITTY_VERSION', '3.0.
|
24 |
}
|
25 |
|
26 |
// Plugin Folder Path.
|
4 |
* Plugin Name: Ditty (formerly Ditty News Ticker)
|
5 |
* Plugin URI: https://www.metaphorcreations.com/ditty
|
6 |
* Description: Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
|
7 |
+
* Version: 3.0.12
|
8 |
* Author: Metaphor Creations
|
9 |
* Author URI: https://www.metaphorcreations.com
|
10 |
* License: GPL-2.0+
|
20 |
|
21 |
// Plugin version.
|
22 |
if ( ! defined( 'DITTY_VERSION' ) ) {
|
23 |
+
define( 'DITTY_VERSION', '3.0.12' );
|
24 |
}
|
25 |
|
26 |
// Plugin Folder Path.
|
includes/admin/{EDD_SL_Plugin_Updater.php → Ditty_Plugin_Updater.php}
RENAMED
@@ -11,7 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
11 |
* @author Easy Digital Downloads
|
12 |
* @version 1.9.1
|
13 |
*/
|
14 |
-
class
|
15 |
|
16 |
private $api_url = '';
|
17 |
private $api_data = array();
|
@@ -457,7 +457,7 @@ class EDD_SL_Plugin_Updater {
|
|
457 |
* will be allowed again. This way if the site is down for some reason we don't bombard
|
458 |
* it with failed API requests.
|
459 |
*
|
460 |
-
* @see
|
461 |
*
|
462 |
* @since 1.9.1
|
463 |
*/
|
11 |
* @author Easy Digital Downloads
|
12 |
* @version 1.9.1
|
13 |
*/
|
14 |
+
class Ditty_Plugin_Updater {
|
15 |
|
16 |
private $api_url = '';
|
17 |
private $api_data = array();
|
457 |
* will be allowed again. This way if the site is down for some reason we don't bombard
|
458 |
* it with failed API requests.
|
459 |
*
|
460 |
+
* @see Ditty_Plugin_Updater::request_recently_failed
|
461 |
*
|
462 |
* @since 1.9.1
|
463 |
*/
|
includes/class-ditty-extensions.php
CHANGED
@@ -56,12 +56,15 @@ class Ditty_Extensions {
|
|
56 |
/**
|
57 |
* Load all the extension updaters
|
58 |
* @access public
|
59 |
-
* @since 3.0
|
60 |
*/
|
61 |
public function add_extension_updaters() {
|
62 |
if ( wp_doing_ajax() ) {
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
65 |
$extension_licenses = ditty_extension_licenses();
|
66 |
$ditty_licenses = $this->licenses;
|
67 |
if ( is_array( $extension_licenses ) && count( $extension_licenses ) > 0 ) {
|
@@ -70,12 +73,12 @@ class Ditty_Extensions {
|
|
70 |
continue;
|
71 |
}
|
72 |
$license_key = isset( $ditty_licenses[$slug] ) ? trim( $ditty_licenses[$slug]['key'] ) : '';
|
73 |
-
$edd_updater = new
|
74 |
array(
|
75 |
'version' => $license_settings['version'], // current version number
|
76 |
'license' => $license_key, // license key (used get_option above to retrieve from DB)
|
77 |
'item_id' => $license_settings['item_id'], // ID of the product
|
78 |
-
'author' => isset( $license_settings['author'] ) ? $license_settings['author'] : __( 'Ditty
|
79 |
'beta' => false,
|
80 |
)
|
81 |
);
|
56 |
/**
|
57 |
* Load all the extension updaters
|
58 |
* @access public
|
59 |
+
* @since 3.0.12
|
60 |
*/
|
61 |
public function add_extension_updaters() {
|
62 |
if ( wp_doing_ajax() ) {
|
63 |
+
$action = isset( $_POST['action'] ) ? $_POST['action'] : false;
|
64 |
+
if ( 'update-plugin' != $action ) {
|
65 |
+
return false;
|
66 |
+
}
|
67 |
+
}
|
68 |
$extension_licenses = ditty_extension_licenses();
|
69 |
$ditty_licenses = $this->licenses;
|
70 |
if ( is_array( $extension_licenses ) && count( $extension_licenses ) > 0 ) {
|
73 |
continue;
|
74 |
}
|
75 |
$license_key = isset( $ditty_licenses[$slug] ) ? trim( $ditty_licenses[$slug]['key'] ) : '';
|
76 |
+
$edd_updater = new Ditty_Plugin_Updater( 'https://www.metaphorcreations.com', $license_settings['path'],
|
77 |
array(
|
78 |
'version' => $license_settings['version'], // current version number
|
79 |
'license' => $license_key, // license key (used get_option above to retrieve from DB)
|
80 |
'item_id' => $license_settings['item_id'], // ID of the product
|
81 |
+
'author' => isset( $license_settings['author'] ) ? $license_settings['author'] : __( 'Ditty', 'ditty-news-ticker' ), // author of this plugin
|
82 |
'beta' => false,
|
83 |
)
|
84 |
);
|
includes/class-ditty-item-type-posts-lite.php
CHANGED
@@ -58,7 +58,7 @@ class Ditty_Item_Type_Posts_Lite extends Ditty_Item_Type {
|
|
58 |
* Setup the type settings
|
59 |
*
|
60 |
* @access public
|
61 |
-
* @since 3.0
|
62 |
*/
|
63 |
public function fields( $values = array() ) {
|
64 |
$fields = array(
|
@@ -69,6 +69,99 @@ class Ditty_Item_Type_Posts_Lite extends Ditty_Item_Type {
|
|
69 |
'help' => __( 'Set the number of Posts to display.', 'ditty-news-ticker' ),
|
70 |
'std' => isset( $values['limit'] ) ? $values['limit'] : false,
|
71 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
);
|
73 |
return $fields;
|
74 |
}
|
@@ -77,11 +170,19 @@ class Ditty_Item_Type_Posts_Lite extends Ditty_Item_Type {
|
|
77 |
* Set the default field values
|
78 |
*
|
79 |
* @access public
|
80 |
-
* @since 3.0
|
81 |
*/
|
82 |
public function default_settings() {
|
83 |
$defaults = array(
|
84 |
-
'limit'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
);
|
86 |
return apply_filters( 'ditty_type_default_settings', $defaults, $this->slug );
|
87 |
}
|
@@ -90,7 +191,7 @@ class Ditty_Item_Type_Posts_Lite extends Ditty_Item_Type {
|
|
90 |
* Set the default layout variation types
|
91 |
*
|
92 |
* @access public
|
93 |
-
* @since 3.0
|
94 |
*/
|
95 |
public function get_layout_variation_types() {
|
96 |
$layout_variations = array(
|
58 |
* Setup the type settings
|
59 |
*
|
60 |
* @access public
|
61 |
+
* @since 3.0.12
|
62 |
*/
|
63 |
public function fields( $values = array() ) {
|
64 |
$fields = array(
|
69 |
'help' => __( 'Set the number of Posts to display.', 'ditty-news-ticker' ),
|
70 |
'std' => isset( $values['limit'] ) ? $values['limit'] : false,
|
71 |
),
|
72 |
+
// 'contentSettings' => array(
|
73 |
+
// 'type' => 'group',
|
74 |
+
// 'id' => 'contentSettings',
|
75 |
+
// 'collapsible' => true,
|
76 |
+
// 'default_state' => 'expanded',
|
77 |
+
// 'multiple_fields' => true,
|
78 |
+
// 'name' => __( 'Content Settings', 'ditty-news-ticker' ),
|
79 |
+
// 'help' => __( 'Configure the content settings for the feed items.', 'ditty-news-ticker' ),
|
80 |
+
// 'fields' => array(
|
81 |
+
// 'content_display' => array(
|
82 |
+
// 'type' => 'radio',
|
83 |
+
// 'id' => 'content_display',
|
84 |
+
// 'name' => __( 'Content Display', 'ditty-news-ticker' ),
|
85 |
+
// 'help' => __( 'Configure settings for the post content.', 'ditty-news-ticker' ),
|
86 |
+
// 'options' => array(
|
87 |
+
// 'full' => __( 'Full Content', 'ditty-news-ticker' ),
|
88 |
+
// 'excerpt' => __( 'Excerpt', 'ditty-news-ticker' ),
|
89 |
+
// ),
|
90 |
+
// 'inline' => true,
|
91 |
+
// 'std' => isset( $values['content_display'] ) ? $values['content_display'] : false,
|
92 |
+
// ),
|
93 |
+
// 'more_link' => array(
|
94 |
+
// 'type' => 'radio',
|
95 |
+
// 'id' => 'more_link',
|
96 |
+
// 'name' => __( 'Read More Link', 'ditty-news-ticker' ),
|
97 |
+
// 'help' => __( 'Link the read more text to the post.', 'ditty-news-ticker' ),
|
98 |
+
// 'options' => array(
|
99 |
+
// 'post' => __( 'Yes', 'ditty-news-ticker' ),
|
100 |
+
// 'false' => __( 'No', 'ditty-news-ticker' ),
|
101 |
+
// ),
|
102 |
+
// 'inline' => true,
|
103 |
+
// 'std' => isset( $values['more_link'] ) ? $values['more_link'] : false,
|
104 |
+
// ),
|
105 |
+
// 'excerpt_length' => array(
|
106 |
+
// 'type' => 'number',
|
107 |
+
// 'id' => 'excerpt_length',
|
108 |
+
// 'name' => __( 'Excerpt Length', 'ditty-news-ticker' ),
|
109 |
+
// 'help' => __( 'Set the length of the excerpt.', 'ditty-news-ticker' ),
|
110 |
+
// 'std' => isset( $values['excerpt_length'] ) ? $values['excerpt_length'] : false,
|
111 |
+
// ),
|
112 |
+
// 'more' => array(
|
113 |
+
// 'type' => 'text',
|
114 |
+
// 'id' => 'more',
|
115 |
+
// 'name' => __( 'Read More Text', 'ditty-news-ticker' ),
|
116 |
+
// 'help' => __( 'Add read more text to the excerpt.', 'ditty-news-ticker' ),
|
117 |
+
// 'std' => isset( $values['more'] ) ? $values['more'] : false,
|
118 |
+
// ),
|
119 |
+
// 'more_before' => array(
|
120 |
+
// 'type' => 'text',
|
121 |
+
// 'id' => 'more_before',
|
122 |
+
// 'name' => __( 'Read More Before Text', 'ditty-news-ticker' ),
|
123 |
+
// 'help' => __( 'Add text before the Read More text.', 'ditty-news-ticker' ),
|
124 |
+
// 'std' => isset( $values['more_before'] ) ? $values['more_before'] : false,
|
125 |
+
// ),
|
126 |
+
// 'more_after' => array(
|
127 |
+
// 'type' => 'text',
|
128 |
+
// 'id' => 'more_after',
|
129 |
+
// 'name' => __( 'Read More After Text', 'ditty-news-ticker' ),
|
130 |
+
// 'help' => __( 'Add text after the Read More text.', 'ditty-news-ticker' ),
|
131 |
+
// 'std' => isset( $values['more_after'] ) ? $values['more_after'] : false,
|
132 |
+
// ),
|
133 |
+
// ),
|
134 |
+
// ),
|
135 |
+
'linkSettings' => array(
|
136 |
+
'type' => 'group',
|
137 |
+
'id' => 'linkSettings',
|
138 |
+
'collapsible' => true,
|
139 |
+
'default_state' => 'expanded',
|
140 |
+
'multiple_fields' => true,
|
141 |
+
'name' => __( 'Link Settings', 'ditty-news-ticker' ),
|
142 |
+
'help' => __( 'Configure the link settings for the feed items.', 'ditty-news-ticker' ),
|
143 |
+
'fields' => array(
|
144 |
+
'link_target' => array(
|
145 |
+
'type' => 'select',
|
146 |
+
'id' => 'link_target',
|
147 |
+
'name' => __( 'Link Target', 'ditty-news-ticker' ),
|
148 |
+
'help' => __( 'Set a target for your links.', 'ditty-news-ticker' ),
|
149 |
+
'options' => array(
|
150 |
+
'_self' => '_self',
|
151 |
+
'_blank' => '_blank'
|
152 |
+
),
|
153 |
+
'std' => isset( $values['link_target'] ) ? $values['link_target'] : false,
|
154 |
+
),
|
155 |
+
'link_nofollow' => array(
|
156 |
+
'type' => 'checkbox',
|
157 |
+
'id' => 'link_nofollow',
|
158 |
+
'name' => __( 'Link No Follow', 'ditty-news-ticker' ),
|
159 |
+
'label' => __( 'Add "nofollow" to link', 'ditty-news-ticker' ),
|
160 |
+
'help' => __( 'Enabling this setting will add an attribute called \'nofollow\' to your links. This tells search engines to not follow this link.', 'ditty-news-ticker' ),
|
161 |
+
'std' => isset( $values['link_nofollow'] ) ? $values['link_nofollow'] : false,
|
162 |
+
),
|
163 |
+
),
|
164 |
+
),
|
165 |
);
|
166 |
return $fields;
|
167 |
}
|
170 |
* Set the default field values
|
171 |
*
|
172 |
* @access public
|
173 |
+
* @since 3.0.12
|
174 |
*/
|
175 |
public function default_settings() {
|
176 |
$defaults = array(
|
177 |
+
'limit' => 10,
|
178 |
+
// 'content_display' => 'excerpt',
|
179 |
+
// 'excerpt_length' => 200,
|
180 |
+
// 'more' => __( 'Read More', 'ditty-news-ticker' ),
|
181 |
+
// 'more_link' => 'post',
|
182 |
+
// 'more_before' => '... ',
|
183 |
+
// 'more_after' => '',
|
184 |
+
'link_target' => '_self',
|
185 |
+
'link_nofollow' => '',
|
186 |
);
|
187 |
return apply_filters( 'ditty_type_default_settings', $defaults, $this->slug );
|
188 |
}
|
191 |
* Set the default layout variation types
|
192 |
*
|
193 |
* @access public
|
194 |
+
* @since 3.0.3
|
195 |
*/
|
196 |
public function get_layout_variation_types() {
|
197 |
$layout_variations = array(
|
includes/class-ditty-item.php
CHANGED
@@ -415,23 +415,7 @@ class Ditty_Item {
|
|
415 |
return trim( ob_get_clean() );
|
416 |
}
|
417 |
}
|
418 |
-
|
419 |
-
/**
|
420 |
-
* Return the display meta
|
421 |
-
*
|
422 |
-
* @access public
|
423 |
-
* @since 3.0
|
424 |
-
* @return array $display_meta
|
425 |
-
*/
|
426 |
-
// public function get_display_meta() {
|
427 |
-
// $item_type_object = $this->get_type_object();
|
428 |
-
// if ( ! $item_type_object ) {
|
429 |
-
// return false;
|
430 |
-
// }
|
431 |
-
// $display_meta = $item_type_object->prepare_items( $this->get_values() );
|
432 |
-
// return $display_meta;
|
433 |
-
// }
|
434 |
-
|
435 |
/**
|
436 |
* Return the display items
|
437 |
*
|
415 |
return trim( ob_get_clean() );
|
416 |
}
|
417 |
}
|
418 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
/**
|
420 |
* Return the display items
|
421 |
*
|
includes/class-ditty-items.php
CHANGED
@@ -393,7 +393,7 @@ class Ditty_Items {
|
|
393 |
unset( $_POST['draft_values'] );
|
394 |
unset( $_POST['security'] );
|
395 |
unset( $_POST['item_id'] );
|
396 |
-
|
397 |
$editor_item = new Ditty_Item( $item_id_ajax );
|
398 |
$editor_item->set_item_value( $_POST );
|
399 |
|
393 |
unset( $_POST['draft_values'] );
|
394 |
unset( $_POST['security'] );
|
395 |
unset( $_POST['item_id'] );
|
396 |
+
|
397 |
$editor_item = new Ditty_Item( $item_id_ajax );
|
398 |
$editor_item->set_item_value( $_POST );
|
399 |
|
includes/class-ditty-layout.php
CHANGED
@@ -123,12 +123,12 @@ class Ditty_Layout {
|
|
123 |
/**
|
124 |
* Return the html tags
|
125 |
* @access public
|
126 |
-
* @since 3.0
|
127 |
* @return int $id
|
128 |
*/
|
129 |
public function get_layout_tags() {
|
130 |
if ( ! $this->layout_tags ) {
|
131 |
-
$this->layout_tags = ditty_layout_tags( $this->get_item_type() );
|
132 |
}
|
133 |
return $this->layout_tags;
|
134 |
}
|
@@ -136,20 +136,20 @@ class Ditty_Layout {
|
|
136 |
/**
|
137 |
* Return the html tags list
|
138 |
* @access public
|
139 |
-
* @since 3.0
|
140 |
* @return html $tags_list
|
141 |
*/
|
142 |
public function get_tags_list() {
|
143 |
$tags_list = '';
|
144 |
-
$tags = apply_filters( 'ditty_layout_tags_list', $this->get_layout_tags(), $this->get_item_type(), 'html' );
|
145 |
if ( is_array( $tags ) && count( $tags ) > 0 ) {
|
146 |
$tags_list .= '<ul class="ditty-editor-options__tags__list ditty-editor-options__tags__list--' . $this->get_item_type() . '">';
|
147 |
foreach ( $tags as $data ) {
|
148 |
$class = ( isset( $data['class'] ) && '' != $data['class'] ) ? ' ' . esc_attr( $data['class'] ) : '';
|
149 |
$atts = array(
|
150 |
-
'class'
|
151 |
-
'data-pt-title' => $data['description'],
|
152 |
-
'data-atts'
|
153 |
);
|
154 |
$tags_list .= '<li ' . ditty_attr_to_html( $atts ) . '>{' . $data['tag'] . '}</li>';
|
155 |
}
|
@@ -161,11 +161,11 @@ class Ditty_Layout {
|
|
161 |
/**
|
162 |
* Return the css selectors
|
163 |
* @access public
|
164 |
-
* @since 3.0
|
165 |
* @return int $id
|
166 |
*/
|
167 |
public function get_css_selectors_list() {
|
168 |
-
$tags = apply_filters( 'ditty_layout_tags_list', $this->get_layout_tags(), $this->get_item_type(), 'css' );
|
169 |
$selectors_list = '';
|
170 |
if ( is_array( $tags ) && count( $tags ) > 0 ) {
|
171 |
$selectors_list .= '<ul class="ditty-editor-options__tags__list ditty-editor-options__tags__list--' . $this->get_item_type() . '">';
|
@@ -293,10 +293,10 @@ class Ditty_Layout {
|
|
293 |
/**
|
294 |
* Return the passed item value
|
295 |
* @access public
|
296 |
-
* @since 3.0
|
297 |
* @return string $html
|
298 |
*/
|
299 |
-
public function
|
300 |
return $this->item_value;
|
301 |
}
|
302 |
|
@@ -407,13 +407,13 @@ class Ditty_Layout {
|
|
407 |
/**
|
408 |
* Render the layout
|
409 |
* @access public
|
410 |
-
* @since 3.0
|
411 |
* @return html
|
412 |
*/
|
413 |
public function render() {
|
414 |
$tags = $this->get_layout_tags();
|
415 |
$html = $this->get_html();
|
416 |
-
$value = $this->
|
417 |
|
418 |
// Return an error if there is one
|
419 |
if ( isset( $value['ditty_feed_error'] ) ) {
|
@@ -429,7 +429,7 @@ class Ditty_Layout {
|
|
429 |
$atts = apply_filters( 'ditty_layout_tag_atts', $atts, $tag['tag'], $this->get_item_type(), $value );
|
430 |
$content = $s->getContent();
|
431 |
if ( isset( $tag['func'] ) && function_exists( $tag['func'] ) ) {
|
432 |
-
return call_user_func( $tag['func'], $this->get_item_type(), $value, $atts, $content );
|
433 |
} else {
|
434 |
return $this->render_tag( $tag['tag'], $this->get_item_type(), $value, $atts, $content );
|
435 |
}
|
123 |
/**
|
124 |
* Return the html tags
|
125 |
* @access public
|
126 |
+
* @since 3.0.12
|
127 |
* @return int $id
|
128 |
*/
|
129 |
public function get_layout_tags() {
|
130 |
if ( ! $this->layout_tags ) {
|
131 |
+
$this->layout_tags = ditty_layout_tags( $this->get_item_type(), $this->get_item_value() );
|
132 |
}
|
133 |
return $this->layout_tags;
|
134 |
}
|
136 |
/**
|
137 |
* Return the html tags list
|
138 |
* @access public
|
139 |
+
* @since 3.0.12
|
140 |
* @return html $tags_list
|
141 |
*/
|
142 |
public function get_tags_list() {
|
143 |
$tags_list = '';
|
144 |
+
$tags = apply_filters( 'ditty_layout_tags_list', $this->get_layout_tags(), $this->get_item_type(), 'html', $this->get_item_value() );
|
145 |
if ( is_array( $tags ) && count( $tags ) > 0 ) {
|
146 |
$tags_list .= '<ul class="ditty-editor-options__tags__list ditty-editor-options__tags__list--' . $this->get_item_type() . '">';
|
147 |
foreach ( $tags as $data ) {
|
148 |
$class = ( isset( $data['class'] ) && '' != $data['class'] ) ? ' ' . esc_attr( $data['class'] ) : '';
|
149 |
$atts = array(
|
150 |
+
'class' => 'ditty-editor-options__tag protip' . $class,
|
151 |
+
'data-pt-title' => isset( $data['description'] ) ? $data['description'] : false,
|
152 |
+
'data-atts' => ( isset( $data['atts'] ) ) ? htmlentities( json_encode( $data['atts'] ) ) : false,
|
153 |
);
|
154 |
$tags_list .= '<li ' . ditty_attr_to_html( $atts ) . '>{' . $data['tag'] . '}</li>';
|
155 |
}
|
161 |
/**
|
162 |
* Return the css selectors
|
163 |
* @access public
|
164 |
+
* @since 3.0.12
|
165 |
* @return int $id
|
166 |
*/
|
167 |
public function get_css_selectors_list() {
|
168 |
+
$tags = apply_filters( 'ditty_layout_tags_list', $this->get_layout_tags(), $this->get_item_type(), 'css', $this->get_item_value() );
|
169 |
$selectors_list = '';
|
170 |
if ( is_array( $tags ) && count( $tags ) > 0 ) {
|
171 |
$selectors_list .= '<ul class="ditty-editor-options__tags__list ditty-editor-options__tags__list--' . $this->get_item_type() . '">';
|
293 |
/**
|
294 |
* Return the passed item value
|
295 |
* @access public
|
296 |
+
* @since 3.0.12
|
297 |
* @return string $html
|
298 |
*/
|
299 |
+
public function get_item_value() {
|
300 |
return $this->item_value;
|
301 |
}
|
302 |
|
407 |
/**
|
408 |
* Render the layout
|
409 |
* @access public
|
410 |
+
* @since 3.0.12
|
411 |
* @return html
|
412 |
*/
|
413 |
public function render() {
|
414 |
$tags = $this->get_layout_tags();
|
415 |
$html = $this->get_html();
|
416 |
+
$value = $this->get_item_value();
|
417 |
|
418 |
// Return an error if there is one
|
419 |
if ( isset( $value['ditty_feed_error'] ) ) {
|
429 |
$atts = apply_filters( 'ditty_layout_tag_atts', $atts, $tag['tag'], $this->get_item_type(), $value );
|
430 |
$content = $s->getContent();
|
431 |
if ( isset( $tag['func'] ) && function_exists( $tag['func'] ) ) {
|
432 |
+
return call_user_func( $tag['func'], $tag['tag'], $this->get_item_type(), $value, $atts, $content );
|
433 |
} else {
|
434 |
return $this->render_tag( $tag['tag'], $this->get_item_type(), $value, $atts, $content );
|
435 |
}
|
includes/class-ditty-layouts.php
CHANGED
@@ -698,7 +698,6 @@ class Ditty_Layouts {
|
|
698 |
$data = array(
|
699 |
'editor_item' => $editor_item->render_editor_list_item( 'return' ),
|
700 |
'display_items' => $editor_item->get_display_items(),
|
701 |
-
//'display_items' => ditty_display_items( $editor_item->get_ditty_id(), 'force' ),
|
702 |
'layout_label' => $editor_layout->get_label(),
|
703 |
'layout_css' => $editor_layout->get_css_compiled(),
|
704 |
);
|
@@ -709,7 +708,7 @@ class Ditty_Layouts {
|
|
709 |
* Return the html field to edit
|
710 |
*
|
711 |
* @access public
|
712 |
-
* @since 3.0
|
713 |
* @param json.
|
714 |
*/
|
715 |
public function editor_fields_ajax() {
|
@@ -718,13 +717,14 @@ class Ditty_Layouts {
|
|
718 |
$layout_id_ajax = isset( $_POST['layout_id'] ) ? sanitize_text_field( $_POST['layout_id'] ) : false;
|
719 |
$layout_title_ajax = isset( $_POST['layout_title'] ) ? sanitize_text_field( $_POST['layout_title'] ) : false;
|
720 |
$item_type_ajax = isset( $_POST['item_type'] ) ? sanitize_text_field( $_POST['item_type'] ) : false;
|
|
|
721 |
$item_id_ajax = isset( $_POST['item_id'] ) ? sanitize_text_field( $_POST['item_id'] ) : false;
|
722 |
$draft_values_ajax = isset( $_POST['draft_values'] ) ? $_POST['draft_values'] : false;
|
723 |
if ( ! current_user_can( 'edit_ditty_layouts' ) ) {
|
724 |
wp_die();
|
725 |
}
|
726 |
ditty_set_draft_values( $draft_values_ajax );
|
727 |
-
if ( ! $layout = new Ditty_Layout( $layout_id_ajax, $item_type_ajax ) ) {
|
728 |
wp_die();
|
729 |
}
|
730 |
|
@@ -800,6 +800,7 @@ class Ditty_Layouts {
|
|
800 |
*/
|
801 |
public function editor_update_ajax() {
|
802 |
check_ajax_referer( 'ditty', 'security' );
|
|
|
803 |
$edit_type_ajax = isset( $_POST['edit_type'] ) ? sanitize_text_field( $_POST['edit_type'] ) : false;
|
804 |
$layout_id_ajax = isset( $_POST['layout_id'] ) ? sanitize_text_field( $_POST['layout_id'] ) : false;
|
805 |
$title_ajax = isset( $_POST['title'] ) ? sanitize_text_field( $_POST['title'] ) : false;
|
698 |
$data = array(
|
699 |
'editor_item' => $editor_item->render_editor_list_item( 'return' ),
|
700 |
'display_items' => $editor_item->get_display_items(),
|
|
|
701 |
'layout_label' => $editor_layout->get_label(),
|
702 |
'layout_css' => $editor_layout->get_css_compiled(),
|
703 |
);
|
708 |
* Return the html field to edit
|
709 |
*
|
710 |
* @access public
|
711 |
+
* @since 3.0.12
|
712 |
* @param json.
|
713 |
*/
|
714 |
public function editor_fields_ajax() {
|
717 |
$layout_id_ajax = isset( $_POST['layout_id'] ) ? sanitize_text_field( $_POST['layout_id'] ) : false;
|
718 |
$layout_title_ajax = isset( $_POST['layout_title'] ) ? sanitize_text_field( $_POST['layout_title'] ) : false;
|
719 |
$item_type_ajax = isset( $_POST['item_type'] ) ? sanitize_text_field( $_POST['item_type'] ) : false;
|
720 |
+
$item_value_ajax = isset( $_POST['item_value'] ) ? $_POST['item_value'] : false;
|
721 |
$item_id_ajax = isset( $_POST['item_id'] ) ? sanitize_text_field( $_POST['item_id'] ) : false;
|
722 |
$draft_values_ajax = isset( $_POST['draft_values'] ) ? $_POST['draft_values'] : false;
|
723 |
if ( ! current_user_can( 'edit_ditty_layouts' ) ) {
|
724 |
wp_die();
|
725 |
}
|
726 |
ditty_set_draft_values( $draft_values_ajax );
|
727 |
+
if ( ! $layout = new Ditty_Layout( $layout_id_ajax, $item_type_ajax, $item_value_ajax ) ) {
|
728 |
wp_die();
|
729 |
}
|
730 |
|
800 |
*/
|
801 |
public function editor_update_ajax() {
|
802 |
check_ajax_referer( 'ditty', 'security' );
|
803 |
+
|
804 |
$edit_type_ajax = isset( $_POST['edit_type'] ) ? sanitize_text_field( $_POST['edit_type'] ) : false;
|
805 |
$layout_id_ajax = isset( $_POST['layout_id'] ) ? sanitize_text_field( $_POST['layout_id'] ) : false;
|
806 |
$title_ajax = isset( $_POST['title'] ) ? sanitize_text_field( $_POST['title'] ) : false;
|
includes/class-ditty-singles.php
CHANGED
@@ -92,10 +92,11 @@ class Ditty_Singles {
|
|
92 |
<div class="ditty-editor-options__contents">
|
93 |
<div class="ditty-editor-options__body">
|
94 |
<?php
|
95 |
-
$
|
|
|
96 |
$status = get_post_status( $ditty_id );
|
97 |
$settings = get_post_meta( $ditty_id, '_ditty_settings', true );
|
98 |
-
if (
|
99 |
$status = 'publish';
|
100 |
}
|
101 |
$shortcode = "[ditty id={$ditty_id}]";
|
@@ -184,15 +185,16 @@ class Ditty_Singles {
|
|
184 |
/**
|
185 |
* Add the edit page preview
|
186 |
* @access public
|
187 |
-
* @since 3.0.
|
188 |
*/
|
189 |
public function edit_preview() {
|
190 |
global $post;
|
191 |
if ( 'ditty' != $post->post_type ) {
|
192 |
return false;
|
193 |
}
|
194 |
-
$
|
195 |
$settings = get_post_meta( $post->ID, '_ditty_settings', true );
|
|
|
196 |
$style = '';
|
197 |
if ( is_array( $settings ) && isset( $settings['previewBg'] ) ) {
|
198 |
$style .= "background-color:{$settings['previewBg']};";
|
@@ -393,7 +395,7 @@ class Ditty_Singles {
|
|
393 |
* Return data for a Ditty to load via ajax
|
394 |
*
|
395 |
* @access public
|
396 |
-
* @since 3.0.
|
397 |
*/
|
398 |
public function init_ajax() {
|
399 |
check_ajax_referer( 'ditty', 'security' );
|
@@ -420,7 +422,7 @@ class Ditty_Singles {
|
|
420 |
$args = $display->get_values();
|
421 |
$args['id'] = $id_ajax;
|
422 |
$args['uniqid'] = $uniqid_ajax;
|
423 |
-
$args['title'] =
|
424 |
$args['status'] = $status;
|
425 |
$args['display'] = $display->get_display_id();
|
426 |
$args['showEditor'] = $editor_ajax;
|
@@ -445,7 +447,7 @@ class Ditty_Singles {
|
|
445 |
* Return data for a Ditty to load via ajax
|
446 |
*
|
447 |
* @access public
|
448 |
-
* @since 3.0.
|
449 |
*/
|
450 |
public function init( $atts ) {
|
451 |
if ( ! $atts['data-id'] ) {
|
@@ -458,7 +460,6 @@ class Ditty_Singles {
|
|
458 |
$display_settings = isset( $atts['data-display_settings'] ) ? $atts['data-display_settings'] : false;
|
459 |
$layout_settings = isset( $atts['data-layout_settings'] ) ? $atts['data-layout_settings'] : false;
|
460 |
$show_editor = isset( $atts['data-show_editor'] ) ? $atts['data-show_editor'] : false;
|
461 |
-
//$load_type = isset( $atts['load_type'] ) ? $atts['load_type'] : '';
|
462 |
|
463 |
// Get the display attributes
|
464 |
if ( ! $display_id ) {
|
@@ -476,7 +477,7 @@ class Ditty_Singles {
|
|
476 |
|
477 |
$args['id'] = $ditty_id;
|
478 |
$args['uniqid'] = $uniqid;
|
479 |
-
$args['title'] =
|
480 |
$args['status'] = $status;
|
481 |
$args['display'] = $display->get_display_id();
|
482 |
$args['showEditor'] = $show_editor;
|
@@ -616,7 +617,7 @@ class Ditty_Singles {
|
|
616 |
* Save draft values on Ditty editor update
|
617 |
*
|
618 |
* @access public
|
619 |
-
* @since 3.0
|
620 |
*/
|
621 |
public function editor_save_ajax() {
|
622 |
check_ajax_referer( 'ditty', 'security' );
|
@@ -626,17 +627,16 @@ class Ditty_Singles {
|
|
626 |
if ( ! current_user_can( 'edit_dittys' ) || ! $ditty_id_ajax ) {
|
627 |
wp_die();
|
628 |
}
|
|
|
629 |
$add_display = false;
|
630 |
$add_item = false;
|
631 |
-
|
632 |
do_action( 'ditty_editor_update', $ditty_id_ajax, $draft_values_ajax );
|
633 |
-
|
634 |
-
//ChromePhp::log( '$draft_values_ajax:', $draft_values_ajax );
|
635 |
-
|
636 |
$json_data = array();
|
637 |
|
638 |
$ditty_post_data = array();
|
639 |
-
if (
|
640 |
$ditty_post_data['post_title'] = sprintf( __( 'Ditty %d', 'ditty-news-ticker' ), $ditty_id_ajax );
|
641 |
$ditty_post_data['post_status'] = 'publish';
|
642 |
}
|
@@ -652,11 +652,13 @@ class Ditty_Singles {
|
|
652 |
}
|
653 |
|
654 |
// Publish the ditty if this is a new post
|
655 |
-
if (
|
656 |
$ditty_post_data['post_type'] = 'ditty';
|
657 |
$ditty_post_data['ID'] = $ditty_id_ajax;
|
658 |
wp_update_post( $ditty_post_data );
|
659 |
$json_data['new_ditty_url'] = get_edit_post_link( $ditty_id_ajax );
|
|
|
|
|
660 |
$add_display = true;
|
661 |
$add_item = true;
|
662 |
|
@@ -666,7 +668,6 @@ class Ditty_Singles {
|
|
666 |
wp_update_post( $ditty_post_data );
|
667 |
}
|
668 |
|
669 |
-
|
670 |
// Sanitize default post meta
|
671 |
$ditty_post_meta = ( isset( $draft_values_ajax['post_meta'] ) && is_array( $draft_values_ajax['post_meta'] ) ) ? $draft_values_ajax['post_meta'] : false;
|
672 |
if ( $ditty_post_meta ) {
|
92 |
<div class="ditty-editor-options__contents">
|
93 |
<div class="ditty-editor-options__body">
|
94 |
<?php
|
95 |
+
$initialized = get_post_meta( $ditty_id, '_ditty_init', true );
|
96 |
+
$title = ( ! $initialized ) ? sprintf( __( 'Ditty %d', 'ditty-news-ticker' ), $ditty_id ) : get_the_title( $ditty_id );
|
97 |
$status = get_post_status( $ditty_id );
|
98 |
$settings = get_post_meta( $ditty_id, '_ditty_settings', true );
|
99 |
+
if ( ! $initialized ) {
|
100 |
$status = 'publish';
|
101 |
}
|
102 |
$shortcode = "[ditty id={$ditty_id}]";
|
185 |
/**
|
186 |
* Add the edit page preview
|
187 |
* @access public
|
188 |
+
* @since 3.0.12
|
189 |
*/
|
190 |
public function edit_preview() {
|
191 |
global $post;
|
192 |
if ( 'ditty' != $post->post_type ) {
|
193 |
return false;
|
194 |
}
|
195 |
+
$initialized = get_post_meta( $post->ID, '_ditty_init', true );
|
196 |
$settings = get_post_meta( $post->ID, '_ditty_settings', true );
|
197 |
+
$title = ( ! $initialized ) ? sprintf( __( 'Ditty %d', 'ditty-news-ticker' ), $post->ID ) : $post->post_title;
|
198 |
$style = '';
|
199 |
if ( is_array( $settings ) && isset( $settings['previewBg'] ) ) {
|
200 |
$style .= "background-color:{$settings['previewBg']};";
|
395 |
* Return data for a Ditty to load via ajax
|
396 |
*
|
397 |
* @access public
|
398 |
+
* @since 3.0.12
|
399 |
*/
|
400 |
public function init_ajax() {
|
401 |
check_ajax_referer( 'ditty', 'security' );
|
422 |
$args = $display->get_values();
|
423 |
$args['id'] = $id_ajax;
|
424 |
$args['uniqid'] = $uniqid_ajax;
|
425 |
+
$args['title'] = get_the_title( $id_ajax );
|
426 |
$args['status'] = $status;
|
427 |
$args['display'] = $display->get_display_id();
|
428 |
$args['showEditor'] = $editor_ajax;
|
447 |
* Return data for a Ditty to load via ajax
|
448 |
*
|
449 |
* @access public
|
450 |
+
* @since 3.0.12
|
451 |
*/
|
452 |
public function init( $atts ) {
|
453 |
if ( ! $atts['data-id'] ) {
|
460 |
$display_settings = isset( $atts['data-display_settings'] ) ? $atts['data-display_settings'] : false;
|
461 |
$layout_settings = isset( $atts['data-layout_settings'] ) ? $atts['data-layout_settings'] : false;
|
462 |
$show_editor = isset( $atts['data-show_editor'] ) ? $atts['data-show_editor'] : false;
|
|
|
463 |
|
464 |
// Get the display attributes
|
465 |
if ( ! $display_id ) {
|
477 |
|
478 |
$args['id'] = $ditty_id;
|
479 |
$args['uniqid'] = $uniqid;
|
480 |
+
$args['title'] = get_the_title( $ditty_id );
|
481 |
$args['status'] = $status;
|
482 |
$args['display'] = $display->get_display_id();
|
483 |
$args['showEditor'] = $show_editor;
|
617 |
* Save draft values on Ditty editor update
|
618 |
*
|
619 |
* @access public
|
620 |
+
* @since 3.0.12
|
621 |
*/
|
622 |
public function editor_save_ajax() {
|
623 |
check_ajax_referer( 'ditty', 'security' );
|
627 |
if ( ! current_user_can( 'edit_dittys' ) || ! $ditty_id_ajax ) {
|
628 |
wp_die();
|
629 |
}
|
630 |
+
$initialized = get_post_meta( $ditty_id_ajax, '_ditty_init', true );
|
631 |
$add_display = false;
|
632 |
$add_item = false;
|
633 |
+
|
634 |
do_action( 'ditty_editor_update', $ditty_id_ajax, $draft_values_ajax );
|
635 |
+
|
|
|
|
|
636 |
$json_data = array();
|
637 |
|
638 |
$ditty_post_data = array();
|
639 |
+
if ( ! $initialized ) {
|
640 |
$ditty_post_data['post_title'] = sprintf( __( 'Ditty %d', 'ditty-news-ticker' ), $ditty_id_ajax );
|
641 |
$ditty_post_data['post_status'] = 'publish';
|
642 |
}
|
652 |
}
|
653 |
|
654 |
// Publish the ditty if this is a new post
|
655 |
+
if ( ! $initialized ) {
|
656 |
$ditty_post_data['post_type'] = 'ditty';
|
657 |
$ditty_post_data['ID'] = $ditty_id_ajax;
|
658 |
wp_update_post( $ditty_post_data );
|
659 |
$json_data['new_ditty_url'] = get_edit_post_link( $ditty_id_ajax );
|
660 |
+
$initialized = 'yes';
|
661 |
+
update_post_meta( $ditty_id_ajax, '_ditty_init', $initialized );
|
662 |
$add_display = true;
|
663 |
$add_item = true;
|
664 |
|
668 |
wp_update_post( $ditty_post_data );
|
669 |
}
|
670 |
|
|
|
671 |
// Sanitize default post meta
|
672 |
$ditty_post_meta = ( isset( $draft_values_ajax['post_meta'] ) && is_array( $draft_values_ajax['post_meta'] ) ) ? $draft_values_ajax['post_meta'] : false;
|
673 |
if ( $ditty_post_meta ) {
|
includes/class-ditty.php
CHANGED
@@ -244,6 +244,7 @@ class Ditty {
|
|
244 |
require_once DITTY_DIR . 'includes/fields/ditty-field-color.php';
|
245 |
require_once DITTY_DIR . 'includes/fields/ditty-field-date.php';
|
246 |
require_once DITTY_DIR . 'includes/fields/ditty-field-divider.php';
|
|
|
247 |
require_once DITTY_DIR . 'includes/fields/ditty-field-group.php';
|
248 |
require_once DITTY_DIR . 'includes/fields/ditty-field-html.php';
|
249 |
require_once DITTY_DIR . 'includes/fields/ditty-field-image.php';
|
@@ -311,8 +312,8 @@ class Ditty {
|
|
311 |
//require_once DITTY_DIR . 'blocks/ditty-block/index.php';
|
312 |
|
313 |
if ( is_admin() ) {
|
314 |
-
if ( ! class_exists( '
|
315 |
-
require_once DITTY_DIR . 'includes/admin/
|
316 |
}
|
317 |
require_once DITTY_DIR . 'includes/admin/columns.php';
|
318 |
require_once DITTY_DIR . 'includes/admin/notices.php';
|
@@ -421,7 +422,7 @@ class Ditty {
|
|
421 |
/**
|
422 |
* Register the stylesheets.
|
423 |
*
|
424 |
-
* @since 3.0.
|
425 |
*/
|
426 |
public function enqueue_styles() {
|
427 |
wp_enqueue_style( 'ditty', DITTY_URL . 'includes/css/ditty.css', array(), $this->version, 'all' );
|
@@ -430,14 +431,11 @@ class Ditty {
|
|
430 |
if ( ! $disable_fontawesome ) {
|
431 |
wp_enqueue_style( 'fontawesome', 'https://use.fontawesome.com/releases/v5.15.3/css/all.css', false, '5.15.3', false );
|
432 |
}
|
433 |
-
if (
|
434 |
wp_enqueue_style( 'wp-codemirror' );
|
435 |
wp_enqueue_style( 'protip', DITTY_URL . 'includes/libs/protip/protip.min.css', false, '1.4.21', false );
|
436 |
wp_enqueue_style( 'ion-rangeslider', DITTY_URL . 'includes/libs/ion.rangeSlider/css/ion.rangeSlider.min.css', false, '2.3.1', false );
|
437 |
wp_enqueue_style( 'jquery-minicolors', DITTY_URL . 'includes/libs/jquery-minicolors/jquery.minicolors.css', false, '2.3.5', false );
|
438 |
-
//wp_enqueue_style( 'jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css' );
|
439 |
-
}
|
440 |
-
if ( is_admin() ) {
|
441 |
wp_enqueue_style( 'ditty-admin', DITTY_URL . 'includes/css/ditty-admin.css', array(), $this->version, 'all' );
|
442 |
if ( $disable_fontawesome ) {
|
443 |
wp_enqueue_style( 'fontawesome', 'https://use.fontawesome.com/releases/v5.15.3/css/all.css', false, '5.15.3', false );
|
@@ -459,77 +457,79 @@ class Ditty {
|
|
459 |
/**
|
460 |
* Register the JavaScript for the public-facing side of the site.
|
461 |
*
|
462 |
-
* @since 3.0.
|
463 |
*/
|
464 |
public function enqueue_scripts( $hook ) {
|
|
|
465 |
$min = WP_DEBUG ? '' : '.min';
|
466 |
|
467 |
wp_register_script( 'hammer', DITTY_URL . 'includes/libs/hammer.min.js', array( 'jquery' ), '2.0.8.1', true );
|
468 |
-
wp_register_script( 'protip', DITTY_URL . 'includes/libs/protip/protip.min.js', array( 'jquery' ), '1.4.21', true );
|
469 |
wp_register_script( 'ditty', DITTY_URL . 'includes/js/ditty.min.js', array( 'jquery', 'jquery-effects-core', ), $this->version, true );
|
470 |
-
wp_add_inline_script( 'ditty', 'const dittyVars = ' . json_encode( array(
|
471 |
-
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
472 |
-
'security' => wp_create_nonce( 'ditty' ),
|
473 |
-
'mode' => WP_DEBUG ? 'development' : 'production',
|
474 |
-
'strings' => ditty_strings(),
|
475 |
-
'adminStrings' => is_admin() ? ditty_admin_strings() : false,
|
476 |
-
'globals' => ditty_get_globals(),
|
477 |
-
'updateIcon' => 'fas fa-sync-alt fa-spin',
|
478 |
-
'updateInterval' => ( MINUTE_IN_SECONDS * ditty_settings( 'live_refresh' ) ),
|
479 |
-
'editor' => array(
|
480 |
-
'ditty_layouts_sass' => ditty_settings( 'ditty_layouts_sass' ),
|
481 |
-
),
|
482 |
-
) ), 'before' );
|
483 |
-
|
484 |
-
wp_register_script( 'ditty-slider', DITTY_URL . 'includes/js/class-ditty-slider' . $min . '.js', array( 'jquery', 'hammer' ), $this->version, true );
|
485 |
-
wp_register_script( 'ditty-display-ticker', DITTY_URL . 'includes/js/class-ditty-display-ticker' . $min . '.js', array( 'jquery' ), $this->version, true );
|
486 |
-
wp_register_script( 'ditty-display-list', DITTY_URL . 'includes/js/class-ditty-display-list' . $min . '.js', array( 'jquery', 'ditty-slider' ), $this->version, true );
|
487 |
-
|
488 |
-
wp_enqueue_script( 'ion-rangeslider', DITTY_URL . 'includes/libs/ion.rangeSlider/js/ion.rangeSlider.min.js', array( 'jquery' ), '2.3.1', true );
|
489 |
-
wp_enqueue_script( 'jquery-minicolors', DITTY_URL . 'includes/libs/jquery-minicolors/jquery.minicolors.min.js', array( 'jquery' ), '2.3.5', true );
|
490 |
-
wp_enqueue_script( 'ditty-fields', DITTY_URL . 'includes/fields/js/ditty-fields.min.js', array(
|
491 |
-
'jquery',
|
492 |
-
'protip',
|
493 |
-
'jquery-effects-core',
|
494 |
-
'wp-codemirror',
|
495 |
-
'ion-rangeslider',
|
496 |
-
'jquery-minicolors',
|
497 |
-
), $this->version, true );
|
498 |
-
wp_register_script( 'ditty-editor', DITTY_URL . 'includes/js/ditty-editor.min.js', array(
|
499 |
-
'jquery',
|
500 |
-
'protip',
|
501 |
-
'iris',
|
502 |
-
'jquery-form',
|
503 |
-
'jquery-ui-core',
|
504 |
-
'jquery-effects-core',
|
505 |
-
'wp-codemirror',
|
506 |
-
'ditty-slider',
|
507 |
-
'ditty-fields',
|
508 |
-
), $this->version, true );
|
509 |
-
wp_register_script( 'ditty-admin', DITTY_URL . 'includes/js/ditty-admin.min.js', array(
|
510 |
-
'jquery',
|
511 |
-
'jquery-ui-core',
|
512 |
-
'jquery-ui-sortable',
|
513 |
-
'wp-i18n',
|
514 |
-
), $this->version, true );
|
515 |
-
|
516 |
-
global $ditty_scripts_enqueued;
|
517 |
if ( empty( $ditty_scripts_enqueued ) ) {
|
518 |
-
wp_add_inline_script( 'ditty
|
519 |
-
'ajaxurl'
|
520 |
-
'security'
|
521 |
-
'mode'
|
522 |
-
'
|
523 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
524 |
) ), 'before' );
|
525 |
}
|
526 |
-
$ditty_scripts_enqueued = 'enqueued';
|
527 |
|
|
|
|
|
|
|
|
|
528 |
if ( is_admin() ) {
|
529 |
|
530 |
// Make sure to enqueue the scripts in the admin
|
531 |
wp_enqueue_script( 'ditty-display-ticker' );
|
532 |
wp_enqueue_script( 'ditty-display-list' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
533 |
|
534 |
if ( current_user_can( 'edit_dittys' ) || current_user_can( 'edit_ditty_layouts' ) ) {
|
535 |
wp_enqueue_editor();
|
@@ -550,6 +550,8 @@ class Ditty {
|
|
550 |
wp_dequeue_script( 'autosave' );
|
551 |
}
|
552 |
}
|
|
|
|
|
553 |
}
|
554 |
|
555 |
/**
|
@@ -602,7 +604,7 @@ class Ditty {
|
|
602 |
/**
|
603 |
* Enqueue global scripts for any Ditty's displayed
|
604 |
*
|
605 |
-
* @since 3.0
|
606 |
*/
|
607 |
public function enqueue_global_scripts() {
|
608 |
global $ditty_item_scripts;
|
@@ -618,10 +620,17 @@ class Ditty {
|
|
618 |
wp_print_scripts( "ditty-{$ditty_item_script}" );
|
619 |
}
|
620 |
}
|
621 |
-
if ( is_array( $ditty_display_scripts ) && count( $ditty_display_scripts ) > 0 ) {
|
622 |
-
|
623 |
foreach ( $ditty_display_scripts as $i => $ditty_display_script ) {
|
|
|
|
|
|
|
624 |
wp_print_scripts( "ditty-display-{$ditty_display_script}" );
|
|
|
|
|
|
|
|
|
625 |
}
|
626 |
}
|
627 |
global $ditty_singles;
|
@@ -631,7 +640,7 @@ class Ditty {
|
|
631 |
if ( is_array( $ditty_singles ) && count( $ditty_singles ) > 0 ) {
|
632 |
?>
|
633 |
<script id="ditty-singles">
|
634 |
-
jQuery(
|
635 |
<?php
|
636 |
foreach ( $ditty_singles as $ditty_atts ) {
|
637 |
Ditty()->singles->init( $ditty_atts );
|
244 |
require_once DITTY_DIR . 'includes/fields/ditty-field-color.php';
|
245 |
require_once DITTY_DIR . 'includes/fields/ditty-field-date.php';
|
246 |
require_once DITTY_DIR . 'includes/fields/ditty-field-divider.php';
|
247 |
+
require_once DITTY_DIR . 'includes/fields/ditty-field-file.php';
|
248 |
require_once DITTY_DIR . 'includes/fields/ditty-field-group.php';
|
249 |
require_once DITTY_DIR . 'includes/fields/ditty-field-html.php';
|
250 |
require_once DITTY_DIR . 'includes/fields/ditty-field-image.php';
|
312 |
//require_once DITTY_DIR . 'blocks/ditty-block/index.php';
|
313 |
|
314 |
if ( is_admin() ) {
|
315 |
+
if ( ! class_exists( 'Ditty_Plugin_Updater' ) ) {
|
316 |
+
require_once DITTY_DIR . 'includes/admin/Ditty_Plugin_Updater.php';
|
317 |
}
|
318 |
require_once DITTY_DIR . 'includes/admin/columns.php';
|
319 |
require_once DITTY_DIR . 'includes/admin/notices.php';
|
422 |
/**
|
423 |
* Register the stylesheets.
|
424 |
*
|
425 |
+
* @since 3.0.12
|
426 |
*/
|
427 |
public function enqueue_styles() {
|
428 |
wp_enqueue_style( 'ditty', DITTY_URL . 'includes/css/ditty.css', array(), $this->version, 'all' );
|
431 |
if ( ! $disable_fontawesome ) {
|
432 |
wp_enqueue_style( 'fontawesome', 'https://use.fontawesome.com/releases/v5.15.3/css/all.css', false, '5.15.3', false );
|
433 |
}
|
434 |
+
if ( is_admin() ) {
|
435 |
wp_enqueue_style( 'wp-codemirror' );
|
436 |
wp_enqueue_style( 'protip', DITTY_URL . 'includes/libs/protip/protip.min.css', false, '1.4.21', false );
|
437 |
wp_enqueue_style( 'ion-rangeslider', DITTY_URL . 'includes/libs/ion.rangeSlider/css/ion.rangeSlider.min.css', false, '2.3.1', false );
|
438 |
wp_enqueue_style( 'jquery-minicolors', DITTY_URL . 'includes/libs/jquery-minicolors/jquery.minicolors.css', false, '2.3.5', false );
|
|
|
|
|
|
|
439 |
wp_enqueue_style( 'ditty-admin', DITTY_URL . 'includes/css/ditty-admin.css', array(), $this->version, 'all' );
|
440 |
if ( $disable_fontawesome ) {
|
441 |
wp_enqueue_style( 'fontawesome', 'https://use.fontawesome.com/releases/v5.15.3/css/all.css', false, '5.15.3', false );
|
457 |
/**
|
458 |
* Register the JavaScript for the public-facing side of the site.
|
459 |
*
|
460 |
+
* @since 3.0.12
|
461 |
*/
|
462 |
public function enqueue_scripts( $hook ) {
|
463 |
+
global $ditty_scripts_enqueued;
|
464 |
$min = WP_DEBUG ? '' : '.min';
|
465 |
|
466 |
wp_register_script( 'hammer', DITTY_URL . 'includes/libs/hammer.min.js', array( 'jquery' ), '2.0.8.1', true );
|
|
|
467 |
wp_register_script( 'ditty', DITTY_URL . 'includes/js/ditty.min.js', array( 'jquery', 'jquery-effects-core', ), $this->version, true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
468 |
if ( empty( $ditty_scripts_enqueued ) ) {
|
469 |
+
wp_add_inline_script( 'ditty', 'const dittyVars = ' . json_encode( array(
|
470 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
471 |
+
'security' => wp_create_nonce( 'ditty' ),
|
472 |
+
'mode' => WP_DEBUG ? 'development' : 'production',
|
473 |
+
'strings' => ditty_strings(),
|
474 |
+
'adminStrings' => is_admin() ? ditty_admin_strings() : false,
|
475 |
+
'globals' => ditty_get_globals(),
|
476 |
+
'updateIcon' => 'fas fa-sync-alt fa-spin',
|
477 |
+
'updateInterval' => ( MINUTE_IN_SECONDS * ditty_settings( 'live_refresh' ) ),
|
478 |
+
'editor' => array(
|
479 |
+
'ditty_layouts_sass' => ditty_settings( 'ditty_layouts_sass' ),
|
480 |
+
),
|
481 |
) ), 'before' );
|
482 |
}
|
|
|
483 |
|
484 |
+
wp_register_script( 'ditty-slider', DITTY_URL . 'includes/js/class-ditty-slider' . $min . '.js', array( 'jquery', 'hammer' ), $this->version, true );
|
485 |
+
wp_register_script( 'ditty-display-ticker', DITTY_URL . 'includes/js/class-ditty-display-ticker' . $min . '.js', array( 'jquery' ), $this->version, true );
|
486 |
+
wp_register_script( 'ditty-display-list', DITTY_URL . 'includes/js/class-ditty-display-list' . $min . '.js', array( 'jquery', 'ditty-slider' ), $this->version, true );
|
487 |
+
|
488 |
if ( is_admin() ) {
|
489 |
|
490 |
// Make sure to enqueue the scripts in the admin
|
491 |
wp_enqueue_script( 'ditty-display-ticker' );
|
492 |
wp_enqueue_script( 'ditty-display-list' );
|
493 |
+
|
494 |
+
wp_enqueue_script( 'ion-rangeslider', DITTY_URL . 'includes/libs/ion.rangeSlider/js/ion.rangeSlider.min.js', array( 'jquery' ), '2.3.1', true );
|
495 |
+
wp_enqueue_script( 'jquery-minicolors', DITTY_URL . 'includes/libs/jquery-minicolors/jquery.minicolors.min.js', array( 'jquery' ), '2.3.5', true );
|
496 |
+
wp_register_script( 'protip', DITTY_URL . 'includes/libs/protip/protip.min.js', array( 'jquery' ), '1.4.21', true );
|
497 |
+
wp_enqueue_script( 'ditty-fields', DITTY_URL . 'includes/fields/js/ditty-fields.min.js', array(
|
498 |
+
'jquery',
|
499 |
+
'protip',
|
500 |
+
'jquery-effects-core',
|
501 |
+
'wp-codemirror',
|
502 |
+
'ion-rangeslider',
|
503 |
+
'jquery-minicolors',
|
504 |
+
), $this->version, true );
|
505 |
+
wp_register_script( 'ditty-editor', DITTY_URL . 'includes/js/ditty-editor.min.js', array(
|
506 |
+
'jquery',
|
507 |
+
'protip',
|
508 |
+
'iris',
|
509 |
+
'jquery-form',
|
510 |
+
'jquery-ui-core',
|
511 |
+
'jquery-effects-core',
|
512 |
+
'wp-codemirror',
|
513 |
+
'ditty-slider',
|
514 |
+
'ditty-fields',
|
515 |
+
), $this->version, true );
|
516 |
+
wp_register_script( 'ditty-admin', DITTY_URL . 'includes/js/ditty-admin.min.js', array(
|
517 |
+
'jquery',
|
518 |
+
'jquery-ui-core',
|
519 |
+
'jquery-ui-sortable',
|
520 |
+
'wp-i18n',
|
521 |
+
), $this->version, true );
|
522 |
+
|
523 |
+
|
524 |
+
if ( empty( $ditty_scripts_enqueued ) ) {
|
525 |
+
wp_add_inline_script( 'ditty-admin', 'const dittyAdminVars = ' . json_encode( array(
|
526 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
527 |
+
'security' => wp_create_nonce( 'ditty' ),
|
528 |
+
'mode' => WP_DEBUG ? 'development' : 'production',
|
529 |
+
'adminStrings' => is_admin() ? ditty_admin_strings() : false,
|
530 |
+
'updateIcon' => 'fas fa-sync-alt fa-spin',
|
531 |
+
) ), 'before' );
|
532 |
+
}
|
533 |
|
534 |
if ( current_user_can( 'edit_dittys' ) || current_user_can( 'edit_ditty_layouts' ) ) {
|
535 |
wp_enqueue_editor();
|
550 |
wp_dequeue_script( 'autosave' );
|
551 |
}
|
552 |
}
|
553 |
+
|
554 |
+
$ditty_scripts_enqueued = 'enqueued';
|
555 |
}
|
556 |
|
557 |
/**
|
604 |
/**
|
605 |
* Enqueue global scripts for any Ditty's displayed
|
606 |
*
|
607 |
+
* @since 3.0.12
|
608 |
*/
|
609 |
public function enqueue_global_scripts() {
|
610 |
global $ditty_item_scripts;
|
620 |
wp_print_scripts( "ditty-{$ditty_item_script}" );
|
621 |
}
|
622 |
}
|
623 |
+
if ( is_array( $ditty_display_scripts ) && count( $ditty_display_scripts ) > 0 ) {
|
624 |
+
$add_ditty = false;
|
625 |
foreach ( $ditty_display_scripts as $i => $ditty_display_script ) {
|
626 |
+
if ( empty( $ditty_display_script ) ) {
|
627 |
+
continue;
|
628 |
+
}
|
629 |
wp_print_scripts( "ditty-display-{$ditty_display_script}" );
|
630 |
+
$add_ditty = true;
|
631 |
+
}
|
632 |
+
if ( $add_ditty ) {
|
633 |
+
wp_print_scripts( 'ditty' );
|
634 |
}
|
635 |
}
|
636 |
global $ditty_singles;
|
640 |
if ( is_array( $ditty_singles ) && count( $ditty_singles ) > 0 ) {
|
641 |
?>
|
642 |
<script id="ditty-singles">
|
643 |
+
jQuery( function( $ ) {
|
644 |
<?php
|
645 |
foreach ( $ditty_singles as $ditty_atts ) {
|
646 |
Ditty()->singles->init( $ditty_atts );
|
includes/css/ditty-admin.css
CHANGED
@@ -530,6 +530,24 @@ table.wp-list-table .type-ditty_display .row-actions {
|
|
530 |
-o-object-fit: cover;
|
531 |
object-fit: cover; }
|
532 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
533 |
.datepicker-container {
|
534 |
background-color: #fff;
|
535 |
direction: ltr;
|
530 |
-o-object-fit: cover;
|
531 |
object-fit: cover; }
|
532 |
|
533 |
+
/* File */
|
534 |
+
.ditty-input--file .ditty-field__input__primary {
|
535 |
+
display: flex;
|
536 |
+
flex-direction: row;
|
537 |
+
align-items: stretch;
|
538 |
+
justify-content: flex-start; }
|
539 |
+
|
540 |
+
.ditty-input--file input[type="text"] {
|
541 |
+
border-top-right-radius: 0 !important;
|
542 |
+
border-bottom-right-radius: 0 !important; }
|
543 |
+
|
544 |
+
.ditty-input--file .ditty-button {
|
545 |
+
padding-left: 20px;
|
546 |
+
padding-right: 20px;
|
547 |
+
margin: 0;
|
548 |
+
border-top-left-radius: 0;
|
549 |
+
border-bottom-left-radius: 0; }
|
550 |
+
|
551 |
.datepicker-container {
|
552 |
background-color: #fff;
|
553 |
direction: ltr;
|
includes/css/ditty.css
CHANGED
@@ -723,7 +723,7 @@
|
|
723 |
align-items: stretch;
|
724 |
justify-content: flex-start;
|
725 |
width: 350px;
|
726 |
-
background: #
|
727 |
#ditty-editor__settings .ditty-field {
|
728 |
padding: 15px;
|
729 |
border-color: rgba(0, 0, 0, 0.05); }
|
@@ -935,7 +935,6 @@
|
|
935 |
.ditty-editor-options__body {
|
936 |
position: relative;
|
937 |
max-height: calc( 100vh - 470px);
|
938 |
-
min-height: 300px;
|
939 |
overflow-y: scroll;
|
940 |
-webkit-overflow-scrolling: touch; }
|
941 |
.ditty-editor-options__body__error {
|
@@ -1013,6 +1012,15 @@
|
|
1013 |
background-color: #fbeaea;
|
1014 |
border-color: #E1362E; }
|
1015 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1016 |
@-webkit-keyframes ditty-unsaved-changes {
|
1017 |
0% {
|
1018 |
color: #FFF; }
|
723 |
align-items: stretch;
|
724 |
justify-content: flex-start;
|
725 |
width: 350px;
|
726 |
+
background: #EBEBEB; }
|
727 |
#ditty-editor__settings .ditty-field {
|
728 |
padding: 15px;
|
729 |
border-color: rgba(0, 0, 0, 0.05); }
|
935 |
.ditty-editor-options__body {
|
936 |
position: relative;
|
937 |
max-height: calc( 100vh - 470px);
|
|
|
938 |
overflow-y: scroll;
|
939 |
-webkit-overflow-scrolling: touch; }
|
940 |
.ditty-editor-options__body__error {
|
1012 |
background-color: #fbeaea;
|
1013 |
border-color: #E1362E; }
|
1014 |
|
1015 |
+
.ditty-editor__panel--item_editor .ditty-editor-options__body {
|
1016 |
+
display: flex;
|
1017 |
+
flex-direction: row;
|
1018 |
+
align-items: flex-start;
|
1019 |
+
justify-content: flex-start;
|
1020 |
+
flex-wrap: wrap; }
|
1021 |
+
.ditty-editor__panel--item_editor .ditty-editor-options__body > .ditty-field {
|
1022 |
+
width: 100%; }
|
1023 |
+
|
1024 |
@-webkit-keyframes ditty-unsaved-changes {
|
1025 |
0% {
|
1026 |
color: #FFF; }
|
includes/fields/ditty-field-file.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Ditty File Field Class
|
5 |
+
*
|
6 |
+
* @package Ditty
|
7 |
+
* @subpackage Classes/Ditty Field File
|
8 |
+
* @copyright Copyright (c) 2022, Metaphor Creations
|
9 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
10 |
+
* @since 3.0.12
|
11 |
+
*/
|
12 |
+
class Ditty_Field_File extends Ditty_Field {
|
13 |
+
public $type = 'file';
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Return the default atts
|
17 |
+
*
|
18 |
+
* @access private
|
19 |
+
* @since 3.0
|
20 |
+
*/
|
21 |
+
public function defaults() {
|
22 |
+
$atts = array(
|
23 |
+
'file_types' => array(),
|
24 |
+
'multiple' => false,
|
25 |
+
'media_title' => __( 'Upload or select a file', 'ditty-news-ticker' ),
|
26 |
+
'media_button' => __( 'Insert File', 'ditty-news-ticker' ),
|
27 |
+
);
|
28 |
+
return wp_parse_args( $atts, $this->common );
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Return the input
|
33 |
+
*
|
34 |
+
* @since 3.0
|
35 |
+
* @return $html string
|
36 |
+
*/
|
37 |
+
public function input( $name, $std = false ) {
|
38 |
+
$html = '';
|
39 |
+
|
40 |
+
$atts = array(
|
41 |
+
'name' => $name,
|
42 |
+
'type' => 'text',
|
43 |
+
'class' => ( $this->args['input_class'] ) ? $this->args['input_class'] : false,
|
44 |
+
'data-media_title' => $this->args['media_title'],
|
45 |
+
'data-media_button' => $this->args['media_button'],
|
46 |
+
'data-file_types' => json_encode( $this->args['file_types'] ),
|
47 |
+
'data-multiple' => $this->args['multiple'],
|
48 |
+
'value' => $std,
|
49 |
+
);
|
50 |
+
//$html .= '<div class="ditty-input--image__preview">';
|
51 |
+
$html .= '<input ' . ditty_attr_to_html( $atts ) . ' />';
|
52 |
+
$html .= '<a href="#" class="ditty-input--file__upload ditty-button ditty-button--small">' . __( 'Upload File', 'ditty-news-ticker' ) . '</a>';
|
53 |
+
//$html .= '</div>';
|
54 |
+
return $html;
|
55 |
+
}
|
56 |
+
}
|
includes/fields/ditty-field-radio.php
CHANGED
@@ -64,7 +64,7 @@ class Ditty_Field_Radio extends Ditty_Field {
|
|
64 |
/**
|
65 |
* Return the input
|
66 |
*
|
67 |
-
* @since 3.0
|
68 |
* @return $html string
|
69 |
*/
|
70 |
public function input( $name, $std = false ) {
|
@@ -72,9 +72,9 @@ class Ditty_Field_Radio extends Ditty_Field {
|
|
72 |
if ( is_array( $this->args['options'] ) && count( $this->args['options'] ) > 0 ) {
|
73 |
foreach ( $this->args['options'] as $value => $label ) {
|
74 |
$input_id = uniqid( 'ditty-input--' );
|
75 |
-
$html .= '<span class="ditty-input--radio__option">';
|
76 |
$sanitized_value = sanitize_text_field( $value );
|
77 |
-
$html .= '<input id="' . $input_id . '" name="' . $name . '" type="radio" value="' . $sanitized_value . '" ' . checked( $sanitized_value, $this->args['std'], false ) . ' /> <label for="' . $input_id . '">' . sanitize_text_field( $label ) . '</label>';
|
78 |
$html .= '</span>';
|
79 |
}
|
80 |
}
|
64 |
/**
|
65 |
* Return the input
|
66 |
*
|
67 |
+
* @since 3.0.12
|
68 |
* @return $html string
|
69 |
*/
|
70 |
public function input( $name, $std = false ) {
|
72 |
if ( is_array( $this->args['options'] ) && count( $this->args['options'] ) > 0 ) {
|
73 |
foreach ( $this->args['options'] as $value => $label ) {
|
74 |
$input_id = uniqid( 'ditty-input--' );
|
75 |
+
$html .= '<span class="ditty-input--radio__option ditty-input--radio__option--' . esc_attr( $value ) . '">';
|
76 |
$sanitized_value = sanitize_text_field( $value );
|
77 |
+
$html .= '<input id="' . esc_attr( $input_id ) . '" name="' . esc_attr( $name ) . '" type="radio" value="' . esc_attr( $sanitized_value ) . '" ' . checked( $sanitized_value, $this->args['std'], false ) . ' /> <label for="' . esc_attr( $input_id ) . '">' . sanitize_text_field( $label ) . '</label>';
|
78 |
$html .= '</span>';
|
79 |
}
|
80 |
}
|
includes/fields/helpers.php
CHANGED
@@ -25,11 +25,14 @@ function ditty_field( $args = array() ) {
|
|
25 |
* Display multiple fields
|
26 |
*
|
27 |
* @access public
|
28 |
-
* @since 3.0
|
29 |
*/
|
30 |
function ditty_fields( $fields = array(), $values = array(), $action = 'render' ) {
|
31 |
if ( is_array( $fields ) && count( $fields ) > 0 ) {
|
32 |
foreach ( $fields as &$field ) {
|
|
|
|
|
|
|
33 |
if ( isset( $values[$field['id']] ) ) {
|
34 |
$field['std'] = $values[$field['id']];
|
35 |
}
|
25 |
* Display multiple fields
|
26 |
*
|
27 |
* @access public
|
28 |
+
* @since 3.0.12
|
29 |
*/
|
30 |
function ditty_fields( $fields = array(), $values = array(), $action = 'render' ) {
|
31 |
if ( is_array( $fields ) && count( $fields ) > 0 ) {
|
32 |
foreach ( $fields as &$field ) {
|
33 |
+
if ( ! is_array( $field ) ) {
|
34 |
+
continue;
|
35 |
+
}
|
36 |
if ( isset( $values[$field['id']] ) ) {
|
37 |
$field['std'] = $values[$field['id']];
|
38 |
}
|
includes/fields/js/ditty-fields.js
CHANGED
@@ -6,6 +6,7 @@
|
|
6 |
// @codekit-append 'fields/code.js
|
7 |
// @codekit-append 'fields/color.js
|
8 |
// @codekit-append 'fields/date.js
|
|
|
9 |
// @codekit-append 'fields/image.js
|
10 |
// @codekit-append 'fields/slider.js
|
11 |
// @codekit-append 'fields/wysiwyg.js
|
6 |
// @codekit-append 'fields/code.js
|
7 |
// @codekit-append 'fields/color.js
|
8 |
// @codekit-append 'fields/date.js
|
9 |
+
// @codekit-append 'fields/file.js
|
10 |
// @codekit-append 'fields/image.js
|
11 |
// @codekit-append 'fields/slider.js
|
12 |
// @codekit-append 'fields/wysiwyg.js
|
includes/fields/js/ditty-fields.min.js
CHANGED
@@ -6,12 +6,13 @@
|
|
6 |
// @codekit-append 'fields/code.js
|
7 |
// @codekit-append 'fields/color.js
|
8 |
// @codekit-append 'fields/date.js
|
|
|
9 |
// @codekit-append 'fields/image.js
|
10 |
// @codekit-append 'fields/slider.js
|
11 |
// @codekit-append 'fields/wysiwyg.js
|
12 |
// @codekit-append 'fields/group.js
|
13 |
|
14 |
-
jQuery(
|
15 |
|
16 |
// Setup strict mode
|
17 |
(function() {
|
@@ -174,7 +175,7 @@ jQuery( document ).ready( function( $ ) {
|
|
174 |
|
175 |
/* global _:true */
|
176 |
|
177 |
-
jQuery(
|
178 |
|
179 |
// Setup strict mode
|
180 |
(function() {
|
@@ -211,7 +212,7 @@ jQuery( document ).ready( function( $ ) {
|
|
211 |
|
212 |
} );
|
213 |
|
214 |
-
jQuery(
|
215 |
|
216 |
// Setup strict mode
|
217 |
(function() {
|
@@ -237,7 +238,7 @@ jQuery( document ).ready( function( $ ) {
|
|
237 |
|
238 |
} );
|
239 |
|
240 |
-
jQuery(
|
241 |
|
242 |
// Setup strict mode
|
243 |
(function() {
|
@@ -262,7 +263,87 @@ jQuery( document ).ready( function( $ ) {
|
|
262 |
|
263 |
} );
|
264 |
|
265 |
-
jQuery(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
|
267 |
// Setup strict mode
|
268 |
(function() {
|
@@ -351,7 +432,7 @@ jQuery( document ).ready( function( $ ) {
|
|
351 |
|
352 |
} );
|
353 |
|
354 |
-
jQuery(
|
355 |
|
356 |
// Setup strict mode
|
357 |
(function() {
|
@@ -380,7 +461,7 @@ jQuery( document ).ready( function( $ ) {
|
|
380 |
/* global QTags:true */
|
381 |
/* global wp:true */
|
382 |
|
383 |
-
jQuery(
|
384 |
|
385 |
// Setup strict mode
|
386 |
(function() {
|
@@ -511,7 +592,7 @@ jQuery( document ).ready( function( $ ) {
|
|
511 |
|
512 |
} );
|
513 |
|
514 |
-
jQuery(
|
515 |
|
516 |
// Setup strict mode
|
517 |
(function() {
|
6 |
// @codekit-append 'fields/code.js
|
7 |
// @codekit-append 'fields/color.js
|
8 |
// @codekit-append 'fields/date.js
|
9 |
+
// @codekit-append 'fields/file.js
|
10 |
// @codekit-append 'fields/image.js
|
11 |
// @codekit-append 'fields/slider.js
|
12 |
// @codekit-append 'fields/wysiwyg.js
|
13 |
// @codekit-append 'fields/group.js
|
14 |
|
15 |
+
jQuery( function( $ ) {
|
16 |
|
17 |
// Setup strict mode
|
18 |
(function() {
|
175 |
|
176 |
/* global _:true */
|
177 |
|
178 |
+
jQuery( function( $ ) {
|
179 |
|
180 |
// Setup strict mode
|
181 |
(function() {
|
212 |
|
213 |
} );
|
214 |
|
215 |
+
jQuery( function( $ ) {
|
216 |
|
217 |
// Setup strict mode
|
218 |
(function() {
|
238 |
|
239 |
} );
|
240 |
|
241 |
+
jQuery( function( $ ) {
|
242 |
|
243 |
// Setup strict mode
|
244 |
(function() {
|
263 |
|
264 |
} );
|
265 |
|
266 |
+
jQuery( function( $ ) {
|
267 |
+
|
268 |
+
// Setup strict mode
|
269 |
+
(function() {
|
270 |
+
|
271 |
+
"use strict";
|
272 |
+
|
273 |
+
function setup( $field ) {
|
274 |
+
$field.addClass( 'ditty-input--file--init' );
|
275 |
+
|
276 |
+
var $input = $field.find( 'input[type="text"]' ),
|
277 |
+
uploader;
|
278 |
+
|
279 |
+
$field.on( 'click', '.ditty-input--file__upload', function( e ) {
|
280 |
+
e.preventDefault();
|
281 |
+
if ( undefined === uploader ) {
|
282 |
+
uploader = wp.media( {
|
283 |
+
title: $input.data( 'media_title' ),
|
284 |
+
button: { text: $input.data( 'media_button' ), size: 'small' },
|
285 |
+
multiple: $input.data( 'multiple' ),
|
286 |
+
library : {
|
287 |
+
type : $input.data( 'file_types' ),
|
288 |
+
}
|
289 |
+
} );
|
290 |
+
}
|
291 |
+
|
292 |
+
uploader.on( 'open', function() {
|
293 |
+
var selection = uploader.state().get( 'selection' );
|
294 |
+
var attachment = wp.media.attachment( $input.val() );
|
295 |
+
if ( attachment ) {
|
296 |
+
selection.add( attachment );
|
297 |
+
}
|
298 |
+
// let ids = [13, 14, 56];
|
299 |
+
// ids.forEach(function(id) {
|
300 |
+
// let attachment = wp.media.attachment(id);
|
301 |
+
// selection.add(attachment ? [attachment] : []);
|
302 |
+
// } );
|
303 |
+
} );
|
304 |
+
|
305 |
+
uploader.on( 'select', function() {
|
306 |
+
var attachments = uploader.state().get( 'selection' ).toJSON(),
|
307 |
+
file_data = [];
|
308 |
+
|
309 |
+
if ( attachments.length > 0 ) {
|
310 |
+
$(attachments).each( function() {
|
311 |
+
file_data.push( {
|
312 |
+
id : $(this)[0].id,
|
313 |
+
title : $(this)[0].title,
|
314 |
+
caption : $(this)[0].caption,
|
315 |
+
description : $(this)[0].description,
|
316 |
+
link : $(this)[0].link,
|
317 |
+
url : $(this)[0].url
|
318 |
+
} );
|
319 |
+
} );
|
320 |
+
}
|
321 |
+
|
322 |
+
$input.val( file_data[0].url );
|
323 |
+
|
324 |
+
$field.trigger( 'ditty_field_file_select', [$field, file_data] );
|
325 |
+
$field.trigger( 'ditty_field_update' );
|
326 |
+
} );
|
327 |
+
|
328 |
+
uploader.open();
|
329 |
+
return false;
|
330 |
+
|
331 |
+
} );
|
332 |
+
|
333 |
+
}
|
334 |
+
|
335 |
+
function init( e ) {
|
336 |
+
$( e.target ).find( '.ditty-input--file:not(.ditty-input--file--init)' ).each( function() {
|
337 |
+
setup( $( this ) );
|
338 |
+
} );
|
339 |
+
}
|
340 |
+
$( document ).on( 'ditty_init_fields', init );
|
341 |
+
|
342 |
+
}() );
|
343 |
+
|
344 |
+
} );
|
345 |
+
|
346 |
+
jQuery( function( $ ) {
|
347 |
|
348 |
// Setup strict mode
|
349 |
(function() {
|
432 |
|
433 |
} );
|
434 |
|
435 |
+
jQuery( function( $ ) {
|
436 |
|
437 |
// Setup strict mode
|
438 |
(function() {
|
461 |
/* global QTags:true */
|
462 |
/* global wp:true */
|
463 |
|
464 |
+
jQuery( function( $ ) {
|
465 |
|
466 |
// Setup strict mode
|
467 |
(function() {
|
592 |
|
593 |
} );
|
594 |
|
595 |
+
jQuery( function( $ ) {
|
596 |
|
597 |
// Setup strict mode
|
598 |
(function() {
|
includes/fields/js/fields/clone.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
jQuery(
|
2 |
|
3 |
// Setup strict mode
|
4 |
(function() {
|
1 |
+
jQuery( function( $ ) {
|
2 |
|
3 |
// Setup strict mode
|
4 |
(function() {
|
includes/fields/js/fields/code.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/* global _:true */
|
2 |
|
3 |
-
jQuery(
|
4 |
|
5 |
// Setup strict mode
|
6 |
(function() {
|
1 |
/* global _:true */
|
2 |
|
3 |
+
jQuery( function( $ ) {
|
4 |
|
5 |
// Setup strict mode
|
6 |
(function() {
|
includes/fields/js/fields/color.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
jQuery(
|
2 |
|
3 |
// Setup strict mode
|
4 |
(function() {
|
1 |
+
jQuery( function( $ ) {
|
2 |
|
3 |
// Setup strict mode
|
4 |
(function() {
|
includes/fields/js/fields/date.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
jQuery(
|
2 |
|
3 |
// Setup strict mode
|
4 |
(function() {
|
1 |
+
jQuery( function( $ ) {
|
2 |
|
3 |
// Setup strict mode
|
4 |
(function() {
|
includes/fields/js/fields/file.js
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery( function( $ ) {
|
2 |
+
|
3 |
+
// Setup strict mode
|
4 |
+
(function() {
|
5 |
+
|
6 |
+
"use strict";
|
7 |
+
|
8 |
+
function setup( $field ) {
|
9 |
+
$field.addClass( 'ditty-input--file--init' );
|
10 |
+
|
11 |
+
var $input = $field.find( 'input[type="text"]' ),
|
12 |
+
uploader;
|
13 |
+
|
14 |
+
$field.on( 'click', '.ditty-input--file__upload', function( e ) {
|
15 |
+
e.preventDefault();
|
16 |
+
if ( undefined === uploader ) {
|
17 |
+
uploader = wp.media( {
|
18 |
+
title: $input.data( 'media_title' ),
|
19 |
+
button: { text: $input.data( 'media_button' ), size: 'small' },
|
20 |
+
multiple: $input.data( 'multiple' ),
|
21 |
+
library : {
|
22 |
+
type : $input.data( 'file_types' ),
|
23 |
+
}
|
24 |
+
} );
|
25 |
+
}
|
26 |
+
|
27 |
+
uploader.on( 'open', function() {
|
28 |
+
var selection = uploader.state().get( 'selection' );
|
29 |
+
var attachment = wp.media.attachment( $input.val() );
|
30 |
+
if ( attachment ) {
|
31 |
+
selection.add( attachment );
|
32 |
+
}
|
33 |
+
// let ids = [13, 14, 56];
|
34 |
+
// ids.forEach(function(id) {
|
35 |
+
// let attachment = wp.media.attachment(id);
|
36 |
+
// selection.add(attachment ? [attachment] : []);
|
37 |
+
// } );
|
38 |
+
} );
|
39 |
+
|
40 |
+
uploader.on( 'select', function() {
|
41 |
+
var attachments = uploader.state().get( 'selection' ).toJSON(),
|
42 |
+
file_data = [];
|
43 |
+
|
44 |
+
if ( attachments.length > 0 ) {
|
45 |
+
$(attachments).each( function() {
|
46 |
+
file_data.push( {
|
47 |
+
id : $(this)[0].id,
|
48 |
+
title : $(this)[0].title,
|
49 |
+
caption : $(this)[0].caption,
|
50 |
+
description : $(this)[0].description,
|
51 |
+
link : $(this)[0].link,
|
52 |
+
url : $(this)[0].url
|
53 |
+
} );
|
54 |
+
} );
|
55 |
+
}
|
56 |
+
|
57 |
+
$input.val( file_data[0].url );
|
58 |
+
|
59 |
+
$field.trigger( 'ditty_field_file_select', [$field, file_data] );
|
60 |
+
$field.trigger( 'ditty_field_update' );
|
61 |
+
} );
|
62 |
+
|
63 |
+
uploader.open();
|
64 |
+
return false;
|
65 |
+
|
66 |
+
} );
|
67 |
+
|
68 |
+
}
|
69 |
+
|
70 |
+
function init( e ) {
|
71 |
+
$( e.target ).find( '.ditty-input--file:not(.ditty-input--file--init)' ).each( function() {
|
72 |
+
setup( $( this ) );
|
73 |
+
} );
|
74 |
+
}
|
75 |
+
$( document ).on( 'ditty_init_fields', init );
|
76 |
+
|
77 |
+
}() );
|
78 |
+
|
79 |
+
} );
|
includes/fields/js/fields/group.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
jQuery(
|
2 |
|
3 |
// Setup strict mode
|
4 |
(function() {
|
1 |
+
jQuery( function( $ ) {
|
2 |
|
3 |
// Setup strict mode
|
4 |
(function() {
|
includes/fields/js/fields/image.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
jQuery(
|
2 |
|
3 |
// Setup strict mode
|
4 |
(function() {
|
1 |
+
jQuery( function( $ ) {
|
2 |
|
3 |
// Setup strict mode
|
4 |
(function() {
|
includes/fields/js/fields/slider.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
jQuery(
|
2 |
|
3 |
// Setup strict mode
|
4 |
(function() {
|
1 |
+
jQuery( function( $ ) {
|
2 |
|
3 |
// Setup strict mode
|
4 |
(function() {
|
includes/fields/js/fields/wysiwyg.js
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
/* global QTags:true */
|
5 |
/* global wp:true */
|
6 |
|
7 |
-
jQuery(
|
8 |
|
9 |
// Setup strict mode
|
10 |
(function() {
|
4 |
/* global QTags:true */
|
5 |
/* global wp:true */
|
6 |
|
7 |
+
jQuery( function( $ ) {
|
8 |
|
9 |
// Setup strict mode
|
10 |
(function() {
|
includes/helpers.php
CHANGED
@@ -934,7 +934,7 @@ function ditty_parse_custom_layouts( $layout_settings ) {
|
|
934 |
/**
|
935 |
* Return display items for a specific Ditty
|
936 |
*
|
937 |
-
* @since 3.0.
|
938 |
* @access public
|
939 |
* @var array $display_items Array of item objects
|
940 |
*/
|
@@ -953,7 +953,8 @@ function ditty_display_items( $ditty_id, $load_type = 'cache', $custom_layouts =
|
|
953 |
if ( ! $display_items || 'force' == $load_type ) {
|
954 |
$display_items = array();
|
955 |
$items_meta = ditty_items_meta( $ditty_id );
|
956 |
-
|
|
|
957 |
$items_meta = array( ditty_get_new_item_meta( $ditty_id ) );
|
958 |
}
|
959 |
if ( is_array( $items_meta ) && count( $items_meta ) > 0 ) {
|
@@ -1300,7 +1301,7 @@ function ditty_render( $atts ) {
|
|
1300 |
/**
|
1301 |
* Parse ditty script types and add to global
|
1302 |
*
|
1303 |
-
* @since 3.0.
|
1304 |
*/
|
1305 |
function ditty_add_scripts( $ditty_id, $display = '' ) {
|
1306 |
|
@@ -1324,9 +1325,8 @@ function ditty_add_scripts( $ditty_id, $display = '' ) {
|
|
1324 |
}
|
1325 |
}
|
1326 |
}
|
1327 |
-
|
1328 |
-
|
1329 |
-
if ( ! $display || '' === $display ) {
|
1330 |
$display = get_post_meta( $ditty_id, '_ditty_display', true );
|
1331 |
}
|
1332 |
$display_obj = new Ditty_Display( $display );
|
934 |
/**
|
935 |
* Return display items for a specific Ditty
|
936 |
*
|
937 |
+
* @since 3.0.12
|
938 |
* @access public
|
939 |
* @var array $display_items Array of item objects
|
940 |
*/
|
953 |
if ( ! $display_items || 'force' == $load_type ) {
|
954 |
$display_items = array();
|
955 |
$items_meta = ditty_items_meta( $ditty_id );
|
956 |
+
$initialized = get_post_meta( $ditty_id, '_ditty_init', true );
|
957 |
+
if ( empty( $items_meta) && ! $initialized ) {
|
958 |
$items_meta = array( ditty_get_new_item_meta( $ditty_id ) );
|
959 |
}
|
960 |
if ( is_array( $items_meta ) && count( $items_meta ) > 0 ) {
|
1301 |
/**
|
1302 |
* Parse ditty script types and add to global
|
1303 |
*
|
1304 |
+
* @since 3.0.12
|
1305 |
*/
|
1306 |
function ditty_add_scripts( $ditty_id, $display = '' ) {
|
1307 |
|
1325 |
}
|
1326 |
}
|
1327 |
}
|
1328 |
+
|
1329 |
+
if ( ! ( $display && ( 'publish' == get_post_status( $display ) ) ) ) {
|
|
|
1330 |
$display = get_post_meta( $ditty_id, '_ditty_display', true );
|
1331 |
}
|
1332 |
$display_obj = new Ditty_Display( $display );
|
includes/js/admin/ditty-displays.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
|
2 |
-
jQuery(
|
3 |
// Setup strict mode
|
4 |
(function() {
|
5 |
|
1 |
|
2 |
+
jQuery( function( $ ) {
|
3 |
// Setup strict mode
|
4 |
(function() {
|
5 |
|
includes/js/admin/ditty-extensions.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
|
2 |
-
jQuery(
|
3 |
// Setup strict mode
|
4 |
(function() {
|
5 |
|
1 |
|
2 |
+
jQuery( function( $ ) {
|
3 |
// Setup strict mode
|
4 |
(function() {
|
5 |
|
includes/js/ditty-admin.js
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
// @codekit-append 'admin/ditty-extensions.js';
|
8 |
// @codekit-append 'admin/ditty-displays.js';
|
9 |
|
10 |
-
jQuery(
|
11 |
|
12 |
// Setup strict mode
|
13 |
(function() {
|
7 |
// @codekit-append 'admin/ditty-extensions.js';
|
8 |
// @codekit-append 'admin/ditty-displays.js';
|
9 |
|
10 |
+
jQuery( function( $ ) {
|
11 |
|
12 |
// Setup strict mode
|
13 |
(function() {
|
includes/js/ditty-admin.min.js
CHANGED
@@ -1 +1,888 @@
|
|
1 |
-
jQuery(document).ready((function($){!function(){"use strict";$("#poststuff").trigger("ditty_init_fields"),$("#ditty-settings").ditty_settings()}()})),function($){"use strict";var t={},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_settings.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-settings__form"),this.$panels=this.$elmt.find(".ditty-settings__panels"),this.saveBtns=this.$elmt.find(".ditty-settings__save"),this.tabs=this.$elmt.find(".ditty-settings__tab"),this.$notice_update=this.$elmt.find(".ditty-notification--updated"),this.$notice_error=this.$elmt.find(".ditty-notification--error"),this.$notice_warning=this.$elmt.find(".ditty-notification--warning"),this.initData=null,this._init()};i.prototype={_init:function(){this._initSlider(),$("body").on("ditty_field_clone_update",{self:this},this._enableSettingsUpdates),this.saveBtns.on("click",{self:this},this._submitForm),this.tabs.on("click",{self:this},this._tabClick),this.$panels.on("ditty_slider_init",{self:this},this._sliderInit),this.$panels.on("ditty_slider_before_slide_update",{self:this},this._beforeSlideUpdate),this.$form.on("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.on("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.on("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.on("click",".ditty-default-layout-install",{self:this},this._installLayout),this.$form.on("click",".ditty-default-display-install",{self:this},this._installDisplay)},_initSlider:function(){var t=this.$panels.data("init_panel");this.$panels.ditty_slider({transition:"fade",transitionSpeed:.75,heightSpeed:.75,touchSwipe:!1,slidesEl:".ditty-settings__panel",slideId:""!==t&&t})},_sliderInit:function(t){var i=t.data.self;i.initData=i.$form.serialize()},_beforeSlideUpdate:function(t,i,e){var s=t.data.self;s._initFields(e.$elmt),s.$elmt.find(".ditty-settings__tab").removeClass("active"),s.$elmt.find('.ditty-settings__tab[data-panel="'+e.id+'"]').addClass("active")},_enableSettingsUpdates:function(t){(t?t.data.self:this).saveBtns.addClass("has-updates")},_disableSettingsUpdates:function(){this.saveBtns.removeClass("has-updates")},_checkUpdates:function(t){var i=t?t.data.self:this;i.$form.serialize()!==i.initData?i._enableSettingsUpdates():i._disableSettingsUpdates()},_initFields:function(t){t.find(".ditty-data-list").ditty_ui_data_list(),t.trigger("ditty_init_fields"),$.protip({defaults:{position:"top",size:"small",scheme:"black",classes:"ditty-protip"}})},_togglePostTypes:function(){if($('input[name="ditty_layout_ui"]').length){var t=$('input[name="ditty_layout_ui"]:checked').val(),i=$('#adminmenu .wp-submenu > li > a[href="edit.php?post_type=ditty_layout"]');"disabled"===t?i.hide():i.css("display","block")}if($('input[name="ditty_display_ui"]').length){var e=$('input[name="ditty_display_ui"]:checked').val(),s=$('#adminmenu .wp-submenu > li > a[href="edit.php?post_type=ditty_display"]');"disabled"===e?s.hide():s.css("display","block")}},_tabClick:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("a")?$(t.target):$(t.target).parent("a"),s=e.data("panel");if(i.$elmt.find(".ditty-settings__tab.active")===e)return!1;i.$elmt.find(".ditty-extension__tab").removeClass("active"),e.addClass("active"),i.$panels.ditty_slider("showSlideById",s)},_upateInputs:function(t){$.each(t,(function(t,i){$('input[name="'+t+'"]').length&&$('input[name="'+t+'"]').val(i)}))},_submitForm:function(t){t.preventDefault();var i=t.data.self;if(i.$elmt.hasClass("updating"))return!1;i.$elmt.trigger("ditty_pre_save_fields"),i.$elmt.addClass("updating"),i.saveBtns.text(dittyAdminVars.adminStrings.settingsSaving),i.$form.ajaxSubmit({url:dittyAdminVars.ajaxurl,type:"post",dataType:"json",data:{action:"ditty_settings_save",security:dittyAdminVars.security},success:function(t){t.input_updates&&i._upateInputs(t.input_updates),i.initData=i.$form.serialize(),i.saveBtns.text(dittyAdminVars.adminStrings.settings_updated),setTimeout((function(){i.saveBtns.text(dittyAdminVars.adminStrings.settings_save)}),2e3),i.$elmt.removeClass("updating"),i._disableSettingsUpdates(),i._togglePostTypes()}})},_installLayout:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("button")?$(t.target):$(t.target).parents("button"),s=e.find("i"),n=s.attr("class");if(e.hasClass("updating"))return!1;e.addClass("updating"),s.attr("class",dittyAdminVars.updateIcon);var a={action:"ditty_install_layout",layout_template:e.data("layout_template"),layout_version:e.data("layout_version"),security:dittyAdminVars.security};$.post(dittyAdminVars.ajaxurl,a,(function(t){s.attr("class",n),i.$elmt.removeClass("updating"),t&&e.replaceWith(t.button)}))},_installDisplay:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("button")?$(t.target):$(t.target).parents("button"),s=e.find("i"),n=s.attr("class");if(e.hasClass("updating"))return!1;e.addClass("updating"),s.attr("class",dittyAdminVars.updateIcon);var a={action:"ditty_install_display",display_type:e.data("display_type"),display_template:e.data("display_template"),display_version:e.data("display_version"),security:dittyAdminVars.security};$.post(dittyAdminVars.ajaxurl,a,(function(t){s.attr("class",n),i.$elmt.removeClass("updating"),t&&e.replaceWith(t.button)}))},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_settings_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_settings.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){$("body").off("ditty_field_clone_update",{self:this},this._enableSettingsUpdates),this.saveBtns.off("click",{self:this},this._submitForm),this.tabs.off("click",{self:this},this._tabClick),this.$panels.off("ditty_slider_init",{self:this},this._sliderInit),this.$panels.off("ditty_slider_before_slide_update",{self:this},this._beforeSlideUpdate),this.$form.off("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.off("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.off("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.off("click",".ditty-default-layout-install",{self:this},this._installLayout),this.$form.off("click",".ditty-default-display-install",{self:this},this._installDisplay),this.$panels.ditty_slider("destroy"),this.elmt._ditty_settings=null}},$.fn.ditty_settings=function(t){var e,s=arguments,n=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_settings||(this._ditty_settings=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_settings;if(!i)throw new Error("No Ditty_Settings applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):n=!0})),n)throw new Error('No method "'+t+'" in Ditty_Settings.');return void 0!==e?e:this}},$.ditty_settings={},$.ditty_settings.defaults=t}(jQuery),function($){"use strict";var t={},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_extension.defaults,e),this.$elmt=$(i),this.$panels=$(i).find(".ditty-extension__panels"),this.initPanel=this.$panels.data("init_panel"),this._init()};i.prototype={_init:function(){this.$elmt.on("click",".ditty-extension__tab",{self:this},this._tabClick),this.$elmt.on("click",'button[name="submit"]',{self:this},this._updatePanel),this.$elmt.on("click",".ditty-extension__license__submit",{self:this,action:"ditty_extension_license_activate"},this._licenseUpdate),this.$elmt.on("click",".ditty-extension__license__refresh",{self:this,action:"ditty_extension_license_refresh"},this._licenseUpdate),this.$elmt.on("click",".ditty-extension__license__deactivate",{self:this,action:"ditty_extension_license_deactivate"},this._licenseUpdate),this.$panels.on("ditty_slider_before_slide_update",{self:this},this._beforePanelUpdate),this._initSlider()},_initSlider:function(){var t={transition:"fade",transitionSpeed:.75,heightSpeed:.75,touchSwipe:!1,slidesEl:".ditty-extension__panel",slideId:""!==this.initPanel&&this.initPanel};this.$panels.ditty_slider(t)},_beforePanelUpdate:function(t,i,e){var s=t.data.self;s.$elmt.find(".ditty-extension__tab").removeClass("active"),s.$elmt.find('.ditty-extension__tab[data-slide_id="'+e.id+'"]').addClass("active")},_tabClick:function(t){t.preventDefault();var i=t.data.self,e=$(this),s=e.data("slide_id"),n="slideLeft",a=i.$elmt.find(".ditty-extension__tab.active");if(a===e)return!1;e.index()<a.index()&&(n="slideRight"),i.$panels.ditty_slider("options","transition",n),i.$panels.ditty_slider("showSlideById",s)},_updatePanel:function(t){t.preventDefault();var i=t.data.self,e=$(this),s=e.parents(".ditty-extension__panel"),n=e.parents(".ditty-extension__form"),a=e.find("i"),d=a.attr("class"),l=i.$elmt.data("extension"),o=s.data("slide_id");if(i.$elmt.hasClass("updating"))return!1;i.$elmt.addClass("updating"),a.attr("class",dittyAdminVars.updateIcon),n.ajaxSubmit({url:dittyAdminVars.ajaxurl,type:"post",dataType:"json",data:{action:"ditty_extension_panel_update",extension:l,panel:o,security:dittyAdminVars.security},success:function(t){a.attr("class",d),i.$elmt.removeClass("updating"),$("#ditty-extensions").trigger("ditty_extension_panel_updated",[t,i.$elmt,s])}})},_licenseUpdate:function(t){t.preventDefault();var i=t.data.self,e=t.data.action,s=$(this),n=i.$elmt.find(".ditty-extension__license__message"),a=s.siblings(".ditty-extension__license__input"),d=a.val(),l=s.data("extension"),o=s.data("extension_id"),r=s.data("extension_name"),_=s.children("i");if(i.$elmt.hasClass("updating"))return!1;i.$elmt.addClass("updating"),_.attr("class",dittyAdminVars.updateIcon);var p={action:e,license:d,extension:l,extension_id:o,extension_name:r,security:dittyAdminVars.security};$.post(dittyAdminVars.ajaxurl,p,(function(t){t&&(i.$elmt.attr("data-license_status",t.status),n.text(t.message)),t.license_key&&("DELETE"===t.license_key?a.val(""):a.val(t.license_key)),_.attr("class",_.data("class")),i.$elmt.removeClass("updating")}),"json")},_getOption:function(t){return this.settings[t]},_setOption:function(t,i){if(void 0===i)return!1;this.settings[t]=i},options:function(t,i){var e=this;if("object"==typeof t)$.each(t,(function(t,i){e._setOption(t,i)}));else{if("string"!=typeof t)return e.settings;if(void 0===i)return e._getOption(t);e._setOption(t,i)}},destroy:function(){this.$elmt.off("click",".ditty-extension__tab",{self:this},this._tabClick),this.$elmt.off("click",'button[name="submit"]',{self:this},this._updatePanel),this.$elmt.off("click",".ditty-extension__license__submit, .ditty-extension__license__refresh",{self:this,action:"ditty_extension_license_activate"},this._licenseUpdate),this.$elmt.off("click",".ditty-extension__license__deactivate",{self:this,action:"ditty_extension_license_deactivate"},this._licenseUpdate),this.$panels.off("ditty_slider_after_slide_update",{self:this},this._afterPanelUpdate),this.$panels.ditty_slider("destroy"),this.elmt._ditty_extension=null}},$.fn.ditty_extension=function(t){var e,s=arguments,n=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_extension||(this._ditty_extension=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_extension;if(!i)throw new Error("No Ditty_Extension applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):n=!0})),n)throw new Error('No method "'+t+'" in Ditty_Extension.');return void 0!==e?e:this}},$.ditty_extension={},$.ditty_extension.defaults=t}(jQuery),jQuery(document).ready((function($){!function(){"use strict";$.protip({defaults:{position:"top",size:"small",scheme:"black",classes:"ditty-protip"}}),$("#ditty-extensions").find(".ditty-extension").each((function(t){var i=$(this);i.find(".ditty-extension__panels").length&&i.ditty_extension(),$("#ditty-extensions").trigger("ditty_init_fields"),setTimeout((function(){i.addClass("ditty-extension--init")}),250*t)}))}()})),jQuery(document).ready((function($){!function(){"use strict";var t=$('input[name="post_type"]').length&&"ditty_display"==$('input[name="post_type"]').val(),i=!1;$("form#post").on("submit",(function(e){if(t&&!i){e.preventDefault();var s=$("#publishing-action").children('input[type="submit"]'),n=$("#publishing-action").children(".spinner");s.attr("disabled","disabled"),n.css("visibility","visible");var a={action:"ditty_admin_display_update",display_id:$('input[name="post_ID"]').val(),security:dittyAdminVars.security};$("#ditty-display-settings").ajaxSubmit({url:dittyAdminVars.ajaxurl,type:"post",dataType:"json",data:a,success:function(t){i=!0,$("form#post").submit()}})}}))}()}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* global jQuery:true */
|
2 |
+
/* global dittyAdminVars:true */
|
3 |
+
/* global console:true */
|
4 |
+
|
5 |
+
// @codekit-append 'admin/class-ditty-settings.js';
|
6 |
+
// @codekit-append 'admin/class-ditty-extension.js';
|
7 |
+
// @codekit-append 'admin/ditty-extensions.js';
|
8 |
+
// @codekit-append 'admin/ditty-displays.js';
|
9 |
+
|
10 |
+
jQuery( function( $ ) {
|
11 |
+
|
12 |
+
// Setup strict mode
|
13 |
+
(function() {
|
14 |
+
|
15 |
+
"use strict";
|
16 |
+
|
17 |
+
$( '#poststuff' ).trigger( 'ditty_init_fields' );
|
18 |
+
$( '#ditty-settings' ).ditty_settings();
|
19 |
+
|
20 |
+
}() );
|
21 |
+
|
22 |
+
} );
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Ditty Settings
|
26 |
+
*
|
27 |
+
* @since 3.0
|
28 |
+
* @return null
|
29 |
+
*/
|
30 |
+
|
31 |
+
(function ($) {
|
32 |
+
'use strict';
|
33 |
+
|
34 |
+
var defaults = {
|
35 |
+
};
|
36 |
+
|
37 |
+
var Ditty_Settings = function ( elmt, options ) {
|
38 |
+
|
39 |
+
this.elmt = elmt;
|
40 |
+
this.settings = $.extend( {}, defaults, $.ditty_settings.defaults, options );
|
41 |
+
this.$elmt = $( elmt );
|
42 |
+
this.$form = this.$elmt.find( '.ditty-settings__form' );
|
43 |
+
this.$panels = this.$elmt.find( '.ditty-settings__panels' );
|
44 |
+
this.saveBtns = this.$elmt.find( '.ditty-settings__save' );
|
45 |
+
this.tabs = this.$elmt.find( '.ditty-settings__tab' );
|
46 |
+
this.$notice_update = this.$elmt.find( '.ditty-notification--updated' );
|
47 |
+
this.$notice_error = this.$elmt.find( '.ditty-notification--error' );
|
48 |
+
this.$notice_warning = this.$elmt.find( '.ditty-notification--warning' );
|
49 |
+
this.initData = null;
|
50 |
+
this._init();
|
51 |
+
};
|
52 |
+
|
53 |
+
|
54 |
+
Ditty_Settings.prototype = {
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Initialize the data list
|
58 |
+
*
|
59 |
+
* @since 3.0
|
60 |
+
* @return null
|
61 |
+
*/
|
62 |
+
_init: function () {
|
63 |
+
|
64 |
+
// Initialize the slider
|
65 |
+
this._initSlider();
|
66 |
+
|
67 |
+
// Add listeners
|
68 |
+
$( 'body' ).on( 'ditty_field_clone_update', { self: this }, this._enableSettingsUpdates );
|
69 |
+
this.saveBtns.on( 'click', { self: this }, this._submitForm );
|
70 |
+
this.tabs.on( 'click', { self: this }, this._tabClick );
|
71 |
+
this.$panels.on( 'ditty_slider_init', { self: this }, this._sliderInit );
|
72 |
+
this.$panels.on( 'ditty_slider_before_slide_update', { self: this }, this._beforeSlideUpdate );
|
73 |
+
this.$form.on( 'keyup change', 'input[type="text"], input[type="number"], textarea, select', { self: this }, this._checkUpdates );
|
74 |
+
this.$form.on( 'click', 'input[type="radio"], input[type="checkbox"]', { self: this }, this._checkUpdates );
|
75 |
+
this.$form.on( 'ditty_input_wysiwyg_update', '.ditty-input--wysiwyg', { self: this }, this._checkUpdates );
|
76 |
+
this.$form.on( 'click', '.ditty-default-layout-install', { self: this }, this._installLayout );
|
77 |
+
this.$form.on( 'click', '.ditty-default-display-install', { self: this }, this._installDisplay );
|
78 |
+
},
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Initialize the extensions
|
82 |
+
*
|
83 |
+
* @since 3.0
|
84 |
+
* @return null
|
85 |
+
*/
|
86 |
+
_initSlider: function () {
|
87 |
+
var initPanel = this.$panels.data( 'init_panel' );
|
88 |
+
this.$panels.ditty_slider( {
|
89 |
+
transition : 'fade',
|
90 |
+
transitionSpeed : 0.75,
|
91 |
+
heightSpeed : 0.75,
|
92 |
+
touchSwipe : false,
|
93 |
+
slidesEl : '.ditty-settings__panel',
|
94 |
+
slideId : ( '' !== initPanel ) ? initPanel : false
|
95 |
+
} );
|
96 |
+
},
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Slider init
|
100 |
+
*
|
101 |
+
* @since 3.0
|
102 |
+
* @return null
|
103 |
+
*/
|
104 |
+
_sliderInit: function( e ) {
|
105 |
+
var self = e.data.self;
|
106 |
+
self.initData = self.$form.serialize();
|
107 |
+
},
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Before slide update
|
111 |
+
*
|
112 |
+
* @since 3.0
|
113 |
+
* @return null
|
114 |
+
*/
|
115 |
+
_beforeSlideUpdate: function( e, index, slide ) {
|
116 |
+
var self = e.data.self;
|
117 |
+
self._initFields( slide.$elmt );
|
118 |
+
self.$elmt.find( '.ditty-settings__tab' ).removeClass( 'active' );
|
119 |
+
self.$elmt.find( '.ditty-settings__tab[data-panel="' + slide.id + '"]' ).addClass( 'active' );
|
120 |
+
},
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Preview button add updates class
|
124 |
+
*
|
125 |
+
* @since 3.0
|
126 |
+
* @return null
|
127 |
+
*/
|
128 |
+
_enableSettingsUpdates: function( e ) {
|
129 |
+
var self = ( e ) ? e.data.self : this;
|
130 |
+
self.saveBtns.addClass( 'has-updates' );
|
131 |
+
//self.notice_warning.slideDown();
|
132 |
+
},
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Preview button remove updates class
|
136 |
+
*
|
137 |
+
* @since 3.0
|
138 |
+
* @return null
|
139 |
+
*/
|
140 |
+
_disableSettingsUpdates: function() {
|
141 |
+
this.saveBtns.removeClass( 'has-updates' );
|
142 |
+
},
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Check for updates
|
146 |
+
*
|
147 |
+
* @since 3.0
|
148 |
+
* @return null
|
149 |
+
*/
|
150 |
+
_checkUpdates: function( e ) {
|
151 |
+
var self = e ? e.data.self : this;
|
152 |
+
var currentData = self.$form.serialize();
|
153 |
+
if ( currentData !== self.initData ) {
|
154 |
+
self._enableSettingsUpdates();
|
155 |
+
} else {
|
156 |
+
self._disableSettingsUpdates();
|
157 |
+
}
|
158 |
+
},
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Initialize dynamic fields
|
162 |
+
*
|
163 |
+
* @since 3.0
|
164 |
+
* @return null
|
165 |
+
*/
|
166 |
+
_initFields: function ( $fields ) {
|
167 |
+
$fields.find( '.ditty-data-list' ).ditty_ui_data_list();
|
168 |
+
$fields.trigger( 'ditty_init_fields' );
|
169 |
+
$.protip( {
|
170 |
+
defaults: {
|
171 |
+
position: 'top',
|
172 |
+
size: 'small',
|
173 |
+
scheme: 'black',
|
174 |
+
classes: 'ditty-protip'
|
175 |
+
}
|
176 |
+
} );
|
177 |
+
},
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Show or hide post types
|
181 |
+
*
|
182 |
+
* @since 3.0
|
183 |
+
* @return null
|
184 |
+
*/
|
185 |
+
_togglePostTypes: function () {
|
186 |
+
if ( $( 'input[name="ditty_layout_ui"]' ).length ) {
|
187 |
+
var layoutUiVal = $( 'input[name="ditty_layout_ui"]:checked' ).val(),
|
188 |
+
$layoutMenu = $( '#adminmenu .wp-submenu > li > a[href="edit.php?post_type=ditty_layout"]' );
|
189 |
+
if ( 'disabled' === layoutUiVal ) {
|
190 |
+
$layoutMenu.hide();
|
191 |
+
} else {
|
192 |
+
$layoutMenu.css( 'display', 'block' );
|
193 |
+
}
|
194 |
+
}
|
195 |
+
if ( $( 'input[name="ditty_display_ui"]' ).length ) {
|
196 |
+
var displayUiVal = $( 'input[name="ditty_display_ui"]:checked' ).val(),
|
197 |
+
$displayMenu = $( '#adminmenu .wp-submenu > li > a[href="edit.php?post_type=ditty_display"]' );
|
198 |
+
if ( 'disabled' === displayUiVal ) {
|
199 |
+
$displayMenu.hide();
|
200 |
+
} else {
|
201 |
+
$displayMenu.css( 'display', 'block' );
|
202 |
+
}
|
203 |
+
}
|
204 |
+
},
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Listen for a tab click
|
208 |
+
*
|
209 |
+
* @since 3.0
|
210 |
+
* @return null
|
211 |
+
*/
|
212 |
+
_tabClick: function( e ) {
|
213 |
+
e.preventDefault();
|
214 |
+
var self = e.data.self,
|
215 |
+
$tab = $( e.target ).is( 'a' ) ? $( e.target ) : $( e.target ).parent( 'a' ),
|
216 |
+
slideId = $tab.data( 'panel' ),
|
217 |
+
$currentTab = self.$elmt.find( '.ditty-settings__tab.active' );
|
218 |
+
|
219 |
+
if ( $currentTab === $tab ) {
|
220 |
+
return false;
|
221 |
+
}
|
222 |
+
|
223 |
+
self.$elmt.find( '.ditty-extension__tab' ).removeClass( 'active' );
|
224 |
+
$tab.addClass( 'active' );
|
225 |
+
|
226 |
+
self.$panels.ditty_slider( 'showSlideById', slideId );
|
227 |
+
},
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Update inputs after save and sanitize
|
231 |
+
*
|
232 |
+
* @since 3.0
|
233 |
+
* @return null
|
234 |
+
*/
|
235 |
+
_upateInputs: function( updates ) {
|
236 |
+
$.each( updates, function( inputName, updatedValue ) {
|
237 |
+
if ( $( 'input[name="' + inputName + '"]' ).length ) {
|
238 |
+
$( 'input[name="' + inputName + '"]' ).val( updatedValue );
|
239 |
+
}
|
240 |
+
} );
|
241 |
+
},
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Submit updates
|
245 |
+
*
|
246 |
+
* @since 3.0
|
247 |
+
* @return null
|
248 |
+
*/
|
249 |
+
_submitForm: function( e ) {
|
250 |
+
e.preventDefault();
|
251 |
+
var self = e.data.self;
|
252 |
+
|
253 |
+
if ( self.$elmt.hasClass( 'updating' ) ) {
|
254 |
+
return false;
|
255 |
+
}
|
256 |
+
|
257 |
+
self.$elmt.trigger( 'ditty_pre_save_fields' );
|
258 |
+
self.$elmt.addClass( 'updating' );
|
259 |
+
self.saveBtns.text( dittyAdminVars.adminStrings.settingsSaving );
|
260 |
+
|
261 |
+
self.$form.ajaxSubmit( {
|
262 |
+
url : dittyAdminVars.ajaxurl,
|
263 |
+
type : 'post',
|
264 |
+
dataType : 'json',
|
265 |
+
data : {
|
266 |
+
action : 'ditty_settings_save',
|
267 |
+
security : dittyAdminVars.security
|
268 |
+
},
|
269 |
+
success: function( data ) {
|
270 |
+
if ( data.input_updates ) {
|
271 |
+
self._upateInputs( data.input_updates );
|
272 |
+
}
|
273 |
+
self.initData = self.$form.serialize();
|
274 |
+
self.saveBtns.text( dittyAdminVars.adminStrings.settings_updated );
|
275 |
+
setTimeout( function() {
|
276 |
+
self.saveBtns.text( dittyAdminVars.adminStrings.settings_save );
|
277 |
+
}, 2000 );
|
278 |
+
self.$elmt.removeClass( 'updating' );
|
279 |
+
self._disableSettingsUpdates();
|
280 |
+
|
281 |
+
//self.$notice_update.slideDown();
|
282 |
+
|
283 |
+
// Check the post types display
|
284 |
+
self._togglePostTypes();
|
285 |
+
}
|
286 |
+
} );
|
287 |
+
},
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Install a layout
|
291 |
+
*
|
292 |
+
* @since 3.0
|
293 |
+
* @return null
|
294 |
+
*/
|
295 |
+
_installLayout: function( e ) {
|
296 |
+
e.preventDefault();
|
297 |
+
var self = e.data.self,
|
298 |
+
$button = $( e.target ).is( 'button' ) ? $( e.target ) : $( e.target ).parents( 'button' ),
|
299 |
+
$icon = $button.find( 'i' ),
|
300 |
+
iconClass = $icon.attr( 'class' );
|
301 |
+
|
302 |
+
if ( $button.hasClass( 'updating' ) ) {
|
303 |
+
return false;
|
304 |
+
}
|
305 |
+
$button.addClass( 'updating' );
|
306 |
+
$icon.attr( 'class', dittyAdminVars.updateIcon );
|
307 |
+
|
308 |
+
var data = {
|
309 |
+
action : 'ditty_install_layout',
|
310 |
+
layout_template : $button.data( 'layout_template' ),
|
311 |
+
layout_version : $button.data( 'layout_version' ),
|
312 |
+
security : dittyAdminVars.security
|
313 |
+
};
|
314 |
+
$.post( dittyAdminVars.ajaxurl, data, function( response ) {
|
315 |
+
$icon.attr( 'class', iconClass );
|
316 |
+
self.$elmt.removeClass( 'updating' );
|
317 |
+
if ( response ) {
|
318 |
+
$button.replaceWith( response.button );
|
319 |
+
}
|
320 |
+
} );
|
321 |
+
},
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Install a display
|
325 |
+
*
|
326 |
+
* @since 3.0
|
327 |
+
* @return null
|
328 |
+
*/
|
329 |
+
_installDisplay: function( e ) {
|
330 |
+
e.preventDefault();
|
331 |
+
var self = e.data.self,
|
332 |
+
$button = $( e.target ).is( 'button' ) ? $( e.target ) : $( e.target ).parents( 'button' ),
|
333 |
+
$icon = $button.find( 'i' ),
|
334 |
+
iconClass = $icon.attr( 'class' );
|
335 |
+
|
336 |
+
if ( $button.hasClass( 'updating' ) ) {
|
337 |
+
return false;
|
338 |
+
}
|
339 |
+
$button.addClass( 'updating' );
|
340 |
+
$icon.attr( 'class', dittyAdminVars.updateIcon );
|
341 |
+
|
342 |
+
var data = {
|
343 |
+
action : 'ditty_install_display',
|
344 |
+
display_type : $button.data( 'display_type' ),
|
345 |
+
display_template : $button.data( 'display_template' ),
|
346 |
+
display_version : $button.data( 'display_version' ),
|
347 |
+
security : dittyAdminVars.security
|
348 |
+
};
|
349 |
+
$.post( dittyAdminVars.ajaxurl, data, function( response ) {
|
350 |
+
$icon.attr( 'class', iconClass );
|
351 |
+
self.$elmt.removeClass( 'updating' );
|
352 |
+
if ( response ) {
|
353 |
+
$button.replaceWith( response.button );
|
354 |
+
}
|
355 |
+
} );
|
356 |
+
},
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Return a specific setting
|
360 |
+
*
|
361 |
+
* @since 3.0
|
362 |
+
* @return null
|
363 |
+
*/
|
364 |
+
_options: function ( key ) {
|
365 |
+
return this.settings[key];
|
366 |
+
},
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Setup triggers
|
370 |
+
*
|
371 |
+
* @since 3.0
|
372 |
+
* @return null
|
373 |
+
*/
|
374 |
+
trigger: function ( fn, customParams ) {
|
375 |
+
var params = [this.settings];
|
376 |
+
if ( customParams ) {
|
377 |
+
params = customParams;
|
378 |
+
}
|
379 |
+
|
380 |
+
this.$elmt.trigger( 'ditty_settings_' + fn, params );
|
381 |
+
|
382 |
+
if ( typeof this.settings[fn] === 'function' ) {
|
383 |
+
this.settings[fn].apply( this.$elmt, params );
|
384 |
+
}
|
385 |
+
},
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Allow settings to be modified
|
389 |
+
*
|
390 |
+
* @since 3.0
|
391 |
+
* @return null
|
392 |
+
*/
|
393 |
+
options: function ( key, value ) {
|
394 |
+
|
395 |
+
if ( typeof key === 'object' ) {
|
396 |
+
this.settings = $.extend( {}, defaults, $.ditty_settings.defaults, key );
|
397 |
+
} else if ( typeof key === 'string' ) {
|
398 |
+
if ( value === undefined ) {
|
399 |
+
return this.settings[key];
|
400 |
+
}
|
401 |
+
this.settings[key] = value;
|
402 |
+
} else {
|
403 |
+
return this.settings;
|
404 |
+
}
|
405 |
+
|
406 |
+
this.trigger( 'options_update' );
|
407 |
+
},
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Destroy the editor
|
411 |
+
*
|
412 |
+
* @since 3.0
|
413 |
+
* @return null
|
414 |
+
*/
|
415 |
+
destroy: function () {
|
416 |
+
|
417 |
+
// Remove listeners
|
418 |
+
$( 'body' ).off( 'ditty_field_clone_update', { self: this }, this._enableSettingsUpdates );
|
419 |
+
this.saveBtns.off( 'click', { self: this }, this._submitForm );
|
420 |
+
this.tabs.off( 'click', { self: this }, this._tabClick );
|
421 |
+
this.$panels.off( 'ditty_slider_init', { self: this }, this._sliderInit );
|
422 |
+
this.$panels.off( 'ditty_slider_before_slide_update', { self: this }, this._beforeSlideUpdate );
|
423 |
+
this.$form.off( 'keyup change', 'input[type="text"], input[type="number"], textarea, select', { self: this }, this._checkUpdates );
|
424 |
+
this.$form.off( 'click', 'input[type="radio"], input[type="checkbox"]', { self: this }, this._checkUpdates );
|
425 |
+
this.$form.off( 'ditty_input_wysiwyg_update', '.ditty-input--wysiwyg', { self: this }, this._checkUpdates );
|
426 |
+
this.$form.off( 'click', '.ditty-default-layout-install', { self: this }, this._installLayout );
|
427 |
+
this.$form.off( 'click', '.ditty-default-display-install', { self: this }, this._installDisplay );
|
428 |
+
|
429 |
+
this.$panels.ditty_slider( 'destroy' );
|
430 |
+
this.elmt._ditty_settings = null;
|
431 |
+
}
|
432 |
+
};
|
433 |
+
|
434 |
+
/**
|
435 |
+
* Create the data list
|
436 |
+
*
|
437 |
+
* @since 3.0
|
438 |
+
* @return null
|
439 |
+
*/
|
440 |
+
$.fn.ditty_settings = function( options ) {
|
441 |
+
var args = arguments,
|
442 |
+
error = false,
|
443 |
+
returns;
|
444 |
+
|
445 |
+
if ( options === undefined || typeof options === 'object' ) {
|
446 |
+
return this.each( function () {
|
447 |
+
if ( ! this._ditty_settings ) {
|
448 |
+
this._ditty_settings = new Ditty_Settings( this, options );
|
449 |
+
}
|
450 |
+
});
|
451 |
+
} else if ( typeof options === 'string' ) {
|
452 |
+
this.each( function () {
|
453 |
+
var instance = this._ditty_settings;
|
454 |
+
|
455 |
+
if ( ! instance ) {
|
456 |
+
throw new Error( 'No Ditty_Settings applied to this element.' );
|
457 |
+
}
|
458 |
+
if ( typeof instance[options] === 'function' && options[0] !== '_' ) {
|
459 |
+
returns = instance[options].apply( instance, [].slice.call( args, 1 ) );
|
460 |
+
} else {
|
461 |
+
error = true;
|
462 |
+
}
|
463 |
+
} );
|
464 |
+
|
465 |
+
if ( error ) {
|
466 |
+
throw new Error( 'No method "' + options + '" in Ditty_Settings.' );
|
467 |
+
}
|
468 |
+
|
469 |
+
return returns !== undefined ? returns : this;
|
470 |
+
}
|
471 |
+
};
|
472 |
+
|
473 |
+
$.ditty_settings = {};
|
474 |
+
$.ditty_settings.defaults = defaults;
|
475 |
+
|
476 |
+
} )( jQuery );
|
477 |
+
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Ditty Extension class
|
481 |
+
*
|
482 |
+
* @since 3.0
|
483 |
+
* @return null
|
484 |
+
*/
|
485 |
+
|
486 |
+
(function ($) {
|
487 |
+
'use strict';
|
488 |
+
|
489 |
+
var defaults = {
|
490 |
+
};
|
491 |
+
|
492 |
+
var Ditty_Extension = function ( elmt, options ) {
|
493 |
+
|
494 |
+
this.elmt = elmt;
|
495 |
+
this.settings = $.extend( {}, defaults, $.ditty_extension.defaults, options );
|
496 |
+
this.$elmt = $( elmt );
|
497 |
+
this.$panels = $( elmt ).find( '.ditty-extension__panels' );
|
498 |
+
this.initPanel = this.$panels.data( 'init_panel' );
|
499 |
+
|
500 |
+
this._init();
|
501 |
+
};
|
502 |
+
|
503 |
+
Ditty_Extension.prototype = {
|
504 |
+
|
505 |
+
_init: function () {
|
506 |
+
|
507 |
+
// Add listeners
|
508 |
+
this.$elmt.on( 'click', '.ditty-extension__tab', { self: this }, this._tabClick );
|
509 |
+
this.$elmt.on( 'click', 'button[name="submit"]', { self: this }, this._updatePanel );
|
510 |
+
this.$elmt.on( 'click', '.ditty-extension__license__submit', { self: this, action: 'ditty_extension_license_activate' }, this._licenseUpdate );
|
511 |
+
this.$elmt.on( 'click', '.ditty-extension__license__refresh', { self: this, action: 'ditty_extension_license_refresh' }, this._licenseUpdate );
|
512 |
+
this.$elmt.on( 'click', '.ditty-extension__license__deactivate', { self: this, action: 'ditty_extension_license_deactivate' }, this._licenseUpdate );
|
513 |
+
this.$panels.on( 'ditty_slider_before_slide_update', { self: this }, this._beforePanelUpdate );
|
514 |
+
this._initSlider();
|
515 |
+
},
|
516 |
+
|
517 |
+
/**
|
518 |
+
* Initialize the slider
|
519 |
+
*
|
520 |
+
* @since 3.0
|
521 |
+
* @return null
|
522 |
+
*/
|
523 |
+
_initSlider: function () {
|
524 |
+
var args = {
|
525 |
+
transition : 'fade',
|
526 |
+
transitionSpeed : 0.75,
|
527 |
+
heightSpeed : 0.75,
|
528 |
+
touchSwipe : false,
|
529 |
+
slidesEl : '.ditty-extension__panel',
|
530 |
+
slideId : ( '' !== this.initPanel ) ? this.initPanel : false
|
531 |
+
};
|
532 |
+
this.$panels.ditty_slider( args );
|
533 |
+
},
|
534 |
+
|
535 |
+
/**
|
536 |
+
* Initialize the slider
|
537 |
+
*
|
538 |
+
* @since 3.0
|
539 |
+
* @return null
|
540 |
+
*/
|
541 |
+
_beforePanelUpdate: function ( e, index, slide ) {
|
542 |
+
var self = e.data.self;
|
543 |
+
self.$elmt.find( '.ditty-extension__tab' ).removeClass( 'active' );
|
544 |
+
self.$elmt.find( '.ditty-extension__tab[data-slide_id="' + slide.id + '"]' ).addClass( 'active' );
|
545 |
+
},
|
546 |
+
|
547 |
+
/**
|
548 |
+
* Tab click
|
549 |
+
*
|
550 |
+
* @since 3.0
|
551 |
+
* @return null
|
552 |
+
*/
|
553 |
+
_tabClick: function ( e ) {
|
554 |
+
e.preventDefault();
|
555 |
+
var self = e.data.self;
|
556 |
+
var $tab = $( this ),
|
557 |
+
slideId = $tab.data( 'slide_id' ),
|
558 |
+
transition = 'slideLeft',
|
559 |
+
$currentTab = self.$elmt.find( '.ditty-extension__tab.active' );
|
560 |
+
|
561 |
+
if ( $currentTab === $tab ) {
|
562 |
+
return false;
|
563 |
+
}
|
564 |
+
|
565 |
+
if ( $tab.index() < $currentTab.index() ) {
|
566 |
+
transition = 'slideRight';
|
567 |
+
}
|
568 |
+
|
569 |
+
//self.$elmt.find( '.ditty-extension__tab' ).removeClass( 'active' );
|
570 |
+
//$tab.addClass( 'active' );
|
571 |
+
|
572 |
+
self.$panels.ditty_slider( 'options', 'transition', transition );
|
573 |
+
self.$panels.ditty_slider( 'showSlideById', slideId );
|
574 |
+
},
|
575 |
+
|
576 |
+
/**
|
577 |
+
* Panel update listener
|
578 |
+
*
|
579 |
+
* @since 3.0
|
580 |
+
* @return null
|
581 |
+
*/
|
582 |
+
_updatePanel: function ( e ) {
|
583 |
+
e.preventDefault();
|
584 |
+
var self = e.data.self;
|
585 |
+
|
586 |
+
var $button = $( this ),
|
587 |
+
$panel = $button.parents( '.ditty-extension__panel' ),
|
588 |
+
$form = $button.parents( '.ditty-extension__form' ),
|
589 |
+
$icon = $button.find( 'i' ),
|
590 |
+
iconClass = $icon.attr( 'class' ),
|
591 |
+
extension = self.$elmt.data( 'extension' ),
|
592 |
+
panel = $panel.data( 'slide_id' );
|
593 |
+
|
594 |
+
if ( self.$elmt.hasClass( 'updating' ) ) {
|
595 |
+
return false;
|
596 |
+
}
|
597 |
+
|
598 |
+
self.$elmt.addClass( 'updating' );
|
599 |
+
$icon.attr( 'class', dittyAdminVars.updateIcon );
|
600 |
+
|
601 |
+
$form.ajaxSubmit( {
|
602 |
+
url : dittyAdminVars.ajaxurl,
|
603 |
+
type : 'post',
|
604 |
+
dataType : 'json',
|
605 |
+
data : {
|
606 |
+
action : 'ditty_extension_panel_update',
|
607 |
+
extension : extension,
|
608 |
+
panel : panel,
|
609 |
+
security : dittyAdminVars.security
|
610 |
+
},
|
611 |
+
success: function( response ) {
|
612 |
+
$icon.attr( 'class', iconClass );
|
613 |
+
self.$elmt.removeClass( 'updating' );
|
614 |
+
$( '#ditty-extensions' ).trigger( 'ditty_extension_panel_updated', [ response, self.$elmt, $panel ] );
|
615 |
+
}
|
616 |
+
} );
|
617 |
+
},
|
618 |
+
|
619 |
+
/**
|
620 |
+
* Update a license
|
621 |
+
*
|
622 |
+
* @since 3.0
|
623 |
+
* @return null
|
624 |
+
*/
|
625 |
+
_licenseUpdate: function ( e ) {
|
626 |
+
e.preventDefault();
|
627 |
+
var self = e.data.self,
|
628 |
+
action = e.data.action;
|
629 |
+
|
630 |
+
var $button = $( this ),
|
631 |
+
$message = self.$elmt.find( '.ditty-extension__license__message' ),
|
632 |
+
$input = $button.siblings( '.ditty-extension__license__input' ),
|
633 |
+
license = $input.val(),
|
634 |
+
extension = $button.data( 'extension' ),
|
635 |
+
extensionId = $button.data( 'extension_id' ),
|
636 |
+
extensionName = $button.data( 'extension_name' ),
|
637 |
+
$icon = $button.children( 'i' );
|
638 |
+
|
639 |
+
if ( self.$elmt.hasClass( 'updating' ) ) {
|
640 |
+
return false;
|
641 |
+
}
|
642 |
+
|
643 |
+
self.$elmt.addClass( 'updating' );
|
644 |
+
$icon.attr( 'class', dittyAdminVars.updateIcon );
|
645 |
+
|
646 |
+
// Load the new display data
|
647 |
+
var data = {
|
648 |
+
action : action,
|
649 |
+
license : license,
|
650 |
+
extension : extension,
|
651 |
+
extension_id : extensionId,
|
652 |
+
extension_name : extensionName,
|
653 |
+
security : dittyAdminVars.security
|
654 |
+
};
|
655 |
+
$.post( dittyAdminVars.ajaxurl, data, function( response ) {
|
656 |
+
if ( response ) {
|
657 |
+
self.$elmt.attr( 'data-license_status', response.status );
|
658 |
+
$message.text( response.message );
|
659 |
+
}
|
660 |
+
if ( response.license_key ) {
|
661 |
+
if ( 'DELETE' === response.license_key ) {
|
662 |
+
$input.val( '' );
|
663 |
+
} else {
|
664 |
+
$input.val( response.license_key );
|
665 |
+
}
|
666 |
+
}
|
667 |
+
$icon.attr( 'class', $icon.data( 'class' ) );
|
668 |
+
self.$elmt.removeClass( 'updating' );
|
669 |
+
}, 'json' );
|
670 |
+
},
|
671 |
+
|
672 |
+
/**
|
673 |
+
* Return data for the object
|
674 |
+
*
|
675 |
+
* @since 3.0
|
676 |
+
* @return null
|
677 |
+
*/
|
678 |
+
_getOption: function( key ) {
|
679 |
+
switch( key ) {
|
680 |
+
default:
|
681 |
+
return this.settings[key];
|
682 |
+
}
|
683 |
+
},
|
684 |
+
|
685 |
+
/**
|
686 |
+
* Set data for the object
|
687 |
+
*
|
688 |
+
* @since 3.0
|
689 |
+
* @return null
|
690 |
+
*/
|
691 |
+
_setOption: function( key, value ) {
|
692 |
+
if ( undefined === value ) {
|
693 |
+
return false;
|
694 |
+
}
|
695 |
+
|
696 |
+
this.settings[key] = value;
|
697 |
+
},
|
698 |
+
|
699 |
+
/**
|
700 |
+
* Get or set ditty options
|
701 |
+
*
|
702 |
+
* @since 3.0
|
703 |
+
* @return null
|
704 |
+
*/
|
705 |
+
options: function ( key, value ) {
|
706 |
+
var self = this;
|
707 |
+
if ( typeof key === 'object' ) {
|
708 |
+
$.each( key, function( k, v ) {
|
709 |
+
self._setOption( k, v );
|
710 |
+
});
|
711 |
+
} else if ( typeof key === 'string' ) {
|
712 |
+
if ( value === undefined ) {
|
713 |
+
return self._getOption( key );
|
714 |
+
}
|
715 |
+
self._setOption( key, value );
|
716 |
+
} else {
|
717 |
+
return self.settings;
|
718 |
+
}
|
719 |
+
},
|
720 |
+
|
721 |
+
/**
|
722 |
+
* Destroy this object
|
723 |
+
*
|
724 |
+
* @since 3.0
|
725 |
+
* @return null
|
726 |
+
*/
|
727 |
+
destroy: function () {
|
728 |
+
// Remove listeners
|
729 |
+
this.$elmt.off( 'click', '.ditty-extension__tab', { self: this }, this._tabClick );
|
730 |
+
this.$elmt.off( 'click', 'button[name="submit"]', { self: this }, this._updatePanel );
|
731 |
+
this.$elmt.off( 'click', '.ditty-extension__license__submit, .ditty-extension__license__refresh', { self: this, action: 'ditty_extension_license_activate' }, this._licenseUpdate );
|
732 |
+
this.$elmt.off( 'click', '.ditty-extension__license__deactivate', { self: this, action: 'ditty_extension_license_deactivate' }, this._licenseUpdate );
|
733 |
+
this.$panels.off( 'ditty_slider_after_slide_update', { self: this }, this._afterPanelUpdate );
|
734 |
+
|
735 |
+
this.$panels.ditty_slider( 'destroy' );
|
736 |
+
this.elmt._ditty_extension = null;
|
737 |
+
}
|
738 |
+
};
|
739 |
+
|
740 |
+
$.fn.ditty_extension = function( options ) {
|
741 |
+
var args = arguments,
|
742 |
+
error = false,
|
743 |
+
returns;
|
744 |
+
|
745 |
+
if ( options === undefined || typeof options === 'object' ) {
|
746 |
+
return this.each( function () {
|
747 |
+
if ( ! this._ditty_extension ) {
|
748 |
+
this._ditty_extension = new Ditty_Extension( this, options );
|
749 |
+
}
|
750 |
+
});
|
751 |
+
} else if ( typeof options === 'string' ) {
|
752 |
+
this.each( function () {
|
753 |
+
var instance = this._ditty_extension;
|
754 |
+
|
755 |
+
if ( ! instance ) {
|
756 |
+
throw new Error( 'No Ditty_Extension applied to this element.' );
|
757 |
+
}
|
758 |
+
if ( typeof instance[options] === 'function' && options[0] !== '_' ) {
|
759 |
+
returns = instance[options].apply( instance, [].slice.call( args, 1 ) );
|
760 |
+
} else {
|
761 |
+
error = true;
|
762 |
+
}
|
763 |
+
} );
|
764 |
+
|
765 |
+
if ( error ) {
|
766 |
+
throw new Error( 'No method "' + options + '" in Ditty_Extension.' );
|
767 |
+
}
|
768 |
+
|
769 |
+
return returns !== undefined ? returns : this;
|
770 |
+
}
|
771 |
+
};
|
772 |
+
|
773 |
+
$.ditty_extension = {};
|
774 |
+
$.ditty_extension.defaults = defaults;
|
775 |
+
|
776 |
+
} )( jQuery );
|
777 |
+
|
778 |
+
|
779 |
+
|
780 |
+
jQuery( function( $ ) {
|
781 |
+
// Setup strict mode
|
782 |
+
(function() {
|
783 |
+
|
784 |
+
"use strict";
|
785 |
+
|
786 |
+
// Setup protip
|
787 |
+
$.protip( {
|
788 |
+
defaults: {
|
789 |
+
position: 'top',
|
790 |
+
size: 'small',
|
791 |
+
scheme: 'black',
|
792 |
+
classes: 'ditty-protip'
|
793 |
+
}
|
794 |
+
} );
|
795 |
+
|
796 |
+
/**
|
797 |
+
* Listen for an accordion toggle click
|
798 |
+
*
|
799 |
+
* @since 3.0
|
800 |
+
* @return null
|
801 |
+
*/
|
802 |
+
// $( '#ditty-extensions' ).on( 'click', '.ditty-accordion__toggle', function( e ) {
|
803 |
+
// e.preventDefault();
|
804 |
+
// var $accordion = $( this ).parent(),
|
805 |
+
// $content = $( this ).next();
|
806 |
+
//
|
807 |
+
// if ( $accordion.hasClass( 'active' ) ) {
|
808 |
+
// $accordion.removeClass( 'active' );
|
809 |
+
// $content.stop().slideUp( { duration: 750, easing: "easeInOutQuint" } );
|
810 |
+
// } else {
|
811 |
+
// $accordion.addClass( 'active' );
|
812 |
+
// $content.stop().slideDown( { duration: 750, easing: "easeInOutQuint" }, function() {
|
813 |
+
// $content.css( 'height', 'auto' );
|
814 |
+
// } );
|
815 |
+
// }
|
816 |
+
// } );
|
817 |
+
//
|
818 |
+
/**
|
819 |
+
* Initialize the extensions
|
820 |
+
*
|
821 |
+
* @since 3.0
|
822 |
+
* @return null
|
823 |
+
*/
|
824 |
+
function ditty_extensions_init() {
|
825 |
+
$( '#ditty-extensions' ).find( '.ditty-extension' ).each( function( index ) {
|
826 |
+
|
827 |
+
var $extension = $( this ),
|
828 |
+
$panels = $extension.find( '.ditty-extension__panels' );
|
829 |
+
|
830 |
+
if ( $panels.length ) {
|
831 |
+
$extension.ditty_extension();
|
832 |
+
}
|
833 |
+
|
834 |
+
$( '#ditty-extensions' ).trigger( 'ditty_init_fields' );
|
835 |
+
|
836 |
+
setTimeout( function() {
|
837 |
+
$extension.addClass( 'ditty-extension--init' );
|
838 |
+
}, index * 250 );
|
839 |
+
|
840 |
+
} );
|
841 |
+
}
|
842 |
+
ditty_extensions_init();
|
843 |
+
|
844 |
+
}() );
|
845 |
+
|
846 |
+
} );
|
847 |
+
|
848 |
+
|
849 |
+
jQuery( function( $ ) {
|
850 |
+
// Setup strict mode
|
851 |
+
(function() {
|
852 |
+
|
853 |
+
"use strict";
|
854 |
+
|
855 |
+
var isDisplayPost = ( $( 'input[name="post_type"]' ).length && 'ditty_display' == $( 'input[name="post_type"]' ).val() ),
|
856 |
+
ajaxSubmitComplete = false;
|
857 |
+
|
858 |
+
$( 'form#post' ).on( 'submit', function( e ) {
|
859 |
+
if ( isDisplayPost && ! ajaxSubmitComplete ) {
|
860 |
+
e.preventDefault();
|
861 |
+
|
862 |
+
var $button = $( '#publishing-action' ).children( 'input[type="submit"]' ),
|
863 |
+
$spinner = $( '#publishing-action' ).children( '.spinner' );
|
864 |
+
|
865 |
+
$button.attr( 'disabled', 'disabled' );
|
866 |
+
$spinner.css( 'visibility', 'visible' );
|
867 |
+
|
868 |
+
var data = {
|
869 |
+
action : 'ditty_admin_display_update',
|
870 |
+
display_id : $( 'input[name="post_ID"]' ).val(),
|
871 |
+
security : dittyAdminVars.security
|
872 |
+
};
|
873 |
+
$( '#ditty-display-settings' ).ajaxSubmit( {
|
874 |
+
url : dittyAdminVars.ajaxurl,
|
875 |
+
type : 'post',
|
876 |
+
dataType : 'json',
|
877 |
+
data : data,
|
878 |
+
success: function( response ) {
|
879 |
+
ajaxSubmitComplete = true;
|
880 |
+
$( 'form#post' ).submit();
|
881 |
+
}
|
882 |
+
} );
|
883 |
+
}
|
884 |
+
} );
|
885 |
+
|
886 |
+
}() );
|
887 |
+
|
888 |
+
} );
|
includes/js/ditty-editor.js
CHANGED
@@ -15,8 +15,9 @@
|
|
15 |
// @codekit-append 'editor/class-ditty-layout-css-editor-panel.js';
|
16 |
// @codekit-append 'editor/ditty-list-display-editor.js';
|
17 |
// @codekit-append 'editor/ditty-ticker-display-editor.js';
|
|
|
18 |
|
19 |
-
jQuery(
|
20 |
|
21 |
// Setup strict mode
|
22 |
(function() {
|
@@ -168,19 +169,15 @@ jQuery( document ).ready( function( $ ) {
|
|
168 |
/**
|
169 |
* Initialize an editor
|
170 |
*
|
171 |
-
* @since 3.0
|
172 |
* @return null
|
173 |
*/
|
174 |
function dittyEditorInit( ditty ) {
|
175 |
if ( ! ditty ) {
|
176 |
return false;
|
177 |
}
|
178 |
-
var status = ditty.options( 'status' ),
|
179 |
-
panel = 'auto-draft' === status ? 'settings' : false;
|
180 |
-
|
181 |
jQuery( '#ditty-editor__settings' ).ditty_editor( {
|
182 |
-
ditty: ditty
|
183 |
-
panel: panel
|
184 |
} );
|
185 |
}
|
186 |
dittyEditorInit();
|
15 |
// @codekit-append 'editor/class-ditty-layout-css-editor-panel.js';
|
16 |
// @codekit-append 'editor/ditty-list-display-editor.js';
|
17 |
// @codekit-append 'editor/ditty-ticker-display-editor.js';
|
18 |
+
// @codekit-append 'editor/ditty-item-edit-editor.js';
|
19 |
|
20 |
+
jQuery( function( $ ) {
|
21 |
|
22 |
// Setup strict mode
|
23 |
(function() {
|
169 |
/**
|
170 |
* Initialize an editor
|
171 |
*
|
172 |
+
* @since 3.0.12
|
173 |
* @return null
|
174 |
*/
|
175 |
function dittyEditorInit( ditty ) {
|
176 |
if ( ! ditty ) {
|
177 |
return false;
|
178 |
}
|
|
|
|
|
|
|
179 |
jQuery( '#ditty-editor__settings' ).ditty_editor( {
|
180 |
+
ditty: ditty
|
|
|
181 |
} );
|
182 |
}
|
183 |
dittyEditorInit();
|
includes/js/ditty-editor.min.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
function dittyEditorInit(t){if(!t)return!1;var i="auto-draft"===t.options("status")&&"settings";jQuery("#ditty-editor__settings").ditty_editor({ditty:t,panel:i})}function dittyGetItemsById(t,i){var e=[];return jQuery.each(t,(function(t,s){String(s.id)===String(i)&&e.push(s)})),e}function dittyItemsReorder(t,i){var e=[];return jQuery.each(i,(function(i,s){e=jQuery.merge(e,dittyGetItemsById(t,s))})),e}function dittyDraftUpdate(t,i,e,s){var a=t.settings.editor.getDraftValues(i);return a||(a={}),e?a[e]=s:a=s,t.settings.editor.updateDraftValues(i,a)}function dittyDraftGet(t,i,e){var s=t.settings.editor.getDraftValues(i);return!!s&&(e&&s[e]?s[e]:s)}function dittyDraftDelete(t,i,e){var s=i.settings.editor.getDraftValues(t),a={};return jQuery.each(s,(function(t,i){String(e)!==String(t)&&(a[t]=i)})),"new-"!==String(e).substring(0,4)&&(a[e]="DELETE"),i.settings.editor.updateDraftValues(t,a)}function dittyDraftItemDelete(t,i){return dittyDraftDelete("items",t,i)}function dittyDraftLayoutDelete(t,i){return dittyDraftDelete("layouts",t,i)}function dittyDraftDisplayDelete(t,i){return dittyDraftDelete("displays",t,i)}function dittyDraftItemUpdateData(t,i,e,s){var a=t.settings.editor.getDraftValues("items");return a||(a={}),a[i]||(a[i]={}),a[i].data||(a[i].data={}),e?a[i].data[e]=s:a[i].data=s,t.settings.editor.updateDraftValues("items",a)}function dittyDraftItemGetData(t,i,e){var s=t.settings.editor.getDraftValues("items");return!!s[i]&&(!!s[i].data&&(e?s[i].data[e]?s[i].data[e]:void 0:s[i].data))}function dittyDraftItemUpdateMeta(t,i,e,s){var a=t.settings.editor.getDraftValues("items");return a||(a={}),a[i]||(a[i]={}),a[i].meta||(a[i].meta={}),e?a[i].meta[e]=s:a[i].meta=s,t.settings.editor.updateDraftValues("items",a)}function dittyDraftItemGetMeta(t,i,e){var s=t.settings.editor.getDraftValues("items");return!!s[i]&&(!!s[i].meta&&(e?s[i].meta[e]?s[i].meta[e]:void 0:s[i].meta))}function dittyDraftLayoutUpdate(t,i,e,s){var a=t.settings.editor.getDraftValues("layouts");return a||(a={}),a[i]||(a[i]={}),e?a[i][e]=s:a[i]=s,t.settings.editor.updateDraftValues("layouts",a)}function dittyDraftLayoutGet(t,i,e){var s=t.settings.editor.getDraftValues("layouts");return!!s[i]&&(e?s[i][e]?s[i][e]:void 0:s[i])}function dittyDraftDisplayUpdate(t,i,e,s){var a=t.settings.editor.getDraftValues("displays");return a||(a={}),a[i]||(a[i]={}),e?a[i][e]=s:a[i]=s,t.settings.editor.updateDraftValues("displays",a)}function dittyDraftDisplayGet(t,i,e){var s=t.settings.editor.getDraftValues("layouts");return!!s[i]&&(e?s[i][e]?s[i][e]:void 0:s[i])}jQuery(document).ready((function($){!function(){"use strict";$("body").on("ditty_editor_before_panel_update",(function(t,i,e,s,a,d){switch(d.delayedSubmitDisable(),$.protip({defaults:{position:"top",size:"small",scheme:"black",classes:"ditty-protip"}}),i){case"settings":e.hasClass("init")||e.ditty_settings_panel({editor:d});break;case"items":e.hasClass("init")?e.ditty_items_panel("panelVisible"):e.ditty_items_panel({editor:d});break;case"displays":e.find(".ditty-data-list__item").removeClass("editing"),e.hasClass("init")?e.ditty_displays_panel("panelVisible"):e.ditty_displays_panel({editor:d});break;case"item_types":e.find(".ditty-data-list__item").removeClass("editing"),e.hasClass("init")?e.ditty_item_types_panel("panelVisible"):e.ditty_item_types_panel({editor:d});break;case"item_editor":e.ditty_item_editor_panel({editor:d});break;case"display_editor":e.ditty_display_editor_panel({editor:d});break;case"layouts":"layoutHtmlEditor"!==s&&"layoutCssEditor"!==s&&e.ditty_layouts_panel({editor:d});break;case"layout_variations":e.hasClass("init")?e.ditty_layout_variations_panel("panelVisible"):e.ditty_layout_variations_panel({editor:d});break;case"layout_html_editor":e.ditty_layout_html_editor_panel({editor:d,prevPanel:s});break;case"layout_css_editor":e.ditty_layout_css_editor_panel({editor:d,prevPanel:s})}})),$("body").on("ditty_editor_panel_removed",(function(t,i,e){switch(i){case"item_editor":e.ditty_item_editor_panel&&e.ditty_item_editor_panel("destroy");break;case"display_editor":e.ditty_display_editor_panel&&e.ditty_display_editor_panel("destroy");break;case"layouts":case"layouts":e.ditty_layouts_panel&&e.ditty_layouts_panel("destroy");break;case"layout_variations":e.ditty_layout_variations_panel&&e.ditty_layout_variations_panel("destroy");break;case"layout_html_editor":e.ditty_layout_html_editor_panel&&e.ditty_layout_html_editor_panel("destroy");break;case"layout_css_editor":e.ditty_layout_css_editor_panel&&e.ditty_layout_css_editor_panel("destroy")}}))}()})),dittyEditorInit(),function($){"use strict";var t={listType:"toggle",showAll:!0,activeFilter:"*",filter:".ditty-data-list__filter",filterSelector:"filter",item:".ditty-data-list__item",itemSelector:"filter"},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_ui_data_list.defaults,e),this.$elmt=$(i),this.filters=[],this._init()};i.prototype={_init:function(){var t=this;this.$elmt.on("click",this.settings.filter,{self:this},this._filterClick),this.$elmt.find(this.settings.filter+".active").each((function(){t._filterList($(this).data(t.settings.filterSelector))})),"*"!==this.settings.activeFilter&&this._filterList(this.settings.activeFilter),setTimeout((function(){t.trigger("init")}),1)},_filterList:function(t){var i=this,e=this.filters;if("toggle"===this.settings.listType)this.filters.includes(t)?this.settings.showAll&&(this.filters=[],this.$elmt.find(this.settings.filter).removeClass("active"),this.$elmt.find(this.settings.item).show()):(this.filters=[t],this.$elmt.find(this.settings.filter).removeClass("active"),this.$elmt.find(this.settings.filter+"[data-"+this.settings.filterSelector+'="'+t+'"]').addClass("active"),this.$elmt.find(this.settings.item).hide(),this.$elmt.find(this.settings.item+"[data-"+this.settings.itemSelector+'="'+t+'"]').show());else if("filter"===this.settings.listType){if(this.$elmt.find(this.settings.item).hide(),this.filters.includes(t)){this.$elmt.find(this.settings.filter+"[data-"+this.settings.filterSelector+'="'+t+'"]').removeClass("active");for(var s=0;s<this.filters.length;s++)i.filters[s]===t&&i.filters.splice(s,1)}else this.$elmt.find(this.settings.filter+"[data-"+this.settings.filterSelector+'="'+t+'"]').addClass("active"),this.filters.push(t);$.each(this.filters,(function(t,e){i.$elmt.find(this.settings.item+"[data-"+this.settings.itemSelector+'="'+e+'"]').show()})),0===this.filters.length&&i.$elmt.find(this.settings.item).show()}e!==this.filters&&i.trigger("update")},_filterClick:function(t){t.preventDefault();var i=t.data.self,e=$(t.target);e.is("a")||(e=e.parents("a")),i._filterList(e.data(i.settings.filterSelector))},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings,this.filters];i&&(e=i),this.$elmt.trigger("ditty_ui_data_list_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_ui_data_list.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.off("click",this.settings.filter,{self:this},this._filterClick),this.trigger("destroy"),this.elmt._ditty_ui_data_list=null}},$.fn.ditty_ui_data_list=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_ui_data_list||(this._ditty_ui_data_list=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_ui_data_list;if(!i)throw new Error("No Ditty_UI_Data_List applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_UI_Data_List.');return void 0!==e?e:this}},$.ditty_ui_data_list={},$.ditty_ui_data_list.defaults=t}(jQuery),function($){"use strict";var t={screen:"admin",ditty:null,panel:""},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_editor.defaults,e),this.$elmt=$(i),this.ditty=this.settings.ditty,this.dittyId=this.settings.ditty.options("id"),this.dittyType=this.settings.ditty.options("type"),this.displayId=0,this.panelsLoaded=0,this.unsavedUpdates={},this.draftValues={},this.$overlay=null,this.$contents=null,this.$header=null,this.$update=null,this.$updateCount=null,this.$updateLabel=null,this.$tabs=null,this.$panels=null,this.currentTab=0,this.currentPanel=this.settings.panel,this.delayedSubmit=!1,this.tabs=[],this.panels=[],this.activeItems=[],this._init()};i.prototype={_init:function(){var t,i,e,s,a,d,r,o=this;t=$('<div class="ditty-editor__contents"></div>'),this.$contents=t,i=$('<div class="ditty-editor__header"></div>'),this.$header=i,e=$('<span class="ditty-editor__update__count"></span>'),this.$updateCount=e,s=$('<span class="ditty-editor__update__label">Save Ditty</span>'),this.$updateLabel=s,a=$('<button type="submit" class="ditty-editor__update ditty-button ditty-button--primary"></button>'),this.$update=a,d=$('<div class="ditty-editor__tabs"></div>'),this.$tabs=d,r=$('<div class="ditty-editor__panels"></div>'),this.$panels=r,a.prepend(e,s),i.append(a),t.append(i,d,r),this.$elmt.append(t),this.$overlay=$('<div class="ditty-updating-overlay ditty-admin-item__overlay"><div class="ditty-updating-overlay__inner"><i class="fas fa-sync-alt fa-spin"></i></div></div>'),this.$elmt.append(this.$overlay),$(document).on("postbox-moved",{self:this},this._postboxMoved),$(document).on("postboxes-columnchange",{self:this},this._postboxMoved),$(window).on("beforeunload",{self:this},this._beforeunload),this.ditty.$elmt.on("ditty_active_items_update",{self:this},this._dittyItemsUpdated),this.ditty.$elmt.on("ditty_disabled_items_update",{self:this},this._disabledItemsUpdate),this.$tabs.on("click",".ditty-editor__tab",{self:this},this._showPanel),this.$update.on("click",{self:this},this._saveClick),this.$panels.on("ditty_slider_init",{self:this},this._editorLoaded),this.$panels.on("ditty_slider_before_slide_update",{self:this},this._beforeSlideUpdate),this.$panels.on("ditty_slider_after_slide_update",{self:this},this._afterSlideUpdate),this.$panels.on("ditty_slider_slide_removed",{self:this},this._slideRemoved),this._loadContents(),this.trigger("stop_live_updates"),setTimeout((function(){o.trigger("init")}),1)},_loadContents:function(){var t=this,i={action:"ditty_editor_load_contents",ditty_id:this.dittyId,security:dittyVars.security};$.post(dittyVars.ajaxurl,i,(function(i){t._initTabs(i.tabs),t._initPanels(i.panels),t._initSlider()}),"json")},_editorLoaded:function(t){var i=t.data.self;$("body").trigger("ditty_editor_loaded",[i])},_setUpdateCount:function(){},_initSlider:function(){var t=this.tabs[0].id;this.currentPanel&&""!==this.currentPanel&&(t=this.currentPanel),this.$panels.ditty_slider({transition:"fade",transitionSpeed:.75,heightSpeed:.75,touchSwipe:!1,slides:this.panels,slideId:t})},_beforeSlideUpdate:function(t,i,e,s,a){var d=t.data.self;d.updateStart(),d._updateTab(e.id),$("body").trigger("ditty_editor_before_panel_update",[e.id,e.$elmt,a.id,a.$elmt,d])},_afterSlideUpdate:function(t,i,e,s,a){var d=t.data.self;d.updateStop(),$("body").trigger("ditty_editor_after_panel_update",[e.id,e.$elmt,a.id,a.$elmt,d])},_slideRemoved:function(t,i){var e=t.data.self;$("body").trigger("ditty_editor_panel_removed",[i.id,i.$elmt,e])},_showPanel:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("a")?$(t.target):$(t.target).parent("a"),s=e.data("panel"),a=parseInt(e.data("index"));if(s===i.currentTab)return!1;var d=a>i.currentTab?"slideLeft":"slideRight";i.$panels.ditty_slider("options","transition",d),i.$panels.ditty_slider("showSlideById",s),i.currentTab=a,i.$elmt.trigger("ditty_editor_add_drafts")},_updateTab:function(t){var i=$('.ditty-editor__tab[data-panel="'+t+'"]');void 0!==i[0]&&($(".ditty-editor__tab").removeClass("active"),i.addClass("active"),this.currentTab=parseInt(i.data("index")))},_initTabs:function(t){var i=this,e=0;$.each(t,(function(t,s){var a=$('<a href="#" class="ditty-editor__tab ditty-editor__tab--'+t+'" data-panel="'+t+'" data-index="'+e+'"><i class="'+s.icon+'"></i><span>'+s.label+"</span></a>");i.$tabs.append(a),i.tabs.push({id:t,tab:a}),e++}))},_initPanels:function(t){var i=this;$.each(t,(function(t,e){var s='<div class="ditty-editor__panel ditty-editor__panel--'+t+'">'+e+"</div>";i.panels.push({id:t,html:s,cache:!0})}))},_initFields:function(t){t.find(".ditty-data-list").ditty_ui_data_list(),t.trigger("ditty_init_fields"),$.protip({defaults:{position:"top",size:"small",scheme:"black",classes:"ditty-protip"}})},saveDitty:function(t){var i=this,e=i.dittyId;i.$updateLabel.text("Updating..."),i.updateStart();var s={action:"ditty_editor_save",ditty_id:e,draft_values:i.draftValues,return_items:1,security:dittyVars.security};s=$.extend({},s,t),$.post(dittyVars.ajaxurl,s,(function(t){$("body").trigger("ditty_editor_save_ditty_response",[t]),t.display_items&&i.ditty.options("items",t.display_items),i.draftValues={},i.unsavedUpdates={},i._setUpdateCount(),i.$elmt.removeClass("ditty-editor--updates-exist"),i.$updateLabel.text("Ditty Saved!"),setTimeout((function(){i.$updateLabel.text("Save Ditty")}),2e3),i.updateStop(),t.new_ditty_url&&window.history.pushState(null,"","/wp-admin/post.php?post="+e+"&action=edit")}))},_saveClick:function(t){t.preventDefault();var i=t.data.self;i.$elmt.trigger("ditty_editor_save_drafts"),i.delayedSubmit||i.saveDitty()},_dittyItemsUpdated:function(t,i,e){var s=t.data.self;s.activeItems=e,s.trigger("active_items_update")},_disabledItemsUpdate:function(t,i){var e=t.data.self;$.each(i,(function(t,i){"disabled"===i?e.$elmt.find("#ditty-editor-item--"+t).addClass("ditty-editor-item--disabled"):e.$elmt.find("#ditty-editor-item--"+t).removeClass("ditty-editor-item--disabled")}))},_postboxMoved:function(t,i){if(!window.tinymce)return!1;$(i).find(".wp-editor-area").each((function(){var t=$(this).attr("id");tinymce.execCommand("mceRemoveEditor",!0,t),tinymce.execCommand("mceAddEditor",!0,t)}))},_beforeunload:function(t){var i=t.data.self;return Object.keys(i.unsavedUpdates).length>0||void 0},_windowResize:function(t){t.preventDefault()},_options:function(t){return this.settings[t]},panelExists:function(t){var i=this.$panels.ditty_slider("options","slides"),e=!1;return $.each(i,(function(i,s){String(s.id)!==String(t)||(e=!0)})),e},showPanel:function(t,i){i&&this.$panels.ditty_slider("addSlideById",t,i),this.$panels.ditty_slider("showSlideById",t,!0)},updateExists:function(t,i){if(void 0===this.unsavedUpdates[t]&&(this.unsavedUpdates[t]=[]),-1!==$.inArray(i,this.unsavedUpdates[t]))return!0},addUpdate:function(t,i){var e=!1;return void 0===this.unsavedUpdates[t]&&(this.unsavedUpdates[t]=[]),-1===$.inArray(i,this.unsavedUpdates[t])&&(e=!0,this.unsavedUpdates[t].push(i)),this._setUpdateCount(),this.$elmt.addClass("ditty-editor--updates-exist"),e},removeUpdate:function(t,i){if(void 0===this.unsavedUpdates[t])return!1;if(-1===$.inArray(i,this.unsavedUpdates[t]))return!1;var e=!1,s=[];return $.each(this.unsavedUpdates[t],(function(t,a){String(i)===String(a)?e=!0:s.push(a)})),this.unsavedUpdates[t]=s,this._setUpdateCount(),""===this.$updateCount.text()&&this.$elmt.removeClass("ditty-editor--updates-exist"),e},updateStart:function(){this.$overlay.fadeIn()},updateStop:function(){this.$overlay.fadeOut()},initFields:function(t){this._initFields(t)},updateDraftValues:function(t,i){return this.$elmt.addClass("ditty-editor--updates-exist"),t?(this.draftValues[t]=i,"development"===dittyVars.mode&&window.console&&console.log("draftValues:",this.draftValues),this.draftValues[t]):(this.draftValues=i,"development"===dittyVars.mode&&window.console&&console.log("draftValues:",this.draftValues),this.draftValues)},getDraftValues:function(t){return t?!!this.draftValues[t]&&this.draftValues[t]:this.draftValues},delayedSubmitEnable:function(){this.delayedSubmit=!0},delayedSubmitDisable:function(){this.delayedSubmit=!1},trigger:function(t,i){var e=[];switch(t){case"active_items_update":e=[this.ditty,this.activeItems];break;case"stop_live_updates":e=[this.dittyId];break;default:e=[this.settings]}i&&(e=i),this.$elmt.trigger("ditty_editor_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e),$("body").trigger("ditty_"+t,e)},_getPanelOption:function(t){return"elmnt"===t?this.$panels:this.settings[t]},_setPanelOption:function(t,i){if(void 0===i)return!1;this.$panels.ditty_slider("options",t,i),this.trigger("update")},panelOptions:function(t,i){var e=this;if("object"==typeof t)$.each(t,(function(t,i){e._setPanelOption(t,i)}));else{if("string"!=typeof t)return e.$panels.ditty_slider("options");if(void 0===i)return e._getPanelOption(t);e._setPanelOption(t,i)}},_getOption:function(t){return"elmnt"===t?this:this.settings[t]},_setOption:function(t,i){if(void 0===i)return!1;this.settings[t]=i,this.trigger("update")},options:function(t,i){var e=this;if("object"==typeof t)$.each(t,(function(t,i){e._setOption(t,i)}));else{if("string"!=typeof t)return e.settings;if(void 0===i)return e._getOption(t);e._setOption(t,i)}},destroy:function(){this.$panels.ditty_slider&&this.$panels.ditty_slider("destroy"),$(document).off("postbox-moved",{self:this},this._postboxMoved),$(document).off("postboxes-columnchange",{self:this},this._postboxMoved),$(window).off("beforeunload",{self:this},this._beforeunload),this.ditty.$elmt.off("ditty_active_items_update",{self:this},this._dittyItemsUpdated),this.ditty.$elmt.off("ditty_disabled_items_update",{self:this},this._disabledItemsUpdate),this.$tabs.off("click","ditty-editor__tab",{self:this},this._showPanel),this.$update.off("click",{self:this},this._saveClick),this.$panels.off("ditty_slider_init",{self:this},this._editorLoaded),this.$panels.off("ditty_slider_before_slide_update",{self:this},this._beforeSlideUpdate),this.$panels.off("ditty_slider_after_slide_update",{self:this},this._afterSlideUpdate),this.$panels.off("ditty_slider_slide_removed",{self:this},this._slideRemoved),this.trigger("destroy"),this.elmt._ditty_editor=null}},$.fn.ditty_editor=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_editor||(this._ditty_editor=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_editor;if(!i)throw new Error("No Ditty_Editor applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Editor.');return void 0!==e?e:this}},$.ditty_editor={},$.ditty_editor.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_settings_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$title=this.$elmt.find('input[name="title]'),this.$previewBg=this.$elmt.find('input[name="previewBg"]'),this.$previewPaddingTop=this.$elmt.find('input[name="previewPadding[paddingTop]"]'),this.$previewPaddingBottom=this.$elmt.find('input[name="previewPadding[paddingBottom]"]'),this.$previewPaddingLeft=this.$elmt.find('input[name="previewPadding[paddingLeft]"]'),this.$previewPaddingRight=this.$elmt.find('input[name="previewPadding[paddingRight]"]'),this.$postTitle=$(".ditty-post__title"),this.$editorPreview=$("#ditty-editor__preview"),this.dittyId=this.$form.data("ditty_id"),this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this.settings.editor.initFields(this.$elmt),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.on("submit",{self:this},this._submitForm),this.$form.on("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.on("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.on("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.on("keyup change",'input[name="title"]',{self:this},this._titleChange),this.$form.on("keyup change",".ditty-field--preview_settings *",{self:this},this._previewBgChange),this.$elmt.addClass("init")},_checkUpdates:function(t){var i=t?t.data.self:this;i.$form.serialize()!==i.initData?(i.settings.editor.addUpdate("settings",i.itemId),i.settings.editor.delayedSubmitEnable()):i.settings.editor.removeUpdate("settings",i.itemId)},_titleChange:function(t){var i=t?t.data.self:this,e=$(t.target).val();i.$postTitle.text(e)},_previewBgChange:function(t){var i=t?t.data.self:this,e={backgroundColor:i.$previewBg.val(),paddingTop:i.$previewPaddingTop.val(),paddingBottom:i.$previewPaddingBottom.val(),paddingLeft:i.$previewPaddingLeft.val(),paddingRight:i.$previewPaddingRight.val()};i.$editorPreview.css(e)},_addDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.dittyId;i.settings.editor.updateStart();var s={action:"ditty_editor_settings_update",ditty_id:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:s,success:function(t){i.initData=i.$form.serialize(),dittyDraftUpdate(i,"settings",!1,t),i.settings.editor.delayedSubmitDisable(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty({return_items:0}),i.afterUpdateAction=""}})},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_settings_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_settings_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.$form.off("submit",{self:this},this._submitForm),this.$form.off("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.off("keyup change",'input[name="previewBg"]',{self:this},this._previewBg_cahnge),this.$form.off("keyup change",'input[name="title"]',{self:this},this._titleChange),this.$form.off("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.off("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.trigger("destroy"),this.elmt._ditty_settings_panel=null}},$.fn.ditty_settings_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_settings_panel||(this._ditty_settings_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_settings_panel;if(!i)throw new Error("No Ditty_Settings_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Settings_Panel.');return void 0!==e?e:this}},$.ditty_settings_panel={},$.ditty_settings_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_items_panel.defaults,e),this.$elmt=$(i),this.$add=$(i).find(".ditty-editor-options__add"),this.$contents=$(i).find(".ditty-editor__panel__contents"),this.$list=$(i).find(".ditty-data-list"),this.$listItems=$(i).find(".ditty-data-list__items"),this.isEmptyTicker=!1,this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.settings.editor.$elmt.on("ditty_editor_aactive_items_update",{self:this},this._dittyActiveItemsUpdated),this.$add.on("click",{self:this},this._add_item),this.$elmt.on("click",".ditty-data-list__item",{self:this},this._showItem),this.$elmt.on("click",".ditty-data-list__item__icon",{self:this},this._editType),this.$elmt.on("click",".ditty-data-list__item__edit",{self:this},this._editItem),this.$elmt.on("click",".ditty-data-list__item__layout",{self:this},this._editLayoutVariations),this.$elmt.on("click",".ditty-data-list__item__clone",{self:this},this._cloneItem),this.$elmt.on("click",".ditty-data-list__item__delete",{self:this},this._deleteItem),this.$list.on("click",".ditty-editor-item > a",{self:this},this._actionClick),$("body").on("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),1>this.$elmt.find(".ditty-data-list__item").length&&(this.isEmptyTicker=!0,this.$add.trigger("click")),this._initializeSorting(),this._highlightListItems(this.settings.editor.activeItems)},dittyUpdateSavedDraftLayouts:function(t,i){$.each($(".ditty-editor-item"),(function(){var e=$(this).data("layout_value");$.each(e,(function(s,a){String(a)===String(t)&&(e[s]=String(i))})),$(this).attr("data-layout_value",e).data("layout_value",e)}))},_dittyEditorSaveResponse:function(t,i){var e=t.data.self;i.ditty_new_item_ids&&$.each(i.ditty_new_item_ids,(function(t,i){var e=$("#ditty-editor-item--"+t);e.length&&(e.attr("id","ditty-editor-item--"+i),e.attr("data-item_id",i).data("item_id",i))})),i.ditty_new_layout_ids&&$.each(i.ditty_new_layout_ids,(function(t,i){e.dittyUpdateSavedDraftLayouts(t,i)}))},_highlightListItem:function(t){var i=t.id+"";i=i.split("_"),this.$elmt.find("#ditty-editor-item--"+i[0]).addClass("active")},_highlightListItems:function(t){this.$elmt.find(".ditty-data-list__item").removeClass("active");var i=this;Array.isArray(t)?$.each(t,(function(t,e){i._highlightListItem(e)})):i._highlightListItem(t)},_dittyActiveItemsUpdated:function(t,i,e){t.data.self._highlightListItems(e)},_initializeSorting:function(){var t=this;this.$listItems.sortable({handle:".ditty-data-list__item__move",items:".ditty-data-list__item",axis:"y",start:function(t,i){$(i.item).addClass("ditty-data-list__item--moving")},stop:function(i,e){$(e.item).removeClass("ditty-data-list__item--moving"),t.settings.editor.addUpdate("item_order",t.settings.editor.dittyId)},update:function(){t._updateItemIndexes("updateDitty")}})},_showItem:function(t){t.preventDefault();var i=t.data.self;if(!$(t.target).is("a")&&!$(t.target).parent().is("a")){var e=($(t.target).is(".ditty-data-list__item")?$(t.target):$(t.target).parents(".ditty-data-list__item")).data("item_id");i.settings.editor.ditty.showItem(e)}},_actionClick:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("a")?$(t.target):$(t.target).parent("a"),s=e.parents(".ditty-data-list__item"),a=s.data("ditty_id"),d=s.data("item_id");dittyVars.editor.currentItem=s,$("body").trigger("ditty_editor_item_action_click",[e,s,d,a,i.settings.editor])},_editType:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item");e.trigger("click"),e.addClass("editing"),i.settings.editor.updateStart(),i.settings.editor.panelOptions("transition","slideRight"),i.settings.editor.showPanel("item_types")},_editItem:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("item_id");e.trigger("click"),e.addClass("editing"),i.settings.editor.updateStart();var a={action:"ditty_editor_item_fields",item_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--item_editor">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("item_editor",e)}}))},_editLayoutVariations:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("item_type"),a=e.data("layout_value"),d=e.find(".ditty-data-list__item__label").html();e.trigger("click"),e.addClass("editing"),i.settings.editor.updateStart();var r={action:"ditty_editor_layout_variations",ditty_id:i.settings.editor.dittyId,item_type:s,item_label:d,layout_value:a,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,r,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--layout-variations">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("layout_variations",e)}}))},_add_item:function(t){t.preventDefault();var i=t.data.self,e={action:"ditty_editor_item_add",ditty_id:i.settings.editor.dittyId,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,e,(function(t){if(t.display_items){if(i.isEmptyTicker){var e=i.settings.editor.ditty.options("items");$.each(e,(function(t,e){i.settings.editor.ditty.deleteItem(e.id)})),i.isEmptyTicker=!1}$.each(t.display_items,(function(t,e){i.settings.editor.ditty.addItem(e,0)}))}if(t.editor_item){var s=$(t.editor_item);s.hide(),i.$listItems.prepend(s),s.slideDown(),i._updateItemIndexes()}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),t.draft_id&&t.draft_meta&&dittyDraftItemUpdateMeta(i,t.draft_id,null,t.draft_meta)}),"json")},_cloneItem:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("item_id");i.settings.editor.updateStart();var a={action:"ditty_editor_item_clone",item_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t.display_items&&t.display_items.length&&i.settings.editor.ditty.updateItems(t.display_items,s,"after"),t.editor_item){var a=$(t.editor_item);a.hide(),e.after(a),a.slideDown(),i._updateItemIndexes()}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),t.draft_id&&t.draft_meta&&dittyDraftItemUpdateMeta(i,t.draft_id,null,t.draft_meta),i.settings.editor.updateStop()}),"json")},_deleteItem:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("item_id");1>=i.$elmt.find(".ditty-data-list__item").length&&i.$add.trigger("click"),e.slideUp((function(){$(this).remove()})),i.settings.editor.ditty.deleteItem(s),dittyDraftItemDelete(i,s)},_updateItemIndexes:function(t){var i=this,e=[];if(this.$elmt.find(".ditty-data-list__item").each((function(t){var s=$(this).data("item_id");e.push(s),dittyDraftItemUpdateData(i,s,"item_index",t)})),"updateDitty"===t){var s=dittyItemsReorder(i.settings.editor.ditty.options("items"),e);i.settings.editor.ditty.options("items",s)}},panelVisible:function(){this.$elmt.find(".ditty-data-list__item").removeClass("editing")},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_items_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_items_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.settings.editor.$elmt.off("ditty_editor_active_items_update",{self:this},this._dittyActiveItemsUpdated),this.$add.off("click",{self:this},this._add_item),this.$elmt.off("click",".ditty-data-list__item",{self:this},this._showItem),this.$elmt.off("click",".ditty-data-list__item__icon",{self:this},this._editType),this.$elmt.off("click",".ditty-data-list__item__edit",{self:this
|
2 |
-
},this._editItem),this.$elmt.off("click",".ditty-data-list__item__layout",{self:this},this._editLayoutVariations),this.$elmt.off("click",".ditty-data-list__item__clone",{self:this},this._cloneItem),this.$elmt.off("click",".ditty-data-list__item__delete",{self:this},this._deleteItem),this.$list.off("click",".ditty-editor-item > a",{self:this},this._actionClick),$("body").off("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this.trigger("destroy"),this.elmt._ditty_items_panel=null}},$.fn.ditty_items_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_items_panel||(this._ditty_items_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_items_panel;if(!i)throw new Error("No Ditty_Items_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Items_Panel.');return void 0!==e?e:this}},$.ditty_items_panel={},$.ditty_items_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_item_types_panel.defaults,e),this.$elmt=$(i),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$editorItem=this.settings.editor.$panels.find(".ditty-editor__panel--items").find(".ditty-data-list__item.editing"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.currentType=null,this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.settings.editor.initFields(this.$elmt),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("click",".ditty-editor-item-type",{self:this},this._typeClick),this.panelVisible()},_showItemsList:function(){this.settings.editor.panelOptions("transition","slideLeft"),this.settings.editor.showPanel("items")},_backClick:function(t){t.preventDefault(),t.data.self._showItemsList()},_typeClick:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is(".ditty-editor-item-type")?$(t.target):$(t.target).parents(".ditty-editor-item-type")).data("item_type");if(e===i.currentType)i._showItemsList();else{i.settings.editor.updateStart();var s={action:"ditty_editor_item_type_update",item_id:i.editorItemId,item_type:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,s,(function(t){if(t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,i.editorItemId),t.editor_item){var e=$(t.editor_item);i.$editorItem.after(e),i.$editorItem.remove(),i.$editorItem=e}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),i._showItemsList(),i.settings.editor.updateStop()}),"json")}},panelVisible:function(){this.$editorItem=this.settings.editor.$panels.find(".ditty-editor__panel--items").find(".ditty-data-list__item.editing"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.currentType=this.$editorItem.data("item_type"),this.$elmt.find(".ditty-editor-item-type").removeClass("active"),this.$elmt.find('.ditty-editor-item-type[data-itemType="'+this.currentType+'"]').addClass("active")},panelHidden:function(){var t=this.$editorItem.find(".ditty-data-list__item__icon").children("i");t.attr("class",t.data("class"))},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_item_types_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_item_types_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$back.off("click",{self:this},this._backClick),this.$elmt.off("click",".ditty-editor-item-type",{self:this},this._typeClick),this.trigger("destroy"),this.elmt._ditty_item_types_panel=null}},$.fn.ditty_item_types_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_item_types_panel||(this._ditty_item_types_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_item_types_panel;if(!i)throw new Error("No Ditty_Item_Types_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Item_Types_Panel.');return void 0!==e?e:this}},$.ditty_item_types_panel={},$.ditty_item_types_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_item_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$preview=this.$elmt.find(".ditty-editor-options__preview"),this.$title=this.$elmt.find(".ditty-editor-options__title"),this.itemId=this.$form.data("item_id"),this.itemType=this.$form.data("item_type"),this.dittyId=this.$form.data("ditty_id"),this.$editorItem=this.settings.editor.$panels.find(".ditty-editor__panel--items").find(".ditty-data-list__item.editing"),this.$editorItemTitle=this.$editorItem.find(".ditty-data-list__item__label"),this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this.settings.editor.initFields(this.$elmt),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.on("submit",{self:this},this._submitForm),this.$back.on("click",{self:this},this._backClick),this.$preview.on("click",{self:this},this._previewClick),this.$form.on("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.on("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.on("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.on("ditty_field_update",".ditty-field__input",{self:this},this._checkUpdates)},_showItemList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","items")},_enablePreviewButton:function(){this.$preview.addClass("ditty-has-updates")},_disablePreviewButton:function(){this.$preview.removeClass("ditty-has-updates"),this.$preview.children("i").attr("class",this.$preview.children("i").data("class"))},_checkUpdates:function(t){var i=t?t.data.self:this;i.$form.serialize()!==i.initData?(i._enablePreviewButton(),i.settings.editor.addUpdate("item_settings",i.itemId),i.settings.editor.delayedSubmitEnable()):(i._disablePreviewButton(),i.settings.editor.removeUpdate("item_settings",i.itemId))},_addDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.$form.serialize()===i.initData?i._showItemList():(i.afterUpdateAction="return",i.$form.trigger("submit"))},_previewClick:function(t){t.preventDefault();var i=t.data.self;i.$form.serialize()!==i.initData&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit"))},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.itemId;i.settings.editor.updateStart();var s={action:"ditty_editor_item_update",item_id:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:s,error:function(){},success:function(t){if(t.value_updates&&i._updateValues(t.value_updates),i.initData=i.$form.serialize(),i._disablePreviewButton(),t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,e),t.editor_item){var s=$(t.editor_item).children(".ditty-data-list__item__label").text();i.$title.html(s),i.$editorItemTitle.html(s)}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),t.draft_id&&t.draft_meta&&dittyDraftItemUpdateMeta(i,t.draft_id,null,t.draft_meta),i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showItemList(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty({return_items:0}),i.afterUpdateAction=""}})},_updateValues:function(t){var i=this;$.each(t,(function(t,e){var s=i.$form.find('[name="'+t+'"]');s.length&&s.val(e)}))},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_item_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_item_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._saveDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.off("submit",{self:this},this._submitForm),this.$back.off("click",{self:this},this._backClick),this.$preview.off("click",{self:this},this._previewClick),this.$form.off("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.off("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.off("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.off("ditty_field_update",".ditty-field__input",{self:this},this._checkUpdates),this.elmt._ditty_item_editor_panel=null}},$.fn.ditty_item_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_item_editor_panel||(this._ditty_item_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_item_editor_panel;if(!i)throw new Error("No Ditty_Item_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Item_Editor_Panel.');return void 0!==e?e:this}},$.ditty_item_editor_panel={},$.ditty_item_editor_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_displays_panel.defaults,e),this.$elmt=$(i),this.$list=$(i).find(".ditty-data-list__items"),this.$contents=$(i).find(".ditty-editor__panel__contents"),this.initDisplay=null,this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.$elmt.ditty_ui_data_list({filter:".ditty-display-panel__filter",item:".ditty-editor-display",itemSelector:"display_type"}),this.initDisplay=this.$list.data("active"),this._activateDisplay(this.$list.find("#ditty-editor-display--"+this.initDisplay)),this.$elmt.on("click",".ditty-data-list__item",{self:this},this._selectDisplay),this.$elmt.on("click",".ditty-data-list__item__edit",{self:this},this._editDisplay),this.$elmt.on("click",".ditty-data-list__item__clone",{self:this},this._cloneDisplay),this.$elmt.on("click",".ditty-data-list__item__delete",{self:this},this._deleteDisplay),this.settings.editor.$elmt.on("ditty_editor_saveDrafts",{self:this},this._saveDrafts)},_saveDrafts:function(t){var i=t.data.self;i.initDisplay=i.$list.find(".ditty-editor-display.active").data("display_id")},_activateDisplay:function(t){this.$list.find(".ditty-editor-display").removeClass("active"),t.addClass("active")},_initDitty:function(t,i,e){var s=this.settings.editor.ditty.$elmt;e.display=i,e.id=this.settings.editor.ditty.options("id"),e.items=this.settings.editor.ditty.options("items"),e.height=this.settings.editor.ditty.options("height"),this.settings.editor.ditty.destroy(),s["ditty_"+t](e),this.settings.editor.ditty=s["ditty_"+t]("options","ditty")},_selectDisplay:function(t){t.preventDefault();var i=t.data.self;if($(t.target).parent().is("a"))return!1;var e=$(t.target).is(".ditty-data-list__item")?$(t.target):$(t.target).parents(".ditty-data-list__item"),s=e.data("display_id"),a=e.data("display_type");if(e.hasClass("active"))return!1;i.settings.editor.updateStart(),dittyDraftUpdate(i,"post_meta","_ditty_display",s),i._activateDisplay(e);var d={action:"ditty_editor_select_display",display_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,d,(function(t){if(!t)return!1;i._initDitty(a,s,t),i.settings.editor.updateStop()}),"json")},_cloneDisplay:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("display_id");i.settings.editor.updateStart();var a={action:"ditty_editor_display_clone",display_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t.editor_display){var s=$(t.editor_display);s.hide(),e.after(s),s.slideDown()}t.draft_id&&t.draft_data&&dittyDraftDisplayUpdate(i,t.draft_id,null,t.draft_data),i.settings.editor.updateStop()}),"json")},_deleteDisplay:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=null,a=e.data("display_id");e.hasClass("active")&&(e.prev().length?s=e.prev():e.next().length&&(s=e.next())),e.slideUp((function(){$(this).remove()})),dittyDraftDisplayDelete(i,a),null!==s&&s.trigger("click")},_editDisplay:function(t){t.preventDefault();var i=t.data.self;i.$displayEdit=$(this).parents(".ditty-data-list__item");var e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("display_id");i.settings.editor.updateStart(),e.addClass("editing");var a={action:"ditty_editor_display_fields",display_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--displayEditor">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("display_editor",e)}}))},panelVisible:function(){this.$elmt.find(".ditty-data-list__item").removeClass("editing")},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_displays_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_displays_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$elmt.ditty_ui_data_list("destroy"),this.$elmt.off("click",".ditty-data-list__item",{self:this},this._selectDisplay),this.$elmt.off("click",".ditty-data-list__item__edit",{self:this},this._editDisplay),this.$elmt.off("click",".ditty-data-list__item__clone",{self:this},this._cloneDisplay),this.$elmt.off("click",".ditty-data-list__item__delete",{self:this},this._deleteDisplay),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.trigger("destroy"),this.elmt._ditty_displays_panel=null}},$.fn.ditty_displays_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_displays_panel||(this._ditty_displays_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_displays_panel;if(!i)throw new Error("No Ditty_Displays_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Displays_Panel.');return void 0!==e?e:this}},$.ditty_displays_panel={},$.ditty_displays_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_display_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$optionsTitle=this.$elmt.find(".ditty-editor-options__title"),this.$importExportField=this.$elmt.find(".ditty-editor__import-export__field"),this.$importExportUpdate=this.$elmt.find(".ditty-editor__import-export__update"),this.displayTitle=null,this.displayId=this.settings.editor.ditty.options("display"),this.displayType=this.settings.editor.ditty.options("type"),this.$editorDisplay=this.settings.editor.$panels.find(".ditty-editor__panel--displays").find(".ditty-data-list__item.editing"),this.$editorDisplayTitle=this.$editorDisplay.find(".ditty-data-list__item__label"),this.displayOptions=null,this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){var t,i=this;this.initData=this.$form.serialize(),this.settings.editor.initFields(this.$elmt),t=this.settings.editor.ditty.$elmt["ditty_"+this.displayType]("options"),this.displayOptions=$.extend({},t),this.displayTitle=this.$optionsTitle.val(),this.$importExportUpdate.on("click",{self:this},this._importUpdate),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.on("submit",{self:this},this._submitForm),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("change",'input[type="text"], input[type="number"]',{self:this},this._textfieldListeners),this.$form.on("click",'input[type="radio"]',{self:this},this._radioListeners),this.$form.on("click",'input[type="checkbox"]',{self:this},this._checkboxListeners),this.$form.on("change","select",{self:this},this._selectListeners),this.$form.on("ditty_field_clone_update",{self:this},this._cloneListeners),setTimeout((function(){i.trigger("init",[i])}),1)},_showDisplayList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","displays")},_checkUpdates:function(){this.$form.serialize()!==this.initData?(this.settings.editor.addUpdate("displaySettings",this.displayId),this.settings.editor.delayedSubmitEnable()):this.settings.editor.removeUpdate("displaySettings",this.displayId)},_addDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.$form.serialize()===i.initData?i._showDisplayList():(i.afterUpdateAction="return",i.$form.trigger("submit"))},_submitForm:function(t){t.preventDefault();var i=t.data.self;i.settings.editor.updateStart();var e={action:"ditty_editor_display_update",display_id:i.displayId,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:e,success:function(t){i.initData=i.$form.serialize(),t.draft_id&&t.draft_label&&(i.displayTitle=t.draft_label,i.$editorDisplayTitle.text(t.draft_label),dittyDraftDisplayUpdate(i,t.draft_id,"label",t.draft_label)),t.draft_id&&t.draft_settings&&(i.displayOptions=t.draft_settings,dittyDraftDisplayUpdate(i,t.draft_id,"settings",t.draft_settings)),t.draft_settings_json&&i.$importExportField.length&&i.$importExportField.val(t.draft_settings_json),i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showDisplayList(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty(),i.afterUpdateAction=""}})},_importUpdate:function(t){t.preventDefault()},_cloneListeners:function(t,i,e){var s=t.data.self;$(t.target);s.settings.editor.ditty.options(e,i)},_textfieldListeners:function(t){var i=t.data.self,e=$(t.target),s=e.attr("name"),a=e.parents(".ditty-input--spacing__group, .ditty-input--radius__group");if(a.length){var d="",r={};a.find("input").each((function(){s=$(this).attr("name"),d=(d=s.split("["))[0];var t=s.match(/\[(.*)\]/);r[t[1]]=$(this).val()})),i.settings.editor.ditty.options(d,r)}else i.settings.editor.ditty.options(s,e.val());i._checkUpdates()},_radioListeners:function(t){var i=t.data.self,e=$(t.target),s=e.val(),a=e.attr("name");i.settings.editor.ditty.options(a,s),i._checkUpdates()},_checkboxListeners:function(t){var i=t.data.self,e=$(t.target),s=!!e.is(":checked")&&$(this).val(),a=e.attr("name");i.settings.editor.ditty.options(a,s),i._checkUpdates()},_selectListeners:function(t){var i=t.data.self,e=$(t.target),s=e.val(),a=e.attr("name");i.settings.editor.ditty.options(a,s),i._checkUpdates()},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_display_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_display_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.trigger("destroy",[this]),this.$importExportUpdate.off("click",{this:this},this._importUpdate),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.off("submit",{this:this},this._submitForm),this.$back.off("click",{this:this},this._cancel_click),this.$elmt.off("change",'input[type="text"], input[type="number"]',{self:this},this._textfieldListeners),this.$form.off("click",'input[type="radio"]',{self:this},this._radioListeners),this.$form.off("click",'input[type="checkbox"]',{self:this},this._checkboxListeners),this.$form.off("change","select",{self:this},this._selectListeners),this.$form.off("ditty_field_clone_update",{self:this},this._cloneListeners),this.elmt._ditty_display_editor_panel=null}},$.fn.ditty_display_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_display_editor_panel||(this._ditty_display_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_display_editor_panel;if(!i)throw new Error("No Ditty_Display_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Display_Editor_Panel.');return void 0!==e?e:this}},$.ditty_display_editor_panel={},$.ditty_display_editor_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layout_variations_panel.defaults,e),this.$elmt=$(i),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$list=$(i).find(".ditty-data-list__items"),this.$editorItem=dittyVars.editor.currentItem,this.editorItemLabel=this.$editorItem.find(".ditty-data-list__item__label").text(),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.editorItemType=this.$editorItem.data("item_type"),this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("click",".ditty-layout-variation__change",{self:this},this._changeTemplate),this.$elmt.on("click",".ditty-layout-variation__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.on("click",".ditty-layout-variation__edit_css",{self:this,editType:"css"},this._editLayout),$("body").on("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse)},_showItemList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","items")},_backClick:function(t){t.preventDefault(),t.data.self._showItemList()},_dittyEditorSaveResponse:function(t,i){t.data.self;i.ditty_new_layout_ids&&$.each(i.ditty_new_layout_ids,(function(t,i){var e=$('.ditty-layout-variation[data-layout_id="'+t+'"]');e.length&&e.attr("data-layout_id",i).data("layout_id",i)}))},_changeTemplate:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("layout_id"),a=e.data("layout_variation_id"),d=e.data("layout_variation_label");dittyVars.editor.currentLayoutVariation=e,i.settings.editor.updateStart(),e.addClass("editing");var r={action:"ditty_editor_layouts",ditty_id:i.editorDittyId,item_type:i.editorItemType,variation_id:a,variation_label:d,layout_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,r,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--layouts">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("layouts",e)}}))},_editLayout:function(t){t.preventDefault();var i=t.data.self,e=t.data.editType,s=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),a=s.data("layout_id"),d=s.data("item_type");dittyVars.editor.currentLayoutVariation=s,i.settings.editor.updateStart(),i.$list.find(".ditty-data-list__item").removeClass("editing"),s.addClass("editing");var r=[],o=i.settings.editor.ditty.options("items");$.each(o,(function(t,i){r.push(i.uniqId)}));var n={action:"ditty_editor_layout_fields",layout_id:a,item_type:d,ditty_id:i.editorDittyId,item_id:i.editorItemId,item_ids:r,edit_type:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,n,(function(t){if(t){var s="layout_"+e+"_editor",a='<div class="ditty-editor__panel ditty-editor__panel--'+s+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel(s,a)}}),"json")},panelVisible:function(){this.$list.find(".ditty-layout-variation").removeClass("editing")},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layout_variations_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layout_variations_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$back.off("click",{self:this},this._backClick),this.$elmt.off("click",".ditty-layout-variation__change",{self:this},this._changeTemplate),this.$elmt.off("click",".ditty-layout-variation__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.off("click",".ditty-layout-variation__edit_css",{self:this,editType:"css"},this._editLayout),$("body").off("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this.elmt._ditty_layout_variations_panel=null}},$.fn.ditty_layout_variations_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layout_variations_panel||(this._ditty_layout_variations_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layout_variations_panel;if(!i)throw new Error("No Ditty_Layout_Variations_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layout_Variations_Panel.');return void 0!==e?e:this}},$.ditty_layout_variations_panel={},$.ditty_layout_variations_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layouts_panel.defaults,e),this.$elmt=$(i),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$list=$(i).find(".ditty-data-list__items"),this.$editorItem=dittyVars.editor.currentItem,this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.editorItemtype=this.$editorItem.data("item_type"),this.$editorVariation=dittyVars.editor.currentLayoutVariation,this.editorVariationId=this.$editorVariation.data("layout_variation_id"),this.editorLayoutId=this.$editorVariation.data("layout_id"),this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("click",".ditty-data-list__item",{self:this},this._selectLayout),this.$elmt.on("click",".ditty-data-list__item__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.on("click",".ditty-data-list__item__edit_css",{self:this,editType:"css"},this._editLayout),this.$elmt.on("click",".ditty-data-list__item__clone",{self:this},this._cloneLayout),this.$elmt.on("click",".ditty-data-list__item__delete",{self:this},this._deleteLayout),this.$list.on("click",".ditty-editor-layout > a",{self:this},this._actionClick),$("body").on("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this._activateLayout(this.$list.find("#ditty-editor-layout--"+this.editorLayoutId))},_activateLayout:function(t){this.$list.find(".ditty-editor-layout").removeClass("active"),t.addClass("active")},_showVariationsList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","layout_variations")},_backClick:function(t){t.preventDefault(),t.data.self._showVariationsList()},_dittyEditorSaveResponse:function(t,i){t.data.self;i.ditty_new_layout_ids&&$.each(i.ditty_new_layout_ids,(function(t,i){var e=$("#ditty-editor-layout--"+t);e.length&&(e.attr("id","ditty-editor-layout--"+i),e.attr("data-layout_id",i).data("layout_id",i))}))},_selectLayout:function(t){t.preventDefault();var i=t.data.self;if($(t.target).parent().is("a"))return!1;var e=$(t.target).is(".ditty-data-list__item")?$(t.target):$(t.target).parents(".ditty-data-list__item"),s=e.data("layout_id"),a=e.data("layout_version"),d=i.$editorItem.data("layout_value");if(e.hasClass("active"))return!1;$.each(d,(function(t){i.editorVariationId===t&&(d[t]=String(s))})),i.settings.editor.updateStart(),dittyDraftItemUpdateData(i,i.editorItemId,"layout_value",d),i._activateLayout(e);var r={action:"ditty_editor_select_layout",layout_id:s,item_id:i.editorItemId,ditty_id:i.editorDittyId,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,r,(function(t){if(i.settings.editor.updateStop(),t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,i.editorItemId),t.editor_item){var e=$(t.editor_item);i.$editorItem.replaceWith(e)}i.$editorItem.attr("data-layout_value",d).data("layout_value",d),i.$editorVariation.attr("data-layout_id",s).data("layout_id",s),i.$editorVariation.find(".ditty-layout-variation__template > span").text(t.layout_label),a?i.$editorVariation.find(".ditty-layout-variation__template > small").text("("+a+")"):i.$editorVariation.find(".ditty-layout-variation__template > small").text("")}),"json")},_cloneLayout:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("layout_id");i.settings.editor.updateStart();var a={action:"ditty_editor_layout_clone",layout_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t.editor_layout){var s=$(t.editor_layout);s.hide(),e.after(s),
|
3 |
-
s.slideDown()}t.draft_id&&t.draft_meta&&dittyDraftLayoutUpdate(i,t.draft_id,null,t.draft_meta),i.settings.editor.updateStop()}),"json")},_deleteLayout:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=null,a=e.data("layout_id");e.hasClass("active")&&(e.prev().length?s=e.prev():e.next().length&&(s=e.next())),e.slideUp((function(){$(this).remove()})),dittyDraftLayoutDelete(i,a),null!==s&&s.trigger("click")},_editLayout:function(t){t.preventDefault();var i=t.data.self,e=t.data.editType,s=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),a=s.data("layout_id");i.settings.editor.updateStart(),i.$list.find(".ditty-data-list__item").removeClass("editing"),s.addClass("editing");var d={action:"ditty_editor_layout_fields",layout_id:a,item_id:i.editorItemId,edit_type:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,d,(function(t){if(t){var s="layout_"+e+"_editor",a='<div class="ditty-editor__panel ditty-editor__panel--'+s+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel(s,a)}}),"json")},_actionClick:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("a")?$(t.target):$(t.target).parent("a"),s=e.parents(".ditty-data-list__item"),a=s.data("layout_id");dittyVars.editor.currentLayout=s,$("body").trigger("ditty_editor_layout_action_click",[e,s,a,i.editorDittyId,i.settings.editor])},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layouts_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layouts_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$back.off("click",{self:this},this._backClick),this.$elmt.off("click",".ditty-data-list__item",{self:this},this._selectLayout),this.$elmt.off("click",".ditty-data-list__item__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.off("click",".ditty-data-list__item__edit_css",{self:this,editType:"css"},this._editLayout),this.$elmt.off("click",".ditty-data-list__item__clone",{self:this},this._cloneLayout),this.$elmt.off("click",".ditty-data-list__item__delete",{self:this},this._deleteLayout),this.$list.off("click",".ditty-editor-layout > a",{self:this},this._actionClick),$("body").off("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this.elmt._ditty_layouts_panel=null}},$.fn.ditty_layouts_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layouts_panel||(this._ditty_layouts_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layouts_panel;if(!i)throw new Error("No Ditty_Layouts_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layouts_Panel.');return void 0!==e?e:this}},$.ditty_layouts_panel={},$.ditty_layouts_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null,prevPanel:""},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layout_html_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$textarea=this.$elmt.find(".ditty-editor-options__code"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$preview=this.$elmt.find(".ditty-editor-options__preview"),this.$editCss=this.$elmt.find(".ditty-editor-options__edit-css"),this.$title=this.$elmt.find(".ditty-editor-options__title"),this.$tags=this.$elmt.find(".ditty-editor-options__tags"),this.itemType=this.$form.data("item_type"),this.layoutId=this.$form.data("layout_id"),this.$editorItem=dittyVars.editor.currentItem,this.$editorLayout=dittyVars.editor.currentLayout,this.$editorLayoutTitle=!!this.$editorLayout&&this.$editorLayout.find(".ditty-data-list__item__label"),this.$editorLayoutVariation=dittyVars.editor.currentLayoutVariation,this.$editorLayoutVariationTitle=this.$editorLayoutVariation.find(".ditty-layout-variation__template span"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.codeEditor=null,this.codeHasUpdates=!1,this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this._initEditor(),this.$back.on("click",{self:this},this._backClick),this.$preview.on("click",{self:this},this._previewClick),this.$editCss.on("click",{self:this},this._editCss),this.$form.on("submit",{self:this},this._submitForm),this.$form.on("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.on("keyup",{self:this},this._titleUpdate),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts)},_showPrevPanel:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById",this.settings.prevPanel)},_titleUpdate:function(t){var i=t.data.self;i.settings.editor.addUpdate("layoutUpdate",i.layoutId)},_enablePreviewButton:function(){this.$preview.addClass("ditty-has-updates")},_disablePreviewButton:function(){this.$preview.removeClass("ditty-has-updates"),this.$preview.children("i").attr("class",this.$preview.children("i").data("class"))},_getLayoutItems:function(){var t=this.settings.editor.ditty.options("items"),i=[];return $.each(t,(function(t,e){String(e.layoutId)===String(this.layoutId)&&i.push(e.id)})),i},_addDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),i.$form.serialize()!==i.initData||i.codeHasUpdates?(i.afterUpdateAction="return",i.$form.trigger("submit")):i._showPrevPanel()},_previewClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit"))},_editCss:function(t){t.preventDefault();var i=t.data.self,e="layout_css_editor";if(i.settings.editor.updateStart(),i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit")),i.settings.editor.panelExists(e))i.settings.editor.$elmt.find(".ditty-editor__panel--layout_css_editor input.ditty-editor-options__title").val(i.$title.val()),i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e);else{var s={action:"ditty_editor_layout_fields",layout_id:i.layoutId,layout_title:i.$title.val(),ditty_id:i.editorDittyId,item_id:i.editorItemId,item_type:i.itemType,edit_type:"css",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,s,(function(t){if(t){var s='<div class="ditty-editor__panel ditty-editor__panel--'+e+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e,s)}}),"json")}},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.layoutId,s=i.itemType,a=i._getLayoutItems();if(i.$form.hasClass("ditty-editor-has-errors"))return!1;i.codeEditor.codemirror.save(),i.settings.editor.updateStart();var d={action:"ditty_editor_layout_update",layout_id:e,item_type:s,item_ids:a,edit_type:"html",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:d,success:function(t){i.initData=i.$form.serialize(),i._disablePreviewButton(),t.label&&(i.$editorLayoutTitle&&i.$editorLayoutTitle.html(t.label),i.$editorLayoutVariationTitle.html(t.label)),i.$editorLayoutTitle&&i.$editorLayoutTitle.find(".ditty-layout-version").remove(),i.$editorLayoutVariationTitle&&i.$editorLayoutVariationTitle.find(".ditty-layout-version").remove(),t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,!1,!1,!0),t.draft_id&&t.draft_meta&&dittyDraftLayoutUpdate(i,t.draft_id,null,t.draft_meta),i.codeHasUpdates=!1,i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showPrevPanel(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty({return_items:0}),i.afterUpdateAction=""}})},_initEditor:function(){var t=this,i=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{};i.codemirror=_.extend({},i.codemirror,{indentUnit:2,tabSize:2}),this.codeEditor=wp.codeEditor.initialize(this.$textarea[0],i),this.codeEditor.codemirror.on("change",(function(){t.codeEditor.codemirror.save(),t.settings.editor.addUpdate("layout_html_update",t.layoutId),t.codeHasUpdates=!0,t._enablePreviewButton(),t.settings.editor.delayedSubmitEnable()}))},_insertTag:function(t){var i=t.data.self,e=$(t.target),s=e.text(),a=e.data("atts"),d=i.codeEditor.codemirror.getCursor();if(t.shiftKey&&a){var r="",o=s.length-1;$.each(a,(function(t,i){r+=" "+t+'="'+i.toString()+'"'})),s=s.substring(0,o)+r+s.substring(o)}i.codeEditor.codemirror.replaceRange(s,d),d.ch=d.ch+s.length,i.codeEditor.codemirror.setCursor(d)},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layout_html_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layout_html_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$back.off("click",{self:this},this._backClick),this.$preview.off("click",{self:this},this._previewClick),this.$editCss.off("click",{self:this},this._editCss),this.$form.off("submit",{self:this},this._submitForm),this.$form.off("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.off("keyup",{self:this},this._titleUpdate),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.codeEditor.codemirror.off("change"),this.codeEditor.codemirror.toTextArea(),this.elmt._ditty_layout_html_editor_panel=null}},$.fn.ditty_layout_html_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layout_html_editor_panel||(this._ditty_layout_html_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layout_html_editor_panel;if(!i)throw new Error("No Ditty_Layout_Html_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layout_Html_Editor_Panel.');return void 0!==e?e:this}},$.ditty_layout_html_editor_panel={},$.ditty_layout_html_editor_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null,prevPanel:""},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layout_css_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$textarea=this.$elmt.find(".ditty-editor-options__code"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$preview=this.$elmt.find(".ditty-editor-options__preview"),this.$editHtml=this.$elmt.find(".ditty-editor-options__edit-html"),this.$title=this.$elmt.find(".ditty-editor-options__title"),this.$body=this.$elmt.find(".ditty-editor-options__body"),this.$tags=this.$elmt.find(".ditty-editor-options__tags"),this.itemType=this.$form.data("item_type"),this.layoutId=this.$form.data("layout_id"),this.$editorItem=dittyVars.editor.currentItem,this.$editorLayout=dittyVars.editor.currentLayout,this.$editorLayoutTitle=!!this.$editorLayout&&this.$editorLayout.find(".ditty-data-list__item__label"),this.$editorLayoutVariation=dittyVars.editor.currentLayoutVariation,this.$editorLayoutVariationTitle=this.$editorLayoutVariation.find(".ditty-layout-variation__template span"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.itemSelector="",this.codeEditor=null,this.codeHasUpdates=!1,this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this._setCssSelector(),this._initEditor(),this.$back.on("click",{self:this},this._backClick),this.$preview.on("click",{self:this},this._previewClick),this.$editHtml.on("click",{self:this},this._editHtml),this.$form.on("submit",{self:this},this._submitForm),this.$form.on("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.on("keyup",{self:this},this._titleUpdate),this.$body.on("click",".ditty-editor-options__body__error",{self:this},this._removeErrorNotice),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts)},_setCssSelector:function(){dittyVars.isTickerPost?this.itemSelector="#poststuff .ditty-layout--"+this.layoutId:this.itemSelector=".ditty-layout--"+this.layoutId},_showPrevPanel:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById",this.settings.prevPanel)},_titleUpdate:function(t){var i=t.data.self;i.settings.editor.addUpdate("layoutUpdate",i.layoutId)},_enablePreviewButton:function(){this.$preview.addClass("ditty-has-updates")},_disablePreviewButton:function(){this.$preview.removeClass("ditty-has-updates"),this.$preview.children("i").attr("class",this.$preview.children("i").data("class"))},_addDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),i.$form.serialize()!==i.initData||i.codeHasUpdates?(i.afterUpdateAction="return",i.$form.trigger("submit")):i._showPrevPanel()},_previewClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit"))},_editHtml:function(t){t.preventDefault();var i=t.data.self,e="layout_html_editor";if(i.settings.editor.updateStart(),i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit")),i.settings.editor.panelExists(e))i.settings.editor.$elmt.find(".ditty-editor__panel--layout_html_editor input.ditty-editor-options__title").val(i.$title.val()),i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e);else{var s={action:"ditty_editor_layout_fields",layout_id:i.layoutId,layout_title:i.$title.val(),ditty_id:i.editorDittyId,item_id:i.editorItemId,item_type:i.itemType,edit_type:"html",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,s,(function(t){if(t){var s='<div class="ditty-editor__panel ditty-editor__panel--'+e+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e,s)}}),"json")}},_showErrorNotice:function(){var t=$('<div class="ditty-editor-options__body__error"><span>'+dittyVars.strings.layout_css_error+"</span></div>");this.$body.append(t)},_removeErrorNotice:function(t){t.data.self.$body.find(".ditty-editor-options__body__error").remove()},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.layoutId,s=i.itemType;if(i.$form.hasClass("ditty-editor-has-errors"))return!1;i.codeEditor.codemirror.save(),i.settings.editor.updateStart();var a={action:"ditty_editor_layout_update",layout_id:e,item_type:s,edit_type:"css",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:a,success:function(t){i.initData=i.$form.serialize(),i._disablePreviewButton(),t.label&&(i.$editorLayoutTitle&&i.$editorLayoutTitle.html(t.label),i.$editorLayoutVariationTitle.html(t.label)),i.$editorLayoutTitle&&i.$editorLayoutTitle.find(".ditty-layout-version").remove(),i.$editorLayoutVariationTitle&&i.$editorLayoutVariationTitle.find(".ditty-layout-version").remove(),t.code?dittyLayoutCss(t.code,i.layoutId,"update"):i._showErrorNotice(),t.draft_id&&t.draft_meta&&dittyDraftLayoutUpdate(i,t.draft_id,null,t.draft_meta),i.codeHasUpdates=!1,i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showPrevPanel(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty(),i.afterUpdateAction=""}})},_initEditor:function(){var t=this,i=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{},e=dittyVars.editor.ditty_layouts_sass?"sass":"css";i.codemirror=_.extend({},i.codemirror,{mode:e,indentUnit:2,tabSize:2}),this.codeEditor=wp.codeEditor.initialize(this.$textarea[0],i),this.codeEditor.codemirror.on("change",(function(){t.codeEditor.codemirror.save(),t.settings.editor.addUpdate("layoutCssUpdate",t.layoutId),t.codeHasUpdates=!0,t._enablePreviewButton(),t.settings.editor.delayedSubmitEnable()}))},_insertTag:function(t){var i=t.data.self,e=$(t.target).text(),s=i.codeEditor.codemirror.getCursor();i.codeEditor.codemirror.replaceRange(e,s),s.ch=s.ch+e.length,i.codeEditor.codemirror.setCursor(s)},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layout_css_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layout_css_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$back.off("click",{self:this},this._backClick),this.$preview.off("click",{self:this},this._previewClick),this.$editHtml.off("click",{self:this},this._editHtml),this.$form.off("submit",{self:this},this._submitForm),this.$form.off("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.off("keyup",{self:this},this._titleUpdate),this.$body.off("click",".ditty-editor-options__body__error",{self:this},this._removeErrorNotice),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.codeEditor.codemirror.off("change"),this.codeEditor.codemirror.toTextArea(),this.elmt._ditty_layout_css_editor_panel=null}},$.fn.ditty_layout_css_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layout_css_editor_panel||(this._ditty_layout_css_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layout_css_editor_panel;if(!i)throw new Error("No Ditty_Layout_Css_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layout_Css_Editor_Panel.');return void 0!==e?e:this}},$.ditty_layout_css_editor_panel={},$.ditty_layout_css_editor_panel.defaults=t}(jQuery),jQuery(document).ready((function($){!function(){"use strict";function t(t,i){0===parseInt(i)?t.hide():t.show()}function i(t,i){"none"===i?t.hide():t.show()}function e(t,i){"none"===i?t.hide():t.show()}$("#ditty-editor").on("ditty_display_editor_panel_init",".ditty-editor__panel--displayEditor",(function(s,a){if("list"===a.displayType){var d=a.$form,r=d.find(".ditty-field--perPage"),o=d.find(".ditty-field--arrows").siblings(),n=d.find(".ditty-field--bullets").siblings();t(r,d.find('input[name="paging"]:checked').val()),d.find('input[name="paging"]').on("change",(function(){t(r,$(this).val())})),i(o,d.find('select[name="arrows"]').val()),d.find('select[name="arrows"]').on("change",(function(){i(o,$(this).val())})),e(n,d.find('select[name="bullets"]').val()),d.find('select[name="bullets"]').on("change",(function(){e(n,$(this).val())}))}}))}()})),jQuery(document).ready((function($){!function(){"use strict";function t(t,i,e){"down"===e||"up"===e?(t.show(),i.show()):(t.hide(),i.hide())}$("#ditty-editor").on("ditty_display_editor_panel_init",".ditty-editor__panel--displayEditor",(function(i,e){if("ticker"===e.displayType){var s=e.$form,a=s.find(".ditty-field--minHeight"),d=s.find(".ditty-field--maxHeight");t(a,d,s.find('input[name="direction"]:checked').val()),s.find('input[name="direction"]').on("change",(function(){t(a,d,$(this).val())}))}}))}()}));
|
1 |
+
function dittyEditorInit(t){if(!t)return!1;jQuery("#ditty-editor__settings").ditty_editor({ditty:t})}function dittyGetItemsById(t,i){var e=[];return jQuery.each(t,(function(t,s){String(s.id)===String(i)&&e.push(s)})),e}function dittyItemsReorder(t,i){var e=[];return jQuery.each(i,(function(i,s){e=jQuery.merge(e,dittyGetItemsById(t,s))})),e}function dittyDraftUpdate(t,i,e,s){var a=t.settings.editor.getDraftValues(i);return a||(a={}),e?a[e]=s:a=s,t.settings.editor.updateDraftValues(i,a)}function dittyDraftGet(t,i,e){var s=t.settings.editor.getDraftValues(i);return!!s&&(e&&s[e]?s[e]:s)}function dittyDraftDelete(t,i,e){var s=i.settings.editor.getDraftValues(t),a={};return jQuery.each(s,(function(t,i){String(e)!==String(t)&&(a[t]=i)})),"new-"!==String(e).substring(0,4)&&(a[e]="DELETE"),i.settings.editor.updateDraftValues(t,a)}function dittyDraftItemDelete(t,i){return dittyDraftDelete("items",t,i)}function dittyDraftLayoutDelete(t,i){return dittyDraftDelete("layouts",t,i)}function dittyDraftDisplayDelete(t,i){return dittyDraftDelete("displays",t,i)}function dittyDraftItemUpdateData(t,i,e,s){var a=t.settings.editor.getDraftValues("items");return a||(a={}),a[i]||(a[i]={}),a[i].data||(a[i].data={}),e?a[i].data[e]=s:a[i].data=s,t.settings.editor.updateDraftValues("items",a)}function dittyDraftItemGetData(t,i,e){var s=t.settings.editor.getDraftValues("items");return!!s[i]&&(!!s[i].data&&(e?s[i].data[e]?s[i].data[e]:void 0:s[i].data))}function dittyDraftItemUpdateMeta(t,i,e,s){var a=t.settings.editor.getDraftValues("items");return a||(a={}),a[i]||(a[i]={}),a[i].meta||(a[i].meta={}),e?a[i].meta[e]=s:a[i].meta=s,t.settings.editor.updateDraftValues("items",a)}function dittyDraftItemGetMeta(t,i,e){var s=t.settings.editor.getDraftValues("items");return!!s[i]&&(!!s[i].meta&&(e?s[i].meta[e]?s[i].meta[e]:void 0:s[i].meta))}function dittyDraftLayoutUpdate(t,i,e,s){var a=t.settings.editor.getDraftValues("layouts");return a||(a={}),a[i]||(a[i]={}),e?a[i][e]=s:a[i]=s,t.settings.editor.updateDraftValues("layouts",a)}function dittyDraftLayoutGet(t,i,e){var s=t.settings.editor.getDraftValues("layouts");return!!s[i]&&(e?s[i][e]?s[i][e]:void 0:s[i])}function dittyDraftDisplayUpdate(t,i,e,s){var a=t.settings.editor.getDraftValues("displays");return a||(a={}),a[i]||(a[i]={}),e?a[i][e]=s:a[i]=s,t.settings.editor.updateDraftValues("displays",a)}function dittyDraftDisplayGet(t,i,e){var s=t.settings.editor.getDraftValues("layouts");return!!s[i]&&(e?s[i][e]?s[i][e]:void 0:s[i])}jQuery((function($){!function(){"use strict";$("body").on("ditty_editor_before_panel_update",(function(t,i,e,s,a,d){switch(d.delayedSubmitDisable(),$.protip({defaults:{position:"top",size:"small",scheme:"black",classes:"ditty-protip"}}),i){case"settings":e.hasClass("init")||e.ditty_settings_panel({editor:d});break;case"items":e.hasClass("init")?e.ditty_items_panel("panelVisible"):e.ditty_items_panel({editor:d});break;case"displays":e.find(".ditty-data-list__item").removeClass("editing"),e.hasClass("init")?e.ditty_displays_panel("panelVisible"):e.ditty_displays_panel({editor:d});break;case"item_types":e.find(".ditty-data-list__item").removeClass("editing"),e.hasClass("init")?e.ditty_item_types_panel("panelVisible"):e.ditty_item_types_panel({editor:d});break;case"item_editor":e.ditty_item_editor_panel({editor:d});break;case"display_editor":e.ditty_display_editor_panel({editor:d});break;case"layouts":"layoutHtmlEditor"!==s&&"layoutCssEditor"!==s&&e.ditty_layouts_panel({editor:d});break;case"layout_variations":e.hasClass("init")?e.ditty_layout_variations_panel("panelVisible"):e.ditty_layout_variations_panel({editor:d});break;case"layout_html_editor":e.ditty_layout_html_editor_panel({editor:d,prevPanel:s});break;case"layout_css_editor":e.ditty_layout_css_editor_panel({editor:d,prevPanel:s})}})),$("body").on("ditty_editor_panel_removed",(function(t,i,e){switch(i){case"item_editor":e.ditty_item_editor_panel&&e.ditty_item_editor_panel("destroy");break;case"display_editor":e.ditty_display_editor_panel&&e.ditty_display_editor_panel("destroy");break;case"layouts":case"layouts":e.ditty_layouts_panel&&e.ditty_layouts_panel("destroy");break;case"layout_variations":e.ditty_layout_variations_panel&&e.ditty_layout_variations_panel("destroy");break;case"layout_html_editor":e.ditty_layout_html_editor_panel&&e.ditty_layout_html_editor_panel("destroy");break;case"layout_css_editor":e.ditty_layout_css_editor_panel&&e.ditty_layout_css_editor_panel("destroy")}}))}()})),dittyEditorInit(),function($){"use strict";var t={listType:"toggle",showAll:!0,activeFilter:"*",filter:".ditty-data-list__filter",filterSelector:"filter",item:".ditty-data-list__item",itemSelector:"filter"},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_ui_data_list.defaults,e),this.$elmt=$(i),this.filters=[],this._init()};i.prototype={_init:function(){var t=this;this.$elmt.on("click",this.settings.filter,{self:this},this._filterClick),this.$elmt.find(this.settings.filter+".active").each((function(){t._filterList($(this).data(t.settings.filterSelector))})),"*"!==this.settings.activeFilter&&this._filterList(this.settings.activeFilter),setTimeout((function(){t.trigger("init")}),1)},_filterList:function(t){var i=this,e=this.filters;if("toggle"===this.settings.listType)this.filters.includes(t)?this.settings.showAll&&(this.filters=[],this.$elmt.find(this.settings.filter).removeClass("active"),this.$elmt.find(this.settings.item).show()):(this.filters=[t],this.$elmt.find(this.settings.filter).removeClass("active"),this.$elmt.find(this.settings.filter+"[data-"+this.settings.filterSelector+'="'+t+'"]').addClass("active"),this.$elmt.find(this.settings.item).hide(),this.$elmt.find(this.settings.item+"[data-"+this.settings.itemSelector+'="'+t+'"]').show());else if("filter"===this.settings.listType){if(this.$elmt.find(this.settings.item).hide(),this.filters.includes(t)){this.$elmt.find(this.settings.filter+"[data-"+this.settings.filterSelector+'="'+t+'"]').removeClass("active");for(var s=0;s<this.filters.length;s++)i.filters[s]===t&&i.filters.splice(s,1)}else this.$elmt.find(this.settings.filter+"[data-"+this.settings.filterSelector+'="'+t+'"]').addClass("active"),this.filters.push(t);$.each(this.filters,(function(t,e){i.$elmt.find(this.settings.item+"[data-"+this.settings.itemSelector+'="'+e+'"]').show()})),0===this.filters.length&&i.$elmt.find(this.settings.item).show()}e!==this.filters&&i.trigger("update")},_filterClick:function(t){t.preventDefault();var i=t.data.self,e=$(t.target);e.is("a")||(e=e.parents("a")),i._filterList(e.data(i.settings.filterSelector))},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings,this.filters];i&&(e=i),this.$elmt.trigger("ditty_ui_data_list_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_ui_data_list.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.off("click",this.settings.filter,{self:this},this._filterClick),this.trigger("destroy"),this.elmt._ditty_ui_data_list=null}},$.fn.ditty_ui_data_list=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_ui_data_list||(this._ditty_ui_data_list=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_ui_data_list;if(!i)throw new Error("No Ditty_UI_Data_List applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_UI_Data_List.');return void 0!==e?e:this}},$.ditty_ui_data_list={},$.ditty_ui_data_list.defaults=t}(jQuery),function($){"use strict";var t={screen:"admin",ditty:null,panel:""},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_editor.defaults,e),this.$elmt=$(i),this.ditty=this.settings.ditty,this.dittyId=this.settings.ditty.options("id"),this.dittyType=this.settings.ditty.options("type"),this.displayId=0,this.panelsLoaded=0,this.unsavedUpdates={},this.draftValues={},this.$overlay=null,this.$contents=null,this.$header=null,this.$update=null,this.$updateCount=null,this.$updateLabel=null,this.$tabs=null,this.$panels=null,this.currentTab=0,this.currentPanel=this.settings.panel,this.delayedSubmit=!1,this.tabs=[],this.panels=[],this.activeItems=[],this._init()};i.prototype={_init:function(){var t,i,e,s,a,d,r,o=this;t=$('<div class="ditty-editor__contents"></div>'),this.$contents=t,i=$('<div class="ditty-editor__header"></div>'),this.$header=i,e=$('<span class="ditty-editor__update__count"></span>'),this.$updateCount=e,s=$('<span class="ditty-editor__update__label">Save Ditty</span>'),this.$updateLabel=s,a=$('<button type="submit" class="ditty-editor__update ditty-button ditty-button--primary"></button>'),this.$update=a,d=$('<div class="ditty-editor__tabs"></div>'),this.$tabs=d,r=$('<div class="ditty-editor__panels"></div>'),this.$panels=r,a.prepend(e,s),i.append(a),t.append(i,d,r),this.$elmt.append(t),this.$overlay=$('<div class="ditty-updating-overlay ditty-admin-item__overlay"><div class="ditty-updating-overlay__inner"><i class="fas fa-sync-alt fa-spin"></i></div></div>'),this.$elmt.append(this.$overlay),$(document).on("postbox-moved",{self:this},this._postboxMoved),$(document).on("postboxes-columnchange",{self:this},this._postboxMoved),$(window).on("beforeunload",{self:this},this._beforeunload),this.ditty.$elmt.on("ditty_active_items_update",{self:this},this._dittyItemsUpdated),this.ditty.$elmt.on("ditty_disabled_items_update",{self:this},this._disabledItemsUpdate),this.$tabs.on("click",".ditty-editor__tab",{self:this},this._showPanel),this.$update.on("click",{self:this},this._saveClick),this.$panels.on("ditty_slider_init",{self:this},this._editorLoaded),this.$panels.on("ditty_slider_before_slide_update",{self:this},this._beforeSlideUpdate),this.$panels.on("ditty_slider_after_slide_update",{self:this},this._afterSlideUpdate),this.$panels.on("ditty_slider_slide_removed",{self:this},this._slideRemoved),this._loadContents(),this.trigger("stop_live_updates"),setTimeout((function(){o.trigger("init")}),1)},_loadContents:function(){var t=this,i={action:"ditty_editor_load_contents",ditty_id:this.dittyId,security:dittyVars.security};$.post(dittyVars.ajaxurl,i,(function(i){t._initTabs(i.tabs),t._initPanels(i.panels),t._initSlider()}),"json")},_editorLoaded:function(t){var i=t.data.self;$("body").trigger("ditty_editor_loaded",[i])},_setUpdateCount:function(){},_initSlider:function(){var t=this.tabs[0].id;this.currentPanel&&""!==this.currentPanel&&(t=this.currentPanel),this.$panels.ditty_slider({transition:"fade",transitionSpeed:.75,heightSpeed:.75,touchSwipe:!1,slides:this.panels,slideId:t})},_beforeSlideUpdate:function(t,i,e,s,a){var d=t.data.self;d.updateStart(),d._updateTab(e.id),$("body").trigger("ditty_editor_before_panel_update",[e.id,e.$elmt,a.id,a.$elmt,d])},_afterSlideUpdate:function(t,i,e,s,a){var d=t.data.self;d.updateStop(),$("body").trigger("ditty_editor_after_panel_update",[e.id,e.$elmt,a.id,a.$elmt,d])},_slideRemoved:function(t,i){var e=t.data.self;$("body").trigger("ditty_editor_panel_removed",[i.id,i.$elmt,e])},_showPanel:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("a")?$(t.target):$(t.target).parent("a"),s=e.data("panel"),a=parseInt(e.data("index"));if(s===i.currentTab)return!1;var d=a>i.currentTab?"slideLeft":"slideRight";i.$panels.ditty_slider("options","transition",d),i.$panels.ditty_slider("showSlideById",s),i.currentTab=a,i.$elmt.trigger("ditty_editor_add_drafts")},_updateTab:function(t){var i=$('.ditty-editor__tab[data-panel="'+t+'"]');void 0!==i[0]&&($(".ditty-editor__tab").removeClass("active"),i.addClass("active"),this.currentTab=parseInt(i.data("index")))},_initTabs:function(t){var i=this,e=0;$.each(t,(function(t,s){var a=$('<a href="#" class="ditty-editor__tab ditty-editor__tab--'+t+'" data-panel="'+t+'" data-index="'+e+'"><i class="'+s.icon+'"></i><span>'+s.label+"</span></a>");i.$tabs.append(a),i.tabs.push({id:t,tab:a}),e++}))},_initPanels:function(t){var i=this;$.each(t,(function(t,e){var s='<div class="ditty-editor__panel ditty-editor__panel--'+t+'">'+e+"</div>";i.panels.push({id:t,html:s,cache:!0})}))},_initFields:function(t){t.find(".ditty-data-list").ditty_ui_data_list(),t.trigger("ditty_init_fields"),$.protip({defaults:{position:"top",size:"small",scheme:"black",classes:"ditty-protip"}})},saveDitty:function(t){var i=this,e=i.dittyId;i.$updateLabel.text("Updating..."),i.updateStart();var s={action:"ditty_editor_save",ditty_id:e,draft_values:i.draftValues,return_items:1,security:dittyVars.security};s=$.extend({},s,t),$.post(dittyVars.ajaxurl,s,(function(t){$("body").trigger("ditty_editor_save_ditty_response",[t]),t.display_items&&i.ditty.options("items",t.display_items),i.draftValues={},i.unsavedUpdates={},i._setUpdateCount(),i.$elmt.removeClass("ditty-editor--updates-exist"),i.$updateLabel.text("Ditty Saved!"),setTimeout((function(){i.$updateLabel.text("Save Ditty")}),2e3),i.updateStop(),t.new_ditty_url&&window.history.pushState(null,"","/wp-admin/post.php?post="+e+"&action=edit")}))},_saveClick:function(t){t.preventDefault();var i=t.data.self;i.$elmt.trigger("ditty_editor_save_drafts"),i.delayedSubmit||i.saveDitty()},_dittyItemsUpdated:function(t,i,e){var s=t.data.self;s.activeItems=e,s.trigger("active_items_update")},_disabledItemsUpdate:function(t,i){var e=t.data.self;$.each(i,(function(t,i){"disabled"===i?e.$elmt.find("#ditty-editor-item--"+t).addClass("ditty-editor-item--disabled"):e.$elmt.find("#ditty-editor-item--"+t).removeClass("ditty-editor-item--disabled")}))},_postboxMoved:function(t,i){if(!window.tinymce)return!1;$(i).find(".wp-editor-area").each((function(){var t=$(this).attr("id");tinymce.execCommand("mceRemoveEditor",!0,t),tinymce.execCommand("mceAddEditor",!0,t)}))},_beforeunload:function(t){var i=t.data.self;return Object.keys(i.unsavedUpdates).length>0||void 0},_windowResize:function(t){t.preventDefault()},_options:function(t){return this.settings[t]},panelExists:function(t){var i=this.$panels.ditty_slider("options","slides"),e=!1;return $.each(i,(function(i,s){String(s.id)!==String(t)||(e=!0)})),e},showPanel:function(t,i){i&&this.$panels.ditty_slider("addSlideById",t,i),this.$panels.ditty_slider("showSlideById",t,!0)},updateExists:function(t,i){if(void 0===this.unsavedUpdates[t]&&(this.unsavedUpdates[t]=[]),-1!==$.inArray(i,this.unsavedUpdates[t]))return!0},addUpdate:function(t,i){var e=!1;return void 0===this.unsavedUpdates[t]&&(this.unsavedUpdates[t]=[]),-1===$.inArray(i,this.unsavedUpdates[t])&&(e=!0,this.unsavedUpdates[t].push(i)),this._setUpdateCount(),this.$elmt.addClass("ditty-editor--updates-exist"),e},removeUpdate:function(t,i){if(void 0===this.unsavedUpdates[t])return!1;if(-1===$.inArray(i,this.unsavedUpdates[t]))return!1;var e=!1,s=[];return $.each(this.unsavedUpdates[t],(function(t,a){String(i)===String(a)?e=!0:s.push(a)})),this.unsavedUpdates[t]=s,this._setUpdateCount(),""===this.$updateCount.text()&&this.$elmt.removeClass("ditty-editor--updates-exist"),e},updateStart:function(){this.$overlay.fadeIn()},updateStop:function(){this.$overlay.fadeOut()},initFields:function(t){this._initFields(t)},updateDraftValues:function(t,i){return this.$elmt.addClass("ditty-editor--updates-exist"),t?(this.draftValues[t]=i,"development"===dittyVars.mode&&window.console&&console.log("draftValues:",this.draftValues),this.draftValues[t]):(this.draftValues=i,"development"===dittyVars.mode&&window.console&&console.log("draftValues:",this.draftValues),this.draftValues)},getDraftValues:function(t){return t?!!this.draftValues[t]&&this.draftValues[t]:this.draftValues},delayedSubmitEnable:function(){this.delayedSubmit=!0},delayedSubmitDisable:function(){this.delayedSubmit=!1},trigger:function(t,i){var e=[];switch(t){case"active_items_update":e=[this.ditty,this.activeItems];break;case"stop_live_updates":e=[this.dittyId];break;default:e=[this.settings]}i&&(e=i),this.$elmt.trigger("ditty_editor_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e),$("body").trigger("ditty_"+t,e)},_getPanelOption:function(t){return"elmnt"===t?this.$panels:this.settings[t]},_setPanelOption:function(t,i){if(void 0===i)return!1;this.$panels.ditty_slider("options",t,i),this.trigger("update")},panelOptions:function(t,i){var e=this;if("object"==typeof t)$.each(t,(function(t,i){e._setPanelOption(t,i)}));else{if("string"!=typeof t)return e.$panels.ditty_slider("options");if(void 0===i)return e._getPanelOption(t);e._setPanelOption(t,i)}},_getOption:function(t){return"elmnt"===t?this:this.settings[t]},_setOption:function(t,i){if(void 0===i)return!1;this.settings[t]=i,this.trigger("update")},options:function(t,i){var e=this;if("object"==typeof t)$.each(t,(function(t,i){e._setOption(t,i)}));else{if("string"!=typeof t)return e.settings;if(void 0===i)return e._getOption(t);e._setOption(t,i)}},destroy:function(){this.$panels.ditty_slider&&this.$panels.ditty_slider("destroy"),$(document).off("postbox-moved",{self:this},this._postboxMoved),$(document).off("postboxes-columnchange",{self:this},this._postboxMoved),$(window).off("beforeunload",{self:this},this._beforeunload),this.ditty.$elmt.off("ditty_active_items_update",{self:this},this._dittyItemsUpdated),this.ditty.$elmt.off("ditty_disabled_items_update",{self:this},this._disabledItemsUpdate),this.$tabs.off("click","ditty-editor__tab",{self:this},this._showPanel),this.$update.off("click",{self:this},this._saveClick),this.$panels.off("ditty_slider_init",{self:this},this._editorLoaded),this.$panels.off("ditty_slider_before_slide_update",{self:this},this._beforeSlideUpdate),this.$panels.off("ditty_slider_after_slide_update",{self:this},this._afterSlideUpdate),this.$panels.off("ditty_slider_slide_removed",{self:this},this._slideRemoved),this.trigger("destroy"),this.elmt._ditty_editor=null}},$.fn.ditty_editor=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_editor||(this._ditty_editor=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_editor;if(!i)throw new Error("No Ditty_Editor applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Editor.');return void 0!==e?e:this}},$.ditty_editor={},$.ditty_editor.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_settings_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$title=this.$elmt.find('input[name="title]'),this.$previewBg=this.$elmt.find('input[name="previewBg"]'),this.$previewPaddingTop=this.$elmt.find('input[name="previewPadding[paddingTop]"]'),this.$previewPaddingBottom=this.$elmt.find('input[name="previewPadding[paddingBottom]"]'),this.$previewPaddingLeft=this.$elmt.find('input[name="previewPadding[paddingLeft]"]'),this.$previewPaddingRight=this.$elmt.find('input[name="previewPadding[paddingRight]"]'),this.$postTitle=$(".ditty-post__title"),this.$editorPreview=$("#ditty-editor__preview"),this.dittyId=this.$form.data("ditty_id"),this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this.settings.editor.initFields(this.$elmt),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.on("submit",{self:this},this._submitForm),this.$form.on("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.on("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.on("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.on("keyup change",'input[name="title"]',{self:this},this._titleChange),this.$form.on("keyup change",".ditty-field--preview_settings *",{self:this},this._previewBgChange),this.$elmt.addClass("init")},_checkUpdates:function(t){var i=t?t.data.self:this;i.$form.serialize()!==i.initData?(i.settings.editor.addUpdate("settings",i.itemId),i.settings.editor.delayedSubmitEnable()):i.settings.editor.removeUpdate("settings",i.itemId)},_titleChange:function(t){var i=t?t.data.self:this,e=$(t.target).val();i.$postTitle.text(e)},_previewBgChange:function(t){var i=t?t.data.self:this,e={backgroundColor:i.$previewBg.val(),paddingTop:i.$previewPaddingTop.val(),paddingBottom:i.$previewPaddingBottom.val(),paddingLeft:i.$previewPaddingLeft.val(),paddingRight:i.$previewPaddingRight.val()};i.$editorPreview.css(e)},_addDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.dittyId;i.settings.editor.updateStart();var s={action:"ditty_editor_settings_update",ditty_id:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:s,success:function(t){i.initData=i.$form.serialize(),dittyDraftUpdate(i,"settings",!1,t),i.settings.editor.delayedSubmitDisable(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty({return_items:0}),i.afterUpdateAction=""}})},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_settings_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_settings_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.$form.off("submit",{self:this},this._submitForm),this.$form.off("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.off("keyup change",'input[name="previewBg"]',{self:this},this._previewBg_cahnge),this.$form.off("keyup change",'input[name="title"]',{self:this},this._titleChange),this.$form.off("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.off("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.trigger("destroy"),this.elmt._ditty_settings_panel=null}},$.fn.ditty_settings_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_settings_panel||(this._ditty_settings_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_settings_panel;if(!i)throw new Error("No Ditty_Settings_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Settings_Panel.');return void 0!==e?e:this}},$.ditty_settings_panel={},$.ditty_settings_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_items_panel.defaults,e),this.$elmt=$(i),this.$add=$(i).find(".ditty-editor-options__add"),this.$contents=$(i).find(".ditty-editor__panel__contents"),this.$list=$(i).find(".ditty-data-list"),this.$listItems=$(i).find(".ditty-data-list__items"),this.isEmptyTicker=!1,this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.settings.editor.$elmt.on("ditty_editor_active_items_update",{self:this},this._dittyActiveItemsUpdated),this.$add.on("click",{self:this},this._add_item),this.$elmt.on("click",".ditty-data-list__item",{self:this},this._showItem),this.$elmt.on("click",".ditty-data-list__item__icon",{self:this},this._editType),this.$elmt.on("click",".ditty-data-list__item__edit",{self:this},this._editItem),this.$elmt.on("click",".ditty-data-list__item__layout",{self:this},this._editLayoutVariations),this.$elmt.on("click",".ditty-data-list__item__clone",{self:this},this._cloneItem),this.$elmt.on("click",".ditty-data-list__item__delete",{self:this},this._deleteItem),this.$list.on("click",".ditty-editor-item > a",{self:this},this._actionClick),$("body").on("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),1>this.$elmt.find(".ditty-data-list__item").length&&(this.isEmptyTicker=!0,this.$add.trigger("click")),this._initializeSorting(),this._highlightListItems(this.settings.editor.activeItems)},dittyUpdateSavedDraftLayouts:function(t,i){$.each($(".ditty-editor-item"),(function(){var e=$(this).data("layout_value");$.each(e,(function(s,a){String(a)===String(t)&&(e[s]=String(i))})),$(this).attr("data-layout_value",e).data("layout_value",e)}))},_dittyEditorSaveResponse:function(t,i){var e=t.data.self;i.ditty_new_item_ids&&$.each(i.ditty_new_item_ids,(function(t,i){var e=$("#ditty-editor-item--"+t);e.length&&(e.attr("id","ditty-editor-item--"+i),e.attr("data-item_id",i).data("item_id",i))})),i.ditty_new_layout_ids&&$.each(i.ditty_new_layout_ids,(function(t,i){e.dittyUpdateSavedDraftLayouts(t,i)}))},_highlightListItem:function(t){var i=t.id+"";i=i.split("_"),this.$elmt.find("#ditty-editor-item--"+i[0]).addClass("active")},_highlightListItems:function(t){this.$elmt.find(".ditty-data-list__item").removeClass("active");var i=this;Array.isArray(t)?$.each(t,(function(t,e){i._highlightListItem(e)})):i._highlightListItem(t)},_dittyActiveItemsUpdated:function(t,i,e){t.data.self._highlightListItems(e)},_initializeSorting:function(){var t=this;this.$listItems.sortable({handle:".ditty-data-list__item__move",items:".ditty-data-list__item",axis:"y",start:function(t,i){$(i.item).addClass("ditty-data-list__item--moving")},stop:function(i,e){$(e.item).removeClass("ditty-data-list__item--moving"),t.settings.editor.addUpdate("item_order",t.settings.editor.dittyId)},update:function(){t._updateItemIndexes("updateDitty")}})},_showItem:function(t){t.preventDefault();var i=t.data.self;if(!$(t.target).is("a")&&!$(t.target).parent().is("a")){var e=($(t.target).is(".ditty-data-list__item")?$(t.target):$(t.target).parents(".ditty-data-list__item")).data("item_id");i.settings.editor.ditty.showItem(e)}},_actionClick:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("a")?$(t.target):$(t.target).parent("a"),s=e.parents(".ditty-data-list__item"),a=s.data("ditty_id"),d=s.data("item_id");dittyVars.editor.currentItem=s,$("body").trigger("ditty_editor_item_action_click",[e,s,d,a,i.settings.editor])},_editType:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item");e.trigger("click"),e.addClass("editing"),i.settings.editor.updateStart(),i.settings.editor.panelOptions("transition","slideRight"),i.settings.editor.showPanel("item_types")},_editItem:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("item_id");e.trigger("click"),e.addClass("editing"),i.settings.editor.updateStart();var a={action:"ditty_editor_item_fields",item_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--item_editor">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("item_editor",e)}}))},_editLayoutVariations:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("item_type"),a=e.data("layout_value"),d=e.find(".ditty-data-list__item__label").html();e.trigger("click"),e.addClass("editing"),i.settings.editor.updateStart();var r={action:"ditty_editor_layout_variations",ditty_id:i.settings.editor.dittyId,item_type:s,item_label:d,layout_value:a,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,r,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--layout-variations">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("layout_variations",e)}}))},_add_item:function(t){t.preventDefault();var i=t.data.self,e={action:"ditty_editor_item_add",ditty_id:i.settings.editor.dittyId,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,e,(function(t){if(t.display_items){if(i.isEmptyTicker){var e=i.settings.editor.ditty.options("items");$.each(e,(function(t,e){i.settings.editor.ditty.deleteItem(e.id)})),i.isEmptyTicker=!1}$.each(t.display_items,(function(t,e){i.settings.editor.ditty.addItem(e,0)}))}if(t.editor_item){var s=$(t.editor_item);s.hide(),i.$listItems.prepend(s),s.slideDown(),i._updateItemIndexes()}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),t.draft_id&&t.draft_meta&&dittyDraftItemUpdateMeta(i,t.draft_id,null,t.draft_meta)}),"json")},_cloneItem:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("item_id");i.settings.editor.updateStart();var a={action:"ditty_editor_item_clone",item_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t.display_items&&t.display_items.length&&i.settings.editor.ditty.updateItems(t.display_items,s,"after"),t.editor_item){var a=$(t.editor_item);a.hide(),e.after(a),a.slideDown(),i._updateItemIndexes()}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),t.draft_id&&t.draft_meta&&dittyDraftItemUpdateMeta(i,t.draft_id,null,t.draft_meta),i.settings.editor.updateStop()}),"json")},_deleteItem:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("item_id");1>=i.$elmt.find(".ditty-data-list__item").length&&i.$add.trigger("click"),e.slideUp((function(){$(this).remove()})),i.settings.editor.ditty.deleteItem(s),dittyDraftItemDelete(i,s)},_updateItemIndexes:function(t){var i=this,e=[];if(this.$elmt.find(".ditty-data-list__item").each((function(t){var s=$(this).data("item_id");e.push(s),dittyDraftItemUpdateData(i,s,"item_index",t)})),"updateDitty"===t){var s=dittyItemsReorder(i.settings.editor.ditty.options("items"),e);i.settings.editor.ditty.options("items",s)}},panelVisible:function(){this.$elmt.find(".ditty-data-list__item").removeClass("editing")},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_items_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_items_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.settings.editor.$elmt.off("ditty_editor_active_items_update",{self:this},this._dittyActiveItemsUpdated),this.$add.off("click",{self:this},this._add_item),this.$elmt.off("click",".ditty-data-list__item",{self:this},this._showItem),this.$elmt.off("click",".ditty-data-list__item__icon",{self:this},this._editType),this.$elmt.off("click",".ditty-data-list__item__edit",{self:this},this._editItem),this.$elmt.off("click",".ditty-data-list__item__layout",{self:this
|
2 |
+
},this._editLayoutVariations),this.$elmt.off("click",".ditty-data-list__item__clone",{self:this},this._cloneItem),this.$elmt.off("click",".ditty-data-list__item__delete",{self:this},this._deleteItem),this.$list.off("click",".ditty-editor-item > a",{self:this},this._actionClick),$("body").off("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this.trigger("destroy"),this.elmt._ditty_items_panel=null}},$.fn.ditty_items_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_items_panel||(this._ditty_items_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_items_panel;if(!i)throw new Error("No Ditty_Items_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Items_Panel.');return void 0!==e?e:this}},$.ditty_items_panel={},$.ditty_items_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_item_types_panel.defaults,e),this.$elmt=$(i),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$editorItem=this.settings.editor.$panels.find(".ditty-editor__panel--items").find(".ditty-data-list__item.editing"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.currentType=null,this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.settings.editor.initFields(this.$elmt),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("click",".ditty-editor-item-type",{self:this},this._typeClick),this.panelVisible()},_showItemsList:function(){this.settings.editor.panelOptions("transition","slideLeft"),this.settings.editor.showPanel("items")},_backClick:function(t){t.preventDefault(),t.data.self._showItemsList()},_typeClick:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is(".ditty-editor-item-type")?$(t.target):$(t.target).parents(".ditty-editor-item-type")).data("item_type");if(e===i.currentType)i._showItemsList();else{i.settings.editor.updateStart();var s={action:"ditty_editor_item_type_update",item_id:i.editorItemId,item_type:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,s,(function(t){if(t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,i.editorItemId),t.editor_item){var e=$(t.editor_item);i.$editorItem.after(e),i.$editorItem.remove(),i.$editorItem=e}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),i._showItemsList(),i.settings.editor.updateStop()}),"json")}},panelVisible:function(){this.$editorItem=this.settings.editor.$panels.find(".ditty-editor__panel--items").find(".ditty-data-list__item.editing"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.currentType=this.$editorItem.data("item_type"),this.$elmt.find(".ditty-editor-item-type").removeClass("active"),this.$elmt.find('.ditty-editor-item-type[data-item_type="'+this.currentType+'"]').addClass("active")},panelHidden:function(){var t=this.$editorItem.find(".ditty-data-list__item__icon").children("i");t.attr("class",t.data("class"))},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_item_types_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_item_types_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$back.off("click",{self:this},this._backClick),this.$elmt.off("click",".ditty-editor-item-type",{self:this},this._typeClick),this.trigger("destroy"),this.elmt._ditty_item_types_panel=null}},$.fn.ditty_item_types_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_item_types_panel||(this._ditty_item_types_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_item_types_panel;if(!i)throw new Error("No Ditty_Item_Types_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Item_Types_Panel.');return void 0!==e?e:this}},$.ditty_item_types_panel={},$.ditty_item_types_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_item_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$preview=this.$elmt.find(".ditty-editor-options__preview"),this.$title=this.$elmt.find(".ditty-editor-options__title"),this.itemId=this.$form.data("item_id"),this.itemType=this.$form.data("item_type"),this.dittyId=this.$form.data("ditty_id"),this.$editorItem=this.settings.editor.$panels.find(".ditty-editor__panel--items").find(".ditty-data-list__item.editing"),this.$editorItemTitle=this.$editorItem.find(".ditty-data-list__item__label"),this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){var t=this;this.initData=this.$form.serialize(),this.settings.editor.initFields(this.$elmt),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.on("submit",{self:this},this._submitForm),this.$back.on("click",{self:this},this._backClick),this.$preview.on("click",{self:this},this._previewClick),this.$form.on("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.on("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.on("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.on("ditty_field_update",".ditty-field__input",{self:this},this._checkUpdates),setTimeout((function(){t.trigger("init",[t])}),1)},_showItemList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","items")},_enablePreviewButton:function(){this.$preview.addClass("ditty-has-updates")},_disablePreviewButton:function(){this.$preview.removeClass("ditty-has-updates"),this.$preview.children("i").attr("class",this.$preview.children("i").data("class"))},_checkUpdates:function(t){var i=t?t.data.self:this;i.$form.serialize()!==i.initData?(i._enablePreviewButton(),i.settings.editor.addUpdate("item_settings",i.itemId),i.settings.editor.delayedSubmitEnable()):(i._disablePreviewButton(),i.settings.editor.removeUpdate("item_settings",i.itemId))},_addDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.$form.serialize()===i.initData?i._showItemList():(i.afterUpdateAction="return",i.$form.trigger("submit"))},_previewClick:function(t){t.preventDefault();var i=t.data.self;i.$form.serialize()!==i.initData&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit"))},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.itemId;i.settings.editor.updateStart();var s={action:"ditty_editor_item_update",item_id:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:s,error:function(){},success:function(t){if(t.value_updates&&i._updateValues(t.value_updates),i.initData=i.$form.serialize(),i._disablePreviewButton(),t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,e),t.editor_item){var s=$(t.editor_item).children(".ditty-data-list__item__label").text();i.$title.html(s),i.$editorItemTitle.html(s)}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),t.draft_id&&t.draft_meta&&dittyDraftItemUpdateMeta(i,t.draft_id,null,t.draft_meta),i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showItemList(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty({return_items:0}),i.afterUpdateAction=""}})},_updateValues:function(t){var i=this;$.each(t,(function(t,e){var s=i.$form.find('[name="'+t+'"]');s.length&&s.val(e)}))},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_item_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_item_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._saveDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.off("submit",{self:this},this._submitForm),this.$back.off("click",{self:this},this._backClick),this.$preview.off("click",{self:this},this._previewClick),this.$form.off("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.off("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.off("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.off("ditty_field_update",".ditty-field__input",{self:this},this._checkUpdates),this.elmt._ditty_item_editor_panel=null}},$.fn.ditty_item_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_item_editor_panel||(this._ditty_item_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_item_editor_panel;if(!i)throw new Error("No Ditty_Item_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Item_Editor_Panel.');return void 0!==e?e:this}},$.ditty_item_editor_panel={},$.ditty_item_editor_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_displays_panel.defaults,e),this.$elmt=$(i),this.$list=$(i).find(".ditty-data-list__items"),this.$contents=$(i).find(".ditty-editor__panel__contents"),this.initDisplay=null,this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.$elmt.ditty_ui_data_list({filter:".ditty-display-panel__filter",item:".ditty-editor-display",itemSelector:"display_type"}),this.initDisplay=this.$list.data("active"),this._activateDisplay(this.$list.find("#ditty-editor-display--"+this.initDisplay)),this.$elmt.on("click",".ditty-data-list__item",{self:this},this._selectDisplay),this.$elmt.on("click",".ditty-data-list__item__edit",{self:this},this._editDisplay),this.$elmt.on("click",".ditty-data-list__item__clone",{self:this},this._cloneDisplay),this.$elmt.on("click",".ditty-data-list__item__delete",{self:this},this._deleteDisplay),this.settings.editor.$elmt.on("ditty_editor_saveDrafts",{self:this},this._saveDrafts)},_saveDrafts:function(t){var i=t.data.self;i.initDisplay=i.$list.find(".ditty-editor-display.active").data("display_id")},_activateDisplay:function(t){this.$list.find(".ditty-editor-display").removeClass("active"),t.addClass("active")},_initDitty:function(t,i,e){var s=this.settings.editor.ditty.$elmt;e.display=i,e.id=this.settings.editor.ditty.options("id"),e.items=this.settings.editor.ditty.options("items"),e.height=this.settings.editor.ditty.options("height"),this.settings.editor.ditty.destroy(),s["ditty_"+t](e),this.settings.editor.ditty=s["ditty_"+t]("options","ditty")},_selectDisplay:function(t){t.preventDefault();var i=t.data.self;if($(t.target).parent().is("a"))return!1;var e=$(t.target).is(".ditty-data-list__item")?$(t.target):$(t.target).parents(".ditty-data-list__item"),s=e.data("display_id"),a=e.data("display_type");if(e.hasClass("active"))return!1;i.settings.editor.updateStart(),dittyDraftUpdate(i,"post_meta","_ditty_display",s),i._activateDisplay(e);var d={action:"ditty_editor_select_display",display_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,d,(function(t){if(!t)return!1;i._initDitty(a,s,t),i.settings.editor.updateStop()}),"json")},_cloneDisplay:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("display_id");i.settings.editor.updateStart();var a={action:"ditty_editor_display_clone",display_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t.editor_display){var s=$(t.editor_display);s.hide(),e.after(s),s.slideDown()}t.draft_id&&t.draft_data&&dittyDraftDisplayUpdate(i,t.draft_id,null,t.draft_data),i.settings.editor.updateStop()}),"json")},_deleteDisplay:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=null,a=e.data("display_id");e.hasClass("active")&&(e.prev().length?s=e.prev():e.next().length&&(s=e.next())),e.slideUp((function(){$(this).remove()})),dittyDraftDisplayDelete(i,a),null!==s&&s.trigger("click")},_editDisplay:function(t){t.preventDefault();var i=t.data.self;i.$displayEdit=$(this).parents(".ditty-data-list__item");var e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("display_id");i.settings.editor.updateStart(),e.addClass("editing");var a={action:"ditty_editor_display_fields",display_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--displayEditor">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("display_editor",e)}}))},panelVisible:function(){this.$elmt.find(".ditty-data-list__item").removeClass("editing")},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_displays_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_displays_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$elmt.ditty_ui_data_list("destroy"),this.$elmt.off("click",".ditty-data-list__item",{self:this},this._selectDisplay),this.$elmt.off("click",".ditty-data-list__item__edit",{self:this},this._editDisplay),this.$elmt.off("click",".ditty-data-list__item__clone",{self:this},this._cloneDisplay),this.$elmt.off("click",".ditty-data-list__item__delete",{self:this},this._deleteDisplay),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.trigger("destroy"),this.elmt._ditty_displays_panel=null}},$.fn.ditty_displays_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_displays_panel||(this._ditty_displays_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_displays_panel;if(!i)throw new Error("No Ditty_Displays_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Displays_Panel.');return void 0!==e?e:this}},$.ditty_displays_panel={},$.ditty_displays_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_display_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$optionsTitle=this.$elmt.find(".ditty-editor-options__title"),this.$importExportField=this.$elmt.find(".ditty-editor__import-export__field"),this.$importExportUpdate=this.$elmt.find(".ditty-editor__import-export__update"),this.displayTitle=null,this.displayId=this.settings.editor.ditty.options("display"),this.displayType=this.settings.editor.ditty.options("type"),this.$editorDisplay=this.settings.editor.$panels.find(".ditty-editor__panel--displays").find(".ditty-data-list__item.editing"),this.$editorDisplayTitle=this.$editorDisplay.find(".ditty-data-list__item__label"),this.displayOptions=null,this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){var t,i=this;this.initData=this.$form.serialize(),this.settings.editor.initFields(this.$elmt),t=this.settings.editor.ditty.$elmt["ditty_"+this.displayType]("options"),this.displayOptions=$.extend({},t),this.displayTitle=this.$optionsTitle.val(),this.$importExportUpdate.on("click",{self:this},this._importUpdate),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.on("submit",{self:this},this._submitForm),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("change",'input[type="text"], input[type="number"]',{self:this},this._textfieldListeners),this.$form.on("click",'input[type="radio"]',{self:this},this._radioListeners),this.$form.on("click",'input[type="checkbox"]',{self:this},this._checkboxListeners),this.$form.on("change","select",{self:this},this._selectListeners),this.$form.on("ditty_field_clone_update",{self:this},this._cloneListeners),setTimeout((function(){i.trigger("init",[i])}),1)},_showDisplayList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","displays")},_checkUpdates:function(){this.$form.serialize()!==this.initData?(this.settings.editor.addUpdate("displaySettings",this.displayId),this.settings.editor.delayedSubmitEnable()):this.settings.editor.removeUpdate("displaySettings",this.displayId)},_addDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.$form.serialize()===i.initData?i._showDisplayList():(i.afterUpdateAction="return",i.$form.trigger("submit"))},_submitForm:function(t){t.preventDefault();var i=t.data.self;i.settings.editor.updateStart();var e={action:"ditty_editor_display_update",display_id:i.displayId,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:e,success:function(t){i.initData=i.$form.serialize(),t.draft_id&&t.draft_label&&(i.displayTitle=t.draft_label,i.$editorDisplayTitle.text(t.draft_label),dittyDraftDisplayUpdate(i,t.draft_id,"label",t.draft_label)),t.draft_id&&t.draft_settings&&(i.displayOptions=t.draft_settings,dittyDraftDisplayUpdate(i,t.draft_id,"settings",t.draft_settings)),t.draft_settings_json&&i.$importExportField.length&&i.$importExportField.val(t.draft_settings_json),i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showDisplayList(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty(),i.afterUpdateAction=""}})},_importUpdate:function(t){t.preventDefault()},_cloneListeners:function(t,i,e){var s=t.data.self;$(t.target);s.settings.editor.ditty.options(e,i)},_textfieldListeners:function(t){var i=t.data.self,e=$(t.target),s=e.attr("name"),a=e.parents(".ditty-input--spacing__group, .ditty-input--radius__group");if(a.length){var d="",r={};a.find("input").each((function(){s=$(this).attr("name"),d=(d=s.split("["))[0];var t=s.match(/\[(.*)\]/);r[t[1]]=$(this).val()})),i.settings.editor.ditty.options(d,r)}else i.settings.editor.ditty.options(s,e.val());i._checkUpdates()},_radioListeners:function(t){var i=t.data.self,e=$(t.target),s=e.val(),a=e.attr("name");i.settings.editor.ditty.options(a,s),i._checkUpdates()},_checkboxListeners:function(t){var i=t.data.self,e=$(t.target),s=!!e.is(":checked")&&$(this).val(),a=e.attr("name");i.settings.editor.ditty.options(a,s),i._checkUpdates()},_selectListeners:function(t){var i=t.data.self,e=$(t.target),s=e.val(),a=e.attr("name");i.settings.editor.ditty.options(a,s),i._checkUpdates()},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_display_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_display_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.trigger("destroy",[this]),this.$importExportUpdate.off("click",{this:this},this._importUpdate),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.off("submit",{this:this},this._submitForm),this.$back.off("click",{this:this},this._cancel_click),this.$elmt.off("change",'input[type="text"], input[type="number"]',{self:this},this._textfieldListeners),this.$form.off("click",'input[type="radio"]',{self:this},this._radioListeners),this.$form.off("click",'input[type="checkbox"]',{self:this},this._checkboxListeners),this.$form.off("change","select",{self:this},this._selectListeners),this.$form.off("ditty_field_clone_update",{self:this},this._cloneListeners),this.elmt._ditty_display_editor_panel=null}},$.fn.ditty_display_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_display_editor_panel||(this._ditty_display_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_display_editor_panel;if(!i)throw new Error("No Ditty_Display_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Display_Editor_Panel.');return void 0!==e?e:this}},$.ditty_display_editor_panel={},$.ditty_display_editor_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layout_variations_panel.defaults,e),this.$elmt=$(i),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$list=$(i).find(".ditty-data-list__items"),this.$editorItem=dittyVars.editor.currentItem,this.editorItemLabel=this.$editorItem.find(".ditty-data-list__item__label").text(),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.editorItemType=this.$editorItem.data("item_type"),this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("click",".ditty-layout-variation__change",{self:this},this._changeTemplate),this.$elmt.on("click",".ditty-layout-variation__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.on("click",".ditty-layout-variation__edit_css",{self:this,editType:"css"},this._editLayout),$("body").on("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse)},_showItemList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","items")},_backClick:function(t){t.preventDefault(),t.data.self._showItemList()},_dittyEditorSaveResponse:function(t,i){t.data.self;i.ditty_new_layout_ids&&$.each(i.ditty_new_layout_ids,(function(t,i){var e=$('.ditty-layout-variation[data-layout_id="'+t+'"]');e.length&&e.attr("data-layout_id",i).data("layout_id",i)}))},_changeTemplate:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("layout_id"),a=e.data("layout_variation_id"),d=e.data("layout_variation_label");dittyVars.editor.currentLayoutVariation=e,i.settings.editor.updateStart(),e.addClass("editing");var r={action:"ditty_editor_layouts",ditty_id:i.editorDittyId,item_type:i.editorItemType,variation_id:a,variation_label:d,layout_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,r,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--layouts">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("layouts",e)}}))},_editLayout:function(t){t.preventDefault();var i=t.data.self,e=t.data.editType,s=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),a=s.data("layout_id"),d=s.data("item_type");dittyVars.editor.currentLayoutVariation=s,i.settings.editor.updateStart(),i.$list.find(".ditty-data-list__item").removeClass("editing"),s.addClass("editing");var r=[],o=i.settings.editor.ditty.options("items");$.each(o,(function(t,i){r.push(i.uniqId)}));var n={action:"ditty_editor_layout_fields",layout_id:a,item_type:d,item_value:i.$editorItem.data("item_value"),ditty_id:i.editorDittyId,item_id:i.editorItemId,item_ids:r,edit_type:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,n,(function(t){if(t){var s="layout_"+e+"_editor",a='<div class="ditty-editor__panel ditty-editor__panel--'+s+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel(s,a)}}),"json")},panelVisible:function(){this.$list.find(".ditty-layout-variation").removeClass("editing")},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layout_variations_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layout_variations_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$back.off("click",{self:this},this._backClick),this.$elmt.off("click",".ditty-layout-variation__change",{self:this},this._changeTemplate),this.$elmt.off("click",".ditty-layout-variation__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.off("click",".ditty-layout-variation__edit_css",{self:this,editType:"css"},this._editLayout),$("body").off("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this.elmt._ditty_layout_variations_panel=null}},$.fn.ditty_layout_variations_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layout_variations_panel||(this._ditty_layout_variations_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layout_variations_panel;if(!i)throw new Error("No Ditty_Layout_Variations_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layout_Variations_Panel.');return void 0!==e?e:this}},$.ditty_layout_variations_panel={},$.ditty_layout_variations_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layouts_panel.defaults,e),this.$elmt=$(i),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$list=$(i).find(".ditty-data-list__items"),this.$editorItem=dittyVars.editor.currentItem,this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.editorItemtype=this.$editorItem.data("item_type"),this.$editorVariation=dittyVars.editor.currentLayoutVariation,this.editorVariationId=this.$editorVariation.data("layout_variation_id"),this.editorLayoutId=this.$editorVariation.data("layout_id"),this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("click",".ditty-data-list__item",{self:this},this._selectLayout),this.$elmt.on("click",".ditty-data-list__item__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.on("click",".ditty-data-list__item__edit_css",{self:this,editType:"css"},this._editLayout),this.$elmt.on("click",".ditty-data-list__item__clone",{self:this},this._cloneLayout),this.$elmt.on("click",".ditty-data-list__item__delete",{self:this},this._deleteLayout),this.$list.on("click",".ditty-editor-layout > a",{self:this},this._actionClick),$("body").on("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this._activateLayout(this.$list.find("#ditty-editor-layout--"+this.editorLayoutId))},_activateLayout:function(t){this.$list.find(".ditty-editor-layout").removeClass("active"),t.addClass("active")},_showVariationsList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","layout_variations")},_backClick:function(t){t.preventDefault(),t.data.self._showVariationsList()},_dittyEditorSaveResponse:function(t,i){t.data.self;i.ditty_new_layout_ids&&$.each(i.ditty_new_layout_ids,(function(t,i){var e=$("#ditty-editor-layout--"+t);e.length&&(e.attr("id","ditty-editor-layout--"+i),e.attr("data-layout_id",i).data("layout_id",i))}))},_selectLayout:function(t){t.preventDefault();var i=t.data.self;if($(t.target).parent().is("a"))return!1;var e=$(t.target).is(".ditty-data-list__item")?$(t.target):$(t.target).parents(".ditty-data-list__item"),s=e.data("layout_id"),a=e.data("layout_version"),d=i.$editorItem.data("layout_value");if(e.hasClass("active"))return!1;$.each(d,(function(t){i.editorVariationId===t&&(d[t]=String(s))})),i.settings.editor.updateStart(),dittyDraftItemUpdateData(i,i.editorItemId,"layout_value",d),i._activateLayout(e);var r={action:"ditty_editor_select_layout",layout_id:s,item_id:i.editorItemId,ditty_id:i.editorDittyId,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,r,(function(t){if(i.settings.editor.updateStop(),t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,i.editorItemId),t.editor_item){var e=$(t.editor_item);i.$editorItem.replaceWith(e)}i.$editorItem.attr("data-layout_value",d).data("layout_value",d),i.$editorVariation.attr("data-layout_id",s).data("layout_id",s),i.$editorVariation.find(".ditty-layout-variation__template > span").text(t.layout_label),a?i.$editorVariation.find(".ditty-layout-variation__template > small").text("("+a+")"):i.$editorVariation.find(".ditty-layout-variation__template > small").text("")}),"json")},_cloneLayout:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("layout_id");i.settings.editor.updateStart();var a={action:"ditty_editor_layout_clone",layout_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t.editor_layout){var s=$(t.editor_layout)
|
3 |
+
;s.hide(),e.after(s),s.slideDown()}t.draft_id&&t.draft_meta&&dittyDraftLayoutUpdate(i,t.draft_id,null,t.draft_meta),i.settings.editor.updateStop()}),"json")},_deleteLayout:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=null,a=e.data("layout_id");e.hasClass("active")&&(e.prev().length?s=e.prev():e.next().length&&(s=e.next())),e.slideUp((function(){$(this).remove()})),dittyDraftLayoutDelete(i,a),null!==s&&s.trigger("click")},_editLayout:function(t){t.preventDefault();var i=t.data.self,e=t.data.editType,s=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),a=s.data("layout_id");i.settings.editor.updateStart(),i.$list.find(".ditty-data-list__item").removeClass("editing"),s.addClass("editing");var d={action:"ditty_editor_layout_fields",layout_id:a,item_id:i.editorItemId,edit_type:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,d,(function(t){if(t){var s="layout_"+e+"_editor",a='<div class="ditty-editor__panel ditty-editor__panel--'+s+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel(s,a)}}),"json")},_actionClick:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("a")?$(t.target):$(t.target).parent("a"),s=e.parents(".ditty-data-list__item"),a=s.data("layout_id");dittyVars.editor.currentLayout=s,$("body").trigger("ditty_editor_layout_action_click",[e,s,a,i.editorDittyId,i.settings.editor])},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layouts_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layouts_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$back.off("click",{self:this},this._backClick),this.$elmt.off("click",".ditty-data-list__item",{self:this},this._selectLayout),this.$elmt.off("click",".ditty-data-list__item__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.off("click",".ditty-data-list__item__edit_css",{self:this,editType:"css"},this._editLayout),this.$elmt.off("click",".ditty-data-list__item__clone",{self:this},this._cloneLayout),this.$elmt.off("click",".ditty-data-list__item__delete",{self:this},this._deleteLayout),this.$list.off("click",".ditty-editor-layout > a",{self:this},this._actionClick),$("body").off("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this.elmt._ditty_layouts_panel=null}},$.fn.ditty_layouts_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layouts_panel||(this._ditty_layouts_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layouts_panel;if(!i)throw new Error("No Ditty_Layouts_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layouts_Panel.');return void 0!==e?e:this}},$.ditty_layouts_panel={},$.ditty_layouts_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null,prevPanel:""},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layout_html_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$textarea=this.$elmt.find(".ditty-editor-options__code"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$preview=this.$elmt.find(".ditty-editor-options__preview"),this.$editCss=this.$elmt.find(".ditty-editor-options__edit-css"),this.$title=this.$elmt.find(".ditty-editor-options__title"),this.$tags=this.$elmt.find(".ditty-editor-options__tags"),this.itemType=this.$form.data("item_type"),this.layoutId=this.$form.data("layout_id"),this.$editorItem=dittyVars.editor.currentItem,this.$editorLayout=dittyVars.editor.currentLayout,this.$editorLayoutTitle=!!this.$editorLayout&&this.$editorLayout.find(".ditty-data-list__item__label"),this.$editorLayoutVariation=dittyVars.editor.currentLayoutVariation,this.$editorLayoutVariationTitle=this.$editorLayoutVariation.find(".ditty-layout-variation__template span"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.codeEditor=null,this.codeHasUpdates=!1,this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this._initEditor(),this.$back.on("click",{self:this},this._backClick),this.$preview.on("click",{self:this},this._previewClick),this.$editCss.on("click",{self:this},this._editCss),this.$form.on("submit",{self:this},this._submitForm),this.$form.on("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.on("keyup",{self:this},this._titleUpdate),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts)},_showPrevPanel:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById",this.settings.prevPanel)},_titleUpdate:function(t){var i=t.data.self;i.settings.editor.addUpdate("layoutUpdate",i.layoutId)},_enablePreviewButton:function(){this.$preview.addClass("ditty-has-updates")},_disablePreviewButton:function(){this.$preview.removeClass("ditty-has-updates"),this.$preview.children("i").attr("class",this.$preview.children("i").data("class"))},_getLayoutItems:function(){var t=this.settings.editor.ditty.options("items"),i=[];return $.each(t,(function(t,e){String(e.layoutId)===String(this.layoutId)&&i.push(e.id)})),i},_addDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),i.$form.serialize()!==i.initData||i.codeHasUpdates?(i.afterUpdateAction="return",i.$form.trigger("submit")):i._showPrevPanel()},_previewClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit"))},_editCss:function(t){t.preventDefault();var i=t.data.self,e="layout_css_editor";if(i.settings.editor.updateStart(),i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit")),i.settings.editor.panelExists(e))i.settings.editor.$elmt.find(".ditty-editor__panel--layout_css_editor input.ditty-editor-options__title").val(i.$title.val()),i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e);else{var s={action:"ditty_editor_layout_fields",layout_id:i.layoutId,layout_title:i.$title.val(),ditty_id:i.editorDittyId,item_id:i.editorItemId,item_type:i.itemType,edit_type:"css",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,s,(function(t){if(t){var s='<div class="ditty-editor__panel ditty-editor__panel--'+e+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e,s)}}),"json")}},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.layoutId,s=i.itemType,a=i._getLayoutItems();if(i.$form.hasClass("ditty-editor-has-errors"))return!1;i.codeEditor.codemirror.save(),i.settings.editor.updateStart();var d={action:"ditty_editor_layout_update",layout_id:e,item_type:s,item_ids:a,edit_type:"html",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:d,success:function(t){i.initData=i.$form.serialize(),i._disablePreviewButton(),t.label&&(i.$editorLayoutTitle&&i.$editorLayoutTitle.html(t.label),i.$editorLayoutVariationTitle.html(t.label)),i.$editorLayoutTitle&&i.$editorLayoutTitle.find(".ditty-layout-version").remove(),i.$editorLayoutVariationTitle&&i.$editorLayoutVariationTitle.find(".ditty-layout-version").remove(),t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,!1,!1,!0),t.draft_id&&t.draft_meta&&dittyDraftLayoutUpdate(i,t.draft_id,null,t.draft_meta),i.codeHasUpdates=!1,i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showPrevPanel(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty({return_items:0}),i.afterUpdateAction=""}})},_initEditor:function(){var t=this,i=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{};i.codemirror=_.extend({},i.codemirror,{indentUnit:2,tabSize:2}),this.codeEditor=wp.codeEditor.initialize(this.$textarea[0],i),this.codeEditor.codemirror.on("change",(function(){t.codeEditor.codemirror.save(),t.settings.editor.addUpdate("layout_html_update",t.layoutId),t.codeHasUpdates=!0,t._enablePreviewButton(),t.settings.editor.delayedSubmitEnable()}))},_insertTag:function(t){var i=t.data.self,e=$(t.target),s=e.text(),a=e.data("atts"),d=i.codeEditor.codemirror.getCursor();if(t.shiftKey&&a){var r="",o=s.length-1;$.each(a,(function(t,i){r+=" "+t+'="'+i.toString()+'"'})),s=s.substring(0,o)+r+s.substring(o)}i.codeEditor.codemirror.replaceRange(s,d),d.ch=d.ch+s.length,i.codeEditor.codemirror.setCursor(d)},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layout_html_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layout_html_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$back.off("click",{self:this},this._backClick),this.$preview.off("click",{self:this},this._previewClick),this.$editCss.off("click",{self:this},this._editCss),this.$form.off("submit",{self:this},this._submitForm),this.$form.off("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.off("keyup",{self:this},this._titleUpdate),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.codeEditor.codemirror.off("change"),this.codeEditor.codemirror.toTextArea(),this.elmt._ditty_layout_html_editor_panel=null}},$.fn.ditty_layout_html_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layout_html_editor_panel||(this._ditty_layout_html_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layout_html_editor_panel;if(!i)throw new Error("No Ditty_Layout_Html_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layout_Html_Editor_Panel.');return void 0!==e?e:this}},$.ditty_layout_html_editor_panel={},$.ditty_layout_html_editor_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null,prevPanel:""},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layout_css_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$textarea=this.$elmt.find(".ditty-editor-options__code"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$preview=this.$elmt.find(".ditty-editor-options__preview"),this.$editHtml=this.$elmt.find(".ditty-editor-options__edit-html"),this.$title=this.$elmt.find(".ditty-editor-options__title"),this.$body=this.$elmt.find(".ditty-editor-options__body"),this.$tags=this.$elmt.find(".ditty-editor-options__tags"),this.itemType=this.$form.data("item_type"),this.layoutId=this.$form.data("layout_id"),this.$editorItem=dittyVars.editor.currentItem,this.$editorLayout=dittyVars.editor.currentLayout,this.$editorLayoutTitle=!!this.$editorLayout&&this.$editorLayout.find(".ditty-data-list__item__label"),this.$editorLayoutVariation=dittyVars.editor.currentLayoutVariation,this.$editorLayoutVariationTitle=this.$editorLayoutVariation.find(".ditty-layout-variation__template span"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.itemSelector="",this.codeEditor=null,this.codeHasUpdates=!1,this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this._setCssSelector(),this._initEditor(),this.$back.on("click",{self:this},this._backClick),this.$preview.on("click",{self:this},this._previewClick),this.$editHtml.on("click",{self:this},this._editHtml),this.$form.on("submit",{self:this},this._submitForm),this.$form.on("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.on("keyup",{self:this},this._titleUpdate),this.$body.on("click",".ditty-editor-options__body__error",{self:this},this._removeErrorNotice),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts)},_setCssSelector:function(){dittyVars.isTickerPost?this.itemSelector="#poststuff .ditty-layout--"+this.layoutId:this.itemSelector=".ditty-layout--"+this.layoutId},_showPrevPanel:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById",this.settings.prevPanel)},_titleUpdate:function(t){var i=t.data.self;i.settings.editor.addUpdate("layoutUpdate",i.layoutId)},_enablePreviewButton:function(){this.$preview.addClass("ditty-has-updates")},_disablePreviewButton:function(){this.$preview.removeClass("ditty-has-updates"),this.$preview.children("i").attr("class",this.$preview.children("i").data("class"))},_addDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),i.$form.serialize()!==i.initData||i.codeHasUpdates?(i.afterUpdateAction="return",i.$form.trigger("submit")):i._showPrevPanel()},_previewClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit"))},_editHtml:function(t){t.preventDefault();var i=t.data.self,e="layout_html_editor";if(i.settings.editor.updateStart(),i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit")),i.settings.editor.panelExists(e))i.settings.editor.$elmt.find(".ditty-editor__panel--layout_html_editor input.ditty-editor-options__title").val(i.$title.val()),i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e);else{var s={action:"ditty_editor_layout_fields",layout_id:i.layoutId,layout_title:i.$title.val(),ditty_id:i.editorDittyId,item_id:i.editorItemId,item_type:i.itemType,edit_type:"html",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,s,(function(t){if(t){var s='<div class="ditty-editor__panel ditty-editor__panel--'+e+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e,s)}}),"json")}},_showErrorNotice:function(){var t=$('<div class="ditty-editor-options__body__error"><span>'+dittyVars.strings.layout_css_error+"</span></div>");this.$body.append(t)},_removeErrorNotice:function(t){t.data.self.$body.find(".ditty-editor-options__body__error").remove()},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.layoutId,s=i.itemType;if(i.$form.hasClass("ditty-editor-has-errors"))return!1;i.codeEditor.codemirror.save(),i.settings.editor.updateStart();var a={action:"ditty_editor_layout_update",layout_id:e,item_type:s,edit_type:"css",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:a,success:function(t){i.initData=i.$form.serialize(),i._disablePreviewButton(),t.label&&(i.$editorLayoutTitle&&i.$editorLayoutTitle.html(t.label),i.$editorLayoutVariationTitle.html(t.label)),i.$editorLayoutTitle&&i.$editorLayoutTitle.find(".ditty-layout-version").remove(),i.$editorLayoutVariationTitle&&i.$editorLayoutVariationTitle.find(".ditty-layout-version").remove(),t.code?dittyLayoutCss(t.code,i.layoutId,"update"):i._showErrorNotice(),t.draft_id&&t.draft_meta&&dittyDraftLayoutUpdate(i,t.draft_id,null,t.draft_meta),i.codeHasUpdates=!1,i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showPrevPanel(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty(),i.afterUpdateAction=""}})},_initEditor:function(){var t=this,i=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{},e=dittyVars.editor.ditty_layouts_sass?"sass":"css";i.codemirror=_.extend({},i.codemirror,{mode:e,indentUnit:2,tabSize:2}),this.codeEditor=wp.codeEditor.initialize(this.$textarea[0],i),this.codeEditor.codemirror.on("change",(function(){t.codeEditor.codemirror.save(),t.settings.editor.addUpdate("layoutCssUpdate",t.layoutId),t.codeHasUpdates=!0,t._enablePreviewButton(),t.settings.editor.delayedSubmitEnable()}))},_insertTag:function(t){var i=t.data.self,e=$(t.target).text(),s=i.codeEditor.codemirror.getCursor();i.codeEditor.codemirror.replaceRange(e,s),s.ch=s.ch+e.length,i.codeEditor.codemirror.setCursor(s)},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layout_css_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layout_css_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$back.off("click",{self:this},this._backClick),this.$preview.off("click",{self:this},this._previewClick),this.$editHtml.off("click",{self:this},this._editHtml),this.$form.off("submit",{self:this},this._submitForm),this.$form.off("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.off("keyup",{self:this},this._titleUpdate),this.$body.off("click",".ditty-editor-options__body__error",{self:this},this._removeErrorNotice),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.codeEditor.codemirror.off("change"),this.codeEditor.codemirror.toTextArea(),this.elmt._ditty_layout_css_editor_panel=null}},$.fn.ditty_layout_css_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layout_css_editor_panel||(this._ditty_layout_css_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layout_css_editor_panel;if(!i)throw new Error("No Ditty_Layout_Css_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layout_Css_Editor_Panel.');return void 0!==e?e:this}},$.ditty_layout_css_editor_panel={},$.ditty_layout_css_editor_panel.defaults=t}(jQuery),jQuery((function($){!function(){"use strict";function t(t,i){0===parseInt(i)?t.hide():t.show()}function i(t,i){"none"===i?t.hide():t.show()}function e(t,i){"none"===i?t.hide():t.show()}$("#ditty-editor").on("ditty_display_editor_panel_init",".ditty-editor__panel--displayEditor",(function(s,a){if("list"===a.displayType){var d=a.$form,r=d.find(".ditty-field--perPage"),o=d.find(".ditty-field--arrows").siblings(),n=d.find(".ditty-field--bullets").siblings();t(r,d.find('input[name="paging"]:checked').val()),d.find('input[name="paging"]').on("change",(function(){t(r,$(this).val())})),i(o,d.find('select[name="arrows"]').val()),d.find('select[name="arrows"]').on("change",(function(){i(o,$(this).val())})),e(n,d.find('select[name="bullets"]').val()),d.find('select[name="bullets"]').on("change",(function(){e(n,$(this).val())}))}}))}()})),jQuery((function($){!function(){"use strict";function t(t,i,e){"down"===e||"up"===e?(t.show(),i.show()):(t.hide(),i.hide())}$("#ditty-editor").on("ditty_display_editor_panel_init",".ditty-editor__panel--displayEditor",(function(i,e){if("ticker"===e.displayType){var s=e.$form,a=s.find(".ditty-field--minHeight"),d=s.find(".ditty-field--maxHeight");t(a,d,s.find('input[name="direction"]:checked').val()),s.find('input[name="direction"]').on("change",(function(){t(a,d,$(this).val())}))}}))}()})),jQuery((function($){!function(){"use strict";function t(t){"full"===t.find('input[name="content_display"]:checked').val()?(t.find(".ditty-field--more_link").hide(),t.find(".ditty-field--excerpt_length").hide(),t.find(".ditty-field--more").hide(),t.find(".ditty-field--more_before").hide(),t.find(".ditty-field--more_after").hide()):(t.find(".ditty-field--more_link").show(),t.find(".ditty-field--excerpt_length").show(),t.find(".ditty-field--more").show(),t.find(".ditty-field--more_before").show(),t.find(".ditty-field--more_after").show())}$("#ditty-editor").on("ditty_item_editor_panel_init",".ditty-editor__panel--item_editor",(function(i,e){if("posts_feed"!==e.itemType&&"post"!==e.itemType)return!1;var s=e.$form;t(s),s.on("click",'input[name="content_display"]',(function(){t(s)}))}))}()}));
|
includes/js/ditty.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
|
4 |
// @codekit-append 'partials/helpers.js';
|
5 |
|
6 |
-
jQuery(
|
7 |
|
8 |
// Setup strict mode
|
9 |
(function() {
|
3 |
|
4 |
// @codekit-append 'partials/helpers.js';
|
5 |
|
6 |
+
jQuery( function( $ ) {
|
7 |
|
8 |
// Setup strict mode
|
9 |
(function() {
|
includes/js/ditty.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function dittyLayoutCss(t,a,e){var i=jQuery("style#ditty-layout--"+a);void 0===i[0]&&(i=jQuery('<style id="ditty-layout--'+a+'"></style>'),jQuery("head").append(i),e="update"),"update"===e&&(t=t.replace(">",">"),i.html(t))}function dittyDisplayCss(t,a){var e=jQuery("style#ditty-display--"+a);void 0===e[0]&&(e=jQuery('<style id="ditty-display--'+a+'"></style>'),jQuery("head").append(e)),t=t.replace(">",">"),e.html(t)}function dittyUpdateItems(t){jQuery.each(t,(function(t,a){var e=a.currentItem,i=a.newItem;e.wrap('<div class="ditty-update-wrapper"></div>');var s=e.parent(),d=i.attr("style");s.stop().css({height:e.outerHeight()}),e.stop().css({position:"absolute",top:0,left:0,width:"100%"}),i.stop().css({position:"absolute",top:0,left:0,width:"100%",opacity:0}),e.after(i),e.stop().animate({opacity:0},375,"linear"),i.stop().animate({opacity:1},375,"linear"),s.stop().animate({height:i.outerHeight()},500,"easeOutQuint",(function(){s.removeAttr("style"),e.unwrap(),e.remove(),d?i.attr("style",d):i.removeAttr("style"),i.hasClass("ditty-temp-item")&&i.remove()}))}))}jQuery(
|
1 |
+
function dittyLayoutCss(t,a,e){var i=jQuery("style#ditty-layout--"+a);void 0===i[0]&&(i=jQuery('<style id="ditty-layout--'+a+'"></style>'),jQuery("head").append(i),e="update"),"update"===e&&(t=t.replace(">",">"),i.html(t))}function dittyDisplayCss(t,a){var e=jQuery("style#ditty-display--"+a);void 0===e[0]&&(e=jQuery('<style id="ditty-display--'+a+'"></style>'),jQuery("head").append(e)),t=t.replace(">",">"),e.html(t)}function dittyUpdateItems(t){jQuery.each(t,(function(t,a){var e=a.currentItem,i=a.newItem;e.wrap('<div class="ditty-update-wrapper"></div>');var s=e.parent(),d=i.attr("style");s.stop().css({height:e.outerHeight()}),e.stop().css({position:"absolute",top:0,left:0,width:"100%"}),i.stop().css({position:"absolute",top:0,left:0,width:"100%",opacity:0}),e.after(i),e.stop().animate({opacity:0},375,"linear"),i.stop().animate({opacity:1},375,"linear"),s.stop().animate({height:i.outerHeight()},500,"easeOutQuint",(function(){s.removeAttr("style"),e.unwrap(),e.remove(),d?i.attr("style",d):i.removeAttr("style"),i.hasClass("ditty-temp-item")&&i.remove()}))}))}jQuery((function($){!function(){"use strict";var t={},a=null;function e(){var a={action:"ditty_live_updates",live_ids:t,security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(a){a.updated_items&&$.each(a.updated_items,(function(a,e){!function(t,a){$('.ditty[data-id="'+t+'"]').each((function(){var t=$(this).data("type");"development"===dittyVars.mode&&window.console&&console.log("LIVE UPDATE"),$(this)["ditty_"+t]("options","items",a)}))}(a,e),t[a].timestamp=Math.floor($.now()/1e3)}))}),"json")}$.each(dittyVars.globals,(function(t,a){var e=$(a.selector);if(a.ditty&&void 0!==e[0]){var i=$('<div class="ditty" data-id="'+a.ditty+'" data-ajax_load="1"></div>');switch(a.display&&""!==a.display&&i.attr("data-display",a.display),a.live_updates&&"1"===String(a.live_updates)&&i.attr("data-live_updates","1"),a.customId&&""!==a.customId&&i.attr("id",a.customId),a.customClasses&&""!==a.customClasses&&i.addClass(a.customClasses),a.position){case"prepend":$(e[0]).prepend(i);break;case"before":$(e[0]).before(i);break;case"after":$(e[0]).after(i);break;default:$(e[0]).append(i)}}})),$(".ditty").each((function(){var a=$(this),e=!!a.data("ajax_load")&&a.data("ajax_load"),i=!!a.data("live_updates")&&a.data("live_updates"),s=!!a.data("display_settings")&&a.data("display_settings"),d=!!a.data("layout_settings")&&a.data("layout_settings"),o=!!a.data("show_editor")&&a.data("show_editor");if(e){var n={action:"ditty_init",id:!!a.data("id")&&a.data("id"),uniqid:!!a.data("uniqid")&&a.data("uniqid"),display:a.data("display")?a.data("display"):"",display_settings:s,layout_settings:d,editor:o,security:dittyVars.security};$.post(dittyVars.ajaxurl,n,(function(e){if(!e.display_type||"function"!=typeof a["ditty_"+e.display_type])return window.console&&console.log("Ditty Display type not loaded:",e.display_type),!1;a["ditty_"+e.display_type](e.args),!o&&i&&(t[a.data("id")]={timestamp:Math.floor($.now()/1e3),layout_settings:d})}),"json")}else!o&&i&&(t[a.data("id")]={timestamp:Math.floor($.now()/1e3),layout_settings:d})})),$(".ditty").length&&dittyVars.updateInterval&&function(){if(null!==a||1>Object.keys(t).length)return!1;cancelAnimationFrame(a);var i=dittyVars.updateInterval?parseInt(dittyVars.updateInterval):60,s=Date.now();a=requestAnimationFrame((function t(){var d=Date.now();Math.floor((d-s)/1e3)>=i&&(s=d,e()),a=requestAnimationFrame(t)}))}()}()}));
|
includes/js/editor/class-ditty-item-editor-panel.js
CHANGED
@@ -38,10 +38,12 @@
|
|
38 |
/**
|
39 |
* Initialize the data list
|
40 |
*
|
41 |
-
* @since 3.0
|
42 |
* @return null
|
43 |
*/
|
44 |
_init: function () {
|
|
|
|
|
45 |
|
46 |
// Save the initial data
|
47 |
this.initData = this.$form.serialize();
|
@@ -59,6 +61,11 @@
|
|
59 |
this.$form.on( 'click', 'input[type="radio"], input[type="checkbox"]', { self: this }, this._checkUpdates );
|
60 |
this.$form.on( 'ditty_input_wysiwyg_update', '.ditty-input--wysiwyg', { self: this }, this._checkUpdates );
|
61 |
this.$form.on( 'ditty_field_update', '.ditty-field__input', { self: this }, this._checkUpdates );
|
|
|
|
|
|
|
|
|
|
|
62 |
},
|
63 |
|
64 |
/**
|
@@ -284,7 +291,6 @@
|
|
284 |
if ( customParams ) {
|
285 |
params = customParams;
|
286 |
}
|
287 |
-
|
288 |
this.$elmt.trigger( 'ditty_item_editor_panel_' + fn, params );
|
289 |
|
290 |
if ( typeof this.settings[fn] === 'function' ) {
|
38 |
/**
|
39 |
* Initialize the data list
|
40 |
*
|
41 |
+
* @since 3.0.12
|
42 |
* @return null
|
43 |
*/
|
44 |
_init: function () {
|
45 |
+
|
46 |
+
var self = this;
|
47 |
|
48 |
// Save the initial data
|
49 |
this.initData = this.$form.serialize();
|
61 |
this.$form.on( 'click', 'input[type="radio"], input[type="checkbox"]', { self: this }, this._checkUpdates );
|
62 |
this.$form.on( 'ditty_input_wysiwyg_update', '.ditty-input--wysiwyg', { self: this }, this._checkUpdates );
|
63 |
this.$form.on( 'ditty_field_update', '.ditty-field__input', { self: this }, this._checkUpdates );
|
64 |
+
|
65 |
+
// Trigger the init
|
66 |
+
setTimeout( function() {
|
67 |
+
self.trigger( 'init', [self] );
|
68 |
+
}, 1 );
|
69 |
},
|
70 |
|
71 |
/**
|
291 |
if ( customParams ) {
|
292 |
params = customParams;
|
293 |
}
|
|
|
294 |
this.$elmt.trigger( 'ditty_item_editor_panel_' + fn, params );
|
295 |
|
296 |
if ( typeof this.settings[fn] === 'function' ) {
|
includes/js/editor/class-ditty-item-types-panel.js
CHANGED
@@ -120,7 +120,7 @@
|
|
120 |
/**
|
121 |
* Do actions when panel is visible
|
122 |
*
|
123 |
-
* @since 3.0
|
124 |
* @return null
|
125 |
*/
|
126 |
panelVisible: function () {
|
@@ -128,9 +128,8 @@
|
|
128 |
this.editorDittyId = this.$editorItem.data( 'ditty_id' );
|
129 |
this.editorItemId = this.$editorItem.data( 'item_id' );
|
130 |
this.currentType = this.$editorItem.data( 'item_type' );
|
131 |
-
|
132 |
this.$elmt.find( '.ditty-editor-item-type' ).removeClass( 'active' );
|
133 |
-
this.$elmt.find( '.ditty-editor-item-type[data-
|
134 |
},
|
135 |
|
136 |
/**
|
120 |
/**
|
121 |
* Do actions when panel is visible
|
122 |
*
|
123 |
+
* @since 3.0.12
|
124 |
* @return null
|
125 |
*/
|
126 |
panelVisible: function () {
|
128 |
this.editorDittyId = this.$editorItem.data( 'ditty_id' );
|
129 |
this.editorItemId = this.$editorItem.data( 'item_id' );
|
130 |
this.currentType = this.$editorItem.data( 'item_type' );
|
|
|
131 |
this.$elmt.find( '.ditty-editor-item-type' ).removeClass( 'active' );
|
132 |
+
this.$elmt.find( '.ditty-editor-item-type[data-item_type="' + this.currentType + '"]' ).addClass( 'active' );
|
133 |
},
|
134 |
|
135 |
/**
|
includes/js/editor/class-ditty-items-panel.js
CHANGED
@@ -31,14 +31,14 @@
|
|
31 |
/**
|
32 |
* Initialize the panel
|
33 |
*
|
34 |
-
* @since 3.0
|
35 |
* @return null
|
36 |
*/
|
37 |
_init: function () {
|
38 |
this.$elmt.addClass( 'init' );
|
39 |
|
40 |
// Add actions
|
41 |
-
this.settings.editor.$elmt.on( '
|
42 |
this.$add.on( 'click', { self: this }, this._add_item );
|
43 |
this.$elmt.on( 'click', '.ditty-data-list__item', { self: this }, this._showItem );
|
44 |
this.$elmt.on( 'click', '.ditty-data-list__item__icon', { self: this }, this._editType );
|
31 |
/**
|
32 |
* Initialize the panel
|
33 |
*
|
34 |
+
* @since 3.0.12
|
35 |
* @return null
|
36 |
*/
|
37 |
_init: function () {
|
38 |
this.$elmt.addClass( 'init' );
|
39 |
|
40 |
// Add actions
|
41 |
+
this.settings.editor.$elmt.on( 'ditty_editor_active_items_update', { self: this }, this._dittyActiveItemsUpdated );
|
42 |
this.$add.on( 'click', { self: this }, this._add_item );
|
43 |
this.$elmt.on( 'click', '.ditty-data-list__item', { self: this }, this._showItem );
|
44 |
this.$elmt.on( 'click', '.ditty-data-list__item__icon', { self: this }, this._editType );
|
includes/js/editor/class-ditty-layout-variations-panel.js
CHANGED
@@ -131,7 +131,7 @@
|
|
131 |
/**
|
132 |
* Edit the html or css of a layout
|
133 |
*
|
134 |
-
* @since 3.0
|
135 |
* @return null
|
136 |
*/
|
137 |
_editLayout: function( e ) {
|
@@ -155,12 +155,13 @@
|
|
155 |
$.each( items, function( index, item ) {
|
156 |
itemIds.push( item.uniqId );
|
157 |
} );
|
158 |
-
|
159 |
// Load the new display fields
|
160 |
var data = {
|
161 |
action : 'ditty_editor_layout_fields',
|
162 |
layout_id : layoutId,
|
163 |
item_type : itemType,
|
|
|
164 |
ditty_id : self.editorDittyId,
|
165 |
item_id : self.editorItemId,
|
166 |
item_ids : itemIds,
|
131 |
/**
|
132 |
* Edit the html or css of a layout
|
133 |
*
|
134 |
+
* @since 3.0.12
|
135 |
* @return null
|
136 |
*/
|
137 |
_editLayout: function( e ) {
|
155 |
$.each( items, function( index, item ) {
|
156 |
itemIds.push( item.uniqId );
|
157 |
} );
|
158 |
+
|
159 |
// Load the new display fields
|
160 |
var data = {
|
161 |
action : 'ditty_editor_layout_fields',
|
162 |
layout_id : layoutId,
|
163 |
item_type : itemType,
|
164 |
+
item_value : self.$editorItem.data( 'item_value' ),
|
165 |
ditty_id : self.editorDittyId,
|
166 |
item_id : self.editorItemId,
|
167 |
item_ids : itemIds,
|
includes/js/editor/ditty-item-edit-editor.js
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery( function( $ ) {
|
2 |
+
|
3 |
+
// Setup strict mode
|
4 |
+
(function() {
|
5 |
+
|
6 |
+
"use strict";
|
7 |
+
|
8 |
+
function toggle_content_fields( $form ) {
|
9 |
+
var val = $form.find( 'input[name="content_display"]:checked' ).val();
|
10 |
+
if ( 'full' === val ) {
|
11 |
+
$form.find( '.ditty-field--more_link' ).hide();
|
12 |
+
$form.find( '.ditty-field--excerpt_length' ).hide();
|
13 |
+
$form.find( '.ditty-field--more' ).hide();
|
14 |
+
$form.find( '.ditty-field--more_before' ).hide();
|
15 |
+
$form.find( '.ditty-field--more_after' ).hide();
|
16 |
+
} else {
|
17 |
+
$form.find( '.ditty-field--more_link' ).show();
|
18 |
+
$form.find( '.ditty-field--excerpt_length' ).show();
|
19 |
+
$form.find( '.ditty-field--more' ).show();
|
20 |
+
$form.find( '.ditty-field--more_before' ).show();
|
21 |
+
$form.find( '.ditty-field--more_after' ).show();
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
$( '#ditty-editor' ).on( 'ditty_item_editor_panel_init', '.ditty-editor__panel--item_editor', function( e, editorPanel ) {
|
26 |
+
if ( 'posts_feed' !== editorPanel.itemType && 'post' !== editorPanel.itemType ) {
|
27 |
+
return false;
|
28 |
+
}
|
29 |
+
var $form = editorPanel.$form;
|
30 |
+
toggle_content_fields( $form );
|
31 |
+
$form.on( 'click', 'input[name="content_display"]', function() {
|
32 |
+
toggle_content_fields( $form );
|
33 |
+
} );
|
34 |
+
} );
|
35 |
+
|
36 |
+
}() );
|
37 |
+
|
38 |
+
} );
|
includes/js/editor/ditty-list-display-editor.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/* global dittyVars:true */
|
2 |
|
3 |
-
jQuery(
|
4 |
|
5 |
// Setup strict mode
|
6 |
(function() {
|
1 |
/* global dittyVars:true */
|
2 |
|
3 |
+
jQuery( function( $ ) {
|
4 |
|
5 |
// Setup strict mode
|
6 |
(function() {
|
includes/js/editor/ditty-ticker-display-editor.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/* global dittyVars:true */
|
2 |
|
3 |
-
jQuery(
|
4 |
|
5 |
// Setup strict mode
|
6 |
(function() {
|
1 |
/* global dittyVars:true */
|
2 |
|
3 |
+
jQuery( function( $ ) {
|
4 |
|
5 |
// Setup strict mode
|
6 |
(function() {
|
includes/layout-tag-helpers.php
CHANGED
@@ -32,7 +32,7 @@ function ditty_layout_render_tag_link( $link, $html, $class, $data, $atts, $pref
|
|
32 |
/**
|
33 |
* Return a rendered wrapper
|
34 |
*
|
35 |
-
* @since 3.0
|
36 |
* @var html
|
37 |
*/
|
38 |
function ditty_layout_render_tag_wrapper( $html, $class = '', $atts = array(), $custom_wrapper = false ) {
|
@@ -50,9 +50,11 @@ function ditty_layout_render_tag_wrapper( $html, $class = '', $atts = array(), $
|
|
50 |
if ( isset( $args['class'] ) && '' != $args['class'] ) {
|
51 |
$class .= ' ' . trim( $args['class'] );
|
52 |
}
|
|
|
|
|
|
|
53 |
$html = sprintf( '<%4$s class="%5$s">%2$s%1$s%3$s</%4$s>', $html, $before, $after, $args['wrapper'], esc_attr( $class ) );
|
54 |
-
}
|
55 |
-
if ( $custom_wrapper ) {
|
56 |
$html = sprintf( $custom_wrapper, $html );
|
57 |
}
|
58 |
return $html;
|
@@ -61,7 +63,7 @@ function ditty_layout_render_tag_wrapper( $html, $class = '', $atts = array(), $
|
|
61 |
/**
|
62 |
* Return a rendered tag
|
63 |
*
|
64 |
-
* @since 3.0
|
65 |
* @var html
|
66 |
*/
|
67 |
function ditty_layout_render_tag( $html, $class, $item_type, $data, $atts = array(), $custom_wrapper = false, $prefix = '' ) {
|
@@ -69,7 +71,9 @@ function ditty_layout_render_tag( $html, $class, $item_type, $data, $atts = arra
|
|
69 |
if ( ! empty( $link_data ) ) {
|
70 |
$html = ditty_layout_render_tag_link( $link_data, $html, "{$class}__link", $data, $atts, $prefix );
|
71 |
}
|
72 |
-
|
|
|
|
|
73 |
}
|
74 |
|
75 |
/**
|
32 |
/**
|
33 |
* Return a rendered wrapper
|
34 |
*
|
35 |
+
* @since 3.0.12
|
36 |
* @var html
|
37 |
*/
|
38 |
function ditty_layout_render_tag_wrapper( $html, $class = '', $atts = array(), $custom_wrapper = false ) {
|
50 |
if ( isset( $args['class'] ) && '' != $args['class'] ) {
|
51 |
$class .= ' ' . trim( $args['class'] );
|
52 |
}
|
53 |
+
if ( $custom_wrapper ) {
|
54 |
+
$html = sprintf( $custom_wrapper, $html );
|
55 |
+
}
|
56 |
$html = sprintf( '<%4$s class="%5$s">%2$s%1$s%3$s</%4$s>', $html, $before, $after, $args['wrapper'], esc_attr( $class ) );
|
57 |
+
} elseif ( $custom_wrapper ) {
|
|
|
58 |
$html = sprintf( $custom_wrapper, $html );
|
59 |
}
|
60 |
return $html;
|
63 |
/**
|
64 |
* Return a rendered tag
|
65 |
*
|
66 |
+
* @since 3.0.12
|
67 |
* @var html
|
68 |
*/
|
69 |
function ditty_layout_render_tag( $html, $class, $item_type, $data, $atts = array(), $custom_wrapper = false, $prefix = '' ) {
|
71 |
if ( ! empty( $link_data ) ) {
|
72 |
$html = ditty_layout_render_tag_link( $link_data, $html, "{$class}__link", $data, $atts, $prefix );
|
73 |
}
|
74 |
+
if ( $html && '' != $html ) {
|
75 |
+
return ditty_layout_render_tag_wrapper( $html, $class, $atts, $custom_wrapper );
|
76 |
+
}
|
77 |
}
|
78 |
|
79 |
/**
|
includes/layout-tag-hooks-posts.php
CHANGED
@@ -68,7 +68,7 @@ function ditty_posts_lite_tag_value( $data, $key = false ) {
|
|
68 |
/**
|
69 |
* Modify the layout user avatar
|
70 |
*
|
71 |
-
* @since 3.0
|
72 |
* @var html
|
73 |
*/
|
74 |
function ditty_posts_lite_layout_tag_author_avatar_data( $avatar_data, $item_type, $data, $atts ) {
|
@@ -76,10 +76,11 @@ function ditty_posts_lite_layout_tag_author_avatar_data( $avatar_data, $item_typ
|
|
76 |
'post',
|
77 |
'posts_feed',
|
78 |
);
|
79 |
-
if ( in_array( $item_type, $types ) ) {
|
|
|
80 |
$avatar_data = array(
|
81 |
-
'src' => get_avatar_url(
|
82 |
-
'alt' => get_the_author_meta( 'display_name' ),
|
83 |
);
|
84 |
}
|
85 |
return $avatar_data;
|
@@ -89,7 +90,7 @@ add_filter( 'ditty_layout_tag_author_avatar_data', 'ditty_posts_lite_layout_tag_
|
|
89 |
/**
|
90 |
* Modify the layout author name
|
91 |
*
|
92 |
-
* @since 3.0
|
93 |
* @var html
|
94 |
*/
|
95 |
function ditty_posts_lite_layout_tag_author_name( $author_name, $item_type, $data, $atts ) {
|
@@ -98,7 +99,8 @@ function ditty_posts_lite_layout_tag_author_name( $author_name, $item_type, $dat
|
|
98 |
'posts_feed',
|
99 |
);
|
100 |
if ( in_array( $item_type, $types ) ) {
|
101 |
-
$
|
|
|
102 |
}
|
103 |
return $author_name;
|
104 |
}
|
@@ -107,7 +109,7 @@ add_filter( 'ditty_layout_tag_author_name', 'ditty_posts_lite_layout_tag_author_
|
|
107 |
/**
|
108 |
* Modify the layout author bio
|
109 |
*
|
110 |
-
* @since 3.0
|
111 |
* @var html
|
112 |
*/
|
113 |
function ditty_posts_lite_layout_tag_author_bio( $author_bio, $item_type, $data, $atts ) {
|
@@ -116,7 +118,8 @@ function ditty_posts_lite_layout_tag_author_bio( $author_bio, $item_type, $data,
|
|
116 |
'posts_feed',
|
117 |
);
|
118 |
if ( in_array( $item_type, $types ) ) {
|
119 |
-
$
|
|
|
120 |
}
|
121 |
return $author_bio;
|
122 |
}
|
@@ -152,7 +155,7 @@ add_filter( 'ditty_layout_tag_category_data', 'ditty_posts_lite_layout_tag_categ
|
|
152 |
/**
|
153 |
* Modify the layout content
|
154 |
*
|
155 |
-
* @since 3.0
|
156 |
* @var html
|
157 |
*/
|
158 |
function ditty_posts_lite_layout_tag_content( $content, $item_type, $data, $atts ) {
|
@@ -161,7 +164,17 @@ function ditty_posts_lite_layout_tag_content( $content, $item_type, $data, $atts
|
|
161 |
'posts_feed',
|
162 |
);
|
163 |
if ( in_array( $item_type, $types ) ) {
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
}
|
166 |
return $content;
|
167 |
}
|
@@ -191,7 +204,7 @@ add_filter( 'ditty_layout_tag_excerpt_data', 'ditty_posts_lite_layout_tag_excerp
|
|
191 |
/**
|
192 |
* Modify the layout tag link data
|
193 |
*
|
194 |
-
* @since 3.0
|
195 |
* @var html
|
196 |
*/
|
197 |
function ditty_posts_lite_layout_tag_link_data( $link_data, $item_type, $data, $atts, $prefix ) {
|
@@ -216,13 +229,15 @@ function ditty_posts_lite_layout_tag_link_data( $link_data, $item_type, $data, $
|
|
216 |
$link_title = ditty_posts_lite_tag_value( $data, 'post_title' );
|
217 |
break;
|
218 |
case 'author':
|
219 |
-
$
|
220 |
-
$
|
|
|
221 |
break;
|
222 |
case 'author_link':
|
223 |
-
|
|
|
224 |
$link_url = $user_url;
|
225 |
-
$link_title = get_the_author_meta( 'display_name' );
|
226 |
}
|
227 |
default:
|
228 |
break;
|
@@ -231,6 +246,7 @@ function ditty_posts_lite_layout_tag_link_data( $link_data, $item_type, $data, $
|
|
231 |
$link_data = array(
|
232 |
'url' => esc_url_raw( $link_url ),
|
233 |
'title' => $link_title,
|
|
|
234 |
);
|
235 |
return $link_data;
|
236 |
}
|
68 |
/**
|
69 |
* Modify the layout user avatar
|
70 |
*
|
71 |
+
* @since 3.0.12
|
72 |
* @var html
|
73 |
*/
|
74 |
function ditty_posts_lite_layout_tag_author_avatar_data( $avatar_data, $item_type, $data, $atts ) {
|
76 |
'post',
|
77 |
'posts_feed',
|
78 |
);
|
79 |
+
if ( in_array( $item_type, $types ) ) {
|
80 |
+
$author_id = ditty_posts_lite_tag_value( $data, 'post_author' );
|
81 |
$avatar_data = array(
|
82 |
+
'src' => get_avatar_url( $author_id ),
|
83 |
+
'alt' => get_the_author_meta( 'display_name', $author_id ),
|
84 |
);
|
85 |
}
|
86 |
return $avatar_data;
|
90 |
/**
|
91 |
* Modify the layout author name
|
92 |
*
|
93 |
+
* @since 3.0.12
|
94 |
* @var html
|
95 |
*/
|
96 |
function ditty_posts_lite_layout_tag_author_name( $author_name, $item_type, $data, $atts ) {
|
99 |
'posts_feed',
|
100 |
);
|
101 |
if ( in_array( $item_type, $types ) ) {
|
102 |
+
$author_id = ditty_posts_lite_tag_value( $data, 'post_author' );
|
103 |
+
$author_name = get_the_author_meta( 'display_name', $author_id );
|
104 |
}
|
105 |
return $author_name;
|
106 |
}
|
109 |
/**
|
110 |
* Modify the layout author bio
|
111 |
*
|
112 |
+
* @since 3.0.12
|
113 |
* @var html
|
114 |
*/
|
115 |
function ditty_posts_lite_layout_tag_author_bio( $author_bio, $item_type, $data, $atts ) {
|
118 |
'posts_feed',
|
119 |
);
|
120 |
if ( in_array( $item_type, $types ) ) {
|
121 |
+
$author_id = ditty_posts_lite_tag_value( $data, 'post_author' );
|
122 |
+
$author_bio = get_the_author_meta( 'description', $author_id );
|
123 |
}
|
124 |
return $author_bio;
|
125 |
}
|
155 |
/**
|
156 |
* Modify the layout content
|
157 |
*
|
158 |
+
* @since 3.0.12
|
159 |
* @var html
|
160 |
*/
|
161 |
function ditty_posts_lite_layout_tag_content( $content, $item_type, $data, $atts ) {
|
164 |
'posts_feed',
|
165 |
);
|
166 |
if ( in_array( $item_type, $types ) ) {
|
167 |
+
// Possibly show the exerpt
|
168 |
+
if ( isset( $data['content_display'] ) && 'excerpt' == $data['content_display'] ) {
|
169 |
+
$atts['excerpt_length'] = isset( $data['excerpt_length'] ) ? intval( $data['excerpt_length'] ) : 200;
|
170 |
+
$atts['more'] = isset( $data['more'] ) ? sanitize_text_field( $data['more'] ) : false;
|
171 |
+
$atts['more_link'] = isset( $data['more_link'] ) ? esc_attr( $data['more_link'] ) : false;
|
172 |
+
$atts['more_before'] = isset( $data['more_before'] ) ? sanitize_text_field( $data['more_before'] ) : false;
|
173 |
+
$atts['more_after'] = isset( $data['more_after'] ) ? sanitize_text_field( $data['more_after'] ) : false;
|
174 |
+
$content = ditty_init_layout_tag_excerpt( $content, $item_type, $data, $atts );
|
175 |
+
} else {
|
176 |
+
$content = ditty_posts_lite_tag_value( $data, 'post_content' );
|
177 |
+
}
|
178 |
}
|
179 |
return $content;
|
180 |
}
|
204 |
/**
|
205 |
* Modify the layout tag link data
|
206 |
*
|
207 |
+
* @since 3.0.12
|
208 |
* @var html
|
209 |
*/
|
210 |
function ditty_posts_lite_layout_tag_link_data( $link_data, $item_type, $data, $atts, $prefix ) {
|
229 |
$link_title = ditty_posts_lite_tag_value( $data, 'post_title' );
|
230 |
break;
|
231 |
case 'author':
|
232 |
+
$author_id = ditty_posts_lite_tag_value( $data, 'post_author' );
|
233 |
+
$link_url = get_author_posts_url( $author_id );
|
234 |
+
$link_title = get_the_author_meta( 'display_name', $author_id );
|
235 |
break;
|
236 |
case 'author_link':
|
237 |
+
$author_id = ditty_posts_lite_tag_value( $data, 'post_author' );
|
238 |
+
if ( $user_url = get_the_author_meta( 'user_url', $author_id ) ) {
|
239 |
$link_url = $user_url;
|
240 |
+
$link_title = get_the_author_meta( 'display_name', $author_id );
|
241 |
}
|
242 |
default:
|
243 |
break;
|
246 |
$link_data = array(
|
247 |
'url' => esc_url_raw( $link_url ),
|
248 |
'title' => $link_title,
|
249 |
+
'rel' => ( isset( $data['link_nofollow'] ) && 1 == $data['link_nofollow'] ) ? 'nofollow' : false,
|
250 |
);
|
251 |
return $link_data;
|
252 |
}
|
includes/layout-tag-hooks.php
CHANGED
@@ -137,7 +137,7 @@ add_filter( 'ditty_layout_tag_categories', 'ditty_init_layout_tag_categories', 1
|
|
137 |
/**
|
138 |
* Modify the layout excerpt
|
139 |
*
|
140 |
-
* @since 3.0
|
141 |
* @var html
|
142 |
*/
|
143 |
function ditty_init_layout_tag_excerpt( $excerpt, $item_type, $data, $atts ) {
|
@@ -146,12 +146,14 @@ function ditty_init_layout_tag_excerpt( $excerpt, $item_type, $data, $atts ) {
|
|
146 |
}
|
147 |
$more = '';
|
148 |
if ( isset( $atts['more'] ) && '' != $atts['more'] ) {
|
149 |
-
$more
|
|
|
|
|
150 |
$link_data = apply_filters( 'ditty_layout_tag_link_data', array(), $item_type, $data, $atts, 'more_' );
|
151 |
if ( ! empty( $link_data ) ) {
|
152 |
$more = ditty_layout_render_tag_link( $link_data, $more, 'ditty-item__excerpt__more__link', $data, $atts, 'more_' );
|
153 |
}
|
154 |
-
$more =
|
155 |
}
|
156 |
$excerpt_length = ( isset( $atts['excerpt_length'] ) && 0 != intval( $atts['excerpt_length'] ) ) ? intval( $atts['excerpt_length'] ) : 200;
|
157 |
$excerpt = '<span class="ditty-item__excerpt__content">' . wp_html_excerpt( $excerpt_data, $excerpt_length, $more ) . '</span>';
|
137 |
/**
|
138 |
* Modify the layout excerpt
|
139 |
*
|
140 |
+
* @since 3.0.12
|
141 |
* @var html
|
142 |
*/
|
143 |
function ditty_init_layout_tag_excerpt( $excerpt, $item_type, $data, $atts ) {
|
146 |
}
|
147 |
$more = '';
|
148 |
if ( isset( $atts['more'] ) && '' != $atts['more'] ) {
|
149 |
+
$more = $atts['more'];
|
150 |
+
$more_before = isset( $atts['more_before'] ) ? sanitize_text_field( $atts['more_before'] ) : '';
|
151 |
+
$more_after = isset( $atts['more_after'] ) ? sanitize_text_field( $atts['more_after'] ) : '';
|
152 |
$link_data = apply_filters( 'ditty_layout_tag_link_data', array(), $item_type, $data, $atts, 'more_' );
|
153 |
if ( ! empty( $link_data ) ) {
|
154 |
$more = ditty_layout_render_tag_link( $link_data, $more, 'ditty-item__excerpt__more__link', $data, $atts, 'more_' );
|
155 |
}
|
156 |
+
$more = "<span class='ditty-item__excerpt__more'>{$more_before}{$more}{$more_after}</span>";
|
157 |
}
|
158 |
$excerpt_length = ( isset( $atts['excerpt_length'] ) && 0 != intval( $atts['excerpt_length'] ) ) ? intval( $atts['excerpt_length'] ) : 200;
|
159 |
$excerpt = '<span class="ditty-item__excerpt__content">' . wp_html_excerpt( $excerpt_data, $excerpt_length, $more ) . '</span>';
|
includes/layout-tags.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
/**
|
3 |
* Return all possible layout tags
|
4 |
*
|
5 |
-
* @since 3.0
|
6 |
* @var html
|
7 |
*/
|
8 |
-
function ditty_layout_tags( $item_type = false ) {
|
9 |
$tags = array(
|
10 |
'author_avatar' => array(
|
11 |
'tag' => 'author_avatar',
|
@@ -258,7 +258,7 @@ function ditty_layout_tags( $item_type = false ) {
|
|
258 |
),
|
259 |
),
|
260 |
);
|
261 |
-
$tags = apply_filters( 'ditty_layout_tags', $tags, $item_type );
|
262 |
ksort( $tags );
|
263 |
return $tags;
|
264 |
}
|
2 |
/**
|
3 |
* Return all possible layout tags
|
4 |
*
|
5 |
+
* @since 3.0.12
|
6 |
* @var html
|
7 |
*/
|
8 |
+
function ditty_layout_tags( $item_type = false, $item_value = false ) {
|
9 |
$tags = array(
|
10 |
'author_avatar' => array(
|
11 |
'tag' => 'author_avatar',
|
258 |
),
|
259 |
),
|
260 |
);
|
261 |
+
$tags = apply_filters( 'ditty_layout_tags', $tags, $item_type, $item_value );
|
262 |
ksort( $tags );
|
263 |
return $tags;
|
264 |
}
|
includes/layout-templates.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* Return all possible layout templates
|
5 |
*
|
6 |
-
* @since 3.0
|
7 |
* @var html
|
8 |
*/
|
9 |
function ditty_layout_templates() {
|
@@ -27,7 +27,7 @@ function ditty_layout_templates() {
|
|
27 |
'description' => __( 'Default layout for Posts.', 'ditty-news-ticker' ),
|
28 |
'html' => ditty_layout_default_post_html(),
|
29 |
'css' => ditty_layout_default_post_css(),
|
30 |
-
'version' => '1.
|
31 |
),
|
32 |
);
|
33 |
return apply_filters( 'ditty_layout_templates', $layout_templates );
|
@@ -174,7 +174,7 @@ function ditty_layout_default_image_css() {
|
|
174 |
/**
|
175 |
* The default post template
|
176 |
*
|
177 |
-
* @since 3.0
|
178 |
* @access private
|
179 |
* @var string
|
180 |
*/
|
@@ -277,6 +277,9 @@ function ditty_layout_default_post_css() {
|
|
277 |
}
|
278 |
.ditty-item__content {
|
279 |
margin-top: 5px;
|
|
|
|
|
|
|
280 |
}
|
281 |
<?php
|
282 |
return ob_get_clean();
|
3 |
/**
|
4 |
* Return all possible layout templates
|
5 |
*
|
6 |
+
* @since 3.0.12
|
7 |
* @var html
|
8 |
*/
|
9 |
function ditty_layout_templates() {
|
27 |
'description' => __( 'Default layout for Posts.', 'ditty-news-ticker' ),
|
28 |
'html' => ditty_layout_default_post_html(),
|
29 |
'css' => ditty_layout_default_post_css(),
|
30 |
+
'version' => '1.1',
|
31 |
),
|
32 |
);
|
33 |
return apply_filters( 'ditty_layout_templates', $layout_templates );
|
174 |
/**
|
175 |
* The default post template
|
176 |
*
|
177 |
+
* @since 3.0.12
|
178 |
* @access private
|
179 |
* @var string
|
180 |
*/
|
277 |
}
|
278 |
.ditty-item__content {
|
279 |
margin-top: 5px;
|
280 |
+
}
|
281 |
+
.ditty-item__excerpt {
|
282 |
+
margin-top: 5px;
|
283 |
}
|
284 |
<?php
|
285 |
return ob_get_clean();
|
includes/sass/admin/_fields.scss
CHANGED
@@ -571,4 +571,25 @@
|
|
571 |
object-fit: cover;
|
572 |
}
|
573 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
574 |
}
|
571 |
object-fit: cover;
|
572 |
}
|
573 |
}
|
574 |
+
}
|
575 |
+
|
576 |
+
/* File */
|
577 |
+
.ditty-input--file {
|
578 |
+
.ditty-field__input__primary {
|
579 |
+
display: flex;
|
580 |
+
flex-direction: row;
|
581 |
+
align-items: stretch;
|
582 |
+
justify-content: flex-start;
|
583 |
+
}
|
584 |
+
input[type="text"] {
|
585 |
+
border-top-right-radius: 0 !important;
|
586 |
+
border-bottom-right-radius: 0 !important;
|
587 |
+
}
|
588 |
+
.ditty-button {
|
589 |
+
padding-left: 20px;
|
590 |
+
padding-right: 20px;
|
591 |
+
margin: 0;
|
592 |
+
border-top-left-radius: 0;
|
593 |
+
border-bottom-left-radius: 0;
|
594 |
+
}
|
595 |
}
|
includes/sass/editor/_editor.scss
CHANGED
@@ -37,7 +37,7 @@ $update_color: orange;
|
|
37 |
align-items: stretch;
|
38 |
justify-content: flex-start;
|
39 |
width: $settings_width;
|
40 |
-
background: #
|
41 |
.ditty-field {
|
42 |
padding: 15px;
|
43 |
border-color: rgba( 0, 0, 0, 0.05 );
|
@@ -298,7 +298,7 @@ $update_color: orange;
|
|
298 |
&__body {
|
299 |
position: relative;
|
300 |
max-height: calc( 100vh - 470px );
|
301 |
-
min-height: 300px;
|
302 |
overflow-y: scroll;
|
303 |
-webkit-overflow-scrolling: touch;
|
304 |
&__error {
|
@@ -389,6 +389,18 @@ $update_color: orange;
|
|
389 |
}
|
390 |
}
|
391 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
@keyframes ditty-unsaved-changes {
|
393 |
0% {
|
394 |
//transform: scale( 1 );
|
37 |
align-items: stretch;
|
38 |
justify-content: flex-start;
|
39 |
width: $settings_width;
|
40 |
+
background: #EBEBEB;
|
41 |
.ditty-field {
|
42 |
padding: 15px;
|
43 |
border-color: rgba( 0, 0, 0, 0.05 );
|
298 |
&__body {
|
299 |
position: relative;
|
300 |
max-height: calc( 100vh - 470px );
|
301 |
+
//min-height: 300px;
|
302 |
overflow-y: scroll;
|
303 |
-webkit-overflow-scrolling: touch;
|
304 |
&__error {
|
389 |
}
|
390 |
}
|
391 |
}
|
392 |
+
.ditty-editor__panel--item_editor {
|
393 |
+
.ditty-editor-options__body {
|
394 |
+
display: flex;
|
395 |
+
flex-direction: row;
|
396 |
+
align-items: flex-start;
|
397 |
+
justify-content: flex-start;
|
398 |
+
flex-wrap: wrap;
|
399 |
+
> .ditty-field {
|
400 |
+
width: 100%;
|
401 |
+
}
|
402 |
+
}
|
403 |
+
}
|
404 |
@keyframes ditty-unsaved-changes {
|
405 |
0% {
|
406 |
//transform: scale( 1 );
|
languages/ditty-news-ticker.pot
CHANGED
@@ -76,35 +76,35 @@ msgid "Display:"
|
|
76 |
msgstr ""
|
77 |
|
78 |
#. translators: the plugin name.
|
79 |
-
#: includes/admin/
|
80 |
#, php-format
|
81 |
msgid "There is a new version of %1$s available."
|
82 |
msgstr ""
|
83 |
|
84 |
-
#: includes/admin/
|
85 |
msgid "Contact your network administrator to install the update."
|
86 |
msgstr ""
|
87 |
|
88 |
#. translators: 1. opening anchor tag, do not translate 2. the new plugin version 3. closing anchor tag, do not translate.
|
89 |
-
#: includes/admin/
|
90 |
#, php-format
|
91 |
msgid "%1$sView version %2$s details%3$s."
|
92 |
msgstr ""
|
93 |
|
94 |
-
#: includes/admin/
|
95 |
#, php-format
|
96 |
msgid "%1$sView version %2$s details%3$s or %4$supdate now%5$s."
|
97 |
msgstr ""
|
98 |
|
99 |
-
#: includes/admin/
|
100 |
msgid "Update now."
|
101 |
msgstr ""
|
102 |
|
103 |
-
#: includes/admin/
|
104 |
msgid "You do not have permission to install plugin updates"
|
105 |
msgstr ""
|
106 |
|
107 |
-
#: includes/admin/
|
108 |
msgid "Error"
|
109 |
msgstr ""
|
110 |
|
76 |
msgstr ""
|
77 |
|
78 |
#. translators: the plugin name.
|
79 |
+
#: includes/admin/Ditty_Plugin_Updater.php:224
|
80 |
#, php-format
|
81 |
msgid "There is a new version of %1$s available."
|
82 |
msgstr ""
|
83 |
|
84 |
+
#: includes/admin/Ditty_Plugin_Updater.php:230
|
85 |
msgid "Contact your network administrator to install the update."
|
86 |
msgstr ""
|
87 |
|
88 |
#. translators: 1. opening anchor tag, do not translate 2. the new plugin version 3. closing anchor tag, do not translate.
|
89 |
+
#: includes/admin/Ditty_Plugin_Updater.php:235
|
90 |
#, php-format
|
91 |
msgid "%1$sView version %2$s details%3$s."
|
92 |
msgstr ""
|
93 |
|
94 |
+
#: includes/admin/Ditty_Plugin_Updater.php:243
|
95 |
#, php-format
|
96 |
msgid "%1$sView version %2$s details%3$s or %4$supdate now%5$s."
|
97 |
msgstr ""
|
98 |
|
99 |
+
#: includes/admin/Ditty_Plugin_Updater.php:254
|
100 |
msgid "Update now."
|
101 |
msgstr ""
|
102 |
|
103 |
+
#: includes/admin/Ditty_Plugin_Updater.php:486
|
104 |
msgid "You do not have permission to install plugin updates"
|
105 |
msgstr ""
|
106 |
|
107 |
+
#: includes/admin/Ditty_Plugin_Updater.php:486
|
108 |
msgid "Error"
|
109 |
msgstr ""
|
110 |
|
legacy/eddsl/eddsl.php
CHANGED
@@ -4,8 +4,8 @@
|
|
4 |
/* !Add the plugin updater - 2.1.17 */
|
5 |
/* --------------------------------------------------------- */
|
6 |
|
7 |
-
if( !class_exists( '
|
8 |
-
include( dirname( __FILE__ ) . '/
|
9 |
}
|
10 |
|
11 |
/**
|
@@ -47,7 +47,7 @@ function mtphr_dnt_plugin_updater() {
|
|
47 |
$license_key = isset($mtphr_edd_licenses[$slug]) ? trim($mtphr_edd_licenses[$slug]) : '';
|
48 |
|
49 |
// setup the updater
|
50 |
-
$edd_updater = new
|
51 |
'version' => $data['version'], // current version number
|
52 |
'license' => $license_key, // license key (used get_option above to retrieve from DB)
|
53 |
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : null, // name of this plugin
|
@@ -636,7 +636,7 @@ add_action( 'wp_ajax_mtphr_dnt_license_activate_ajax', 'mtphr_dnt_license_activa
|
|
636 |
function mtphr_dnt_license_bug_ajax() {
|
637 |
?>
|
638 |
<script>
|
639 |
-
jQuery(
|
640 |
|
641 |
$( '#ditty-news-ticker-license-notice' ).on( 'click', '.notice-dismiss', function(e){
|
642 |
var data = {
|
4 |
/* !Add the plugin updater - 2.1.17 */
|
5 |
/* --------------------------------------------------------- */
|
6 |
|
7 |
+
if( !class_exists( 'Ditty_Plugin_Updater' ) ) {
|
8 |
+
include( dirname( __FILE__ ) . '/Ditty_Plugin_Updater.php' );
|
9 |
}
|
10 |
|
11 |
/**
|
47 |
$license_key = isset($mtphr_edd_licenses[$slug]) ? trim($mtphr_edd_licenses[$slug]) : '';
|
48 |
|
49 |
// setup the updater
|
50 |
+
$edd_updater = new Ditty_Plugin_Updater( 'https://www.metaphorcreations.com', $data['path'], array(
|
51 |
'version' => $data['version'], // current version number
|
52 |
'license' => $license_key, // license key (used get_option above to retrieve from DB)
|
53 |
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : null, // name of this plugin
|
636 |
function mtphr_dnt_license_bug_ajax() {
|
637 |
?>
|
638 |
<script>
|
639 |
+
jQuery(function($){
|
640 |
|
641 |
$( '#ditty-news-ticker-license-notice' ).on( 'click', '.notice-dismiss', function(e){
|
642 |
var data = {
|
legacy/inc/static.php
CHANGED
@@ -83,7 +83,7 @@ add_action( 'wp_head', 'mtphr_dnt_custom_css' );
|
|
83 |
|
84 |
|
85 |
/* --------------------------------------------------------- */
|
86 |
-
/* !Initialize the ticker scripts -
|
87 |
/* --------------------------------------------------------- */
|
88 |
|
89 |
function mtphr_dnt_tickers_init_scripts() {
|
@@ -103,7 +103,7 @@ function mtphr_dnt_tickers_init_scripts() {
|
|
103 |
}
|
104 |
?>
|
105 |
<script>
|
106 |
-
jQuery(
|
107 |
<?php foreach( $filtered_tickers as $ticker ) { ?>
|
108 |
$( '<?php echo $ticker['ticker']; ?>' ).ditty_news_ticker({
|
109 |
id : '<?php echo $ticker['id']; ?>',
|
83 |
|
84 |
|
85 |
/* --------------------------------------------------------- */
|
86 |
+
/* !Initialize the ticker scripts - 3.0.12 */
|
87 |
/* --------------------------------------------------------- */
|
88 |
|
89 |
function mtphr_dnt_tickers_init_scripts() {
|
103 |
}
|
104 |
?>
|
105 |
<script>
|
106 |
+
jQuery( function( $ ) {
|
107 |
<?php foreach( $filtered_tickers as $ticker ) { ?>
|
108 |
$( '<?php echo $ticker['ticker']; ?>' ).ditty_news_ticker({
|
109 |
id : '<?php echo $ticker['id']; ?>',
|
legacy/inc/static/js/partials/admin-general.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
jQuery(
|
2 |
|
3 |
var $settings_select = $('#mtphr-dnt-settings-select'),
|
4 |
$admin_bar = $('#wpadminbar');
|
1 |
+
jQuery( function($) {
|
2 |
|
3 |
var $settings_select = $('#mtphr-dnt-settings-select'),
|
4 |
$admin_bar = $('#wpadminbar');
|
legacy/inc/static/js/script-admin.min.js
CHANGED
@@ -1 +1,752 @@
|
|
1 |
-
!function(t){"use strict";function e(e){return this.each((function(){var n=t(this),r=n.data("bs.mtphr_dnt_affix"),o="object"==typeof e&&e;r||n.data("bs.mtphr_dnt_affix",r=new i(this,o)),"string"==typeof e&&r[e]()}))}var i=function(e,n){this.options=t.extend({},i.DEFAULTS,n),this.$target=t(this.options.target).on("scroll.bs.mtphr_dnt_affix.data-api",t.proxy(this.checkPosition,this)).on("click.bs.mtphr_dnt_affix.data-api",t.proxy(this.checkPositionWithEventLoop,this)),this.$element=t(e),this.mtphr_dnt_affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};i.VERSION="3.3.5",i.RESET="mtphr_dnt_affix mtphr_dnt_affix-top mtphr_dnt_affix-bottom",i.DEFAULTS={offset:0,target:window},i.prototype.getState=function(t,e,i,n){var r=this.$target.scrollTop(),o=this.$element.offset(),a=this.$target.height();if(null!==i&&"top"===this.mtphr_dnt_affixed)return r<i&&"top";if("bottom"===this.mtphr_dnt_affixed)return null!==i?!(r+this.unpin<=o.top)&&"bottom":!(r+a<=t-n)&&"bottom";var s=null===this.mtphr_dnt_affixed,h=s?r:o.top,d;return null!==i&&r<=i?"top":null!==n&&h+(s?a:e)>=t-n&&"bottom"},i.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(i.RESET).addClass("mtphr_dnt_affix");var t=this.$target.scrollTop(),e=this.$element.offset();return this.pinnedOffset=e.top-t},i.prototype.checkPositionWithEventLoop=function(){setTimeout(t.proxy(this.checkPosition,this),1)},i.prototype.checkPosition=function(){if(this.$element.is(":visible")){var e=this.$element.height(),n=this.options.offset,r=n.top,o=n.bottom,a=Math.max(t(document).height(),t(document.body).height());"object"!=typeof n&&(o=r=n),"function"==typeof r&&(r=n.top(this.$element)),"function"==typeof o&&(o=n.bottom(this.$element));var s=this.getState(a,e,r,o);if(this.mtphr_dnt_affixed!==s){null!==this.unpin&&this.$element.css("top","");var h="mtphr_dnt_affix"+(s?"-"+s:""),d=t.Event(h+".bs.mtphr_dnt_affix");if(this.$element.trigger(d),d.isDefaultPrevented())return;this.mtphr_dnt_affixed=s,this.unpin="bottom"===s?this.getPinnedOffset():null,this.$element.removeClass(i.RESET).addClass(h).trigger(h.replace("mtphr_dnt_affix","mtphr_dnt_affixed")+".bs.mtphr_dnt_affix")}"bottom"===s&&this.$element.offset({top:a-e-o})}};var n=t.fn.mtphr_dnt_affix;t.fn.mtphr_dnt_affix=e,t.fn.mtphr_dnt_affix.Constructor=i,t.fn.mtphr_dnt_affix.noConflict=function(){return t.fn.mtphr_dnt_affix=n,this},t(window).on("load",(function(){t('[data-spy="mtphr_dnt_affix"]').each((function(){var i=t(this),n=i.data();n.offset=n.offset||{},null!==n.offsetBottom&&(n.offset.bottom=n.offsetBottom),null!==n.offsetTop&&(n.offset.top=n.offsetTop),e.call(i,n)}))}))}(jQuery),jQuery(document).ready((function(t){function e(e,i){t("#mtphr-dnt-"+i+"-metaboxes > div").stop(!0,!0).hide();for(var n=e.attr("metabox").split(" "),r=0;r<n.length;r++)t("#"+n[r]).show();e.siblings("a").removeClass("button-primary"),e.addClass("button-primary"),e.siblings("input").val(e.attr("href").substring(1))}function i(t){var e;t.find("input").is(":checked")?t.next().fadeOut():t.next().fadeIn()}function n(e){e.is(":checked")?t(".mtphr-dnt-field-mtphr_dnt_scroll_init_delay").show():t(".mtphr-dnt-field-mtphr_dnt_scroll_init_delay").hide()}var r=t("#mtphr-dnt-settings-select"),o=t("#wpadminbar");r.mtphr_dnt_affix({offset:{top:function(){return t(window).width()<601?this.top=r.offset().top+5:this.top=r.offset().top-o.height()+5}}}),t("#mtphr-dnt-metabox-group-toggles").on("click",".mtphr-dnt-metabox-group-toggle",(function(e){e.preventDefault();var i=t(this).attr("href");t(".mtphr-dnt-metabox-group-toggle").removeClass("active"),t(".mtphr-dnt-metabox-group").removeClass("active"),t(this).addClass("active"),t(i).addClass("active"),t('input[name="_mtphr_dnt_admin_tab"]').val(i)})),t(".mtphr-dnt-codemirror-css").each((function(){var e=t(this).children("textarea");CodeMirror.fromTextArea(e[0],{mode:"css",lineNumbers:!0,lineWrapping:!0,viewportMargin:1/0})})),t(".mtphr-dnt-codemirror-js").each((function(){var e=t(this).children("textarea"),i;CodeMirror.fromTextArea(e[0],{mode:"htmlmixed",lineNumbers:!0,lineWrapping:!0}).setSize(!1,140)})),t('input[name="_mtphr_dnt_admin_javascript"]').length&&t('input[name="_mtphr_dnt_admin_javascript"]').val("ok"),t(".mtphr-dnt-type-toggle.button-primary").length&&e(t(".mtphr-dnt-type-toggle.button-primary"),"type"),t(".mtphr-dnt-mode-toggle.button-primary").length&&e(t(".mtphr-dnt-mode-toggle.button-primary"),"mode"),t("#mtphr-dnt-type-select").on("click",".mtphr-dnt-type-toggle",(function(i){i.preventDefault(),t(this).hasClass("button-primary")||e(t(this),"type")})),t("#mtphr-dnt-mode-select").on("click",".mtphr-dnt-mode-toggle",(function(i){i.preventDefault(),t(this).hasClass("button-primary")||e(t(this),"mode")})),t(".mtphr-dnt-sort").length>0&&(t(".mtphr-dnt-sort").sortable({handle:".mtphr-dnt-sort-heading",items:".mtphr-dnt-sort-item",axis:"y",opacity:.7,placeholder:{element:function(e){var i=t(e).innerHeight();return t('<div class="mtphr-dnt-sort-placeholder" style="height:'+i+'px;"></div>')[0]},update:function(){}},helper:function(e,i){var n=i.children(),r=i.clone();return r.children().each((function(e){t(this).width(n.eq(e).width()),t(this).height(n.eq(e).height())})),r}}),t("body").on("click",".mtphr-dnt-sort-heading.optional",(function(e){e.preventDefault();var i=t(this).parents(".mtphr-dnt-sort-item"),n=t(this).next(".mtphr-dnt-sort-item-fields"),r=t(this).children("input");i.hasClass("active")?(i.removeClass("active"),r.val("off"),n.length&&n.stop(!0,!0).slideUp(1e3,"easeOutQuint")):(i.addClass("active"),r.val("on"),n.length&&n.stop(!0,!0).slideDown(1e3,"easeOutQuint"))}))),t(".mtphr-dnt-list").mtphr_dnt_list(),t("body").on("click",".mtphr-dnt-single-image .mtphr-dnt-delete",(function(e){e.preventDefault();var i=t(this).parent(),n=i.siblings(".mtphr-dnt-single-image-upload"),r;i.siblings("input").val(""),i.remove(),n.show()})),t("body").on("click",".mtphr-dnt-single-image-upload",(function(e){e.preventDefault();var i=t(this),n=i.parent(),r=n.children("input"),o;if(!o)return(o=wp.media({title:ditty_news_ticker_vars.img_title,button:{text:ditty_news_ticker_vars.img_button,size:"small"},multiple:!1,library:{type:"image"}})).on("select",(function(){var t=o.state().get("selection").toJSON();if(t.length>0){r.val(t[0].id);var e={action:"mtphr_dnt_single_image_ajax",attachment:t[0],security:ditty_news_ticker_vars.security};jQuery.post(ajaxurl,e,(function(t){i.hide(),n.append(t)}))}})),o.open(),!1;o.open()})),t.protip({defaults:{position:"top",size:"small",scheme:"black",classes:"ditty-protip"}}),t("body").on("click",".mtphr-dnt-list-field-mtphr_dnt_mixed_ticks_all input",(function(){i(t(this).parents(".mtphr-dnt-list-field-mtphr_dnt_mixed_ticks_all"))})),t(".mtphr-dnt-list-field-mtphr_dnt_mixed_ticks_all").each((function(){i(t(this))})),t("body").on("click",'input[name="_mtphr_dnt_scroll_init"]',(function(){n(t(this))})),t('input[name="_mtphr_dnt_scroll_init"]').length&&n(t('input[name="_mtphr_dnt_scroll_init"]'))})),function(t){var e={init:function(e){return this.each((function(){function i(){a.find(".mtphr-dnt-list-item").length>1?(a.find(".mtphr-dnt-list-handle").show(),a.find(".mtphr-dnt-list-delete").show()):(a.find(".mtphr-dnt-list-handle").hide(),a.find(".mtphr-dnt-list-delete").hide())}function n(){a.find(".mtphr-dnt-list-item").each((function(e){t(this).find("textarea, input, select").each((function(){var i,n;if(t(this).hasClass("wp-editor-area")){var r=t(this).parents(".mtphr-dnt-field-type-wysiwyg");i=r.attr("data-name"),n=r.attr("data-key")}else i=t(this).attr("data-name"),n=t(this).attr("data-key");i&&n&&t(this).attr("name",i+"["+e+"]["+n+"]")}))})),i()}function r(e,i){var r=e.clone();r.find("textarea, input, select").each((function(){"checkbox"===t(this).attr("type")||"radio"===t(this).attr("type")?t(this).attr("checked",!1):t(this).val("")})),r.find("textarea").each((function(){if(t(this).hasClass("wp-editor-area")){var e=t(this).parents(".mtphr-dnt-field-type-wysiwyg"),i=e.attr("data-name");e.children(".wp-core-ui").remove();var r={action:"mtphr_dnt_wysiwyg_ajax",name:i,security:ditty_news_ticker_vars.security};jQuery.post(ajaxurl,r,(function(i){var r,o=t(i).find("textarea").attr("id");e.append(i),"object"==typeof tinyMCE&&"function"==typeof tinyMCE.execCommand&&tinyMCE.execCommand("mceAddEditor",!1,o),n()}))}})),r.hide(),e.after(r),r.fadeIn().addClass(i),t.protip({defaults:{position:"top",size:"small",scheme:"black",classes:"ditty-protip"}}),n(),a.trigger("mtphr_dnt_list_item_added",[r,i])}var o={};e&&t.extend(o,e);var a=t(this);t.protip({defaults:{position:"top",size:"small",scheme:"black",classes:"ditty-protip"}}),a.sortable({handle:".mtphr-dnt-list-heading > .dashicons-menu",items:".mtphr-dnt-list-item",axis:"y",opacity:.7,placeholder:{element:function(e){var i=t(e).innerHeight();return t('<div class="mtphr-dnt-sort-placeholder" style="height:'+i+'px;"></div>')[0]},update:function(){}},helper:function(e,i){var n=i.children(),r=i.clone();return r.children().each((function(e){t(this).width(n.eq(e).width()),t(this).height(n.eq(e).height())})),r},start:function(e,i){var n=t(i.item);if(n.find(".wp-editor-container").length){var r=n.find(".wp-editor-area").attr("id");tinyMCE.execCommand("mceRemoveEditor",!0,r)}},stop:function(e,i){var n=t(i.item);if(n.find(".wp-editor-container").length){var r=n.find(".wp-editor-area").attr("id");tinyMCE.execCommand("mceAddEditor",!0,r)}}}),a.on("click",".mtphr-dnt-list-delete",(function(e){e.preventDefault(),t(this).parents(".mtphr-dnt-list-item").fadeOut((function(){t(this).remove(),n()}))})),a.on("click",".mtphr-dnt-list-add",(function(e){e.preventDefault(),r(t(this).parents(".mtphr-dnt-list-item"))})),a.on("mtphr_dnt_list_add_item",(function(t,e,i){r(e,i)})),n()}))}};t.fn.mtphr_dnt_list=function(t){if(e[t])return e[t].apply(this,Array.prototype.slice.call(arguments,1));if("object"!=typeof t&&t)throw new Error("Method "+t+" does not exist in mtphr_dnt_list");return e.init.apply(this,arguments)}}(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* global CodeMirror:true */
|
2 |
+
/* global wp:true */
|
3 |
+
/* global ditty_news_ticker_vars:true */
|
4 |
+
/* global ajaxurl:true */
|
5 |
+
/* global tinyMCE:true */
|
6 |
+
|
7 |
+
// @codekit-append 'partials/mtphr-dnt-affix.js';
|
8 |
+
// @codekit-append 'partials/admin-general.js';
|
9 |
+
|
10 |
+
/* ========================================================================
|
11 |
+
* Bootstrap: mtphr_dnt_affix.js v3.3.5
|
12 |
+
* http://getbootstrap.com/javascript/#mtphr_dnt_affix
|
13 |
+
* ========================================================================
|
14 |
+
* Copyright 2011-2015 Twitter, Inc.
|
15 |
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
16 |
+
* ======================================================================== */
|
17 |
+
|
18 |
+
|
19 |
+
(function ($) {
|
20 |
+
'use strict';
|
21 |
+
|
22 |
+
// AFFIX CLASS DEFINITION
|
23 |
+
// ======================
|
24 |
+
|
25 |
+
var MTPHR_DNT_Affix = function (element, options) {
|
26 |
+
this.options = $.extend({}, MTPHR_DNT_Affix.DEFAULTS, options);
|
27 |
+
|
28 |
+
this.$target = $(this.options.target)
|
29 |
+
.on('scroll.bs.mtphr_dnt_affix.data-api', $.proxy(this.checkPosition, this))
|
30 |
+
.on('click.bs.mtphr_dnt_affix.data-api', $.proxy(this.checkPositionWithEventLoop, this));
|
31 |
+
|
32 |
+
this.$element = $(element);
|
33 |
+
this.mtphr_dnt_affixed = null;
|
34 |
+
this.unpin = null;
|
35 |
+
this.pinnedOffset = null;
|
36 |
+
|
37 |
+
this.checkPosition();
|
38 |
+
};
|
39 |
+
|
40 |
+
MTPHR_DNT_Affix.VERSION = '3.3.5';
|
41 |
+
|
42 |
+
MTPHR_DNT_Affix.RESET = 'mtphr_dnt_affix mtphr_dnt_affix-top mtphr_dnt_affix-bottom';
|
43 |
+
|
44 |
+
MTPHR_DNT_Affix.DEFAULTS = {
|
45 |
+
offset: 0,
|
46 |
+
target: window
|
47 |
+
};
|
48 |
+
|
49 |
+
MTPHR_DNT_Affix.prototype.getState = function (scrollHeight, height, offsetTop, offsetBottom) {
|
50 |
+
var scrollTop = this.$target.scrollTop();
|
51 |
+
var position = this.$element.offset();
|
52 |
+
var targetHeight = this.$target.height();
|
53 |
+
|
54 |
+
if (offsetTop !== null && this.mtphr_dnt_affixed === 'top') {
|
55 |
+
return scrollTop < offsetTop ? 'top' : false;
|
56 |
+
}
|
57 |
+
|
58 |
+
if (this.mtphr_dnt_affixed === 'bottom') {
|
59 |
+
if (offsetTop !== null) {
|
60 |
+
return (scrollTop + this.unpin <= position.top) ? false : 'bottom';
|
61 |
+
}
|
62 |
+
return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom';
|
63 |
+
}
|
64 |
+
|
65 |
+
var initializing = this.mtphr_dnt_affixed === null;
|
66 |
+
var colliderTop = initializing ? scrollTop : position.top;
|
67 |
+
var colliderHeight = initializing ? targetHeight : height;
|
68 |
+
|
69 |
+
if (offsetTop !== null && scrollTop <= offsetTop) {
|
70 |
+
return 'top';
|
71 |
+
}
|
72 |
+
if (offsetBottom !== null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) {
|
73 |
+
return 'bottom';
|
74 |
+
}
|
75 |
+
|
76 |
+
return false;
|
77 |
+
};
|
78 |
+
|
79 |
+
MTPHR_DNT_Affix.prototype.getPinnedOffset = function () {
|
80 |
+
if (this.pinnedOffset) {
|
81 |
+
return this.pinnedOffset;
|
82 |
+
}
|
83 |
+
this.$element.removeClass(MTPHR_DNT_Affix.RESET).addClass('mtphr_dnt_affix');
|
84 |
+
var scrollTop = this.$target.scrollTop();
|
85 |
+
var position = this.$element.offset();
|
86 |
+
return (this.pinnedOffset = position.top - scrollTop);
|
87 |
+
};
|
88 |
+
|
89 |
+
MTPHR_DNT_Affix.prototype.checkPositionWithEventLoop = function () {
|
90 |
+
setTimeout($.proxy(this.checkPosition, this), 1);
|
91 |
+
};
|
92 |
+
|
93 |
+
MTPHR_DNT_Affix.prototype.checkPosition = function () {
|
94 |
+
if (!this.$element.is(':visible')) {
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
|
98 |
+
var height = this.$element.height();
|
99 |
+
var offset = this.options.offset;
|
100 |
+
var offsetTop = offset.top;
|
101 |
+
var offsetBottom = offset.bottom;
|
102 |
+
var scrollHeight = Math.max($(document).height(), $(document.body).height());
|
103 |
+
|
104 |
+
if (typeof offset !== 'object') {
|
105 |
+
offsetBottom = offsetTop = offset;
|
106 |
+
}
|
107 |
+
if (typeof offsetTop === 'function') {
|
108 |
+
offsetTop = offset.top(this.$element);
|
109 |
+
}
|
110 |
+
if (typeof offsetBottom === 'function') {
|
111 |
+
offsetBottom = offset.bottom(this.$element);
|
112 |
+
}
|
113 |
+
|
114 |
+
var mtphr_dnt_affix = this.getState(scrollHeight, height, offsetTop, offsetBottom);
|
115 |
+
|
116 |
+
if (this.mtphr_dnt_affixed !== mtphr_dnt_affix) {
|
117 |
+
if (this.unpin !== null) {
|
118 |
+
this.$element.css('top', '');
|
119 |
+
}
|
120 |
+
|
121 |
+
var mtphr_dnt_affixType = 'mtphr_dnt_affix' + (mtphr_dnt_affix ? '-' + mtphr_dnt_affix : '');
|
122 |
+
var e = $.Event(mtphr_dnt_affixType + '.bs.mtphr_dnt_affix');
|
123 |
+
|
124 |
+
this.$element.trigger(e);
|
125 |
+
|
126 |
+
if (e.isDefaultPrevented()) {
|
127 |
+
return;
|
128 |
+
}
|
129 |
+
|
130 |
+
this.mtphr_dnt_affixed = mtphr_dnt_affix;
|
131 |
+
this.unpin = mtphr_dnt_affix === 'bottom' ? this.getPinnedOffset() : null;
|
132 |
+
|
133 |
+
this.$element
|
134 |
+
.removeClass(MTPHR_DNT_Affix.RESET)
|
135 |
+
.addClass(mtphr_dnt_affixType)
|
136 |
+
.trigger(mtphr_dnt_affixType.replace('mtphr_dnt_affix', 'mtphr_dnt_affixed') + '.bs.mtphr_dnt_affix');
|
137 |
+
}
|
138 |
+
|
139 |
+
if (mtphr_dnt_affix === 'bottom') {
|
140 |
+
this.$element.offset({
|
141 |
+
top: scrollHeight - height - offsetBottom
|
142 |
+
});
|
143 |
+
}
|
144 |
+
};
|
145 |
+
|
146 |
+
|
147 |
+
// AFFIX PLUGIN DEFINITION
|
148 |
+
// =======================
|
149 |
+
|
150 |
+
function Plugin(option) {
|
151 |
+
return this.each(function () {
|
152 |
+
var $this = $(this);
|
153 |
+
var data = $this.data('bs.mtphr_dnt_affix');
|
154 |
+
var options = typeof option === 'object' && option;
|
155 |
+
|
156 |
+
if (!data) {
|
157 |
+
$this.data('bs.mtphr_dnt_affix', (data = new MTPHR_DNT_Affix(this, options)));
|
158 |
+
}
|
159 |
+
if (typeof option === 'string') {
|
160 |
+
data[option]();
|
161 |
+
}
|
162 |
+
});
|
163 |
+
}
|
164 |
+
|
165 |
+
var old = $.fn.mtphr_dnt_affix;
|
166 |
+
|
167 |
+
$.fn.mtphr_dnt_affix = Plugin;
|
168 |
+
$.fn.mtphr_dnt_affix.Constructor = MTPHR_DNT_Affix;
|
169 |
+
|
170 |
+
|
171 |
+
// AFFIX NO CONFLICT
|
172 |
+
// =================
|
173 |
+
|
174 |
+
$.fn.mtphr_dnt_affix.noConflict = function () {
|
175 |
+
$.fn.mtphr_dnt_affix = old;
|
176 |
+
return this;
|
177 |
+
};
|
178 |
+
|
179 |
+
|
180 |
+
// AFFIX DATA-API
|
181 |
+
// ==============
|
182 |
+
|
183 |
+
$(window).on('load', function () {
|
184 |
+
$('[data-spy="mtphr_dnt_affix"]').each(function () {
|
185 |
+
var $spy = $(this);
|
186 |
+
var data = $spy.data();
|
187 |
+
|
188 |
+
data.offset = data.offset || {};
|
189 |
+
|
190 |
+
if (data.offsetBottom !== null) {
|
191 |
+
data.offset.bottom = data.offsetBottom;
|
192 |
+
}
|
193 |
+
if (data.offsetTop !== null) {
|
194 |
+
data.offset.top = data.offsetTop;
|
195 |
+
}
|
196 |
+
|
197 |
+
Plugin.call($spy, data);
|
198 |
+
});
|
199 |
+
});
|
200 |
+
|
201 |
+
}(jQuery));
|
202 |
+
|
203 |
+
|
204 |
+
jQuery( function($) {
|
205 |
+
|
206 |
+
var $settings_select = $('#mtphr-dnt-settings-select'),
|
207 |
+
$admin_bar = $('#wpadminbar');
|
208 |
+
|
209 |
+
|
210 |
+
/* --------------------------------------------------------- */
|
211 |
+
/* !Affix the menu bar - 2.0.1 */
|
212 |
+
/* --------------------------------------------------------- */
|
213 |
+
|
214 |
+
$settings_select.mtphr_dnt_affix({
|
215 |
+
offset: {
|
216 |
+
top: function () {
|
217 |
+
if( $(window).width() < 601 ) {
|
218 |
+
return (this.top = $settings_select.offset().top + 5);
|
219 |
+
} else {
|
220 |
+
return (this.top = $settings_select.offset().top - $admin_bar.height() + 5);
|
221 |
+
}
|
222 |
+
}
|
223 |
+
}
|
224 |
+
});
|
225 |
+
|
226 |
+
|
227 |
+
/* --------------------------------------------------------- */
|
228 |
+
/* !Main settings selects - 2.0.0 */
|
229 |
+
/* --------------------------------------------------------- */
|
230 |
+
|
231 |
+
$('#mtphr-dnt-metabox-group-toggles').on( 'click', '.mtphr-dnt-metabox-group-toggle', function(e) {
|
232 |
+
e.preventDefault();
|
233 |
+
|
234 |
+
var value = $(this).attr('href');
|
235 |
+
|
236 |
+
$('.mtphr-dnt-metabox-group-toggle').removeClass('active');
|
237 |
+
$('.mtphr-dnt-metabox-group').removeClass('active');
|
238 |
+
|
239 |
+
$(this).addClass('active');
|
240 |
+
$(value).addClass('active');
|
241 |
+
|
242 |
+
// Set the input data
|
243 |
+
$('input[name="_mtphr_dnt_admin_tab"]').val( value );
|
244 |
+
});
|
245 |
+
|
246 |
+
|
247 |
+
/* --------------------------------------------------------- */
|
248 |
+
/* !Initiate the CodeMirror fields - 1.4.0 */
|
249 |
+
/* --------------------------------------------------------- */
|
250 |
+
|
251 |
+
$('.mtphr-dnt-codemirror-css').each( function() {
|
252 |
+
|
253 |
+
var $textarea = $(this).children('textarea');
|
254 |
+
CodeMirror.fromTextArea($textarea[0], {
|
255 |
+
'mode' : 'css',
|
256 |
+
'lineNumbers' : true,
|
257 |
+
'lineWrapping' : true,
|
258 |
+
'viewportMargin' : Infinity
|
259 |
+
});
|
260 |
+
//myCodeMirror.setSize( false, false );
|
261 |
+
});
|
262 |
+
|
263 |
+
$('.mtphr-dnt-codemirror-js').each( function() {
|
264 |
+
|
265 |
+
var $textarea = $(this).children('textarea');
|
266 |
+
var myCodeMirror = CodeMirror.fromTextArea($textarea[0], {
|
267 |
+
'mode' : 'htmlmixed',
|
268 |
+
'lineNumbers' : true,
|
269 |
+
'lineWrapping' : true
|
270 |
+
});
|
271 |
+
myCodeMirror.setSize( false, 140 );
|
272 |
+
});
|
273 |
+
|
274 |
+
|
275 |
+
/* --------------------------------------------------------- */
|
276 |
+
/* !Ensure javascript is working - 2.0.0 */
|
277 |
+
/* --------------------------------------------------------- */
|
278 |
+
|
279 |
+
if( $('input[name="_mtphr_dnt_admin_javascript"]').length ) {
|
280 |
+
$('input[name="_mtphr_dnt_admin_javascript"]').val('ok');
|
281 |
+
}
|
282 |
+
|
283 |
+
|
284 |
+
|
285 |
+
/* --------------------------------------------------------- */
|
286 |
+
/* !Metabox toggles - 2.0.0 */
|
287 |
+
/* --------------------------------------------------------- */
|
288 |
+
|
289 |
+
function mtphr_dnt_toggle_metaboxes( $button, kind ) {
|
290 |
+
|
291 |
+
// Set the metaboxes
|
292 |
+
$('#mtphr-dnt-'+kind+'-metaboxes > div').stop(true, true).hide();
|
293 |
+
var metaboxes = $button.attr('metabox').split(' ');
|
294 |
+
for( var i=0; i < metaboxes.length; i++ ) {
|
295 |
+
$('#'+metaboxes[i]).show();
|
296 |
+
}
|
297 |
+
|
298 |
+
// Set the button classes
|
299 |
+
$button.siblings('a').removeClass('button-primary');
|
300 |
+
$button.addClass('button-primary');
|
301 |
+
|
302 |
+
// Store the new value
|
303 |
+
$button.siblings('input').val($button.attr('href').substring(1));
|
304 |
+
}
|
305 |
+
|
306 |
+
if( $('.mtphr-dnt-type-toggle.button-primary').length ) {
|
307 |
+
mtphr_dnt_toggle_metaboxes( $('.mtphr-dnt-type-toggle.button-primary'), 'type' );
|
308 |
+
}
|
309 |
+
|
310 |
+
if( $('.mtphr-dnt-mode-toggle.button-primary').length ) {
|
311 |
+
mtphr_dnt_toggle_metaboxes( $('.mtphr-dnt-mode-toggle.button-primary'), 'mode' );
|
312 |
+
}
|
313 |
+
|
314 |
+
$('#mtphr-dnt-type-select').on( 'click', '.mtphr-dnt-type-toggle', function(e) {
|
315 |
+
|
316 |
+
e.preventDefault();
|
317 |
+
if( !$(this).hasClass('button-primary') ) {
|
318 |
+
mtphr_dnt_toggle_metaboxes( $(this), 'type' );
|
319 |
+
}
|
320 |
+
});
|
321 |
+
|
322 |
+
$('#mtphr-dnt-mode-select').on( 'click', '.mtphr-dnt-mode-toggle', function(e) {
|
323 |
+
|
324 |
+
e.preventDefault();
|
325 |
+
if( !$(this).hasClass('button-primary') ) {
|
326 |
+
mtphr_dnt_toggle_metaboxes( $(this), 'mode' );
|
327 |
+
}
|
328 |
+
});
|
329 |
+
|
330 |
+
|
331 |
+
|
332 |
+
/* --------------------------------------------------------- */
|
333 |
+
/* !Sort list - 1.4.4 */
|
334 |
+
/* --------------------------------------------------------- */
|
335 |
+
|
336 |
+
if( $('.mtphr-dnt-sort').length > 0 ) {
|
337 |
+
|
338 |
+
$('.mtphr-dnt-sort').sortable( {
|
339 |
+
handle: '.mtphr-dnt-sort-heading',
|
340 |
+
items: '.mtphr-dnt-sort-item',
|
341 |
+
axis: 'y',
|
342 |
+
opacity: 0.7,
|
343 |
+
placeholder: {
|
344 |
+
element: function(currentItem) {
|
345 |
+
var height = $(currentItem).innerHeight();
|
346 |
+
return $('<div class="mtphr-dnt-sort-placeholder" style="height:'+height+'px;"></div>')[0];
|
347 |
+
},
|
348 |
+
update: function() {
|
349 |
+
return;
|
350 |
+
}
|
351 |
+
},
|
352 |
+
helper: function(e, tr) {
|
353 |
+
var $originals = tr.children();
|
354 |
+
var $helper = tr.clone();
|
355 |
+
$helper.children().each(function(index) {
|
356 |
+
$(this).width($originals.eq(index).width());
|
357 |
+
$(this).height($originals.eq(index).height());
|
358 |
+
});
|
359 |
+
return $helper;
|
360 |
+
},
|
361 |
+
});
|
362 |
+
|
363 |
+
$('body').on( 'click', '.mtphr-dnt-sort-heading.optional', function(e) {
|
364 |
+
e.preventDefault();
|
365 |
+
|
366 |
+
var $container = $(this).parents('.mtphr-dnt-sort-item'),
|
367 |
+
$content = $(this).next('.mtphr-dnt-sort-item-fields'),
|
368 |
+
$input = $(this).children('input');
|
369 |
+
|
370 |
+
if( $container.hasClass('active') ) {
|
371 |
+
$container.removeClass('active');
|
372 |
+
$input.val('off');
|
373 |
+
if( $content.length ) {
|
374 |
+
$content.stop(true,true).slideUp( 1000, 'easeOutQuint' );
|
375 |
+
}
|
376 |
+
} else {
|
377 |
+
$container.addClass('active');
|
378 |
+
$input.val('on');
|
379 |
+
if( $content.length ) {
|
380 |
+
$content.stop(true,true).slideDown( 1000, 'easeOutQuint' );
|
381 |
+
}
|
382 |
+
}
|
383 |
+
});
|
384 |
+
}
|
385 |
+
|
386 |
+
|
387 |
+
/* --------------------------------------------------------- */
|
388 |
+
/* !List - 2.0.0 */
|
389 |
+
/* --------------------------------------------------------- */
|
390 |
+
|
391 |
+
$('.mtphr-dnt-list').mtphr_dnt_list();
|
392 |
+
|
393 |
+
|
394 |
+
/* --------------------------------------------------------- */
|
395 |
+
/* !Single image upload - 2.0.0 */
|
396 |
+
/* --------------------------------------------------------- */
|
397 |
+
|
398 |
+
// Delete an image
|
399 |
+
$('body').on( 'click', '.mtphr-dnt-single-image .mtphr-dnt-delete', function(e) {
|
400 |
+
e.preventDefault();
|
401 |
+
|
402 |
+
var $image = $(this).parent(),
|
403 |
+
$button = $image.siblings('.mtphr-dnt-single-image-upload'),
|
404 |
+
$input = $image.siblings('input');
|
405 |
+
|
406 |
+
$input.val('');
|
407 |
+
$image.remove();
|
408 |
+
$button.show();
|
409 |
+
});
|
410 |
+
|
411 |
+
// Add an image
|
412 |
+
$('body').on( 'click', '.mtphr-dnt-single-image-upload', function(e) {
|
413 |
+
e.preventDefault();
|
414 |
+
|
415 |
+
// Save the container
|
416 |
+
var $button = $(this),
|
417 |
+
$container = $button.parent(),
|
418 |
+
$input = $container.children('input');
|
419 |
+
|
420 |
+
// Create a custom uploader
|
421 |
+
var uploader;
|
422 |
+
if( uploader ) {
|
423 |
+
uploader.open();
|
424 |
+
return;
|
425 |
+
}
|
426 |
+
|
427 |
+
// Set the uploader attributes
|
428 |
+
uploader = wp.media({
|
429 |
+
title: ditty_news_ticker_vars.img_title,
|
430 |
+
button: { text: ditty_news_ticker_vars.img_button, size: 'small' },
|
431 |
+
multiple: false,
|
432 |
+
library : {
|
433 |
+
type : 'image'
|
434 |
+
}
|
435 |
+
});
|
436 |
+
|
437 |
+
uploader.on( 'select', function() {
|
438 |
+
|
439 |
+
var attachments = uploader.state().get('selection').toJSON();
|
440 |
+
if( attachments.length > 0 ) {
|
441 |
+
|
442 |
+
$input.val(attachments[0].id);
|
443 |
+
|
444 |
+
// Create the display
|
445 |
+
var data = {
|
446 |
+
action: 'mtphr_dnt_single_image_ajax',
|
447 |
+
attachment: attachments[0],
|
448 |
+
security: ditty_news_ticker_vars.security
|
449 |
+
};
|
450 |
+
jQuery.post( ajaxurl, data, function( response ) {
|
451 |
+
$button.hide();
|
452 |
+
$container.append( response );
|
453 |
+
});
|
454 |
+
}
|
455 |
+
});
|
456 |
+
|
457 |
+
//Open the uploader dialog
|
458 |
+
uploader.open();
|
459 |
+
|
460 |
+
return false;
|
461 |
+
});
|
462 |
+
|
463 |
+
|
464 |
+
/* --------------------------------------------------------- */
|
465 |
+
/* !Tool tips - 2.0.0 */
|
466 |
+
/* --------------------------------------------------------- */
|
467 |
+
|
468 |
+
// Setup protip
|
469 |
+
$.protip( {
|
470 |
+
defaults: {
|
471 |
+
position: 'top',
|
472 |
+
size: 'small',
|
473 |
+
scheme: 'black',
|
474 |
+
classes: 'ditty-protip',
|
475 |
+
}
|
476 |
+
} );
|
477 |
+
|
478 |
+
|
479 |
+
|
480 |
+
/* --------------------------------------------------------- */
|
481 |
+
/* !Mixed tick list - 2.0.0 */
|
482 |
+
/* --------------------------------------------------------- */
|
483 |
+
|
484 |
+
function mtphr_dnt_mixed_ticks_all( $field ) {
|
485 |
+
|
486 |
+
var checked = $field.find('input').is(':checked');
|
487 |
+
if( checked ) {
|
488 |
+
$field.next().fadeOut();
|
489 |
+
} else {
|
490 |
+
$field.next().fadeIn();
|
491 |
+
}
|
492 |
+
}
|
493 |
+
|
494 |
+
$('body').on( 'click', '.mtphr-dnt-list-field-mtphr_dnt_mixed_ticks_all input', function() {
|
495 |
+
mtphr_dnt_mixed_ticks_all( $(this).parents('.mtphr-dnt-list-field-mtphr_dnt_mixed_ticks_all') );
|
496 |
+
});
|
497 |
+
|
498 |
+
$('.mtphr-dnt-list-field-mtphr_dnt_mixed_ticks_all').each( function() {
|
499 |
+
mtphr_dnt_mixed_ticks_all( $(this) );
|
500 |
+
});
|
501 |
+
|
502 |
+
|
503 |
+
/* --------------------------------------------------------- */
|
504 |
+
/* !First tick on init */
|
505 |
+
/* --------------------------------------------------------- */
|
506 |
+
|
507 |
+
function mtphr_dnt_init_tick( $field ) {
|
508 |
+
if ( $field.is( ':checked' ) ) {
|
509 |
+
$( '.mtphr-dnt-field-mtphr_dnt_scroll_init_delay' ).show();
|
510 |
+
} else {
|
511 |
+
$( '.mtphr-dnt-field-mtphr_dnt_scroll_init_delay' ).hide();
|
512 |
+
}
|
513 |
+
}
|
514 |
+
|
515 |
+
$('body').on( 'click', 'input[name="_mtphr_dnt_scroll_init"]', function() {
|
516 |
+
mtphr_dnt_init_tick( $(this) );
|
517 |
+
});
|
518 |
+
|
519 |
+
if ( $( 'input[name="_mtphr_dnt_scroll_init"]').length ) {
|
520 |
+
mtphr_dnt_init_tick( $( 'input[name="_mtphr_dnt_scroll_init"]') );
|
521 |
+
}
|
522 |
+
|
523 |
+
});
|
524 |
+
|
525 |
+
|
526 |
+
|
527 |
+
/* --------------------------------------------------------- */
|
528 |
+
/* !List */
|
529 |
+
/* --------------------------------------------------------- */
|
530 |
+
|
531 |
+
( function($) {
|
532 |
+
|
533 |
+
var methods = {
|
534 |
+
|
535 |
+
init : function( options ) {
|
536 |
+
|
537 |
+
return this.each( function(){
|
538 |
+
|
539 |
+
// Create default options
|
540 |
+
var settings = {
|
541 |
+
};
|
542 |
+
|
543 |
+
// Add any set options
|
544 |
+
if (options) {
|
545 |
+
$.extend(settings, options);
|
546 |
+
}
|
547 |
+
|
548 |
+
var $table = $(this);
|
549 |
+
// Setup protip
|
550 |
+
$.protip( {
|
551 |
+
defaults: {
|
552 |
+
position: 'top',
|
553 |
+
size: 'small',
|
554 |
+
scheme: 'black',
|
555 |
+
classes: 'ditty-protip',
|
556 |
+
}
|
557 |
+
} );
|
558 |
+
|
559 |
+
$table.sortable( {
|
560 |
+
handle: '.mtphr-dnt-list-heading > .dashicons-menu',
|
561 |
+
items: '.mtphr-dnt-list-item',
|
562 |
+
axis: 'y',
|
563 |
+
opacity: 0.7,
|
564 |
+
placeholder: {
|
565 |
+
element: function(currentItem) {
|
566 |
+
var height = $(currentItem).innerHeight();
|
567 |
+
return $('<div class="mtphr-dnt-sort-placeholder" style="height:'+height+'px;"></div>')[0];
|
568 |
+
},
|
569 |
+
update: function() {
|
570 |
+
return;
|
571 |
+
}
|
572 |
+
},
|
573 |
+
helper: function(e, tr) {
|
574 |
+
var $originals = tr.children();
|
575 |
+
var $helper = tr.clone();
|
576 |
+
$helper.children().each(function(index) {
|
577 |
+
$(this).width($originals.eq(index).width());
|
578 |
+
$(this).height($originals.eq(index).height());
|
579 |
+
});
|
580 |
+
return $helper;
|
581 |
+
},
|
582 |
+
start: function( e, ui ) {
|
583 |
+
var $item = $( ui.item );
|
584 |
+
//$item.parents( '.mtphr-dnt-field-mtphr_dnt_ticks' ).find( '.mtphr-dnt-list-item-contents' ).hide();
|
585 |
+
if ( $item.find('.wp-editor-container').length ) {
|
586 |
+
var id = $item.find( '.wp-editor-area' ).attr('id');
|
587 |
+
tinyMCE.execCommand( 'mceRemoveEditor', true, id );
|
588 |
+
}
|
589 |
+
},
|
590 |
+
stop: function( e, ui ) {
|
591 |
+
var $item = $( ui.item );
|
592 |
+
//$item.parents( '.mtphr-dnt-field-mtphr_dnt_ticks' ).find( '.mtphr-dnt-list-item-contents' ).show();
|
593 |
+
if ( $item.find('.wp-editor-container').length ) {
|
594 |
+
var id = $item.find( '.wp-editor-area' ).attr('id');
|
595 |
+
tinyMCE.execCommand( 'mceAddEditor', true, id );
|
596 |
+
}
|
597 |
+
},
|
598 |
+
});
|
599 |
+
|
600 |
+
function mtphr_dnt_list_handle_toggle() {
|
601 |
+
|
602 |
+
if( $table.find('.mtphr-dnt-list-item').length > 1 ) {
|
603 |
+
$table.find('.mtphr-dnt-list-handle').show();
|
604 |
+
$table.find('.mtphr-dnt-list-delete').show();
|
605 |
+
} else {
|
606 |
+
$table.find('.mtphr-dnt-list-handle').hide();
|
607 |
+
$table.find('.mtphr-dnt-list-delete').hide();
|
608 |
+
}
|
609 |
+
}
|
610 |
+
|
611 |
+
function mtphr_dnt_list_set_order() {
|
612 |
+
|
613 |
+
$table.find('.mtphr-dnt-list-item').each( function(index) {
|
614 |
+
$(this).find('textarea, input, select').each( function() {
|
615 |
+
|
616 |
+
var name, key;
|
617 |
+
|
618 |
+
if( $(this).hasClass('wp-editor-area') ) {
|
619 |
+
|
620 |
+
var $parent = $(this).parents('.mtphr-dnt-field-type-wysiwyg');
|
621 |
+
name = $parent.attr('data-name');
|
622 |
+
key = $parent.attr('data-key');
|
623 |
+
|
624 |
+
} else {
|
625 |
+
|
626 |
+
name = $(this).attr('data-name');
|
627 |
+
key = $(this).attr('data-key');
|
628 |
+
}
|
629 |
+
|
630 |
+
if( name && key ) {
|
631 |
+
$(this).attr('name', name+'['+index+']['+key+']');
|
632 |
+
}
|
633 |
+
});
|
634 |
+
});
|
635 |
+
|
636 |
+
mtphr_dnt_list_handle_toggle();
|
637 |
+
}
|
638 |
+
|
639 |
+
function mtphr_dnt_list_add_item( $item, unique_class ) {
|
640 |
+
|
641 |
+
// Save the container
|
642 |
+
var $dup = $item.clone();
|
643 |
+
|
644 |
+
// Reset the duplicate
|
645 |
+
$dup.find('textarea, input, select').each( function() {
|
646 |
+
if( $(this).attr('type') === 'checkbox' || $(this).attr('type') === 'radio' ) {
|
647 |
+
$(this).attr('checked', false);
|
648 |
+
} else {
|
649 |
+
$(this).val('');
|
650 |
+
}
|
651 |
+
});
|
652 |
+
|
653 |
+
// Setup new wysiwyg editors
|
654 |
+
$dup.find('textarea').each( function() {
|
655 |
+
if( $(this).hasClass('wp-editor-area') ) {
|
656 |
+
|
657 |
+
var $parent = $(this).parents('.mtphr-dnt-field-type-wysiwyg'),
|
658 |
+
name = $parent.attr('data-name');
|
659 |
+
|
660 |
+
$parent.children('.wp-core-ui').remove();
|
661 |
+
|
662 |
+
// Create the display
|
663 |
+
var data = {
|
664 |
+
action: 'mtphr_dnt_wysiwyg_ajax',
|
665 |
+
name: name,
|
666 |
+
security: ditty_news_ticker_vars.security
|
667 |
+
};
|
668 |
+
jQuery.post( ajaxurl, data, function( response ) {
|
669 |
+
|
670 |
+
var $editor = $(response),
|
671 |
+
id = $editor.find('textarea').attr('id');
|
672 |
+
|
673 |
+
$parent.append( response );
|
674 |
+
|
675 |
+
if( typeof(tinyMCE) === 'object' && typeof(tinyMCE.execCommand) === 'function' ) {
|
676 |
+
tinyMCE.execCommand("mceAddEditor", false, id);
|
677 |
+
}
|
678 |
+
|
679 |
+
// Set the order
|
680 |
+
mtphr_dnt_list_set_order();
|
681 |
+
});
|
682 |
+
|
683 |
+
}
|
684 |
+
});
|
685 |
+
|
686 |
+
// Add the duplicate
|
687 |
+
$dup.hide();
|
688 |
+
$item.after( $dup );
|
689 |
+
$dup.fadeIn().addClass(unique_class);
|
690 |
+
|
691 |
+
// Setup protip
|
692 |
+
$.protip( {
|
693 |
+
defaults: {
|
694 |
+
position: 'top',
|
695 |
+
size: 'small',
|
696 |
+
scheme: 'black',
|
697 |
+
classes: 'ditty-protip',
|
698 |
+
}
|
699 |
+
} );
|
700 |
+
|
701 |
+
// Set the order
|
702 |
+
mtphr_dnt_list_set_order();
|
703 |
+
|
704 |
+
// Trigger an added event
|
705 |
+
$table.trigger('mtphr_dnt_list_item_added', [$dup, unique_class]);
|
706 |
+
}
|
707 |
+
|
708 |
+
// Delete list item
|
709 |
+
$table.on( 'click', '.mtphr-dnt-list-delete', function(e) {
|
710 |
+
e.preventDefault();
|
711 |
+
|
712 |
+
// Fade out the item
|
713 |
+
$(this).parents('.mtphr-dnt-list-item').fadeOut( function() {
|
714 |
+
$(this).remove();
|
715 |
+
mtphr_dnt_list_set_order();
|
716 |
+
});
|
717 |
+
});
|
718 |
+
|
719 |
+
// Add new row
|
720 |
+
$table.on( 'click', '.mtphr-dnt-list-add', function(e) {
|
721 |
+
e.preventDefault();
|
722 |
+
mtphr_dnt_list_add_item( $(this).parents('.mtphr-dnt-list-item') );
|
723 |
+
});
|
724 |
+
|
725 |
+
|
726 |
+
$table.on('mtphr_dnt_list_add_item', function( e, item, unique_class ) {
|
727 |
+
mtphr_dnt_list_add_item( item, unique_class );
|
728 |
+
});
|
729 |
+
|
730 |
+
mtphr_dnt_list_set_order();
|
731 |
+
|
732 |
+
});
|
733 |
+
}
|
734 |
+
};
|
735 |
+
|
736 |
+
/**
|
737 |
+
* Setup the list
|
738 |
+
*
|
739 |
+
* @since 1.0.0
|
740 |
+
*/
|
741 |
+
$.fn.mtphr_dnt_list = function( method ) {
|
742 |
+
|
743 |
+
if ( methods[method] ) {
|
744 |
+
return methods[method].apply( this, Array.prototype.slice.call(arguments, 1) );
|
745 |
+
} else if ( typeof method === 'object' || !method ) {
|
746 |
+
return methods.init.apply( this, arguments );
|
747 |
+
} else {
|
748 |
+
throw new Error( 'Method ' + method + ' does not exist in mtphr_dnt_list' );
|
749 |
+
}
|
750 |
+
};
|
751 |
+
|
752 |
+
})( jQuery );
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: ticker, post ticker, news ticker, content aggregator, latest posts, live refresh, rotator, data rotator, lists, data, aggregator
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 5.9
|
7 |
-
Stable tag: 3.0.
|
8 |
License: GPL2
|
9 |
|
10 |
Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
|
@@ -66,6 +66,23 @@ The most common cause for an unresponsive Ditty (when using scroll or rotate mod
|
|
66 |
|
67 |
== Changelog ==
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
= 3.0.11 =
|
70 |
* Resolved bug in ditty_add_scripts function that was causing a javascript error
|
71 |
* Only possibly load cached ditty on live_updates
|
@@ -638,4 +655,4 @@ The most common cause for an unresponsive Ditty (when using scroll or rotate mod
|
|
638 |
|
639 |
== Upgrade Notice ==
|
640 |
|
641 |
-
Multiple updates
|
4 |
Tags: ticker, post ticker, news ticker, content aggregator, latest posts, live refresh, rotator, data rotator, lists, data, aggregator
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 5.9
|
7 |
+
Stable tag: 3.0.12
|
8 |
License: GPL2
|
9 |
|
10 |
Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
|
66 |
|
67 |
== Changelog ==
|
68 |
|
69 |
+
= 3.0.12 =
|
70 |
+
* Modified custom display check when rendering Ditty
|
71 |
+
* Resolved current Item(s) bug in Ditty Editor
|
72 |
+
* Resolved current Item Type bug in Ditty Editor
|
73 |
+
* Modified Default Post Layout and increased version number
|
74 |
+
* Added init trigger for Ditty_Item_Editor_Panel js file
|
75 |
+
* Removed jQuery document ready in all js files
|
76 |
+
* Added link options to Posts Feed Lite
|
77 |
+
* Added content options to Posts Feed Lite
|
78 |
+
* Radio field update
|
79 |
+
* Asset loading optimization
|
80 |
+
* Added file field type
|
81 |
+
* Added item_value to layout tag filters
|
82 |
+
* Removed auto-draft checks
|
83 |
+
* Customized plugin updater file and references
|
84 |
+
* Resolved bug in extension updater
|
85 |
+
|
86 |
= 3.0.11 =
|
87 |
* Resolved bug in ditty_add_scripts function that was causing a javascript error
|
88 |
* Only possibly load cached ditty on live_updates
|
655 |
|
656 |
== Upgrade Notice ==
|
657 |
|
658 |
+
Resolved bug in extension updater. Multiple other updates.
|
vendor/composer/InstalledVersions.php
CHANGED
@@ -19,7 +19,7 @@ private static $installed = array (
|
|
19 |
'aliases' =>
|
20 |
array (
|
21 |
),
|
22 |
-
'reference' => '
|
23 |
'name' => '__root__',
|
24 |
),
|
25 |
'versions' =>
|
@@ -31,7 +31,7 @@ private static $installed = array (
|
|
31 |
'aliases' =>
|
32 |
array (
|
33 |
),
|
34 |
-
'reference' => '
|
35 |
),
|
36 |
'composer/installers' =>
|
37 |
array (
|
@@ -69,12 +69,12 @@ private static $installed = array (
|
|
69 |
),
|
70 |
'scssphp/scssphp' =>
|
71 |
array (
|
72 |
-
'pretty_version' => 'v1.
|
73 |
-
'version' => '1.
|
74 |
'aliases' =>
|
75 |
array (
|
76 |
),
|
77 |
-
'reference' => '
|
78 |
),
|
79 |
'shama/baton' =>
|
80 |
array (
|
@@ -85,12 +85,12 @@ private static $installed = array (
|
|
85 |
),
|
86 |
'thunderer/shortcode' =>
|
87 |
array (
|
88 |
-
'pretty_version' => 'v0.7.
|
89 |
-
'version' => '0.7.
|
90 |
'aliases' =>
|
91 |
array (
|
92 |
),
|
93 |
-
'reference' => '
|
94 |
),
|
95 |
),
|
96 |
);
|
19 |
'aliases' =>
|
20 |
array (
|
21 |
),
|
22 |
+
'reference' => '3d85d247ec6eed8ec21065f1ec0e66499ea986bf',
|
23 |
'name' => '__root__',
|
24 |
),
|
25 |
'versions' =>
|
31 |
'aliases' =>
|
32 |
array (
|
33 |
),
|
34 |
+
'reference' => '3d85d247ec6eed8ec21065f1ec0e66499ea986bf',
|
35 |
),
|
36 |
'composer/installers' =>
|
37 |
array (
|
69 |
),
|
70 |
'scssphp/scssphp' =>
|
71 |
array (
|
72 |
+
'pretty_version' => 'v1.10.0',
|
73 |
+
'version' => '1.10.0.0',
|
74 |
'aliases' =>
|
75 |
array (
|
76 |
),
|
77 |
+
'reference' => '9699a52a862da4efb43985943afa17150155dd3d',
|
78 |
),
|
79 |
'shama/baton' =>
|
80 |
array (
|
85 |
),
|
86 |
'thunderer/shortcode' =>
|
87 |
array (
|
88 |
+
'pretty_version' => 'v0.7.5',
|
89 |
+
'version' => '0.7.5.0',
|
90 |
'aliases' =>
|
91 |
array (
|
92 |
),
|
93 |
+
'reference' => 'a4fee30613bd46efb421f8305aff0466a3268a99',
|
94 |
),
|
95 |
),
|
96 |
);
|
vendor/composer/installed.json
CHANGED
@@ -254,17 +254,17 @@
|
|
254 |
},
|
255 |
{
|
256 |
"name": "scssphp/scssphp",
|
257 |
-
"version": "v1.
|
258 |
-
"version_normalized": "1.
|
259 |
"source": {
|
260 |
"type": "git",
|
261 |
"url": "https://github.com/scssphp/scssphp.git",
|
262 |
-
"reference": "
|
263 |
},
|
264 |
"dist": {
|
265 |
"type": "zip",
|
266 |
-
"url": "https://api.github.com/repos/scssphp/scssphp/zipball/
|
267 |
-
"reference": "
|
268 |
"shasum": ""
|
269 |
},
|
270 |
"require": {
|
@@ -280,14 +280,14 @@
|
|
280 |
"symfony/phpunit-bridge": "^5.1",
|
281 |
"thoughtbot/bourbon": "^7.0",
|
282 |
"twbs/bootstrap": "~5.0",
|
283 |
-
"twbs/bootstrap4": "4.6.
|
284 |
"zurb/foundation": "~6.5"
|
285 |
},
|
286 |
"suggest": {
|
287 |
"ext-iconv": "Can be used as fallback when ext-mbstring is not available",
|
288 |
"ext-mbstring": "For best performance, mbstring should be installed as it is faster than ext-iconv"
|
289 |
},
|
290 |
-
"time": "
|
291 |
"bin": [
|
292 |
"bin/pscss"
|
293 |
],
|
@@ -325,23 +325,23 @@
|
|
325 |
],
|
326 |
"support": {
|
327 |
"issues": "https://github.com/scssphp/scssphp/issues",
|
328 |
-
"source": "https://github.com/scssphp/scssphp/tree/v1.
|
329 |
},
|
330 |
"install-path": "../scssphp/scssphp"
|
331 |
},
|
332 |
{
|
333 |
"name": "thunderer/shortcode",
|
334 |
-
"version": "v0.7.
|
335 |
-
"version_normalized": "0.7.
|
336 |
"source": {
|
337 |
"type": "git",
|
338 |
"url": "https://github.com/thunderer/Shortcode.git",
|
339 |
-
"reference": "
|
340 |
},
|
341 |
"dist": {
|
342 |
"type": "zip",
|
343 |
-
"url": "https://api.github.com/repos/thunderer/Shortcode/zipball/
|
344 |
-
"reference": "
|
345 |
"shasum": ""
|
346 |
},
|
347 |
"require": {
|
@@ -356,7 +356,7 @@
|
|
356 |
"ext-json": "if you want to use JSON serializer",
|
357 |
"symfony/yaml": "if you want to use YAML serializer"
|
358 |
},
|
359 |
-
"time": "
|
360 |
"type": "library",
|
361 |
"installation-source": "dist",
|
362 |
"autoload": {
|
@@ -384,7 +384,7 @@
|
|
384 |
],
|
385 |
"support": {
|
386 |
"issues": "https://github.com/thunderer/Shortcode/issues",
|
387 |
-
"source": "https://github.com/thunderer/Shortcode/tree/v0.7.
|
388 |
},
|
389 |
"install-path": "../thunderer/shortcode"
|
390 |
}
|
254 |
},
|
255 |
{
|
256 |
"name": "scssphp/scssphp",
|
257 |
+
"version": "v1.10.0",
|
258 |
+
"version_normalized": "1.10.0.0",
|
259 |
"source": {
|
260 |
"type": "git",
|
261 |
"url": "https://github.com/scssphp/scssphp.git",
|
262 |
+
"reference": "9699a52a862da4efb43985943afa17150155dd3d"
|
263 |
},
|
264 |
"dist": {
|
265 |
"type": "zip",
|
266 |
+
"url": "https://api.github.com/repos/scssphp/scssphp/zipball/9699a52a862da4efb43985943afa17150155dd3d",
|
267 |
+
"reference": "9699a52a862da4efb43985943afa17150155dd3d",
|
268 |
"shasum": ""
|
269 |
},
|
270 |
"require": {
|
280 |
"symfony/phpunit-bridge": "^5.1",
|
281 |
"thoughtbot/bourbon": "^7.0",
|
282 |
"twbs/bootstrap": "~5.0",
|
283 |
+
"twbs/bootstrap4": "4.6.1",
|
284 |
"zurb/foundation": "~6.5"
|
285 |
},
|
286 |
"suggest": {
|
287 |
"ext-iconv": "Can be used as fallback when ext-mbstring is not available",
|
288 |
"ext-mbstring": "For best performance, mbstring should be installed as it is faster than ext-iconv"
|
289 |
},
|
290 |
+
"time": "2022-01-06T18:16:18+00:00",
|
291 |
"bin": [
|
292 |
"bin/pscss"
|
293 |
],
|
325 |
],
|
326 |
"support": {
|
327 |
"issues": "https://github.com/scssphp/scssphp/issues",
|
328 |
+
"source": "https://github.com/scssphp/scssphp/tree/v1.10.0"
|
329 |
},
|
330 |
"install-path": "../scssphp/scssphp"
|
331 |
},
|
332 |
{
|
333 |
"name": "thunderer/shortcode",
|
334 |
+
"version": "v0.7.5",
|
335 |
+
"version_normalized": "0.7.5.0",
|
336 |
"source": {
|
337 |
"type": "git",
|
338 |
"url": "https://github.com/thunderer/Shortcode.git",
|
339 |
+
"reference": "a4fee30613bd46efb421f8305aff0466a3268a99"
|
340 |
},
|
341 |
"dist": {
|
342 |
"type": "zip",
|
343 |
+
"url": "https://api.github.com/repos/thunderer/Shortcode/zipball/a4fee30613bd46efb421f8305aff0466a3268a99",
|
344 |
+
"reference": "a4fee30613bd46efb421f8305aff0466a3268a99",
|
345 |
"shasum": ""
|
346 |
},
|
347 |
"require": {
|
356 |
"ext-json": "if you want to use JSON serializer",
|
357 |
"symfony/yaml": "if you want to use YAML serializer"
|
358 |
},
|
359 |
+
"time": "2022-01-13T18:53:33+00:00",
|
360 |
"type": "library",
|
361 |
"installation-source": "dist",
|
362 |
"autoload": {
|
384 |
],
|
385 |
"support": {
|
386 |
"issues": "https://github.com/thunderer/Shortcode/issues",
|
387 |
+
"source": "https://github.com/thunderer/Shortcode/tree/v0.7.5"
|
388 |
},
|
389 |
"install-path": "../thunderer/shortcode"
|
390 |
}
|
vendor/composer/installed.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
'aliases' =>
|
7 |
array (
|
8 |
),
|
9 |
-
'reference' => '
|
10 |
'name' => '__root__',
|
11 |
),
|
12 |
'versions' =>
|
@@ -18,7 +18,7 @@
|
|
18 |
'aliases' =>
|
19 |
array (
|
20 |
),
|
21 |
-
'reference' => '
|
22 |
),
|
23 |
'composer/installers' =>
|
24 |
array (
|
@@ -56,12 +56,12 @@
|
|
56 |
),
|
57 |
'scssphp/scssphp' =>
|
58 |
array (
|
59 |
-
'pretty_version' => 'v1.
|
60 |
-
'version' => '1.
|
61 |
'aliases' =>
|
62 |
array (
|
63 |
),
|
64 |
-
'reference' => '
|
65 |
),
|
66 |
'shama/baton' =>
|
67 |
array (
|
@@ -72,12 +72,12 @@
|
|
72 |
),
|
73 |
'thunderer/shortcode' =>
|
74 |
array (
|
75 |
-
'pretty_version' => 'v0.7.
|
76 |
-
'version' => '0.7.
|
77 |
'aliases' =>
|
78 |
array (
|
79 |
),
|
80 |
-
'reference' => '
|
81 |
),
|
82 |
),
|
83 |
);
|
6 |
'aliases' =>
|
7 |
array (
|
8 |
),
|
9 |
+
'reference' => '3d85d247ec6eed8ec21065f1ec0e66499ea986bf',
|
10 |
'name' => '__root__',
|
11 |
),
|
12 |
'versions' =>
|
18 |
'aliases' =>
|
19 |
array (
|
20 |
),
|
21 |
+
'reference' => '3d85d247ec6eed8ec21065f1ec0e66499ea986bf',
|
22 |
),
|
23 |
'composer/installers' =>
|
24 |
array (
|
56 |
),
|
57 |
'scssphp/scssphp' =>
|
58 |
array (
|
59 |
+
'pretty_version' => 'v1.10.0',
|
60 |
+
'version' => '1.10.0.0',
|
61 |
'aliases' =>
|
62 |
array (
|
63 |
),
|
64 |
+
'reference' => '9699a52a862da4efb43985943afa17150155dd3d',
|
65 |
),
|
66 |
'shama/baton' =>
|
67 |
array (
|
72 |
),
|
73 |
'thunderer/shortcode' =>
|
74 |
array (
|
75 |
+
'pretty_version' => 'v0.7.5',
|
76 |
+
'version' => '0.7.5.0',
|
77 |
'aliases' =>
|
78 |
array (
|
79 |
),
|
80 |
+
'reference' => 'a4fee30613bd46efb421f8305aff0466a3268a99',
|
81 |
),
|
82 |
),
|
83 |
);
|
vendor/scssphp/scssphp/bin/pscss
CHANGED
@@ -38,8 +38,8 @@ $embedSourceMap = false;
|
|
38 |
/**
|
39 |
* Parse argument
|
40 |
*
|
41 |
-
* @param
|
42 |
-
* @param
|
43 |
*
|
44 |
* @return string|null
|
45 |
*/
|
38 |
/**
|
39 |
* Parse argument
|
40 |
*
|
41 |
+
* @param int $i
|
42 |
+
* @param string[] $options
|
43 |
*
|
44 |
* @return string|null
|
45 |
*/
|
vendor/scssphp/scssphp/composer.json
CHANGED
@@ -42,7 +42,7 @@
|
|
42 |
"symfony/phpunit-bridge": "^5.1",
|
43 |
"thoughtbot/bourbon": "^7.0",
|
44 |
"twbs/bootstrap": "~5.0",
|
45 |
-
"twbs/bootstrap4": "4.6.
|
46 |
"zurb/foundation": "~6.5"
|
47 |
},
|
48 |
"repositories": [
|
@@ -50,16 +50,16 @@
|
|
50 |
"type": "package",
|
51 |
"package": {
|
52 |
"name": "sass/sass-spec",
|
53 |
-
"version": "2021.
|
54 |
"source": {
|
55 |
"type": "git",
|
56 |
"url": "https://github.com/sass/sass-spec.git",
|
57 |
-
"reference": "
|
58 |
},
|
59 |
"dist": {
|
60 |
"type": "zip",
|
61 |
-
"url": "https://api.github.com/repos/sass/sass-spec/zipball/
|
62 |
-
"reference": "
|
63 |
"shasum": ""
|
64 |
}
|
65 |
}
|
@@ -86,16 +86,16 @@
|
|
86 |
"type": "package",
|
87 |
"package": {
|
88 |
"name": "twbs/bootstrap4",
|
89 |
-
"version": "v4.6.
|
90 |
"source": {
|
91 |
"type": "git",
|
92 |
"url": "https://github.com/twbs/bootstrap.git",
|
93 |
-
"reference": "
|
94 |
},
|
95 |
"dist": {
|
96 |
"type": "zip",
|
97 |
-
"url": "https://api.github.com/repos/twbs/bootstrap/zipball/
|
98 |
-
"reference": "
|
99 |
"shasum": ""
|
100 |
}
|
101 |
}
|
@@ -103,6 +103,9 @@
|
|
103 |
],
|
104 |
"bin": ["bin/pscss"],
|
105 |
"config": {
|
106 |
-
"sort-packages": true
|
|
|
|
|
|
|
107 |
}
|
108 |
}
|
42 |
"symfony/phpunit-bridge": "^5.1",
|
43 |
"thoughtbot/bourbon": "^7.0",
|
44 |
"twbs/bootstrap": "~5.0",
|
45 |
+
"twbs/bootstrap4": "4.6.1",
|
46 |
"zurb/foundation": "~6.5"
|
47 |
},
|
48 |
"repositories": [
|
50 |
"type": "package",
|
51 |
"package": {
|
52 |
"name": "sass/sass-spec",
|
53 |
+
"version": "2021.11.30",
|
54 |
"source": {
|
55 |
"type": "git",
|
56 |
"url": "https://github.com/sass/sass-spec.git",
|
57 |
+
"reference": "ee5b460ac84b1ce27b86e22c0252b4296444cf3a"
|
58 |
},
|
59 |
"dist": {
|
60 |
"type": "zip",
|
61 |
+
"url": "https://api.github.com/repos/sass/sass-spec/zipball/ee5b460ac84b1ce27b86e22c0252b4296444cf3a",
|
62 |
+
"reference": "ee5b460ac84b1ce27b86e22c0252b4296444cf3a",
|
63 |
"shasum": ""
|
64 |
}
|
65 |
}
|
86 |
"type": "package",
|
87 |
"package": {
|
88 |
"name": "twbs/bootstrap4",
|
89 |
+
"version": "v4.6.1",
|
90 |
"source": {
|
91 |
"type": "git",
|
92 |
"url": "https://github.com/twbs/bootstrap.git",
|
93 |
+
"reference": "043a03c95a2ad6738f85b65e53b9dbdfb03b8d10"
|
94 |
},
|
95 |
"dist": {
|
96 |
"type": "zip",
|
97 |
+
"url": "https://api.github.com/repos/twbs/bootstrap/zipball/043a03c95a2ad6738f85b65e53b9dbdfb03b8d10",
|
98 |
+
"reference": "043a03c95a2ad6738f85b65e53b9dbdfb03b8d10",
|
99 |
"shasum": ""
|
100 |
}
|
101 |
}
|
103 |
],
|
104 |
"bin": ["bin/pscss"],
|
105 |
"config": {
|
106 |
+
"sort-packages": true,
|
107 |
+
"allow-plugins": {
|
108 |
+
"bamarni/composer-bin-plugin": true
|
109 |
+
}
|
110 |
}
|
111 |
}
|
vendor/scssphp/scssphp/src/Base/Range.php
CHANGED
@@ -34,8 +34,8 @@ class Range
|
|
34 |
/**
|
35 |
* Initialize range
|
36 |
*
|
37 |
-
* @param
|
38 |
-
* @param
|
39 |
*/
|
40 |
public function __construct($first, $last)
|
41 |
{
|
@@ -46,9 +46,9 @@ class Range
|
|
46 |
/**
|
47 |
* Test for inclusion in range
|
48 |
*
|
49 |
-
* @param
|
50 |
*
|
51 |
-
* @return
|
52 |
*/
|
53 |
public function includes($value)
|
54 |
{
|
34 |
/**
|
35 |
* Initialize range
|
36 |
*
|
37 |
+
* @param int|float $first
|
38 |
+
* @param int|float $last
|
39 |
*/
|
40 |
public function __construct($first, $last)
|
41 |
{
|
46 |
/**
|
47 |
* Test for inclusion in range
|
48 |
*
|
49 |
+
* @param int|float $value
|
50 |
*
|
51 |
+
* @return bool
|
52 |
*/
|
53 |
public function includes($value)
|
54 |
{
|
vendor/scssphp/scssphp/src/Block.php
CHANGED
@@ -22,12 +22,12 @@ namespace ScssPhp\ScssPhp;
|
|
22 |
class Block
|
23 |
{
|
24 |
/**
|
25 |
-
* @var string
|
26 |
*/
|
27 |
public $type;
|
28 |
|
29 |
/**
|
30 |
-
* @var
|
31 |
*/
|
32 |
public $parent;
|
33 |
|
@@ -37,17 +37,17 @@ class Block
|
|
37 |
public $sourceName;
|
38 |
|
39 |
/**
|
40 |
-
* @var
|
41 |
*/
|
42 |
public $sourceIndex;
|
43 |
|
44 |
/**
|
45 |
-
* @var
|
46 |
*/
|
47 |
public $sourceLine;
|
48 |
|
49 |
/**
|
50 |
-
* @var
|
51 |
*/
|
52 |
public $sourceColumn;
|
53 |
|
@@ -67,7 +67,7 @@ class Block
|
|
67 |
public $children;
|
68 |
|
69 |
/**
|
70 |
-
* @var
|
71 |
*/
|
72 |
public $selfParent;
|
73 |
}
|
22 |
class Block
|
23 |
{
|
24 |
/**
|
25 |
+
* @var string|null
|
26 |
*/
|
27 |
public $type;
|
28 |
|
29 |
/**
|
30 |
+
* @var Block|null
|
31 |
*/
|
32 |
public $parent;
|
33 |
|
37 |
public $sourceName;
|
38 |
|
39 |
/**
|
40 |
+
* @var int
|
41 |
*/
|
42 |
public $sourceIndex;
|
43 |
|
44 |
/**
|
45 |
+
* @var int
|
46 |
*/
|
47 |
public $sourceLine;
|
48 |
|
49 |
/**
|
50 |
+
* @var int
|
51 |
*/
|
52 |
public $sourceColumn;
|
53 |
|
67 |
public $children;
|
68 |
|
69 |
/**
|
70 |
+
* @var Block|null
|
71 |
*/
|
72 |
public $selfParent;
|
73 |
}
|
vendor/scssphp/scssphp/src/Block/AtRootBlock.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SCSSPHP
|
5 |
+
*
|
6 |
+
* @copyright 2012-2020 Leaf Corcoran
|
7 |
+
*
|
8 |
+
* @license http://opensource.org/licenses/MIT MIT
|
9 |
+
*
|
10 |
+
* @link http://scssphp.github.io/scssphp
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace ScssPhp\ScssPhp\Block;
|
14 |
+
|
15 |
+
use ScssPhp\ScssPhp\Block;
|
16 |
+
use ScssPhp\ScssPhp\Type;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @internal
|
20 |
+
*/
|
21 |
+
class AtRootBlock extends Block
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* @var array|null
|
25 |
+
*/
|
26 |
+
public $selector;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var array|null
|
30 |
+
*/
|
31 |
+
public $with;
|
32 |
+
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
$this->type = Type::T_AT_ROOT;
|
36 |
+
}
|
37 |
+
}
|
vendor/scssphp/scssphp/src/Block/CallableBlock.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SCSSPHP
|
5 |
+
*
|
6 |
+
* @copyright 2012-2020 Leaf Corcoran
|
7 |
+
*
|
8 |
+
* @license http://opensource.org/licenses/MIT MIT
|
9 |
+
*
|
10 |
+
* @link http://scssphp.github.io/scssphp
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace ScssPhp\ScssPhp\Block;
|
14 |
+
|
15 |
+
use ScssPhp\ScssPhp\Block;
|
16 |
+
use ScssPhp\ScssPhp\Compiler\Environment;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @internal
|
20 |
+
*/
|
21 |
+
class CallableBlock extends Block
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
public $name;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var array|null
|
30 |
+
*/
|
31 |
+
public $args;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @var Environment|null
|
35 |
+
*/
|
36 |
+
public $parentEnv;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @param string $type
|
40 |
+
*/
|
41 |
+
public function __construct($type)
|
42 |
+
{
|
43 |
+
$this->type = $type;
|
44 |
+
}
|
45 |
+
}
|
vendor/scssphp/scssphp/src/Block/ContentBlock.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SCSSPHP
|
5 |
+
*
|
6 |
+
* @copyright 2012-2020 Leaf Corcoran
|
7 |
+
*
|
8 |
+
* @license http://opensource.org/licenses/MIT MIT
|
9 |
+
*
|
10 |
+
* @link http://scssphp.github.io/scssphp
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace ScssPhp\ScssPhp\Block;
|
14 |
+
|
15 |
+
use ScssPhp\ScssPhp\Block;
|
16 |
+
use ScssPhp\ScssPhp\Compiler\Environment;
|
17 |
+
use ScssPhp\ScssPhp\Type;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @internal
|
21 |
+
*/
|
22 |
+
class ContentBlock extends Block
|
23 |
+
{
|
24 |
+
/**
|
25 |
+
* @var array|null
|
26 |
+
*/
|
27 |
+
public $child;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @var Environment|null
|
31 |
+
*/
|
32 |
+
public $scope;
|
33 |
+
|
34 |
+
public function __construct()
|
35 |
+
{
|
36 |
+
$this->type = Type::T_INCLUDE;
|
37 |
+
}
|
38 |
+
}
|
vendor/scssphp/scssphp/src/Block/DirectiveBlock.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SCSSPHP
|
5 |
+
*
|
6 |
+
* @copyright 2012-2020 Leaf Corcoran
|
7 |
+
*
|
8 |
+
* @license http://opensource.org/licenses/MIT MIT
|
9 |
+
*
|
10 |
+
* @link http://scssphp.github.io/scssphp
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace ScssPhp\ScssPhp\Block;
|
14 |
+
|
15 |
+
use ScssPhp\ScssPhp\Block;
|
16 |
+
use ScssPhp\ScssPhp\Type;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @internal
|
20 |
+
*/
|
21 |
+
class DirectiveBlock extends Block
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* @var string|array
|
25 |
+
*/
|
26 |
+
public $name;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var string|array|null
|
30 |
+
*/
|
31 |
+
public $value;
|
32 |
+
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
$this->type = Type::T_DIRECTIVE;
|
36 |
+
}
|
37 |
+
}
|
vendor/scssphp/scssphp/src/Block/EachBlock.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SCSSPHP
|
5 |
+
*
|
6 |
+
* @copyright 2012-2020 Leaf Corcoran
|
7 |
+
*
|
8 |
+
* @license http://opensource.org/licenses/MIT MIT
|
9 |
+
*
|
10 |
+
* @link http://scssphp.github.io/scssphp
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace ScssPhp\ScssPhp\Block;
|
14 |
+
|
15 |
+
use ScssPhp\ScssPhp\Block;
|
16 |
+
use ScssPhp\ScssPhp\Type;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @internal
|
20 |
+
*/
|
21 |
+
class EachBlock extends Block
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* @var string[]
|
25 |
+
*/
|
26 |
+
public $vars = [];
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var array
|
30 |
+
*/
|
31 |
+
public $list;
|
32 |
+
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
$this->type = Type::T_EACH;
|
36 |
+
}
|
37 |
+
}
|
vendor/scssphp/scssphp/src/Block/ElseBlock.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SCSSPHP
|
5 |
+
*
|
6 |
+
* @copyright 2012-2020 Leaf Corcoran
|
7 |
+
*
|
8 |
+
* @license http://opensource.org/licenses/MIT MIT
|
9 |
+
*
|
10 |
+
* @link http://scssphp.github.io/scssphp
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace ScssPhp\ScssPhp\Block;
|
14 |
+
|
15 |
+
use ScssPhp\ScssPhp\Block;
|
16 |
+
use ScssPhp\ScssPhp\Type;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @internal
|
20 |
+
*/
|
21 |
+
class ElseBlock extends Block
|
22 |
+
{
|
23 |
+
public function __construct()
|
24 |
+
{
|
25 |
+
$this->type = Type::T_ELSE;
|
26 |
+
}
|
27 |
+
}
|
vendor/scssphp/scssphp/src/Block/ElseifBlock.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SCSSPHP
|
5 |
+
*
|
6 |
+
* @copyright 2012-2020 Leaf Corcoran
|
7 |
+
*
|
8 |
+
* @license http://opensource.org/licenses/MIT MIT
|
9 |
+
*
|
10 |
+
* @link http://scssphp.github.io/scssphp
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace ScssPhp\ScssPhp\Block;
|
14 |
+
|
15 |
+
use ScssPhp\ScssPhp\Block;
|
16 |
+
use ScssPhp\ScssPhp\Type;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @internal
|
20 |
+
*/
|
21 |
+
class ElseifBlock extends Block
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
public $cond;
|
27 |
+
|
28 |
+
public function __construct()
|
29 |
+
{
|
30 |
+
$this->type = Type::T_ELSEIF;
|
31 |
+
}
|
32 |
+
}
|
vendor/scssphp/scssphp/src/Block/ForBlock.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SCSSPHP
|
5 |
+
*
|
6 |
+
* @copyright 2012-2020 Leaf Corcoran
|
7 |
+
*
|
8 |
+
* @license http://opensource.org/licenses/MIT MIT
|
9 |
+
*
|
10 |
+
* @link http://scssphp.github.io/scssphp
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace ScssPhp\ScssPhp\Block;
|
14 |
+
|
15 |
+
use ScssPhp\ScssPhp\Block;
|
16 |
+
use ScssPhp\ScssPhp\Type;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @internal
|
20 |
+
*/
|
21 |
+
class ForBlock extends Block
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
public $var;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var array
|
30 |
+
*/
|
31 |
+
public $start;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @var array
|
35 |
+
*/
|
36 |
+
public $end;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @var bool
|
40 |
+
*/
|
41 |
+
public $until;
|
42 |
+
|
43 |
+
public function __construct()
|
44 |
+
{
|
45 |
+
$this->type = Type::T_FOR;
|
46 |
+
}
|
47 |
+
}
|
vendor/scssphp/scssphp/src/Block/IfBlock.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SCSSPHP
|
5 |
+
*
|
6 |
+
* @copyright 2012-2020 Leaf Corcoran
|
7 |
+
*
|
8 |
+
* @license http://opensource.org/licenses/MIT MIT
|
9 |
+
*
|
10 |
+
* @link http://scssphp.github.io/scssphp
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace ScssPhp\ScssPhp\Block;
|
14 |
+
|
15 |
+
use ScssPhp\ScssPhp\Block;
|
16 |
+
use ScssPhp\ScssPhp\Type;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @internal
|
20 |
+
*/
|
21 |
+
class IfBlock extends Block
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
public $cond;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var array<ElseifBlock|ElseBlock>
|
30 |
+
*/
|
31 |
+
public $cases = [];
|
32 |
+
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
$this->type = Type::T_IF;
|
36 |
+
}
|
37 |
+
}
|
vendor/scssphp/scssphp/src/Block/MediaBlock.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SCSSPHP
|
5 |
+
*
|
6 |
+
* @copyright 2012-2020 Leaf Corcoran
|
7 |
+
*
|
8 |
+
* @license http://opensource.org/licenses/MIT MIT
|
9 |
+
*
|
10 |
+
* @link http://scssphp.github.io/scssphp
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace ScssPhp\ScssPhp\Block;
|
14 |
+
|
15 |
+
use ScssPhp\ScssPhp\Block;
|
16 |
+
use ScssPhp\ScssPhp\Type;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @internal
|
20 |
+
*/
|
21 |
+
class MediaBlock extends Block
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* @var string|array|null
|
25 |
+
*/
|
26 |
+
public $value;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var array|null
|
30 |
+
*/
|
31 |
+
public $queryList;
|
32 |
+
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
$this->type = Type::T_MEDIA;
|
36 |
+
}
|
37 |
+
}
|
vendor/scssphp/scssphp/src/Block/NestedPropertyBlock.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SCSSPHP
|
5 |
+
*
|
6 |
+
* @copyright 2012-2020 Leaf Corcoran
|
7 |
+
*
|
8 |
+
* @license http://opensource.org/licenses/MIT MIT
|
9 |
+
*
|
10 |
+
* @link http://scssphp.github.io/scssphp
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace ScssPhp\ScssPhp\Block;
|
14 |
+
|
15 |
+
use ScssPhp\ScssPhp\Block;
|
16 |
+
use ScssPhp\ScssPhp\Type;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @internal
|
20 |
+
*/
|
21 |
+
class NestedPropertyBlock extends Block
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* @var bool
|
25 |
+
*/
|
26 |
+
public $hasValue;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var array
|
30 |
+
*/
|
31 |
+
public $prefix;
|
32 |
+
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
$this->type = Type::T_NESTED_PROPERTY;
|
36 |
+
}
|
37 |
+
}
|
vendor/scssphp/scssphp/src/Block/WhileBlock.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SCSSPHP
|
5 |
+
*
|
6 |
+
* @copyright 2012-2020 Leaf Corcoran
|
7 |
+
*
|
8 |
+
* @license http://opensource.org/licenses/MIT MIT
|
9 |
+
*
|
10 |
+
* @link http://scssphp.github.io/scssphp
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace ScssPhp\ScssPhp\Block;
|
14 |
+
|
15 |
+
use ScssPhp\ScssPhp\Block;
|
16 |
+
use ScssPhp\ScssPhp\Type;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @internal
|
20 |
+
*/
|
21 |
+
class WhileBlock extends Block
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
public $cond;
|
27 |
+
|
28 |
+
public function __construct()
|
29 |
+
{
|
30 |
+
$this->type = Type::T_WHILE;
|
31 |
+
}
|
32 |
+
}
|
vendor/scssphp/scssphp/src/Colors.php
CHANGED
@@ -204,10 +204,10 @@ class Colors
|
|
204 |
/**
|
205 |
* Reverse conversion : from RGBA to a color name if possible
|
206 |
*
|
207 |
-
* @param
|
208 |
-
* @param
|
209 |
-
* @param
|
210 |
-
* @param
|
211 |
*
|
212 |
* @return string|null
|
213 |
*/
|
204 |
/**
|
205 |
* Reverse conversion : from RGBA to a color name if possible
|
206 |
*
|
207 |
+
* @param int $r
|
208 |
+
* @param int $g
|
209 |
+
* @param int $b
|
210 |
+
* @param int|float $a
|
211 |
*
|
212 |
* @return string|null
|
213 |
*/
|
vendor/scssphp/scssphp/src/Compiler.php
CHANGED
@@ -13,6 +13,17 @@
|
|
13 |
namespace ScssPhp\ScssPhp;
|
14 |
|
15 |
use ScssPhp\ScssPhp\Base\Range;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
use ScssPhp\ScssPhp\Compiler\CachedResult;
|
17 |
use ScssPhp\ScssPhp\Compiler\Environment;
|
18 |
use ScssPhp\ScssPhp\Exception\CompilerException;
|
@@ -644,7 +655,7 @@ class Compiler
|
|
644 |
* @param array $target
|
645 |
* @param array $origin
|
646 |
*
|
647 |
-
* @return
|
648 |
*/
|
649 |
protected function isSelfExtend($target, $origin)
|
650 |
{
|
@@ -853,10 +864,10 @@ class Compiler
|
|
853 |
/**
|
854 |
* Match extends
|
855 |
*
|
856 |
-
* @param array
|
857 |
-
* @param array
|
858 |
-
* @param
|
859 |
-
* @param
|
860 |
*
|
861 |
* @return void
|
862 |
*/
|
@@ -989,7 +1000,7 @@ class Compiler
|
|
989 |
* @param string $part
|
990 |
* @param array $matches
|
991 |
*
|
992 |
-
* @return
|
993 |
*/
|
994 |
protected function isPseudoSelector($part, &$matches)
|
995 |
{
|
@@ -1051,11 +1062,11 @@ class Compiler
|
|
1051 |
/**
|
1052 |
* Match extends single
|
1053 |
*
|
1054 |
-
* @param array
|
1055 |
-
* @param array
|
1056 |
-
* @param
|
1057 |
*
|
1058 |
-
* @return
|
1059 |
*/
|
1060 |
protected function matchExtendsSingle($rawSingle, &$outOrigin, $initial = true)
|
1061 |
{
|
@@ -1270,6 +1281,7 @@ class Compiler
|
|
1270 |
*/
|
1271 |
protected function compileMedia(Block $media)
|
1272 |
{
|
|
|
1273 |
$this->pushEnv($media);
|
1274 |
|
1275 |
$mediaQueries = $this->compileMediaQuery($this->multiplyMedia($this->env));
|
@@ -1347,7 +1359,7 @@ class Compiler
|
|
1347 |
/**
|
1348 |
* Compile directive
|
1349 |
*
|
1350 |
-
* @param
|
1351 |
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $out
|
1352 |
*
|
1353 |
* @return void
|
@@ -1413,6 +1425,7 @@ class Compiler
|
|
1413 |
*/
|
1414 |
protected function compileAtRoot(Block $block)
|
1415 |
{
|
|
|
1416 |
$env = $this->pushEnv($block);
|
1417 |
$envs = $this->compactEnv($env);
|
1418 |
list($with, $without) = $this->compileWith(isset($block->with) ? $block->with : null);
|
@@ -1461,7 +1474,7 @@ class Compiler
|
|
1461 |
}
|
1462 |
|
1463 |
/**
|
1464 |
-
* Filter at-root scope depending
|
1465 |
*
|
1466 |
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $scope
|
1467 |
* @param array $with
|
@@ -1561,7 +1574,7 @@ class Compiler
|
|
1561 |
* Find a selector by the depth node in the scope
|
1562 |
*
|
1563 |
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $scope
|
1564 |
-
* @param
|
1565 |
*
|
1566 |
* @return array
|
1567 |
*/
|
@@ -1585,7 +1598,7 @@ class Compiler
|
|
1585 |
/**
|
1586 |
* Compile @at-root's with: inclusion / without: exclusion into 2 lists uses to filter scope/env later
|
1587 |
*
|
1588 |
-
* @param array $withCondition
|
1589 |
*
|
1590 |
* @return array
|
1591 |
*
|
@@ -1674,7 +1687,7 @@ class Compiler
|
|
1674 |
* @param array $with
|
1675 |
* @param array $without
|
1676 |
*
|
1677 |
-
* @return
|
1678 |
*/
|
1679 |
protected function isWith($block, $with, $without)
|
1680 |
{
|
@@ -1684,6 +1697,7 @@ class Compiler
|
|
1684 |
}
|
1685 |
|
1686 |
if ($block->type === Type::T_DIRECTIVE) {
|
|
|
1687 |
if (isset($block->name)) {
|
1688 |
return $this->testWithWithout($this->compileDirectiveName($block->name), $with, $without);
|
1689 |
} elseif (isset($block->selectors) && preg_match(',@(\w+),ims', json_encode($block->selectors), $m)) {
|
@@ -1719,7 +1733,7 @@ class Compiler
|
|
1719 |
* @param array $with
|
1720 |
* @param array $without
|
1721 |
*
|
1722 |
-
* @return
|
1723 |
* true if the block should be kept, false to reject
|
1724 |
*/
|
1725 |
protected function testWithWithout($what, $with, $without)
|
@@ -1774,6 +1788,7 @@ class Compiler
|
|
1774 |
*/
|
1775 |
protected function compileNestedPropertiesBlock(Block $block, OutputBlock $out)
|
1776 |
{
|
|
|
1777 |
$prefix = $this->compileValue($block->prefix) . '-';
|
1778 |
|
1779 |
$nested = $this->makeOutputBlock($block->type);
|
@@ -1792,6 +1807,7 @@ class Compiler
|
|
1792 |
break;
|
1793 |
|
1794 |
case Type::T_NESTED_PROPERTY:
|
|
|
1795 |
array_unshift($child[1]->prefix[2], $prefix);
|
1796 |
break;
|
1797 |
}
|
@@ -1817,7 +1833,7 @@ class Compiler
|
|
1817 |
|
1818 |
// wrap assign children in a block
|
1819 |
// except for @font-face
|
1820 |
-
if (
|
1821 |
// need wrapping?
|
1822 |
$needWrapping = false;
|
1823 |
|
@@ -1906,8 +1922,8 @@ class Compiler
|
|
1906 |
/**
|
1907 |
* Compile the value of a comment that can have interpolation
|
1908 |
*
|
1909 |
-
* @param array
|
1910 |
-
* @param
|
1911 |
*
|
1912 |
* @return string
|
1913 |
*/
|
@@ -2224,7 +2240,7 @@ class Compiler
|
|
2224 |
*
|
2225 |
* @param array $selector
|
2226 |
*
|
2227 |
-
* @return
|
2228 |
*/
|
2229 |
protected function hasSelectorPlaceholder($selector)
|
2230 |
{
|
@@ -2641,9 +2657,9 @@ class Compiler
|
|
2641 |
*
|
2642 |
* @param array $rawPath
|
2643 |
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $out
|
2644 |
-
* @param
|
2645 |
*
|
2646 |
-
* @return
|
2647 |
*/
|
2648 |
protected function compileImport($rawPath, OutputBlock $out, $once = false)
|
2649 |
{
|
@@ -2778,7 +2794,7 @@ class Compiler
|
|
2778 |
// insert the directive as a comment
|
2779 |
$child = $this->makeOutputBlock(Type::T_COMMENT);
|
2780 |
$child->lines[] = $line;
|
2781 |
-
$child->sourceName = $this->sourceNames[$this->sourceIndex];
|
2782 |
$child->sourceLine = $this->sourceLine;
|
2783 |
$child->sourceColumn = $this->sourceColumn;
|
2784 |
|
@@ -3049,6 +3065,7 @@ class Compiler
|
|
3049 |
case Type::T_MIXIN:
|
3050 |
case Type::T_FUNCTION:
|
3051 |
list(, $block) = $child;
|
|
|
3052 |
// the block need to be able to go up to it's parent env to resolve vars
|
3053 |
$block->parentEnv = $this->getStoreEnv();
|
3054 |
$this->set(static::$namespaces[$block->type] . $block->name, $block, true);
|
@@ -3099,6 +3116,7 @@ EOL;
|
|
3099 |
|
3100 |
case Type::T_IF:
|
3101 |
list(, $if) = $child;
|
|
|
3102 |
|
3103 |
if ($this->isTruthy($this->reduce($if->cond, true))) {
|
3104 |
return $this->compileChildren($if->children, $out);
|
@@ -3106,8 +3124,8 @@ EOL;
|
|
3106 |
|
3107 |
foreach ($if->cases as $case) {
|
3108 |
if (
|
3109 |
-
$case
|
3110 |
-
$case
|
3111 |
) {
|
3112 |
return $this->compileChildren($case->children, $out);
|
3113 |
}
|
@@ -3116,6 +3134,7 @@ EOL;
|
|
3116 |
|
3117 |
case Type::T_EACH:
|
3118 |
list(, $each) = $child;
|
|
|
3119 |
|
3120 |
$list = $this->coerceList($this->reduce($each->list), ',', true);
|
3121 |
|
@@ -3150,6 +3169,7 @@ EOL;
|
|
3150 |
|
3151 |
case Type::T_WHILE:
|
3152 |
list(, $while) = $child;
|
|
|
3153 |
|
3154 |
while ($this->isTruthy($this->reduce($while->cond, true))) {
|
3155 |
$ret = $this->compileChildren($while->children, $out);
|
@@ -3162,6 +3182,7 @@ EOL;
|
|
3162 |
|
3163 |
case Type::T_FOR:
|
3164 |
list(, $for) = $child;
|
|
|
3165 |
|
3166 |
$startNumber = $this->assertNumber($this->reduce($for->start, true));
|
3167 |
$endNumber = $this->assertNumber($this->reduce($for->end, true));
|
@@ -3222,6 +3243,8 @@ EOL;
|
|
3222 |
throw $this->error("Undefined mixin $name");
|
3223 |
}
|
3224 |
|
|
|
|
|
3225 |
$callingScope = $this->getStoreEnv();
|
3226 |
|
3227 |
// push scope, apply args
|
@@ -3394,7 +3417,7 @@ EOL;
|
|
3394 |
*
|
3395 |
* @param array|Number $value
|
3396 |
*
|
3397 |
-
* @return
|
3398 |
*/
|
3399 |
public function isTruthy($value)
|
3400 |
{
|
@@ -3406,7 +3429,7 @@ EOL;
|
|
3406 |
*
|
3407 |
* @param string $value
|
3408 |
*
|
3409 |
-
* @return
|
3410 |
*/
|
3411 |
protected function isImmediateRelationshipCombinator($value)
|
3412 |
{
|
@@ -3418,7 +3441,7 @@ EOL;
|
|
3418 |
*
|
3419 |
* @param array $value
|
3420 |
*
|
3421 |
-
* @return
|
3422 |
*/
|
3423 |
protected function shouldEval($value)
|
3424 |
{
|
@@ -3441,7 +3464,7 @@ EOL;
|
|
3441 |
* Reduce value
|
3442 |
*
|
3443 |
* @param array|Number $value
|
3444 |
-
* @param
|
3445 |
*
|
3446 |
* @return array|Number
|
3447 |
*/
|
@@ -3946,6 +3969,10 @@ EOL;
|
|
3946 |
unset($value['enclosing']);
|
3947 |
}
|
3948 |
|
|
|
|
|
|
|
|
|
3949 |
return $value;
|
3950 |
|
3951 |
case Type::T_STRING:
|
@@ -4061,8 +4088,8 @@ EOL;
|
|
4061 |
* Boolean and
|
4062 |
*
|
4063 |
* @param array|Number $left
|
4064 |
-
* @param array|Number
|
4065 |
-
* @param
|
4066 |
*
|
4067 |
* @return array|Number|null
|
4068 |
*/
|
@@ -4090,7 +4117,7 @@ EOL;
|
|
4090 |
*
|
4091 |
* @param array|Number $left
|
4092 |
* @param array|Number $right
|
4093 |
-
* @param
|
4094 |
*
|
4095 |
* @return array|Number|null
|
4096 |
*/
|
@@ -4516,8 +4543,7 @@ EOL;
|
|
4516 |
// force double quote as string quote for the output in certain cases
|
4517 |
if (
|
4518 |
$value[1] === "'" &&
|
4519 |
-
(strpos($content, '"') === false or strpos($content, "'") !== false)
|
4520 |
-
strpbrk($content, '{}\\\'') !== false
|
4521 |
) {
|
4522 |
$value[1] = '"';
|
4523 |
} elseif (
|
@@ -4570,6 +4596,8 @@ EOL;
|
|
4570 |
}
|
4571 |
}
|
4572 |
|
|
|
|
|
4573 |
$prefix_value = '';
|
4574 |
|
4575 |
if ($delim !== ' ') {
|
@@ -4608,7 +4636,7 @@ EOL;
|
|
4608 |
$filtered[] = $compiled;
|
4609 |
}
|
4610 |
|
4611 |
-
return $pre . substr(implode(
|
4612 |
|
4613 |
case Type::T_MAP:
|
4614 |
$keys = $value[1];
|
@@ -4880,10 +4908,10 @@ EOL;
|
|
4880 |
/**
|
4881 |
* Join selectors; looks for & to replace, or append parent before child
|
4882 |
*
|
4883 |
-
* @param array
|
4884 |
-
* @param array
|
4885 |
-
* @param
|
4886 |
-
* @param array
|
4887 |
|
4888 |
* @return array
|
4889 |
*/
|
@@ -4961,6 +4989,8 @@ EOL;
|
|
4961 |
return $this->multiplyMedia($env->parent, $childQueries);
|
4962 |
}
|
4963 |
|
|
|
|
|
4964 |
$parentQueries = isset($env->block->queryList)
|
4965 |
? $env->block->queryList
|
4966 |
: [[[Type::T_MEDIA_VALUE, $env->block->value]]];
|
@@ -5095,7 +5125,7 @@ EOL;
|
|
5095 |
*
|
5096 |
* @param string $name
|
5097 |
* @param mixed $value
|
5098 |
-
* @param
|
5099 |
* @param \ScssPhp\ScssPhp\Compiler\Environment $env
|
5100 |
* @param mixed $valueUnreduced
|
5101 |
*
|
@@ -5201,9 +5231,9 @@ EOL;
|
|
5201 |
* @internal
|
5202 |
*
|
5203 |
* @param string $name
|
5204 |
-
* @param
|
5205 |
* @param \ScssPhp\ScssPhp\Compiler\Environment $env
|
5206 |
-
* @param
|
5207 |
*
|
5208 |
* @return mixed|null
|
5209 |
*/
|
@@ -5270,7 +5300,7 @@ EOL;
|
|
5270 |
* @param string $name
|
5271 |
* @param \ScssPhp\ScssPhp\Compiler\Environment $env
|
5272 |
*
|
5273 |
-
* @return
|
5274 |
*/
|
5275 |
protected function has($name, Environment $env = null)
|
5276 |
{
|
@@ -5460,7 +5490,7 @@ EOL;
|
|
5460 |
*
|
5461 |
* @api
|
5462 |
*
|
5463 |
-
* @param
|
5464 |
*
|
5465 |
* @return void
|
5466 |
*
|
@@ -5561,7 +5591,7 @@ EOL;
|
|
5561 |
*
|
5562 |
* @api
|
5563 |
*
|
5564 |
-
* @param
|
5565 |
*
|
5566 |
* @return void
|
5567 |
*
|
@@ -5963,7 +5993,7 @@ EOL;
|
|
5963 |
*
|
5964 |
* @api
|
5965 |
*
|
5966 |
-
* @param
|
5967 |
*
|
5968 |
* @return \ScssPhp\ScssPhp\Compiler
|
5969 |
*
|
@@ -6102,7 +6132,7 @@ EOL;
|
|
6102 |
/**
|
6103 |
* Beautify call stack for output
|
6104 |
*
|
6105 |
-
* @param
|
6106 |
* @param int|null $limit
|
6107 |
*
|
6108 |
* @return string
|
@@ -6162,8 +6192,8 @@ EOL;
|
|
6162 |
/**
|
6163 |
* Call SCSS @function
|
6164 |
*
|
6165 |
-
* @param
|
6166 |
-
* @param array
|
6167 |
*
|
6168 |
* @return array|Number
|
6169 |
*/
|
@@ -6737,9 +6767,8 @@ EOL;
|
|
6737 |
*
|
6738 |
* @param array[] $argDef
|
6739 |
* @param array|null $argValues
|
6740 |
-
* @param
|
6741 |
-
* @param
|
6742 |
-
* only used if $storeInEnv = false
|
6743 |
*
|
6744 |
* @return array<string, array|Number>
|
6745 |
*
|
@@ -6983,14 +7012,14 @@ EOL;
|
|
6983 |
*
|
6984 |
* @param array|Number $item
|
6985 |
* @param string $delim
|
6986 |
-
* @param
|
6987 |
*
|
6988 |
* @return array
|
6989 |
*/
|
6990 |
protected function coerceList($item, $delim = ',', $removeTrailingNull = false)
|
6991 |
{
|
6992 |
if ($item instanceof Number) {
|
6993 |
-
return [Type::T_LIST,
|
6994 |
}
|
6995 |
|
6996 |
if ($item[0] === Type::T_LIST) {
|
@@ -7013,15 +7042,15 @@ EOL;
|
|
7013 |
|
7014 |
$list[] = [
|
7015 |
Type::T_LIST,
|
7016 |
-
'',
|
7017 |
[$key, $value]
|
7018 |
];
|
7019 |
}
|
7020 |
|
7021 |
-
return [Type::T_LIST, ',', $list];
|
7022 |
}
|
7023 |
|
7024 |
-
return [Type::T_LIST,
|
7025 |
}
|
7026 |
|
7027 |
/**
|
@@ -7162,10 +7191,10 @@ EOL;
|
|
7162 |
}
|
7163 |
|
7164 |
/**
|
7165 |
-
* @param
|
7166 |
-
* @param
|
7167 |
*
|
7168 |
-
* @return
|
7169 |
*/
|
7170 |
protected function compileRGBAValue($value, $isAlpha = false)
|
7171 |
{
|
@@ -7177,12 +7206,12 @@ EOL;
|
|
7177 |
}
|
7178 |
|
7179 |
/**
|
7180 |
-
* @param mixed
|
7181 |
-
* @param
|
7182 |
-
* @param
|
7183 |
-
* @param
|
7184 |
*
|
7185 |
-
* @return
|
7186 |
*/
|
7187 |
protected function compileColorPartValue($value, $min, $max, $isInt = true)
|
7188 |
{
|
@@ -7276,7 +7305,7 @@ EOL;
|
|
7276 |
*
|
7277 |
* @param array|Number $value
|
7278 |
*
|
7279 |
-
* @return
|
7280 |
*
|
7281 |
* @deprecated
|
7282 |
*/
|
@@ -7414,7 +7443,7 @@ EOL;
|
|
7414 |
* @param array|Number $value
|
7415 |
* @param string|null $varName
|
7416 |
*
|
7417 |
-
* @return
|
7418 |
*
|
7419 |
* @throws SassScriptException
|
7420 |
*/
|
@@ -7478,9 +7507,9 @@ EOL;
|
|
7478 |
*
|
7479 |
* @internal
|
7480 |
*
|
7481 |
-
* @param
|
7482 |
-
* @param
|
7483 |
-
* @param
|
7484 |
*
|
7485 |
* @return array
|
7486 |
*/
|
@@ -7584,9 +7613,9 @@ EOL;
|
|
7584 |
*
|
7585 |
* @api
|
7586 |
*
|
7587 |
-
* @param
|
7588 |
-
* @param
|
7589 |
-
* @param
|
7590 |
*
|
7591 |
* @return array
|
7592 |
*/
|
@@ -7616,9 +7645,9 @@ EOL;
|
|
7616 |
*
|
7617 |
* @api
|
7618 |
*
|
7619 |
-
* @param
|
7620 |
-
* @param
|
7621 |
-
* @param
|
7622 |
*
|
7623 |
* @return array
|
7624 |
*/
|
@@ -7746,7 +7775,6 @@ EOL;
|
|
7746 |
|
7747 |
$values = [];
|
7748 |
|
7749 |
-
|
7750 |
foreach ($list[2] as $item) {
|
7751 |
$values[] = $this->normalizeValue($item);
|
7752 |
}
|
@@ -8375,6 +8403,13 @@ EOL;
|
|
8375 |
}
|
8376 |
*/
|
8377 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8378 |
protected function adjustHsl($color, $idx, $amount)
|
8379 |
{
|
8380 |
$hsl = $this->toHSL($color[1], $color[2], $color[3]);
|
@@ -8664,7 +8699,7 @@ will be an error in future versions of Sass.\n on line $line of $fname";
|
|
8664 |
|
8665 |
$list = $this->coerceList($args[0]);
|
8666 |
|
8667 |
-
if (\count($list[2]) <= 1 && empty($list['enclosing'])) {
|
8668 |
return [Type::T_KEYWORD, 'space'];
|
8669 |
}
|
8670 |
|
@@ -8672,6 +8707,10 @@ will be an error in future versions of Sass.\n on line $line of $fname";
|
|
8672 |
return [Type::T_KEYWORD, 'comma'];
|
8673 |
}
|
8674 |
|
|
|
|
|
|
|
|
|
8675 |
return [Type::T_KEYWORD, 'space'];
|
8676 |
}
|
8677 |
|
@@ -9038,9 +9077,13 @@ will be an error in future versions of Sass.\n on line $line of $fname";
|
|
9038 |
*
|
9039 |
* @return string
|
9040 |
* @throws CompilerException
|
|
|
|
|
9041 |
*/
|
9042 |
protected function listSeparatorForJoin($list1, $sep)
|
9043 |
{
|
|
|
|
|
9044 |
if (! isset($sep)) {
|
9045 |
return $list1[1];
|
9046 |
}
|
@@ -9057,14 +9100,40 @@ will be an error in future versions of Sass.\n on line $line of $fname";
|
|
9057 |
}
|
9058 |
}
|
9059 |
|
9060 |
-
protected static $libJoin = ['list1', 'list2', 'separator:
|
9061 |
protected function libJoin($args)
|
9062 |
{
|
9063 |
list($list1, $list2, $sep, $bracketed) = $args;
|
9064 |
|
9065 |
$list1 = $this->coerceList($list1, ' ', true);
|
9066 |
$list2 = $this->coerceList($list2, ' ', true);
|
9067 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9068 |
|
9069 |
if ($bracketed === static::$true) {
|
9070 |
$bracketed = true;
|
@@ -9091,11 +9160,7 @@ will be an error in future versions of Sass.\n on line $line of $fname";
|
|
9091 |
}
|
9092 |
}
|
9093 |
|
9094 |
-
$res = [Type::T_LIST, $
|
9095 |
-
|
9096 |
-
if (isset($list1['enclosing'])) {
|
9097 |
-
$res['enlcosing'] = $list1['enclosing'];
|
9098 |
-
}
|
9099 |
|
9100 |
if ($bracketed) {
|
9101 |
$res['enclosing'] = 'bracket';
|
@@ -9104,14 +9169,35 @@ will be an error in future versions of Sass.\n on line $line of $fname";
|
|
9104 |
return $res;
|
9105 |
}
|
9106 |
|
9107 |
-
protected static $libAppend = ['list', 'val', 'separator:
|
9108 |
protected function libAppend($args)
|
9109 |
{
|
9110 |
list($list1, $value, $sep) = $args;
|
9111 |
|
9112 |
$list1 = $this->coerceList($list1, ' ', true);
|
9113 |
-
|
9114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9115 |
|
9116 |
if (isset($list1['enclosing'])) {
|
9117 |
$res['enclosing'] = $list1['enclosing'];
|
@@ -9134,7 +9220,7 @@ will be an error in future versions of Sass.\n on line $line of $fname";
|
|
9134 |
$result = [Type::T_LIST, ',', $lists];
|
9135 |
if (! \is_null($firstList)) {
|
9136 |
foreach ($firstList[2] as $key => $item) {
|
9137 |
-
$list = [Type::T_LIST, '', [$item]];
|
9138 |
|
9139 |
foreach ($argLists as $arg) {
|
9140 |
if (isset($arg[2][$key])) {
|
@@ -9514,6 +9600,8 @@ will be an error in future versions of Sass.\n on line $line of $fname";
|
|
9514 |
) {
|
9515 |
$value['enclosing'] = 'forced_' . $value['enclosing'];
|
9516 |
$force_enclosing_display = true;
|
|
|
|
|
9517 |
}
|
9518 |
|
9519 |
foreach ($value[2] as $k => $listelement) {
|
@@ -9637,7 +9725,7 @@ will be an error in future versions of Sass.\n on line $line of $fname";
|
|
9637 |
* @param array $super
|
9638 |
* @param array $sub
|
9639 |
*
|
9640 |
-
* @return
|
9641 |
*/
|
9642 |
protected function isSuperSelector($super, $sub)
|
9643 |
{
|
@@ -9718,7 +9806,7 @@ will be an error in future versions of Sass.\n on line $line of $fname";
|
|
9718 |
* @param array $superParts
|
9719 |
* @param array $subParts
|
9720 |
*
|
9721 |
-
* @return
|
9722 |
*/
|
9723 |
protected function isSuperPart($superParts, $subParts)
|
9724 |
{
|
@@ -9785,21 +9873,18 @@ will be an error in future versions of Sass.\n on line $line of $fname";
|
|
9785 |
// do the trick, happening $lastSelector to $previousSelector
|
9786 |
$appended = [];
|
9787 |
|
9788 |
-
foreach ($
|
9789 |
-
$
|
9790 |
-
|
9791 |
-
|
9792 |
-
|
9793 |
-
|
9794 |
-
|
9795 |
-
$previous[$i][$j][] = $lastSelectorPart;
|
9796 |
}
|
9797 |
}
|
9798 |
}
|
9799 |
-
}
|
9800 |
|
9801 |
-
|
9802 |
-
$appended[] = $ps;
|
9803 |
}
|
9804 |
}
|
9805 |
|
@@ -9855,10 +9940,10 @@ will be an error in future versions of Sass.\n on line $line of $fname";
|
|
9855 |
* Extend/replace in selectors
|
9856 |
* used by selector-extend and selector-replace that use the same logic
|
9857 |
*
|
9858 |
-
* @param array
|
9859 |
-
* @param array
|
9860 |
-
* @param array
|
9861 |
-
* @param
|
9862 |
*
|
9863 |
* @return array
|
9864 |
*/
|
13 |
namespace ScssPhp\ScssPhp;
|
14 |
|
15 |
use ScssPhp\ScssPhp\Base\Range;
|
16 |
+
use ScssPhp\ScssPhp\Block\AtRootBlock;
|
17 |
+
use ScssPhp\ScssPhp\Block\CallableBlock;
|
18 |
+
use ScssPhp\ScssPhp\Block\DirectiveBlock;
|
19 |
+
use ScssPhp\ScssPhp\Block\EachBlock;
|
20 |
+
use ScssPhp\ScssPhp\Block\ElseBlock;
|
21 |
+
use ScssPhp\ScssPhp\Block\ElseifBlock;
|
22 |
+
use ScssPhp\ScssPhp\Block\ForBlock;
|
23 |
+
use ScssPhp\ScssPhp\Block\IfBlock;
|
24 |
+
use ScssPhp\ScssPhp\Block\MediaBlock;
|
25 |
+
use ScssPhp\ScssPhp\Block\NestedPropertyBlock;
|
26 |
+
use ScssPhp\ScssPhp\Block\WhileBlock;
|
27 |
use ScssPhp\ScssPhp\Compiler\CachedResult;
|
28 |
use ScssPhp\ScssPhp\Compiler\Environment;
|
29 |
use ScssPhp\ScssPhp\Exception\CompilerException;
|
655 |
* @param array $target
|
656 |
* @param array $origin
|
657 |
*
|
658 |
+
* @return bool
|
659 |
*/
|
660 |
protected function isSelfExtend($target, $origin)
|
661 |
{
|
864 |
/**
|
865 |
* Match extends
|
866 |
*
|
867 |
+
* @param array $selector
|
868 |
+
* @param array $out
|
869 |
+
* @param int $from
|
870 |
+
* @param bool $initial
|
871 |
*
|
872 |
* @return void
|
873 |
*/
|
1000 |
* @param string $part
|
1001 |
* @param array $matches
|
1002 |
*
|
1003 |
+
* @return bool
|
1004 |
*/
|
1005 |
protected function isPseudoSelector($part, &$matches)
|
1006 |
{
|
1062 |
/**
|
1063 |
* Match extends single
|
1064 |
*
|
1065 |
+
* @param array $rawSingle
|
1066 |
+
* @param array $outOrigin
|
1067 |
+
* @param bool $initial
|
1068 |
*
|
1069 |
+
* @return bool
|
1070 |
*/
|
1071 |
protected function matchExtendsSingle($rawSingle, &$outOrigin, $initial = true)
|
1072 |
{
|
1281 |
*/
|
1282 |
protected function compileMedia(Block $media)
|
1283 |
{
|
1284 |
+
assert($media instanceof MediaBlock);
|
1285 |
$this->pushEnv($media);
|
1286 |
|
1287 |
$mediaQueries = $this->compileMediaQuery($this->multiplyMedia($this->env));
|
1359 |
/**
|
1360 |
* Compile directive
|
1361 |
*
|
1362 |
+
* @param DirectiveBlock|array $directive
|
1363 |
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $out
|
1364 |
*
|
1365 |
* @return void
|
1425 |
*/
|
1426 |
protected function compileAtRoot(Block $block)
|
1427 |
{
|
1428 |
+
assert($block instanceof AtRootBlock);
|
1429 |
$env = $this->pushEnv($block);
|
1430 |
$envs = $this->compactEnv($env);
|
1431 |
list($with, $without) = $this->compileWith(isset($block->with) ? $block->with : null);
|
1474 |
}
|
1475 |
|
1476 |
/**
|
1477 |
+
* Filter at-root scope depending on with/without option
|
1478 |
*
|
1479 |
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $scope
|
1480 |
* @param array $with
|
1574 |
* Find a selector by the depth node in the scope
|
1575 |
*
|
1576 |
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $scope
|
1577 |
+
* @param int $depth
|
1578 |
*
|
1579 |
* @return array
|
1580 |
*/
|
1598 |
/**
|
1599 |
* Compile @at-root's with: inclusion / without: exclusion into 2 lists uses to filter scope/env later
|
1600 |
*
|
1601 |
+
* @param array|null $withCondition
|
1602 |
*
|
1603 |
* @return array
|
1604 |
*
|
1687 |
* @param array $with
|
1688 |
* @param array $without
|
1689 |
*
|
1690 |
+
* @return bool
|
1691 |
*/
|
1692 |
protected function isWith($block, $with, $without)
|
1693 |
{
|
1697 |
}
|
1698 |
|
1699 |
if ($block->type === Type::T_DIRECTIVE) {
|
1700 |
+
assert($block instanceof DirectiveBlock || $block instanceof OutputBlock);
|
1701 |
if (isset($block->name)) {
|
1702 |
return $this->testWithWithout($this->compileDirectiveName($block->name), $with, $without);
|
1703 |
} elseif (isset($block->selectors) && preg_match(',@(\w+),ims', json_encode($block->selectors), $m)) {
|
1733 |
* @param array $with
|
1734 |
* @param array $without
|
1735 |
*
|
1736 |
+
* @return bool
|
1737 |
* true if the block should be kept, false to reject
|
1738 |
*/
|
1739 |
protected function testWithWithout($what, $with, $without)
|
1788 |
*/
|
1789 |
protected function compileNestedPropertiesBlock(Block $block, OutputBlock $out)
|
1790 |
{
|
1791 |
+
assert($block instanceof NestedPropertyBlock);
|
1792 |
$prefix = $this->compileValue($block->prefix) . '-';
|
1793 |
|
1794 |
$nested = $this->makeOutputBlock($block->type);
|
1807 |
break;
|
1808 |
|
1809 |
case Type::T_NESTED_PROPERTY:
|
1810 |
+
assert($child[1] instanceof NestedPropertyBlock);
|
1811 |
array_unshift($child[1]->prefix[2], $prefix);
|
1812 |
break;
|
1813 |
}
|
1833 |
|
1834 |
// wrap assign children in a block
|
1835 |
// except for @font-face
|
1836 |
+
if (!$block instanceof DirectiveBlock || $this->compileDirectiveName($block->name) !== 'font-face') {
|
1837 |
// need wrapping?
|
1838 |
$needWrapping = false;
|
1839 |
|
1922 |
/**
|
1923 |
* Compile the value of a comment that can have interpolation
|
1924 |
*
|
1925 |
+
* @param array $value
|
1926 |
+
* @param bool $pushEnv
|
1927 |
*
|
1928 |
* @return string
|
1929 |
*/
|
2240 |
*
|
2241 |
* @param array $selector
|
2242 |
*
|
2243 |
+
* @return bool
|
2244 |
*/
|
2245 |
protected function hasSelectorPlaceholder($selector)
|
2246 |
{
|
2657 |
*
|
2658 |
* @param array $rawPath
|
2659 |
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $out
|
2660 |
+
* @param bool $once
|
2661 |
*
|
2662 |
+
* @return bool
|
2663 |
*/
|
2664 |
protected function compileImport($rawPath, OutputBlock $out, $once = false)
|
2665 |
{
|
2794 |
// insert the directive as a comment
|
2795 |
$child = $this->makeOutputBlock(Type::T_COMMENT);
|
2796 |
$child->lines[] = $line;
|
2797 |
+
$child->sourceName = $this->sourceNames[$this->sourceIndex] ?: '(stdin)';
|
2798 |
$child->sourceLine = $this->sourceLine;
|
2799 |
$child->sourceColumn = $this->sourceColumn;
|
2800 |
|
3065 |
case Type::T_MIXIN:
|
3066 |
case Type::T_FUNCTION:
|
3067 |
list(, $block) = $child;
|
3068 |
+
assert($block instanceof CallableBlock);
|
3069 |
// the block need to be able to go up to it's parent env to resolve vars
|
3070 |
$block->parentEnv = $this->getStoreEnv();
|
3071 |
$this->set(static::$namespaces[$block->type] . $block->name, $block, true);
|
3116 |
|
3117 |
case Type::T_IF:
|
3118 |
list(, $if) = $child;
|
3119 |
+
assert($if instanceof IfBlock);
|
3120 |
|
3121 |
if ($this->isTruthy($this->reduce($if->cond, true))) {
|
3122 |
return $this->compileChildren($if->children, $out);
|
3124 |
|
3125 |
foreach ($if->cases as $case) {
|
3126 |
if (
|
3127 |
+
$case instanceof ElseBlock ||
|
3128 |
+
$case instanceof ElseifBlock && $this->isTruthy($this->reduce($case->cond))
|
3129 |
) {
|
3130 |
return $this->compileChildren($case->children, $out);
|
3131 |
}
|
3134 |
|
3135 |
case Type::T_EACH:
|
3136 |
list(, $each) = $child;
|
3137 |
+
assert($each instanceof EachBlock);
|
3138 |
|
3139 |
$list = $this->coerceList($this->reduce($each->list), ',', true);
|
3140 |
|
3169 |
|
3170 |
case Type::T_WHILE:
|
3171 |
list(, $while) = $child;
|
3172 |
+
assert($while instanceof WhileBlock);
|
3173 |
|
3174 |
while ($this->isTruthy($this->reduce($while->cond, true))) {
|
3175 |
$ret = $this->compileChildren($while->children, $out);
|
3182 |
|
3183 |
case Type::T_FOR:
|
3184 |
list(, $for) = $child;
|
3185 |
+
assert($for instanceof ForBlock);
|
3186 |
|
3187 |
$startNumber = $this->assertNumber($this->reduce($for->start, true));
|
3188 |
$endNumber = $this->assertNumber($this->reduce($for->end, true));
|
3243 |
throw $this->error("Undefined mixin $name");
|
3244 |
}
|
3245 |
|
3246 |
+
assert($mixin instanceof CallableBlock);
|
3247 |
+
|
3248 |
$callingScope = $this->getStoreEnv();
|
3249 |
|
3250 |
// push scope, apply args
|
3417 |
*
|
3418 |
* @param array|Number $value
|
3419 |
*
|
3420 |
+
* @return bool
|
3421 |
*/
|
3422 |
public function isTruthy($value)
|
3423 |
{
|
3429 |
*
|
3430 |
* @param string $value
|
3431 |
*
|
3432 |
+
* @return bool
|
3433 |
*/
|
3434 |
protected function isImmediateRelationshipCombinator($value)
|
3435 |
{
|
3441 |
*
|
3442 |
* @param array $value
|
3443 |
*
|
3444 |
+
* @return bool
|
3445 |
*/
|
3446 |
protected function shouldEval($value)
|
3447 |
{
|
3464 |
* Reduce value
|
3465 |
*
|
3466 |
* @param array|Number $value
|
3467 |
+
* @param bool $inExp
|
3468 |
*
|
3469 |
* @return array|Number
|
3470 |
*/
|
3969 |
unset($value['enclosing']);
|
3970 |
}
|
3971 |
|
3972 |
+
if ($value[1] === '' && count($value[2]) > 1) {
|
3973 |
+
$value[1] = ' ';
|
3974 |
+
}
|
3975 |
+
|
3976 |
return $value;
|
3977 |
|
3978 |
case Type::T_STRING:
|
4088 |
* Boolean and
|
4089 |
*
|
4090 |
* @param array|Number $left
|
4091 |
+
* @param array|Number $right
|
4092 |
+
* @param bool $shouldEval
|
4093 |
*
|
4094 |
* @return array|Number|null
|
4095 |
*/
|
4117 |
*
|
4118 |
* @param array|Number $left
|
4119 |
* @param array|Number $right
|
4120 |
+
* @param bool $shouldEval
|
4121 |
*
|
4122 |
* @return array|Number|null
|
4123 |
*/
|
4543 |
// force double quote as string quote for the output in certain cases
|
4544 |
if (
|
4545 |
$value[1] === "'" &&
|
4546 |
+
(strpos($content, '"') === false or strpos($content, "'") !== false)
|
|
|
4547 |
) {
|
4548 |
$value[1] = '"';
|
4549 |
} elseif (
|
4596 |
}
|
4597 |
}
|
4598 |
|
4599 |
+
$separator = $delim === '/' ? ' /' : $delim;
|
4600 |
+
|
4601 |
$prefix_value = '';
|
4602 |
|
4603 |
if ($delim !== ' ') {
|
4636 |
$filtered[] = $compiled;
|
4637 |
}
|
4638 |
|
4639 |
+
return $pre . substr(implode($separator, $filtered), \strlen($prefix_value)) . $post;
|
4640 |
|
4641 |
case Type::T_MAP:
|
4642 |
$keys = $value[1];
|
4908 |
/**
|
4909 |
* Join selectors; looks for & to replace, or append parent before child
|
4910 |
*
|
4911 |
+
* @param array $parent
|
4912 |
+
* @param array $child
|
4913 |
+
* @param bool $stillHasSelf
|
4914 |
+
* @param array $selfParentSelectors
|
4915 |
|
4916 |
* @return array
|
4917 |
*/
|
4989 |
return $this->multiplyMedia($env->parent, $childQueries);
|
4990 |
}
|
4991 |
|
4992 |
+
assert($env->block instanceof MediaBlock);
|
4993 |
+
|
4994 |
$parentQueries = isset($env->block->queryList)
|
4995 |
? $env->block->queryList
|
4996 |
: [[[Type::T_MEDIA_VALUE, $env->block->value]]];
|
5125 |
*
|
5126 |
* @param string $name
|
5127 |
* @param mixed $value
|
5128 |
+
* @param bool $shadow
|
5129 |
* @param \ScssPhp\ScssPhp\Compiler\Environment $env
|
5130 |
* @param mixed $valueUnreduced
|
5131 |
*
|
5231 |
* @internal
|
5232 |
*
|
5233 |
* @param string $name
|
5234 |
+
* @param bool $shouldThrow
|
5235 |
* @param \ScssPhp\ScssPhp\Compiler\Environment $env
|
5236 |
+
* @param bool $unreduced
|
5237 |
*
|
5238 |
* @return mixed|null
|
5239 |
*/
|
5300 |
* @param string $name
|
5301 |
* @param \ScssPhp\ScssPhp\Compiler\Environment $env
|
5302 |
*
|
5303 |
+
* @return bool
|
5304 |
*/
|
5305 |
protected function has($name, Environment $env = null)
|
5306 |
{
|
5490 |
*
|
5491 |
* @api
|
5492 |
*
|
5493 |
+
* @param int $numberPrecision
|
5494 |
*
|
5495 |
* @return void
|
5496 |
*
|
5591 |
*
|
5592 |
* @api
|
5593 |
*
|
5594 |
+
* @param int $sourceMap
|
5595 |
*
|
5596 |
* @return void
|
5597 |
*
|
5993 |
*
|
5994 |
* @api
|
5995 |
*
|
5996 |
+
* @param bool $ignoreErrors
|
5997 |
*
|
5998 |
* @return \ScssPhp\ScssPhp\Compiler
|
5999 |
*
|
6132 |
/**
|
6133 |
* Beautify call stack for output
|
6134 |
*
|
6135 |
+
* @param bool $all
|
6136 |
* @param int|null $limit
|
6137 |
*
|
6138 |
* @return string
|
6192 |
/**
|
6193 |
* Call SCSS @function
|
6194 |
*
|
6195 |
+
* @param CallableBlock|null $func
|
6196 |
+
* @param array $argValues
|
6197 |
*
|
6198 |
* @return array|Number
|
6199 |
*/
|
6767 |
*
|
6768 |
* @param array[] $argDef
|
6769 |
* @param array|null $argValues
|
6770 |
+
* @param bool $storeInEnv
|
6771 |
+
* @param bool $reduce only used if $storeInEnv = false
|
|
|
6772 |
*
|
6773 |
* @return array<string, array|Number>
|
6774 |
*
|
7012 |
*
|
7013 |
* @param array|Number $item
|
7014 |
* @param string $delim
|
7015 |
+
* @param bool $removeTrailingNull
|
7016 |
*
|
7017 |
* @return array
|
7018 |
*/
|
7019 |
protected function coerceList($item, $delim = ',', $removeTrailingNull = false)
|
7020 |
{
|
7021 |
if ($item instanceof Number) {
|
7022 |
+
return [Type::T_LIST, '', [$item]];
|
7023 |
}
|
7024 |
|
7025 |
if ($item[0] === Type::T_LIST) {
|
7042 |
|
7043 |
$list[] = [
|
7044 |
Type::T_LIST,
|
7045 |
+
' ',
|
7046 |
[$key, $value]
|
7047 |
];
|
7048 |
}
|
7049 |
|
7050 |
+
return [Type::T_LIST, $list ? ',' : '', $list];
|
7051 |
}
|
7052 |
|
7053 |
+
return [Type::T_LIST, '', [$item]];
|
7054 |
}
|
7055 |
|
7056 |
/**
|
7191 |
}
|
7192 |
|
7193 |
/**
|
7194 |
+
* @param int|Number $value
|
7195 |
+
* @param bool $isAlpha
|
7196 |
*
|
7197 |
+
* @return int|mixed
|
7198 |
*/
|
7199 |
protected function compileRGBAValue($value, $isAlpha = false)
|
7200 |
{
|
7206 |
}
|
7207 |
|
7208 |
/**
|
7209 |
+
* @param mixed $value
|
7210 |
+
* @param int|float $min
|
7211 |
+
* @param int|float $max
|
7212 |
+
* @param bool $isInt
|
7213 |
*
|
7214 |
+
* @return int|mixed
|
7215 |
*/
|
7216 |
protected function compileColorPartValue($value, $min, $max, $isInt = true)
|
7217 |
{
|
7305 |
*
|
7306 |
* @param array|Number $value
|
7307 |
*
|
7308 |
+
* @return int|float
|
7309 |
*
|
7310 |
* @deprecated
|
7311 |
*/
|
7443 |
* @param array|Number $value
|
7444 |
* @param string|null $varName
|
7445 |
*
|
7446 |
+
* @return int
|
7447 |
*
|
7448 |
* @throws SassScriptException
|
7449 |
*/
|
7507 |
*
|
7508 |
* @internal
|
7509 |
*
|
7510 |
+
* @param int $red
|
7511 |
+
* @param int $green
|
7512 |
+
* @param int $blue
|
7513 |
*
|
7514 |
* @return array
|
7515 |
*/
|
7613 |
*
|
7614 |
* @api
|
7615 |
*
|
7616 |
+
* @param int $hue H from 0 to 360
|
7617 |
+
* @param int $whiteness W from 0 to 100
|
7618 |
+
* @param int $blackness B from 0 to 100
|
7619 |
*
|
7620 |
* @return array
|
7621 |
*/
|
7645 |
*
|
7646 |
* @api
|
7647 |
*
|
7648 |
+
* @param int $red
|
7649 |
+
* @param int $green
|
7650 |
+
* @param int $blue
|
7651 |
*
|
7652 |
* @return array
|
7653 |
*/
|
7775 |
|
7776 |
$values = [];
|
7777 |
|
|
|
7778 |
foreach ($list[2] as $item) {
|
7779 |
$values[] = $this->normalizeValue($item);
|
7780 |
}
|
8403 |
}
|
8404 |
*/
|
8405 |
|
8406 |
+
/**
|
8407 |
+
* @param array $color
|
8408 |
+
* @param int $idx
|
8409 |
+
* @param int|float $amount
|
8410 |
+
*
|
8411 |
+
* @return array
|
8412 |
+
*/
|
8413 |
protected function adjustHsl($color, $idx, $amount)
|
8414 |
{
|
8415 |
$hsl = $this->toHSL($color[1], $color[2], $color[3]);
|
8699 |
|
8700 |
$list = $this->coerceList($args[0]);
|
8701 |
|
8702 |
+
if ($list[1] === '' && \count($list[2]) <= 1 && empty($list['enclosing'])) {
|
8703 |
return [Type::T_KEYWORD, 'space'];
|
8704 |
}
|
8705 |
|
8707 |
return [Type::T_KEYWORD, 'comma'];
|
8708 |
}
|
8709 |
|
8710 |
+
if ($list[1] === '/') {
|
8711 |
+
return [Type::T_KEYWORD, 'slash'];
|
8712 |
+
}
|
8713 |
+
|
8714 |
return [Type::T_KEYWORD, 'space'];
|
8715 |
}
|
8716 |
|
9077 |
*
|
9078 |
* @return string
|
9079 |
* @throws CompilerException
|
9080 |
+
*
|
9081 |
+
* @deprecated
|
9082 |
*/
|
9083 |
protected function listSeparatorForJoin($list1, $sep)
|
9084 |
{
|
9085 |
+
@trigger_error(sprintf('The "%s" method is deprecated.', __METHOD__), E_USER_DEPRECATED);
|
9086 |
+
|
9087 |
if (! isset($sep)) {
|
9088 |
return $list1[1];
|
9089 |
}
|
9100 |
}
|
9101 |
}
|
9102 |
|
9103 |
+
protected static $libJoin = ['list1', 'list2', 'separator:auto', 'bracketed:auto'];
|
9104 |
protected function libJoin($args)
|
9105 |
{
|
9106 |
list($list1, $list2, $sep, $bracketed) = $args;
|
9107 |
|
9108 |
$list1 = $this->coerceList($list1, ' ', true);
|
9109 |
$list2 = $this->coerceList($list2, ' ', true);
|
9110 |
+
|
9111 |
+
switch ($this->compileStringContent($this->assertString($sep, 'separator'))) {
|
9112 |
+
case 'comma':
|
9113 |
+
$separator = ',';
|
9114 |
+
break;
|
9115 |
+
|
9116 |
+
case 'space':
|
9117 |
+
$separator = ' ';
|
9118 |
+
break;
|
9119 |
+
|
9120 |
+
case 'slash':
|
9121 |
+
$separator = '/';
|
9122 |
+
break;
|
9123 |
+
|
9124 |
+
case 'auto':
|
9125 |
+
if ($list1[1] !== '' || count($list1[2]) > 1 || !empty($list1['enclosing']) && $list1['enclosing'] !== 'parent') {
|
9126 |
+
$separator = $list1[1] ?: ' ';
|
9127 |
+
} elseif ($list2[1] !== '' || count($list2[2]) > 1 || !empty($list2['enclosing']) && $list2['enclosing'] !== 'parent') {
|
9128 |
+
$separator = $list2[1] ?: ' ';
|
9129 |
+
} else {
|
9130 |
+
$separator = ' ';
|
9131 |
+
}
|
9132 |
+
break;
|
9133 |
+
|
9134 |
+
default:
|
9135 |
+
throw SassScriptException::forArgument('Must be "space", "comma", "slash", or "auto".', 'separator');
|
9136 |
+
}
|
9137 |
|
9138 |
if ($bracketed === static::$true) {
|
9139 |
$bracketed = true;
|
9160 |
}
|
9161 |
}
|
9162 |
|
9163 |
+
$res = [Type::T_LIST, $separator, array_merge($list1[2], $list2[2])];
|
|
|
|
|
|
|
|
|
9164 |
|
9165 |
if ($bracketed) {
|
9166 |
$res['enclosing'] = 'bracket';
|
9169 |
return $res;
|
9170 |
}
|
9171 |
|
9172 |
+
protected static $libAppend = ['list', 'val', 'separator:auto'];
|
9173 |
protected function libAppend($args)
|
9174 |
{
|
9175 |
list($list1, $value, $sep) = $args;
|
9176 |
|
9177 |
$list1 = $this->coerceList($list1, ' ', true);
|
9178 |
+
|
9179 |
+
switch ($this->compileStringContent($this->assertString($sep, 'separator'))) {
|
9180 |
+
case 'comma':
|
9181 |
+
$separator = ',';
|
9182 |
+
break;
|
9183 |
+
|
9184 |
+
case 'space':
|
9185 |
+
$separator = ' ';
|
9186 |
+
break;
|
9187 |
+
|
9188 |
+
case 'slash':
|
9189 |
+
$separator = '/';
|
9190 |
+
break;
|
9191 |
+
|
9192 |
+
case 'auto':
|
9193 |
+
$separator = $list1[1] === '' && \count($list1[2]) <= 1 && (empty($list1['enclosing']) || $list1['enclosing'] === 'parent') ? ' ' : $list1[1];
|
9194 |
+
break;
|
9195 |
+
|
9196 |
+
default:
|
9197 |
+
throw SassScriptException::forArgument('Must be "space", "comma", "slash", or "auto".', 'separator');
|
9198 |
+
}
|
9199 |
+
|
9200 |
+
$res = [Type::T_LIST, $separator, array_merge($list1[2], [$value])];
|
9201 |
|
9202 |
if (isset($list1['enclosing'])) {
|
9203 |
$res['enclosing'] = $list1['enclosing'];
|
9220 |
$result = [Type::T_LIST, ',', $lists];
|
9221 |
if (! \is_null($firstList)) {
|
9222 |
foreach ($firstList[2] as $key => $item) {
|
9223 |
+
$list = [Type::T_LIST, ' ', [$item]];
|
9224 |
|
9225 |
foreach ($argLists as $arg) {
|
9226 |
if (isset($arg[2][$key])) {
|
9600 |
) {
|
9601 |
$value['enclosing'] = 'forced_' . $value['enclosing'];
|
9602 |
$force_enclosing_display = true;
|
9603 |
+
} elseif (! \count($value[2])) {
|
9604 |
+
$value['enclosing'] = 'forced_parent';
|
9605 |
}
|
9606 |
|
9607 |
foreach ($value[2] as $k => $listelement) {
|
9725 |
* @param array $super
|
9726 |
* @param array $sub
|
9727 |
*
|
9728 |
+
* @return bool
|
9729 |
*/
|
9730 |
protected function isSuperSelector($super, $sub)
|
9731 |
{
|
9806 |
* @param array $superParts
|
9807 |
* @param array $subParts
|
9808 |
*
|
9809 |
+
* @return bool
|
9810 |
*/
|
9811 |
protected function isSuperPart($superParts, $subParts)
|
9812 |
{
|
9873 |
// do the trick, happening $lastSelector to $previousSelector
|
9874 |
$appended = [];
|
9875 |
|
9876 |
+
foreach ($previousSelectors as $previousSelector) {
|
9877 |
+
foreach ($lastSelectors as $lastSelector) {
|
9878 |
+
$previous = $previousSelector;
|
9879 |
+
foreach ($previousSelector as $j => $previousSelectorParts) {
|
9880 |
+
foreach ($lastSelector as $lastSelectorParts) {
|
9881 |
+
foreach ($lastSelectorParts as $lastSelectorPart) {
|
9882 |
+
$previous[$j][] = $lastSelectorPart;
|
|
|
9883 |
}
|
9884 |
}
|
9885 |
}
|
|
|
9886 |
|
9887 |
+
$appended[] = $previous;
|
|
|
9888 |
}
|
9889 |
}
|
9890 |
|
9940 |
* Extend/replace in selectors
|
9941 |
* used by selector-extend and selector-replace that use the same logic
|
9942 |
*
|
9943 |
+
* @param array $selectors
|
9944 |
+
* @param array $extendee
|
9945 |
+
* @param array $extender
|
9946 |
+
* @param bool $replace
|
9947 |
*
|
9948 |
* @return array
|
9949 |
*/
|
vendor/scssphp/scssphp/src/Compiler/Environment.php
CHANGED
@@ -31,6 +31,26 @@ class Environment
|
|
31 |
*/
|
32 |
public $parent;
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
/**
|
35 |
* @var array
|
36 |
*/
|
@@ -42,7 +62,7 @@ class Environment
|
|
42 |
public $storeUnreduced;
|
43 |
|
44 |
/**
|
45 |
-
* @var
|
46 |
*/
|
47 |
public $depth;
|
48 |
}
|
31 |
*/
|
32 |
public $parent;
|
33 |
|
34 |
+
/**
|
35 |
+
* @var Environment|null
|
36 |
+
*/
|
37 |
+
public $declarationScopeParent;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @var Environment|null
|
41 |
+
*/
|
42 |
+
public $parentStore;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @var array|null
|
46 |
+
*/
|
47 |
+
public $selectors;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @var string|null
|
51 |
+
*/
|
52 |
+
public $marker;
|
53 |
+
|
54 |
/**
|
55 |
* @var array
|
56 |
*/
|
62 |
public $storeUnreduced;
|
63 |
|
64 |
/**
|
65 |
+
* @var int
|
66 |
*/
|
67 |
public $depth;
|
68 |
}
|
vendor/scssphp/scssphp/src/Formatter.php
CHANGED
@@ -25,7 +25,7 @@ use ScssPhp\ScssPhp\SourceMap\SourceMapGenerator;
|
|
25 |
abstract class Formatter
|
26 |
{
|
27 |
/**
|
28 |
-
* @var
|
29 |
*/
|
30 |
public $indentLevel;
|
31 |
|
@@ -60,7 +60,7 @@ abstract class Formatter
|
|
60 |
public $assignSeparator;
|
61 |
|
62 |
/**
|
63 |
-
* @var
|
64 |
*/
|
65 |
public $keepSemicolons;
|
66 |
|
@@ -70,12 +70,12 @@ abstract class Formatter
|
|
70 |
protected $currentBlock;
|
71 |
|
72 |
/**
|
73 |
-
* @var
|
74 |
*/
|
75 |
protected $currentLine;
|
76 |
|
77 |
/**
|
78 |
-
* @var
|
79 |
*/
|
80 |
protected $currentColumn;
|
81 |
|
@@ -239,7 +239,7 @@ abstract class Formatter
|
|
239 |
*
|
240 |
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
|
241 |
*
|
242 |
-
* @return
|
243 |
*/
|
244 |
protected function testEmptyChildren($block)
|
245 |
{
|
25 |
abstract class Formatter
|
26 |
{
|
27 |
/**
|
28 |
+
* @var int
|
29 |
*/
|
30 |
public $indentLevel;
|
31 |
|
60 |
public $assignSeparator;
|
61 |
|
62 |
/**
|
63 |
+
* @var bool
|
64 |
*/
|
65 |
public $keepSemicolons;
|
66 |
|
70 |
protected $currentBlock;
|
71 |
|
72 |
/**
|
73 |
+
* @var int
|
74 |
*/
|
75 |
protected $currentLine;
|
76 |
|
77 |
/**
|
78 |
+
* @var int
|
79 |
*/
|
80 |
protected $currentColumn;
|
81 |
|
239 |
*
|
240 |
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
|
241 |
*
|
242 |
+
* @return bool
|
243 |
*/
|
244 |
protected function testEmptyChildren($block)
|
245 |
{
|
vendor/scssphp/scssphp/src/Formatter/Compressed.php
CHANGED
@@ -50,8 +50,6 @@ class Compressed extends Formatter
|
|
50 |
foreach ($block->lines as $index => $line) {
|
51 |
if (substr($line, 0, 2) === '/*' && substr($line, 2, 1) !== '!') {
|
52 |
unset($block->lines[$index]);
|
53 |
-
} elseif (substr($line, 0, 3) === '/*!') {
|
54 |
-
$block->lines[$index] = '/*' . substr($line, 3);
|
55 |
}
|
56 |
}
|
57 |
|
50 |
foreach ($block->lines as $index => $line) {
|
51 |
if (substr($line, 0, 2) === '/*' && substr($line, 2, 1) !== '!') {
|
52 |
unset($block->lines[$index]);
|
|
|
|
|
53 |
}
|
54 |
}
|
55 |
|
vendor/scssphp/scssphp/src/Formatter/Nested.php
CHANGED
@@ -27,7 +27,7 @@ use ScssPhp\ScssPhp\Type;
|
|
27 |
class Nested extends Formatter
|
28 |
{
|
29 |
/**
|
30 |
-
* @var
|
31 |
*/
|
32 |
private $depth;
|
33 |
|
@@ -221,7 +221,7 @@ class Nested extends Formatter
|
|
221 |
*
|
222 |
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
|
223 |
*
|
224 |
-
* @return
|
225 |
*/
|
226 |
private function hasFlatChild($block)
|
227 |
{
|
27 |
class Nested extends Formatter
|
28 |
{
|
29 |
/**
|
30 |
+
* @var int
|
31 |
*/
|
32 |
private $depth;
|
33 |
|
221 |
*
|
222 |
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
|
223 |
*
|
224 |
+
* @return bool
|
225 |
*/
|
226 |
private function hasFlatChild($block)
|
227 |
{
|
vendor/scssphp/scssphp/src/Formatter/OutputBlock.php
CHANGED
@@ -27,7 +27,7 @@ class OutputBlock
|
|
27 |
public $type;
|
28 |
|
29 |
/**
|
30 |
-
* @var
|
31 |
*/
|
32 |
public $depth;
|
33 |
|
@@ -57,12 +57,12 @@ class OutputBlock
|
|
57 |
public $sourceName;
|
58 |
|
59 |
/**
|
60 |
-
* @var
|
61 |
*/
|
62 |
public $sourceLine;
|
63 |
|
64 |
/**
|
65 |
-
* @var
|
66 |
*/
|
67 |
public $sourceColumn;
|
68 |
}
|
27 |
public $type;
|
28 |
|
29 |
/**
|
30 |
+
* @var int
|
31 |
*/
|
32 |
public $depth;
|
33 |
|
57 |
public $sourceName;
|
58 |
|
59 |
/**
|
60 |
+
* @var int|null
|
61 |
*/
|
62 |
public $sourceLine;
|
63 |
|
64 |
/**
|
65 |
+
* @var int|null
|
66 |
*/
|
67 |
public $sourceColumn;
|
68 |
}
|
vendor/scssphp/scssphp/src/Node.php
CHANGED
@@ -27,7 +27,7 @@ abstract class Node
|
|
27 |
public $type;
|
28 |
|
29 |
/**
|
30 |
-
* @var
|
31 |
*/
|
32 |
public $sourceIndex;
|
33 |
|
27 |
public $type;
|
28 |
|
29 |
/**
|
30 |
+
* @var int
|
31 |
*/
|
32 |
public $sourceIndex;
|
33 |
|
vendor/scssphp/scssphp/src/Node/Number.php
CHANGED
@@ -38,7 +38,7 @@ class Number extends Node implements \ArrayAccess
|
|
38 |
const PRECISION = 10;
|
39 |
|
40 |
/**
|
41 |
-
* @var
|
42 |
* @deprecated use {Number::PRECISION} instead to read the precision. Configuring it is not supported anymore.
|
43 |
*/
|
44 |
public static $precision = self::PRECISION;
|
@@ -81,7 +81,7 @@ class Number extends Node implements \ArrayAccess
|
|
81 |
];
|
82 |
|
83 |
/**
|
84 |
-
* @var
|
85 |
*/
|
86 |
private $dimension;
|
87 |
|
@@ -100,7 +100,7 @@ class Number extends Node implements \ArrayAccess
|
|
100 |
/**
|
101 |
* Initialize number
|
102 |
*
|
103 |
-
* @param
|
104 |
* @param string[]|string $numeratorUnits
|
105 |
* @param string[] $denominatorUnits
|
106 |
*
|
@@ -147,7 +147,7 @@ class Number extends Node implements \ArrayAccess
|
|
147 |
}
|
148 |
|
149 |
/**
|
150 |
-
*
|
151 |
*/
|
152 |
#[\ReturnTypeWillChange]
|
153 |
public function offsetExists($offset)
|
@@ -173,7 +173,7 @@ class Number extends Node implements \ArrayAccess
|
|
173 |
}
|
174 |
|
175 |
/**
|
176 |
-
*
|
177 |
*/
|
178 |
#[\ReturnTypeWillChange]
|
179 |
public function offsetGet($offset)
|
@@ -200,7 +200,7 @@ class Number extends Node implements \ArrayAccess
|
|
200 |
}
|
201 |
|
202 |
/**
|
203 |
-
*
|
204 |
*/
|
205 |
#[\ReturnTypeWillChange]
|
206 |
public function offsetSet($offset, $value)
|
@@ -209,7 +209,7 @@ class Number extends Node implements \ArrayAccess
|
|
209 |
}
|
210 |
|
211 |
/**
|
212 |
-
*
|
213 |
*/
|
214 |
#[\ReturnTypeWillChange]
|
215 |
public function offsetUnset($offset)
|
@@ -220,7 +220,7 @@ class Number extends Node implements \ArrayAccess
|
|
220 |
/**
|
221 |
* Returns true if the number is unitless
|
222 |
*
|
223 |
-
* @return
|
224 |
*/
|
225 |
public function unitless()
|
226 |
{
|
38 |
const PRECISION = 10;
|
39 |
|
40 |
/**
|
41 |
+
* @var int
|
42 |
* @deprecated use {Number::PRECISION} instead to read the precision. Configuring it is not supported anymore.
|
43 |
*/
|
44 |
public static $precision = self::PRECISION;
|
81 |
];
|
82 |
|
83 |
/**
|
84 |
+
* @var int|float
|
85 |
*/
|
86 |
private $dimension;
|
87 |
|
100 |
/**
|
101 |
* Initialize number
|
102 |
*
|
103 |
+
* @param int|float $dimension
|
104 |
* @param string[]|string $numeratorUnits
|
105 |
* @param string[] $denominatorUnits
|
106 |
*
|
147 |
}
|
148 |
|
149 |
/**
|
150 |
+
* @return bool
|
151 |
*/
|
152 |
#[\ReturnTypeWillChange]
|
153 |
public function offsetExists($offset)
|
173 |
}
|
174 |
|
175 |
/**
|
176 |
+
* @return mixed
|
177 |
*/
|
178 |
#[\ReturnTypeWillChange]
|
179 |
public function offsetGet($offset)
|
200 |
}
|
201 |
|
202 |
/**
|
203 |
+
* @return void
|
204 |
*/
|
205 |
#[\ReturnTypeWillChange]
|
206 |
public function offsetSet($offset, $value)
|
209 |
}
|
210 |
|
211 |
/**
|
212 |
+
* @return void
|
213 |
*/
|
214 |
#[\ReturnTypeWillChange]
|
215 |
public function offsetUnset($offset)
|
220 |
/**
|
221 |
* Returns true if the number is unitless
|
222 |
*
|
223 |
+
* @return bool
|
224 |
*/
|
225 |
public function unitless()
|
226 |
{
|
vendor/scssphp/scssphp/src/Parser.php
CHANGED
@@ -12,6 +12,18 @@
|
|
12 |
|
13 |
namespace ScssPhp\ScssPhp;
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
use ScssPhp\ScssPhp\Exception\ParserException;
|
16 |
use ScssPhp\ScssPhp\Logger\LoggerInterface;
|
17 |
use ScssPhp\ScssPhp\Logger\QuietLogger;
|
@@ -125,7 +137,7 @@ class Parser
|
|
125 |
* @api
|
126 |
*
|
127 |
* @param string|null $sourceName
|
128 |
-
* @param
|
129 |
* @param string|null $encoding
|
130 |
* @param Cache|null $cache
|
131 |
* @param bool $cssOnly
|
@@ -305,7 +317,7 @@ class Parser
|
|
305 |
* @param string $buffer
|
306 |
* @param string|array $out
|
307 |
*
|
308 |
-
* @return
|
309 |
*/
|
310 |
public function parseValue($buffer, &$out)
|
311 |
{
|
@@ -334,7 +346,7 @@ class Parser
|
|
334 |
* @param string|array $out
|
335 |
* @param bool $shouldValidate
|
336 |
*
|
337 |
-
* @return
|
338 |
*/
|
339 |
public function parseSelector($buffer, &$out, $shouldValidate = true)
|
340 |
{
|
@@ -371,7 +383,7 @@ class Parser
|
|
371 |
* @param string $buffer
|
372 |
* @param string|array $out
|
373 |
*
|
374 |
-
* @return
|
375 |
*/
|
376 |
public function parseMediaQueryList($buffer, &$out)
|
377 |
{
|
@@ -428,7 +440,7 @@ class Parser
|
|
428 |
* position into $s. Then if a chain fails, use $this->seek($s) to
|
429 |
* go back where we started.
|
430 |
*
|
431 |
-
* @return
|
432 |
*/
|
433 |
protected function parseChunk()
|
434 |
{
|
@@ -447,7 +459,8 @@ class Parser
|
|
447 |
) {
|
448 |
! $this->cssOnly || $this->assertPlainCssValid(false, $s);
|
449 |
|
450 |
-
$atRoot =
|
|
|
451 |
$atRoot->selector = $selector;
|
452 |
$atRoot->with = $with;
|
453 |
|
@@ -461,7 +474,8 @@ class Parser
|
|
461 |
$this->mediaQueryList($mediaQueryList) &&
|
462 |
$this->matchChar('{', false)
|
463 |
) {
|
464 |
-
$media =
|
|
|
465 |
$media->queryList = $mediaQueryList[2];
|
466 |
|
467 |
return true;
|
@@ -477,7 +491,8 @@ class Parser
|
|
477 |
) {
|
478 |
! $this->cssOnly || $this->assertPlainCssValid(false, $s);
|
479 |
|
480 |
-
$mixin =
|
|
|
481 |
$mixin->name = $mixinName;
|
482 |
$mixin->args = $args;
|
483 |
|
@@ -509,7 +524,8 @@ class Parser
|
|
509 |
];
|
510 |
|
511 |
if (! empty($hasBlock)) {
|
512 |
-
$include =
|
|
|
513 |
$include->child = $child;
|
514 |
} else {
|
515 |
$this->append($child, $s);
|
@@ -599,7 +615,8 @@ class Parser
|
|
599 |
) {
|
600 |
! $this->cssOnly || $this->assertPlainCssValid(false, $s);
|
601 |
|
602 |
-
$func =
|
|
|
603 |
$func->name = $fnName;
|
604 |
$func->args = $args;
|
605 |
|
@@ -631,7 +648,8 @@ class Parser
|
|
631 |
) {
|
632 |
! $this->cssOnly || $this->assertPlainCssValid(false, $s);
|
633 |
|
634 |
-
$each =
|
|
|
635 |
|
636 |
foreach ($varNames[2] as $varName) {
|
637 |
$each->vars[] = $varName[1];
|
@@ -660,7 +678,8 @@ class Parser
|
|
660 |
$cond = reset($cond[2]);
|
661 |
}
|
662 |
|
663 |
-
$while =
|
|
|
664 |
$while->cond = $cond;
|
665 |
|
666 |
return true;
|
@@ -680,7 +699,8 @@ class Parser
|
|
680 |
) {
|
681 |
! $this->cssOnly || $this->assertPlainCssValid(false, $s);
|
682 |
|
683 |
-
$for =
|
|
|
684 |
$for->var = $varName[1];
|
685 |
$for->start = $start;
|
686 |
$for->end = $end;
|
@@ -697,7 +717,8 @@ class Parser
|
|
697 |
) {
|
698 |
! $this->cssOnly || $this->assertPlainCssValid(false, $s);
|
699 |
|
700 |
-
$if =
|
|
|
701 |
|
702 |
while (
|
703 |
$cond[0] === Type::T_LIST &&
|
@@ -776,20 +797,21 @@ class Parser
|
|
776 |
|
777 |
if (isset($last) && $last[0] === Type::T_IF) {
|
778 |
list(, $if) = $last;
|
|
|
779 |
|
780 |
if ($this->literal('@else', 5)) {
|
781 |
if ($this->matchChar('{', false)) {
|
782 |
-
$else =
|
783 |
} elseif (
|
784 |
$this->literal('if', 2) &&
|
785 |
$this->functionCallArgumentsList($cond, false, '{', false)
|
786 |
) {
|
787 |
-
$else =
|
788 |
$else->cond = $cond;
|
789 |
}
|
790 |
|
791 |
if (isset($else)) {
|
792 |
-
$else
|
793 |
$if->cases[] = $else;
|
794 |
|
795 |
return true;
|
@@ -827,7 +849,8 @@ class Parser
|
|
827 |
($t1 = $this->supportsQuery($supportQuery)) &&
|
828 |
($t2 = $this->matchChar('{', false))
|
829 |
) {
|
830 |
-
$directive =
|
|
|
831 |
$directive->name = 'supports';
|
832 |
$directive->value = $supportQuery;
|
833 |
|
@@ -848,11 +871,12 @@ class Parser
|
|
848 |
$dirName = [Type::T_STRING, '', $dirName];
|
849 |
}
|
850 |
if ($dirName === 'media') {
|
851 |
-
$directive =
|
852 |
} else {
|
853 |
-
$directive =
|
854 |
$directive->name = $dirName;
|
855 |
}
|
|
|
856 |
|
857 |
if (isset($dirValue)) {
|
858 |
! $this->cssOnly || ($dirValue = $this->assertPlainCssValid($dirValue));
|
@@ -1028,7 +1052,8 @@ class Parser
|
|
1028 |
if ($this->matchChar('{', false)) {
|
1029 |
! $this->cssOnly || $this->assertPlainCssValid(false);
|
1030 |
|
1031 |
-
$propBlock =
|
|
|
1032 |
$propBlock->prefix = $name;
|
1033 |
$propBlock->hasValue = $foundSomething;
|
1034 |
|
@@ -1054,12 +1079,13 @@ class Parser
|
|
1054 |
}
|
1055 |
}
|
1056 |
|
1057 |
-
if (
|
1058 |
$include = $block->child;
|
|
|
1059 |
unset($block->child);
|
1060 |
$include[3] = $block;
|
1061 |
$this->append($include, $s);
|
1062 |
-
} elseif (
|
1063 |
$type = isset($block->type) ? $block->type : Type::T_BLOCK;
|
1064 |
$this->append([$type, $block], $s);
|
1065 |
}
|
@@ -1088,20 +1114,34 @@ class Parser
|
|
1088 |
* Push block onto parse tree
|
1089 |
*
|
1090 |
* @param array|null $selectors
|
1091 |
-
* @param
|
1092 |
*
|
1093 |
* @return Block
|
1094 |
*/
|
1095 |
protected function pushBlock($selectors, $pos = 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1096 |
{
|
1097 |
list($line, $column) = $this->getSourcePosition($pos);
|
1098 |
|
1099 |
-
$b = new Block();
|
1100 |
$b->sourceName = $this->sourceName;
|
1101 |
$b->sourceLine = $line;
|
1102 |
$b->sourceColumn = $column;
|
1103 |
$b->sourceIndex = $this->sourceIndex;
|
1104 |
-
$b->selectors = $selectors;
|
1105 |
$b->comments = [];
|
1106 |
$b->parent = $this->env;
|
1107 |
|
@@ -1126,15 +1166,15 @@ class Parser
|
|
1126 |
$this->append(null);
|
1127 |
}
|
1128 |
}
|
1129 |
-
|
1130 |
-
return $b;
|
1131 |
}
|
1132 |
|
1133 |
/**
|
1134 |
* Push special (named) block onto parse tree
|
1135 |
*
|
|
|
|
|
1136 |
* @param string $type
|
1137 |
-
* @param
|
1138 |
*
|
1139 |
* @return Block
|
1140 |
*/
|
@@ -1183,11 +1223,11 @@ class Parser
|
|
1183 |
/**
|
1184 |
* Peek input stream
|
1185 |
*
|
1186 |
-
* @param string
|
1187 |
-
* @param array
|
1188 |
-
* @param
|
1189 |
*
|
1190 |
-
* @return
|
1191 |
*/
|
1192 |
protected function peek($regex, &$out, $from = null)
|
1193 |
{
|
@@ -1204,7 +1244,7 @@ class Parser
|
|
1204 |
/**
|
1205 |
* Seek to position in input stream (or return current position in input stream)
|
1206 |
*
|
1207 |
-
* @param
|
1208 |
*/
|
1209 |
protected function seek($where)
|
1210 |
{
|
@@ -1215,7 +1255,8 @@ class Parser
|
|
1215 |
* Assert a parsed part is plain CSS Valid
|
1216 |
*
|
1217 |
* @param array|false $parsed
|
1218 |
-
* @param int
|
|
|
1219 |
* @throws ParserException
|
1220 |
*/
|
1221 |
protected function assertPlainCssValid($parsed, $startPos = null)
|
@@ -1243,7 +1284,10 @@ class Parser
|
|
1243 |
|
1244 |
/**
|
1245 |
* Check a parsed element is plain CSS Valid
|
|
|
1246 |
* @param array $parsed
|
|
|
|
|
1247 |
* @return bool|array
|
1248 |
*/
|
1249 |
protected function isPlainCssValidElement($parsed, $allowExpression = false)
|
@@ -1423,7 +1467,7 @@ class Parser
|
|
1423 |
* @param array $m Matches (passed by reference)
|
1424 |
* @param string $delim Delimiter
|
1425 |
*
|
1426 |
-
* @return
|
1427 |
*/
|
1428 |
protected function matchString(&$m, $delim)
|
1429 |
{
|
@@ -1459,11 +1503,11 @@ class Parser
|
|
1459 |
/**
|
1460 |
* Try to match something on head of buffer
|
1461 |
*
|
1462 |
-
* @param string
|
1463 |
-
* @param array
|
1464 |
-
* @param
|
1465 |
*
|
1466 |
-
* @return
|
1467 |
*/
|
1468 |
protected function match($regex, &$out, $eatWhitespace = null)
|
1469 |
{
|
@@ -1489,10 +1533,10 @@ class Parser
|
|
1489 |
/**
|
1490 |
* Match a single string
|
1491 |
*
|
1492 |
-
* @param string
|
1493 |
-
* @param
|
1494 |
*
|
1495 |
-
* @return
|
1496 |
*/
|
1497 |
protected function matchChar($char, $eatWhitespace = null)
|
1498 |
{
|
@@ -1516,11 +1560,11 @@ class Parser
|
|
1516 |
/**
|
1517 |
* Match literal string
|
1518 |
*
|
1519 |
-
* @param string
|
1520 |
-
* @param
|
1521 |
-
* @param
|
1522 |
*
|
1523 |
-
* @return
|
1524 |
*/
|
1525 |
protected function literal($what, $len, $eatWhitespace = null)
|
1526 |
{
|
@@ -1544,7 +1588,7 @@ class Parser
|
|
1544 |
/**
|
1545 |
* Match some whitespace
|
1546 |
*
|
1547 |
-
* @return
|
1548 |
*/
|
1549 |
protected function whitespace()
|
1550 |
{
|
@@ -1643,7 +1687,7 @@ class Parser
|
|
1643 |
* Append statement to current block
|
1644 |
*
|
1645 |
* @param array|null $statement
|
1646 |
-
* @param
|
1647 |
*/
|
1648 |
protected function append($statement, $pos = null)
|
1649 |
{
|
@@ -1688,7 +1732,7 @@ class Parser
|
|
1688 |
*
|
1689 |
* @param array $out
|
1690 |
*
|
1691 |
-
* @return
|
1692 |
*/
|
1693 |
protected function mediaQueryList(&$out)
|
1694 |
{
|
@@ -1700,7 +1744,7 @@ class Parser
|
|
1700 |
*
|
1701 |
* @param array $out
|
1702 |
*
|
1703 |
-
* @return
|
1704 |
*/
|
1705 |
protected function mediaQuery(&$out)
|
1706 |
{
|
@@ -1754,7 +1798,7 @@ class Parser
|
|
1754 |
*
|
1755 |
* @param array $out
|
1756 |
*
|
1757 |
-
* @return
|
1758 |
*/
|
1759 |
protected function supportsQuery(&$out)
|
1760 |
{
|
@@ -1887,7 +1931,7 @@ class Parser
|
|
1887 |
*
|
1888 |
* @param array $out
|
1889 |
*
|
1890 |
-
* @return
|
1891 |
*/
|
1892 |
protected function mediaExpression(&$out)
|
1893 |
{
|
@@ -1920,7 +1964,7 @@ class Parser
|
|
1920 |
*
|
1921 |
* @param array $out
|
1922 |
*
|
1923 |
-
* @return
|
1924 |
*/
|
1925 |
protected function argValues(&$out)
|
1926 |
{
|
@@ -1945,7 +1989,7 @@ class Parser
|
|
1945 |
*
|
1946 |
* @param array $out
|
1947 |
*
|
1948 |
-
* @return
|
1949 |
*/
|
1950 |
protected function argValue(&$out)
|
1951 |
{
|
@@ -2025,10 +2069,10 @@ class Parser
|
|
2025 |
/**
|
2026 |
* Parse directive value list that considers $vars as keyword
|
2027 |
*
|
2028 |
-
* @param array
|
2029 |
-
* @param
|
2030 |
*
|
2031 |
-
* @return
|
2032 |
*/
|
2033 |
protected function directiveValue(&$out, $endChar = false)
|
2034 |
{
|
@@ -2089,7 +2133,7 @@ class Parser
|
|
2089 |
*
|
2090 |
* @param array $out
|
2091 |
*
|
2092 |
-
* @return
|
2093 |
*/
|
2094 |
protected function valueList(&$out)
|
2095 |
{
|
@@ -2105,10 +2149,11 @@ class Parser
|
|
2105 |
* Parse a function call, where externals () are part of the call
|
2106 |
* and not of the value list
|
2107 |
*
|
2108 |
-
* @param $out
|
2109 |
-
* @param bool
|
2110 |
* @param null|string $charAfter
|
2111 |
-
* @param null|bool
|
|
|
2112 |
* @return bool
|
2113 |
*/
|
2114 |
protected function functionCallArgumentsList(&$out, $mandatoryEnclos = true, $charAfter = null, $eatWhiteSp = null)
|
@@ -2145,7 +2190,7 @@ class Parser
|
|
2145 |
*
|
2146 |
* @param array $out
|
2147 |
*
|
2148 |
-
* @return
|
2149 |
*/
|
2150 |
protected function spaceList(&$out)
|
2151 |
{
|
@@ -2155,12 +2200,12 @@ class Parser
|
|
2155 |
/**
|
2156 |
* Parse generic list
|
2157 |
*
|
2158 |
-
* @param array
|
2159 |
-
* @param string
|
2160 |
-
* @param string
|
2161 |
-
* @param
|
2162 |
*
|
2163 |
-
* @return
|
2164 |
*/
|
2165 |
protected function genericList(&$out, $parseItem, $delim = '', $flatten = true)
|
2166 |
{
|
@@ -2256,11 +2301,11 @@ class Parser
|
|
2256 |
/**
|
2257 |
* Parse expression
|
2258 |
*
|
2259 |
-
* @param array
|
2260 |
-
* @param
|
2261 |
-
* @param
|
2262 |
*
|
2263 |
-
* @return
|
2264 |
*/
|
2265 |
protected function expression(&$out, $listOnly = false, $lookForExp = true)
|
2266 |
{
|
@@ -2322,11 +2367,11 @@ class Parser
|
|
2322 |
* Parse expression specifically checking for lists in parenthesis or brackets
|
2323 |
*
|
2324 |
* @param array $out
|
2325 |
-
* @param
|
2326 |
* @param string $closingParen
|
2327 |
* @param array $allowedTypes
|
2328 |
*
|
2329 |
-
* @return
|
2330 |
*/
|
2331 |
protected function enclosedExpression(&$out, $s, $closingParen = ')', $allowedTypes = [Type::T_LIST, Type::T_MAP])
|
2332 |
{
|
@@ -2381,8 +2426,8 @@ class Parser
|
|
2381 |
/**
|
2382 |
* Parse left-hand side of subexpression
|
2383 |
*
|
2384 |
-
* @param array
|
2385 |
-
* @param
|
2386 |
*
|
2387 |
* @return array
|
2388 |
*/
|
@@ -2437,7 +2482,7 @@ class Parser
|
|
2437 |
*
|
2438 |
* @param array $out
|
2439 |
*
|
2440 |
-
* @return
|
2441 |
*/
|
2442 |
protected function value(&$out)
|
2443 |
{
|
@@ -2645,7 +2690,7 @@ class Parser
|
|
2645 |
*
|
2646 |
* @param array $out
|
2647 |
*
|
2648 |
-
* @return
|
2649 |
*/
|
2650 |
protected function parenValue(&$out)
|
2651 |
{
|
@@ -2684,7 +2729,7 @@ class Parser
|
|
2684 |
*
|
2685 |
* @param array $out
|
2686 |
*
|
2687 |
-
* @return
|
2688 |
*/
|
2689 |
protected function progid(&$out)
|
2690 |
{
|
@@ -2717,7 +2762,7 @@ class Parser
|
|
2717 |
* @param string $name
|
2718 |
* @param array $func
|
2719 |
*
|
2720 |
-
* @return
|
2721 |
*/
|
2722 |
protected function func($name, &$func)
|
2723 |
{
|
@@ -2771,7 +2816,7 @@ class Parser
|
|
2771 |
*
|
2772 |
* @param array $out
|
2773 |
*
|
2774 |
-
* @return
|
2775 |
*/
|
2776 |
protected function argumentList(&$out)
|
2777 |
{
|
@@ -2816,7 +2861,7 @@ class Parser
|
|
2816 |
*
|
2817 |
* @param array $out
|
2818 |
*
|
2819 |
-
* @return
|
2820 |
*/
|
2821 |
protected function argumentDef(&$out)
|
2822 |
{
|
@@ -2878,7 +2923,7 @@ class Parser
|
|
2878 |
*
|
2879 |
* @param array $out
|
2880 |
*
|
2881 |
-
* @return
|
2882 |
*/
|
2883 |
protected function map(&$out)
|
2884 |
{
|
@@ -2920,7 +2965,7 @@ class Parser
|
|
2920 |
*
|
2921 |
* @param array $out
|
2922 |
*
|
2923 |
-
* @return
|
2924 |
*/
|
2925 |
protected function color(&$out)
|
2926 |
{
|
@@ -2946,7 +2991,7 @@ class Parser
|
|
2946 |
*
|
2947 |
* @param array $unit
|
2948 |
*
|
2949 |
-
* @return
|
2950 |
*/
|
2951 |
protected function unit(&$unit)
|
2952 |
{
|
@@ -2971,8 +3016,9 @@ class Parser
|
|
2971 |
* Parse string
|
2972 |
*
|
2973 |
* @param array $out
|
|
|
2974 |
*
|
2975 |
-
* @return
|
2976 |
*/
|
2977 |
protected function string(&$out, $keepDelimWithInterpolation = false)
|
2978 |
{
|
@@ -3053,7 +3099,8 @@ class Parser
|
|
3053 |
|
3054 |
/**
|
3055 |
* @param string $out
|
3056 |
-
* @param bool
|
|
|
3057 |
* @return bool
|
3058 |
*/
|
3059 |
protected function matchEscapeCharacter(&$out, $inKeywords = false)
|
@@ -3103,10 +3150,10 @@ class Parser
|
|
3103 |
/**
|
3104 |
* Parse keyword or interpolation
|
3105 |
*
|
3106 |
-
* @param array
|
3107 |
-
* @param
|
3108 |
*
|
3109 |
-
* @return
|
3110 |
*/
|
3111 |
protected function mixedKeyword(&$out, $restricted = false)
|
3112 |
{
|
@@ -3147,14 +3194,14 @@ class Parser
|
|
3147 |
/**
|
3148 |
* Parse an unbounded string stopped by $end
|
3149 |
*
|
3150 |
-
* @param string
|
3151 |
-
* @param array
|
3152 |
-
* @param string
|
3153 |
-
* @param string
|
3154 |
-
* @param
|
3155 |
* @param string $disallow
|
3156 |
*
|
3157 |
-
* @return
|
3158 |
*/
|
3159 |
protected function openString($end, &$out, $nestOpen = null, $nestClose = null, $rtrim = true, $disallow = null)
|
3160 |
{
|
@@ -3230,9 +3277,9 @@ class Parser
|
|
3230 |
* Parser interpolation
|
3231 |
*
|
3232 |
* @param string|array $out
|
3233 |
-
* @param
|
3234 |
*
|
3235 |
-
* @return
|
3236 |
*/
|
3237 |
protected function interpolation(&$out, $lookWhite = true)
|
3238 |
{
|
@@ -3287,7 +3334,7 @@ class Parser
|
|
3287 |
*
|
3288 |
* @param array $out
|
3289 |
*
|
3290 |
-
* @return
|
3291 |
*/
|
3292 |
protected function propertyName(&$out)
|
3293 |
{
|
@@ -3342,7 +3389,7 @@ class Parser
|
|
3342 |
*
|
3343 |
* @param array $out
|
3344 |
*
|
3345 |
-
* @return
|
3346 |
*/
|
3347 |
protected function customProperty(&$out)
|
3348 |
{
|
@@ -3400,9 +3447,9 @@ class Parser
|
|
3400 |
* Parse comma separated selector list
|
3401 |
*
|
3402 |
* @param array $out
|
3403 |
-
* @param string|
|
3404 |
*
|
3405 |
-
* @return
|
3406 |
*/
|
3407 |
protected function selectors(&$out, $subSelector = false)
|
3408 |
{
|
@@ -3436,9 +3483,9 @@ class Parser
|
|
3436 |
* Parse whitespace separated selector list
|
3437 |
*
|
3438 |
* @param array $out
|
3439 |
-
* @param string|
|
3440 |
*
|
3441 |
-
* @return
|
3442 |
*/
|
3443 |
protected function selector(&$out, $subSelector = false)
|
3444 |
{
|
@@ -3494,7 +3541,8 @@ class Parser
|
|
3494 |
* - but this require a better formal selector representation instead of the array we have now
|
3495 |
*
|
3496 |
* @param string $out
|
3497 |
-
* @param bool
|
|
|
3498 |
* @return bool
|
3499 |
*/
|
3500 |
protected function matchEscapeCharacterInSelector(&$out, $keepEscapedNumber = false)
|
@@ -3539,9 +3587,9 @@ class Parser
|
|
3539 |
* }}
|
3540 |
*
|
3541 |
* @param array $out
|
3542 |
-
* @param string|
|
3543 |
*
|
3544 |
-
* @return
|
3545 |
*/
|
3546 |
protected function selectorSingle(&$out, $subSelector = false)
|
3547 |
{
|
@@ -3765,7 +3813,7 @@ class Parser
|
|
3765 |
*
|
3766 |
* @param array $out
|
3767 |
*
|
3768 |
-
* @return
|
3769 |
*/
|
3770 |
protected function variable(&$out)
|
3771 |
{
|
@@ -3792,11 +3840,11 @@ class Parser
|
|
3792 |
/**
|
3793 |
* Parse a keyword
|
3794 |
*
|
3795 |
-
* @param string
|
3796 |
-
* @param
|
3797 |
-
* @param
|
3798 |
*
|
3799 |
-
* @return
|
3800 |
*/
|
3801 |
protected function keyword(&$word, $eatWhitespace = null, $inSelector = false)
|
3802 |
{
|
@@ -3859,11 +3907,11 @@ class Parser
|
|
3859 |
/**
|
3860 |
* Parse a keyword that should not start with a number
|
3861 |
*
|
3862 |
-
* @param string
|
3863 |
-
* @param
|
3864 |
-
* @param
|
3865 |
*
|
3866 |
-
* @return
|
3867 |
*/
|
3868 |
protected function restrictedKeyword(&$word, $eatWhitespace = null, $inSelector = false)
|
3869 |
{
|
@@ -3883,7 +3931,7 @@ class Parser
|
|
3883 |
*
|
3884 |
* @param string|array $placeholder
|
3885 |
*
|
3886 |
-
* @return
|
3887 |
*/
|
3888 |
protected function placeholder(&$placeholder)
|
3889 |
{
|
@@ -3912,7 +3960,7 @@ class Parser
|
|
3912 |
*
|
3913 |
* @param array $out
|
3914 |
*
|
3915 |
-
* @return
|
3916 |
*/
|
3917 |
protected function url(&$out)
|
3918 |
{
|
@@ -3947,7 +3995,7 @@ class Parser
|
|
3947 |
* Consume an end of statement delimiter
|
3948 |
* @param bool $eatWhitespace
|
3949 |
*
|
3950 |
-
* @return
|
3951 |
*/
|
3952 |
protected function end($eatWhitespace = null)
|
3953 |
{
|
@@ -4065,7 +4113,7 @@ class Parser
|
|
4065 |
/**
|
4066 |
* Get source line number and column (given character position in the buffer)
|
4067 |
*
|
4068 |
-
* @param
|
4069 |
*
|
4070 |
* @return array
|
4071 |
*/
|
12 |
|
13 |
namespace ScssPhp\ScssPhp;
|
14 |
|
15 |
+
use ScssPhp\ScssPhp\Block\AtRootBlock;
|
16 |
+
use ScssPhp\ScssPhp\Block\CallableBlock;
|
17 |
+
use ScssPhp\ScssPhp\Block\ContentBlock;
|
18 |
+
use ScssPhp\ScssPhp\Block\DirectiveBlock;
|
19 |
+
use ScssPhp\ScssPhp\Block\EachBlock;
|
20 |
+
use ScssPhp\ScssPhp\Block\ElseBlock;
|
21 |
+
use ScssPhp\ScssPhp\Block\ElseifBlock;
|
22 |
+
use ScssPhp\ScssPhp\Block\ForBlock;
|
23 |
+
use ScssPhp\ScssPhp\Block\IfBlock;
|
24 |
+
use ScssPhp\ScssPhp\Block\MediaBlock;
|
25 |
+
use ScssPhp\ScssPhp\Block\NestedPropertyBlock;
|
26 |
+
use ScssPhp\ScssPhp\Block\WhileBlock;
|
27 |
use ScssPhp\ScssPhp\Exception\ParserException;
|
28 |
use ScssPhp\ScssPhp\Logger\LoggerInterface;
|
29 |
use ScssPhp\ScssPhp\Logger\QuietLogger;
|
137 |
* @api
|
138 |
*
|
139 |
* @param string|null $sourceName
|
140 |
+
* @param int $sourceIndex
|
141 |
* @param string|null $encoding
|
142 |
* @param Cache|null $cache
|
143 |
* @param bool $cssOnly
|
317 |
* @param string $buffer
|
318 |
* @param string|array $out
|
319 |
*
|
320 |
+
* @return bool
|
321 |
*/
|
322 |
public function parseValue($buffer, &$out)
|
323 |
{
|
346 |
* @param string|array $out
|
347 |
* @param bool $shouldValidate
|
348 |
*
|
349 |
+
* @return bool
|
350 |
*/
|
351 |
public function parseSelector($buffer, &$out, $shouldValidate = true)
|
352 |
{
|
383 |
* @param string $buffer
|
384 |
* @param string|array $out
|
385 |
*
|
386 |
+
* @return bool
|
387 |
*/
|
388 |
public function parseMediaQueryList($buffer, &$out)
|
389 |
{
|
440 |
* position into $s. Then if a chain fails, use $this->seek($s) to
|
441 |
* go back where we started.
|
442 |
*
|
443 |
+
* @return bool
|
444 |
*/
|
445 |
protected function parseChunk()
|
446 |
{
|
459 |
) {
|
460 |
! $this->cssOnly || $this->assertPlainCssValid(false, $s);
|
461 |
|
462 |
+
$atRoot = new AtRootBlock();
|
463 |
+
$this->registerPushedBlock($atRoot, $s);
|
464 |
$atRoot->selector = $selector;
|
465 |
$atRoot->with = $with;
|
466 |
|
474 |
$this->mediaQueryList($mediaQueryList) &&
|
475 |
$this->matchChar('{', false)
|
476 |
) {
|
477 |
+
$media = new MediaBlock();
|
478 |
+
$this->registerPushedBlock($media, $s);
|
479 |
$media->queryList = $mediaQueryList[2];
|
480 |
|
481 |
return true;
|
491 |
) {
|
492 |
! $this->cssOnly || $this->assertPlainCssValid(false, $s);
|
493 |
|
494 |
+
$mixin = new CallableBlock(Type::T_MIXIN);
|
495 |
+
$this->registerPushedBlock($mixin, $s);
|
496 |
$mixin->name = $mixinName;
|
497 |
$mixin->args = $args;
|
498 |
|
524 |
];
|
525 |
|
526 |
if (! empty($hasBlock)) {
|
527 |
+
$include = new ContentBlock();
|
528 |
+
$this->registerPushedBlock($include, $s);
|
529 |
$include->child = $child;
|
530 |
} else {
|
531 |
$this->append($child, $s);
|
615 |
) {
|
616 |
! $this->cssOnly || $this->assertPlainCssValid(false, $s);
|
617 |
|
618 |
+
$func = new CallableBlock(Type::T_FUNCTION);
|
619 |
+
$this->registerPushedBlock($func, $s);
|
620 |
$func->name = $fnName;
|
621 |
$func->args = $args;
|
622 |
|
648 |
) {
|
649 |
! $this->cssOnly || $this->assertPlainCssValid(false, $s);
|
650 |
|
651 |
+
$each = new EachBlock();
|
652 |
+
$this->registerPushedBlock($each, $s);
|
653 |
|
654 |
foreach ($varNames[2] as $varName) {
|
655 |
$each->vars[] = $varName[1];
|
678 |
$cond = reset($cond[2]);
|
679 |
}
|
680 |
|
681 |
+
$while = new WhileBlock();
|
682 |
+
$this->registerPushedBlock($while, $s);
|
683 |
$while->cond = $cond;
|
684 |
|
685 |
return true;
|
699 |
) {
|
700 |
! $this->cssOnly || $this->assertPlainCssValid(false, $s);
|
701 |
|
702 |
+
$for = new ForBlock();
|
703 |
+
$this->registerPushedBlock($for, $s);
|
704 |
$for->var = $varName[1];
|
705 |
$for->start = $start;
|
706 |
$for->end = $end;
|
717 |
) {
|
718 |
! $this->cssOnly || $this->assertPlainCssValid(false, $s);
|
719 |
|
720 |
+
$if = new IfBlock();
|
721 |
+
$this->registerPushedBlock($if, $s);
|
722 |
|
723 |
while (
|
724 |
$cond[0] === Type::T_LIST &&
|
797 |
|
798 |
if (isset($last) && $last[0] === Type::T_IF) {
|
799 |
list(, $if) = $last;
|
800 |
+
assert($if instanceof IfBlock);
|
801 |
|
802 |
if ($this->literal('@else', 5)) {
|
803 |
if ($this->matchChar('{', false)) {
|
804 |
+
$else = new ElseBlock();
|
805 |
} elseif (
|
806 |
$this->literal('if', 2) &&
|
807 |
$this->functionCallArgumentsList($cond, false, '{', false)
|
808 |
) {
|
809 |
+
$else = new ElseifBlock();
|
810 |
$else->cond = $cond;
|
811 |
}
|
812 |
|
813 |
if (isset($else)) {
|
814 |
+
$this->registerPushedBlock($else, $s);
|
815 |
$if->cases[] = $else;
|
816 |
|
817 |
return true;
|
849 |
($t1 = $this->supportsQuery($supportQuery)) &&
|
850 |
($t2 = $this->matchChar('{', false))
|
851 |
) {
|
852 |
+
$directive = new DirectiveBlock();
|
853 |
+
$this->registerPushedBlock($directive, $s);
|
854 |
$directive->name = 'supports';
|
855 |
$directive->value = $supportQuery;
|
856 |
|
871 |
$dirName = [Type::T_STRING, '', $dirName];
|
872 |
}
|
873 |
if ($dirName === 'media') {
|
874 |
+
$directive = new MediaBlock();
|
875 |
} else {
|
876 |
+
$directive = new DirectiveBlock();
|
877 |
$directive->name = $dirName;
|
878 |
}
|
879 |
+
$this->registerPushedBlock($directive, $s);
|
880 |
|
881 |
if (isset($dirValue)) {
|
882 |
! $this->cssOnly || ($dirValue = $this->assertPlainCssValid($dirValue));
|
1052 |
if ($this->matchChar('{', false)) {
|
1053 |
! $this->cssOnly || $this->assertPlainCssValid(false);
|
1054 |
|
1055 |
+
$propBlock = new NestedPropertyBlock();
|
1056 |
+
$this->registerPushedBlock($propBlock, $s);
|
1057 |
$propBlock->prefix = $name;
|
1058 |
$propBlock->hasValue = $foundSomething;
|
1059 |
|
1079 |
}
|
1080 |
}
|
1081 |
|
1082 |
+
if ($block instanceof ContentBlock) {
|
1083 |
$include = $block->child;
|
1084 |
+
assert(\is_array($include));
|
1085 |
unset($block->child);
|
1086 |
$include[3] = $block;
|
1087 |
$this->append($include, $s);
|
1088 |
+
} elseif (!$block instanceof ElseBlock && !$block instanceof ElseifBlock) {
|
1089 |
$type = isset($block->type) ? $block->type : Type::T_BLOCK;
|
1090 |
$this->append([$type, $block], $s);
|
1091 |
}
|
1114 |
* Push block onto parse tree
|
1115 |
*
|
1116 |
* @param array|null $selectors
|
1117 |
+
* @param int $pos
|
1118 |
*
|
1119 |
* @return Block
|
1120 |
*/
|
1121 |
protected function pushBlock($selectors, $pos = 0)
|
1122 |
+
{
|
1123 |
+
$b = new Block();
|
1124 |
+
$b->selectors = $selectors;
|
1125 |
+
|
1126 |
+
$this->registerPushedBlock($b, $pos);
|
1127 |
+
|
1128 |
+
return $b;
|
1129 |
+
}
|
1130 |
+
|
1131 |
+
/**
|
1132 |
+
* @param Block $b
|
1133 |
+
* @param int $pos
|
1134 |
+
*
|
1135 |
+
* @return void
|
1136 |
+
*/
|
1137 |
+
private function registerPushedBlock(Block $b, $pos)
|
1138 |
{
|
1139 |
list($line, $column) = $this->getSourcePosition($pos);
|
1140 |
|
|
|
1141 |
$b->sourceName = $this->sourceName;
|
1142 |
$b->sourceLine = $line;
|
1143 |
$b->sourceColumn = $column;
|
1144 |
$b->sourceIndex = $this->sourceIndex;
|
|
|
1145 |
$b->comments = [];
|
1146 |
$b->parent = $this->env;
|
1147 |
|
1166 |
$this->append(null);
|
1167 |
}
|
1168 |
}
|
|
|
|
|
1169 |
}
|
1170 |
|
1171 |
/**
|
1172 |
* Push special (named) block onto parse tree
|
1173 |
*
|
1174 |
+
* @deprecated
|
1175 |
+
*
|
1176 |
* @param string $type
|
1177 |
+
* @param int $pos
|
1178 |
*
|
1179 |
* @return Block
|
1180 |
*/
|
1223 |
/**
|
1224 |
* Peek input stream
|
1225 |
*
|
1226 |
+
* @param string $regex
|
1227 |
+
* @param array $out
|
1228 |
+
* @param int $from
|
1229 |
*
|
1230 |
+
* @return int
|
1231 |
*/
|
1232 |
protected function peek($regex, &$out, $from = null)
|
1233 |
{
|
1244 |
/**
|
1245 |
* Seek to position in input stream (or return current position in input stream)
|
1246 |
*
|
1247 |
+
* @param int $where
|
1248 |
*/
|
1249 |
protected function seek($where)
|
1250 |
{
|
1255 |
* Assert a parsed part is plain CSS Valid
|
1256 |
*
|
1257 |
* @param array|false $parsed
|
1258 |
+
* @param int $startPos
|
1259 |
+
*
|
1260 |
* @throws ParserException
|
1261 |
*/
|
1262 |
protected function assertPlainCssValid($parsed, $startPos = null)
|
1284 |
|
1285 |
/**
|
1286 |
* Check a parsed element is plain CSS Valid
|
1287 |
+
*
|
1288 |
* @param array $parsed
|
1289 |
+
* @param bool $allowExpression
|
1290 |
+
*
|
1291 |
* @return bool|array
|
1292 |
*/
|
1293 |
protected function isPlainCssValidElement($parsed, $allowExpression = false)
|
1467 |
* @param array $m Matches (passed by reference)
|
1468 |
* @param string $delim Delimiter
|
1469 |
*
|
1470 |
+
* @return bool True if match; false otherwise
|
1471 |
*/
|
1472 |
protected function matchString(&$m, $delim)
|
1473 |
{
|
1503 |
/**
|
1504 |
* Try to match something on head of buffer
|
1505 |
*
|
1506 |
+
* @param string $regex
|
1507 |
+
* @param array $out
|
1508 |
+
* @param bool $eatWhitespace
|
1509 |
*
|
1510 |
+
* @return bool
|
1511 |
*/
|
1512 |
protected function match($regex, &$out, $eatWhitespace = null)
|
1513 |
{
|
1533 |
/**
|
1534 |
* Match a single string
|
1535 |
*
|
1536 |
+
* @param string $char
|
1537 |
+
* @param bool $eatWhitespace
|
1538 |
*
|
1539 |
+
* @return bool
|
1540 |
*/
|
1541 |
protected function matchChar($char, $eatWhitespace = null)
|
1542 |
{
|
1560 |
/**
|
1561 |
* Match literal string
|
1562 |
*
|
1563 |
+
* @param string $what
|
1564 |
+
* @param int $len
|
1565 |
+
* @param bool $eatWhitespace
|
1566 |
*
|
1567 |
+
* @return bool
|
1568 |
*/
|
1569 |
protected function literal($what, $len, $eatWhitespace = null)
|
1570 |
{
|
1588 |
/**
|
1589 |
* Match some whitespace
|
1590 |
*
|
1591 |
+
* @return bool
|
1592 |
*/
|
1593 |
protected function whitespace()
|
1594 |
{
|
1687 |
* Append statement to current block
|
1688 |
*
|
1689 |
* @param array|null $statement
|
1690 |
+
* @param int $pos
|
1691 |
*/
|
1692 |
protected function append($statement, $pos = null)
|
1693 |
{
|
1732 |
*
|
1733 |
* @param array $out
|
1734 |
*
|
1735 |
+
* @return bool
|
1736 |
*/
|
1737 |
protected function mediaQueryList(&$out)
|
1738 |
{
|
1744 |
*
|
1745 |
* @param array $out
|
1746 |
*
|
1747 |
+
* @return bool
|
1748 |
*/
|
1749 |
protected function mediaQuery(&$out)
|
1750 |
{
|
1798 |
*
|
1799 |
* @param array $out
|
1800 |
*
|
1801 |
+
* @return bool
|
1802 |
*/
|
1803 |
protected function supportsQuery(&$out)
|
1804 |
{
|
1931 |
*
|
1932 |
* @param array $out
|
1933 |
*
|
1934 |
+
* @return bool
|
1935 |
*/
|
1936 |
protected function mediaExpression(&$out)
|
1937 |
{
|
1964 |
*
|
1965 |
* @param array $out
|
1966 |
*
|
1967 |
+
* @return bool
|
1968 |
*/
|
1969 |
protected function argValues(&$out)
|
1970 |
{
|
1989 |
*
|
1990 |
* @param array $out
|
1991 |
*
|
1992 |
+
* @return bool
|
1993 |
*/
|
1994 |
protected function argValue(&$out)
|
1995 |
{
|
2069 |
/**
|
2070 |
* Parse directive value list that considers $vars as keyword
|
2071 |
*
|
2072 |
+
* @param array $out
|
2073 |
+
* @param bool|string $endChar
|
2074 |
*
|
2075 |
+
* @return bool
|
2076 |
*/
|
2077 |
protected function directiveValue(&$out, $endChar = false)
|
2078 |
{
|
2133 |
*
|
2134 |
* @param array $out
|
2135 |
*
|
2136 |
+
* @return bool
|
2137 |
*/
|
2138 |
protected function valueList(&$out)
|
2139 |
{
|
2149 |
* Parse a function call, where externals () are part of the call
|
2150 |
* and not of the value list
|
2151 |
*
|
2152 |
+
* @param array $out
|
2153 |
+
* @param bool $mandatoryEnclos
|
2154 |
* @param null|string $charAfter
|
2155 |
+
* @param null|bool $eatWhiteSp
|
2156 |
+
*
|
2157 |
* @return bool
|
2158 |
*/
|
2159 |
protected function functionCallArgumentsList(&$out, $mandatoryEnclos = true, $charAfter = null, $eatWhiteSp = null)
|
2190 |
*
|
2191 |
* @param array $out
|
2192 |
*
|
2193 |
+
* @return bool
|
2194 |
*/
|
2195 |
protected function spaceList(&$out)
|
2196 |
{
|
2200 |
/**
|
2201 |
* Parse generic list
|
2202 |
*
|
2203 |
+
* @param array $out
|
2204 |
+
* @param string $parseItem The name of the method used to parse items
|
2205 |
+
* @param string $delim
|
2206 |
+
* @param bool $flatten
|
2207 |
*
|
2208 |
+
* @return bool
|
2209 |
*/
|
2210 |
protected function genericList(&$out, $parseItem, $delim = '', $flatten = true)
|
2211 |
{
|
2301 |
/**
|
2302 |
* Parse expression
|
2303 |
*
|
2304 |
+
* @param array $out
|
2305 |
+
* @param bool $listOnly
|
2306 |
+
* @param bool $lookForExp
|
2307 |
*
|
2308 |
+
* @return bool
|
2309 |
*/
|
2310 |
protected function expression(&$out, $listOnly = false, $lookForExp = true)
|
2311 |
{
|
2367 |
* Parse expression specifically checking for lists in parenthesis or brackets
|
2368 |
*
|
2369 |
* @param array $out
|
2370 |
+
* @param int $s
|
2371 |
* @param string $closingParen
|
2372 |
* @param array $allowedTypes
|
2373 |
*
|
2374 |
+
* @return bool
|
2375 |
*/
|
2376 |
protected function enclosedExpression(&$out, $s, $closingParen = ')', $allowedTypes = [Type::T_LIST, Type::T_MAP])
|
2377 |
{
|
2426 |
/**
|
2427 |
* Parse left-hand side of subexpression
|
2428 |
*
|
2429 |
+
* @param array $lhs
|
2430 |
+
* @param int $minP
|
2431 |
*
|
2432 |
* @return array
|
2433 |
*/
|
2482 |
*
|
2483 |
* @param array $out
|
2484 |
*
|
2485 |
+
* @return bool
|
2486 |
*/
|
2487 |
protected function value(&$out)
|
2488 |
{
|
2690 |
*
|
2691 |
* @param array $out
|
2692 |
*
|
2693 |
+
* @return bool
|
2694 |
*/
|
2695 |
protected function parenValue(&$out)
|
2696 |
{
|
2729 |
*
|
2730 |
* @param array $out
|
2731 |
*
|
2732 |
+
* @return bool
|
2733 |
*/
|
2734 |
protected function progid(&$out)
|
2735 |
{
|
2762 |
* @param string $name
|
2763 |
* @param array $func
|
2764 |
*
|
2765 |
+
* @return bool
|
2766 |
*/
|
2767 |
protected function func($name, &$func)
|
2768 |
{
|
2816 |
*
|
2817 |
* @param array $out
|
2818 |
*
|
2819 |
+
* @return bool
|
2820 |
*/
|
2821 |
protected function argumentList(&$out)
|
2822 |
{
|
2861 |
*
|
2862 |
* @param array $out
|
2863 |
*
|
2864 |
+
* @return bool
|
2865 |
*/
|
2866 |
protected function argumentDef(&$out)
|
2867 |
{
|
2923 |
*
|
2924 |
* @param array $out
|
2925 |
*
|
2926 |
+
* @return bool
|
2927 |
*/
|
2928 |
protected function map(&$out)
|
2929 |
{
|
2965 |
*
|
2966 |
* @param array $out
|
2967 |
*
|
2968 |
+
* @return bool
|
2969 |
*/
|
2970 |
protected function color(&$out)
|
2971 |
{
|
2991 |
*
|
2992 |
* @param array $unit
|
2993 |
*
|
2994 |
+
* @return bool
|
2995 |
*/
|
2996 |
protected function unit(&$unit)
|
2997 |
{
|
3016 |
* Parse string
|
3017 |
*
|
3018 |
* @param array $out
|
3019 |
+
* @param bool $keepDelimWithInterpolation
|
3020 |
*
|
3021 |
+
* @return bool
|
3022 |
*/
|
3023 |
protected function string(&$out, $keepDelimWithInterpolation = false)
|
3024 |
{
|
3099 |
|
3100 |
/**
|
3101 |
* @param string $out
|
3102 |
+
* @param bool $inKeywords
|
3103 |
+
*
|
3104 |
* @return bool
|
3105 |
*/
|
3106 |
protected function matchEscapeCharacter(&$out, $inKeywords = false)
|
3150 |
/**
|
3151 |
* Parse keyword or interpolation
|
3152 |
*
|
3153 |
+
* @param array $out
|
3154 |
+
* @param bool $restricted
|
3155 |
*
|
3156 |
+
* @return bool
|
3157 |
*/
|
3158 |
protected function mixedKeyword(&$out, $restricted = false)
|
3159 |
{
|
3194 |
/**
|
3195 |
* Parse an unbounded string stopped by $end
|
3196 |
*
|
3197 |
+
* @param string $end
|
3198 |
+
* @param array $out
|
3199 |
+
* @param string $nestOpen
|
3200 |
+
* @param string $nestClose
|
3201 |
+
* @param bool $rtrim
|
3202 |
* @param string $disallow
|
3203 |
*
|
3204 |
+
* @return bool
|
3205 |
*/
|
3206 |
protected function openString($end, &$out, $nestOpen = null, $nestClose = null, $rtrim = true, $disallow = null)
|
3207 |
{
|
3277 |
* Parser interpolation
|
3278 |
*
|
3279 |
* @param string|array $out
|
3280 |
+
* @param bool $lookWhite save information about whitespace before and after
|
3281 |
*
|
3282 |
+
* @return bool
|
3283 |
*/
|
3284 |
protected function interpolation(&$out, $lookWhite = true)
|
3285 |
{
|
3334 |
*
|
3335 |
* @param array $out
|
3336 |
*
|
3337 |
+
* @return bool
|
3338 |
*/
|
3339 |
protected function propertyName(&$out)
|
3340 |
{
|
3389 |
*
|
3390 |
* @param array $out
|
3391 |
*
|
3392 |
+
* @return bool
|
3393 |
*/
|
3394 |
protected function customProperty(&$out)
|
3395 |
{
|
3447 |
* Parse comma separated selector list
|
3448 |
*
|
3449 |
* @param array $out
|
3450 |
+
* @param string|bool $subSelector
|
3451 |
*
|
3452 |
+
* @return bool
|
3453 |
*/
|
3454 |
protected function selectors(&$out, $subSelector = false)
|
3455 |
{
|
3483 |
* Parse whitespace separated selector list
|
3484 |
*
|
3485 |
* @param array $out
|
3486 |
+
* @param string|bool $subSelector
|
3487 |
*
|
3488 |
+
* @return bool
|
3489 |
*/
|
3490 |
protected function selector(&$out, $subSelector = false)
|
3491 |
{
|
3541 |
* - but this require a better formal selector representation instead of the array we have now
|
3542 |
*
|
3543 |
* @param string $out
|
3544 |
+
* @param bool $keepEscapedNumber
|
3545 |
+
*
|
3546 |
* @return bool
|
3547 |
*/
|
3548 |
protected function matchEscapeCharacterInSelector(&$out, $keepEscapedNumber = false)
|
3587 |
* }}
|
3588 |
*
|
3589 |
* @param array $out
|
3590 |
+
* @param string|bool $subSelector
|
3591 |
*
|
3592 |
+
* @return bool
|
3593 |
*/
|
3594 |
protected function selectorSingle(&$out, $subSelector = false)
|
3595 |
{
|
3813 |
*
|
3814 |
* @param array $out
|
3815 |
*
|
3816 |
+
* @return bool
|
3817 |
*/
|
3818 |
protected function variable(&$out)
|
3819 |
{
|
3840 |
/**
|
3841 |
* Parse a keyword
|
3842 |
*
|
3843 |
+
* @param string $word
|
3844 |
+
* @param bool $eatWhitespace
|
3845 |
+
* @param bool $inSelector
|
3846 |
*
|
3847 |
+
* @return bool
|
3848 |
*/
|
3849 |
protected function keyword(&$word, $eatWhitespace = null, $inSelector = false)
|
3850 |
{
|
3907 |
/**
|
3908 |
* Parse a keyword that should not start with a number
|
3909 |
*
|
3910 |
+
* @param string $word
|
3911 |
+
* @param bool $eatWhitespace
|
3912 |
+
* @param bool $inSelector
|
3913 |
*
|
3914 |
+
* @return bool
|
3915 |
*/
|
3916 |
protected function restrictedKeyword(&$word, $eatWhitespace = null, $inSelector = false)
|
3917 |
{
|
3931 |
*
|
3932 |
* @param string|array $placeholder
|
3933 |
*
|
3934 |
+
* @return bool
|
3935 |
*/
|
3936 |
protected function placeholder(&$placeholder)
|
3937 |
{
|
3960 |
*
|
3961 |
* @param array $out
|
3962 |
*
|
3963 |
+
* @return bool
|
3964 |
*/
|
3965 |
protected function url(&$out)
|
3966 |
{
|
3995 |
* Consume an end of statement delimiter
|
3996 |
* @param bool $eatWhitespace
|
3997 |
*
|
3998 |
+
* @return bool
|
3999 |
*/
|
4000 |
protected function end($eatWhitespace = null)
|
4001 |
{
|
4113 |
/**
|
4114 |
* Get source line number and column (given character position in the buffer)
|
4115 |
*
|
4116 |
+
* @param int $pos
|
4117 |
*
|
4118 |
* @return array
|
4119 |
*/
|
vendor/scssphp/scssphp/src/SourceMap/Base64.php
CHANGED
@@ -164,7 +164,7 @@ class Base64
|
|
164 |
/**
|
165 |
* Convert to base64
|
166 |
*
|
167 |
-
* @param
|
168 |
*
|
169 |
* @return string
|
170 |
*/
|
@@ -178,7 +178,7 @@ class Base64
|
|
178 |
*
|
179 |
* @param string $value
|
180 |
*
|
181 |
-
* @return
|
182 |
*/
|
183 |
public static function decode($value)
|
184 |
{
|
164 |
/**
|
165 |
* Convert to base64
|
166 |
*
|
167 |
+
* @param int $value
|
168 |
*
|
169 |
* @return string
|
170 |
*/
|
178 |
*
|
179 |
* @param string $value
|
180 |
*
|
181 |
+
* @return int
|
182 |
*/
|
183 |
public static function decode($value)
|
184 |
{
|
vendor/scssphp/scssphp/src/SourceMap/Base64VLQ.php
CHANGED
@@ -51,7 +51,7 @@ class Base64VLQ
|
|
51 |
/**
|
52 |
* Returns the VLQ encoded value.
|
53 |
*
|
54 |
-
* @param
|
55 |
*
|
56 |
* @return string
|
57 |
*/
|
@@ -80,9 +80,9 @@ class Base64VLQ
|
|
80 |
* Decodes VLQValue.
|
81 |
*
|
82 |
* @param string $str
|
83 |
-
* @param
|
84 |
*
|
85 |
-
* @return
|
86 |
*/
|
87 |
public static function decode($str, &$index)
|
88 |
{
|
@@ -107,9 +107,9 @@ class Base64VLQ
|
|
107 |
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
|
108 |
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
109 |
*
|
110 |
-
* @param
|
111 |
*
|
112 |
-
* @return
|
113 |
*/
|
114 |
private static function toVLQSigned($value)
|
115 |
{
|
@@ -126,9 +126,9 @@ class Base64VLQ
|
|
126 |
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
|
127 |
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
|
128 |
*
|
129 |
-
* @param
|
130 |
*
|
131 |
-
* @return
|
132 |
*/
|
133 |
private static function fromVLQSigned($value)
|
134 |
{
|
51 |
/**
|
52 |
* Returns the VLQ encoded value.
|
53 |
*
|
54 |
+
* @param int $value
|
55 |
*
|
56 |
* @return string
|
57 |
*/
|
80 |
* Decodes VLQValue.
|
81 |
*
|
82 |
* @param string $str
|
83 |
+
* @param int $index
|
84 |
*
|
85 |
+
* @return int
|
86 |
*/
|
87 |
public static function decode($str, &$index)
|
88 |
{
|
107 |
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
|
108 |
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
109 |
*
|
110 |
+
* @param int $value
|
111 |
*
|
112 |
+
* @return int
|
113 |
*/
|
114 |
private static function toVLQSigned($value)
|
115 |
{
|
126 |
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
|
127 |
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
|
128 |
*
|
129 |
+
* @param int $value
|
130 |
*
|
131 |
+
* @return int
|
132 |
*/
|
133 |
private static function fromVLQSigned($value)
|
134 |
{
|
vendor/scssphp/scssphp/src/SourceMap/SourceMapGenerator.php
CHANGED
@@ -114,11 +114,11 @@ class SourceMapGenerator
|
|
114 |
/**
|
115 |
* Adds a mapping
|
116 |
*
|
117 |
-
* @param
|
118 |
-
* @param
|
119 |
-
* @param
|
120 |
-
* @param
|
121 |
-
* @param string
|
122 |
*
|
123 |
* @return void
|
124 |
*/
|
@@ -326,7 +326,7 @@ class SourceMapGenerator
|
|
326 |
*
|
327 |
* @param string $filename
|
328 |
*
|
329 |
-
* @return
|
330 |
*/
|
331 |
protected function findFileIndex($filename)
|
332 |
{
|
@@ -362,8 +362,8 @@ class SourceMapGenerator
|
|
362 |
/**
|
363 |
* Fix windows paths
|
364 |
*
|
365 |
-
* @param string
|
366 |
-
* @param
|
367 |
*
|
368 |
* @return string
|
369 |
*/
|
114 |
/**
|
115 |
* Adds a mapping
|
116 |
*
|
117 |
+
* @param int $generatedLine The line number in generated file
|
118 |
+
* @param int $generatedColumn The column number in generated file
|
119 |
+
* @param int $originalLine The line number in original file
|
120 |
+
* @param int $originalColumn The column number in original file
|
121 |
+
* @param string $sourceFile The original source file
|
122 |
*
|
123 |
* @return void
|
124 |
*/
|
326 |
*
|
327 |
* @param string $filename
|
328 |
*
|
329 |
+
* @return int|false
|
330 |
*/
|
331 |
protected function findFileIndex($filename)
|
332 |
{
|
362 |
/**
|
363 |
* Fix windows paths
|
364 |
*
|
365 |
+
* @param string $path
|
366 |
+
* @param bool $addEndSlash
|
367 |
*
|
368 |
* @return string
|
369 |
*/
|
vendor/scssphp/scssphp/src/Type.php
CHANGED
@@ -19,58 +19,190 @@ namespace ScssPhp\ScssPhp;
|
|
19 |
*/
|
20 |
class Type
|
21 |
{
|
|
|
|
|
|
|
22 |
const T_ASSIGN = 'assign';
|
|
|
|
|
|
|
23 |
const T_AT_ROOT = 'at-root';
|
|
|
|
|
|
|
24 |
const T_BLOCK = 'block';
|
25 |
-
/**
|
|
|
|
|
|
|
26 |
const T_BREAK = 'break';
|
|
|
|
|
|
|
27 |
const T_CHARSET = 'charset';
|
28 |
const T_COLOR = 'color';
|
|
|
|
|
|
|
29 |
const T_COMMENT = 'comment';
|
30 |
-
/**
|
|
|
|
|
|
|
31 |
const T_CONTINUE = 'continue';
|
32 |
-
/**
|
|
|
|
|
|
|
33 |
const T_CONTROL = 'control';
|
|
|
|
|
|
|
34 |
const T_CUSTOM_PROPERTY = 'custom';
|
|
|
|
|
|
|
35 |
const T_DEBUG = 'debug';
|
|
|
|
|
|
|
36 |
const T_DIRECTIVE = 'directive';
|
|
|
|
|
|
|
37 |
const T_EACH = 'each';
|
|
|
|
|
|
|
38 |
const T_ELSE = 'else';
|
|
|
|
|
|
|
39 |
const T_ELSEIF = 'elseif';
|
|
|
|
|
|
|
40 |
const T_ERROR = 'error';
|
|
|
|
|
|
|
41 |
const T_EXPRESSION = 'exp';
|
|
|
|
|
|
|
42 |
const T_EXTEND = 'extend';
|
|
|
|
|
|
|
43 |
const T_FOR = 'for';
|
44 |
const T_FUNCTION = 'function';
|
|
|
|
|
|
|
45 |
const T_FUNCTION_REFERENCE = 'function-reference';
|
|
|
|
|
|
|
46 |
const T_FUNCTION_CALL = 'fncall';
|
|
|
|
|
|
|
47 |
const T_HSL = 'hsl';
|
|
|
|
|
|
|
48 |
const T_HWB = 'hwb';
|
|
|
|
|
|
|
49 |
const T_IF = 'if';
|
|
|
|
|
|
|
50 |
const T_IMPORT = 'import';
|
|
|
|
|
|
|
51 |
const T_INCLUDE = 'include';
|
|
|
|
|
|
|
52 |
const T_INTERPOLATE = 'interpolate';
|
|
|
|
|
|
|
53 |
const T_INTERPOLATED = 'interpolated';
|
|
|
|
|
|
|
54 |
const T_KEYWORD = 'keyword';
|
55 |
const T_LIST = 'list';
|
56 |
const T_MAP = 'map';
|
|
|
|
|
|
|
57 |
const T_MEDIA = 'media';
|
|
|
|
|
|
|
58 |
const T_MEDIA_EXPRESSION = 'mediaExp';
|
|
|
|
|
|
|
59 |
const T_MEDIA_TYPE = 'mediaType';
|
|
|
|
|
|
|
60 |
const T_MEDIA_VALUE = 'mediaValue';
|
|
|
|
|
|
|
61 |
const T_MIXIN = 'mixin';
|
|
|
|
|
|
|
62 |
const T_MIXIN_CONTENT = 'mixin_content';
|
|
|
|
|
|
|
63 |
const T_NESTED_PROPERTY = 'nestedprop';
|
|
|
|
|
|
|
64 |
const T_NOT = 'not';
|
65 |
const T_NULL = 'null';
|
66 |
const T_NUMBER = 'number';
|
|
|
|
|
|
|
67 |
const T_RETURN = 'return';
|
|
|
|
|
|
|
68 |
const T_ROOT = 'root';
|
|
|
|
|
|
|
69 |
const T_SCSSPHP_IMPORT_ONCE = 'scssphp-import-once';
|
|
|
|
|
|
|
70 |
const T_SELF = 'self';
|
71 |
const T_STRING = 'string';
|
|
|
|
|
|
|
72 |
const T_UNARY = 'unary';
|
|
|
|
|
|
|
73 |
const T_VARIABLE = 'var';
|
|
|
|
|
|
|
74 |
const T_WARN = 'warn';
|
|
|
|
|
|
|
75 |
const T_WHILE = 'while';
|
76 |
}
|
19 |
*/
|
20 |
class Type
|
21 |
{
|
22 |
+
/**
|
23 |
+
* @internal
|
24 |
+
*/
|
25 |
const T_ASSIGN = 'assign';
|
26 |
+
/**
|
27 |
+
* @internal
|
28 |
+
*/
|
29 |
const T_AT_ROOT = 'at-root';
|
30 |
+
/**
|
31 |
+
* @internal
|
32 |
+
*/
|
33 |
const T_BLOCK = 'block';
|
34 |
+
/**
|
35 |
+
* @deprecated
|
36 |
+
* @internal
|
37 |
+
*/
|
38 |
const T_BREAK = 'break';
|
39 |
+
/**
|
40 |
+
* @internal
|
41 |
+
*/
|
42 |
const T_CHARSET = 'charset';
|
43 |
const T_COLOR = 'color';
|
44 |
+
/**
|
45 |
+
* @internal
|
46 |
+
*/
|
47 |
const T_COMMENT = 'comment';
|
48 |
+
/**
|
49 |
+
* @deprecated
|
50 |
+
* @internal
|
51 |
+
*/
|
52 |
const T_CONTINUE = 'continue';
|
53 |
+
/**
|
54 |
+
* @deprecated
|
55 |
+
* @internal
|
56 |
+
*/
|
57 |
const T_CONTROL = 'control';
|
58 |
+
/**
|
59 |
+
* @internal
|
60 |
+
*/
|
61 |
const T_CUSTOM_PROPERTY = 'custom';
|
62 |
+
/**
|
63 |
+
* @internal
|
64 |
+
*/
|
65 |
const T_DEBUG = 'debug';
|
66 |
+
/**
|
67 |
+
* @internal
|
68 |
+
*/
|
69 |
const T_DIRECTIVE = 'directive';
|
70 |
+
/**
|
71 |
+
* @internal
|
72 |
+
*/
|
73 |
const T_EACH = 'each';
|
74 |
+
/**
|
75 |
+
* @internal
|
76 |
+
*/
|
77 |
const T_ELSE = 'else';
|
78 |
+
/**
|
79 |
+
* @internal
|
80 |
+
*/
|
81 |
const T_ELSEIF = 'elseif';
|
82 |
+
/**
|
83 |
+
* @internal
|
84 |
+
*/
|
85 |
const T_ERROR = 'error';
|
86 |
+
/**
|
87 |
+
* @internal
|
88 |
+
*/
|
89 |
const T_EXPRESSION = 'exp';
|
90 |
+
/**
|
91 |
+
* @internal
|
92 |
+
*/
|
93 |
const T_EXTEND = 'extend';
|
94 |
+
/**
|
95 |
+
* @internal
|
96 |
+
*/
|
97 |
const T_FOR = 'for';
|
98 |
const T_FUNCTION = 'function';
|
99 |
+
/**
|
100 |
+
* @internal
|
101 |
+
*/
|
102 |
const T_FUNCTION_REFERENCE = 'function-reference';
|
103 |
+
/**
|
104 |
+
* @internal
|
105 |
+
*/
|
106 |
const T_FUNCTION_CALL = 'fncall';
|
107 |
+
/**
|
108 |
+
* @internal
|
109 |
+
*/
|
110 |
const T_HSL = 'hsl';
|
111 |
+
/**
|
112 |
+
* @internal
|
113 |
+
*/
|
114 |
const T_HWB = 'hwb';
|
115 |
+
/**
|
116 |
+
* @internal
|
117 |
+
*/
|
118 |
const T_IF = 'if';
|
119 |
+
/**
|
120 |
+
* @internal
|
121 |
+
*/
|
122 |
const T_IMPORT = 'import';
|
123 |
+
/**
|
124 |
+
* @internal
|
125 |
+
*/
|
126 |
const T_INCLUDE = 'include';
|
127 |
+
/**
|
128 |
+
* @internal
|
129 |
+
*/
|
130 |
const T_INTERPOLATE = 'interpolate';
|
131 |
+
/**
|
132 |
+
* @internal
|
133 |
+
*/
|
134 |
const T_INTERPOLATED = 'interpolated';
|
135 |
+
/**
|
136 |
+
* @internal
|
137 |
+
*/
|
138 |
const T_KEYWORD = 'keyword';
|
139 |
const T_LIST = 'list';
|
140 |
const T_MAP = 'map';
|
141 |
+
/**
|
142 |
+
* @internal
|
143 |
+
*/
|
144 |
const T_MEDIA = 'media';
|
145 |
+
/**
|
146 |
+
* @internal
|
147 |
+
*/
|
148 |
const T_MEDIA_EXPRESSION = 'mediaExp';
|
149 |
+
/**
|
150 |
+
* @internal
|
151 |
+
*/
|
152 |
const T_MEDIA_TYPE = 'mediaType';
|
153 |
+
/**
|
154 |
+
* @internal
|
155 |
+
*/
|
156 |
const T_MEDIA_VALUE = 'mediaValue';
|
157 |
+
/**
|
158 |
+
* @internal
|
159 |
+
*/
|
160 |
const T_MIXIN = 'mixin';
|
161 |
+
/**
|
162 |
+
* @internal
|
163 |
+
*/
|
164 |
const T_MIXIN_CONTENT = 'mixin_content';
|
165 |
+
/**
|
166 |
+
* @internal
|
167 |
+
*/
|
168 |
const T_NESTED_PROPERTY = 'nestedprop';
|
169 |
+
/**
|
170 |
+
* @internal
|
171 |
+
*/
|
172 |
const T_NOT = 'not';
|
173 |
const T_NULL = 'null';
|
174 |
const T_NUMBER = 'number';
|
175 |
+
/**
|
176 |
+
* @internal
|
177 |
+
*/
|
178 |
const T_RETURN = 'return';
|
179 |
+
/**
|
180 |
+
* @internal
|
181 |
+
*/
|
182 |
const T_ROOT = 'root';
|
183 |
+
/**
|
184 |
+
* @internal
|
185 |
+
*/
|
186 |
const T_SCSSPHP_IMPORT_ONCE = 'scssphp-import-once';
|
187 |
+
/**
|
188 |
+
* @internal
|
189 |
+
*/
|
190 |
const T_SELF = 'self';
|
191 |
const T_STRING = 'string';
|
192 |
+
/**
|
193 |
+
* @internal
|
194 |
+
*/
|
195 |
const T_UNARY = 'unary';
|
196 |
+
/**
|
197 |
+
* @internal
|
198 |
+
*/
|
199 |
const T_VARIABLE = 'var';
|
200 |
+
/**
|
201 |
+
* @internal
|
202 |
+
*/
|
203 |
const T_WARN = 'warn';
|
204 |
+
/**
|
205 |
+
* @internal
|
206 |
+
*/
|
207 |
const T_WHILE = 'while';
|
208 |
}
|
vendor/scssphp/scssphp/src/Util.php
CHANGED
@@ -79,7 +79,7 @@ class Util
|
|
79 |
/**
|
80 |
* mb_chr() wrapper
|
81 |
*
|
82 |
-
* @param
|
83 |
*
|
84 |
* @return string
|
85 |
*/
|
79 |
/**
|
80 |
* mb_chr() wrapper
|
81 |
*
|
82 |
+
* @param int $code
|
83 |
*
|
84 |
* @return string
|
85 |
*/
|
vendor/scssphp/scssphp/src/Version.php
CHANGED
@@ -19,5 +19,5 @@ namespace ScssPhp\ScssPhp;
|
|
19 |
*/
|
20 |
class Version
|
21 |
{
|
22 |
-
const VERSION = '1.
|
23 |
}
|
19 |
*/
|
20 |
class Version
|
21 |
{
|
22 |
+
const VERSION = '1.10.0';
|
23 |
}
|
vendor/thunderer/shortcode/.github/workflows/test.yaml
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Test
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches: ['master']
|
6 |
+
pull_request: ~
|
7 |
+
|
8 |
+
jobs:
|
9 |
+
test:
|
10 |
+
runs-on: '${{ matrix.os }}'
|
11 |
+
strategy:
|
12 |
+
matrix:
|
13 |
+
php: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
|
14 |
+
os: ['ubuntu-latest']
|
15 |
+
failure: [false]
|
16 |
+
include:
|
17 |
+
- { php: '8.2', os: 'ubuntu-latest', failure: true } # '8.2' means 'nightly'
|
18 |
+
steps:
|
19 |
+
- name: 'Checkout'
|
20 |
+
uses: 'actions/checkout@v2'
|
21 |
+
- name: 'Install PHP'
|
22 |
+
uses: 'shivammathur/setup-php@v2'
|
23 |
+
with:
|
24 |
+
php-version: '${{ matrix.php }}'
|
25 |
+
tools: 'composer:v2'
|
26 |
+
coverage: 'xdebug'
|
27 |
+
- name: 'PHP'
|
28 |
+
run: 'php -v'
|
29 |
+
|
30 |
+
- name: 'Composer'
|
31 |
+
run: 'composer install'
|
32 |
+
continue-on-error: '${{ matrix.failure }}'
|
33 |
+
- name: 'PHPUnit'
|
34 |
+
run: 'php vendor/bin/phpunit --coverage-text'
|
35 |
+
continue-on-error: '${{ matrix.failure }}'
|
36 |
+
- name: 'Psalm'
|
37 |
+
run: |
|
38 |
+
composer require --dev vimeo/psalm
|
39 |
+
php vendor/bin/psalm --shepherd --php-version=${{ matrix.php }}
|
40 |
+
if: '${{ matrix.php >= 7.1 }}'
|
41 |
+
continue-on-error: '${{ matrix.failure }}'
|
42 |
+
- name: 'Infection'
|
43 |
+
run: |
|
44 |
+
composer require --dev --with-all-dependencies infection/infection
|
45 |
+
php vendor/bin/infection
|
46 |
+
if: '${{ matrix.php >= 7.1 }}'
|
47 |
+
continue-on-error: '${{ matrix.failure }}'
|
vendor/thunderer/shortcode/.gitignore
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
vendor
|
2 |
composer.lock
|
3 |
coverage
|
1 |
+
.phpunit.result.cache
|
2 |
+
infection.log
|
3 |
vendor
|
4 |
composer.lock
|
5 |
coverage
|
vendor/thunderer/shortcode/.symfony.insight.yaml
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
rules:
|
2 |
-
# RegularParser::parse() disables xdebug.max_nesting_level to avoid errors when XDebug is enabled
|
3 |
-
php.dynamically_change_configuration:
|
4 |
-
enabled: false
|
|
|
|
|
|
|
|
vendor/thunderer/shortcode/.travis.yml
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
dist: trusty
|
2 |
-
language: php
|
3 |
-
|
4 |
-
php:
|
5 |
-
- 5.3
|
6 |
-
- 5.4
|
7 |
-
- 5.5
|
8 |
-
- 5.6
|
9 |
-
- 7.0
|
10 |
-
- 7.1
|
11 |
-
- 7.2
|
12 |
-
- 7.3
|
13 |
-
- 7.4snapshot
|
14 |
-
- hhvm
|
15 |
-
- nightly
|
16 |
-
|
17 |
-
sudo: false
|
18 |
-
|
19 |
-
before_script:
|
20 |
-
- COMPOSER_ROOT_VERSION=dev-master composer install
|
21 |
-
|
22 |
-
script:
|
23 |
-
- vendor/bin/phpunit --coverage-text
|
24 |
-
|
25 |
-
after_script:
|
26 |
-
- wget https://scrutinizer-ci.com/ocular.phar
|
27 |
-
- php ocular.phar code-coverage:upload --format=php-clover coverage.xml
|
28 |
-
|
29 |
-
matrix:
|
30 |
-
allow_failures:
|
31 |
-
- php: 5.3
|
32 |
-
- php: hhvm
|
33 |
-
- php: nightly
|
34 |
-
- php: hhvm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/thunderer/shortcode/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
Copyright (c) 2015-
|
2 |
|
3 |
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
of this software and associated documentation files (the "Software"), to deal
|
1 |
+
Copyright (c) 2015-2022 Tomasz Kowalczyk
|
2 |
|
3 |
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
of this software and associated documentation files (the "Software"), to deal
|
vendor/thunderer/shortcode/Makefile
CHANGED
@@ -1,13 +1,60 @@
|
|
1 |
-
|
|
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
composer-update:
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
test-
|
|
|
|
|
|
|
12 |
php -v
|
13 |
-
php vendor/bin/phpunit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
PHP_VERSION ?= 8.0
|
2 |
+
PHP := docker-compose run --rm php-${PHP_VERSION}
|
3 |
|
4 |
+
php-version:
|
5 |
+
${PHP} php -v
|
6 |
+
cache-clear:
|
7 |
+
sudo rm -rfv coverage .phpunit.result.cache infection.log
|
8 |
+
|
9 |
+
docker-build:
|
10 |
+
docker-compose build
|
11 |
+
|
12 |
+
composer-install:
|
13 |
+
${PHP} composer install
|
14 |
+
composer-self-update:
|
15 |
+
${PHP} composer self-update
|
16 |
composer-update:
|
17 |
+
${PHP} composer update
|
18 |
+
composer-require:
|
19 |
+
${PHP} composer require ${PACKAGE}
|
20 |
+
composer-require-dev:
|
21 |
+
${PHP} composer require --dev ${PACKAGE}
|
22 |
+
|
23 |
+
test: test-phpunit test-infection qa-psalm
|
24 |
+
test-phpunit:
|
25 |
+
${PHP} php -v
|
26 |
+
${PHP} php vendor/bin/phpunit --coverage-text
|
27 |
+
test-phpunit-local:
|
28 |
php -v
|
29 |
+
php vendor/bin/phpunit --coverage-text
|
30 |
+
php vendor/bin/psalm --no-cache
|
31 |
+
php vendor/bin/infection
|
32 |
+
test-infection:
|
33 |
+
${PHP} php vendor/bin/infection -j2 --min-msi=80
|
34 |
+
|
35 |
+
travis:
|
36 |
+
# PHP_VERSION=5.3 make travis-job
|
37 |
+
PHP_VERSION=5.4 make travis-job
|
38 |
+
PHP_VERSION=5.5 make travis-job
|
39 |
+
PHP_VERSION=5.6 make travis-job
|
40 |
+
PHP_VERSION=7.0 make travis-job
|
41 |
+
PHP_VERSION=7.1 make travis-job
|
42 |
+
PHP_VERSION=7.2 make travis-job
|
43 |
+
PHP_VERSION=7.3 make travis-job
|
44 |
+
PHP_VERSION=7.4 make travis-job
|
45 |
+
PHP_VERSION=8.0 make travis-job
|
46 |
+
travis-job:
|
47 |
+
${PHP} composer update --no-plugins
|
48 |
+
${PHP} php -v
|
49 |
+
${PHP} php vendor/bin/phpunit
|
50 |
+
if ${PHP} php -r 'exit((int)(version_compare(PHP_VERSION, "7.1", ">=") === false));'; then \
|
51 |
+
${PHP} composer require --dev vimeo/psalm infection/infection; \
|
52 |
+
${PHP} vendor/bin/psalm --threads=1 --no-cache --shepherd --find-unused-psalm-suppress; \
|
53 |
+
${PHP} vendor/bin/infection; \
|
54 |
+
${PHP} composer remove --dev vimeo/psalm infection/infection; \
|
55 |
+
fi;
|
56 |
+
|
57 |
+
qa-psalm:
|
58 |
+
${PHP} php vendor/bin/psalm --no-cache
|
59 |
+
qa-psalm-suppressed:
|
60 |
+
grep -rn psalm-suppress src
|
vendor/thunderer/shortcode/README.md
CHANGED
@@ -1,14 +1,12 @@
|
|
1 |
# Shortcode
|
2 |
|
3 |
-
[![Build Status](https://
|
4 |
-
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/5235d5e3-d112-48df-bc07-d4555aef293d/mini.png)](https://insight.sensiolabs.com/projects/5235d5e3-d112-48df-bc07-d4555aef293d)
|
5 |
-
[![License](https://poser.pugx.org/thunderer/shortcode/license.svg)](https://packagist.org/packages/thunderer/shortcode)
|
6 |
[![Latest Stable Version](https://poser.pugx.org/thunderer/shortcode/v/stable.svg)](https://packagist.org/packages/thunderer/shortcode)
|
7 |
[![Total Downloads](https://poser.pugx.org/thunderer/shortcode/downloads)](https://packagist.org/packages/thunderer/shortcode)
|
8 |
-
[![
|
9 |
-
[![
|
10 |
[![Code Coverage](https://scrutinizer-ci.com/g/thunderer/Shortcode/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/thunderer/Shortcode/?branch=master)
|
11 |
-
[![Code
|
12 |
|
13 |
Shortcode is a framework agnostic PHP library allowing to find, extract and process text fragments called "shortcodes" or "BBCodes". Examples of their usual syntax and usage are shown below:
|
14 |
|
@@ -33,10 +31,10 @@ Each part is described in the dedicated section in this document.
|
|
33 |
|
34 |
## Installation
|
35 |
|
36 |
-
There are no required dependencies and all PHP versions from 5.3 up to latest
|
37 |
|
38 |
```
|
39 |
-
composer require thunderer/shortcode=^0.7
|
40 |
```
|
41 |
|
42 |
or manually update your `composer.json` with:
|
@@ -44,7 +42,7 @@ or manually update your `composer.json` with:
|
|
44 |
```
|
45 |
(...)
|
46 |
"require": {
|
47 |
-
"thunderer/shortcode": "^0.7
|
48 |
}
|
49 |
(...)
|
50 |
```
|
1 |
# Shortcode
|
2 |
|
3 |
+
[![Build Status](https://github.com/thunderer/Shortcode/actions/workflows/test.yaml/badge.svg)](https://github.com/thunderer/Shortcode)
|
|
|
|
|
4 |
[![Latest Stable Version](https://poser.pugx.org/thunderer/shortcode/v/stable.svg)](https://packagist.org/packages/thunderer/shortcode)
|
5 |
[![Total Downloads](https://poser.pugx.org/thunderer/shortcode/downloads)](https://packagist.org/packages/thunderer/shortcode)
|
6 |
+
[![License](https://poser.pugx.org/thunderer/shortcode/license.svg)](https://packagist.org/packages/thunderer/shortcode)
|
7 |
+
[![Psalm coverage](https://shepherd.dev/github/thunderer/Shortcode/coverage.svg)](https://shepherd.dev/github/thunderer/Shortcode)
|
8 |
[![Code Coverage](https://scrutinizer-ci.com/g/thunderer/Shortcode/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/thunderer/Shortcode/?branch=master)
|
9 |
+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/thunderer/Shortcode/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/thunderer/Shortcode/?branch=master)
|
10 |
|
11 |
Shortcode is a framework agnostic PHP library allowing to find, extract and process text fragments called "shortcodes" or "BBCodes". Examples of their usual syntax and usage are shown below:
|
12 |
|
31 |
|
32 |
## Installation
|
33 |
|
34 |
+
There are no required dependencies and all PHP versions from 5.3 up to latest 8.1 [are tested](https://github.com/thunderer/Shortcode/actions/workflows/test.yaml) and supported. This library is available on Composer/Packagist as `thunderer/shortcode`, to install it execute:
|
35 |
|
36 |
```
|
37 |
+
composer require thunderer/shortcode=^0.7
|
38 |
```
|
39 |
|
40 |
or manually update your `composer.json` with:
|
42 |
```
|
43 |
(...)
|
44 |
"require": {
|
45 |
+
"thunderer/shortcode": "^0.7"
|
46 |
}
|
47 |
(...)
|
48 |
```
|
vendor/thunderer/shortcode/docker-compose.yaml
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
version: '3'
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
image: 'composer:1.6'
|
7 |
-
volumes: ['.:/app']
|
8 |
|
|
|
9 |
# PHP 5.3 contains neither mbstring extension nor docker-php-ext-install script
|
10 |
# Original Dockerfile can be found here https://github.com/docker-library/php/pull/20/files
|
11 |
# Unfortunately it fails to build now because GPG signatures do not exist anymore
|
12 |
-
# php-5.3: { build:
|
13 |
-
php-5.4: { build:
|
14 |
-
php-5.5: {
|
15 |
-
php-5.6: {
|
16 |
-
php-7.0: {
|
17 |
-
php-7.1: {
|
18 |
-
php-7.2: {
|
19 |
-
php-7.3: {
|
20 |
-
php-7.4: {
|
|
1 |
+
version: '3.4'
|
2 |
|
3 |
+
x-php: &php
|
4 |
+
volumes: ['.:/app', './docker/php/php.ini:/usr/local/etc/php/conf.d/php.ini']
|
5 |
+
working_dir: '/app'
|
|
|
|
|
6 |
|
7 |
+
services:
|
8 |
# PHP 5.3 contains neither mbstring extension nor docker-php-ext-install script
|
9 |
# Original Dockerfile can be found here https://github.com/docker-library/php/pull/20/files
|
10 |
# Unfortunately it fails to build now because GPG signatures do not exist anymore
|
11 |
+
# php-5.3: { build: { context: docker/php-5.x, args: { PHP_VERSION: 5.3 } } }
|
12 |
+
php-5.4: { <<: *php, build: { context: docker/php-5.x, args: { PHP_VERSION: 5.4 } } }
|
13 |
+
php-5.5: { <<: *php, build: { context: docker/php-5.x, args: { PHP_VERSION: 5.5 } } }
|
14 |
+
php-5.6: { <<: *php, build: { context: docker/php-5.x, args: { PHP_VERSION: 5.6 } } }
|
15 |
+
php-7.0: { <<: *php, build: { context: docker/php, args: { PHP_VERSION: 7.0 } } }
|
16 |
+
php-7.1: { <<: *php, build: { context: docker/php, args: { PHP_VERSION: 7.1.3 } } }
|
17 |
+
php-7.2: { <<: *php, build: { context: docker/php, args: { PHP_VERSION: 7.2 } } }
|
18 |
+
php-7.3: { <<: *php, build: { context: docker/php, args: { PHP_VERSION: 7.3 } } }
|
19 |
+
php-7.4: { <<: *php, build: { context: docker/php, args: { PHP_VERSION: 7.4 } } }
|
20 |
+
php-8.0: { <<: *php, build: { context: docker/php, args: { PHP_VERSION: 8.0 } } }
|
vendor/thunderer/shortcode/docker/php-5.4/Dockerfile
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
FROM php:5.4
|
2 |
-
|
3 |
-
RUN docker-php-ext-install mbstring
|
|
|
|
|
|
vendor/thunderer/shortcode/docker/php-5.x/Dockerfile
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ARG PHP_VERSION=7.4
|
2 |
+
FROM php:$PHP_VERSION
|
3 |
+
|
4 |
+
RUN apt update && apt install -y --force-yes libonig-dev libzip-dev
|
5 |
+
RUN docker-php-ext-install mbstring zip
|
6 |
+
|
7 |
+
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
|
8 |
+
&& php -r "if (hash_file('sha384', 'composer-setup.php') === 'c31c1e292ad7be5f49291169c0ac8f683499edddcfd4e42232982d0fd193004208a58ff6f353fde0012d35fdd72bc394') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
|
9 |
+
&& php composer-setup.php \
|
10 |
+
&& php -r "unlink('composer-setup.php');" \
|
11 |
+
&& mv composer.phar /usr/local/bin/composer
|
vendor/thunderer/shortcode/docker/php/Dockerfile
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ARG PHP_VERSION=8.0
|
2 |
+
FROM php:$PHP_VERSION
|
3 |
+
|
4 |
+
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
|
5 |
+
&& php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
|
6 |
+
&& php composer-setup.php \
|
7 |
+
&& php -r "unlink('composer-setup.php');" \
|
8 |
+
&& mv composer.phar /usr/local/bin/composer
|
9 |
+
|
10 |
+
RUN apt update && apt install -y libonig-dev libzip-dev
|
11 |
+
RUN docker-php-ext-install mbstring zip
|
12 |
+
RUN pecl install xdebug && docker-php-ext-enable xdebug
|
vendor/thunderer/shortcode/docker/php/php.ini
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
xdebug.mode=coverage
|
vendor/thunderer/shortcode/infection.json
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"source": {
|
3 |
+
"directories": ["src"]
|
4 |
+
},
|
5 |
+
"logs": {
|
6 |
+
"text": "infection.log"
|
7 |
+
},
|
8 |
+
"timeout": 2,
|
9 |
+
"mutators": {
|
10 |
+
"@default": true
|
11 |
+
}
|
12 |
+
}
|
vendor/thunderer/shortcode/phpunit.xml.dist
CHANGED
@@ -9,22 +9,22 @@
|
|
9 |
processIsolation = "false"
|
10 |
stopOnFailure = "false"
|
11 |
bootstrap = "vendor/autoload.php"
|
12 |
-
|
|
|
13 |
|
14 |
<testsuites>
|
15 |
<testsuite name="Shortcode">
|
16 |
-
<directory
|
17 |
</testsuite>
|
18 |
</testsuites>
|
19 |
|
20 |
-
<
|
21 |
-
<
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
<filter>
|
26 |
-
<whitelist>
|
27 |
-
<directory>./src</directory>
|
28 |
-
</whitelist>
|
29 |
-
</filter>
|
30 |
</phpunit>
|
9 |
processIsolation = "false"
|
10 |
stopOnFailure = "false"
|
11 |
bootstrap = "vendor/autoload.php"
|
12 |
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
13 |
+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
14 |
|
15 |
<testsuites>
|
16 |
<testsuite name="Shortcode">
|
17 |
+
<directory>tests</directory>
|
18 |
</testsuite>
|
19 |
</testsuites>
|
20 |
|
21 |
+
<coverage>
|
22 |
+
<include>
|
23 |
+
<directory>src</directory>
|
24 |
+
</include>
|
25 |
+
<report>
|
26 |
+
<html outputDirectory="coverage/html" lowUpperBound="50" highLowerBound="90" />
|
27 |
+
</report>
|
28 |
+
</coverage>
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
</phpunit>
|
vendor/thunderer/shortcode/psalm.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<psalm
|
3 |
+
totallyTyped="true"
|
4 |
+
findUnusedCode="false"
|
5 |
+
findUnusedVariablesAndParams="true"
|
6 |
+
findUnusedPsalmSuppress="true"
|
7 |
+
resolveFromConfigFile="true"
|
8 |
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
9 |
+
xmlns="https://getpsalm.org/schema/config"
|
10 |
+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
|
11 |
+
|
12 |
+
<projectFiles>
|
13 |
+
<directory name="src" />
|
14 |
+
<ignoreFiles>
|
15 |
+
<directory name="vendor" />
|
16 |
+
</ignoreFiles>
|
17 |
+
</projectFiles>
|
18 |
+
|
19 |
+
</psalm>
|
vendor/thunderer/shortcode/src/Event/FilterShortcodesEvent.php
CHANGED
@@ -13,28 +13,35 @@ use Thunder\Shortcode\Shortcode\ProcessedShortcode;
|
|
13 |
*/
|
14 |
class FilterShortcodesEvent
|
15 |
{
|
|
|
16 |
private $parent;
|
17 |
-
|
|
|
18 |
|
|
|
19 |
public function __construct(array $shortcodes, ProcessedShortcode $parent = null)
|
20 |
{
|
21 |
$this->parent = $parent;
|
22 |
$this->setShortcodes($shortcodes);
|
23 |
}
|
24 |
|
25 |
-
/**
|
26 |
-
* @return ParsedShortcodeInterface[]
|
27 |
-
*/
|
28 |
public function getShortcodes()
|
29 |
{
|
30 |
return $this->shortcodes;
|
31 |
}
|
32 |
|
|
|
33 |
public function getParent()
|
34 |
{
|
35 |
return $this->parent;
|
36 |
}
|
37 |
|
|
|
|
|
|
|
|
|
|
|
38 |
public function setShortcodes(array $shortcodes)
|
39 |
{
|
40 |
$this->shortcodes = array();
|
@@ -43,6 +50,11 @@ class FilterShortcodesEvent
|
|
43 |
}
|
44 |
}
|
45 |
|
|
|
|
|
|
|
|
|
|
|
46 |
private function addShortcode(ParsedShortcodeInterface $shortcode)
|
47 |
{
|
48 |
$this->shortcodes[] = $shortcode;
|
13 |
*/
|
14 |
class FilterShortcodesEvent
|
15 |
{
|
16 |
+
/** @var ProcessedShortcode|null */
|
17 |
private $parent;
|
18 |
+
/** @var ParsedShortcodeInterface[] */
|
19 |
+
private $shortcodes = array();
|
20 |
|
21 |
+
/** @param ParsedShortcodeInterface[] $shortcodes */
|
22 |
public function __construct(array $shortcodes, ProcessedShortcode $parent = null)
|
23 |
{
|
24 |
$this->parent = $parent;
|
25 |
$this->setShortcodes($shortcodes);
|
26 |
}
|
27 |
|
28 |
+
/** @return ParsedShortcodeInterface[] */
|
|
|
|
|
29 |
public function getShortcodes()
|
30 |
{
|
31 |
return $this->shortcodes;
|
32 |
}
|
33 |
|
34 |
+
/** @return ProcessedShortcode|null */
|
35 |
public function getParent()
|
36 |
{
|
37 |
return $this->parent;
|
38 |
}
|
39 |
|
40 |
+
/**
|
41 |
+
* @param ParsedShortcodeInterface[] $shortcodes
|
42 |
+
*
|
43 |
+
* @return void
|
44 |
+
*/
|
45 |
public function setShortcodes(array $shortcodes)
|
46 |
{
|
47 |
$this->shortcodes = array();
|
50 |
}
|
51 |
}
|
52 |
|
53 |
+
/**
|
54 |
+
* @param ParsedShortcodeInterface $shortcode
|
55 |
+
*
|
56 |
+
* @return void
|
57 |
+
*/
|
58 |
private function addShortcode(ParsedShortcodeInterface $shortcode)
|
59 |
{
|
60 |
$this->shortcodes[] = $shortcode;
|
vendor/thunderer/shortcode/src/Event/ReplaceShortcodesEvent.php
CHANGED
@@ -13,12 +13,19 @@ use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
|
13 |
*/
|
14 |
class ReplaceShortcodesEvent
|
15 |
{
|
|
|
16 |
private $shortcode;
|
|
|
17 |
private $text;
|
18 |
/** @var ReplacedShortcode[] */
|
19 |
-
private $replacements;
|
|
|
20 |
private $result;
|
21 |
|
|
|
|
|
|
|
|
|
22 |
public function __construct($text, array $replacements, ShortcodeInterface $shortcode = null)
|
23 |
{
|
24 |
$this->shortcode = $shortcode;
|
@@ -27,6 +34,11 @@ class ReplaceShortcodesEvent
|
|
27 |
$this->setReplacements($replacements);
|
28 |
}
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
private function setReplacements(array $replacements)
|
31 |
{
|
32 |
foreach($replacements as $replacement) {
|
@@ -34,36 +46,47 @@ class ReplaceShortcodesEvent
|
|
34 |
}
|
35 |
}
|
36 |
|
|
|
37 |
private function addReplacement(ReplacedShortcode $replacement)
|
38 |
{
|
39 |
$this->replacements[] = $replacement;
|
40 |
}
|
41 |
|
|
|
42 |
public function getText()
|
43 |
{
|
44 |
return $this->text;
|
45 |
}
|
46 |
|
|
|
47 |
public function getReplacements()
|
48 |
{
|
49 |
return $this->replacements;
|
50 |
}
|
51 |
|
|
|
52 |
public function getShortcode()
|
53 |
{
|
54 |
return $this->shortcode;
|
55 |
}
|
56 |
|
|
|
|
|
|
|
|
|
|
|
57 |
public function setResult($result)
|
58 |
{
|
59 |
$this->result = $result;
|
60 |
}
|
61 |
|
|
|
62 |
public function getResult()
|
63 |
{
|
64 |
return $this->result;
|
65 |
}
|
66 |
|
|
|
67 |
public function hasResult()
|
68 |
{
|
69 |
return null !== $this->result;
|
13 |
*/
|
14 |
class ReplaceShortcodesEvent
|
15 |
{
|
16 |
+
/** @var ShortcodeInterface|null */
|
17 |
private $shortcode;
|
18 |
+
/** @var string */
|
19 |
private $text;
|
20 |
/** @var ReplacedShortcode[] */
|
21 |
+
private $replacements = array();
|
22 |
+
/** @var string|null */
|
23 |
private $result;
|
24 |
|
25 |
+
/**
|
26 |
+
* @param string $text
|
27 |
+
* @param ReplacedShortcode[] $replacements
|
28 |
+
*/
|
29 |
public function __construct($text, array $replacements, ShortcodeInterface $shortcode = null)
|
30 |
{
|
31 |
$this->shortcode = $shortcode;
|
34 |
$this->setReplacements($replacements);
|
35 |
}
|
36 |
|
37 |
+
/**
|
38 |
+
* @param ReplacedShortcode[] $replacements
|
39 |
+
*
|
40 |
+
* @return void
|
41 |
+
*/
|
42 |
private function setReplacements(array $replacements)
|
43 |
{
|
44 |
foreach($replacements as $replacement) {
|
46 |
}
|
47 |
}
|
48 |
|
49 |
+
/** @return void */
|
50 |
private function addReplacement(ReplacedShortcode $replacement)
|
51 |
{
|
52 |
$this->replacements[] = $replacement;
|
53 |
}
|
54 |
|
55 |
+
/** @return string */
|
56 |
public function getText()
|
57 |
{
|
58 |
return $this->text;
|
59 |
}
|
60 |
|
61 |
+
/** @return ReplacedShortcode[] */
|
62 |
public function getReplacements()
|
63 |
{
|
64 |
return $this->replacements;
|
65 |
}
|
66 |
|
67 |
+
/** @return ShortcodeInterface|null */
|
68 |
public function getShortcode()
|
69 |
{
|
70 |
return $this->shortcode;
|
71 |
}
|
72 |
|
73 |
+
/**
|
74 |
+
* @param string $result
|
75 |
+
*
|
76 |
+
* @return void
|
77 |
+
*/
|
78 |
public function setResult($result)
|
79 |
{
|
80 |
$this->result = $result;
|
81 |
}
|
82 |
|
83 |
+
/** @return string|null */
|
84 |
public function getResult()
|
85 |
{
|
86 |
return $this->result;
|
87 |
}
|
88 |
|
89 |
+
/** @return bool */
|
90 |
public function hasResult()
|
91 |
{
|
92 |
return null !== $this->result;
|
vendor/thunderer/shortcode/src/EventContainer/EventContainer.php
CHANGED
@@ -8,12 +8,19 @@ use Thunder\Shortcode\Events;
|
|
8 |
*/
|
9 |
final class EventContainer implements EventContainerInterface
|
10 |
{
|
|
|
11 |
private $listeners = array();
|
12 |
|
13 |
public function __construct()
|
14 |
{
|
15 |
}
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
public function addListener($event, $handler)
|
18 |
{
|
19 |
if(!\in_array($event, Events::getEvents(), true)) {
|
@@ -27,11 +34,21 @@ final class EventContainer implements EventContainerInterface
|
|
27 |
$this->listeners[$event][] = $handler;
|
28 |
}
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
public function getListeners($event)
|
31 |
{
|
32 |
return $this->hasEvent($event) ? $this->listeners[$event] : array();
|
33 |
}
|
34 |
|
|
|
|
|
|
|
|
|
|
|
35 |
private function hasEvent($name)
|
36 |
{
|
37 |
return array_key_exists($name, $this->listeners);
|
8 |
*/
|
9 |
final class EventContainer implements EventContainerInterface
|
10 |
{
|
11 |
+
/** @psalm-var array<string,list<callable>> */
|
12 |
private $listeners = array();
|
13 |
|
14 |
public function __construct()
|
15 |
{
|
16 |
}
|
17 |
|
18 |
+
/**
|
19 |
+
* @param string $event
|
20 |
+
* @param callable $handler
|
21 |
+
*
|
22 |
+
* @return void
|
23 |
+
*/
|
24 |
public function addListener($event, $handler)
|
25 |
{
|
26 |
if(!\in_array($event, Events::getEvents(), true)) {
|
34 |
$this->listeners[$event][] = $handler;
|
35 |
}
|
36 |
|
37 |
+
/**
|
38 |
+
* @param string $event
|
39 |
+
*
|
40 |
+
* @psalm-return list<callable>
|
41 |
+
*/
|
42 |
public function getListeners($event)
|
43 |
{
|
44 |
return $this->hasEvent($event) ? $this->listeners[$event] : array();
|
45 |
}
|
46 |
|
47 |
+
/**
|
48 |
+
* @param string $name
|
49 |
+
*
|
50 |
+
* @return bool
|
51 |
+
*/
|
52 |
private function hasEvent($name)
|
53 |
{
|
54 |
return array_key_exists($name, $this->listeners);
|
vendor/thunderer/shortcode/src/EventHandler/ReplaceJoinEventHandler.php
CHANGED
@@ -24,7 +24,8 @@ final class ReplaceJoinEventHandler
|
|
24 |
|
25 |
public function __invoke(ReplaceShortcodesEvent $event)
|
26 |
{
|
27 |
-
|
|
|
28 |
$replaces = array();
|
29 |
foreach($event->getReplacements() as $r) {
|
30 |
$replaces[] = $r->getReplacement();
|
24 |
|
25 |
public function __invoke(ReplaceShortcodesEvent $event)
|
26 |
{
|
27 |
+
$shortcode = $event->getShortcode();
|
28 |
+
if($shortcode && in_array($shortcode->getName(), $this->names)) {
|
29 |
$replaces = array();
|
30 |
foreach($event->getReplacements() as $r) {
|
31 |
$replaces[] = $r->getReplacement();
|
vendor/thunderer/shortcode/src/Events.php
CHANGED
@@ -9,6 +9,7 @@ final class Events
|
|
9 |
const FILTER_SHORTCODES = 'event.filter-shortcodes';
|
10 |
const REPLACE_SHORTCODES = 'event.replace-shortcodes';
|
11 |
|
|
|
12 |
public static function getEvents()
|
13 |
{
|
14 |
return array(static::FILTER_SHORTCODES, static::REPLACE_SHORTCODES);
|
9 |
const FILTER_SHORTCODES = 'event.filter-shortcodes';
|
10 |
const REPLACE_SHORTCODES = 'event.replace-shortcodes';
|
11 |
|
12 |
+
/** @return string[] */
|
13 |
public static function getEvents()
|
14 |
{
|
15 |
return array(static::FILTER_SHORTCODES, static::REPLACE_SHORTCODES);
|
vendor/thunderer/shortcode/src/Handler/DeclareHandler.php
CHANGED
@@ -11,8 +11,10 @@ final class DeclareHandler
|
|
11 |
{
|
12 |
/** @var HandlerContainer */
|
13 |
private $handlers;
|
|
|
14 |
private $delimiter;
|
15 |
|
|
|
16 |
public function __construct(HandlerContainer $container, $delimiter = '%')
|
17 |
{
|
18 |
$this->handlers = $container;
|
@@ -33,12 +35,13 @@ final class DeclareHandler
|
|
33 |
}
|
34 |
$keys = array_keys($args);
|
35 |
$name = array_shift($keys);
|
36 |
-
$content = $shortcode->getContent();
|
37 |
$delimiter = $this->delimiter;
|
38 |
|
39 |
$this->handlers->add($name, function(ShortcodeInterface $shortcode) use($content, $delimiter) {
|
40 |
$args = $shortcode->getParameters();
|
41 |
$keys = array_map(function($key) use($delimiter) { return $delimiter.$key.$delimiter; }, array_keys($args));
|
|
|
42 |
$values = array_values($args);
|
43 |
|
44 |
return str_replace($keys, $values, $content);
|
11 |
{
|
12 |
/** @var HandlerContainer */
|
13 |
private $handlers;
|
14 |
+
/** @var string */
|
15 |
private $delimiter;
|
16 |
|
17 |
+
/** @param string $delimiter */
|
18 |
public function __construct(HandlerContainer $container, $delimiter = '%')
|
19 |
{
|
20 |
$this->handlers = $container;
|
35 |
}
|
36 |
$keys = array_keys($args);
|
37 |
$name = array_shift($keys);
|
38 |
+
$content = (string)$shortcode->getContent();
|
39 |
$delimiter = $this->delimiter;
|
40 |
|
41 |
$this->handlers->add($name, function(ShortcodeInterface $shortcode) use($content, $delimiter) {
|
42 |
$args = $shortcode->getParameters();
|
43 |
$keys = array_map(function($key) use($delimiter) { return $delimiter.$key.$delimiter; }, array_keys($args));
|
44 |
+
/** @var string[] $values */
|
45 |
$values = array_values($args);
|
46 |
|
47 |
return str_replace($keys, $values, $content);
|
vendor/thunderer/shortcode/src/Handler/EmailHandler.php
CHANGED
@@ -22,6 +22,6 @@ final class EmailHandler
|
|
22 |
$email = $shortcode->getBbCode() ?: $shortcode->getContent();
|
23 |
$content = $shortcode->getContent() === null ? $email : $shortcode->getContent();
|
24 |
|
25 |
-
return '<a href="mailto:'
|
26 |
}
|
27 |
}
|
22 |
$email = $shortcode->getBbCode() ?: $shortcode->getContent();
|
23 |
$content = $shortcode->getContent() === null ? $email : $shortcode->getContent();
|
24 |
|
25 |
+
return '<a href="mailto:'.(string)$email.'">'.(string)$content.'</a>';
|
26 |
}
|
27 |
}
|
vendor/thunderer/shortcode/src/Handler/PlaceholderHandler.php
CHANGED
@@ -8,8 +8,10 @@ use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
|
8 |
*/
|
9 |
final class PlaceholderHandler
|
10 |
{
|
|
|
11 |
private $delimiter;
|
12 |
|
|
|
13 |
public function __construct($delimiter = '%')
|
14 |
{
|
15 |
$this->delimiter = $delimiter;
|
@@ -27,8 +29,9 @@ final class PlaceholderHandler
|
|
27 |
$args = $shortcode->getParameters();
|
28 |
$delimiter = $this->delimiter;
|
29 |
$keys = array_map(function($key) use($delimiter) { return $delimiter.$key.$delimiter; }, array_keys($args));
|
|
|
30 |
$values = array_values($args);
|
31 |
|
32 |
-
return str_replace($keys, $values, $shortcode->getContent());
|
33 |
}
|
34 |
}
|
8 |
*/
|
9 |
final class PlaceholderHandler
|
10 |
{
|
11 |
+
/** @var string */
|
12 |
private $delimiter;
|
13 |
|
14 |
+
/** @param string $delimiter */
|
15 |
public function __construct($delimiter = '%')
|
16 |
{
|
17 |
$this->delimiter = $delimiter;
|
29 |
$args = $shortcode->getParameters();
|
30 |
$delimiter = $this->delimiter;
|
31 |
$keys = array_map(function($key) use($delimiter) { return $delimiter.$key.$delimiter; }, array_keys($args));
|
32 |
+
/** @var string[] $values */
|
33 |
$values = array_values($args);
|
34 |
|
35 |
+
return str_replace($keys, $values, (string)$shortcode->getContent());
|
36 |
}
|
37 |
}
|
vendor/thunderer/shortcode/src/Handler/UrlHandler.php
CHANGED
@@ -21,6 +21,6 @@ final class UrlHandler
|
|
21 |
{
|
22 |
$url = $shortcode->getBbCode() ?: $shortcode->getContent();
|
23 |
|
24 |
-
return '<a href="'
|
25 |
}
|
26 |
}
|
21 |
{
|
22 |
$url = $shortcode->getBbCode() ?: $shortcode->getContent();
|
23 |
|
24 |
+
return '<a href="'.(string)$url.'">'.(string)$shortcode->getContent().'</a>';
|
25 |
}
|
26 |
}
|
vendor/thunderer/shortcode/src/Handler/WrapHandler.php
CHANGED
@@ -8,15 +8,22 @@ use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
|
8 |
*/
|
9 |
final class WrapHandler
|
10 |
{
|
|
|
11 |
private $before;
|
|
|
12 |
private $after;
|
13 |
|
|
|
|
|
|
|
|
|
14 |
public function __construct($before, $after)
|
15 |
{
|
16 |
$this->before = $before;
|
17 |
$this->after = $after;
|
18 |
}
|
19 |
|
|
|
20 |
public static function createBold()
|
21 |
{
|
22 |
return new self('<b>', '</b>');
|
@@ -32,6 +39,6 @@ final class WrapHandler
|
|
32 |
*/
|
33 |
public function __invoke(ShortcodeInterface $shortcode)
|
34 |
{
|
35 |
-
return $this->before
|
36 |
}
|
37 |
}
|
8 |
*/
|
9 |
final class WrapHandler
|
10 |
{
|
11 |
+
/** @var string */
|
12 |
private $before;
|
13 |
+
/** @var string */
|
14 |
private $after;
|
15 |
|
16 |
+
/**
|
17 |
+
* @param string $before
|
18 |
+
* @param string $after
|
19 |
+
*/
|
20 |
public function __construct($before, $after)
|
21 |
{
|
22 |
$this->before = $before;
|
23 |
$this->after = $after;
|
24 |
}
|
25 |
|
26 |
+
/** @return self */
|
27 |
public static function createBold()
|
28 |
{
|
29 |
return new self('<b>', '</b>');
|
39 |
*/
|
40 |
public function __invoke(ShortcodeInterface $shortcode)
|
41 |
{
|
42 |
+
return $this->before.(string)$shortcode->getContent().$this->after;
|
43 |
}
|
44 |
}
|
vendor/thunderer/shortcode/src/HandlerContainer/HandlerContainer.php
CHANGED
@@ -1,17 +1,25 @@
|
|
1 |
<?php
|
2 |
namespace Thunder\Shortcode\HandlerContainer;
|
3 |
|
|
|
|
|
4 |
/**
|
5 |
* @author Tomasz Kowalczyk <tomasz@kowalczyk.cc>
|
6 |
*/
|
7 |
final class HandlerContainer implements HandlerContainerInterface
|
8 |
{
|
9 |
-
/** @var callable
|
10 |
private $handlers = array();
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
public function add($name, $handler)
|
16 |
{
|
17 |
$this->guardHandler($handler);
|
@@ -26,6 +34,12 @@ final class HandlerContainer implements HandlerContainerInterface
|
|
26 |
return $this;
|
27 |
}
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
public function addAlias($alias, $name)
|
30 |
{
|
31 |
if (false === $this->has($name)) {
|
@@ -33,9 +47,15 @@ final class HandlerContainer implements HandlerContainerInterface
|
|
33 |
throw new \RuntimeException(sprintf($msg, $alias, $name));
|
34 |
}
|
35 |
|
|
|
36 |
return $this->add($alias, $this->get($name));
|
37 |
}
|
38 |
|
|
|
|
|
|
|
|
|
|
|
39 |
public function remove($name)
|
40 |
{
|
41 |
if (false === $this->has($name)) {
|
@@ -46,6 +66,12 @@ final class HandlerContainer implements HandlerContainerInterface
|
|
46 |
unset($this->handlers[$name]);
|
47 |
}
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
public function setDefault($handler)
|
50 |
{
|
51 |
$this->guardHandler($handler);
|
@@ -55,21 +81,38 @@ final class HandlerContainer implements HandlerContainerInterface
|
|
55 |
return $this;
|
56 |
}
|
57 |
|
|
|
58 |
public function getNames()
|
59 |
{
|
60 |
return array_keys($this->handlers);
|
61 |
}
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
public function get($name)
|
64 |
{
|
65 |
return $this->has($name) ? $this->handlers[$name] : $this->default;
|
66 |
}
|
67 |
|
|
|
|
|
|
|
|
|
|
|
68 |
public function has($name)
|
69 |
{
|
70 |
return array_key_exists($name, $this->handlers);
|
71 |
}
|
72 |
|
|
|
|
|
|
|
|
|
|
|
73 |
private function guardHandler($handler)
|
74 |
{
|
75 |
if (!is_callable($handler)) {
|
1 |
<?php
|
2 |
namespace Thunder\Shortcode\HandlerContainer;
|
3 |
|
4 |
+
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
5 |
+
|
6 |
/**
|
7 |
* @author Tomasz Kowalczyk <tomasz@kowalczyk.cc>
|
8 |
*/
|
9 |
final class HandlerContainer implements HandlerContainerInterface
|
10 |
{
|
11 |
+
/** @psalm-var array<string,callable(ShortcodeInterface):string> */
|
12 |
private $handlers = array();
|
13 |
+
/** @psalm-var (callable(ShortcodeInterface):string)|null */
|
14 |
+
private $default = null;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @param string $name
|
18 |
+
* @param callable $handler
|
19 |
+
* @psalm-param callable(ShortcodeInterface):string $handler
|
20 |
+
*
|
21 |
+
* @return $this
|
22 |
+
*/
|
23 |
public function add($name, $handler)
|
24 |
{
|
25 |
$this->guardHandler($handler);
|
34 |
return $this;
|
35 |
}
|
36 |
|
37 |
+
/**
|
38 |
+
* @param string $alias
|
39 |
+
* @param string $name
|
40 |
+
*
|
41 |
+
* @return $this
|
42 |
+
*/
|
43 |
public function addAlias($alias, $name)
|
44 |
{
|
45 |
if (false === $this->has($name)) {
|
47 |
throw new \RuntimeException(sprintf($msg, $alias, $name));
|
48 |
}
|
49 |
|
50 |
+
/** @psalm-suppress PossiblyNullArgument */
|
51 |
return $this->add($alias, $this->get($name));
|
52 |
}
|
53 |
|
54 |
+
/**
|
55 |
+
* @param string $name
|
56 |
+
*
|
57 |
+
* @return void
|
58 |
+
*/
|
59 |
public function remove($name)
|
60 |
{
|
61 |
if (false === $this->has($name)) {
|
66 |
unset($this->handlers[$name]);
|
67 |
}
|
68 |
|
69 |
+
/**
|
70 |
+
* @param callable $handler
|
71 |
+
* @psalm-param callable(ShortcodeInterface):string $handler
|
72 |
+
*
|
73 |
+
* @return $this
|
74 |
+
*/
|
75 |
public function setDefault($handler)
|
76 |
{
|
77 |
$this->guardHandler($handler);
|
81 |
return $this;
|
82 |
}
|
83 |
|
84 |
+
/** @return string[] */
|
85 |
public function getNames()
|
86 |
{
|
87 |
return array_keys($this->handlers);
|
88 |
}
|
89 |
|
90 |
+
/**
|
91 |
+
* @param string $name
|
92 |
+
*
|
93 |
+
* @return callable|null
|
94 |
+
* @psalm-return (callable(ShortcodeInterface):string)|null
|
95 |
+
*/
|
96 |
public function get($name)
|
97 |
{
|
98 |
return $this->has($name) ? $this->handlers[$name] : $this->default;
|
99 |
}
|
100 |
|
101 |
+
/**
|
102 |
+
* @param string $name
|
103 |
+
*
|
104 |
+
* @return bool
|
105 |
+
*/
|
106 |
public function has($name)
|
107 |
{
|
108 |
return array_key_exists($name, $this->handlers);
|
109 |
}
|
110 |
|
111 |
+
/**
|
112 |
+
* @param callable $handler
|
113 |
+
*
|
114 |
+
* @return void
|
115 |
+
*/
|
116 |
private function guardHandler($handler)
|
117 |
{
|
118 |
if (!is_callable($handler)) {
|
vendor/thunderer/shortcode/src/HandlerContainer/HandlerContainerInterface.php
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
<?php
|
2 |
namespace Thunder\Shortcode\HandlerContainer;
|
3 |
|
|
|
|
|
4 |
/**
|
5 |
* @author Tomasz Kowalczyk <tomasz@kowalczyk.cc>
|
6 |
*/
|
@@ -13,6 +15,7 @@ interface HandlerContainerInterface
|
|
13 |
* @param string $name Shortcode name
|
14 |
*
|
15 |
* @return callable|null
|
|
|
16 |
*/
|
17 |
public function get($name);
|
18 |
}
|
1 |
<?php
|
2 |
namespace Thunder\Shortcode\HandlerContainer;
|
3 |
|
4 |
+
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
5 |
+
|
6 |
/**
|
7 |
* @author Tomasz Kowalczyk <tomasz@kowalczyk.cc>
|
8 |
*/
|
15 |
* @param string $name Shortcode name
|
16 |
*
|
17 |
* @return callable|null
|
18 |
+
* @psalm-return (callable(ShortcodeInterface):string)|null
|
19 |
*/
|
20 |
public function get($name);
|
21 |
}
|
vendor/thunderer/shortcode/src/HandlerContainer/ImmutableHandlerContainer.php
CHANGED
@@ -1,11 +1,14 @@
|
|
1 |
<?php
|
2 |
namespace Thunder\Shortcode\HandlerContainer;
|
3 |
|
|
|
|
|
4 |
/**
|
5 |
* @author Tomasz Kowalczyk <tomasz@kowalczyk.cc>
|
6 |
*/
|
7 |
final class ImmutableHandlerContainer implements HandlerContainerInterface
|
8 |
{
|
|
|
9 |
private $handlers;
|
10 |
|
11 |
public function __construct(HandlerContainer $handlers)
|
@@ -13,6 +16,12 @@ final class ImmutableHandlerContainer implements HandlerContainerInterface
|
|
13 |
$this->handlers = clone $handlers;
|
14 |
}
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
public function get($name)
|
17 |
{
|
18 |
return $this->handlers->get($name);
|
1 |
<?php
|
2 |
namespace Thunder\Shortcode\HandlerContainer;
|
3 |
|
4 |
+
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
5 |
+
|
6 |
/**
|
7 |
* @author Tomasz Kowalczyk <tomasz@kowalczyk.cc>
|
8 |
*/
|
9 |
final class ImmutableHandlerContainer implements HandlerContainerInterface
|
10 |
{
|
11 |
+
/** @var HandlerContainer */
|
12 |
private $handlers;
|
13 |
|
14 |
public function __construct(HandlerContainer $handlers)
|
16 |
$this->handlers = clone $handlers;
|
17 |
}
|
18 |
|
19 |
+
/**
|
20 |
+
* @param string $name
|
21 |
+
*
|
22 |
+
* @return callable|null
|
23 |
+
* @psalm-return (callable(ShortcodeInterface):string)|null
|
24 |
+
*/
|
25 |
public function get($name)
|
26 |
{
|
27 |
return $this->handlers->get($name);
|
vendor/thunderer/shortcode/src/Parser/RegexParser.php
CHANGED
@@ -14,8 +14,11 @@ final class RegexParser implements ParserInterface
|
|
14 |
{
|
15 |
/** @var SyntaxInterface */
|
16 |
private $syntax;
|
|
|
17 |
private $shortcodeRegex;
|
|
|
18 |
private $singleShortcodeRegex;
|
|
|
19 |
private $parametersRegex;
|
20 |
|
21 |
public function __construct(SyntaxInterface $syntax = null)
|
@@ -45,10 +48,17 @@ final class RegexParser implements ParserInterface
|
|
45 |
return array_filter($shortcodes);
|
46 |
}
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
private function parseSingle($text, $offset)
|
49 |
{
|
50 |
preg_match($this->singleShortcodeRegex, $text, $matches, PREG_OFFSET_CAPTURE);
|
51 |
|
|
|
52 |
$name = $matches['name'][0];
|
53 |
$parameters = isset($matches['parameters'][0]) ? $this->parseParameters($matches['parameters'][0]) : array();
|
54 |
$bbCode = isset($matches['bbCode'][0]) && $matches['bbCode'][1] !== -1
|
@@ -59,6 +69,11 @@ final class RegexParser implements ParserInterface
|
|
59 |
return new ParsedShortcode(new Shortcode($name, $parameters, $content, $bbCode), $text, $offset);
|
60 |
}
|
61 |
|
|
|
|
|
|
|
|
|
|
|
62 |
private function parseParameters($text)
|
63 |
{
|
64 |
preg_match_all($this->parametersRegex, $text, $argsMatches);
|
@@ -66,6 +81,7 @@ final class RegexParser implements ParserInterface
|
|
66 |
// loop because PHP 5.3 can't handle $this properly and I want separate methods
|
67 |
$return = array();
|
68 |
foreach ($argsMatches[1] as $item) {
|
|
|
69 |
$parts = explode($this->syntax->getParameterValueSeparator(), $item, 2);
|
70 |
$return[trim($parts[0])] = $this->parseValue(isset($parts[1]) ? $parts[1] : null);
|
71 |
}
|
@@ -73,11 +89,21 @@ final class RegexParser implements ParserInterface
|
|
73 |
return $return;
|
74 |
}
|
75 |
|
|
|
|
|
|
|
|
|
|
|
76 |
private function parseValue($value)
|
77 |
{
|
78 |
return null === $value ? null : $this->extractValue(trim($value));
|
79 |
}
|
80 |
|
|
|
|
|
|
|
|
|
|
|
81 |
private function extractValue($value)
|
82 |
{
|
83 |
$length = strlen($this->syntax->getParameterValueDelimiter());
|
@@ -85,6 +111,11 @@ final class RegexParser implements ParserInterface
|
|
85 |
return $this->isDelimitedValue($value) ? substr($value, $length, -1 * $length) : $value;
|
86 |
}
|
87 |
|
|
|
|
|
|
|
|
|
|
|
88 |
private function isDelimitedValue($value)
|
89 |
{
|
90 |
return preg_match('/^'.$this->syntax->getParameterValueDelimiter().'/us', $value)
|
14 |
{
|
15 |
/** @var SyntaxInterface */
|
16 |
private $syntax;
|
17 |
+
/** @var string */
|
18 |
private $shortcodeRegex;
|
19 |
+
/** @var string */
|
20 |
private $singleShortcodeRegex;
|
21 |
+
/** @var string */
|
22 |
private $parametersRegex;
|
23 |
|
24 |
public function __construct(SyntaxInterface $syntax = null)
|
48 |
return array_filter($shortcodes);
|
49 |
}
|
50 |
|
51 |
+
/**
|
52 |
+
* @param string $text
|
53 |
+
* @param int $offset
|
54 |
+
*
|
55 |
+
* @return ParsedShortcode
|
56 |
+
*/
|
57 |
private function parseSingle($text, $offset)
|
58 |
{
|
59 |
preg_match($this->singleShortcodeRegex, $text, $matches, PREG_OFFSET_CAPTURE);
|
60 |
|
61 |
+
/** @psalm-var array<string,array{0:string,1:int}> $matches */
|
62 |
$name = $matches['name'][0];
|
63 |
$parameters = isset($matches['parameters'][0]) ? $this->parseParameters($matches['parameters'][0]) : array();
|
64 |
$bbCode = isset($matches['bbCode'][0]) && $matches['bbCode'][1] !== -1
|
69 |
return new ParsedShortcode(new Shortcode($name, $parameters, $content, $bbCode), $text, $offset);
|
70 |
}
|
71 |
|
72 |
+
/**
|
73 |
+
* @param string $text
|
74 |
+
*
|
75 |
+
* @psalm-return array<string,string|null>
|
76 |
+
*/
|
77 |
private function parseParameters($text)
|
78 |
{
|
79 |
preg_match_all($this->parametersRegex, $text, $argsMatches);
|
81 |
// loop because PHP 5.3 can't handle $this properly and I want separate methods
|
82 |
$return = array();
|
83 |
foreach ($argsMatches[1] as $item) {
|
84 |
+
/** @psalm-var array{0:string,1:string} $parts */
|
85 |
$parts = explode($this->syntax->getParameterValueSeparator(), $item, 2);
|
86 |
$return[trim($parts[0])] = $this->parseValue(isset($parts[1]) ? $parts[1] : null);
|
87 |
}
|
89 |
return $return;
|
90 |
}
|
91 |
|
92 |
+
/**
|
93 |
+
* @param string|null $value
|
94 |
+
*
|
95 |
+
* @return string|null
|
96 |
+
*/
|
97 |
private function parseValue($value)
|
98 |
{
|
99 |
return null === $value ? null : $this->extractValue(trim($value));
|
100 |
}
|
101 |
|
102 |
+
/**
|
103 |
+
* @param string $value
|
104 |
+
*
|
105 |
+
* @return string
|
106 |
+
*/
|
107 |
private function extractValue($value)
|
108 |
{
|
109 |
$length = strlen($this->syntax->getParameterValueDelimiter());
|
111 |
return $this->isDelimitedValue($value) ? substr($value, $length, -1 * $length) : $value;
|
112 |
}
|
113 |
|
114 |
+
/**
|
115 |
+
* @param string $value
|
116 |
+
*
|
117 |
+
* @return bool
|
118 |
+
*/
|
119 |
private function isDelimitedValue($value)
|
120 |
{
|
121 |
return preg_match('/^'.$this->syntax->getParameterValueDelimiter().'/us', $value)
|
vendor/thunderer/shortcode/src/Parser/RegularParser.php
CHANGED
@@ -12,14 +12,20 @@ use Thunder\Shortcode\Utility\RegexBuilderUtility;
|
|
12 |
*/
|
13 |
final class RegularParser implements ParserInterface
|
14 |
{
|
|
|
15 |
private $lexerRegex;
|
|
|
16 |
private $nameRegex;
|
17 |
-
|
18 |
-
private $
|
19 |
-
|
|
|
|
|
|
|
20 |
/** @var int[] */
|
21 |
-
private $backtracks;
|
22 |
-
|
|
|
23 |
|
24 |
const TOKEN_OPEN = 1;
|
25 |
const TOKEN_CLOSE = 2;
|
@@ -42,7 +48,7 @@ final class RegularParser implements ParserInterface
|
|
42 |
*/
|
43 |
public function parse($text)
|
44 |
{
|
45 |
-
$nestingLevel = ini_set('xdebug.max_nesting_level', -1);
|
46 |
$this->tokens = $this->tokenize($text);
|
47 |
$this->backtracks = array();
|
48 |
$this->lastBacktrack = 0;
|
@@ -73,6 +79,16 @@ final class RegularParser implements ParserInterface
|
|
73 |
return $shortcodes;
|
74 |
}
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
private function getObject($name, $parameters, $bbCode, $offset, $content, $text)
|
77 |
{
|
78 |
return new ParsedShortcode(new Shortcode($name, $parameters, $content, $bbCode), $text, $offset);
|
@@ -80,6 +96,14 @@ final class RegularParser implements ParserInterface
|
|
80 |
|
81 |
/* --- RULES ----------------------------------------------------------- */
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
private function shortcode(array &$names)
|
84 |
{
|
85 |
if(!$this->match(self::TOKEN_OPEN, false)) { return false; }
|
@@ -118,6 +142,7 @@ final class RegularParser implements ParserInterface
|
|
118 |
}
|
119 |
|
120 |
$this->beginBacktrack();
|
|
|
121 |
$contentMatchedShortcodes = $this->shortcode($names);
|
122 |
if(\is_string($contentMatchedShortcodes)) {
|
123 |
$closingName = $contentMatchedShortcodes;
|
@@ -133,7 +158,6 @@ final class RegularParser implements ParserInterface
|
|
133 |
|
134 |
$this->beginBacktrack();
|
135 |
if(false !== ($closingName = $this->close($names))) {
|
136 |
-
if(null === $content) { $content = ''; }
|
137 |
$this->backtrack();
|
138 |
$shortcodes = array();
|
139 |
break;
|
@@ -167,6 +191,11 @@ final class RegularParser implements ParserInterface
|
|
167 |
return array($this->getObject($name, $parameters, $bbCode, $offset, $content, $this->getBacktrack()));
|
168 |
}
|
169 |
|
|
|
|
|
|
|
|
|
|
|
170 |
private function close(array &$names)
|
171 |
{
|
172 |
if(!$this->match(self::TOKEN_OPEN, true)) { return false; }
|
@@ -177,6 +206,7 @@ final class RegularParser implements ParserInterface
|
|
177 |
return \in_array($closingName, $names, true) ? $closingName : false;
|
178 |
}
|
179 |
|
|
|
180 |
private function parameters()
|
181 |
{
|
182 |
$parameters = array();
|
@@ -195,6 +225,7 @@ final class RegularParser implements ParserInterface
|
|
195 |
return $parameters;
|
196 |
}
|
197 |
|
|
|
198 |
private function value()
|
199 |
{
|
200 |
$value = '';
|
@@ -221,12 +252,14 @@ final class RegularParser implements ParserInterface
|
|
221 |
|
222 |
/* --- PARSER ---------------------------------------------------------- */
|
223 |
|
|
|
224 |
private function beginBacktrack()
|
225 |
{
|
226 |
$this->backtracks[] = $this->position;
|
227 |
$this->lastBacktrack = $this->position;
|
228 |
}
|
229 |
|
|
|
230 |
private function getBacktrack()
|
231 |
{
|
232 |
$position = array_pop($this->backtracks);
|
@@ -238,6 +271,11 @@ final class RegularParser implements ParserInterface
|
|
238 |
return $backtrack;
|
239 |
}
|
240 |
|
|
|
|
|
|
|
|
|
|
|
241 |
private function backtrack($modifyPosition = true)
|
242 |
{
|
243 |
$position = array_pop($this->backtracks);
|
@@ -254,11 +292,22 @@ final class RegularParser implements ParserInterface
|
|
254 |
return $backtrack;
|
255 |
}
|
256 |
|
|
|
|
|
|
|
|
|
|
|
257 |
private function lookahead($type)
|
258 |
{
|
259 |
return $this->position < $this->tokensCount && $this->tokens[$this->position][0] === $type;
|
260 |
}
|
261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
private function match($type, $ws)
|
263 |
{
|
264 |
if($this->position >= $this->tokensCount) {
|
@@ -280,6 +329,11 @@ final class RegularParser implements ParserInterface
|
|
280 |
|
281 |
/* --- LEXER ----------------------------------------------------------- */
|
282 |
|
|
|
|
|
|
|
|
|
|
|
283 |
private function tokenize($text)
|
284 |
{
|
285 |
$count = preg_match_all($this->lexerRegex, $text, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
|
@@ -308,13 +362,17 @@ final class RegularParser implements ParserInterface
|
|
308 |
return $tokens;
|
309 |
}
|
310 |
|
|
|
311 |
private function prepareLexer(SyntaxInterface $syntax)
|
312 |
{
|
|
|
|
|
313 |
$group = function($text, $group) {
|
314 |
-
return '(?<'
|
315 |
};
|
|
|
316 |
$quote = function($text) {
|
317 |
-
return preg_replace('/(.)/us', '\\\\$0', $text);
|
318 |
};
|
319 |
|
320 |
$rules = array(
|
12 |
*/
|
13 |
final class RegularParser implements ParserInterface
|
14 |
{
|
15 |
+
/** @var string */
|
16 |
private $lexerRegex;
|
17 |
+
/** @var string */
|
18 |
private $nameRegex;
|
19 |
+
/** @psalm-var list<array{0:int,1:string,2:int}> */
|
20 |
+
private $tokens = array();
|
21 |
+
/** @var int */
|
22 |
+
private $tokensCount = 0;
|
23 |
+
/** @var int */
|
24 |
+
private $position = 0;
|
25 |
/** @var int[] */
|
26 |
+
private $backtracks = array();
|
27 |
+
/** @var int */
|
28 |
+
private $lastBacktrack = 0;
|
29 |
|
30 |
const TOKEN_OPEN = 1;
|
31 |
const TOKEN_CLOSE = 2;
|
48 |
*/
|
49 |
public function parse($text)
|
50 |
{
|
51 |
+
$nestingLevel = ini_set('xdebug.max_nesting_level', '-1');
|
52 |
$this->tokens = $this->tokenize($text);
|
53 |
$this->backtracks = array();
|
54 |
$this->lastBacktrack = 0;
|
79 |
return $shortcodes;
|
80 |
}
|
81 |
|
82 |
+
/**
|
83 |
+
* @param string $name
|
84 |
+
* @psalm-param array<string,string|null> $parameters
|
85 |
+
* @param string|null $bbCode
|
86 |
+
* @param int $offset
|
87 |
+
* @param string|null $content
|
88 |
+
* @param string $text
|
89 |
+
*
|
90 |
+
* @return ParsedShortcode
|
91 |
+
*/
|
92 |
private function getObject($name, $parameters, $bbCode, $offset, $content, $text)
|
93 |
{
|
94 |
return new ParsedShortcode(new Shortcode($name, $parameters, $content, $bbCode), $text, $offset);
|
96 |
|
97 |
/* --- RULES ----------------------------------------------------------- */
|
98 |
|
99 |
+
/**
|
100 |
+
* @param string[] $names
|
101 |
+
* @psalm-param list<string> $names
|
102 |
+
* FIXME: investigate the reason Psalm complains about references
|
103 |
+
* @psalm-suppress ReferenceConstraintViolation
|
104 |
+
*
|
105 |
+
* @return ParsedShortcode[]|string|false
|
106 |
+
*/
|
107 |
private function shortcode(array &$names)
|
108 |
{
|
109 |
if(!$this->match(self::TOKEN_OPEN, false)) { return false; }
|
142 |
}
|
143 |
|
144 |
$this->beginBacktrack();
|
145 |
+
/** @psalm-suppress MixedArgumentTypeCoercion */
|
146 |
$contentMatchedShortcodes = $this->shortcode($names);
|
147 |
if(\is_string($contentMatchedShortcodes)) {
|
148 |
$closingName = $contentMatchedShortcodes;
|
158 |
|
159 |
$this->beginBacktrack();
|
160 |
if(false !== ($closingName = $this->close($names))) {
|
|
|
161 |
$this->backtrack();
|
162 |
$shortcodes = array();
|
163 |
break;
|
191 |
return array($this->getObject($name, $parameters, $bbCode, $offset, $content, $this->getBacktrack()));
|
192 |
}
|
193 |
|
194 |
+
/**
|
195 |
+
* @param string[] $names
|
196 |
+
*
|
197 |
+
* @return string|false
|
198 |
+
*/
|
199 |
private function close(array &$names)
|
200 |
{
|
201 |
if(!$this->match(self::TOKEN_OPEN, true)) { return false; }
|
206 |
return \in_array($closingName, $names, true) ? $closingName : false;
|
207 |
}
|
208 |
|
209 |
+
/** @psalm-return array<string,string|null>|false */
|
210 |
private function parameters()
|
211 |
{
|
212 |
$parameters = array();
|
225 |
return $parameters;
|
226 |
}
|
227 |
|
228 |
+
/** @return false|string */
|
229 |
private function value()
|
230 |
{
|
231 |
$value = '';
|
252 |
|
253 |
/* --- PARSER ---------------------------------------------------------- */
|
254 |
|
255 |
+
/** @return void */
|
256 |
private function beginBacktrack()
|
257 |
{
|
258 |
$this->backtracks[] = $this->position;
|
259 |
$this->lastBacktrack = $this->position;
|
260 |
}
|
261 |
|
262 |
+
/** @return string */
|
263 |
private function getBacktrack()
|
264 |
{
|
265 |
$position = array_pop($this->backtracks);
|
271 |
return $backtrack;
|
272 |
}
|
273 |
|
274 |
+
/**
|
275 |
+
* @param bool $modifyPosition
|
276 |
+
*
|
277 |
+
* @return string
|
278 |
+
*/
|
279 |
private function backtrack($modifyPosition = true)
|
280 |
{
|
281 |
$position = array_pop($this->backtracks);
|
292 |
return $backtrack;
|
293 |
}
|
294 |
|
295 |
+
/**
|
296 |
+
* @param int $type
|
297 |
+
*
|
298 |
+
* @return bool
|
299 |
+
*/
|
300 |
private function lookahead($type)
|
301 |
{
|
302 |
return $this->position < $this->tokensCount && $this->tokens[$this->position][0] === $type;
|
303 |
}
|
304 |
|
305 |
+
/**
|
306 |
+
* @param int|null $type
|
307 |
+
* @param bool $ws
|
308 |
+
*
|
309 |
+
* @return string
|
310 |
+
*/
|
311 |
private function match($type, $ws)
|
312 |
{
|
313 |
if($this->position >= $this->tokensCount) {
|
329 |
|
330 |
/* --- LEXER ----------------------------------------------------------- */
|
331 |
|
332 |
+
/**
|
333 |
+
* @param string $text
|
334 |
+
*
|
335 |
+
* @psalm-return list<array{0:int,1:string,2:int}>
|
336 |
+
*/
|
337 |
private function tokenize($text)
|
338 |
{
|
339 |
$count = preg_match_all($this->lexerRegex, $text, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
|
362 |
return $tokens;
|
363 |
}
|
364 |
|
365 |
+
/** @return string */
|
366 |
private function prepareLexer(SyntaxInterface $syntax)
|
367 |
{
|
368 |
+
// FIXME: for some reason Psalm does not understand the `@psalm-var callable() $var` annotation
|
369 |
+
/** @psalm-suppress MissingClosureParamType, MissingClosureReturnType */
|
370 |
$group = function($text, $group) {
|
371 |
+
return '(?<'.(string)$group.'>'.preg_replace('/(.)/us', '\\\\$0', (string)$text).')';
|
372 |
};
|
373 |
+
/** @psalm-suppress MissingClosureParamType, MissingClosureReturnType */
|
374 |
$quote = function($text) {
|
375 |
+
return preg_replace('/(.)/us', '\\\\$0', (string)$text);
|
376 |
};
|
377 |
|
378 |
$rules = array(
|
vendor/thunderer/shortcode/src/Parser/WordpressParser.php
CHANGED
@@ -26,21 +26,33 @@ use Thunder\Shortcode\Utility\RegexBuilderUtility;
|
|
26 |
*/
|
27 |
final class WordpressParser implements ParserInterface
|
28 |
{
|
|
|
29 |
private static $shortcodeRegex = '/\\[(\\[?)(<NAMES>)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)/s';
|
|
|
30 |
private static $argumentsRegex = '/([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*\'([^\']*)\'(?:\s|$)|([\w-]+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
|
31 |
|
32 |
-
|
|
|
33 |
|
34 |
-
|
|
|
|
|
35 |
|
|
|
36 |
public static function createFromHandlers(HandlerContainer $handlers)
|
37 |
{
|
38 |
return static::createFromNames($handlers->getNames());
|
39 |
}
|
40 |
|
|
|
|
|
|
|
|
|
|
|
41 |
public static function createFromNames(array $names)
|
42 |
{
|
43 |
foreach($names as $name) {
|
|
|
44 |
if(false === is_string($name)) {
|
45 |
throw new \InvalidArgumentException('Shortcode name must be a string!');
|
46 |
}
|
@@ -60,7 +72,7 @@ final class WordpressParser implements ParserInterface
|
|
60 |
public function parse($text)
|
61 |
{
|
62 |
$names = $this->names
|
63 |
-
? implode('|', array_map(
|
64 |
: RegexBuilderUtility::buildNameRegex();
|
65 |
$regex = str_replace('<NAMES>', $names, static::$shortcodeRegex);
|
66 |
preg_match_all($regex, $text, $matches, PREG_OFFSET_CAPTURE);
|
@@ -81,6 +93,11 @@ final class WordpressParser implements ParserInterface
|
|
81 |
return $shortcodes;
|
82 |
}
|
83 |
|
|
|
|
|
|
|
|
|
|
|
84 |
private static function parseParameters($text)
|
85 |
{
|
86 |
$text = preg_replace('/[\x{00a0}\x{200b}]+/u', ' ', $text);
|
@@ -105,6 +122,8 @@ final class WordpressParser implements ParserInterface
|
|
105 |
}
|
106 |
|
107 |
foreach($parameters as $key => $value) {
|
|
|
|
|
108 |
if(false !== strpos($value, '<') && 1 !== preg_match('/^[^<]*+(?:<[^>]*+>[^<]*+)*+$/', $value)) {
|
109 |
$parameters[$key] = '';
|
110 |
}
|
26 |
*/
|
27 |
final class WordpressParser implements ParserInterface
|
28 |
{
|
29 |
+
/** @var string */
|
30 |
private static $shortcodeRegex = '/\\[(\\[?)(<NAMES>)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)/s';
|
31 |
+
/** @var string */
|
32 |
private static $argumentsRegex = '/([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*\'([^\']*)\'(?:\s|$)|([\w-]+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
|
33 |
|
34 |
+
/** @var string[] */
|
35 |
+
private $names = array();
|
36 |
|
37 |
+
public function __construct()
|
38 |
+
{
|
39 |
+
}
|
40 |
|
41 |
+
/** @return self */
|
42 |
public static function createFromHandlers(HandlerContainer $handlers)
|
43 |
{
|
44 |
return static::createFromNames($handlers->getNames());
|
45 |
}
|
46 |
|
47 |
+
/**
|
48 |
+
* @param string[] $names
|
49 |
+
*
|
50 |
+
* @return self
|
51 |
+
*/
|
52 |
public static function createFromNames(array $names)
|
53 |
{
|
54 |
foreach($names as $name) {
|
55 |
+
/** @psalm-suppress DocblockTypeContradiction, RedundantConditionGivenDocblockType */
|
56 |
if(false === is_string($name)) {
|
57 |
throw new \InvalidArgumentException('Shortcode name must be a string!');
|
58 |
}
|
72 |
public function parse($text)
|
73 |
{
|
74 |
$names = $this->names
|
75 |
+
? implode('|', array_map(function($name) { return preg_quote($name, '/'); }, $this->names))
|
76 |
: RegexBuilderUtility::buildNameRegex();
|
77 |
$regex = str_replace('<NAMES>', $names, static::$shortcodeRegex);
|
78 |
preg_match_all($regex, $text, $matches, PREG_OFFSET_CAPTURE);
|
93 |
return $shortcodes;
|
94 |
}
|
95 |
|
96 |
+
/**
|
97 |
+
* @param string $text
|
98 |
+
*
|
99 |
+
* @psalm-return array<string,string|null>
|
100 |
+
*/
|
101 |
private static function parseParameters($text)
|
102 |
{
|
103 |
$text = preg_replace('/[\x{00a0}\x{200b}]+/u', ' ', $text);
|
122 |
}
|
123 |
|
124 |
foreach($parameters as $key => $value) {
|
125 |
+
// NOTE: the `?: ''` fallback is the only change from the way WordPress parses shortcodes to satisfy Psalm's PossiblyNullArgument
|
126 |
+
$value = $value ?: '';
|
127 |
if(false !== strpos($value, '<') && 1 !== preg_match('/^[^<]*+(?:<[^>]*+>[^<]*+)*+$/', $value)) {
|
128 |
$parameters[$key] = '';
|
129 |
}
|
vendor/thunderer/shortcode/src/Processor/Processor.php
CHANGED
@@ -10,6 +10,7 @@ use Thunder\Shortcode\Parser\ParserInterface;
|
|
10 |
use Thunder\Shortcode\Shortcode\ReplacedShortcode;
|
11 |
use Thunder\Shortcode\Shortcode\ParsedShortcodeInterface;
|
12 |
use Thunder\Shortcode\Shortcode\ProcessedShortcode;
|
|
|
13 |
|
14 |
/**
|
15 |
* @author Tomasz Kowalczyk <tomasz@kowalczyk.cc>
|
@@ -20,12 +21,14 @@ final class Processor implements ProcessorInterface
|
|
20 |
private $handlers;
|
21 |
/** @var ParserInterface */
|
22 |
private $parser;
|
23 |
-
/** @var EventContainerInterface */
|
24 |
private $eventContainer;
|
25 |
|
26 |
/** @var int|null */
|
27 |
private $recursionDepth; // infinite recursion
|
|
|
28 |
private $maxIterations = 1; // one iteration
|
|
|
29 |
private $autoProcessContent = true; // automatically process shortcode content
|
30 |
|
31 |
public function __construct(ParserInterface $parser, Handlers $handlers)
|
@@ -61,6 +64,12 @@ final class Processor implements ProcessorInterface
|
|
61 |
return $text;
|
62 |
}
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
private function dispatchEvent($name, $event)
|
65 |
{
|
66 |
if(null === $this->eventContainer) {
|
@@ -75,6 +84,11 @@ final class Processor implements ProcessorInterface
|
|
75 |
return $event;
|
76 |
}
|
77 |
|
|
|
|
|
|
|
|
|
|
|
78 |
private function processIteration($text, ProcessorContext $context, ProcessedShortcode $parent = null)
|
79 |
{
|
80 |
if (null !== $this->recursionDepth && $context->recursionLevel > $this->recursionDepth) {
|
@@ -88,7 +102,7 @@ final class Processor implements ProcessorInterface
|
|
88 |
$shortcodes = $filterEvent->getShortcodes();
|
89 |
$replaces = array();
|
90 |
$baseOffset = $parent && $shortcodes
|
91 |
-
? mb_strpos($parent->getShortcodeText(), $shortcodes[0]->getText(),
|
92 |
: 0;
|
93 |
foreach ($shortcodes as $shortcode) {
|
94 |
$name = $shortcode->getName();
|
@@ -100,7 +114,7 @@ final class Processor implements ProcessorInterface
|
|
100 |
$context->shortcodeText = $shortcode->getText();
|
101 |
$context->offset = $shortcode->getOffset();
|
102 |
$context->shortcode = $shortcode;
|
103 |
-
$context->textContent = $shortcode->getContent();
|
104 |
|
105 |
$handler = $this->handlers->get($name);
|
106 |
$replace = $this->processHandler($shortcode, $context, $handler);
|
@@ -111,12 +125,17 @@ final class Processor implements ProcessorInterface
|
|
111 |
$applyEvent = new ReplaceShortcodesEvent($text, $replaces, $parent);
|
112 |
$this->dispatchEvent(Events::REPLACE_SHORTCODES, $applyEvent);
|
113 |
|
114 |
-
return $applyEvent->hasResult() ? $applyEvent->getResult() : $this->applyReplaces($text, $replaces);
|
115 |
}
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
private function applyReplaces($text, array $replaces)
|
118 |
{
|
119 |
-
/** @var ReplacedShortcode $s */
|
120 |
foreach(array_reverse($replaces) as $s) {
|
121 |
$offset = $s->getOffset();
|
122 |
$length = mb_strlen($s->getText(), 'utf-8');
|
@@ -128,6 +147,10 @@ final class Processor implements ProcessorInterface
|
|
128 |
return $text;
|
129 |
}
|
130 |
|
|
|
|
|
|
|
|
|
131 |
private function processHandler(ParsedShortcodeInterface $parsed, ProcessorContext $context, $handler)
|
132 |
{
|
133 |
$processed = ProcessedShortcode::createFromContext(clone $context);
|
@@ -139,24 +162,27 @@ final class Processor implements ProcessorInterface
|
|
139 |
}
|
140 |
|
141 |
$state = $parsed->getText();
|
142 |
-
|
143 |
-
$
|
|
|
144 |
|
145 |
-
return mb_substr($state, 0, $offset, 'utf-8')
|
146 |
}
|
147 |
|
|
|
148 |
private function processRecursion(ProcessedShortcode $shortcode, ProcessorContext $context)
|
149 |
{
|
150 |
-
|
|
|
151 |
$context->recursionLevel++;
|
152 |
// this is safe from using max iterations value because it's manipulated in process() method
|
153 |
-
$content = $this->processIteration($
|
154 |
$context->recursionLevel--;
|
155 |
|
156 |
return $content;
|
157 |
}
|
158 |
|
159 |
-
return $
|
160 |
}
|
161 |
|
162 |
/**
|
@@ -185,6 +211,7 @@ final class Processor implements ProcessorInterface
|
|
185 |
*/
|
186 |
public function withRecursionDepth($depth)
|
187 |
{
|
|
|
188 |
if (null !== $depth && !(is_int($depth) && $depth >= 0)) {
|
189 |
$msg = 'Recursion depth must be null (infinite) or integer >= 0!';
|
190 |
throw new \InvalidArgumentException($msg);
|
@@ -208,6 +235,7 @@ final class Processor implements ProcessorInterface
|
|
208 |
*/
|
209 |
public function withMaxIterations($iterations)
|
210 |
{
|
|
|
211 |
if (null !== $iterations && !(is_int($iterations) && $iterations > 0)) {
|
212 |
$msg = 'Maximum number of iterations must be null (infinite) or integer > 0!';
|
213 |
throw new \InvalidArgumentException($msg);
|
@@ -230,13 +258,14 @@ final class Processor implements ProcessorInterface
|
|
230 |
*/
|
231 |
public function withAutoProcessContent($flag)
|
232 |
{
|
|
|
233 |
if (!is_bool($flag)) {
|
234 |
$msg = 'Auto processing flag must be a boolean value!';
|
235 |
throw new \InvalidArgumentException($msg);
|
236 |
}
|
237 |
|
238 |
$self = clone $this;
|
239 |
-
$self->autoProcessContent =
|
240 |
|
241 |
return $self;
|
242 |
}
|
10 |
use Thunder\Shortcode\Shortcode\ReplacedShortcode;
|
11 |
use Thunder\Shortcode\Shortcode\ParsedShortcodeInterface;
|
12 |
use Thunder\Shortcode\Shortcode\ProcessedShortcode;
|
13 |
+
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
14 |
|
15 |
/**
|
16 |
* @author Tomasz Kowalczyk <tomasz@kowalczyk.cc>
|
21 |
private $handlers;
|
22 |
/** @var ParserInterface */
|
23 |
private $parser;
|
24 |
+
/** @var EventContainerInterface|null */
|
25 |
private $eventContainer;
|
26 |
|
27 |
/** @var int|null */
|
28 |
private $recursionDepth; // infinite recursion
|
29 |
+
/** @var int|null */
|
30 |
private $maxIterations = 1; // one iteration
|
31 |
+
/** @var bool */
|
32 |
private $autoProcessContent = true; // automatically process shortcode content
|
33 |
|
34 |
public function __construct(ParserInterface $parser, Handlers $handlers)
|
64 |
return $text;
|
65 |
}
|
66 |
|
67 |
+
/**
|
68 |
+
* @param string $name
|
69 |
+
* @param object $event
|
70 |
+
*
|
71 |
+
* @return object
|
72 |
+
*/
|
73 |
private function dispatchEvent($name, $event)
|
74 |
{
|
75 |
if(null === $this->eventContainer) {
|
84 |
return $event;
|
85 |
}
|
86 |
|
87 |
+
/**
|
88 |
+
* @param string $text
|
89 |
+
*
|
90 |
+
* @return string
|
91 |
+
*/
|
92 |
private function processIteration($text, ProcessorContext $context, ProcessedShortcode $parent = null)
|
93 |
{
|
94 |
if (null !== $this->recursionDepth && $context->recursionLevel > $this->recursionDepth) {
|
102 |
$shortcodes = $filterEvent->getShortcodes();
|
103 |
$replaces = array();
|
104 |
$baseOffset = $parent && $shortcodes
|
105 |
+
? (int)mb_strpos($parent->getShortcodeText(), $shortcodes[0]->getText(), 0, 'utf-8') - $shortcodes[0]->getOffset() + $parent->getOffset()
|
106 |
: 0;
|
107 |
foreach ($shortcodes as $shortcode) {
|
108 |
$name = $shortcode->getName();
|
114 |
$context->shortcodeText = $shortcode->getText();
|
115 |
$context->offset = $shortcode->getOffset();
|
116 |
$context->shortcode = $shortcode;
|
117 |
+
$context->textContent = (string)$shortcode->getContent();
|
118 |
|
119 |
$handler = $this->handlers->get($name);
|
120 |
$replace = $this->processHandler($shortcode, $context, $handler);
|
125 |
$applyEvent = new ReplaceShortcodesEvent($text, $replaces, $parent);
|
126 |
$this->dispatchEvent(Events::REPLACE_SHORTCODES, $applyEvent);
|
127 |
|
128 |
+
return $applyEvent->hasResult() ? (string)$applyEvent->getResult() : $this->applyReplaces($text, $replaces);
|
129 |
}
|
130 |
|
131 |
+
/**
|
132 |
+
* @param string $text
|
133 |
+
* @param ReplacedShortcode[] $replaces
|
134 |
+
*
|
135 |
+
* @return string
|
136 |
+
*/
|
137 |
private function applyReplaces($text, array $replaces)
|
138 |
{
|
|
|
139 |
foreach(array_reverse($replaces) as $s) {
|
140 |
$offset = $s->getOffset();
|
141 |
$length = mb_strlen($s->getText(), 'utf-8');
|
147 |
return $text;
|
148 |
}
|
149 |
|
150 |
+
/**
|
151 |
+
* @psalm-param (callable(ShortcodeInterface):string)|null $handler
|
152 |
+
* @return string
|
153 |
+
*/
|
154 |
private function processHandler(ParsedShortcodeInterface $parsed, ProcessorContext $context, $handler)
|
155 |
{
|
156 |
$processed = ProcessedShortcode::createFromContext(clone $context);
|
162 |
}
|
163 |
|
164 |
$state = $parsed->getText();
|
165 |
+
/** @psalm-suppress RedundantCast */
|
166 |
+
$length = (int)mb_strlen($processed->getTextContent(), 'utf-8');
|
167 |
+
$offset = (int)mb_strrpos($state, $processed->getTextContent(), 0, 'utf-8');
|
168 |
|
169 |
+
return mb_substr($state, 0, $offset, 'utf-8').(string)$processed->getContent().mb_substr($state, $offset + $length, mb_strlen($state, 'utf-8'), 'utf-8');
|
170 |
}
|
171 |
|
172 |
+
/** @return string|null */
|
173 |
private function processRecursion(ProcessedShortcode $shortcode, ProcessorContext $context)
|
174 |
{
|
175 |
+
$content = $shortcode->getContent();
|
176 |
+
if ($this->autoProcessContent && null !== $content) {
|
177 |
$context->recursionLevel++;
|
178 |
// this is safe from using max iterations value because it's manipulated in process() method
|
179 |
+
$content = $this->processIteration($content, clone $context, $shortcode);
|
180 |
$context->recursionLevel--;
|
181 |
|
182 |
return $content;
|
183 |
}
|
184 |
|
185 |
+
return $content;
|
186 |
}
|
187 |
|
188 |
/**
|
211 |
*/
|
212 |
public function withRecursionDepth($depth)
|
213 |
{
|
214 |
+
/** @psalm-suppress DocblockTypeContradiction */
|
215 |
if (null !== $depth && !(is_int($depth) && $depth >= 0)) {
|
216 |
$msg = 'Recursion depth must be null (infinite) or integer >= 0!';
|
217 |
throw new \InvalidArgumentException($msg);
|
235 |
*/
|
236 |
public function withMaxIterations($iterations)
|
237 |
{
|
238 |
+
/** @psalm-suppress DocblockTypeContradiction */
|
239 |
if (null !== $iterations && !(is_int($iterations) && $iterations > 0)) {
|
240 |
$msg = 'Maximum number of iterations must be null (infinite) or integer > 0!';
|
241 |
throw new \InvalidArgumentException($msg);
|
258 |
*/
|
259 |
public function withAutoProcessContent($flag)
|
260 |
{
|
261 |
+
/** @psalm-suppress DocblockTypeContradiction */
|
262 |
if (!is_bool($flag)) {
|
263 |
$msg = 'Auto processing flag must be a boolean value!';
|
264 |
throw new \InvalidArgumentException($msg);
|
265 |
}
|
266 |
|
267 |
$self = clone $this;
|
268 |
+
$self->autoProcessContent = $flag;
|
269 |
|
270 |
return $self;
|
271 |
}
|
vendor/thunderer/shortcode/src/Processor/ProcessorContext.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
2 |
namespace Thunder\Shortcode\Processor;
|
3 |
|
|
|
4 |
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
5 |
|
6 |
/**
|
@@ -8,22 +9,50 @@ use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
|
8 |
*/
|
9 |
final class ProcessorContext
|
10 |
{
|
11 |
-
/**
|
|
|
|
|
|
|
12 |
public $shortcode;
|
13 |
|
14 |
-
/** @var
|
15 |
-
public $parent;
|
16 |
|
17 |
-
/**
|
|
|
|
|
|
|
18 |
public $processor;
|
19 |
|
|
|
|
|
|
|
|
|
20 |
public $textContent;
|
|
|
21 |
public $position = 0;
|
|
|
22 |
public $namePosition = array();
|
|
|
23 |
public $text = '';
|
|
|
24 |
public $shortcodeText = '';
|
|
|
25 |
public $iterationNumber = 0;
|
|
|
26 |
public $recursionLevel = 0;
|
|
|
|
|
|
|
|
|
27 |
public $offset;
|
|
|
|
|
|
|
|
|
28 |
public $baseOffset;
|
|
|
|
|
|
|
|
|
29 |
}
|
1 |
<?php
|
2 |
namespace Thunder\Shortcode\Processor;
|
3 |
|
4 |
+
use Thunder\Shortcode\Shortcode\ProcessedShortcode;
|
5 |
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
6 |
|
7 |
/**
|
9 |
*/
|
10 |
final class ProcessorContext
|
11 |
{
|
12 |
+
/**
|
13 |
+
* @var ShortcodeInterface
|
14 |
+
* @psalm-suppress PropertyNotSetInConstructor
|
15 |
+
*/
|
16 |
public $shortcode;
|
17 |
|
18 |
+
/** @var ProcessedShortcode|null */
|
19 |
+
public $parent = null;
|
20 |
|
21 |
+
/**
|
22 |
+
* @var ProcessorInterface
|
23 |
+
* @psalm-suppress PropertyNotSetInConstructor
|
24 |
+
*/
|
25 |
public $processor;
|
26 |
|
27 |
+
/**
|
28 |
+
* @var string
|
29 |
+
* @psalm-suppress PropertyNotSetInConstructor
|
30 |
+
*/
|
31 |
public $textContent;
|
32 |
+
/** @var int */
|
33 |
public $position = 0;
|
34 |
+
/** @psalm-var array<string,int> */
|
35 |
public $namePosition = array();
|
36 |
+
/** @var string */
|
37 |
public $text = '';
|
38 |
+
/** @var string */
|
39 |
public $shortcodeText = '';
|
40 |
+
/** @var int */
|
41 |
public $iterationNumber = 0;
|
42 |
+
/** @var int */
|
43 |
public $recursionLevel = 0;
|
44 |
+
/**
|
45 |
+
* @var int
|
46 |
+
* @psalm-suppress PropertyNotSetInConstructor
|
47 |
+
*/
|
48 |
public $offset;
|
49 |
+
/**
|
50 |
+
* @var int
|
51 |
+
* @psalm-suppress PropertyNotSetInConstructor
|
52 |
+
*/
|
53 |
public $baseOffset;
|
54 |
+
|
55 |
+
public function __construct()
|
56 |
+
{
|
57 |
+
}
|
58 |
}
|
vendor/thunderer/shortcode/src/Serializer/JsonSerializer.php
CHANGED
@@ -26,6 +26,7 @@ final class JsonSerializer implements SerializerInterface
|
|
26 |
*/
|
27 |
public function unserialize($text)
|
28 |
{
|
|
|
29 |
$data = json_decode($text, true);
|
30 |
|
31 |
if (!is_array($data)) {
|
@@ -35,11 +36,13 @@ final class JsonSerializer implements SerializerInterface
|
|
35 |
throw new \InvalidArgumentException('Malformed Shortcode JSON, expected name, parameters, and content!');
|
36 |
}
|
37 |
|
|
|
38 |
$name = array_key_exists('name', $data) ? $data['name'] : null;
|
39 |
$parameters = array_key_exists('parameters', $data) ? $data['parameters'] : array();
|
40 |
$content = array_key_exists('content', $data) ? $data['content'] : null;
|
41 |
$bbCode = array_key_exists('bbCode', $data) ? $data['bbCode'] : null;
|
42 |
|
|
|
43 |
if(!is_array($parameters)) {
|
44 |
throw new \InvalidArgumentException('Parameters must be an array!');
|
45 |
}
|
26 |
*/
|
27 |
public function unserialize($text)
|
28 |
{
|
29 |
+
/** @psalm-var array{name:string,parameters:array<string,string|null>,bbCode:string|null,content:string|null}|null $data */
|
30 |
$data = json_decode($text, true);
|
31 |
|
32 |
if (!is_array($data)) {
|
36 |
throw new \InvalidArgumentException('Malformed Shortcode JSON, expected name, parameters, and content!');
|
37 |
}
|
38 |
|
39 |
+
/** @var string $name */
|
40 |
$name = array_key_exists('name', $data) ? $data['name'] : null;
|
41 |
$parameters = array_key_exists('parameters', $data) ? $data['parameters'] : array();
|
42 |
$content = array_key_exists('content', $data) ? $data['content'] : null;
|
43 |
$bbCode = array_key_exists('bbCode', $data) ? $data['bbCode'] : null;
|
44 |
|
45 |
+
/** @psalm-suppress DocblockTypeContradiction */
|
46 |
if(!is_array($parameters)) {
|
47 |
throw new \InvalidArgumentException('Parameters must be an array!');
|
48 |
}
|
vendor/thunderer/shortcode/src/Serializer/SerializerInterface.php
CHANGED
@@ -20,7 +20,7 @@ interface SerializerInterface
|
|
20 |
/**
|
21 |
* Loads back Shortcode instance from serialized format
|
22 |
*
|
23 |
-
* @param $text
|
24 |
*
|
25 |
* @return ShortcodeInterface
|
26 |
*/
|
20 |
/**
|
21 |
* Loads back Shortcode instance from serialized format
|
22 |
*
|
23 |
+
* @param string $text
|
24 |
*
|
25 |
* @return ShortcodeInterface
|
26 |
*/
|
vendor/thunderer/shortcode/src/Serializer/TextSerializer.php
CHANGED
@@ -12,6 +12,7 @@ use Thunder\Shortcode\Syntax\SyntaxInterface;
|
|
12 |
*/
|
13 |
final class TextSerializer implements SerializerInterface
|
14 |
{
|
|
|
15 |
private $syntax;
|
16 |
|
17 |
public function __construct(SyntaxInterface $syntax = null)
|
@@ -19,6 +20,7 @@ final class TextSerializer implements SerializerInterface
|
|
19 |
$this->syntax = $syntax ?: new Syntax();
|
20 |
}
|
21 |
|
|
|
22 |
public function serialize(ShortcodeInterface $shortcode)
|
23 |
{
|
24 |
$open = $this->syntax->getOpeningTag();
|
@@ -33,9 +35,14 @@ final class TextSerializer implements SerializerInterface
|
|
33 |
|
34 |
return null === $shortcode->getContent()
|
35 |
? $return.' '.$marker.$close
|
36 |
-
: $return.$close
|
37 |
}
|
38 |
|
|
|
|
|
|
|
|
|
|
|
39 |
private function serializeParameters(array $parameters)
|
40 |
{
|
41 |
// unfortunately array_reduce() does not support keys
|
@@ -47,6 +54,11 @@ final class TextSerializer implements SerializerInterface
|
|
47 |
return $return;
|
48 |
}
|
49 |
|
|
|
|
|
|
|
|
|
|
|
50 |
private function serializeValue($value)
|
51 |
{
|
52 |
if (null === $value) {
|
@@ -76,7 +88,7 @@ final class TextSerializer implements SerializerInterface
|
|
76 |
throw new \InvalidArgumentException(sprintf($msg, $text));
|
77 |
}
|
78 |
|
79 |
-
/** @var $parsed
|
80 |
$parsed = array_shift($shortcodes);
|
81 |
|
82 |
$name = $parsed->getName();
|
12 |
*/
|
13 |
final class TextSerializer implements SerializerInterface
|
14 |
{
|
15 |
+
/** @var SyntaxInterface */
|
16 |
private $syntax;
|
17 |
|
18 |
public function __construct(SyntaxInterface $syntax = null)
|
20 |
$this->syntax = $syntax ?: new Syntax();
|
21 |
}
|
22 |
|
23 |
+
/** @inheritDoc */
|
24 |
public function serialize(ShortcodeInterface $shortcode)
|
25 |
{
|
26 |
$open = $this->syntax->getOpeningTag();
|
35 |
|
36 |
return null === $shortcode->getContent()
|
37 |
? $return.' '.$marker.$close
|
38 |
+
: $return.$close.(string)$shortcode->getContent().$open.$marker.$shortcode->getName().$close;
|
39 |
}
|
40 |
|
41 |
+
/**
|
42 |
+
* @psalm-param array<string,string|null> $parameters
|
43 |
+
*
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
private function serializeParameters(array $parameters)
|
47 |
{
|
48 |
// unfortunately array_reduce() does not support keys
|
54 |
return $return;
|
55 |
}
|
56 |
|
57 |
+
/**
|
58 |
+
* @param string|null $value
|
59 |
+
*
|
60 |
+
* @return string
|
61 |
+
*/
|
62 |
private function serializeValue($value)
|
63 |
{
|
64 |
if (null === $value) {
|
88 |
throw new \InvalidArgumentException(sprintf($msg, $text));
|
89 |
}
|
90 |
|
91 |
+
/** @var ShortcodeInterface $parsed */
|
92 |
$parsed = array_shift($shortcodes);
|
93 |
|
94 |
$name = $parsed->getName();
|
vendor/thunderer/shortcode/src/Serializer/XmlSerializer.php
CHANGED
@@ -50,6 +50,13 @@ final class XmlSerializer implements SerializerInterface
|
|
50 |
return $doc->saveXML();
|
51 |
}
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
private function createCDataNode(\DOMDocument $doc, $name, $content)
|
54 |
{
|
55 |
$node = $doc->createElement($name);
|
@@ -70,7 +77,7 @@ final class XmlSerializer implements SerializerInterface
|
|
70 |
{
|
71 |
$xml = new \DOMDocument();
|
72 |
$internalErrors = libxml_use_internal_errors(true);
|
73 |
-
if(!$text ||
|
74 |
libxml_use_internal_errors($internalErrors);
|
75 |
throw new \InvalidArgumentException('Failed to parse provided XML!');
|
76 |
}
|
@@ -97,6 +104,11 @@ final class XmlSerializer implements SerializerInterface
|
|
97 |
return new Shortcode($name, $parameters, $content, $bbCode);
|
98 |
}
|
99 |
|
|
|
|
|
|
|
|
|
|
|
100 |
private function getValue(\DOMNodeList $node)
|
101 |
{
|
102 |
return $node->length === 1 && $node->item(0)->hasChildNodes()
|
@@ -104,11 +116,23 @@ final class XmlSerializer implements SerializerInterface
|
|
104 |
: null;
|
105 |
}
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
private function getAttribute(\DOMNode $node, $name)
|
108 |
{
|
|
|
|
|
|
|
|
|
109 |
$attribute = $node->attributes->getNamedItem($name);
|
110 |
|
111 |
-
|
|
|
112 |
throw new \InvalidArgumentException('Invalid shortcode XML!');
|
113 |
}
|
114 |
|
50 |
return $doc->saveXML();
|
51 |
}
|
52 |
|
53 |
+
/**
|
54 |
+
* @param \DOMDocument $doc
|
55 |
+
* @param string $name
|
56 |
+
* @param string|null $content
|
57 |
+
*
|
58 |
+
* @return \DOMElement
|
59 |
+
*/
|
60 |
private function createCDataNode(\DOMDocument $doc, $name, $content)
|
61 |
{
|
62 |
$node = $doc->createElement($name);
|
77 |
{
|
78 |
$xml = new \DOMDocument();
|
79 |
$internalErrors = libxml_use_internal_errors(true);
|
80 |
+
if(!$text || !$xml->loadXML($text)) {
|
81 |
libxml_use_internal_errors($internalErrors);
|
82 |
throw new \InvalidArgumentException('Failed to parse provided XML!');
|
83 |
}
|
104 |
return new Shortcode($name, $parameters, $content, $bbCode);
|
105 |
}
|
106 |
|
107 |
+
/**
|
108 |
+
* @param \DOMNodeList $node
|
109 |
+
*
|
110 |
+
* @return string|null
|
111 |
+
*/
|
112 |
private function getValue(\DOMNodeList $node)
|
113 |
{
|
114 |
return $node->length === 1 && $node->item(0)->hasChildNodes()
|
116 |
: null;
|
117 |
}
|
118 |
|
119 |
+
/**
|
120 |
+
* @param \DOMNode $node
|
121 |
+
* @param string $name
|
122 |
+
* @psalm-suppress UnusedParam
|
123 |
+
*
|
124 |
+
* @return string
|
125 |
+
*/
|
126 |
private function getAttribute(\DOMNode $node, $name)
|
127 |
{
|
128 |
+
/**
|
129 |
+
* @var \DOMNode $attribute
|
130 |
+
* @psalm-suppress NullReference
|
131 |
+
*/
|
132 |
$attribute = $node->attributes->getNamedItem($name);
|
133 |
|
134 |
+
/** @psalm-suppress DocblockTypeContradiction */
|
135 |
+
if(!$attribute || !$attribute->nodeValue) {
|
136 |
throw new \InvalidArgumentException('Invalid shortcode XML!');
|
137 |
}
|
138 |
|
vendor/thunderer/shortcode/src/Serializer/YamlSerializer.php
CHANGED
@@ -27,20 +27,23 @@ final class YamlSerializer implements SerializerInterface
|
|
27 |
*/
|
28 |
public function unserialize($text)
|
29 |
{
|
|
|
30 |
$data = Yaml::parse($text);
|
31 |
|
32 |
-
if(
|
33 |
throw new \InvalidArgumentException('Invalid YAML, cannot unserialize Shortcode!');
|
34 |
}
|
35 |
if (!array_intersect(array_keys($data), array('name', 'parameters', 'content'))) {
|
36 |
throw new \InvalidArgumentException('Malformed shortcode YAML, expected name, parameters, and content!');
|
37 |
}
|
38 |
|
|
|
39 |
$name = array_key_exists('name', $data) ? $data['name'] : null;
|
40 |
$parameters = array_key_exists('parameters', $data) ? $data['parameters'] : array();
|
41 |
$content = array_key_exists('content', $data) ? $data['content'] : null;
|
42 |
$bbCode = array_key_exists('bbCode', $data) ? $data['bbCode'] : null;
|
43 |
|
|
|
44 |
if(!is_array($parameters)) {
|
45 |
throw new \InvalidArgumentException('Parameters must be an array!');
|
46 |
}
|
27 |
*/
|
28 |
public function unserialize($text)
|
29 |
{
|
30 |
+
/** @psalm-var array{name:string,parameters:array<string,string|null>,bbCode:string|null,content:string|null}|null $data */
|
31 |
$data = Yaml::parse($text);
|
32 |
|
33 |
+
if(!is_array($data)) {
|
34 |
throw new \InvalidArgumentException('Invalid YAML, cannot unserialize Shortcode!');
|
35 |
}
|
36 |
if (!array_intersect(array_keys($data), array('name', 'parameters', 'content'))) {
|
37 |
throw new \InvalidArgumentException('Malformed shortcode YAML, expected name, parameters, and content!');
|
38 |
}
|
39 |
|
40 |
+
/** @var string $name */
|
41 |
$name = array_key_exists('name', $data) ? $data['name'] : null;
|
42 |
$parameters = array_key_exists('parameters', $data) ? $data['parameters'] : array();
|
43 |
$content = array_key_exists('content', $data) ? $data['content'] : null;
|
44 |
$bbCode = array_key_exists('bbCode', $data) ? $data['bbCode'] : null;
|
45 |
|
46 |
+
/** @psalm-suppress DocblockTypeContradiction */
|
47 |
if(!is_array($parameters)) {
|
48 |
throw new \InvalidArgumentException('Parameters must be an array!');
|
49 |
}
|
vendor/thunderer/shortcode/src/Shortcode/AbstractShortcode.php
CHANGED
@@ -6,41 +6,65 @@ namespace Thunder\Shortcode\Shortcode;
|
|
6 |
*/
|
7 |
abstract class AbstractShortcode
|
8 |
{
|
|
|
9 |
protected $name;
|
|
|
10 |
protected $parameters = array();
|
|
|
11 |
protected $content;
|
|
|
12 |
protected $bbCode;
|
13 |
|
|
|
14 |
public function hasContent()
|
15 |
{
|
16 |
return $this->content !== null;
|
17 |
}
|
18 |
|
|
|
19 |
public function getName()
|
20 |
{
|
21 |
return $this->name;
|
22 |
}
|
23 |
|
|
|
24 |
public function getParameters()
|
25 |
{
|
26 |
return $this->parameters;
|
27 |
}
|
28 |
|
|
|
|
|
|
|
|
|
|
|
29 |
public function hasParameter($name)
|
30 |
{
|
31 |
return array_key_exists($name, $this->parameters);
|
32 |
}
|
33 |
|
|
|
34 |
public function hasParameters()
|
35 |
{
|
36 |
return (bool)$this->parameters;
|
37 |
}
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
public function getParameter($name, $default = null)
|
40 |
{
|
41 |
return $this->hasParameter($name) ? $this->parameters[$name] : $default;
|
42 |
}
|
43 |
|
|
|
|
|
|
|
|
|
|
|
44 |
public function getParameterAt($index)
|
45 |
{
|
46 |
$keys = array_keys($this->parameters);
|
@@ -48,11 +72,13 @@ abstract class AbstractShortcode
|
|
48 |
return array_key_exists($index, $keys) ? $keys[$index] : null;
|
49 |
}
|
50 |
|
|
|
51 |
public function getContent()
|
52 |
{
|
53 |
return $this->content;
|
54 |
}
|
55 |
|
|
|
56 |
public function getBbCode()
|
57 |
{
|
58 |
return $this->bbCode;
|
6 |
*/
|
7 |
abstract class AbstractShortcode
|
8 |
{
|
9 |
+
/** @var string */
|
10 |
protected $name;
|
11 |
+
/** @psalm-var array<string,string|null> */
|
12 |
protected $parameters = array();
|
13 |
+
/** @var string|null */
|
14 |
protected $content;
|
15 |
+
/** @var string|null */
|
16 |
protected $bbCode;
|
17 |
|
18 |
+
/** @return bool */
|
19 |
public function hasContent()
|
20 |
{
|
21 |
return $this->content !== null;
|
22 |
}
|
23 |
|
24 |
+
/** @return string */
|
25 |
public function getName()
|
26 |
{
|
27 |
return $this->name;
|
28 |
}
|
29 |
|
30 |
+
/** @psalm-return array<string,string|null> */
|
31 |
public function getParameters()
|
32 |
{
|
33 |
return $this->parameters;
|
34 |
}
|
35 |
|
36 |
+
/**
|
37 |
+
* @param string $name
|
38 |
+
*
|
39 |
+
* @return bool
|
40 |
+
*/
|
41 |
public function hasParameter($name)
|
42 |
{
|
43 |
return array_key_exists($name, $this->parameters);
|
44 |
}
|
45 |
|
46 |
+
/** @return bool */
|
47 |
public function hasParameters()
|
48 |
{
|
49 |
return (bool)$this->parameters;
|
50 |
}
|
51 |
|
52 |
+
/**
|
53 |
+
* @param string $name
|
54 |
+
* @param string|null $default
|
55 |
+
*
|
56 |
+
* @psalm-return string|null
|
57 |
+
*/
|
58 |
public function getParameter($name, $default = null)
|
59 |
{
|
60 |
return $this->hasParameter($name) ? $this->parameters[$name] : $default;
|
61 |
}
|
62 |
|
63 |
+
/**
|
64 |
+
* @param int $index
|
65 |
+
*
|
66 |
+
* @return string|null
|
67 |
+
*/
|
68 |
public function getParameterAt($index)
|
69 |
{
|
70 |
$keys = array_keys($this->parameters);
|
72 |
return array_key_exists($index, $keys) ? $keys[$index] : null;
|
73 |
}
|
74 |
|
75 |
+
/** @return string|null */
|
76 |
public function getContent()
|
77 |
{
|
78 |
return $this->content;
|
79 |
}
|
80 |
|
81 |
+
/** @return string|null */
|
82 |
public function getBbCode()
|
83 |
{
|
84 |
return $this->bbCode;
|
vendor/thunderer/shortcode/src/Shortcode/ParsedShortcode.php
CHANGED
@@ -6,9 +6,15 @@ namespace Thunder\Shortcode\Shortcode;
|
|
6 |
*/
|
7 |
final class ParsedShortcode extends AbstractShortcode implements ParsedShortcodeInterface
|
8 |
{
|
|
|
9 |
private $text;
|
|
|
10 |
private $offset;
|
11 |
|
|
|
|
|
|
|
|
|
12 |
public function __construct(ShortcodeInterface $shortcode, $text, $offset)
|
13 |
{
|
14 |
$this->name = $shortcode->getName();
|
@@ -27,11 +33,13 @@ final class ParsedShortcode extends AbstractShortcode implements ParsedShortcode
|
|
27 |
return $self;
|
28 |
}
|
29 |
|
|
|
30 |
public function getText()
|
31 |
{
|
32 |
return $this->text;
|
33 |
}
|
34 |
|
|
|
35 |
public function getOffset()
|
36 |
{
|
37 |
return $this->offset;
|
6 |
*/
|
7 |
final class ParsedShortcode extends AbstractShortcode implements ParsedShortcodeInterface
|
8 |
{
|
9 |
+
/** @var string */
|
10 |
private $text;
|
11 |
+
/** @var int */
|
12 |
private $offset;
|
13 |
|
14 |
+
/**
|
15 |
+
* @param string $text
|
16 |
+
* @param int $offset
|
17 |
+
*/
|
18 |
public function __construct(ShortcodeInterface $shortcode, $text, $offset)
|
19 |
{
|
20 |
$this->name = $shortcode->getName();
|
33 |
return $self;
|
34 |
}
|
35 |
|
36 |
+
/** @return string */
|
37 |
public function getText()
|
38 |
{
|
39 |
return $this->text;
|
40 |
}
|
41 |
|
42 |
+
/** @return int */
|
43 |
public function getOffset()
|
44 |
{
|
45 |
return $this->offset;
|
vendor/thunderer/shortcode/src/Shortcode/ProcessedShortcode.php
CHANGED
@@ -9,54 +9,66 @@ use Thunder\Shortcode\Processor\ProcessorInterface;
|
|
9 |
*/
|
10 |
final class ProcessedShortcode extends AbstractShortcode implements ParsedShortcodeInterface
|
11 |
{
|
12 |
-
/** @var
|
13 |
private $parent;
|
|
|
14 |
private $position;
|
|
|
15 |
private $namePosition;
|
|
|
16 |
private $text;
|
|
|
17 |
private $textContent;
|
|
|
18 |
private $offset;
|
|
|
19 |
private $baseOffset;
|
|
|
20 |
private $shortcodeText;
|
|
|
21 |
private $iterationNumber;
|
|
|
22 |
private $recursionLevel;
|
23 |
/** @var ProcessorInterface */
|
24 |
private $processor;
|
25 |
|
26 |
-
private function __construct()
|
27 |
{
|
28 |
-
}
|
29 |
-
|
30 |
-
public static function createFromContext(ProcessorContext $context)
|
31 |
-
{
|
32 |
-
$self = new self();
|
33 |
-
|
34 |
// basic properties
|
35 |
-
$
|
36 |
-
$
|
37 |
-
$
|
38 |
-
$
|
39 |
-
$
|
40 |
|
41 |
// runtime context
|
42 |
-
$
|
43 |
-
$
|
44 |
-
$
|
45 |
-
$
|
46 |
-
$
|
47 |
|
48 |
// processor state
|
49 |
-
$
|
50 |
-
$
|
51 |
-
$
|
52 |
|
53 |
// text context
|
54 |
-
$
|
55 |
-
$
|
|
|
56 |
|
57 |
-
|
|
|
|
|
|
|
58 |
}
|
59 |
|
|
|
|
|
|
|
|
|
|
|
60 |
public function withContent($content)
|
61 |
{
|
62 |
$self = clone $this;
|
@@ -65,6 +77,11 @@ final class ProcessedShortcode extends AbstractShortcode implements ParsedShortc
|
|
65 |
return $self;
|
66 |
}
|
67 |
|
|
|
|
|
|
|
|
|
|
|
68 |
public function hasAncestor($name)
|
69 |
{
|
70 |
$self = $this;
|
@@ -78,56 +95,67 @@ final class ProcessedShortcode extends AbstractShortcode implements ParsedShortc
|
|
78 |
return false;
|
79 |
}
|
80 |
|
|
|
81 |
public function getParent()
|
82 |
{
|
83 |
return $this->parent;
|
84 |
}
|
85 |
|
|
|
86 |
public function getTextContent()
|
87 |
{
|
88 |
return $this->textContent;
|
89 |
}
|
90 |
|
|
|
91 |
public function getPosition()
|
92 |
{
|
93 |
return $this->position;
|
94 |
}
|
95 |
|
|
|
96 |
public function getNamePosition()
|
97 |
{
|
98 |
return $this->namePosition;
|
99 |
}
|
100 |
|
|
|
101 |
public function getText()
|
102 |
{
|
103 |
return $this->text;
|
104 |
}
|
105 |
|
|
|
106 |
public function getShortcodeText()
|
107 |
{
|
108 |
return $this->shortcodeText;
|
109 |
}
|
110 |
|
|
|
111 |
public function getOffset()
|
112 |
{
|
113 |
return $this->offset;
|
114 |
}
|
115 |
|
|
|
116 |
public function getBaseOffset()
|
117 |
{
|
118 |
return $this->baseOffset;
|
119 |
}
|
120 |
|
|
|
121 |
public function getIterationNumber()
|
122 |
{
|
123 |
return $this->iterationNumber;
|
124 |
}
|
125 |
|
|
|
126 |
public function getRecursionLevel()
|
127 |
{
|
128 |
return $this->recursionLevel;
|
129 |
}
|
130 |
|
|
|
131 |
public function getProcessor()
|
132 |
{
|
133 |
return $this->processor;
|
9 |
*/
|
10 |
final class ProcessedShortcode extends AbstractShortcode implements ParsedShortcodeInterface
|
11 |
{
|
12 |
+
/** @var ProcessedShortcode|null */
|
13 |
private $parent;
|
14 |
+
/** @var int */
|
15 |
private $position;
|
16 |
+
/** @var int */
|
17 |
private $namePosition;
|
18 |
+
/** @var string */
|
19 |
private $text;
|
20 |
+
/** @var string */
|
21 |
private $textContent;
|
22 |
+
/** @var int */
|
23 |
private $offset;
|
24 |
+
/** @var int */
|
25 |
private $baseOffset;
|
26 |
+
/** @var string */
|
27 |
private $shortcodeText;
|
28 |
+
/** @var int */
|
29 |
private $iterationNumber;
|
30 |
+
/** @var int */
|
31 |
private $recursionLevel;
|
32 |
/** @var ProcessorInterface */
|
33 |
private $processor;
|
34 |
|
35 |
+
private function __construct(ProcessorContext $context)
|
36 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
// basic properties
|
38 |
+
$this->name = $context->shortcode->getName();
|
39 |
+
$this->parameters = $context->shortcode->getParameters();
|
40 |
+
$this->content = $context->shortcode->getContent();
|
41 |
+
$this->bbCode = $context->shortcode->getBbCode();
|
42 |
+
$this->textContent = $context->textContent;
|
43 |
|
44 |
// runtime context
|
45 |
+
$this->parent = $context->parent;
|
46 |
+
$this->position = $context->position;
|
47 |
+
$this->namePosition = $context->namePosition[$this->name];
|
48 |
+
$this->text = $context->text;
|
49 |
+
$this->shortcodeText = $context->shortcodeText;
|
50 |
|
51 |
// processor state
|
52 |
+
$this->iterationNumber = $context->iterationNumber;
|
53 |
+
$this->recursionLevel = $context->recursionLevel;
|
54 |
+
$this->processor = $context->processor;
|
55 |
|
56 |
// text context
|
57 |
+
$this->offset = $context->offset;
|
58 |
+
$this->baseOffset = $context->baseOffset;
|
59 |
+
}
|
60 |
|
61 |
+
/** @return self */
|
62 |
+
public static function createFromContext(ProcessorContext $context)
|
63 |
+
{
|
64 |
+
return new self($context);
|
65 |
}
|
66 |
|
67 |
+
/**
|
68 |
+
* @param string|null $content
|
69 |
+
*
|
70 |
+
* @return self
|
71 |
+
*/
|
72 |
public function withContent($content)
|
73 |
{
|
74 |
$self = clone $this;
|
77 |
return $self;
|
78 |
}
|
79 |
|
80 |
+
/**
|
81 |
+
* @param string $name
|
82 |
+
*
|
83 |
+
* @return bool
|
84 |
+
*/
|
85 |
public function hasAncestor($name)
|
86 |
{
|
87 |
$self = $this;
|
95 |
return false;
|
96 |
}
|
97 |
|
98 |
+
/** @return ProcessedShortcode|null */
|
99 |
public function getParent()
|
100 |
{
|
101 |
return $this->parent;
|
102 |
}
|
103 |
|
104 |
+
/** @return string */
|
105 |
public function getTextContent()
|
106 |
{
|
107 |
return $this->textContent;
|
108 |
}
|
109 |
|
110 |
+
/** @return int */
|
111 |
public function getPosition()
|
112 |
{
|
113 |
return $this->position;
|
114 |
}
|
115 |
|
116 |
+
/** @return int */
|
117 |
public function getNamePosition()
|
118 |
{
|
119 |
return $this->namePosition;
|
120 |
}
|
121 |
|
122 |
+
/** @return string */
|
123 |
public function getText()
|
124 |
{
|
125 |
return $this->text;
|
126 |
}
|
127 |
|
128 |
+
/** @return string */
|
129 |
public function getShortcodeText()
|
130 |
{
|
131 |
return $this->shortcodeText;
|
132 |
}
|
133 |
|
134 |
+
/** @return int */
|
135 |
public function getOffset()
|
136 |
{
|
137 |
return $this->offset;
|
138 |
}
|
139 |
|
140 |
+
/** @return int */
|
141 |
public function getBaseOffset()
|
142 |
{
|
143 |
return $this->baseOffset;
|
144 |
}
|
145 |
|
146 |
+
/** @return int */
|
147 |
public function getIterationNumber()
|
148 |
{
|
149 |
return $this->iterationNumber;
|
150 |
}
|
151 |
|
152 |
+
/** @return int */
|
153 |
public function getRecursionLevel()
|
154 |
{
|
155 |
return $this->recursionLevel;
|
156 |
}
|
157 |
|
158 |
+
/** @return ProcessorInterface */
|
159 |
public function getProcessor()
|
160 |
{
|
161 |
return $this->processor;
|
vendor/thunderer/shortcode/src/Shortcode/ReplacedShortcode.php
CHANGED
@@ -6,10 +6,14 @@ namespace Thunder\Shortcode\Shortcode;
|
|
6 |
*/
|
7 |
final class ReplacedShortcode extends AbstractShortcode
|
8 |
{
|
|
|
9 |
private $replacement;
|
|
|
10 |
private $text;
|
|
|
11 |
private $offset;
|
12 |
|
|
|
13 |
public function __construct(ParsedShortcodeInterface $shortcode, $replacement)
|
14 |
{
|
15 |
$this->name = $shortcode->getName();
|
@@ -22,16 +26,19 @@ final class ReplacedShortcode extends AbstractShortcode
|
|
22 |
$this->replacement = $replacement;
|
23 |
}
|
24 |
|
|
|
25 |
public function getReplacement()
|
26 |
{
|
27 |
return $this->replacement;
|
28 |
}
|
29 |
|
|
|
30 |
public function getText()
|
31 |
{
|
32 |
return $this->text;
|
33 |
}
|
34 |
|
|
|
35 |
public function getOffset()
|
36 |
{
|
37 |
return $this->offset;
|
6 |
*/
|
7 |
final class ReplacedShortcode extends AbstractShortcode
|
8 |
{
|
9 |
+
/** @var string */
|
10 |
private $replacement;
|
11 |
+
/** @var string */
|
12 |
private $text;
|
13 |
+
/** @var int */
|
14 |
private $offset;
|
15 |
|
16 |
+
/** @param string $replacement */
|
17 |
public function __construct(ParsedShortcodeInterface $shortcode, $replacement)
|
18 |
{
|
19 |
$this->name = $shortcode->getName();
|
26 |
$this->replacement = $replacement;
|
27 |
}
|
28 |
|
29 |
+
/** @return string */
|
30 |
public function getReplacement()
|
31 |
{
|
32 |
return $this->replacement;
|
33 |
}
|
34 |
|
35 |
+
/** @return string */
|
36 |
public function getText()
|
37 |
{
|
38 |
return $this->text;
|
39 |
}
|
40 |
|
41 |
+
/** @return int */
|
42 |
public function getOffset()
|
43 |
{
|
44 |
return $this->offset;
|
vendor/thunderer/shortcode/src/Shortcode/Shortcode.php
CHANGED
@@ -6,12 +6,21 @@ namespace Thunder\Shortcode\Shortcode;
|
|
6 |
*/
|
7 |
final class Shortcode extends AbstractShortcode implements ShortcodeInterface
|
8 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
public function __construct($name, array $parameters, $content, $bbCode = null)
|
10 |
{
|
|
|
11 |
if(false === is_string($name) || '' === $name) {
|
12 |
throw new \InvalidArgumentException('Shortcode name must be a non-empty string!');
|
13 |
}
|
14 |
|
|
|
15 |
$isStringOrNull = function($value) { return is_string($value) || null === $value; };
|
16 |
if(count(array_filter($parameters, $isStringOrNull)) !== count($parameters)) {
|
17 |
throw new \InvalidArgumentException('Parameter values must be either string or empty (null)!');
|
6 |
*/
|
7 |
final class Shortcode extends AbstractShortcode implements ShortcodeInterface
|
8 |
{
|
9 |
+
/**
|
10 |
+
* @param string $name
|
11 |
+
* @param array $parameters
|
12 |
+
* @psalm-param array<string,string|null> $parameters
|
13 |
+
* @param string|null $content
|
14 |
+
* @param string|null $bbCode
|
15 |
+
*/
|
16 |
public function __construct($name, array $parameters, $content, $bbCode = null)
|
17 |
{
|
18 |
+
/** @psalm-suppress RedundantConditionGivenDocblockType, DocblockTypeContradiction */
|
19 |
if(false === is_string($name) || '' === $name) {
|
20 |
throw new \InvalidArgumentException('Shortcode name must be a non-empty string!');
|
21 |
}
|
22 |
|
23 |
+
/** @psalm-suppress MissingClosureParamType, MissingClosureReturnType */
|
24 |
$isStringOrNull = function($value) { return is_string($value) || null === $value; };
|
25 |
if(count(array_filter($parameters, $isStringOrNull)) !== count($parameters)) {
|
26 |
throw new \InvalidArgumentException('Parameter values must be either string or empty (null)!');
|
vendor/thunderer/shortcode/src/Shortcode/ShortcodeInterface.php
CHANGED
@@ -26,6 +26,7 @@ interface ShortcodeInterface
|
|
26 |
* Returns associative array(name => value) of shortcode parameters
|
27 |
*
|
28 |
* @return array
|
|
|
29 |
*/
|
30 |
public function getParameters();
|
31 |
|
@@ -53,7 +54,7 @@ interface ShortcodeInterface
|
|
53 |
* Returns the so-called "BBCode" fragment when shortcode name is treated
|
54 |
* like a parameter, eg.: [name="value" /]
|
55 |
*
|
56 |
-
* @return string
|
57 |
*/
|
58 |
public function getBbCode();
|
59 |
}
|
26 |
* Returns associative array(name => value) of shortcode parameters
|
27 |
*
|
28 |
* @return array
|
29 |
+
* @psalm-return array<string,string|null>
|
30 |
*/
|
31 |
public function getParameters();
|
32 |
|
54 |
* Returns the so-called "BBCode" fragment when shortcode name is treated
|
55 |
* like a parameter, eg.: [name="value" /]
|
56 |
*
|
57 |
+
* @return string|null
|
58 |
*/
|
59 |
public function getBbCode();
|
60 |
}
|
vendor/thunderer/shortcode/src/ShortcodeFacade.php
CHANGED
@@ -13,6 +13,7 @@ use Thunder\Shortcode\Serializer\SerializerInterface;
|
|
13 |
use Thunder\Shortcode\Serializer\TextSerializer;
|
14 |
use Thunder\Shortcode\Serializer\XmlSerializer;
|
15 |
use Thunder\Shortcode\Serializer\YamlSerializer;
|
|
|
16 |
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
17 |
use Thunder\Shortcode\Syntax\CommonSyntax;
|
18 |
use Thunder\Shortcode\Syntax\SyntaxInterface;
|
@@ -58,11 +59,15 @@ class ShortcodeFacade
|
|
58 |
$this->xmlSerializer = new XmlSerializer();
|
59 |
}
|
60 |
|
61 |
-
/**
|
|
|
|
|
|
|
62 |
public static function create(HandlerContainerInterface $handlers, SyntaxInterface $syntax)
|
63 |
{
|
64 |
$self = new self();
|
65 |
|
|
|
66 |
$self->handlers = $handlers;
|
67 |
$self->syntax = $syntax;
|
68 |
$self->rebuildProcessor();
|
@@ -70,22 +75,34 @@ class ShortcodeFacade
|
|
70 |
return $self;
|
71 |
}
|
72 |
|
|
|
73 |
private function rebuildProcessor()
|
74 |
{
|
75 |
$this->processor = new Processor($this->parser, $this->handlers);
|
76 |
$this->processor = $this->processor->withEventContainer($this->events);
|
77 |
}
|
78 |
|
|
|
|
|
|
|
|
|
|
|
79 |
public function process($text)
|
80 |
{
|
81 |
return $this->processor->process($text);
|
82 |
}
|
83 |
|
|
|
|
|
|
|
|
|
|
|
84 |
public function parse($text)
|
85 |
{
|
86 |
return $this->parser->parse($text);
|
87 |
}
|
88 |
|
|
|
89 |
public function setParser(ParserInterface $parser)
|
90 |
{
|
91 |
$this->parser = $parser;
|
@@ -94,6 +111,12 @@ class ShortcodeFacade
|
|
94 |
return $this;
|
95 |
}
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
public function addHandler($name, $handler)
|
98 |
{
|
99 |
$this->handlers->add($name, $handler);
|
@@ -101,6 +124,12 @@ class ShortcodeFacade
|
|
101 |
return $this;
|
102 |
}
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
public function addHandlerAlias($alias, $name)
|
105 |
{
|
106 |
$this->handlers->addAlias($alias, $name);
|
@@ -108,6 +137,12 @@ class ShortcodeFacade
|
|
108 |
return $this;
|
109 |
}
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
public function addEventHandler($name, $handler)
|
112 |
{
|
113 |
$this->events->addListener($name, $handler);
|
@@ -117,6 +152,11 @@ class ShortcodeFacade
|
|
117 |
|
118 |
/* --- SERIALIZATION --------------------------------------------------- */
|
119 |
|
|
|
|
|
|
|
|
|
|
|
120 |
public function serialize(ShortcodeInterface $shortcode, $format)
|
121 |
{
|
122 |
switch($format) {
|
@@ -128,6 +168,12 @@ class ShortcodeFacade
|
|
128 |
}
|
129 |
}
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
public function unserialize($text, $format)
|
132 |
{
|
133 |
switch($format) {
|
@@ -139,12 +185,31 @@ class ShortcodeFacade
|
|
139 |
}
|
140 |
}
|
141 |
|
142 |
-
/**
|
|
|
|
|
|
|
143 |
public function serializeToText(ShortcodeInterface $s) { return $this->serialize($s, 'text'); }
|
144 |
-
|
|
|
|
|
|
|
|
|
145 |
public function serializeToJson(ShortcodeInterface $s) { return $this->serialize($s, 'json'); }
|
146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
public function unserializeFromText($text) { return $this->unserialize($text, 'text'); }
|
148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
public function unserializeFromJson($text) { return $this->unserialize($text, 'json'); }
|
150 |
}
|
13 |
use Thunder\Shortcode\Serializer\TextSerializer;
|
14 |
use Thunder\Shortcode\Serializer\XmlSerializer;
|
15 |
use Thunder\Shortcode\Serializer\YamlSerializer;
|
16 |
+
use Thunder\Shortcode\Shortcode\ParsedShortcodeInterface;
|
17 |
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
18 |
use Thunder\Shortcode\Syntax\CommonSyntax;
|
19 |
use Thunder\Shortcode\Syntax\SyntaxInterface;
|
59 |
$this->xmlSerializer = new XmlSerializer();
|
60 |
}
|
61 |
|
62 |
+
/**
|
63 |
+
* @deprecated use constructor and customize using exposed methods
|
64 |
+
* @return self
|
65 |
+
*/
|
66 |
public static function create(HandlerContainerInterface $handlers, SyntaxInterface $syntax)
|
67 |
{
|
68 |
$self = new self();
|
69 |
|
70 |
+
/** @psalm-suppress PropertyTypeCoercion */
|
71 |
$self->handlers = $handlers;
|
72 |
$self->syntax = $syntax;
|
73 |
$self->rebuildProcessor();
|
75 |
return $self;
|
76 |
}
|
77 |
|
78 |
+
/** @return void */
|
79 |
private function rebuildProcessor()
|
80 |
{
|
81 |
$this->processor = new Processor($this->parser, $this->handlers);
|
82 |
$this->processor = $this->processor->withEventContainer($this->events);
|
83 |
}
|
84 |
|
85 |
+
/**
|
86 |
+
* @param string $text
|
87 |
+
*
|
88 |
+
* @return string
|
89 |
+
*/
|
90 |
public function process($text)
|
91 |
{
|
92 |
return $this->processor->process($text);
|
93 |
}
|
94 |
|
95 |
+
/**
|
96 |
+
* @param string $text
|
97 |
+
*
|
98 |
+
* @return ParsedShortcodeInterface[]
|
99 |
+
*/
|
100 |
public function parse($text)
|
101 |
{
|
102 |
return $this->parser->parse($text);
|
103 |
}
|
104 |
|
105 |
+
/** @return $this */
|
106 |
public function setParser(ParserInterface $parser)
|
107 |
{
|
108 |
$this->parser = $parser;
|
111 |
return $this;
|
112 |
}
|
113 |
|
114 |
+
/**
|
115 |
+
* @param string $name
|
116 |
+
* @psalm-param callable(ShortcodeInterface):string $handler
|
117 |
+
*
|
118 |
+
* @return $this
|
119 |
+
*/
|
120 |
public function addHandler($name, $handler)
|
121 |
{
|
122 |
$this->handlers->add($name, $handler);
|
124 |
return $this;
|
125 |
}
|
126 |
|
127 |
+
/**
|
128 |
+
* @param string $alias
|
129 |
+
* @param string $name
|
130 |
+
*
|
131 |
+
* @return $this
|
132 |
+
*/
|
133 |
public function addHandlerAlias($alias, $name)
|
134 |
{
|
135 |
$this->handlers->addAlias($alias, $name);
|
137 |
return $this;
|
138 |
}
|
139 |
|
140 |
+
/**
|
141 |
+
* @param string $name
|
142 |
+
* @param callable $handler
|
143 |
+
*
|
144 |
+
* @return $this
|
145 |
+
*/
|
146 |
public function addEventHandler($name, $handler)
|
147 |
{
|
148 |
$this->events->addListener($name, $handler);
|
152 |
|
153 |
/* --- SERIALIZATION --------------------------------------------------- */
|
154 |
|
155 |
+
/**
|
156 |
+
* @param string $format
|
157 |
+
*
|
158 |
+
* @return string
|
159 |
+
*/
|
160 |
public function serialize(ShortcodeInterface $shortcode, $format)
|
161 |
{
|
162 |
switch($format) {
|
168 |
}
|
169 |
}
|
170 |
|
171 |
+
/**
|
172 |
+
* @param string $text
|
173 |
+
* @param string $format
|
174 |
+
*
|
175 |
+
* @return ShortcodeInterface
|
176 |
+
*/
|
177 |
public function unserialize($text, $format)
|
178 |
{
|
179 |
switch($format) {
|
185 |
}
|
186 |
}
|
187 |
|
188 |
+
/**
|
189 |
+
* @deprecated use serialize($shortcode, $format)
|
190 |
+
* @return string
|
191 |
+
*/
|
192 |
public function serializeToText(ShortcodeInterface $s) { return $this->serialize($s, 'text'); }
|
193 |
+
|
194 |
+
/**
|
195 |
+
* @deprecated use serialize($shortcode, $format)
|
196 |
+
* @return string
|
197 |
+
*/
|
198 |
public function serializeToJson(ShortcodeInterface $s) { return $this->serialize($s, 'json'); }
|
199 |
+
|
200 |
+
/**
|
201 |
+
* @deprecated use serialize($shortcode, $format)
|
202 |
+
* @param string $text
|
203 |
+
*
|
204 |
+
* @return ShortcodeInterface
|
205 |
+
*/
|
206 |
public function unserializeFromText($text) { return $this->unserialize($text, 'text'); }
|
207 |
+
|
208 |
+
/**
|
209 |
+
* @deprecated use serialize($shortcode, $format)
|
210 |
+
* @param string $text
|
211 |
+
*
|
212 |
+
* @return ShortcodeInterface
|
213 |
+
*/
|
214 |
public function unserializeFromJson($text) { return $this->unserialize($text, 'json'); }
|
215 |
}
|
vendor/thunderer/shortcode/src/Syntax/CommonSyntax.php
CHANGED
@@ -6,26 +6,31 @@ namespace Thunder\Shortcode\Syntax;
|
|
6 |
*/
|
7 |
final class CommonSyntax implements SyntaxInterface
|
8 |
{
|
|
|
9 |
public function getOpeningTag()
|
10 |
{
|
11 |
return '[';
|
12 |
}
|
13 |
|
|
|
14 |
public function getClosingTag()
|
15 |
{
|
16 |
return ']';
|
17 |
}
|
18 |
|
|
|
19 |
public function getClosingTagMarker()
|
20 |
{
|
21 |
return '/';
|
22 |
}
|
23 |
|
|
|
24 |
public function getParameterValueSeparator()
|
25 |
{
|
26 |
return '=';
|
27 |
}
|
28 |
|
|
|
29 |
public function getParameterValueDelimiter()
|
30 |
{
|
31 |
return '"';
|
6 |
*/
|
7 |
final class CommonSyntax implements SyntaxInterface
|
8 |
{
|
9 |
+
/** @return string */
|
10 |
public function getOpeningTag()
|
11 |
{
|
12 |
return '[';
|
13 |
}
|
14 |
|
15 |
+
/** @return string */
|
16 |
public function getClosingTag()
|
17 |
{
|
18 |
return ']';
|
19 |
}
|
20 |
|
21 |
+
/** @return string */
|
22 |
public function getClosingTagMarker()
|
23 |
{
|
24 |
return '/';
|
25 |
}
|
26 |
|
27 |
+
/** @return string */
|
28 |
public function getParameterValueSeparator()
|
29 |
{
|
30 |
return '=';
|
31 |
}
|
32 |
|
33 |
+
/** @return string */
|
34 |
public function getParameterValueDelimiter()
|
35 |
{
|
36 |
return '"';
|
vendor/thunderer/shortcode/src/Syntax/Syntax.php
CHANGED
@@ -6,12 +6,24 @@ namespace Thunder\Shortcode\Syntax;
|
|
6 |
*/
|
7 |
final class Syntax implements SyntaxInterface
|
8 |
{
|
|
|
9 |
private $openingTag;
|
|
|
10 |
private $closingTag;
|
|
|
11 |
private $closingTagMarker;
|
|
|
12 |
private $parameterValueSeparator;
|
|
|
13 |
private $parameterValueDelimiter;
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
public function __construct(
|
16 |
$openingTag = null,
|
17 |
$closingTag = null,
|
@@ -26,26 +38,31 @@ final class Syntax implements SyntaxInterface
|
|
26 |
$this->parameterValueDelimiter = $parameterValueDelimiter;
|
27 |
}
|
28 |
|
|
|
29 |
public function getOpeningTag()
|
30 |
{
|
31 |
return $this->openingTag ?: '[';
|
32 |
}
|
33 |
|
|
|
34 |
public function getClosingTag()
|
35 |
{
|
36 |
return $this->closingTag ?: ']';
|
37 |
}
|
38 |
|
|
|
39 |
public function getClosingTagMarker()
|
40 |
{
|
41 |
return $this->closingTagMarker ?: '/';
|
42 |
}
|
43 |
|
|
|
44 |
public function getParameterValueSeparator()
|
45 |
{
|
46 |
return $this->parameterValueSeparator ?: '=';
|
47 |
}
|
48 |
|
|
|
49 |
public function getParameterValueDelimiter()
|
50 |
{
|
51 |
return $this->parameterValueDelimiter ?: '"';
|
6 |
*/
|
7 |
final class Syntax implements SyntaxInterface
|
8 |
{
|
9 |
+
/** @var string|null */
|
10 |
private $openingTag;
|
11 |
+
/** @var string|null */
|
12 |
private $closingTag;
|
13 |
+
/** @var string|null */
|
14 |
private $closingTagMarker;
|
15 |
+
/** @var string|null */
|
16 |
private $parameterValueSeparator;
|
17 |
+
/** @var string|null */
|
18 |
private $parameterValueDelimiter;
|
19 |
|
20 |
+
/**
|
21 |
+
* @param string|null $openingTag
|
22 |
+
* @param string|null $closingTag
|
23 |
+
* @param string|null $closingTagMarker
|
24 |
+
* @param string|null $parameterValueSeparator
|
25 |
+
* @param string|null $parameterValueDelimiter
|
26 |
+
*/
|
27 |
public function __construct(
|
28 |
$openingTag = null,
|
29 |
$closingTag = null,
|
38 |
$this->parameterValueDelimiter = $parameterValueDelimiter;
|
39 |
}
|
40 |
|
41 |
+
/** @return string */
|
42 |
public function getOpeningTag()
|
43 |
{
|
44 |
return $this->openingTag ?: '[';
|
45 |
}
|
46 |
|
47 |
+
/** @return string */
|
48 |
public function getClosingTag()
|
49 |
{
|
50 |
return $this->closingTag ?: ']';
|
51 |
}
|
52 |
|
53 |
+
/** @return string */
|
54 |
public function getClosingTagMarker()
|
55 |
{
|
56 |
return $this->closingTagMarker ?: '/';
|
57 |
}
|
58 |
|
59 |
+
/** @return string */
|
60 |
public function getParameterValueSeparator()
|
61 |
{
|
62 |
return $this->parameterValueSeparator ?: '=';
|
63 |
}
|
64 |
|
65 |
+
/** @return string */
|
66 |
public function getParameterValueDelimiter()
|
67 |
{
|
68 |
return $this->parameterValueDelimiter ?: '"';
|
vendor/thunderer/shortcode/src/Syntax/SyntaxBuilder.php
CHANGED
@@ -6,16 +6,22 @@ namespace Thunder\Shortcode\Syntax;
|
|
6 |
*/
|
7 |
final class SyntaxBuilder
|
8 |
{
|
|
|
9 |
private $openingTag;
|
|
|
10 |
private $closingTag;
|
|
|
11 |
private $closingTagMarker;
|
|
|
12 |
private $parameterValueSeparator;
|
|
|
13 |
private $parameterValueDelimiter;
|
14 |
|
15 |
public function __construct()
|
16 |
{
|
17 |
}
|
18 |
|
|
|
19 |
public function getSyntax()
|
20 |
{
|
21 |
return new Syntax(
|
@@ -27,6 +33,11 @@ final class SyntaxBuilder
|
|
27 |
);
|
28 |
}
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
public function setOpeningTag($tag)
|
31 |
{
|
32 |
$this->openingTag = $tag;
|
@@ -34,6 +45,11 @@ final class SyntaxBuilder
|
|
34 |
return $this;
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
|
|
37 |
public function setClosingTag($tag)
|
38 |
{
|
39 |
$this->closingTag = $tag;
|
@@ -41,6 +57,11 @@ final class SyntaxBuilder
|
|
41 |
return $this;
|
42 |
}
|
43 |
|
|
|
|
|
|
|
|
|
|
|
44 |
public function setClosingTagMarker($marker)
|
45 |
{
|
46 |
$this->closingTagMarker = $marker;
|
@@ -48,6 +69,11 @@ final class SyntaxBuilder
|
|
48 |
return $this;
|
49 |
}
|
50 |
|
|
|
|
|
|
|
|
|
|
|
51 |
public function setParameterValueSeparator($separator)
|
52 |
{
|
53 |
$this->parameterValueSeparator = $separator;
|
@@ -55,6 +81,11 @@ final class SyntaxBuilder
|
|
55 |
return $this;
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
58 |
public function setParameterValueDelimiter($delimiter)
|
59 |
{
|
60 |
$this->parameterValueDelimiter = $delimiter;
|
6 |
*/
|
7 |
final class SyntaxBuilder
|
8 |
{
|
9 |
+
/** @var string|null */
|
10 |
private $openingTag;
|
11 |
+
/** @var string|null */
|
12 |
private $closingTag;
|
13 |
+
/** @var string|null */
|
14 |
private $closingTagMarker;
|
15 |
+
/** @var string|null */
|
16 |
private $parameterValueSeparator;
|
17 |
+
/** @var string|null */
|
18 |
private $parameterValueDelimiter;
|
19 |
|
20 |
public function __construct()
|
21 |
{
|
22 |
}
|
23 |
|
24 |
+
/** @return Syntax */
|
25 |
public function getSyntax()
|
26 |
{
|
27 |
return new Syntax(
|
33 |
);
|
34 |
}
|
35 |
|
36 |
+
/**
|
37 |
+
* @param string $tag
|
38 |
+
*
|
39 |
+
* @return $this
|
40 |
+
*/
|
41 |
public function setOpeningTag($tag)
|
42 |
{
|
43 |
$this->openingTag = $tag;
|
45 |
return $this;
|
46 |
}
|
47 |
|
48 |
+
/**
|
49 |
+
* @param string $tag
|
50 |
+
*
|
51 |
+
* @return $this
|
52 |
+
*/
|
53 |
public function setClosingTag($tag)
|
54 |
{
|
55 |
$this->closingTag = $tag;
|
57 |
return $this;
|
58 |
}
|
59 |
|
60 |
+
/**
|
61 |
+
* @param string $marker
|
62 |
+
*
|
63 |
+
* @return $this
|
64 |
+
*/
|
65 |
public function setClosingTagMarker($marker)
|
66 |
{
|
67 |
$this->closingTagMarker = $marker;
|
69 |
return $this;
|
70 |
}
|
71 |
|
72 |
+
/**
|
73 |
+
* @param string $separator
|
74 |
+
*
|
75 |
+
* @return $this
|
76 |
+
*/
|
77 |
public function setParameterValueSeparator($separator)
|
78 |
{
|
79 |
$this->parameterValueSeparator = $separator;
|
81 |
return $this;
|
82 |
}
|
83 |
|
84 |
+
/**
|
85 |
+
* @param string $delimiter
|
86 |
+
*
|
87 |
+
* @return $this
|
88 |
+
*/
|
89 |
public function setParameterValueDelimiter($delimiter)
|
90 |
{
|
91 |
$this->parameterValueDelimiter = $delimiter;
|
vendor/thunderer/shortcode/src/Syntax/SyntaxInterface.php
CHANGED
@@ -6,13 +6,18 @@ namespace Thunder\Shortcode\Syntax;
|
|
6 |
*/
|
7 |
interface SyntaxInterface
|
8 |
{
|
|
|
9 |
public function getOpeningTag();
|
10 |
|
|
|
11 |
public function getClosingTag();
|
12 |
|
|
|
13 |
public function getClosingTagMarker();
|
14 |
|
|
|
15 |
public function getParameterValueSeparator();
|
16 |
|
|
|
17 |
public function getParameterValueDelimiter();
|
18 |
}
|
6 |
*/
|
7 |
interface SyntaxInterface
|
8 |
{
|
9 |
+
/** @return string */
|
10 |
public function getOpeningTag();
|
11 |
|
12 |
+
/** @return string */
|
13 |
public function getClosingTag();
|
14 |
|
15 |
+
/** @return string */
|
16 |
public function getClosingTagMarker();
|
17 |
|
18 |
+
/** @return string */
|
19 |
public function getParameterValueSeparator();
|
20 |
|
21 |
+
/** @return string */
|
22 |
public function getParameterValueDelimiter();
|
23 |
}
|
vendor/thunderer/shortcode/src/Utility/RegexBuilderUtility.php
CHANGED
@@ -8,21 +8,25 @@ use Thunder\Shortcode\Syntax\SyntaxInterface;
|
|
8 |
*/
|
9 |
final class RegexBuilderUtility
|
10 |
{
|
|
|
11 |
public static function buildNameRegex()
|
12 |
{
|
13 |
return '[a-zA-Z0-9-_\\*]+';
|
14 |
}
|
15 |
|
|
|
16 |
public static function buildShortcodeRegex(SyntaxInterface $syntax)
|
17 |
{
|
18 |
return '~('.self::createShortcodeRegexContent($syntax).')~us';
|
19 |
}
|
20 |
|
|
|
21 |
public static function buildSingleShortcodeRegex(SyntaxInterface $syntax)
|
22 |
{
|
23 |
return '~(\A'.self::createShortcodeRegexContent($syntax).'\Z)~us';
|
24 |
}
|
25 |
|
|
|
26 |
public static function buildParametersRegex(SyntaxInterface $syntax)
|
27 |
{
|
28 |
$equals = self::quote($syntax->getParameterValueSeparator());
|
@@ -39,6 +43,7 @@ final class RegexBuilderUtility
|
|
39 |
return '~(?:\s*(\w+(?:'.$complex.'|'.$simple.'|'.$empty.')))~us';
|
40 |
}
|
41 |
|
|
|
42 |
private static function createShortcodeRegexContent(SyntaxInterface $syntax)
|
43 |
{
|
44 |
$open = self::quote($syntax->getOpeningTag());
|
@@ -78,6 +83,11 @@ final class RegexBuilderUtility
|
|
78 |
return '(?:'.$common.'(?:'.$withContent.'|'.$justClosed.'|'.$selfClosed.'))';
|
79 |
}
|
80 |
|
|
|
|
|
|
|
|
|
|
|
81 |
private static function quote($text)
|
82 |
{
|
83 |
return preg_replace('/(.)/us', '\\\\$0', $text);
|
8 |
*/
|
9 |
final class RegexBuilderUtility
|
10 |
{
|
11 |
+
/** @return string */
|
12 |
public static function buildNameRegex()
|
13 |
{
|
14 |
return '[a-zA-Z0-9-_\\*]+';
|
15 |
}
|
16 |
|
17 |
+
/** @return string */
|
18 |
public static function buildShortcodeRegex(SyntaxInterface $syntax)
|
19 |
{
|
20 |
return '~('.self::createShortcodeRegexContent($syntax).')~us';
|
21 |
}
|
22 |
|
23 |
+
/** @return string */
|
24 |
public static function buildSingleShortcodeRegex(SyntaxInterface $syntax)
|
25 |
{
|
26 |
return '~(\A'.self::createShortcodeRegexContent($syntax).'\Z)~us';
|
27 |
}
|
28 |
|
29 |
+
/** @return string */
|
30 |
public static function buildParametersRegex(SyntaxInterface $syntax)
|
31 |
{
|
32 |
$equals = self::quote($syntax->getParameterValueSeparator());
|
43 |
return '~(?:\s*(\w+(?:'.$complex.'|'.$simple.'|'.$empty.')))~us';
|
44 |
}
|
45 |
|
46 |
+
/** @return string */
|
47 |
private static function createShortcodeRegexContent(SyntaxInterface $syntax)
|
48 |
{
|
49 |
$open = self::quote($syntax->getOpeningTag());
|
83 |
return '(?:'.$common.'(?:'.$withContent.'|'.$justClosed.'|'.$selfClosed.'))';
|
84 |
}
|
85 |
|
86 |
+
/**
|
87 |
+
* @param string $text
|
88 |
+
*
|
89 |
+
* @return string
|
90 |
+
*/
|
91 |
private static function quote($text)
|
92 |
{
|
93 |
return preg_replace('/(.)/us', '\\\\$0', $text);
|