Version Description
- Resolved bug in default item link css
- Code field updates
- PHP 8 updates
- Item preview & title updates
- Added ticker display item wrap setting
- Editor item css updates
Download this release
Release Info
Developer | metaphorcreations |
Plugin | Ditty News Ticker |
Version | 3.0.16 |
Comparing to | |
See all releases |
Code changes from version 3.0.15 to 3.0.16
- ditty-news-ticker.php +2 -2
- includes/class-ditty-db-item-meta.php +10 -4
- includes/class-ditty-display-type-ticker.php +27 -3
- includes/class-ditty-items.php +1 -1
- includes/class-ditty-layout.php +3 -3
- includes/class-ditty-layouts.php +2 -2
- includes/css/ditty.css +11 -1
- includes/fields/ditty-field-code.php +1 -1
- includes/fields/helpers.php +4 -1
- includes/helpers.php +25 -10
- includes/js/admin/class-ditty-extension.js +1 -1
- includes/js/class-ditty-display-ticker.js +7 -2
- includes/js/class-ditty-display-ticker.min.js +1 -1
- includes/js/ditty-admin.min.js +1194 -1
- includes/js/ditty-editor-hooks.min.js +1 -1
- includes/js/ditty-editor.js +3 -3
- includes/js/ditty-editor.min.js +3 -3
- includes/js/editor/class-ditty-item-editor-panel.js +2 -2
- includes/js/editor_hooks/ditty-ticker-display-editor.js +20 -0
- includes/layout-tag-hooks-default.php +2 -2
- includes/sass/editor/_editor.scss +4 -0
- includes/sass/editor/_items_panel.scss +2 -0
- includes/sass/partials/_ditty-ui.scss +4 -0
- legacy/inc/helpers.php +3 -3
- readme.txt +11 -3
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.16
|
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.16' );
|
24 |
}
|
25 |
|
26 |
// Plugin Folder Path.
|
includes/class-ditty-db-item-meta.php
CHANGED
@@ -89,9 +89,12 @@ class Ditty_DB_Item_Meta extends Ditty_DB {
|
|
89 |
* @return bool False for failure. True for success.
|
90 |
*
|
91 |
* @access private
|
92 |
-
* @since 3.0
|
93 |
*/
|
94 |
-
public function add_meta( $item_id = 0, $meta_key = '', $meta_value, $unique = false ) {
|
|
|
|
|
|
|
95 |
$item_id = $this->sanitize_item_id( $item_id );
|
96 |
if ( false === $item_id ) {
|
97 |
return false;
|
@@ -117,9 +120,12 @@ class Ditty_DB_Item_Meta extends Ditty_DB {
|
|
117 |
* @return bool False on failure, true if success.
|
118 |
*
|
119 |
* @access private
|
120 |
-
* @since 3.0
|
121 |
*/
|
122 |
-
public function update_meta( $item_id = 0, $meta_key = '', $meta_value, $prev_value = '' ) {
|
|
|
|
|
|
|
123 |
$item_id = $this->sanitize_item_id( $item_id );
|
124 |
if ( false === $item_id ) {
|
125 |
return false;
|
89 |
* @return bool False for failure. True for success.
|
90 |
*
|
91 |
* @access private
|
92 |
+
* @since 3.0.randombytes_random16()
|
93 |
*/
|
94 |
+
public function add_meta( $item_id = 0, $meta_key = '', $meta_value = false, $unique = false ) {
|
95 |
+
if ( ! $meta_value ) {
|
96 |
+
return false;
|
97 |
+
}
|
98 |
$item_id = $this->sanitize_item_id( $item_id );
|
99 |
if ( false === $item_id ) {
|
100 |
return false;
|
120 |
* @return bool False on failure, true if success.
|
121 |
*
|
122 |
* @access private
|
123 |
+
* @since 3.0.16
|
124 |
*/
|
125 |
+
public function update_meta( $item_id = 0, $meta_key = '', $meta_value = false, $prev_value = '' ) {
|
126 |
+
if ( ! $meta_value ) {
|
127 |
+
return false;
|
128 |
+
}
|
129 |
$item_id = $this->sanitize_item_id( $item_id );
|
130 |
if ( false === $item_id ) {
|
131 |
return false;
|
includes/class-ditty-display-type-ticker.php
CHANGED
@@ -22,7 +22,7 @@ class Ditty_Display_Type_Ticker extends Ditty_Display_Type {
|
|
22 |
* Setup the fields
|
23 |
*
|
24 |
* @access public
|
25 |
-
* @since 3.0.
|
26 |
*/
|
27 |
public function fields( $values = array() ) {
|
28 |
$fields = array(
|
@@ -147,6 +147,30 @@ class Ditty_Display_Type_Ticker extends Ditty_Display_Type {
|
|
147 |
'inline' => true,
|
148 |
'std' => isset( $values['cloneItems'] ) ? $values['cloneItems'] : false,
|
149 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
'hoverPause' => array(
|
151 |
'type' => 'checkbox',
|
152 |
'id' => 'hoverPause',
|
@@ -214,11 +238,11 @@ class Ditty_Display_Type_Ticker extends Ditty_Display_Type {
|
|
214 |
/**
|
215 |
* Set the metabox defaults
|
216 |
* @access public
|
217 |
-
* @since 3.0.
|
218 |
*/
|
219 |
public function default_settings() {
|
220 |
|
221 |
-
$defaults = json_decode( '{"direction":"left","minHeight":"300px","maxHeight":"","spacing":"25","speed":"10","heightEase":"easeInOutQuint","heightSpeed":"1.5","scrollInit":"empty","scrollDelay":"3","cloneItems":"yes","hoverPause":"1","maxWidth":"","bgColor":"","padding":{"paddingTop":"","paddingBottom":"","paddingLeft":"","paddingRight":""},"margin":{"marginTop":"","marginBottom":"","marginLeft":"","marginRight":""},"borderColor":"","borderStyle":"none","borderWidth":{"borderTopWidth":"","borderBottomWidth":"","borderLeftWidth":"","borderRightWidth":""},"borderRadius":{"borderTopLeftRadius":"","borderTopRightRadius":"","borderBottomLeftRadius":"","borderBottomRightRadius":""},"titleDisplay":"none","titleElement":"h3","titleElementPosition":"start","titleFontSize":"","titleLineHeight":"","titleColor":"rgba(255, 255, 255, 1)","titleBgColor":"rgba(0, 0, 0, 1)","titleMargin":{"marginTop":"","marginBottom":"","marginLeft":"","marginRight":""},"titlePadding":{"paddingTop":"10px","paddingBottom":"10px","paddingLeft":"15px","paddingRight":"15px"},"titleBorderColor":"","titleBorderStyle":"none","titleBorderWidth":{"borderTopWidth":"","borderBottomWidth":"","borderLeftWidth":"","borderRightWidth":""},"titleBorderRadius":{"borderTopLeftRadius":"","borderTopRightRadius":"","borderBottomLeftRadius":"","borderBottomRightRadius":""},"contentsBgColor":"rgba(255, 255, 255, 0.5)","contentsPadding":{"paddingTop":"10px","paddingBottom":"10px","paddingLeft":"10px","paddingRight":"10px"},"contentsBorderColor":"","contentsBorderStyle":"none","contentsBorderWidth":{"borderTopWidth":"","borderBottomWidth":"","borderLeftWidth":"","borderRightWidth":""},"contentsBorderRadius":{"borderTopLeftRadius":"0","borderTopRightRadius":"","borderBottomLeftRadius":"","borderBottomRightRadius":""},"itemTextColor":"","itemBgColor":"","itemPadding":{"paddingTop":"","paddingBottom":"","paddingLeft":"","paddingRight":""},"itemBorderColor":"","itemBorderStyle":"none","itemBorderWidth":{"borderTopWidth":"","borderBottomWidth":"","borderLeftWidth":"","borderRightWidth":""},"itemBorderRadius":{"borderTopLeftRadius":"","borderTopRightRadius":"","borderBottomLeftRadius":"","borderBottomRightRadius":""},"itemMaxWidth":"300px","itemElementsWrap":"wrap"}', true );
|
222 |
|
223 |
return apply_filters( 'ditty_display_default_settings', $defaults, $this->type );
|
224 |
}
|
22 |
* Setup the fields
|
23 |
*
|
24 |
* @access public
|
25 |
+
* @since 3.0.16
|
26 |
*/
|
27 |
public function fields( $values = array() ) {
|
28 |
$fields = array(
|
147 |
'inline' => true,
|
148 |
'std' => isset( $values['cloneItems'] ) ? $values['cloneItems'] : false,
|
149 |
),
|
150 |
+
'cloneItems' => array(
|
151 |
+
'type' => 'radio',
|
152 |
+
'id' => 'cloneItems',
|
153 |
+
'name' => __( 'Clone Items?', 'ditty-news-ticker' ),
|
154 |
+
'help' => __( 'Should items continually clone to fill the ticker?', 'ditty-news-ticker' ),
|
155 |
+
'options' => array(
|
156 |
+
'yes' => __( 'Yes', 'ditty-news-ticker' ),
|
157 |
+
'no' => __( 'No', 'ditty-news-ticker' ),
|
158 |
+
),
|
159 |
+
'inline' => true,
|
160 |
+
'std' => isset( $values['cloneItems'] ) ? $values['cloneItems'] : false,
|
161 |
+
),
|
162 |
+
'wrapItems' => array(
|
163 |
+
'type' => 'radio',
|
164 |
+
'id' => 'wrapItems',
|
165 |
+
'name' => __( 'Wrap Items?', 'ditty-news-ticker' ),
|
166 |
+
'help' => __( 'Should items restart before all items have finished scrolling?', 'ditty-news-ticker' ),
|
167 |
+
'options' => array(
|
168 |
+
'yes' => __( 'Yes', 'ditty-news-ticker' ),
|
169 |
+
'no' => __( 'No', 'ditty-news-ticker' ),
|
170 |
+
),
|
171 |
+
'inline' => true,
|
172 |
+
'std' => isset( $values['wrapItems'] ) ? $values['wrapItems'] : false,
|
173 |
+
),
|
174 |
'hoverPause' => array(
|
175 |
'type' => 'checkbox',
|
176 |
'id' => 'hoverPause',
|
238 |
/**
|
239 |
* Set the metabox defaults
|
240 |
* @access public
|
241 |
+
* @since 3.0.16
|
242 |
*/
|
243 |
public function default_settings() {
|
244 |
|
245 |
+
$defaults = json_decode( '{"direction":"left","minHeight":"300px","maxHeight":"","spacing":"25","speed":"10","heightEase":"easeInOutQuint","heightSpeed":"1.5","scrollInit":"empty","scrollDelay":"3","cloneItems":"yes","wrapItems":"yes","hoverPause":"1","maxWidth":"","bgColor":"","padding":{"paddingTop":"","paddingBottom":"","paddingLeft":"","paddingRight":""},"margin":{"marginTop":"","marginBottom":"","marginLeft":"","marginRight":""},"borderColor":"","borderStyle":"none","borderWidth":{"borderTopWidth":"","borderBottomWidth":"","borderLeftWidth":"","borderRightWidth":""},"borderRadius":{"borderTopLeftRadius":"","borderTopRightRadius":"","borderBottomLeftRadius":"","borderBottomRightRadius":""},"titleDisplay":"none","titleElement":"h3","titleElementPosition":"start","titleFontSize":"","titleLineHeight":"","titleColor":"rgba(255, 255, 255, 1)","titleBgColor":"rgba(0, 0, 0, 1)","titleMargin":{"marginTop":"","marginBottom":"","marginLeft":"","marginRight":""},"titlePadding":{"paddingTop":"10px","paddingBottom":"10px","paddingLeft":"15px","paddingRight":"15px"},"titleBorderColor":"","titleBorderStyle":"none","titleBorderWidth":{"borderTopWidth":"","borderBottomWidth":"","borderLeftWidth":"","borderRightWidth":""},"titleBorderRadius":{"borderTopLeftRadius":"","borderTopRightRadius":"","borderBottomLeftRadius":"","borderBottomRightRadius":""},"contentsBgColor":"rgba(255, 255, 255, 0.5)","contentsPadding":{"paddingTop":"10px","paddingBottom":"10px","paddingLeft":"10px","paddingRight":"10px"},"contentsBorderColor":"","contentsBorderStyle":"none","contentsBorderWidth":{"borderTopWidth":"","borderBottomWidth":"","borderLeftWidth":"","borderRightWidth":""},"contentsBorderRadius":{"borderTopLeftRadius":"0","borderTopRightRadius":"","borderBottomLeftRadius":"","borderBottomRightRadius":""},"itemTextColor":"","itemBgColor":"","itemPadding":{"paddingTop":"","paddingBottom":"","paddingLeft":"","paddingRight":""},"itemBorderColor":"","itemBorderStyle":"none","itemBorderWidth":{"borderTopWidth":"","borderBottomWidth":"","borderLeftWidth":"","borderRightWidth":""},"itemBorderRadius":{"borderTopLeftRadius":"","borderTopRightRadius":"","borderBottomLeftRadius":"","borderBottomRightRadius":""},"itemMaxWidth":"300px","itemElementsWrap":"wrap"}', true );
|
246 |
|
247 |
return apply_filters( 'ditty_display_default_settings', $defaults, $this->type );
|
248 |
}
|
includes/class-ditty-items.php
CHANGED
@@ -400,7 +400,7 @@ class Ditty_Items {
|
|
400 |
|
401 |
$editor_item = new Ditty_Item( $item_id_ajax );
|
402 |
$editor_item->set_item_value( $_POST );
|
403 |
-
|
404 |
// Find updated values
|
405 |
$value_updates = array();
|
406 |
$sanitized_values = $editor_item->get_value();
|
400 |
|
401 |
$editor_item = new Ditty_Item( $item_id_ajax );
|
402 |
$editor_item->set_item_value( $_POST );
|
403 |
+
|
404 |
// Find updated values
|
405 |
$value_updates = array();
|
406 |
$sanitized_values = $editor_item->get_value();
|
includes/class-ditty-layout.php
CHANGED
@@ -383,12 +383,12 @@ class Ditty_Layout {
|
|
383 |
* Parse layout atts
|
384 |
*
|
385 |
* @access private
|
386 |
-
* @since 3.0
|
387 |
* @var array $parsed_atts
|
388 |
*/
|
389 |
-
private function parse_atts( $atts = array(), $s ) {
|
390 |
$parsed_atts = array();
|
391 |
-
if ( is_array( $atts ) && count( $atts ) > 0 ) {
|
392 |
foreach ( $atts as $key => $value ) {
|
393 |
if ( $custom_value = $s->getParameter( $key ) ) {
|
394 |
$parsed_atts[$key] = $custom_value;
|
383 |
* Parse layout atts
|
384 |
*
|
385 |
* @access private
|
386 |
+
* @since 3.0.16
|
387 |
* @var array $parsed_atts
|
388 |
*/
|
389 |
+
private function parse_atts( $atts = array(), $s = false ) {
|
390 |
$parsed_atts = array();
|
391 |
+
if ( $s && is_array( $atts ) && count( $atts ) > 0 ) {
|
392 |
foreach ( $atts as $key => $value ) {
|
393 |
if ( $custom_value = $s->getParameter( $key ) ) {
|
394 |
$parsed_atts[$key] = $custom_value;
|
includes/class-ditty-layouts.php
CHANGED
@@ -570,7 +570,7 @@ class Ditty_Layouts {
|
|
570 |
<div class="ditty-editor-options__buttons ditty-editor-options__buttons--start">
|
571 |
<a href="#" class="ditty-editor-options__back"><i class="fas fa-chevron-left" data-class="fas fa-chevron-left"></i></a>
|
572 |
</div>
|
573 |
-
<h3 class="ditty-editor-options__title"><?php
|
574 |
</div>
|
575 |
<div class="ditty-data-list">
|
576 |
<div class="ditty-data-list__items">
|
@@ -642,7 +642,7 @@ class Ditty_Layouts {
|
|
642 |
<div class="ditty-editor-options__buttons ditty-editor-options__buttons--start">
|
643 |
<a href="#" class="ditty-editor-options__back"><i class="fas fa-chevron-left" data-class="fas fa-chevron-left"></i></a>
|
644 |
</div>
|
645 |
-
<h3 class="ditty-editor-options__title"><?php echo sprintf( __( 'Variation
|
646 |
</div>
|
647 |
<div class="ditty-data-list">
|
648 |
<div class="ditty-data-list__items" data-active="<?php echo $layout_id_ajax; ?>">
|
570 |
<div class="ditty-editor-options__buttons ditty-editor-options__buttons--start">
|
571 |
<a href="#" class="ditty-editor-options__back"><i class="fas fa-chevron-left" data-class="fas fa-chevron-left"></i></a>
|
572 |
</div>
|
573 |
+
<h3 class="ditty-editor-options__title"><?php esc_html_e( 'Layout Variations', 'ditty-news-ticker' ); ?></h3>
|
574 |
</div>
|
575 |
<div class="ditty-data-list">
|
576 |
<div class="ditty-data-list__items">
|
642 |
<div class="ditty-editor-options__buttons ditty-editor-options__buttons--start">
|
643 |
<a href="#" class="ditty-editor-options__back"><i class="fas fa-chevron-left" data-class="fas fa-chevron-left"></i></a>
|
644 |
</div>
|
645 |
+
<h3 class="ditty-editor-options__title"><?php echo sprintf( __( 'Variation: <span>%s</span>', 'ditty-news-ticker' ), stripslashes( $variation_label_ajax ) ); ?></h3>
|
646 |
</div>
|
647 |
<div class="ditty-data-list">
|
648 |
<div class="ditty-data-list__items" data-active="<?php echo $layout_id_ajax; ?>">
|
includes/css/ditty.css
CHANGED
@@ -1133,6 +1133,10 @@
|
|
1133 |
.ditty-data-list__item:last-child {
|
1134 |
margin-bottom: 0; }
|
1135 |
.ditty-data-list__item__label {
|
|
|
|
|
|
|
|
|
1136 |
color: #444;
|
1137 |
padding-right: 5px;
|
1138 |
margin-right: auto;
|
@@ -1498,6 +1502,10 @@
|
|
1498 |
|
1499 |
.ditty-editor-options__title, .ditty-editor-options__title[type="text"] {
|
1500 |
flex: 1;
|
|
|
|
|
|
|
|
|
1501 |
font-size: 14px;
|
1502 |
line-height: 18px;
|
1503 |
margin: 0;
|
@@ -1631,7 +1639,9 @@
|
|
1631 |
border: 1px solid red;
|
1632 |
box-shadow: 0 0 1px red; }
|
1633 |
.ditty-editor__panel--items .ditty-data-list__item a.ditty-data-list__item__icon {
|
1634 |
-
display: block;
|
|
|
|
|
1635 |
|
1636 |
.ditty-editor-display {
|
1637 |
cursor: pointer; }
|
1133 |
.ditty-data-list__item:last-child {
|
1134 |
margin-bottom: 0; }
|
1135 |
.ditty-data-list__item__label {
|
1136 |
+
display: flex;
|
1137 |
+
flex-direction: row;
|
1138 |
+
align-items: center;
|
1139 |
+
justify-content: flex-start;
|
1140 |
color: #444;
|
1141 |
padding-right: 5px;
|
1142 |
margin-right: auto;
|
1502 |
|
1503 |
.ditty-editor-options__title, .ditty-editor-options__title[type="text"] {
|
1504 |
flex: 1;
|
1505 |
+
display: flex;
|
1506 |
+
flex-direction: row;
|
1507 |
+
align-items: center;
|
1508 |
+
justify-content: flex-start;
|
1509 |
font-size: 14px;
|
1510 |
line-height: 18px;
|
1511 |
margin: 0;
|
1639 |
border: 1px solid red;
|
1640 |
box-shadow: 0 0 1px red; }
|
1641 |
.ditty-editor__panel--items .ditty-data-list__item a.ditty-data-list__item__icon {
|
1642 |
+
display: block;
|
1643 |
+
border-right: 1px solid rgba(0, 0, 0, 0.05);
|
1644 |
+
margin-right: 10px; }
|
1645 |
|
1646 |
.ditty-editor-display {
|
1647 |
cursor: pointer; }
|
includes/fields/ditty-field-code.php
CHANGED
@@ -54,7 +54,7 @@ class Ditty_Field_Code extends Ditty_Field {
|
|
54 |
*/
|
55 |
public function input( $name, $std = false ) {
|
56 |
$html = '';
|
57 |
-
$html .= '<textarea name="' . $name . '" ' . ditty_attr_to_html( $this->attributes() ) . '>' . $std . '</textarea>';
|
58 |
return $html;
|
59 |
}
|
60 |
}
|
54 |
*/
|
55 |
public function input( $name, $std = false ) {
|
56 |
$html = '';
|
57 |
+
$html .= '<textarea name="' . $name . '" ' . ditty_attr_to_html( $this->attributes() ) . '>' . stripslashes( $std ) . '</textarea>';
|
58 |
return $html;
|
59 |
}
|
60 |
}
|
includes/fields/helpers.php
CHANGED
@@ -159,12 +159,15 @@ function ditty_sanitize_field( $field = array(), $values = array() ) {
|
|
159 |
* Sanitize fields
|
160 |
*
|
161 |
* @access public
|
162 |
-
* @since 3.0
|
163 |
*/
|
164 |
function ditty_sanitize_fields( $fields = array(), $values = array(), $id = '' ) {
|
165 |
$sanitized_values = array();
|
166 |
if ( is_array( $fields ) && count( $fields ) > 0 ) {
|
167 |
foreach ( $fields as $field ) {
|
|
|
|
|
|
|
168 |
if ( 'group' == $field['type'] && isset( $field['multiple_fields'] ) && true == $field['multiple_fields'] ) {
|
169 |
if ( isset( $field['fields'] ) && is_array( $field['fields'] ) && count( $field['fields'] ) > 0 ) {
|
170 |
foreach ( $field['fields'] as $group_field ) {
|
159 |
* Sanitize fields
|
160 |
*
|
161 |
* @access public
|
162 |
+
* @since 3.0.16
|
163 |
*/
|
164 |
function ditty_sanitize_fields( $fields = array(), $values = array(), $id = '' ) {
|
165 |
$sanitized_values = array();
|
166 |
if ( is_array( $fields ) && count( $fields ) > 0 ) {
|
167 |
foreach ( $fields as $field ) {
|
168 |
+
if ( ! is_array( $field ) ) {
|
169 |
+
continue;
|
170 |
+
}
|
171 |
if ( 'group' == $field['type'] && isset( $field['multiple_fields'] ) && true == $field['multiple_fields'] ) {
|
172 |
if ( isset( $field['fields'] ) && is_array( $field['fields'] ) && count( $field['fields'] ) > 0 ) {
|
173 |
foreach ( $field['fields'] as $group_field ) {
|
includes/helpers.php
CHANGED
@@ -463,9 +463,12 @@ function ditty_draft_item_get_meta( $item_id, $key = false ) {
|
|
463 |
|
464 |
/**
|
465 |
* Update item draft meta
|
466 |
-
* @since 3.0
|
467 |
*/
|
468 |
-
function ditty_draft_item_update_meta( $item_id, $key = false, $value ) {
|
|
|
|
|
|
|
469 |
$draft_values = ditty_get_draft_values();
|
470 |
if ( ! $draft_values ) {
|
471 |
$draft_values = array();
|
@@ -516,9 +519,12 @@ function ditty_draft_layout_get( $layout_id = false, $key = false ) {
|
|
516 |
|
517 |
/**
|
518 |
* Update a layout draft
|
519 |
-
* @since 3.0
|
520 |
*/
|
521 |
-
function ditty_draft_layout_update( $layout_id, $key = false, $value ) {
|
|
|
|
|
|
|
522 |
$draft_values = ditty_get_draft_values();
|
523 |
if ( ! $draft_values ) {
|
524 |
$draft_values = array();
|
@@ -563,9 +569,12 @@ function ditty_draft_display_get( $display_id, $key = false ) {
|
|
563 |
|
564 |
/**
|
565 |
* Update a display draft
|
566 |
-
* @since 3.0
|
567 |
*/
|
568 |
-
function ditty_draft_display_update( $display_id, $key = false, $value ) {
|
|
|
|
|
|
|
569 |
$draft_values = ditty_get_draft_values();
|
570 |
if ( ! $draft_values ) {
|
571 |
$draft_values = array();
|
@@ -1579,18 +1588,24 @@ function ditty_item_get_meta( $item_id, $meta_key = '', $single = true ) {
|
|
1579 |
/**
|
1580 |
* Add meta data field to a item.
|
1581 |
*
|
1582 |
-
* @since 3.0
|
1583 |
*/
|
1584 |
-
function ditty_item_add_meta( $item_id, $meta_key = '', $meta_value, $unique = false ) {
|
|
|
|
|
|
|
1585 |
return Ditty()->db_item_meta->add_meta( $item_id, $meta_key, $meta_value, $unique );
|
1586 |
}
|
1587 |
|
1588 |
/**
|
1589 |
* Update item meta field based on item ID.
|
1590 |
*
|
1591 |
-
* @since 3.0
|
1592 |
*/
|
1593 |
-
function ditty_item_update_meta( $item_id, $meta_key = '', $meta_value, $prev_value = '' ) {
|
|
|
|
|
|
|
1594 |
return Ditty()->db_item_meta->update_meta( $item_id, $meta_key, $meta_value, $prev_value );
|
1595 |
}
|
1596 |
|
463 |
|
464 |
/**
|
465 |
* Update item draft meta
|
466 |
+
* @since 3.0.16
|
467 |
*/
|
468 |
+
function ditty_draft_item_update_meta( $item_id, $key = false, $value = false ) {
|
469 |
+
if ( ! $value ) {
|
470 |
+
return false;
|
471 |
+
}
|
472 |
$draft_values = ditty_get_draft_values();
|
473 |
if ( ! $draft_values ) {
|
474 |
$draft_values = array();
|
519 |
|
520 |
/**
|
521 |
* Update a layout draft
|
522 |
+
* @since 3.0.16
|
523 |
*/
|
524 |
+
function ditty_draft_layout_update( $layout_id, $key = false, $value = false ) {
|
525 |
+
if ( ! $value ) {
|
526 |
+
return false;
|
527 |
+
}
|
528 |
$draft_values = ditty_get_draft_values();
|
529 |
if ( ! $draft_values ) {
|
530 |
$draft_values = array();
|
569 |
|
570 |
/**
|
571 |
* Update a display draft
|
572 |
+
* @since 3.0.16
|
573 |
*/
|
574 |
+
function ditty_draft_display_update( $display_id, $key = false, $value = false ) {
|
575 |
+
if ( ! $value ) {
|
576 |
+
return false;
|
577 |
+
}
|
578 |
$draft_values = ditty_get_draft_values();
|
579 |
if ( ! $draft_values ) {
|
580 |
$draft_values = array();
|
1588 |
/**
|
1589 |
* Add meta data field to a item.
|
1590 |
*
|
1591 |
+
* @since 3.0.16
|
1592 |
*/
|
1593 |
+
function ditty_item_add_meta( $item_id, $meta_key = '', $meta_value = false, $unique = false ) {
|
1594 |
+
if ( ! $meta_value ) {
|
1595 |
+
return false;
|
1596 |
+
}
|
1597 |
return Ditty()->db_item_meta->add_meta( $item_id, $meta_key, $meta_value, $unique );
|
1598 |
}
|
1599 |
|
1600 |
/**
|
1601 |
* Update item meta field based on item ID.
|
1602 |
*
|
1603 |
+
* @since 3.0.16
|
1604 |
*/
|
1605 |
+
function ditty_item_update_meta( $item_id, $meta_key = '', $meta_value = false, $prev_value = '' ) {
|
1606 |
+
if ( ! $meta_value ) {
|
1607 |
+
return false;
|
1608 |
+
}
|
1609 |
return Ditty()->db_item_meta->update_meta( $item_id, $meta_key, $meta_value, $prev_value );
|
1610 |
}
|
1611 |
|
includes/js/admin/class-ditty-extension.js
CHANGED
@@ -177,7 +177,7 @@
|
|
177 |
$.post( dittyAdminVars.ajaxurl, data, function( response ) {
|
178 |
if ( response ) {
|
179 |
self.$elmt.attr( 'data-license_status', response.status );
|
180 |
-
$message.
|
181 |
}
|
182 |
if ( response.license_key ) {
|
183 |
if ( 'DELETE' === response.license_key ) {
|
177 |
$.post( dittyAdminVars.ajaxurl, data, function( response ) {
|
178 |
if ( response ) {
|
179 |
self.$elmt.attr( 'data-license_status', response.status );
|
180 |
+
$message.html( response.message );
|
181 |
}
|
182 |
if ( response.license_key ) {
|
183 |
if ( 'DELETE' === response.license_key ) {
|
includes/js/class-ditty-display-ticker.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
/**
|
6 |
* Ditty class
|
7 |
*
|
8 |
-
* @since 3.0
|
9 |
* @return null
|
10 |
*/
|
11 |
|
@@ -21,6 +21,7 @@
|
|
21 |
spacing : 20,
|
22 |
speed : 10, // 1 - 10
|
23 |
cloneItems : 'yes',
|
|
|
24 |
hoverPause : 0, // 0, 1
|
25 |
height : null,
|
26 |
minHeight : null,
|
@@ -96,6 +97,7 @@
|
|
96 |
this.scrollPercent = 0.13;
|
97 |
this.running = false;
|
98 |
this.interval = false;
|
|
|
99 |
this.currentHeight = this.settings.height;
|
100 |
this.visibleItems = [];
|
101 |
|
@@ -205,7 +207,7 @@
|
|
205 |
|
206 |
// Initialize the first item
|
207 |
if ( 0 === self.visibleItems.length ) {
|
208 |
-
var firstItem = self.
|
209 |
if ( ! this._isItemEnabled( firstItem ) ) {
|
210 |
firstItem = this._getNextItem( firstItem );
|
211 |
}
|
@@ -321,6 +323,9 @@
|
|
321 |
if ( 'yes' !== this.settings.cloneItems && existingItems.length ) {
|
322 |
return false;
|
323 |
}
|
|
|
|
|
|
|
324 |
|
325 |
// Create and add a new item
|
326 |
var $item = $( this.settings.items[index].html );
|
5 |
/**
|
6 |
* Ditty class
|
7 |
*
|
8 |
+
* @since 3.0.16
|
9 |
* @return null
|
10 |
*/
|
11 |
|
21 |
spacing : 20,
|
22 |
speed : 10, // 1 - 10
|
23 |
cloneItems : 'yes',
|
24 |
+
wrapItems : 'yes',
|
25 |
hoverPause : 0, // 0, 1
|
26 |
height : null,
|
27 |
minHeight : null,
|
97 |
this.scrollPercent = 0.13;
|
98 |
this.running = false;
|
99 |
this.interval = false;
|
100 |
+
this.firstItem = this.settings.item;
|
101 |
this.currentHeight = this.settings.height;
|
102 |
this.visibleItems = [];
|
103 |
|
207 |
|
208 |
// Initialize the first item
|
209 |
if ( 0 === self.visibleItems.length ) {
|
210 |
+
var firstItem = self.firstItem;
|
211 |
if ( ! this._isItemEnabled( firstItem ) ) {
|
212 |
firstItem = this._getNextItem( firstItem );
|
213 |
}
|
323 |
if ( 'yes' !== this.settings.cloneItems && existingItems.length ) {
|
324 |
return false;
|
325 |
}
|
326 |
+
if ( 'yes' !== this.settings.cloneItems && 'yes' !== this.settings.wrapItems && this.firstItem === parseInt( index ) && 0 !== parseInt( this.visibleItems.length ) ) {
|
327 |
+
return false;
|
328 |
+
}
|
329 |
|
330 |
// Create and add a new item
|
331 |
var $item = $( this.settings.items[index].html );
|
includes/js/class-ditty-display-ticker.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function($){"use strict";var t={id:0,title:"",display:0,status:"",direction:"left",spacing:20,speed:10,cloneItems:"yes",hoverPause:0,height:null,minHeight:null,maxHeight:null,heightEase:"easeInOutQuint",heightSpeed:1.5,scrollInit:"empty",scrollDelay:2,maxWidth:"",bgColor:"",padding:{},margin:{},borderColor:{},borderStyle:{},borderWidth:{},borderRadius:{},contentsBgColor:"",contentsPadding:{},contentsBorderColor:{},contentsBorderStyle:{},contentsBorderWidth:{},contentsBorderRadius:{},titleDisplay:"none",titleElement:"h3",titleElementPosition:"topLeft",titleFontSize:"",titleLineHeight:"",titleColor:"",titleBgColor:"",titleMargin:{},titlePadding:{},titleBorderColor:{},titleBorderStyle:{},titleBorderWidth:{},titleBorderRadius:{},itemTextColor:"",itemBgColor:"",itemBorderColor:{},itemBorderStyle:{},itemBorderWidth:{},itemBorderRadius:{},itemPadding:{},itemMaxWidth:"",itemElementsWrap:"wrap",item:0,shuffle:0,showEditor:0,items:[]},i=function(i,e){this.displayType="ticker",this.elmt=i,this.settings=$.extend({},t,$.ditty_ticker.defaults,e),this.nextItem=null,this.total=this.settings.items.length,this.$elmt=$(i),this.$title=null,this.$titleContents=null,this.$contents=null,this.$items=null,this.$currentItem=null,this.$lastItem=null,this.scrollPercent=.13,this.running=!1,this.interval=!1,this.currentHeight=this.settings.height,this.visibleItems=[],1===parseInt(this.settings.shuffle)&&this.shuffle(),this._init()};i.prototype={_init:function(){var t,i,e=this;0===this.total&&this.hide(),this.$elmt.removeClass("ditty--pre"),this.$elmt.addClass("ditty ditty-ticker"),this.$elmt.attr("data-id",this.settings.id),this.$elmt.attr("data-type",this.displayType),this.$elmt.attr("data-display",this.settings.display),t=$('<div class="ditty-ticker__contents"></div>'),this.$contents=t,this.$title=$('<div class="ditty-ticker__title"></div>'),this.$titleContents=$('<div class="ditty-ticker__title__contents"></div>'),this.$title.append(this.$titleContents),i=$('<div class="ditty-ticker__items"></div>'),this.$items=i,this.$items.height(this.currentHeight),t.append(i),this.$elmt.append(t),this._styleDisplay(),this._styleTitle(),this.$elmt.on("mouseenter",{self:this},this._mouseenter),this.$elmt.on("mouseleave",{self:this},this._mouseleave),this.settings.showEditor?dittyEditorInit(this):this.trigger("start_live_updates"),setTimeout((function(){for(var t=0;t<e.total;t++)e._preloadItem(e.settings.items[t]);e._initializeItems(),e.trigger("init")}),1)},_initializeItems:function(){"filled"===this.settings.scrollInit?this._fillTicker():this.running||this._timerStart()},_preloadItem:function(t){$(t.html).find("img").each((function(){(new Image).src=$(this).attr("src")}))},_positionItems:function(t){var i=this;if(0===i.visibleItems.length){var e=i.settings.item;this._isItemEnabled(e)||(e=this._getNextItem(e)),i._initializeItem(e)}$.each(i.visibleItems,(function(e,s){if(s){var n=i.visibleItems[e].$item,r=i._calculateItemPosition(e,t);i.visibleItems[e].posX=r.posX,i.visibleItems[e].posY=r.posY,i._itemSetTransform(n,r),i._newItemShouldStart(n,r)&&i._initializeItem(parseInt(i.nextItem)),i._itemShouldTerminate(n,r)&&i._terminateItem(e)}}))},_timerStart:function(){var t=this;this.running=!0,this.trigger("start"),cancelAnimationFrame(this.interval),t.interval=requestAnimationFrame((function i(){t._positionItems(),t.interval=requestAnimationFrame(i)}))},_timerStop:function(){cancelAnimationFrame(this.interval),this.running=!1,this.trigger("stop")},_mouseenter:function(t){var i=t.data.self;i.settings.hoverPause&&i._timerStop()},_mouseleave:function(t){var i=t.data.self;i.settings.hoverPause&&i._timerStart()},_newItemShouldStart:function(t,i){if(this.$currentItem[0]!==t[0])return!1;var e=!1;switch(this.settings.direction){case"left":i.posX<=this.$items.outerWidth()-t.outerWidth()&&(e=!0);break;case"right":i.posX>=0&&(e=!0);break;case"down":i.posY>=0&&(e=!0);break;case"up":i.posY<=this.$items.outerHeight()-t.outerHeight()&&(e=!0)}return e},_initializeItem:function(t,i){if(void 0===this.settings.items[t])return!1;var e=this.$items.children(".ditty-item--"+this.settings.items[t].uniq_id);if("yes"!==this.settings.cloneItems&&e.length)return!1;var s=$(this.settings.items[t].html);if(s.css({top:0,left:0}),this.$items.children(".ditty-item--"+this.settings.items[t].id).not(".ditty-item--clone").length>0&&s.addClass("ditty-item--clone"),this._styleItem(s),this.settings.items[t].css&&dittyLayoutCss(this.settings.items[t].css,this.settings.items[t].layout_id),this._itemSpacing(s),this._itemSetTransform(s,this._itemResetPosition(s)),this.$items.append(s),s.css({display:"block",top:0,left:0,opacity:1}),s.addClass("ditty-item--current"),null!==this.$currentItem&&this.$currentItem.removeClass("ditty-item--current"),this.$currentItem=s,null===this.$lastItem&&(s.addClass("ditty-item--last"),this.$lastItem=s),this.settings.item=t,this.nextItem=this._getNextItem(t),"custom"!==i){var n=this._itemResetPosition(s);this._itemSetTransform(s,n),this.visibleItems.push({$item:s,itemId:this.settings.items[t].id,posX:n.posX,posY:n.posY}),this._setCurrentHeight()}return this.trigger("active_items_update"),s},_getNextItem:function(t){var i,e=this,s=!1;if(null!==this.nextItem&&t!==this.nextItem){var n=parseInt(this.nextItem);n<this.total&&n>=0&&e._isItemEnabled(n)&&(s=parseInt(this.nextItem))}if(!s)for(i=t;i<this.total;i++)if(i!==t&&e._isItemEnabled(i)){s=parseInt(i);break}if(!s)for(i=0;i<this.total;i++)if(e._isItemEnabled(i)){s=parseInt(i);break}return s},_itemShouldTerminate:function(t,i){var e=!1;switch(this.settings.direction){case"left":i.posX<-t.outerWidth()&&(e=!0);break;case"right":i.posX>this.$items.outerWidth()&&(e=!0);break;case"up":i.posY<-t.outerHeight()&&(e=!0);break;case"down":i.posY>this.$items.outerHeight()&&(e=!0)}return e},_terminateItem:function(t){var i=this.visibleItems[t].$item,e=i.next();i.remove(),this.visibleItems.splice(t,1),e.length&&(e.addClass("ditty-item--last"),this.$lastItem=e),this._setCurrentHeight(),this.trigger("active_items_update")},_setCurrentHeight:function(){var t=this.currentHeight;"up"===this.settings.direction||"down"===this.settings.direction?(t=this.$items.outerHeight(),this.$items.css({height:"100%"})):(t=0,$.each(this.visibleItems,(function(i,e){var s=e.$item.outerHeight();s>t&&(t=s)})),t!==this.currentHeight&&this.$items.stop().animate({height:t+"px"},1e3*parseFloat(this.settings.heightSpeed),this.settings.heightEase,(function(){}))),t!==this.currentHeight&&(this.currentHeight=t,this.trigger("height_updated"))},_itemSpacing:function(t){switch(this.settings.direction){case"left":case"right":t.css({paddingLeft:this.settings.spacing/2+"px",paddingRight:this.settings.spacing/2+"px",paddingTop:0,paddingBottom:0});break;case"up":case"down":t.css({paddingLeft:0,paddingRight:0,paddingTop:this.settings.spacing/2+"px",paddingBottom:this.settings.spacing/2+"px"})}},_itemSetTransform:function(t,i){var e=i.posX,s=i.posY;0!==e&&(e+="px"),0!==s&&(s+="px"),t.css({transform:"translate( "+e+", "+s+" )"})},_calculateItemPosition:function(t,i){var e=0,s=0,n=parseFloat(this.settings.speed)*this.scrollPercent;switch(i&&(n=i),this.settings.direction){case"left":e=parseFloat(this.visibleItems[t].posX)-n;break;case"right":e=parseFloat(this.visibleItems[t].posX)+n;break;case"up":s=parseFloat(this.visibleItems[t].posY)-n;break;case"down":s=parseFloat(this.visibleItems[t].posY)+n}return{posX:e,posY:s}},_itemResetPosition:function(t){var i=0,e=0;switch(this.settings.direction){case"left":i=this.$items.outerWidth();break;case"right":i="-"+t.outerWidth();break;case"up":e=this.$items.outerHeight();break;case"down":e="-"+t.outerHeight()}return{posX:i,posY:e}},_reverseItems:function(){if(this.$currentItem===this.$lastItem)return!1;var t=this.$currentItem,i=this.$lastItem;this.$currentItem=i,this.$lastItem=t,this.$currentItem.removeClass("ditty-item--last").addClass("ditty-item--current"),this.$lastItem.removeClass("ditty-item--current").addClass("ditty-item--last");var e=this.$items.children(".ditty-item");this.$items.append(e.get().reverse())},_resetItems:function(){this.$items.empty(),this.visibleItems=[],this.trigger("active_items_update")},_fillTicker:function(){var t=this,i=parseFloat(this.$items.outerWidth()),e=parseFloat(this.$items.outerHeight()),s=0,n=0,r=!1,h=this.settings.item,o=null;this._isItemEnabled(h)||(h=this._getNextItem(h)),"right"===this.settings.direction?s=i:"down"===this.settings.direction&&(n=e),o=setInterval((function(){var a=t._initializeItem(h);if(a){var l=t._filledItemInit(h,a,s,n,i,e);s=l.posX,n=l.posY,r=l.filled,h=t._getNextItem(h)}else r=!0;r&&(clearInterval(o),t.trigger("active_items_update"),setTimeout((function(){t.running||t._timerStart()}),1e3*parseFloat(t.settings.scrollDelay)))}),100)},_filledItemInit:function(t,i,e,s,n,r){var h=i.data("id"),o=parseFloat(i.outerWidth()),a=parseFloat(i.outerHeight()),l=0,d=0,m=!1;switch(i.css({display:"block",opacity:0}),this.settings.direction){case"left":l=e,this._itemSetTransform(i,{posX:l,posY:s}),(e+=o)>n&&(m=!0);break;case"right":l=e-=o,this._itemSetTransform(i,{posX:l,posY:s}),e<0&&(m=!0);break;case"up":d=s,this._itemSetTransform(i,{posX:e,posY:d}),(s+=a)>r&&(m=!0);break;case"down":d=s-=a,this._itemSetTransform(i,{posX:e,posY:d}),s<0&&(m=!0)}return i.stop().animate({opacity:1},1e3,"linear",(function(){})),this.visibleItems.push({$item:i,itemId:h,posX:l,posY:d}),this._setCurrentHeight(),{posX:e,posY:s,filled:m}},_setDirection:function(t){return!!$.inArray(t,this.settings.directions)&&(t!==this.settings.directions&&(this.settings.direction=t,this._timerStop(),this._resetItems(),this.settings.item=0,this._initializeItems(),void this.trigger("direction")))},_styleDisplay:function(){if(this.$elmt.css({maxWidth:this.settings.maxWidth,backgroundColor:this.settings.bgColor,borderColor:this.settings.borderColor,borderStyle:this.settings.borderStyle}),this.$elmt.css(this.settings.borderRadius),this.$elmt.css(this.settings.borderWidth),this.$elmt.css(this.settings.margin),this.$elmt.css(this.settings.padding),this.$contents.css({backgroundColor:this.settings.contentsBgColor,borderColor:this.settings.contentsBorderColor,borderStyle:this.settings.contentsBorderStyle}),this.$contents.css(this.settings.contentsPadding),this.$contents.css(this.settings.contentsBorderRadius),this.$contents.css(this.settings.contentsBorderWidth),"up"===this.settings.direction||"down"===this.settings.direction){var t=this.settings.minHeight?this.settings.minHeight:0,i=this.settings.maxHeight?this.settings.maxHeight:"none";this.$items.css({minHeight:t,maxHeight:i})}else this.$items.css({minHeight:"",maxHeight:""})},_styleTitle:function(){if(this.$elmt.attr("data-title",this.settings.titleDisplay),this.$elmt.attr("data-title_position",this.settings.titleElementPosition),"none"===this.settings.titleDisplay)this.$title.remove();else{var t=$("<"+this.settings.titleElement+' class="ditty-ticker__title__element">'+this.settings.title+"</"+this.settings.titleElement+">");t.css({fontSize:this.settings.titleFontSize,lineHeight:this.settings.titleLineHeight,color:this.settings.titleColor,margin:0,padding:0}),this.$title.css({backgroundColor:this.settings.titleBgColor,borderColor:this.settings.titleBorderColor,borderStyle:this.settings.titleBorderStyle}),this.$title.css(this.settings.titleMargin),this.$title.css(this.settings.titlePadding),this.$title.css(this.settings.titleBorderRadius),this.$title.css(this.settings.titleBorderWidth),this.$titleContents.html(t),this.$elmt.prepend(this.$title)}},_styleItem:function(t){t.children(".ditty-item__elements").css({color:this.settings.itemTextColor,backgroundColor:this.settings.itemBgColor,borderColor:this.settings.itemBorderColor,borderStyle:this.settings.itemBorderStyle}),t.children(".ditty-item__elements").css(this.settings.itemPadding),t.children(".ditty-item__elements").css(this.settings.itemBorderRadius),t.children(".ditty-item__elements").css(this.settings.itemBorderWidth),""!==this.settings.itemElementsWrap&&t.children(".ditty-item__elements").css({whiteSpace:this.settings.itemElementsWrap}),""!==this.settings.itemMaxWidth&&t.children(".ditty-item__elements").css({maxWidth:this.settings.itemMaxWidth})},_getOption:function(t){switch(t){case"ditty":return this;case"type":return this.displayType;case"display":return this.settings.display;case"items":return this.settings.items;case"height":return this.currentHeight;default:return this.settings[t]}},_setOption:function(t,i){if(void 0===i)return!1;switch(t){case"items":this.updateItems(i);break;case"direction":this.settings[t]=i,this._styleDisplay(),this._setDirection(i);break;case"titleDisplay":case"titleElement":case"titleElementPosition":case"titleFontSize":case"titleLineHeight":case"titleColor":case"titleBgColor":case"titleMargin":case"titlePadding":case"titleBorderColor":case"titleBorderStyle":case"titleBorderWidth":case"titleBorderRadius":this.settings[t]=i,this._styleTitle();break;case"minHeight":case"maxHeight":case"bgColor":case"padding":case"borderColor":case"borderStyle":case"borderWidth":case"borderRadius":case"contentsBgColor":case"contentsPadding":case"contentsBorderRadius":this.settings[t]=i,this._styleDisplay(),this._setCurrentHeight();break;default:this.settings[t]=i}this.trigger("update")},shuffle:function(){for(var t,i,e=this.total-1;e>0;e--)i=Math.floor(Math.random()*(e+1)),t=this.settings.items[e],this.settings.items[e]=this.settings.items[i],this.settings.items[i]=t},play:function(){this.running||this._timerStart()},pause:function(){this.running&&this._timerStop()},direction:function(t){this._setDirection(t)},toggle:function(){this.running?this.pause():this.play()},running:function(){return this.running},current:function(){return this.$currentItem},_isItemEnabled:function(t){return void 0!==this.settings.items[parseInt(t)]&&(void 0===this.settings.items[parseInt(t)].is_disabled||!(this.settings.items[parseInt(t)].is_disabled.length>0))},_disabledItemsStatus:function(){var t=this,i={};return $.each(this.settings.items,(function(e,s){t._isItemEnabled(e)?i[s.id]="enabled":i[s.id]="disabled"})),i},addItemDisabled:function(t,i){var e=this;$.each(this.settings.items,(function(s,n){String(n.id)===String(t)&&($.isArray(e.settings.items[s].is_disabled)||(e.settings.items[s].is_disabled=[]),e.settings.items[s].is_disabled.push(i))})),this.trigger("disabled_items_update")},removeItemDisabled:function(t,i){var e=this;$.each(this.settings.items,(function(s,n){String(n.id)===String(t)&&$.isArray(e.settings.items[s].is_disabled)&&e.settings.items[s].is_disabled.length&&(e.settings.items[s].is_disabled=$.grep(e.settings.items[s].is_disabled,(function(t){return t!==i})))})),this.trigger("disabled_items_update")},showItem:function(t){var i=[];if($.each(this.settings.items,(function(e,s){String(s.id)===String(t)&&i.push(e)})),0!==i.length)return this.nextItem=i[0],this.nextItem},addItem:function(t,i,e){var s=this.settings.items.slice(),n=!0;(i>=this.total||i<0)&&(n=!1),"replace"===e&&n?s.splice(i,1,t):null===i||""===i?s.splice(this.nextItem,0,t):i>=this.total?s.push(t):i<0?s.splice(0,0,t):s.splice(i,0,t),this.updateItems(s)},deleteItem:function(t){var i=[];$.each(this.settings.items,(function(e,s){String(s.id)!==String(t)&&i.push(s)})),this.updateItems(i)},updateItems:function(t,i,e,s){if(void 0===t)return!1;var n=[];if(i){var r=this.settings.items.slice(),h=[],o=!1;$.each(r,(function(s,r){String(r.id)===String(i)?"after"===e?(h.push(r),$.each(t,(function(t,i){h.push(i)})),o=!0):"before"===e?($.each(t,(function(t,i){h.push(i)})),h.push(r),o=!0):o||($.each(t,(function(t,i){h.push(i),n.push(String(i.uniq_id))})),o=!0):h.push(r)})),o||($.each(this.settings.items,(function(t,i){h.push(i)})),o=!0),0!==this.total&&(t=h)}this.settings.items=t,this.total=t.length,0===this.total?this.hide():this.show(),this.nextItem>=this.total&&(this.nextItem=0),this.trigger("update")},getActiveItems:function(){var t=[];return $.each(this.visibleItems,(function(i,e){t.push({id:e.itemId})})),t},hide:function(){this.$elmt.hide(),this.pause()},show:function(){this.$elmt.show(),this.play()},trigger:function(t){var i=[];switch(t){case"active_items_update":i=[this,this.getActiveItems()];break;case"disabled_items_update":i=[this._disabledItemsStatus()];break;case"height_updated":i=[this.currentHeight,this.$elmt];break;case"start_live_updates":i=[this.settings.id];break;default:i=[this.settings,this.$elmt]}this.$elmt.trigger("ditty_"+t,i),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,i),$("body").trigger("ditty_"+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("mouseenter",{self:this},this._mouseenter),this.$elmt.off("mouseleave",{self:this},this._mouseleave),cancelAnimationFrame(this.interval),this.$elmt.removeClass("ditty ditty-ticker"),this.$elmt.removeAttr("data-id"),this.$elmt.removeAttr("data-type"),this.$elmt.removeAttr("data-display"),this.$elmt.removeAttr("style"),this.$elmt.empty(),this.elmt._ditty_ticker=null}},$.fn.ditty_ticker=function(t){var e,s=arguments,n=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_ticker||(this._ditty_ticker=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_ticker;if(!i)throw new Error("No Ditty_Ticker 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_Ticker.');return void 0!==e?e:this}},$.ditty_ticker={},$.ditty_ticker.defaults=t}(jQuery);
|
1 |
+
!function($){"use strict";var t={id:0,title:"",display:0,status:"",direction:"left",spacing:20,speed:10,cloneItems:"yes",wrapItems:"yes",hoverPause:0,height:null,minHeight:null,maxHeight:null,heightEase:"easeInOutQuint",heightSpeed:1.5,scrollInit:"empty",scrollDelay:2,maxWidth:"",bgColor:"",padding:{},margin:{},borderColor:{},borderStyle:{},borderWidth:{},borderRadius:{},contentsBgColor:"",contentsPadding:{},contentsBorderColor:{},contentsBorderStyle:{},contentsBorderWidth:{},contentsBorderRadius:{},titleDisplay:"none",titleElement:"h3",titleElementPosition:"topLeft",titleFontSize:"",titleLineHeight:"",titleColor:"",titleBgColor:"",titleMargin:{},titlePadding:{},titleBorderColor:{},titleBorderStyle:{},titleBorderWidth:{},titleBorderRadius:{},itemTextColor:"",itemBgColor:"",itemBorderColor:{},itemBorderStyle:{},itemBorderWidth:{},itemBorderRadius:{},itemPadding:{},itemMaxWidth:"",itemElementsWrap:"wrap",item:0,shuffle:0,showEditor:0,items:[]},i=function(i,e){this.displayType="ticker",this.elmt=i,this.settings=$.extend({},t,$.ditty_ticker.defaults,e),this.nextItem=null,this.total=this.settings.items.length,this.$elmt=$(i),this.$title=null,this.$titleContents=null,this.$contents=null,this.$items=null,this.$currentItem=null,this.$lastItem=null,this.scrollPercent=.13,this.running=!1,this.interval=!1,this.firstItem=this.settings.item,this.currentHeight=this.settings.height,this.visibleItems=[],1===parseInt(this.settings.shuffle)&&this.shuffle(),this._init()};i.prototype={_init:function(){var t,i,e=this;0===this.total&&this.hide(),this.$elmt.removeClass("ditty--pre"),this.$elmt.addClass("ditty ditty-ticker"),this.$elmt.attr("data-id",this.settings.id),this.$elmt.attr("data-type",this.displayType),this.$elmt.attr("data-display",this.settings.display),t=$('<div class="ditty-ticker__contents"></div>'),this.$contents=t,this.$title=$('<div class="ditty-ticker__title"></div>'),this.$titleContents=$('<div class="ditty-ticker__title__contents"></div>'),this.$title.append(this.$titleContents),i=$('<div class="ditty-ticker__items"></div>'),this.$items=i,this.$items.height(this.currentHeight),t.append(i),this.$elmt.append(t),this._styleDisplay(),this._styleTitle(),this.$elmt.on("mouseenter",{self:this},this._mouseenter),this.$elmt.on("mouseleave",{self:this},this._mouseleave),this.settings.showEditor?dittyEditorInit(this):this.trigger("start_live_updates"),setTimeout((function(){for(var t=0;t<e.total;t++)e._preloadItem(e.settings.items[t]);e._initializeItems(),e.trigger("init")}),1)},_initializeItems:function(){"filled"===this.settings.scrollInit?this._fillTicker():this.running||this._timerStart()},_preloadItem:function(t){$(t.html).find("img").each((function(){(new Image).src=$(this).attr("src")}))},_positionItems:function(t){var i=this;if(0===i.visibleItems.length){var e=i.firstItem;this._isItemEnabled(e)||(e=this._getNextItem(e)),i._initializeItem(e)}$.each(i.visibleItems,(function(e,s){if(s){var n=i.visibleItems[e].$item,r=i._calculateItemPosition(e,t);i.visibleItems[e].posX=r.posX,i.visibleItems[e].posY=r.posY,i._itemSetTransform(n,r),i._newItemShouldStart(n,r)&&i._initializeItem(parseInt(i.nextItem)),i._itemShouldTerminate(n,r)&&i._terminateItem(e)}}))},_timerStart:function(){var t=this;this.running=!0,this.trigger("start"),cancelAnimationFrame(this.interval),t.interval=requestAnimationFrame((function i(){t._positionItems(),t.interval=requestAnimationFrame(i)}))},_timerStop:function(){cancelAnimationFrame(this.interval),this.running=!1,this.trigger("stop")},_mouseenter:function(t){var i=t.data.self;i.settings.hoverPause&&i._timerStop()},_mouseleave:function(t){var i=t.data.self;i.settings.hoverPause&&i._timerStart()},_newItemShouldStart:function(t,i){if(this.$currentItem[0]!==t[0])return!1;var e=!1;switch(this.settings.direction){case"left":i.posX<=this.$items.outerWidth()-t.outerWidth()&&(e=!0);break;case"right":i.posX>=0&&(e=!0);break;case"down":i.posY>=0&&(e=!0);break;case"up":i.posY<=this.$items.outerHeight()-t.outerHeight()&&(e=!0)}return e},_initializeItem:function(t,i){if(void 0===this.settings.items[t])return!1;var e=this.$items.children(".ditty-item--"+this.settings.items[t].uniq_id);if("yes"!==this.settings.cloneItems&&e.length)return!1;if("yes"!==this.settings.cloneItems&&"yes"!==this.settings.wrapItems&&this.firstItem===parseInt(t)&&0!==parseInt(this.visibleItems.length))return!1;var s=$(this.settings.items[t].html);if(s.css({top:0,left:0}),this.$items.children(".ditty-item--"+this.settings.items[t].id).not(".ditty-item--clone").length>0&&s.addClass("ditty-item--clone"),this._styleItem(s),this.settings.items[t].css&&dittyLayoutCss(this.settings.items[t].css,this.settings.items[t].layout_id),this._itemSpacing(s),this._itemSetTransform(s,this._itemResetPosition(s)),this.$items.append(s),s.css({display:"block",top:0,left:0,opacity:1}),s.addClass("ditty-item--current"),null!==this.$currentItem&&this.$currentItem.removeClass("ditty-item--current"),this.$currentItem=s,null===this.$lastItem&&(s.addClass("ditty-item--last"),this.$lastItem=s),this.settings.item=t,this.nextItem=this._getNextItem(t),"custom"!==i){var n=this._itemResetPosition(s);this._itemSetTransform(s,n),this.visibleItems.push({$item:s,itemId:this.settings.items[t].id,posX:n.posX,posY:n.posY}),this._setCurrentHeight()}return this.trigger("active_items_update"),s},_getNextItem:function(t){var i,e=this,s=!1;if(null!==this.nextItem&&t!==this.nextItem){var n=parseInt(this.nextItem);n<this.total&&n>=0&&e._isItemEnabled(n)&&(s=parseInt(this.nextItem))}if(!s)for(i=t;i<this.total;i++)if(i!==t&&e._isItemEnabled(i)){s=parseInt(i);break}if(!s)for(i=0;i<this.total;i++)if(e._isItemEnabled(i)){s=parseInt(i);break}return s},_itemShouldTerminate:function(t,i){var e=!1;switch(this.settings.direction){case"left":i.posX<-t.outerWidth()&&(e=!0);break;case"right":i.posX>this.$items.outerWidth()&&(e=!0);break;case"up":i.posY<-t.outerHeight()&&(e=!0);break;case"down":i.posY>this.$items.outerHeight()&&(e=!0)}return e},_terminateItem:function(t){var i=this.visibleItems[t].$item,e=i.next();i.remove(),this.visibleItems.splice(t,1),e.length&&(e.addClass("ditty-item--last"),this.$lastItem=e),this._setCurrentHeight(),this.trigger("active_items_update")},_setCurrentHeight:function(){var t=this.currentHeight;"up"===this.settings.direction||"down"===this.settings.direction?(t=this.$items.outerHeight(),this.$items.css({height:"100%"})):(t=0,$.each(this.visibleItems,(function(i,e){var s=e.$item.outerHeight();s>t&&(t=s)})),t!==this.currentHeight&&this.$items.stop().animate({height:t+"px"},1e3*parseFloat(this.settings.heightSpeed),this.settings.heightEase,(function(){}))),t!==this.currentHeight&&(this.currentHeight=t,this.trigger("height_updated"))},_itemSpacing:function(t){switch(this.settings.direction){case"left":case"right":t.css({paddingLeft:this.settings.spacing/2+"px",paddingRight:this.settings.spacing/2+"px",paddingTop:0,paddingBottom:0});break;case"up":case"down":t.css({paddingLeft:0,paddingRight:0,paddingTop:this.settings.spacing/2+"px",paddingBottom:this.settings.spacing/2+"px"})}},_itemSetTransform:function(t,i){var e=i.posX,s=i.posY;0!==e&&(e+="px"),0!==s&&(s+="px"),t.css({transform:"translate( "+e+", "+s+" )"})},_calculateItemPosition:function(t,i){var e=0,s=0,n=parseFloat(this.settings.speed)*this.scrollPercent;switch(i&&(n=i),this.settings.direction){case"left":e=parseFloat(this.visibleItems[t].posX)-n;break;case"right":e=parseFloat(this.visibleItems[t].posX)+n;break;case"up":s=parseFloat(this.visibleItems[t].posY)-n;break;case"down":s=parseFloat(this.visibleItems[t].posY)+n}return{posX:e,posY:s}},_itemResetPosition:function(t){var i=0,e=0;switch(this.settings.direction){case"left":i=this.$items.outerWidth();break;case"right":i="-"+t.outerWidth();break;case"up":e=this.$items.outerHeight();break;case"down":e="-"+t.outerHeight()}return{posX:i,posY:e}},_reverseItems:function(){if(this.$currentItem===this.$lastItem)return!1;var t=this.$currentItem,i=this.$lastItem;this.$currentItem=i,this.$lastItem=t,this.$currentItem.removeClass("ditty-item--last").addClass("ditty-item--current"),this.$lastItem.removeClass("ditty-item--current").addClass("ditty-item--last");var e=this.$items.children(".ditty-item");this.$items.append(e.get().reverse())},_resetItems:function(){this.$items.empty(),this.visibleItems=[],this.trigger("active_items_update")},_fillTicker:function(){var t=this,i=parseFloat(this.$items.outerWidth()),e=parseFloat(this.$items.outerHeight()),s=0,n=0,r=!1,h=this.settings.item,o=null;this._isItemEnabled(h)||(h=this._getNextItem(h)),"right"===this.settings.direction?s=i:"down"===this.settings.direction&&(n=e),o=setInterval((function(){var a=t._initializeItem(h);if(a){var l=t._filledItemInit(h,a,s,n,i,e);s=l.posX,n=l.posY,r=l.filled,h=t._getNextItem(h)}else r=!0;r&&(clearInterval(o),t.trigger("active_items_update"),setTimeout((function(){t.running||t._timerStart()}),1e3*parseFloat(t.settings.scrollDelay)))}),100)},_filledItemInit:function(t,i,e,s,n,r){var h=i.data("id"),o=parseFloat(i.outerWidth()),a=parseFloat(i.outerHeight()),l=0,d=0,m=!1;switch(i.css({display:"block",opacity:0}),this.settings.direction){case"left":l=e,this._itemSetTransform(i,{posX:l,posY:s}),(e+=o)>n&&(m=!0);break;case"right":l=e-=o,this._itemSetTransform(i,{posX:l,posY:s}),e<0&&(m=!0);break;case"up":d=s,this._itemSetTransform(i,{posX:e,posY:d}),(s+=a)>r&&(m=!0);break;case"down":d=s-=a,this._itemSetTransform(i,{posX:e,posY:d}),s<0&&(m=!0)}return i.stop().animate({opacity:1},1e3,"linear",(function(){})),this.visibleItems.push({$item:i,itemId:h,posX:l,posY:d}),this._setCurrentHeight(),{posX:e,posY:s,filled:m}},_setDirection:function(t){return!!$.inArray(t,this.settings.directions)&&(t!==this.settings.directions&&(this.settings.direction=t,this._timerStop(),this._resetItems(),this.settings.item=0,this._initializeItems(),void this.trigger("direction")))},_styleDisplay:function(){if(this.$elmt.css({maxWidth:this.settings.maxWidth,backgroundColor:this.settings.bgColor,borderColor:this.settings.borderColor,borderStyle:this.settings.borderStyle}),this.$elmt.css(this.settings.borderRadius),this.$elmt.css(this.settings.borderWidth),this.$elmt.css(this.settings.margin),this.$elmt.css(this.settings.padding),this.$contents.css({backgroundColor:this.settings.contentsBgColor,borderColor:this.settings.contentsBorderColor,borderStyle:this.settings.contentsBorderStyle}),this.$contents.css(this.settings.contentsPadding),this.$contents.css(this.settings.contentsBorderRadius),this.$contents.css(this.settings.contentsBorderWidth),"up"===this.settings.direction||"down"===this.settings.direction){var t=this.settings.minHeight?this.settings.minHeight:0,i=this.settings.maxHeight?this.settings.maxHeight:"none";this.$items.css({minHeight:t,maxHeight:i})}else this.$items.css({minHeight:"",maxHeight:""})},_styleTitle:function(){if(this.$elmt.attr("data-title",this.settings.titleDisplay),this.$elmt.attr("data-title_position",this.settings.titleElementPosition),"none"===this.settings.titleDisplay)this.$title.remove();else{var t=$("<"+this.settings.titleElement+' class="ditty-ticker__title__element">'+this.settings.title+"</"+this.settings.titleElement+">");t.css({fontSize:this.settings.titleFontSize,lineHeight:this.settings.titleLineHeight,color:this.settings.titleColor,margin:0,padding:0}),this.$title.css({backgroundColor:this.settings.titleBgColor,borderColor:this.settings.titleBorderColor,borderStyle:this.settings.titleBorderStyle}),this.$title.css(this.settings.titleMargin),this.$title.css(this.settings.titlePadding),this.$title.css(this.settings.titleBorderRadius),this.$title.css(this.settings.titleBorderWidth),this.$titleContents.html(t),this.$elmt.prepend(this.$title)}},_styleItem:function(t){t.children(".ditty-item__elements").css({color:this.settings.itemTextColor,backgroundColor:this.settings.itemBgColor,borderColor:this.settings.itemBorderColor,borderStyle:this.settings.itemBorderStyle}),t.children(".ditty-item__elements").css(this.settings.itemPadding),t.children(".ditty-item__elements").css(this.settings.itemBorderRadius),t.children(".ditty-item__elements").css(this.settings.itemBorderWidth),""!==this.settings.itemElementsWrap&&t.children(".ditty-item__elements").css({whiteSpace:this.settings.itemElementsWrap}),""!==this.settings.itemMaxWidth&&t.children(".ditty-item__elements").css({maxWidth:this.settings.itemMaxWidth})},_getOption:function(t){switch(t){case"ditty":return this;case"type":return this.displayType;case"display":return this.settings.display;case"items":return this.settings.items;case"height":return this.currentHeight;default:return this.settings[t]}},_setOption:function(t,i){if(void 0===i)return!1;switch(t){case"items":this.updateItems(i);break;case"direction":this.settings[t]=i,this._styleDisplay(),this._setDirection(i);break;case"titleDisplay":case"titleElement":case"titleElementPosition":case"titleFontSize":case"titleLineHeight":case"titleColor":case"titleBgColor":case"titleMargin":case"titlePadding":case"titleBorderColor":case"titleBorderStyle":case"titleBorderWidth":case"titleBorderRadius":this.settings[t]=i,this._styleTitle();break;case"minHeight":case"maxHeight":case"bgColor":case"padding":case"borderColor":case"borderStyle":case"borderWidth":case"borderRadius":case"contentsBgColor":case"contentsPadding":case"contentsBorderRadius":this.settings[t]=i,this._styleDisplay(),this._setCurrentHeight();break;default:this.settings[t]=i}this.trigger("update")},shuffle:function(){for(var t,i,e=this.total-1;e>0;e--)i=Math.floor(Math.random()*(e+1)),t=this.settings.items[e],this.settings.items[e]=this.settings.items[i],this.settings.items[i]=t},play:function(){this.running||this._timerStart()},pause:function(){this.running&&this._timerStop()},direction:function(t){this._setDirection(t)},toggle:function(){this.running?this.pause():this.play()},running:function(){return this.running},current:function(){return this.$currentItem},_isItemEnabled:function(t){return void 0!==this.settings.items[parseInt(t)]&&(void 0===this.settings.items[parseInt(t)].is_disabled||!(this.settings.items[parseInt(t)].is_disabled.length>0))},_disabledItemsStatus:function(){var t=this,i={};return $.each(this.settings.items,(function(e,s){t._isItemEnabled(e)?i[s.id]="enabled":i[s.id]="disabled"})),i},addItemDisabled:function(t,i){var e=this;$.each(this.settings.items,(function(s,n){String(n.id)===String(t)&&($.isArray(e.settings.items[s].is_disabled)||(e.settings.items[s].is_disabled=[]),e.settings.items[s].is_disabled.push(i))})),this.trigger("disabled_items_update")},removeItemDisabled:function(t,i){var e=this;$.each(this.settings.items,(function(s,n){String(n.id)===String(t)&&$.isArray(e.settings.items[s].is_disabled)&&e.settings.items[s].is_disabled.length&&(e.settings.items[s].is_disabled=$.grep(e.settings.items[s].is_disabled,(function(t){return t!==i})))})),this.trigger("disabled_items_update")},showItem:function(t){var i=[];if($.each(this.settings.items,(function(e,s){String(s.id)===String(t)&&i.push(e)})),0!==i.length)return this.nextItem=i[0],this.nextItem},addItem:function(t,i,e){var s=this.settings.items.slice(),n=!0;(i>=this.total||i<0)&&(n=!1),"replace"===e&&n?s.splice(i,1,t):null===i||""===i?s.splice(this.nextItem,0,t):i>=this.total?s.push(t):i<0?s.splice(0,0,t):s.splice(i,0,t),this.updateItems(s)},deleteItem:function(t){var i=[];$.each(this.settings.items,(function(e,s){String(s.id)!==String(t)&&i.push(s)})),this.updateItems(i)},updateItems:function(t,i,e,s){if(void 0===t)return!1;var n=[];if(i){var r=this.settings.items.slice(),h=[],o=!1;$.each(r,(function(s,r){String(r.id)===String(i)?"after"===e?(h.push(r),$.each(t,(function(t,i){h.push(i)})),o=!0):"before"===e?($.each(t,(function(t,i){h.push(i)})),h.push(r),o=!0):o||($.each(t,(function(t,i){h.push(i),n.push(String(i.uniq_id))})),o=!0):h.push(r)})),o||($.each(this.settings.items,(function(t,i){h.push(i)})),o=!0),0!==this.total&&(t=h)}this.settings.items=t,this.total=t.length,0===this.total?this.hide():this.show(),this.nextItem>=this.total&&(this.nextItem=0),this.trigger("update")},getActiveItems:function(){var t=[];return $.each(this.visibleItems,(function(i,e){t.push({id:e.itemId})})),t},hide:function(){this.$elmt.hide(),this.pause()},show:function(){this.$elmt.show(),this.play()},trigger:function(t){var i=[];switch(t){case"active_items_update":i=[this,this.getActiveItems()];break;case"disabled_items_update":i=[this._disabledItemsStatus()];break;case"height_updated":i=[this.currentHeight,this.$elmt];break;case"start_live_updates":i=[this.settings.id];break;default:i=[this.settings,this.$elmt]}this.$elmt.trigger("ditty_"+t,i),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,i),$("body").trigger("ditty_"+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("mouseenter",{self:this},this._mouseenter),this.$elmt.off("mouseleave",{self:this},this._mouseleave),cancelAnimationFrame(this.interval),this.$elmt.removeClass("ditty ditty-ticker"),this.$elmt.removeAttr("data-id"),this.$elmt.removeAttr("data-type"),this.$elmt.removeAttr("data-display"),this.$elmt.removeAttr("style"),this.$elmt.empty(),this.elmt._ditty_ticker=null}},$.fn.ditty_ticker=function(t){var e,s=arguments,n=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_ticker||(this._ditty_ticker=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_ticker;if(!i)throw new Error("No Ditty_Ticker 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_Ticker.');return void 0!==e?e:this}},$.ditty_ticker={},$.ditty_ticker.defaults=t}(jQuery);
|
includes/js/ditty-admin.min.js
CHANGED
@@ -1 +1,1194 @@
|
|
1 |
-
jQuery((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.url=window.location.href,this._init()};i.prototype={_init:function(){if(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),this.url.indexOf("#")>0){var t=this.url.substring(this.url.indexOf("#")+1);this._activatePanel(t)}},_initSlider:function(){var t=this.$panels.data("init_panel");this.$panels.ditty_slider({transition:"fade",transitionEase:"linear",transitionSpeed:0,heightSpeed:0,initTransition:"fade",initTransitionEase:"linear",initTransitionSpeed:0,initHeightEase:"linear",initHeightSpeed:0,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")}},_activatePanel:function(t){var i=this.$elmt.find('.ditty-settings__tab[data-panel="'+t+'"]');if(!i.length)return!1;this.$elmt.find(".ditty-settings__tab").removeClass("active"),i.addClass("active"),this.$panels.ditty_slider("showSlideById",t)},_tabClick:function(t){t.preventDefault();var i,e=t.data.self,s=$(t.target).is("a")?$(t.target):$(t.target).parent("a"),n=s.data("panel");if(e.$elmt.find(".ditty-settings__tab.active")===s)return!1;if(n){var a="#"+n;i=e.url.split("#")[0]+a}else i=e.url.split("#")[0];history.replaceState(null,null,i),e._activatePanel(n)},_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"),p=s.children("i");if(i.$elmt.hasClass("updating"))return!1;i.$elmt.addClass("updating"),p.attr("class",dittyAdminVars.updateIcon);var c={action:e,license:d,extension:l,extension_id:o,extension_name:r,security:dittyAdminVars.security};$.post(dittyAdminVars.ajaxurl,c,(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)),p.attr("class",p.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((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((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()}})}}))}()})),jQuery((function($){!function(){"use strict";var t={};$('.ditty-wizard-setting--title input[name="ditty_title"]').on("keyup",(function(){var i=$(this).parents(".ditty-wizard-setting"),e=$(this).val();""!==e&&(i.addClass("complete"),$(".ditty-wizard-setting--item-type").css("display","flex")),t.title=e})),$(".ditty-wizard-setting--item-type .ditty-option-grid__item").on("click",(function(i){i.preventDefault();var e=$(this).parents(".ditty-wizard-setting"),s=$(this).data("value");if(!$(this).hasClass("active")){$(this).siblings().removeClass("active"),$(this).addClass("active"),$(".ditty-wizard-setting--item-type-settings").removeClass("complete"),$(".ditty-wizard-setting--item-type-settings .ditty-option-submit").addClass("ditty-button--primary"),$(".ditty-wizard-setting--item-type-settings").css("display","flex");var n=$('.ditty-item-type-settings__group[data-id="'+s+'"]');$(".ditty-item-type-settings__group").removeClass("active").hide(),n.addClass("active").show(),n.trigger("ditty_init_fields"),n.hasClass("init")||(n.trigger("ditty_wizard_init",[s]),n.addClass("init")),$(".ditty-wizard-setting--layout").removeClass("complete"),$(".ditty-wizard-setting--layout .ditty-option-grid__item").removeClass("active"),$(".ditty-wizard-setting--layout").hide(),$(".ditty-wizard-setting--layout__variation").removeClass("complete").removeClass("active").hide(),$(".ditty-wizard-setting--layout__variation."+s).addClass("active").show(),$(".ditty-wizard-setting--display").removeClass("complete"),$(".ditty-wizard-setting--display .ditty-option-grid__item").removeClass("active"),$(".ditty-wizard-setting--display").hide(),$(".ditty-wizard-setting--submit").hide(),t.itemType=$(this).data("value"),e.hasClass("complete")||(e.addClass("complete"),$([document.documentElement,document.body]).stop().animate({scrollTop:$(".ditty-wizard-setting--item-type-settings").offset().top},700))}})),$(".ditty-wizard-setting--item-type-settings .ditty-option-submit").on("click",(function(i){i.preventDefault();var e=$(this).parents(".ditty-wizard-setting"),s=e.find(".ditty-item-type-settings__group.active"),n={};$(this).removeClass("ditty-button--primary"),s.find(":input").each((function(){var t=$(this).prop("type");"checkbox"===t||"radio"===t?this.checked&&(n[$(this).attr("name")]=$(this).val()):"button"!==t&&"submit"!==t&&(n[$(this).attr("name")]=$(this).val())})),$(".ditty-wizard-setting--layout").css("display","flex"),t.itemTypeValues=n,e.hasClass("complete")||(e.addClass("complete"),$([document.documentElement,document.body]).stop().animate({scrollTop:$(".ditty-wizard-setting--layout").offset().top},700))})),$(".ditty-wizard-setting--layout .ditty-option-grid__item").on("click",(function(i){i.preventDefault();var e=$(this).parents(".ditty-wizard-setting"),s=$(this).parents(".ditty-wizard-setting--layout__variation");if(!$(this).hasClass("active")&&($(this).siblings().removeClass("active"),$(this).addClass("active"),s.addClass("complete"),$(".ditty-wizard-setting--layout__variation.active").length===$(".ditty-wizard-setting--layout__variation.complete").length)){var n={};$(".ditty-wizard-setting--layout__variation.complete").each((function(){n[$(this).data("id")]=$(this).find(".ditty-option-grid__item.active").data("value")})),$(".ditty-wizard-setting--display").css("display","flex"),t.layoutVariations=n,e.hasClass("complete")||(e.addClass("complete"),$([document.documentElement,document.body]).stop().animate({scrollTop:$(".ditty-wizard-setting--display").offset().top},700))}})),$(".ditty-wizard-setting--display .ditty-option-grid__item").on("click",(function(i){i.preventDefault();var e=$(this).parents(".ditty-wizard-setting"),s=$(this).data("value");$(this).hasClass("active")||($(this).siblings().removeClass("active"),$(this).addClass("active"),$(".ditty-wizard-setting--submit").css("display","flex"),t.display=s,e.hasClass("complete")||(e.addClass("complete"),$([document.documentElement,document.body]).stop().animate({scrollTop:$(".ditty-wizard-setting--submit").offset().top},700)))})),$("#ditty-wizard-submit").on("click",(function(i){i.preventDefault();var e=$(this).data("ditty_id");$("#ditty-wizard-overlay").addClass("active");var s={action:"ditty_submit_wizard",ditty_id:e,init_values:t,security:dittyVars.security};$.post(dittyVars.ajaxurl,s,(function(t){window.history.pushState(null,"","/wp-admin/post.php?post="+e+"&action=edit"),location.reload()}),"json")}))}()}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
// @codekit-append 'admin/ditty-wizard.js';
|
10 |
+
|
11 |
+
jQuery( function( $ ) {
|
12 |
+
|
13 |
+
// Setup strict mode
|
14 |
+
(function() {
|
15 |
+
|
16 |
+
"use strict";
|
17 |
+
|
18 |
+
$( '#poststuff' ).trigger( 'ditty_init_fields' );
|
19 |
+
$( '#ditty-settings' ).ditty_settings();
|
20 |
+
|
21 |
+
}() );
|
22 |
+
|
23 |
+
} );
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Ditty Settings
|
27 |
+
*
|
28 |
+
* @since 3.0
|
29 |
+
* @return null
|
30 |
+
*/
|
31 |
+
|
32 |
+
(function ($) {
|
33 |
+
'use strict';
|
34 |
+
|
35 |
+
var defaults = {
|
36 |
+
};
|
37 |
+
|
38 |
+
var Ditty_Settings = function ( elmt, options ) {
|
39 |
+
|
40 |
+
this.elmt = elmt;
|
41 |
+
this.settings = $.extend( {}, defaults, $.ditty_settings.defaults, options );
|
42 |
+
this.$elmt = $( elmt );
|
43 |
+
this.$form = this.$elmt.find( '.ditty-settings__form' );
|
44 |
+
this.$panels = this.$elmt.find( '.ditty-settings__panels' );
|
45 |
+
this.saveBtns = this.$elmt.find( '.ditty-settings__save' );
|
46 |
+
this.tabs = this.$elmt.find( '.ditty-settings__tab' );
|
47 |
+
this.$notice_update = this.$elmt.find( '.ditty-notification--updated' );
|
48 |
+
this.$notice_error = this.$elmt.find( '.ditty-notification--error' );
|
49 |
+
this.$notice_warning = this.$elmt.find( '.ditty-notification--warning' );
|
50 |
+
this.initData = null;
|
51 |
+
this.url = window.location.href;
|
52 |
+
this._init();
|
53 |
+
};
|
54 |
+
|
55 |
+
|
56 |
+
Ditty_Settings.prototype = {
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Initialize the data list
|
60 |
+
*
|
61 |
+
* @since 3.0
|
62 |
+
* @return null
|
63 |
+
*/
|
64 |
+
_init: function () {
|
65 |
+
|
66 |
+
// Initialize the slider
|
67 |
+
this._initSlider();
|
68 |
+
|
69 |
+
// Add listeners
|
70 |
+
$( 'body' ).on( 'ditty_field_clone_update', { self: this }, this._enableSettingsUpdates );
|
71 |
+
this.saveBtns.on( 'click', { self: this }, this._submitForm );
|
72 |
+
this.tabs.on( 'click', { self: this }, this._tabClick );
|
73 |
+
this.$panels.on( 'ditty_slider_init', { self: this }, this._sliderInit );
|
74 |
+
this.$panels.on( 'ditty_slider_before_slide_update', { self: this }, this._beforeSlideUpdate );
|
75 |
+
this.$form.on( 'keyup change', 'input[type="text"], input[type="number"], textarea, select', { self: this }, this._checkUpdates );
|
76 |
+
this.$form.on( 'click', 'input[type="radio"], input[type="checkbox"]', { self: this }, this._checkUpdates );
|
77 |
+
this.$form.on( 'ditty_input_wysiwyg_update', '.ditty-input--wysiwyg', { self: this }, this._checkUpdates );
|
78 |
+
this.$form.on( 'click', '.ditty-default-layout-install', { self: this }, this._installLayout );
|
79 |
+
this.$form.on( 'click', '.ditty-default-display-install', { self: this }, this._installDisplay );
|
80 |
+
//this.$form.on( 'click', 'button[name="ditty_export_button"]', { self: this }, this._exportPosts );
|
81 |
+
|
82 |
+
if ( this.url.indexOf( "#" ) > 0 ) {
|
83 |
+
var activePanel = this.url.substring( this.url.indexOf( "#" ) + 1 );
|
84 |
+
this._activatePanel( activePanel );
|
85 |
+
}
|
86 |
+
},
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Initialize the slider
|
90 |
+
*
|
91 |
+
* @since 3.0.13
|
92 |
+
* @return null
|
93 |
+
*/
|
94 |
+
_initSlider: function () {
|
95 |
+
var initPanel = this.$panels.data( 'init_panel' );
|
96 |
+
this.$panels.ditty_slider( {
|
97 |
+
transition : 'fade',
|
98 |
+
transitionEase : 'linear',
|
99 |
+
transitionSpeed : 0,
|
100 |
+
heightSpeed : 0,
|
101 |
+
initTransition : 'fade',
|
102 |
+
initTransitionEase : 'linear',
|
103 |
+
initTransitionSpeed : 0,
|
104 |
+
initHeightEase : 'linear',
|
105 |
+
initHeightSpeed : 0,
|
106 |
+
touchSwipe : false,
|
107 |
+
slidesEl : '.ditty-settings__panel',
|
108 |
+
slideId : ( '' !== initPanel ) ? initPanel : false
|
109 |
+
} );
|
110 |
+
},
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Slider init
|
114 |
+
*
|
115 |
+
* @since 3.0
|
116 |
+
* @return null
|
117 |
+
*/
|
118 |
+
_sliderInit: function( e ) {
|
119 |
+
var self = e.data.self;
|
120 |
+
self.initData = self.$form.serialize();
|
121 |
+
},
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Before slide update
|
125 |
+
*
|
126 |
+
* @since 3.0
|
127 |
+
* @return null
|
128 |
+
*/
|
129 |
+
_beforeSlideUpdate: function( e, index, slide ) {
|
130 |
+
var self = e.data.self;
|
131 |
+
self._initFields( slide.$elmt );
|
132 |
+
self.$elmt.find( '.ditty-settings__tab' ).removeClass( 'active' );
|
133 |
+
self.$elmt.find( '.ditty-settings__tab[data-panel="' + slide.id + '"]' ).addClass( 'active' );
|
134 |
+
},
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Preview button add updates class
|
138 |
+
*
|
139 |
+
* @since 3.0
|
140 |
+
* @return null
|
141 |
+
*/
|
142 |
+
_enableSettingsUpdates: function( e ) {
|
143 |
+
var self = ( e ) ? e.data.self : this;
|
144 |
+
self.saveBtns.addClass( 'has-updates' );
|
145 |
+
//self.notice_warning.slideDown();
|
146 |
+
},
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Preview button remove updates class
|
150 |
+
*
|
151 |
+
* @since 3.0
|
152 |
+
* @return null
|
153 |
+
*/
|
154 |
+
_disableSettingsUpdates: function() {
|
155 |
+
this.saveBtns.removeClass( 'has-updates' );
|
156 |
+
},
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Check for updates
|
160 |
+
*
|
161 |
+
* @since 3.0
|
162 |
+
* @return null
|
163 |
+
*/
|
164 |
+
_checkUpdates: function( e ) {
|
165 |
+
var self = e ? e.data.self : this;
|
166 |
+
var currentData = self.$form.serialize();
|
167 |
+
if ( currentData !== self.initData ) {
|
168 |
+
self._enableSettingsUpdates();
|
169 |
+
} else {
|
170 |
+
self._disableSettingsUpdates();
|
171 |
+
}
|
172 |
+
},
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Initialize dynamic fields
|
176 |
+
*
|
177 |
+
* @since 3.0
|
178 |
+
* @return null
|
179 |
+
*/
|
180 |
+
_initFields: function ( $fields ) {
|
181 |
+
$fields.find( '.ditty-data-list' ).ditty_ui_data_list();
|
182 |
+
$fields.trigger( 'ditty_init_fields' );
|
183 |
+
$.protip( {
|
184 |
+
defaults: {
|
185 |
+
position: 'top',
|
186 |
+
size: 'small',
|
187 |
+
scheme: 'black',
|
188 |
+
classes: 'ditty-protip'
|
189 |
+
}
|
190 |
+
} );
|
191 |
+
},
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Show or hide post types
|
195 |
+
*
|
196 |
+
* @since 3.0
|
197 |
+
* @return null
|
198 |
+
*/
|
199 |
+
_togglePostTypes: function () {
|
200 |
+
if ( $( 'input[name="ditty_layout_ui"]' ).length ) {
|
201 |
+
var layoutUiVal = $( 'input[name="ditty_layout_ui"]:checked' ).val(),
|
202 |
+
$layoutMenu = $( '#adminmenu .wp-submenu > li > a[href="edit.php?post_type=ditty_layout"]' );
|
203 |
+
if ( 'disabled' === layoutUiVal ) {
|
204 |
+
$layoutMenu.hide();
|
205 |
+
} else {
|
206 |
+
$layoutMenu.css( 'display', 'block' );
|
207 |
+
}
|
208 |
+
}
|
209 |
+
if ( $( 'input[name="ditty_display_ui"]' ).length ) {
|
210 |
+
var displayUiVal = $( 'input[name="ditty_display_ui"]:checked' ).val(),
|
211 |
+
$displayMenu = $( '#adminmenu .wp-submenu > li > a[href="edit.php?post_type=ditty_display"]' );
|
212 |
+
if ( 'disabled' === displayUiVal ) {
|
213 |
+
$displayMenu.hide();
|
214 |
+
} else {
|
215 |
+
$displayMenu.css( 'display', 'block' );
|
216 |
+
}
|
217 |
+
}
|
218 |
+
},
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Activate a panel
|
222 |
+
*
|
223 |
+
* @since 3.0.13
|
224 |
+
* @return null
|
225 |
+
*/
|
226 |
+
_activatePanel: function( panelId ) {
|
227 |
+
var $tab = this.$elmt.find( '.ditty-settings__tab[data-panel="' + panelId + '"]' );
|
228 |
+
if ( ! $tab.length ) {
|
229 |
+
return false;
|
230 |
+
}
|
231 |
+
|
232 |
+
this.$elmt.find( '.ditty-settings__tab' ).removeClass( 'active' );
|
233 |
+
$tab.addClass( 'active' );
|
234 |
+
|
235 |
+
this.$panels.ditty_slider( 'showSlideById', panelId );
|
236 |
+
},
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Listen for a tab click
|
240 |
+
*
|
241 |
+
* @since 3.0
|
242 |
+
* @return null
|
243 |
+
*/
|
244 |
+
_tabClick: function( e ) {
|
245 |
+
e.preventDefault();
|
246 |
+
var self = e.data.self,
|
247 |
+
$tab = $( e.target ).is( 'a' ) ? $( e.target ) : $( e.target ).parent( 'a' ),
|
248 |
+
slideId = $tab.data( 'panel' ),
|
249 |
+
$currentTab = self.$elmt.find( '.ditty-settings__tab.active' );
|
250 |
+
|
251 |
+
if ( $currentTab === $tab ) {
|
252 |
+
return false;
|
253 |
+
}
|
254 |
+
|
255 |
+
var newUrl;
|
256 |
+
if ( slideId ) {
|
257 |
+
var hash = '#' + slideId;
|
258 |
+
newUrl = self.url.split("#")[0] + hash;
|
259 |
+
} else {
|
260 |
+
newUrl = self.url.split("#")[0];
|
261 |
+
}
|
262 |
+
history.replaceState( null, null, newUrl );
|
263 |
+
|
264 |
+
self._activatePanel( slideId );
|
265 |
+
},
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Update inputs after save and sanitize
|
269 |
+
*
|
270 |
+
* @since 3.0
|
271 |
+
* @return null
|
272 |
+
*/
|
273 |
+
_upateInputs: function( updates ) {
|
274 |
+
$.each( updates, function( inputName, updatedValue ) {
|
275 |
+
if ( $( 'input[name="' + inputName + '"]' ).length ) {
|
276 |
+
$( 'input[name="' + inputName + '"]' ).val( updatedValue );
|
277 |
+
}
|
278 |
+
} );
|
279 |
+
},
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Submit updates
|
283 |
+
*
|
284 |
+
* @since 3.0
|
285 |
+
* @return null
|
286 |
+
*/
|
287 |
+
_submitForm: function( e ) {
|
288 |
+
e.preventDefault();
|
289 |
+
var self = e.data.self;
|
290 |
+
|
291 |
+
if ( self.$elmt.hasClass( 'updating' ) ) {
|
292 |
+
return false;
|
293 |
+
}
|
294 |
+
|
295 |
+
self.$elmt.trigger( 'ditty_pre_save_fields' );
|
296 |
+
self.$elmt.addClass( 'updating' );
|
297 |
+
self.saveBtns.text( dittyAdminVars.adminStrings.settingsSaving );
|
298 |
+
|
299 |
+
self.$form.ajaxSubmit( {
|
300 |
+
url : dittyAdminVars.ajaxurl,
|
301 |
+
type : 'post',
|
302 |
+
dataType : 'json',
|
303 |
+
data : {
|
304 |
+
action : 'ditty_settings_save',
|
305 |
+
security : dittyAdminVars.security
|
306 |
+
},
|
307 |
+
success: function( data ) {
|
308 |
+
if ( data.input_updates ) {
|
309 |
+
self._upateInputs( data.input_updates );
|
310 |
+
}
|
311 |
+
self.initData = self.$form.serialize();
|
312 |
+
self.saveBtns.text( dittyAdminVars.adminStrings.settings_updated );
|
313 |
+
setTimeout( function() {
|
314 |
+
self.saveBtns.text( dittyAdminVars.adminStrings.settings_save );
|
315 |
+
}, 2000 );
|
316 |
+
self.$elmt.removeClass( 'updating' );
|
317 |
+
self._disableSettingsUpdates();
|
318 |
+
|
319 |
+
//self.$notice_update.slideDown();
|
320 |
+
|
321 |
+
// Check the post types display
|
322 |
+
self._togglePostTypes();
|
323 |
+
}
|
324 |
+
} );
|
325 |
+
},
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Install a layout
|
329 |
+
*
|
330 |
+
* @since 3.0
|
331 |
+
* @return null
|
332 |
+
*/
|
333 |
+
_installLayout: function( e ) {
|
334 |
+
e.preventDefault();
|
335 |
+
var self = e.data.self,
|
336 |
+
$button = $( e.target ).is( 'button' ) ? $( e.target ) : $( e.target ).parents( 'button' ),
|
337 |
+
$icon = $button.find( 'i' ),
|
338 |
+
iconClass = $icon.attr( 'class' );
|
339 |
+
|
340 |
+
if ( $button.hasClass( 'updating' ) ) {
|
341 |
+
return false;
|
342 |
+
}
|
343 |
+
$button.addClass( 'updating' );
|
344 |
+
$icon.attr( 'class', dittyAdminVars.updateIcon );
|
345 |
+
|
346 |
+
var data = {
|
347 |
+
action : 'ditty_install_layout',
|
348 |
+
layout_template : $button.data( 'layout_template' ),
|
349 |
+
layout_version : $button.data( 'layout_version' ),
|
350 |
+
security : dittyAdminVars.security
|
351 |
+
};
|
352 |
+
$.post( dittyAdminVars.ajaxurl, data, function( response ) {
|
353 |
+
$icon.attr( 'class', iconClass );
|
354 |
+
self.$elmt.removeClass( 'updating' );
|
355 |
+
if ( response ) {
|
356 |
+
$button.replaceWith( response.button );
|
357 |
+
}
|
358 |
+
} );
|
359 |
+
},
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Install a display
|
363 |
+
*
|
364 |
+
* @since 3.0
|
365 |
+
* @return null
|
366 |
+
*/
|
367 |
+
_installDisplay: function( e ) {
|
368 |
+
e.preventDefault();
|
369 |
+
var self = e.data.self,
|
370 |
+
$button = $( e.target ).is( 'button' ) ? $( e.target ) : $( e.target ).parents( 'button' ),
|
371 |
+
$icon = $button.find( 'i' ),
|
372 |
+
iconClass = $icon.attr( 'class' );
|
373 |
+
|
374 |
+
if ( $button.hasClass( 'updating' ) ) {
|
375 |
+
return false;
|
376 |
+
}
|
377 |
+
$button.addClass( 'updating' );
|
378 |
+
$icon.attr( 'class', dittyAdminVars.updateIcon );
|
379 |
+
|
380 |
+
var data = {
|
381 |
+
action : 'ditty_install_display',
|
382 |
+
display_type : $button.data( 'display_type' ),
|
383 |
+
display_template : $button.data( 'display_template' ),
|
384 |
+
display_version : $button.data( 'display_version' ),
|
385 |
+
security : dittyAdminVars.security
|
386 |
+
};
|
387 |
+
$.post( dittyAdminVars.ajaxurl, data, function( response ) {
|
388 |
+
$icon.attr( 'class', iconClass );
|
389 |
+
self.$elmt.removeClass( 'updating' );
|
390 |
+
if ( response ) {
|
391 |
+
$button.replaceWith( response.button );
|
392 |
+
}
|
393 |
+
} );
|
394 |
+
},
|
395 |
+
|
396 |
+
/**
|
397 |
+
* Export posts
|
398 |
+
*
|
399 |
+
* @since 3.0.13
|
400 |
+
* @return null
|
401 |
+
*/
|
402 |
+
// _exportPosts: function( e ) {
|
403 |
+
// e.preventDefault();
|
404 |
+
// var self = e.data.self,
|
405 |
+
// $button = $( e.target ).is( 'button' ) ? $( e.target ) : $( e.target ).parents( 'button' ),
|
406 |
+
// $parent = $button.parent( '.ditty-field-only' ),
|
407 |
+
// $options = $parent.siblings( '.ditty-field-only--ditty_export_options' ),
|
408 |
+
// $icon = $button.find( 'i' ),
|
409 |
+
// export_options = [];
|
410 |
+
//
|
411 |
+
// if ( $button.attr( 'disabled' ) ) {
|
412 |
+
// return false;
|
413 |
+
// }
|
414 |
+
// $button.attr( 'disabled', 'disabled' );
|
415 |
+
// $icon.show();
|
416 |
+
//
|
417 |
+
// if ( $options.length ) {
|
418 |
+
// $options.find( 'input[type="checkbox"]' ).each( function() {
|
419 |
+
// if ( $( this ).is( ':checked' ) ) {
|
420 |
+
// export_options.push( $( this ).val() );
|
421 |
+
// }
|
422 |
+
// } );
|
423 |
+
// }
|
424 |
+
//
|
425 |
+
// var data = {
|
426 |
+
// action : 'ditty_export_posts',
|
427 |
+
// export_type : $button.data( 'export_type' ),
|
428 |
+
// export_options : export_options,
|
429 |
+
// security : dittyAdminVars.security
|
430 |
+
// };
|
431 |
+
// $.post( dittyAdminVars.ajaxurl, data, function( response ) {
|
432 |
+
// $icon.hide();
|
433 |
+
// self.$elmt.removeAttr( 'disabled' );
|
434 |
+
// } );
|
435 |
+
// },
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Return a specific setting
|
439 |
+
*
|
440 |
+
* @since 3.0
|
441 |
+
* @return null
|
442 |
+
*/
|
443 |
+
_options: function ( key ) {
|
444 |
+
return this.settings[key];
|
445 |
+
},
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Setup triggers
|
449 |
+
*
|
450 |
+
* @since 3.0
|
451 |
+
* @return null
|
452 |
+
*/
|
453 |
+
trigger: function ( fn, customParams ) {
|
454 |
+
var params = [this.settings];
|
455 |
+
if ( customParams ) {
|
456 |
+
params = customParams;
|
457 |
+
}
|
458 |
+
|
459 |
+
this.$elmt.trigger( 'ditty_settings_' + fn, params );
|
460 |
+
|
461 |
+
if ( typeof this.settings[fn] === 'function' ) {
|
462 |
+
this.settings[fn].apply( this.$elmt, params );
|
463 |
+
}
|
464 |
+
},
|
465 |
+
|
466 |
+
/**
|
467 |
+
* Allow settings to be modified
|
468 |
+
*
|
469 |
+
* @since 3.0
|
470 |
+
* @return null
|
471 |
+
*/
|
472 |
+
options: function ( key, value ) {
|
473 |
+
|
474 |
+
if ( typeof key === 'object' ) {
|
475 |
+
this.settings = $.extend( {}, defaults, $.ditty_settings.defaults, key );
|
476 |
+
} else if ( typeof key === 'string' ) {
|
477 |
+
if ( value === undefined ) {
|
478 |
+
return this.settings[key];
|
479 |
+
}
|
480 |
+
this.settings[key] = value;
|
481 |
+
} else {
|
482 |
+
return this.settings;
|
483 |
+
}
|
484 |
+
|
485 |
+
this.trigger( 'options_update' );
|
486 |
+
},
|
487 |
+
|
488 |
+
/**
|
489 |
+
* Destroy the editor
|
490 |
+
*
|
491 |
+
* @since 3.0
|
492 |
+
* @return null
|
493 |
+
*/
|
494 |
+
destroy: function () {
|
495 |
+
|
496 |
+
// Remove listeners
|
497 |
+
$( 'body' ).off( 'ditty_field_clone_update', { self: this }, this._enableSettingsUpdates );
|
498 |
+
this.saveBtns.off( 'click', { self: this }, this._submitForm );
|
499 |
+
this.tabs.off( 'click', { self: this }, this._tabClick );
|
500 |
+
this.$panels.off( 'ditty_slider_init', { self: this }, this._sliderInit );
|
501 |
+
this.$panels.off( 'ditty_slider_before_slide_update', { self: this }, this._beforeSlideUpdate );
|
502 |
+
this.$form.off( 'keyup change', 'input[type="text"], input[type="number"], textarea, select', { self: this }, this._checkUpdates );
|
503 |
+
this.$form.off( 'click', 'input[type="radio"], input[type="checkbox"]', { self: this }, this._checkUpdates );
|
504 |
+
this.$form.off( 'ditty_input_wysiwyg_update', '.ditty-input--wysiwyg', { self: this }, this._checkUpdates );
|
505 |
+
this.$form.off( 'click', '.ditty-default-layout-install', { self: this }, this._installLayout );
|
506 |
+
this.$form.off( 'click', '.ditty-default-display-install', { self: this }, this._installDisplay );
|
507 |
+
//this.$form.off( 'click', 'button[name="ditty_export_button"]', { self: this }, this._exportPosts );
|
508 |
+
|
509 |
+
this.$panels.ditty_slider( 'destroy' );
|
510 |
+
this.elmt._ditty_settings = null;
|
511 |
+
}
|
512 |
+
};
|
513 |
+
|
514 |
+
/**
|
515 |
+
* Create the data list
|
516 |
+
*
|
517 |
+
* @since 3.0
|
518 |
+
* @return null
|
519 |
+
*/
|
520 |
+
$.fn.ditty_settings = function( options ) {
|
521 |
+
var args = arguments,
|
522 |
+
error = false,
|
523 |
+
returns;
|
524 |
+
|
525 |
+
if ( options === undefined || typeof options === 'object' ) {
|
526 |
+
return this.each( function () {
|
527 |
+
if ( ! this._ditty_settings ) {
|
528 |
+
this._ditty_settings = new Ditty_Settings( this, options );
|
529 |
+
}
|
530 |
+
});
|
531 |
+
} else if ( typeof options === 'string' ) {
|
532 |
+
this.each( function () {
|
533 |
+
var instance = this._ditty_settings;
|
534 |
+
|
535 |
+
if ( ! instance ) {
|
536 |
+
throw new Error( 'No Ditty_Settings applied to this element.' );
|
537 |
+
}
|
538 |
+
if ( typeof instance[options] === 'function' && options[0] !== '_' ) {
|
539 |
+
returns = instance[options].apply( instance, [].slice.call( args, 1 ) );
|
540 |
+
} else {
|
541 |
+
error = true;
|
542 |
+
}
|
543 |
+
} );
|
544 |
+
|
545 |
+
if ( error ) {
|
546 |
+
throw new Error( 'No method "' + options + '" in Ditty_Settings.' );
|
547 |
+
}
|
548 |
+
|
549 |
+
return returns !== undefined ? returns : this;
|
550 |
+
}
|
551 |
+
};
|
552 |
+
|
553 |
+
$.ditty_settings = {};
|
554 |
+
$.ditty_settings.defaults = defaults;
|
555 |
+
|
556 |
+
} )( jQuery );
|
557 |
+
|
558 |
+
|
559 |
+
/**
|
560 |
+
* Ditty Extension class
|
561 |
+
*
|
562 |
+
* @since 3.0
|
563 |
+
* @return null
|
564 |
+
*/
|
565 |
+
|
566 |
+
(function ($) {
|
567 |
+
'use strict';
|
568 |
+
|
569 |
+
var defaults = {
|
570 |
+
};
|
571 |
+
|
572 |
+
var Ditty_Extension = function ( elmt, options ) {
|
573 |
+
|
574 |
+
this.elmt = elmt;
|
575 |
+
this.settings = $.extend( {}, defaults, $.ditty_extension.defaults, options );
|
576 |
+
this.$elmt = $( elmt );
|
577 |
+
this.$panels = $( elmt ).find( '.ditty-extension__panels' );
|
578 |
+
this.initPanel = this.$panels.data( 'init_panel' );
|
579 |
+
|
580 |
+
this._init();
|
581 |
+
};
|
582 |
+
|
583 |
+
Ditty_Extension.prototype = {
|
584 |
+
|
585 |
+
_init: function () {
|
586 |
+
|
587 |
+
// Add listeners
|
588 |
+
this.$elmt.on( 'click', '.ditty-extension__tab', { self: this }, this._tabClick );
|
589 |
+
this.$elmt.on( 'click', 'button[name="submit"]', { self: this }, this._updatePanel );
|
590 |
+
this.$elmt.on( 'click', '.ditty-extension__license__submit', { self: this, action: 'ditty_extension_license_activate' }, this._licenseUpdate );
|
591 |
+
this.$elmt.on( 'click', '.ditty-extension__license__refresh', { self: this, action: 'ditty_extension_license_refresh' }, this._licenseUpdate );
|
592 |
+
this.$elmt.on( 'click', '.ditty-extension__license__deactivate', { self: this, action: 'ditty_extension_license_deactivate' }, this._licenseUpdate );
|
593 |
+
this.$panels.on( 'ditty_slider_before_slide_update', { self: this }, this._beforePanelUpdate );
|
594 |
+
this._initSlider();
|
595 |
+
},
|
596 |
+
|
597 |
+
/**
|
598 |
+
* Initialize the slider
|
599 |
+
*
|
600 |
+
* @since 3.0
|
601 |
+
* @return null
|
602 |
+
*/
|
603 |
+
_initSlider: function () {
|
604 |
+
var args = {
|
605 |
+
transition : 'fade',
|
606 |
+
transitionSpeed : 0.75,
|
607 |
+
heightSpeed : 0.75,
|
608 |
+
touchSwipe : false,
|
609 |
+
slidesEl : '.ditty-extension__panel',
|
610 |
+
slideId : ( '' !== this.initPanel ) ? this.initPanel : false
|
611 |
+
};
|
612 |
+
this.$panels.ditty_slider( args );
|
613 |
+
},
|
614 |
+
|
615 |
+
/**
|
616 |
+
* Initialize the slider
|
617 |
+
*
|
618 |
+
* @since 3.0
|
619 |
+
* @return null
|
620 |
+
*/
|
621 |
+
_beforePanelUpdate: function ( e, index, slide ) {
|
622 |
+
var self = e.data.self;
|
623 |
+
self.$elmt.find( '.ditty-extension__tab' ).removeClass( 'active' );
|
624 |
+
self.$elmt.find( '.ditty-extension__tab[data-slide_id="' + slide.id + '"]' ).addClass( 'active' );
|
625 |
+
},
|
626 |
+
|
627 |
+
/**
|
628 |
+
* Tab click
|
629 |
+
*
|
630 |
+
* @since 3.0
|
631 |
+
* @return null
|
632 |
+
*/
|
633 |
+
_tabClick: function ( e ) {
|
634 |
+
e.preventDefault();
|
635 |
+
var self = e.data.self;
|
636 |
+
var $tab = $( this ),
|
637 |
+
slideId = $tab.data( 'slide_id' ),
|
638 |
+
transition = 'slideLeft',
|
639 |
+
$currentTab = self.$elmt.find( '.ditty-extension__tab.active' );
|
640 |
+
|
641 |
+
if ( $currentTab === $tab ) {
|
642 |
+
return false;
|
643 |
+
}
|
644 |
+
|
645 |
+
if ( $tab.index() < $currentTab.index() ) {
|
646 |
+
transition = 'slideRight';
|
647 |
+
}
|
648 |
+
|
649 |
+
//self.$elmt.find( '.ditty-extension__tab' ).removeClass( 'active' );
|
650 |
+
//$tab.addClass( 'active' );
|
651 |
+
|
652 |
+
self.$panels.ditty_slider( 'options', 'transition', transition );
|
653 |
+
self.$panels.ditty_slider( 'showSlideById', slideId );
|
654 |
+
},
|
655 |
+
|
656 |
+
/**
|
657 |
+
* Panel update listener
|
658 |
+
*
|
659 |
+
* @since 3.0
|
660 |
+
* @return null
|
661 |
+
*/
|
662 |
+
_updatePanel: function ( e ) {
|
663 |
+
e.preventDefault();
|
664 |
+
var self = e.data.self;
|
665 |
+
|
666 |
+
var $button = $( this ),
|
667 |
+
$panel = $button.parents( '.ditty-extension__panel' ),
|
668 |
+
$form = $button.parents( '.ditty-extension__form' ),
|
669 |
+
$icon = $button.find( 'i' ),
|
670 |
+
iconClass = $icon.attr( 'class' ),
|
671 |
+
extension = self.$elmt.data( 'extension' ),
|
672 |
+
panel = $panel.data( 'slide_id' );
|
673 |
+
|
674 |
+
if ( self.$elmt.hasClass( 'updating' ) ) {
|
675 |
+
return false;
|
676 |
+
}
|
677 |
+
|
678 |
+
self.$elmt.addClass( 'updating' );
|
679 |
+
$icon.attr( 'class', dittyAdminVars.updateIcon );
|
680 |
+
|
681 |
+
$form.ajaxSubmit( {
|
682 |
+
url : dittyAdminVars.ajaxurl,
|
683 |
+
type : 'post',
|
684 |
+
dataType : 'json',
|
685 |
+
data : {
|
686 |
+
action : 'ditty_extension_panel_update',
|
687 |
+
extension : extension,
|
688 |
+
panel : panel,
|
689 |
+
security : dittyAdminVars.security
|
690 |
+
},
|
691 |
+
success: function( response ) {
|
692 |
+
$icon.attr( 'class', iconClass );
|
693 |
+
self.$elmt.removeClass( 'updating' );
|
694 |
+
$( '#ditty-extensions' ).trigger( 'ditty_extension_panel_updated', [ response, self.$elmt, $panel ] );
|
695 |
+
}
|
696 |
+
} );
|
697 |
+
},
|
698 |
+
|
699 |
+
/**
|
700 |
+
* Update a license
|
701 |
+
*
|
702 |
+
* @since 3.0
|
703 |
+
* @return null
|
704 |
+
*/
|
705 |
+
_licenseUpdate: function ( e ) {
|
706 |
+
e.preventDefault();
|
707 |
+
var self = e.data.self,
|
708 |
+
action = e.data.action;
|
709 |
+
|
710 |
+
var $button = $( this ),
|
711 |
+
$message = self.$elmt.find( '.ditty-extension__license__message' ),
|
712 |
+
$input = $button.siblings( '.ditty-extension__license__input' ),
|
713 |
+
license = $input.val(),
|
714 |
+
extension = $button.data( 'extension' ),
|
715 |
+
extensionId = $button.data( 'extension_id' ),
|
716 |
+
extensionName = $button.data( 'extension_name' ),
|
717 |
+
$icon = $button.children( 'i' );
|
718 |
+
|
719 |
+
if ( self.$elmt.hasClass( 'updating' ) ) {
|
720 |
+
return false;
|
721 |
+
}
|
722 |
+
|
723 |
+
self.$elmt.addClass( 'updating' );
|
724 |
+
$icon.attr( 'class', dittyAdminVars.updateIcon );
|
725 |
+
|
726 |
+
// Load the new display data
|
727 |
+
var data = {
|
728 |
+
action : action,
|
729 |
+
license : license,
|
730 |
+
extension : extension,
|
731 |
+
extension_id : extensionId,
|
732 |
+
extension_name : extensionName,
|
733 |
+
security : dittyAdminVars.security
|
734 |
+
};
|
735 |
+
$.post( dittyAdminVars.ajaxurl, data, function( response ) {
|
736 |
+
if ( response ) {
|
737 |
+
self.$elmt.attr( 'data-license_status', response.status );
|
738 |
+
$message.html( response.message );
|
739 |
+
}
|
740 |
+
if ( response.license_key ) {
|
741 |
+
if ( 'DELETE' === response.license_key ) {
|
742 |
+
$input.val( '' );
|
743 |
+
} else {
|
744 |
+
$input.val( response.license_key );
|
745 |
+
}
|
746 |
+
}
|
747 |
+
$icon.attr( 'class', $icon.data( 'class' ) );
|
748 |
+
self.$elmt.removeClass( 'updating' );
|
749 |
+
}, 'json' );
|
750 |
+
},
|
751 |
+
|
752 |
+
/**
|
753 |
+
* Return data for the object
|
754 |
+
*
|
755 |
+
* @since 3.0
|
756 |
+
* @return null
|
757 |
+
*/
|
758 |
+
_getOption: function( key ) {
|
759 |
+
switch( key ) {
|
760 |
+
default:
|
761 |
+
return this.settings[key];
|
762 |
+
}
|
763 |
+
},
|
764 |
+
|
765 |
+
/**
|
766 |
+
* Set data for the object
|
767 |
+
*
|
768 |
+
* @since 3.0
|
769 |
+
* @return null
|
770 |
+
*/
|
771 |
+
_setOption: function( key, value ) {
|
772 |
+
if ( undefined === value ) {
|
773 |
+
return false;
|
774 |
+
}
|
775 |
+
|
776 |
+
this.settings[key] = value;
|
777 |
+
},
|
778 |
+
|
779 |
+
/**
|
780 |
+
* Get or set ditty options
|
781 |
+
*
|
782 |
+
* @since 3.0
|
783 |
+
* @return null
|
784 |
+
*/
|
785 |
+
options: function ( key, value ) {
|
786 |
+
var self = this;
|
787 |
+
if ( typeof key === 'object' ) {
|
788 |
+
$.each( key, function( k, v ) {
|
789 |
+
self._setOption( k, v );
|
790 |
+
});
|
791 |
+
} else if ( typeof key === 'string' ) {
|
792 |
+
if ( value === undefined ) {
|
793 |
+
return self._getOption( key );
|
794 |
+
}
|
795 |
+
self._setOption( key, value );
|
796 |
+
} else {
|
797 |
+
return self.settings;
|
798 |
+
}
|
799 |
+
},
|
800 |
+
|
801 |
+
/**
|
802 |
+
* Destroy this object
|
803 |
+
*
|
804 |
+
* @since 3.0
|
805 |
+
* @return null
|
806 |
+
*/
|
807 |
+
destroy: function () {
|
808 |
+
// Remove listeners
|
809 |
+
this.$elmt.off( 'click', '.ditty-extension__tab', { self: this }, this._tabClick );
|
810 |
+
this.$elmt.off( 'click', 'button[name="submit"]', { self: this }, this._updatePanel );
|
811 |
+
this.$elmt.off( 'click', '.ditty-extension__license__submit, .ditty-extension__license__refresh', { self: this, action: 'ditty_extension_license_activate' }, this._licenseUpdate );
|
812 |
+
this.$elmt.off( 'click', '.ditty-extension__license__deactivate', { self: this, action: 'ditty_extension_license_deactivate' }, this._licenseUpdate );
|
813 |
+
this.$panels.off( 'ditty_slider_after_slide_update', { self: this }, this._afterPanelUpdate );
|
814 |
+
|
815 |
+
this.$panels.ditty_slider( 'destroy' );
|
816 |
+
this.elmt._ditty_extension = null;
|
817 |
+
}
|
818 |
+
};
|
819 |
+
|
820 |
+
$.fn.ditty_extension = function( options ) {
|
821 |
+
var args = arguments,
|
822 |
+
error = false,
|
823 |
+
returns;
|
824 |
+
|
825 |
+
if ( options === undefined || typeof options === 'object' ) {
|
826 |
+
return this.each( function () {
|
827 |
+
if ( ! this._ditty_extension ) {
|
828 |
+
this._ditty_extension = new Ditty_Extension( this, options );
|
829 |
+
}
|
830 |
+
});
|
831 |
+
} else if ( typeof options === 'string' ) {
|
832 |
+
this.each( function () {
|
833 |
+
var instance = this._ditty_extension;
|
834 |
+
|
835 |
+
if ( ! instance ) {
|
836 |
+
throw new Error( 'No Ditty_Extension applied to this element.' );
|
837 |
+
}
|
838 |
+
if ( typeof instance[options] === 'function' && options[0] !== '_' ) {
|
839 |
+
returns = instance[options].apply( instance, [].slice.call( args, 1 ) );
|
840 |
+
} else {
|
841 |
+
error = true;
|
842 |
+
}
|
843 |
+
} );
|
844 |
+
|
845 |
+
if ( error ) {
|
846 |
+
throw new Error( 'No method "' + options + '" in Ditty_Extension.' );
|
847 |
+
}
|
848 |
+
|
849 |
+
return returns !== undefined ? returns : this;
|
850 |
+
}
|
851 |
+
};
|
852 |
+
|
853 |
+
$.ditty_extension = {};
|
854 |
+
$.ditty_extension.defaults = defaults;
|
855 |
+
|
856 |
+
} )( jQuery );
|
857 |
+
|
858 |
+
|
859 |
+
|
860 |
+
jQuery( function( $ ) {
|
861 |
+
// Setup strict mode
|
862 |
+
(function() {
|
863 |
+
|
864 |
+
"use strict";
|
865 |
+
|
866 |
+
// Setup protip
|
867 |
+
$.protip( {
|
868 |
+
defaults: {
|
869 |
+
position: 'top',
|
870 |
+
size: 'small',
|
871 |
+
scheme: 'black',
|
872 |
+
classes: 'ditty-protip'
|
873 |
+
}
|
874 |
+
} );
|
875 |
+
|
876 |
+
/**
|
877 |
+
* Listen for an accordion toggle click
|
878 |
+
*
|
879 |
+
* @since 3.0
|
880 |
+
* @return null
|
881 |
+
*/
|
882 |
+
// $( '#ditty-extensions' ).on( 'click', '.ditty-accordion__toggle', function( e ) {
|
883 |
+
// e.preventDefault();
|
884 |
+
// var $accordion = $( this ).parent(),
|
885 |
+
// $content = $( this ).next();
|
886 |
+
//
|
887 |
+
// if ( $accordion.hasClass( 'active' ) ) {
|
888 |
+
// $accordion.removeClass( 'active' );
|
889 |
+
// $content.stop().slideUp( { duration: 750, easing: "easeInOutQuint" } );
|
890 |
+
// } else {
|
891 |
+
// $accordion.addClass( 'active' );
|
892 |
+
// $content.stop().slideDown( { duration: 750, easing: "easeInOutQuint" }, function() {
|
893 |
+
// $content.css( 'height', 'auto' );
|
894 |
+
// } );
|
895 |
+
// }
|
896 |
+
// } );
|
897 |
+
//
|
898 |
+
/**
|
899 |
+
* Initialize the extensions
|
900 |
+
*
|
901 |
+
* @since 3.0
|
902 |
+
* @return null
|
903 |
+
*/
|
904 |
+
function ditty_extensions_init() {
|
905 |
+
$( '#ditty-extensions' ).find( '.ditty-extension' ).each( function( index ) {
|
906 |
+
|
907 |
+
var $extension = $( this ),
|
908 |
+
$panels = $extension.find( '.ditty-extension__panels' );
|
909 |
+
|
910 |
+
if ( $panels.length ) {
|
911 |
+
$extension.ditty_extension();
|
912 |
+
}
|
913 |
+
|
914 |
+
$( '#ditty-extensions' ).trigger( 'ditty_init_fields' );
|
915 |
+
|
916 |
+
setTimeout( function() {
|
917 |
+
$extension.addClass( 'ditty-extension--init' );
|
918 |
+
}, index * 250 );
|
919 |
+
|
920 |
+
} );
|
921 |
+
}
|
922 |
+
ditty_extensions_init();
|
923 |
+
|
924 |
+
}() );
|
925 |
+
|
926 |
+
} );
|
927 |
+
|
928 |
+
|
929 |
+
jQuery( function( $ ) {
|
930 |
+
// Setup strict mode
|
931 |
+
(function() {
|
932 |
+
|
933 |
+
"use strict";
|
934 |
+
|
935 |
+
var isDisplayPost = ( $( 'input[name="post_type"]' ).length && 'ditty_display' == $( 'input[name="post_type"]' ).val() ),
|
936 |
+
ajaxSubmitComplete = false;
|
937 |
+
|
938 |
+
$( 'form#post' ).on( 'submit', function( e ) {
|
939 |
+
if ( isDisplayPost && ! ajaxSubmitComplete ) {
|
940 |
+
e.preventDefault();
|
941 |
+
|
942 |
+
var $button = $( '#publishing-action' ).children( 'input[type="submit"]' ),
|
943 |
+
$spinner = $( '#publishing-action' ).children( '.spinner' );
|
944 |
+
|
945 |
+
$button.attr( 'disabled', 'disabled' );
|
946 |
+
$spinner.css( 'visibility', 'visible' );
|
947 |
+
|
948 |
+
var data = {
|
949 |
+
action : 'ditty_admin_display_update',
|
950 |
+
display_id : $( 'input[name="post_ID"]' ).val(),
|
951 |
+
security : dittyAdminVars.security
|
952 |
+
};
|
953 |
+
$( '#ditty-display-settings' ).ajaxSubmit( {
|
954 |
+
url : dittyAdminVars.ajaxurl,
|
955 |
+
type : 'post',
|
956 |
+
dataType : 'json',
|
957 |
+
data : data,
|
958 |
+
success: function( response ) {
|
959 |
+
ajaxSubmitComplete = true;
|
960 |
+
$( 'form#post' ).submit();
|
961 |
+
}
|
962 |
+
} );
|
963 |
+
}
|
964 |
+
} );
|
965 |
+
|
966 |
+
}() );
|
967 |
+
|
968 |
+
} );
|
969 |
+
|
970 |
+
|
971 |
+
jQuery( function( $ ) {
|
972 |
+
// Setup strict mode
|
973 |
+
(function() {
|
974 |
+
|
975 |
+
"use strict";
|
976 |
+
|
977 |
+
var dittyWizardValues = {};
|
978 |
+
|
979 |
+
/**
|
980 |
+
* Ditty title
|
981 |
+
*
|
982 |
+
* @since 3.0.13
|
983 |
+
*/
|
984 |
+
$( '.ditty-wizard-setting--title input[name="ditty_title"]' ).on( 'keyup', function() {
|
985 |
+
var $setting = $( this ).parents( '.ditty-wizard-setting' ),
|
986 |
+
val = $( this ).val();
|
987 |
+
|
988 |
+
if ( '' !== val ) {
|
989 |
+
$setting.addClass( 'complete' );
|
990 |
+
|
991 |
+
// Show the layout settings
|
992 |
+
$( '.ditty-wizard-setting--item-type').css( 'display', 'flex' );
|
993 |
+
}
|
994 |
+
dittyWizardValues.title = val;
|
995 |
+
} );
|
996 |
+
|
997 |
+
/**
|
998 |
+
* Item Type
|
999 |
+
*
|
1000 |
+
* @since 3.0.13
|
1001 |
+
*/
|
1002 |
+
$( '.ditty-wizard-setting--item-type .ditty-option-grid__item' ).on( 'click', function( e ) {
|
1003 |
+
e.preventDefault();
|
1004 |
+
var $setting = $( this ).parents( '.ditty-wizard-setting' ),
|
1005 |
+
slug = $( this ).data( 'value' );
|
1006 |
+
|
1007 |
+
if ( ! $( this ).hasClass( 'active' ) ) {
|
1008 |
+
|
1009 |
+
$( this ).siblings().removeClass( 'active' );
|
1010 |
+
$( this ).addClass( 'active' );
|
1011 |
+
|
1012 |
+
// Reset & show item type settings
|
1013 |
+
$( '.ditty-wizard-setting--item-type-settings' ).removeClass( 'complete' );
|
1014 |
+
$( '.ditty-wizard-setting--item-type-settings .ditty-option-submit' ).addClass( 'ditty-button--primary' );
|
1015 |
+
$( '.ditty-wizard-setting--item-type-settings').css( 'display', 'flex' );
|
1016 |
+
|
1017 |
+
// Display the correct item type settings group
|
1018 |
+
var $itemSettings = $( '.ditty-item-type-settings__group[data-id="' + slug + '"]' );
|
1019 |
+
$( '.ditty-item-type-settings__group' ).removeClass( 'active' ).hide();
|
1020 |
+
$itemSettings.addClass( 'active' ).show();
|
1021 |
+
$itemSettings.trigger( 'ditty_init_fields' );
|
1022 |
+
if ( ! $itemSettings.hasClass( 'init' ) ) {
|
1023 |
+
$itemSettings.trigger( 'ditty_wizard_init', [slug] );
|
1024 |
+
$itemSettings.addClass( 'init' );
|
1025 |
+
}
|
1026 |
+
|
1027 |
+
// Reset the layout settings
|
1028 |
+
$( '.ditty-wizard-setting--layout' ).removeClass( 'complete' );
|
1029 |
+
$( '.ditty-wizard-setting--layout .ditty-option-grid__item' ).removeClass( 'active' );
|
1030 |
+
$( '.ditty-wizard-setting--layout').hide();
|
1031 |
+
|
1032 |
+
// Display the correct layout variation settings group
|
1033 |
+
$( '.ditty-wizard-setting--layout__variation' ).removeClass( 'complete' ).removeClass( 'active' ).hide();
|
1034 |
+
$( '.ditty-wizard-setting--layout__variation.' + slug ).addClass( 'active' ).show();
|
1035 |
+
|
1036 |
+
// Reset the display settings
|
1037 |
+
$( '.ditty-wizard-setting--display' ).removeClass( 'complete' );
|
1038 |
+
$( '.ditty-wizard-setting--display .ditty-option-grid__item' ).removeClass( 'active' );
|
1039 |
+
$( '.ditty-wizard-setting--display').hide();
|
1040 |
+
|
1041 |
+
// Reset the submit settings
|
1042 |
+
$( '.ditty-wizard-setting--submit').hide();
|
1043 |
+
|
1044 |
+
// Add to the initialize object
|
1045 |
+
dittyWizardValues.itemType = $( this ).data( 'value' );
|
1046 |
+
|
1047 |
+
// Animate to the next setting
|
1048 |
+
if ( ! $setting.hasClass( 'complete' ) ) {
|
1049 |
+
$setting.addClass( 'complete' );
|
1050 |
+
$( [document.documentElement, document.body] ).stop().animate( {
|
1051 |
+
scrollTop: $( '.ditty-wizard-setting--item-type-settings' ).offset().top
|
1052 |
+
}, 700 );
|
1053 |
+
}
|
1054 |
+
}
|
1055 |
+
} );
|
1056 |
+
|
1057 |
+
/**
|
1058 |
+
* Item Type Settings Submit
|
1059 |
+
*
|
1060 |
+
* @since 3.0.13
|
1061 |
+
*/
|
1062 |
+
$( '.ditty-wizard-setting--item-type-settings .ditty-option-submit' ).on( 'click', function( e ) {
|
1063 |
+
e.preventDefault();
|
1064 |
+
var $setting = $( this ).parents( '.ditty-wizard-setting' ),
|
1065 |
+
$settings_group = $setting.find( '.ditty-item-type-settings__group.active' ),
|
1066 |
+
values = {};
|
1067 |
+
|
1068 |
+
$( this ).removeClass( 'ditty-button--primary' );
|
1069 |
+
|
1070 |
+
$settings_group.find( ':input' ).each( function() {
|
1071 |
+
var type = $( this ).prop( 'type' );
|
1072 |
+
|
1073 |
+
// checked radios/checkboxes
|
1074 |
+
if ( ( type === "checkbox" || type === "radio" ) ) {
|
1075 |
+
if ( this.checked ) {
|
1076 |
+
values[$( this ).attr( 'name' )] = $( this ).val();
|
1077 |
+
}
|
1078 |
+
} else if ( type !== "button" && type !== "submit" ) {
|
1079 |
+
values[$( this ).attr( 'name' )] = $( this ).val();
|
1080 |
+
}
|
1081 |
+
} );
|
1082 |
+
|
1083 |
+
// Show the layout settings
|
1084 |
+
$( '.ditty-wizard-setting--layout').css( 'display', 'flex' );
|
1085 |
+
|
1086 |
+
// Add to the initialize object
|
1087 |
+
dittyWizardValues.itemTypeValues = values;
|
1088 |
+
|
1089 |
+
// Animate to the next setting
|
1090 |
+
if ( ! $setting.hasClass( 'complete' ) ) {
|
1091 |
+
$setting.addClass( 'complete' );
|
1092 |
+
$( [document.documentElement, document.body] ).stop().animate( {
|
1093 |
+
scrollTop: $( '.ditty-wizard-setting--layout' ).offset().top
|
1094 |
+
}, 700 );
|
1095 |
+
}
|
1096 |
+
} );
|
1097 |
+
|
1098 |
+
/**
|
1099 |
+
* Variation Layout
|
1100 |
+
*
|
1101 |
+
* @since 3.0.13
|
1102 |
+
*/
|
1103 |
+
$( '.ditty-wizard-setting--layout .ditty-option-grid__item' ).on( 'click', function( e ) {
|
1104 |
+
e.preventDefault();
|
1105 |
+
var $setting = $( this ).parents( '.ditty-wizard-setting' ),
|
1106 |
+
$variations = $( this ).parents( '.ditty-wizard-setting--layout__variation' );
|
1107 |
+
|
1108 |
+
if ( ! $( this ).hasClass( 'active' ) ) {
|
1109 |
+
$( this ).siblings().removeClass( 'active' );
|
1110 |
+
$( this ).addClass( 'active' );
|
1111 |
+
$variations.addClass( 'complete' );
|
1112 |
+
|
1113 |
+
// Check for all variations complete
|
1114 |
+
if ( $( '.ditty-wizard-setting--layout__variation.active' ).length === $( '.ditty-wizard-setting--layout__variation.complete' ).length ) {
|
1115 |
+
var layoutVariations = {};
|
1116 |
+
$( '.ditty-wizard-setting--layout__variation.complete' ).each( function() {
|
1117 |
+
layoutVariations[$( this ).data( 'id' )] = $( this ).find( '.ditty-option-grid__item.active' ).data( 'value' );
|
1118 |
+
} );
|
1119 |
+
|
1120 |
+
// Show the display settings
|
1121 |
+
$( '.ditty-wizard-setting--display').css( 'display', 'flex' );
|
1122 |
+
|
1123 |
+
dittyWizardValues.layoutVariations = layoutVariations;
|
1124 |
+
|
1125 |
+
// Animate to the next setting
|
1126 |
+
if ( ! $setting.hasClass( 'complete' ) ) {
|
1127 |
+
$setting.addClass( 'complete' );
|
1128 |
+
$( [document.documentElement, document.body] ).stop().animate( {
|
1129 |
+
scrollTop: $( '.ditty-wizard-setting--display' ).offset().top
|
1130 |
+
}, 700 );
|
1131 |
+
}
|
1132 |
+
}
|
1133 |
+
}
|
1134 |
+
} );
|
1135 |
+
|
1136 |
+
/**
|
1137 |
+
* Display
|
1138 |
+
*
|
1139 |
+
* @since 3.0.13
|
1140 |
+
*/
|
1141 |
+
$( '.ditty-wizard-setting--display .ditty-option-grid__item' ).on( 'click', function( e ) {
|
1142 |
+
e.preventDefault();
|
1143 |
+
var $setting = $( this ).parents( '.ditty-wizard-setting' ),
|
1144 |
+
id = $( this ).data( 'value' );
|
1145 |
+
|
1146 |
+
if ( ! $( this ).hasClass( 'active' ) ) {
|
1147 |
+
$( this ).siblings().removeClass( 'active' );
|
1148 |
+
$( this ).addClass( 'active' );
|
1149 |
+
|
1150 |
+
// Show the submit settings
|
1151 |
+
$( '.ditty-wizard-setting--submit').css( 'display', 'flex' );
|
1152 |
+
|
1153 |
+
dittyWizardValues.display = id;
|
1154 |
+
|
1155 |
+
// Animate to the next setting
|
1156 |
+
if ( ! $setting.hasClass( 'complete' ) ) {
|
1157 |
+
$setting.addClass( 'complete' );
|
1158 |
+
$( [document.documentElement, document.body] ).stop().animate( {
|
1159 |
+
scrollTop: $( '.ditty-wizard-setting--submit' ).offset().top
|
1160 |
+
}, 700 );
|
1161 |
+
}
|
1162 |
+
}
|
1163 |
+
} );
|
1164 |
+
|
1165 |
+
/**
|
1166 |
+
* Submit the wizard
|
1167 |
+
*
|
1168 |
+
* @since 3.0.13
|
1169 |
+
*/
|
1170 |
+
$( '#ditty-wizard-submit' ).on( 'click', function( e ) {
|
1171 |
+
e.preventDefault();
|
1172 |
+
|
1173 |
+
var dittyId = $( this ).data( 'ditty_id' );
|
1174 |
+
|
1175 |
+
$( '#ditty-wizard-overlay' ).addClass( 'active' );
|
1176 |
+
|
1177 |
+
//$( this ).text( $( this ).data( 'submitting' ) );
|
1178 |
+
|
1179 |
+
var data = {
|
1180 |
+
action : 'ditty_submit_wizard',
|
1181 |
+
ditty_id : dittyId,
|
1182 |
+
init_values : dittyWizardValues,
|
1183 |
+
security : dittyVars.security
|
1184 |
+
};
|
1185 |
+
$.post( dittyVars.ajaxurl, data, function( response ) {
|
1186 |
+
window.history.pushState( null, '', '/wp-admin/post.php?post=' + dittyId + '&action=edit' );
|
1187 |
+
location.reload();
|
1188 |
+
}, 'json' );
|
1189 |
+
|
1190 |
+
} );
|
1191 |
+
|
1192 |
+
}() );
|
1193 |
+
|
1194 |
+
} );
|
includes/js/ditty-editor-hooks.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery((function($){!function(){"use strict";function i(i,t){0===parseInt(t)?i.hide():i.show()}function t(i,t){"none"===t?i.hide():i.show()}function n(i,t){"none"===t?i.hide():i.show()}$("#ditty-editor").on("ditty_display_editor_panel_init",".ditty-editor__panel--displayEditor",(function(e,d){if("list"===d.displayType){var o=d.$form,f=o.find(".ditty-field--perPage"),l=o.find(".ditty-field--arrows").siblings(),a=o.find(".ditty-field--bullets").siblings();i(f,o.find('input[name="paging"]:checked').val()),o.find('input[name="paging"]').on("change",(function(){i(f,$(this).val())})),t(l,o.find('select[name="arrows"]').val()),o.find('select[name="arrows"]').on("change",(function(){t(l,$(this).val())})),n(a,o.find('select[name="bullets"]').val()),o.find('select[name="bullets"]').on("change",(function(){n(a,$(this).val())}))}}))}()})),jQuery((function($){!function(){"use strict";function i(i,t){var n=i.find('input[name="direction"]:checked').val(),e=i.find(".ditty-field--minHeight"),d=i.find(".ditty-field--maxHeight"),o=i.find('input[name="minHeight"]');if("down"===n||"up"===n){if(e.show(),d.show(),""===o.val()){var f="300px";o.val(f),t.options("minHeight",f)}}else e.hide(),d.hide()}function t(i){"filled"===i.find('input[name="scrollInit"]:checked').val()?i.find(".ditty-field--scrollDelay").show():i.find(".ditty-field--scrollDelay").hide()}function n(i){var t=i.find('select[name="titleDisplay"]').val(),n=i.find(".ditty-field--titleDisplay");"none"===t?n.siblings().hide():n.siblings().show()}function
|
1 |
+
jQuery((function($){!function(){"use strict";function i(i,t){0===parseInt(t)?i.hide():i.show()}function t(i,t){"none"===t?i.hide():i.show()}function n(i,t){"none"===t?i.hide():i.show()}$("#ditty-editor").on("ditty_display_editor_panel_init",".ditty-editor__panel--displayEditor",(function(e,d){if("list"===d.displayType){var o=d.$form,f=o.find(".ditty-field--perPage"),l=o.find(".ditty-field--arrows").siblings(),a=o.find(".ditty-field--bullets").siblings();i(f,o.find('input[name="paging"]:checked').val()),o.find('input[name="paging"]').on("change",(function(){i(f,$(this).val())})),t(l,o.find('select[name="arrows"]').val()),o.find('select[name="arrows"]').on("change",(function(){t(l,$(this).val())})),n(a,o.find('select[name="bullets"]').val()),o.find('select[name="bullets"]').on("change",(function(){n(a,$(this).val())}))}}))}()})),jQuery((function($){!function(){"use strict";function i(i,t){var n=i.find('input[name="direction"]:checked').val(),e=i.find(".ditty-field--minHeight"),d=i.find(".ditty-field--maxHeight"),o=i.find('input[name="minHeight"]');if("down"===n||"up"===n){if(e.show(),d.show(),""===o.val()){var f="300px";o.val(f),t.options("minHeight",f)}}else e.hide(),d.hide()}function t(i){"filled"===i.find('input[name="scrollInit"]:checked').val()?i.find(".ditty-field--scrollDelay").show():i.find(".ditty-field--scrollDelay").hide()}function n(i){"no"===i.find('input[name="cloneItems"]:checked').val()?i.find(".ditty-field--wrapItems").show():i.find(".ditty-field--wrapItems").hide()}function e(i){var t=i.find('select[name="titleDisplay"]').val(),n=i.find(".ditty-field--titleDisplay");"none"===t?n.siblings().hide():n.siblings().show()}function d(d,o){i(d,o),d.find('input[name="direction"]').on("click",(function(){i(d,o)})),t(d),d.find('input[name="scrollInit"]').on("click",(function(){t(d)})),n(d),d.find('input[name="cloneItems"]').on("click",(function(){n(d)})),e(d),d.find('select[name="titleDisplay"]').on("change",(function(){e(d)}))}$("#ditty-editor").on("ditty_display_editor_panel_init",".ditty-editor__panel--displayEditor",(function(i,t){if("ticker"===t.displayType){var n=t.$form,e=n.parents("#ditty-editor__settings")[0];d(n,e._ditty_editor.ditty)}})),$(".ditty-sandbox").on("ditty_sandbox_init",(function(i,t,n){"ticker"===t.displayType&&d($(this).find("form"),n)}))}()})),jQuery((function($){!function(){"use strict";function i(i){"full"===i.find('input[name="content_display"]:checked').val()?(i.find(".ditty-field--more_link").hide(),i.find(".ditty-field--excerpt_length").hide(),i.find(".ditty-field--more").hide(),i.find(".ditty-field--more_before").hide(),i.find(".ditty-field--more_after").hide()):(i.find(".ditty-field--more_link").show(),i.find(".ditty-field--excerpt_length").show(),i.find(".ditty-field--more").show(),i.find(".ditty-field--more_before").show(),i.find(".ditty-field--more_after").show())}$("#ditty-editor").on("ditty_item_editor_panel_init",".ditty-editor__panel--item_editor",(function(t,n){if("posts_feed"!==n.itemType&&"post"!==n.itemType)return!1;var e=n.$form;i(e),e.on("click",'input[name="content_display"]',(function(){i(e)}))}))}()}));
|
includes/js/ditty-editor.js
CHANGED
@@ -13,9 +13,9 @@
|
|
13 |
// @codekit-append 'editor/class-ditty-layouts-panel.js';
|
14 |
// @codekit-append 'editor/class-ditty-layout-html-editor-panel.js';
|
15 |
// @codekit-append 'editor/class-ditty-layout-css-editor-panel.js';
|
16 |
-
// @codekit-append '
|
17 |
-
// @codekit-append '
|
18 |
-
// @codekit-append '
|
19 |
|
20 |
jQuery( function( $ ) {
|
21 |
|
13 |
// @codekit-append 'editor/class-ditty-layouts-panel.js';
|
14 |
// @codekit-append 'editor/class-ditty-layout-html-editor-panel.js';
|
15 |
// @codekit-append 'editor/class-ditty-layout-css-editor-panel.js';
|
16 |
+
// @codekit-append 'editor_hooks/ditty-list-display-editor.js';
|
17 |
+
// @codekit-append 'editor_hooks/ditty-ticker-display-editor.js';
|
18 |
+
// @codekit-append 'editor_hooks/ditty-item-edit-editor.js';
|
19 |
|
20 |
jQuery( function( $ ) {
|
21 |
|
includes/js/ditty-editor.min.js
CHANGED
@@ -1,3 +1,3 @@
|
|
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.editorItemValue=this.$editorItem.data("item_value"),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");dittyVars.editor.currentLayoutVariation=s,i.settings.editor.updateStart(),i.$list.find(".ditty-data-list__item").removeClass("editing"),s.addClass("editing");var d=[],r=i.settings.editor.ditty.options("items");$.each(r,(function(t,i){d.push(i.uniqId)}));var o={action:"ditty_editor_layout_fields",layout_id:a,item_type:i.editorItemType,item_value:i.editorItemValue,ditty_id:i.editorDittyId,item_id:i.editorItemId,item_ids:d,edit_type:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,o,(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.editorItemValue=this.$editorItem.data("item_value"),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}
|
3 |
-
;$.post(dittyVars.ajaxurl,a,(function(t){if(t.editor_layout){var s=$(t.editor_layout);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,item_type:i.editorItemtype,item_value:i.editorItemValue,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.editorItemType=this.$editorItem.data("item_type"),this.editorItemValue=this.$editorItem.data("item_value"),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.editorItemType,item_value:i.editorItemValue,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.editorItemType=this.$editorItem.data("item_type"),this.editorItemValue=this.$editorItem.data("item_value"),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.editorItemType,item_value:i.editorItemValue,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){var i=t.find('input[name="direction"]:checked').val(),e=t.find(".ditty-field--minHeight"),s=t.find(".ditty-field--maxHeight"),a=t.find('input[name="minHeight"]');if("down"===i||"up"===i){if(e.show(),s.show(),""===a.val()){var d=t.parents("#ditty-editor__settings")[0],r="300px";a.val(r),d._ditty_editor.ditty.options("minHeight",r)}}else e.hide(),s.hide()}function i(t){"filled"===t.find('input[name="scrollInit"]:checked').val()?t.find(".ditty-field--scrollDelay").show():t.find(".ditty-field--scrollDelay").hide()}function e(t){var i=t.find('select[name="titleDisplay"]').val(),e=t.find(".ditty-field--titleDisplay");"none"===i?e.siblings().hide():e.siblings().show()}$("#ditty-editor").on("ditty_display_editor_panel_init",".ditty-editor__panel--displayEditor",(function(s,a){if("ticker"===a.displayType){var d=a.$form;t(d),d.find('input[name="direction"]').on("click",(function(){t(d)})),i(d),d.find('input[name="scrollInit"]').on("click",(function(){i(d)})),e(d),d.find('select[name="titleDisplay"]').on("change",(function(){e(d)}))}}))}()})),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)}))}))}()}));
|
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,n,r=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,n=$('<div class="ditty-editor__panels"></div>'),this.$panels=n,a.prepend(e,s),i.append(a),t.append(i,d,n),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(){r.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 n={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,n,(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").html();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="",n={};a.find("input").each((function(){s=$(this).attr("name"),d=(d=s.split("["))[0];var t=s.match(/\[(.*)\]/);n[t[1]]=$(this).val()})),i.settings.editor.ditty.options(d,n)}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.editorItemValue=this.$editorItem.data("item_value"),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 n={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,n,(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");dittyVars.editor.currentLayoutVariation=s,i.settings.editor.updateStart(),i.$list.find(".ditty-data-list__item").removeClass("editing"),s.addClass("editing");var d=[],n=i.settings.editor.ditty.options("items");$.each(n,(function(t,i){d.push(i.uniqId)}));var r={action:"ditty_editor_layout_fields",layout_id:a,item_type:i.editorItemType,item_value:i.editorItemValue,ditty_id:i.editorDittyId,item_id:i.editorItemId,item_ids:d,edit_type:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,r,(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.editorItemValue=this.$editorItem.data("item_value"),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 n={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,n,(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}
|
3 |
+
;$.post(dittyVars.ajaxurl,a,(function(t){if(t.editor_layout){var s=$(t.editor_layout);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,item_type:i.editorItemtype,item_value:i.editorItemValue,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.editorItemType=this.$editorItem.data("item_type"),this.editorItemValue=this.$editorItem.data("item_value"),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.editorItemType,item_value:i.editorItemValue,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 n="",r=s.length-1;$.each(a,(function(t,i){n+=" "+t+'="'+i.toString()+'"'})),s=s.substring(0,r)+n+s.substring(r)}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.editorItemType=this.$editorItem.data("item_type"),this.editorItemValue=this.$editorItem.data("item_value"),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.editorItemType,item_value:i.editorItemValue,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,n=d.find(".ditty-field--perPage"),r=d.find(".ditty-field--arrows").siblings(),o=d.find(".ditty-field--bullets").siblings();t(n,d.find('input[name="paging"]:checked').val()),d.find('input[name="paging"]').on("change",(function(){t(n,$(this).val())})),i(r,d.find('select[name="arrows"]').val()),d.find('select[name="arrows"]').on("change",(function(){i(r,$(this).val())})),e(o,d.find('select[name="bullets"]').val()),d.find('select[name="bullets"]').on("change",(function(){e(o,$(this).val())}))}}))}()})),jQuery((function($){!function(){"use strict";function t(t,i){var e=t.find('input[name="direction"]:checked').val(),s=t.find(".ditty-field--minHeight"),a=t.find(".ditty-field--maxHeight"),d=t.find('input[name="minHeight"]');if("down"===e||"up"===e){if(s.show(),a.show(),""===d.val()){var n="300px";d.val(n),i.options("minHeight",n)}}else s.hide(),a.hide()}function i(t){"filled"===t.find('input[name="scrollInit"]:checked').val()?t.find(".ditty-field--scrollDelay").show():t.find(".ditty-field--scrollDelay").hide()}function e(t){"no"===t.find('input[name="cloneItems"]:checked').val()?t.find(".ditty-field--wrapItems").show():t.find(".ditty-field--wrapItems").hide()}function s(t){var i=t.find('select[name="titleDisplay"]').val(),e=t.find(".ditty-field--titleDisplay");"none"===i?e.siblings().hide():e.siblings().show()}function a(a,d){t(a,d),a.find('input[name="direction"]').on("click",(function(){t(a,d)})),i(a),a.find('input[name="scrollInit"]').on("click",(function(){i(a)})),e(a),a.find('input[name="cloneItems"]').on("click",(function(){e(a)})),s(a),a.find('select[name="titleDisplay"]').on("change",(function(){s(a)}))}$("#ditty-editor").on("ditty_display_editor_panel_init",".ditty-editor__panel--displayEditor",(function(t,i){if("ticker"===i.displayType){var e=i.$form,s=e.parents("#ditty-editor__settings")[0];a(e,s._ditty_editor.ditty)}})),$(".ditty-sandbox").on("ditty_sandbox_init",(function(t,i,e){"ticker"===i.displayType&&a($(this).find("form"),e)}))}()})),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/editor/class-ditty-item-editor-panel.js
CHANGED
@@ -224,8 +224,8 @@
|
|
224 |
}
|
225 |
if ( response.editor_item ) {
|
226 |
var $item = $( response.editor_item ),
|
227 |
-
itemTitle = $item.children( '.ditty-data-list__item__label' ).
|
228 |
-
|
229 |
// Set the new titles
|
230 |
self.$title.html( itemTitle );
|
231 |
self.$editorItemTitle.html( itemTitle );
|
224 |
}
|
225 |
if ( response.editor_item ) {
|
226 |
var $item = $( response.editor_item ),
|
227 |
+
itemTitle = $item.children( '.ditty-data-list__item__label' ).html();
|
228 |
+
|
229 |
// Set the new titles
|
230 |
self.$title.html( itemTitle );
|
231 |
self.$editorItemTitle.html( itemTitle );
|
includes/js/editor_hooks/ditty-ticker-display-editor.js
CHANGED
@@ -45,6 +45,20 @@ jQuery( function( $ ) {
|
|
45 |
}
|
46 |
}
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
/**
|
49 |
* Set the title field visibility
|
50 |
*
|
@@ -80,6 +94,12 @@ jQuery( function( $ ) {
|
|
80 |
setScrollDelay( $form );
|
81 |
} );
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
// Set the title styles
|
84 |
setTitleStyles( $form );
|
85 |
$form.find( 'select[name="titleDisplay"]' ).on( 'change', function() {
|
45 |
}
|
46 |
}
|
47 |
|
48 |
+
/**
|
49 |
+
* Set the scroll delay field visibility
|
50 |
+
*
|
51 |
+
* @since 3.0.13
|
52 |
+
*/
|
53 |
+
function setItemWrap( $form ) {
|
54 |
+
var val = $form.find( 'input[name="cloneItems"]:checked' ).val();
|
55 |
+
if ( 'no' === val ) {
|
56 |
+
$form.find( '.ditty-field--wrapItems' ).show();
|
57 |
+
} else {
|
58 |
+
$form.find( '.ditty-field--wrapItems' ).hide();
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
/**
|
63 |
* Set the title field visibility
|
64 |
*
|
94 |
setScrollDelay( $form );
|
95 |
} );
|
96 |
|
97 |
+
// Set item wrap
|
98 |
+
setItemWrap( $form );
|
99 |
+
$form.find( 'input[name="cloneItems"]' ).on( 'click', function() {
|
100 |
+
setItemWrap( $form );
|
101 |
+
} );
|
102 |
+
|
103 |
// Set the title styles
|
104 |
setTitleStyles( $form );
|
105 |
$form.find( 'select[name="titleDisplay"]' ).on( 'change', function() {
|
includes/layout-tag-hooks-default.php
CHANGED
@@ -66,7 +66,7 @@ add_filter( 'ditty_layout_tag_author_bio', 'ditty_default_layout_tag_author_bio'
|
|
66 |
/**
|
67 |
* Modify the layout content
|
68 |
*
|
69 |
-
* @since 3.0.
|
70 |
* @var html
|
71 |
*/
|
72 |
function ditty_default_layout_tag_content( $content, $item_type, $data, $atts ) {
|
@@ -77,7 +77,7 @@ function ditty_default_layout_tag_content( $content, $item_type, $data, $atts )
|
|
77 |
$target = isset( $data['link_target'] ) ? $data['link_target'] : '_self';
|
78 |
$rel = isset( $data['link_nofollow'] ) ? 'nofollow' : '';
|
79 |
$title = isset( $data['link_title'] ) ? $data['link_title'] : '';
|
80 |
-
$content = sprintf( '<a href="%2$s" class="ditty-
|
81 |
}
|
82 |
} elseif ( 'wp_editor' == $item_type ) {
|
83 |
$content = $data['content'];
|
66 |
/**
|
67 |
* Modify the layout content
|
68 |
*
|
69 |
+
* @since 3.0.16
|
70 |
* @var html
|
71 |
*/
|
72 |
function ditty_default_layout_tag_content( $content, $item_type, $data, $atts ) {
|
77 |
$target = isset( $data['link_target'] ) ? $data['link_target'] : '_self';
|
78 |
$rel = isset( $data['link_nofollow'] ) ? 'nofollow' : '';
|
79 |
$title = isset( $data['link_title'] ) ? $data['link_title'] : '';
|
80 |
+
$content = sprintf( '<a href="%2$s" class="ditty-item__link" target="%3$s" rel="%4$s" title="%5$s">%1$s</a>', $content, $url, $target, $rel, $title );
|
81 |
}
|
82 |
} elseif ( 'wp_editor' == $item_type ) {
|
83 |
$content = $data['content'];
|
includes/sass/editor/_editor.scss
CHANGED
@@ -290,6 +290,10 @@ $update_color: orange;
|
|
290 |
&__title,
|
291 |
&__title[type="text"] {
|
292 |
flex: 1;
|
|
|
|
|
|
|
|
|
293 |
font-size: 14px;
|
294 |
line-height: 18px;
|
295 |
//color: #FFF;
|
290 |
&__title,
|
291 |
&__title[type="text"] {
|
292 |
flex: 1;
|
293 |
+
display: flex;
|
294 |
+
flex-direction: row;
|
295 |
+
align-items: center;
|
296 |
+
justify-content: flex-start;
|
297 |
font-size: 14px;
|
298 |
line-height: 18px;
|
299 |
//color: #FFF;
|
includes/sass/editor/_items_panel.scss
CHANGED
@@ -13,6 +13,8 @@
|
|
13 |
}
|
14 |
a.ditty-data-list__item__icon {
|
15 |
display: block;
|
|
|
|
|
16 |
}
|
17 |
}
|
18 |
}
|
13 |
}
|
14 |
a.ditty-data-list__item__icon {
|
15 |
display: block;
|
16 |
+
border-right: 1px solid rgba(0,0,0,.05);
|
17 |
+
margin-right: 10px;
|
18 |
}
|
19 |
}
|
20 |
}
|
includes/sass/partials/_ditty-ui.scss
CHANGED
@@ -134,6 +134,10 @@
|
|
134 |
margin-bottom: 0;
|
135 |
}
|
136 |
&__label {
|
|
|
|
|
|
|
|
|
137 |
color: #444;
|
138 |
padding-right: 5px;
|
139 |
margin-right: auto;
|
134 |
margin-bottom: 0;
|
135 |
}
|
136 |
&__label {
|
137 |
+
display: flex;
|
138 |
+
flex-direction: row;
|
139 |
+
align-items: center;
|
140 |
+
justify-content: flex-start;
|
141 |
color: #444;
|
142 |
padding-right: 5px;
|
143 |
margin-right: auto;
|
legacy/inc/helpers.php
CHANGED
@@ -164,18 +164,18 @@ function mtphr_dnt_settings_tabs() {
|
|
164 |
|
165 |
|
166 |
/* --------------------------------------------------------- */
|
167 |
-
/* !Return the ticker class -
|
168 |
/* --------------------------------------------------------- */
|
169 |
|
170 |
if( !function_exists('mtphr_dnt_ticker_class') ) {
|
171 |
-
function mtphr_dnt_ticker_class( $id='', $class='', $meta_data ) {
|
172 |
|
173 |
return 'class="'.join( ' ', get_mtphr_dnt_ticker_class($id,$class,$meta_data) ).'"';
|
174 |
}
|
175 |
}
|
176 |
|
177 |
if( !function_exists('get_mtphr_dnt_ticker_class') ) {
|
178 |
-
function get_mtphr_dnt_ticker_class( $id='', $class='', $meta_data ) {
|
179 |
|
180 |
// Extract the metadata array into variables
|
181 |
extract( $meta_data );
|
164 |
|
165 |
|
166 |
/* --------------------------------------------------------- */
|
167 |
+
/* !Return the ticker class - 3.0.16 */
|
168 |
/* --------------------------------------------------------- */
|
169 |
|
170 |
if( !function_exists('mtphr_dnt_ticker_class') ) {
|
171 |
+
function mtphr_dnt_ticker_class( $id='', $class='', $meta_data = array() ) {
|
172 |
|
173 |
return 'class="'.join( ' ', get_mtphr_dnt_ticker_class($id,$class,$meta_data) ).'"';
|
174 |
}
|
175 |
}
|
176 |
|
177 |
if( !function_exists('get_mtphr_dnt_ticker_class') ) {
|
178 |
+
function get_mtphr_dnt_ticker_class( $id='', $class='', $meta_data = array() ) {
|
179 |
|
180 |
// Extract the metadata array into variables
|
181 |
extract( $meta_data );
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: metaphorcreations
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FUZKZGAJSBAE6
|
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,14 @@ The most common cause for an unresponsive Ditty (when using scroll or rotate mod
|
|
66 |
|
67 |
== Changelog ==
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
= 3.0.15 =
|
70 |
* Ticker container border width render issue fix
|
71 |
* Data sanitization updates
|
@@ -680,4 +688,4 @@ The most common cause for an unresponsive Ditty (when using scroll or rotate mod
|
|
680 |
|
681 |
== Upgrade Notice ==
|
682 |
|
683 |
-
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FUZKZGAJSBAE6
|
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.1
|
7 |
+
Stable tag: 3.0.16
|
8 |
License: GPL2
|
9 |
|
10 |
Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
|
66 |
|
67 |
== Changelog ==
|
68 |
|
69 |
+
= 3.0.16 =
|
70 |
+
* Resolved bug in default item link css
|
71 |
+
* Code field updates
|
72 |
+
* PHP 8 updates
|
73 |
+
* Item preview & title updates
|
74 |
+
* Added ticker display item wrap setting
|
75 |
+
* Editor item css updates
|
76 |
+
|
77 |
= 3.0.15 =
|
78 |
* Ticker container border width render issue fix
|
79 |
* Data sanitization updates
|
688 |
|
689 |
== Upgrade Notice ==
|
690 |
|
691 |
+
PHP 8 updates & other updates
|