Ditty News Ticker - Version 3.0.9

Version Description

  • Ditty editor Layout css update bug fix
  • Added WPML functionality to Ditty post type
  • Ticker Display vertical scrolling updates
Download this release

Release Info

Developer metaphorcreations
Plugin Icon 128x128 Ditty News Ticker
Version 3.0.9
Comparing to
See all releases

Code changes from version 3.0.8 to 3.0.9

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
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.8' );
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.9
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.9' );
24
  }
25
 
26
  // Plugin Folder Path.
includes/class-ditty-display-type-ticker.php CHANGED
@@ -49,6 +49,20 @@ class Ditty_Display_Type_Ticker extends Ditty_Display_Type {
49
  'inline' => true,
50
  'std' => isset( $values['direction'] ) ? $values['direction'] : false,
51
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  'spacing' => array(
53
  'type' => 'slider',
54
  'id' => 'spacing',
@@ -75,20 +89,6 @@ class Ditty_Display_Type_Ticker extends Ditty_Display_Type {
75
  ),
76
  'std' => isset( $values['speed'] ) ? $values['speed'] : false,
77
  ),
78
- 'minHeight' => array(
79
- 'type' => 'text',
80
- 'id' => 'minHeight',
81
- 'name' => __( 'Min. Height', 'ditty-news-ticker' ),
82
- 'help' => __( 'Set the minimum height of the Ditty for vertical scrolling tickers.', 'ditty-news-ticker' ),
83
- 'std' => isset( $values['minHeight'] ) ? $values['minHeight'] : false,
84
- ),
85
- 'maxHeight' => array(
86
- 'type' => 'text',
87
- 'id' => 'maxHeight',
88
- 'name' => __( 'Max. Height', 'ditty-news-ticker' ),
89
- 'help' => __( 'Set the maximum height of the Ditty for vertical scrolling tickers.', 'ditty-news-ticker' ),
90
- 'std' => isset( $values['maxHeight'] ) ? $values['maxHeight'] : false,
91
- ),
92
  'hoverPause' => array(
93
  'type' => 'checkbox',
94
  'id' => 'hoverPause',
@@ -176,22 +176,22 @@ class Ditty_Display_Type_Ticker extends Ditty_Display_Type {
176
  'std' => isset( $values['itemElementsWrap'] ) ? $values['itemElementsWrap'] : false,
177
  ),
178
  ) ),
179
- // 'importExportSettings' => array(
180
- // 'type' => 'group',
181
- // 'id' => 'importExportSettings',
182
- // 'collapsible' => true,
183
- // 'default_state' => 'collapsed',
184
- // 'multiple_fields' => true,
185
- // 'name' => __( 'Import/Export', 'ditty-news-ticker' ),
186
- // 'help' => __( 'Import or export the display settings.', 'ditty-news-ticker' ),
187
- // 'fields' => array(
188
- // 'importExport' => array(
189
- // 'type' => 'html',
190
- // 'id' => 'importExport',
191
- // 'std' => parent::import_export_settings( $values ),
192
- // ),
193
- // ),
194
- // ),
195
  );
196
  return $fields;
197
  }
@@ -203,7 +203,7 @@ class Ditty_Display_Type_Ticker extends Ditty_Display_Type {
203
  */
204
  public function default_settings() {
205
 
206
- $defaults = json_decode( '{"direction":"left","spacing":"25","speed":"10","minHeight":"","maxHeight":"","hoverPause":"1","scrollInit":"empty","scrollDelay":"3","heightEase":"easeInOutQuint","heightSpeed":"1.5","maxWidth":"","bgColor":"","padding":{"paddingTop":"5px","paddingBottom":"5px","paddingLeft":"5px","paddingRight":"5px"},"margin":{"marginTop":"","marginBottom":"","marginLeft":"","marginRight":""},"borderColor":"","borderStyle":"none","borderWidth":{"borderTopWidth":"","borderBottomWidth":"","borderLeftWidth":"","borderRightWidth":""},"borderRadius":{"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":"3px","borderTopRightRadius":"3px","borderBottomLeftRadius":"3px","borderBottomRightRadius":"3px"},"itemTextColor":"","itemBgColor":"","itemPadding":{"paddingTop":"","paddingBottom":"","paddingLeft":"","paddingRight":""},"itemBorderColor":"","itemBorderStyle":"none","itemBorderWidth":{"borderTopWidth":"","borderBottomWidth":"","borderLeftWidth":"","borderRightWidth":""},"itemBorderRadius":{"borderTopLeftRadius":"","borderTopRightRadius":"","borderBottomLeftRadius":"","borderBottomRightRadius":""},"itemMaxWidth":"400px","itemElementsWrap":"wrap"}', true );
207
 
208
  return apply_filters( 'ditty_display_default_settings', $defaults, $this->type );
209
  }
@@ -221,7 +221,7 @@ class Ditty_Display_Type_Ticker extends Ditty_Display_Type {
221
  'label' => __( 'Default Ticker', 'ditty-news-ticker' ),
222
  'description' => __( 'Default ticker display', 'ditty-news-ticker' ),
223
  'settings' => $defaults,
224
- 'version' => '1.1',
225
  );
226
  return apply_filters( 'ditty_display_type_templates', $templates, $this->type );
227
  }
49
  'inline' => true,
50
  'std' => isset( $values['direction'] ) ? $values['direction'] : false,
51
  ),
52
+ 'minHeight' => array(
53
+ 'type' => 'text',
54
+ 'id' => 'minHeight',
55
+ 'name' => __( 'Min. Height', 'ditty-news-ticker' ),
56
+ 'help' => __( 'Set the minimum height of the Ditty for vertical scrolling tickers.', 'ditty-news-ticker' ),
57
+ 'std' => isset( $values['minHeight'] ) ? $values['minHeight'] : false,
58
+ ),
59
+ 'maxHeight' => array(
60
+ 'type' => 'text',
61
+ 'id' => 'maxHeight',
62
+ 'name' => __( 'Max. Height', 'ditty-news-ticker' ),
63
+ 'help' => __( 'Set the maximum height of the Ditty for vertical scrolling tickers.', 'ditty-news-ticker' ),
64
+ 'std' => isset( $values['maxHeight'] ) ? $values['maxHeight'] : false,
65
+ ),
66
  'spacing' => array(
67
  'type' => 'slider',
68
  'id' => 'spacing',
89
  ),
90
  'std' => isset( $values['speed'] ) ? $values['speed'] : false,
91
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  'hoverPause' => array(
93
  'type' => 'checkbox',
94
  'id' => 'hoverPause',
176
  'std' => isset( $values['itemElementsWrap'] ) ? $values['itemElementsWrap'] : false,
177
  ),
178
  ) ),
179
+ 'importExportSettings' => array(
180
+ 'type' => 'group',
181
+ 'id' => 'importExportSettings',
182
+ 'collapsible' => true,
183
+ 'default_state' => 'collapsed',
184
+ 'multiple_fields' => true,
185
+ 'name' => __( 'Import/Export', 'ditty-news-ticker' ),
186
+ 'help' => __( 'Import or export the display settings.', 'ditty-news-ticker' ),
187
+ 'fields' => array(
188
+ 'importExport' => array(
189
+ 'type' => 'html',
190
+ 'id' => 'importExport',
191
+ 'std' => parent::import_export_settings( $values ),
192
+ ),
193
+ ),
194
+ ),
195
  );
196
  return $fields;
197
  }
203
  */
204
  public function default_settings() {
205
 
206
+ $defaults = json_decode( '{"direction":"left","spacing":"25","speed":"10","minHeight":"300px","maxHeight":"","hoverPause":"1","scrollInit":"empty","scrollDelay":"3","heightEase":"easeInOutQuint","heightSpeed":"1.5","maxWidth":"","bgColor":"","padding":{"paddingTop":"5px","paddingBottom":"5px","paddingLeft":"5px","paddingRight":"5px"},"margin":{"marginTop":"","marginBottom":"","marginLeft":"","marginRight":""},"borderColor":"","borderStyle":"none","borderWidth":{"borderTopWidth":"","borderBottomWidth":"","borderLeftWidth":"","borderRightWidth":""},"borderRadius":{"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":"3px","borderTopRightRadius":"3px","borderBottomLeftRadius":"3px","borderBottomRightRadius":"3px"},"itemTextColor":"","itemBgColor":"","itemPadding":{"paddingTop":"","paddingBottom":"","paddingLeft":"","paddingRight":""},"itemBorderColor":"","itemBorderStyle":"none","itemBorderWidth":{"borderTopWidth":"","borderBottomWidth":"","borderLeftWidth":"","borderRightWidth":""},"itemBorderRadius":{"borderTopLeftRadius":"","borderTopRightRadius":"","borderBottomLeftRadius":"","borderBottomRightRadius":""},"itemMaxWidth":"400px","itemElementsWrap":"wrap"}', true );
207
 
208
  return apply_filters( 'ditty_display_default_settings', $defaults, $this->type );
209
  }
221
  'label' => __( 'Default Ticker', 'ditty-news-ticker' ),
222
  'description' => __( 'Default ticker display', 'ditty-news-ticker' ),
223
  'settings' => $defaults,
224
+ 'version' => '1.2',
225
  );
226
  return apply_filters( 'ditty_display_type_templates', $templates, $this->type );
227
  }
includes/class-ditty-wpml.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Ditty WMPL Class
5
+ *
6
+ * @package Ditty
7
+ * @subpackage Classes/Ditty WPML
8
+ * @copyright Copyright (c) 2021, Metaphor Creations
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 3.0.9
11
+ */
12
+
13
+ class Ditty_WPML {
14
+
15
+ /**
16
+ * Get things started
17
+ * @access public
18
+ * @since 3.0.9
19
+ */
20
+ public function __construct() {
21
+ add_action( 'icl_make_duplicate', array( $this, 'after_duplicate_post' ), 10, 4 );
22
+ }
23
+
24
+ /**
25
+ * Add custom table data after WPML duplication
26
+ *
27
+ * @access public
28
+ * @since 3.0.9
29
+ * @param $html
30
+ */
31
+ public function after_duplicate_post( $master_post_id, $lang, $post_array, $id ) {
32
+
33
+ // Delete any existing Ditty items
34
+ $items_meta = ditty_items_meta( $id );
35
+ if ( is_array( $items_meta ) && count( $items_meta ) > 0 ) {
36
+ foreach ( $items_meta as $i => $item ) {
37
+ Ditty()->db_items->delete( $item->item_id );
38
+ }
39
+ }
40
+
41
+ // Duplicate and add master Ditty items
42
+ $all_meta = Ditty()->db_items->get_items( $master_post_id );
43
+ if ( is_array( $all_meta ) && count( $all_meta ) > 0 ) {
44
+ foreach ( $all_meta as $i => $meta ) {
45
+ unset( $meta->item_id );
46
+ $meta->ditty_id = $id;
47
+ Ditty()->db_items->insert( $meta, 'item' );
48
+ }
49
+ }
50
+
51
+ // Delete possible transient for Ditty
52
+ $transient_name = "ditty_display_items_{$id}";
53
+ delete_transient( $transient_name );
54
+ }
55
+
56
+ }
includes/class-ditty.php CHANGED
@@ -123,6 +123,15 @@ class Ditty {
123
  */
124
  public $extensions;
125
 
 
 
 
 
 
 
 
 
 
126
  /**
127
  * Ditty error object.
128
  *
@@ -168,7 +177,8 @@ class Ditty {
168
  self::$instance->extensions = new Ditty_Extensions();
169
  self::$instance->layouts = new Ditty_Layouts();
170
  self::$instance->singles = new Ditty_Singles();
171
- self::$instance->items = new Ditty_Items();
 
172
  }
173
 
174
  return self::$instance;
@@ -296,6 +306,7 @@ class Ditty {
296
  require_once DITTY_DIR . 'includes/class-ditty-item-type-wp-editor.php';
297
  require_once DITTY_DIR . 'includes/class-ditty-item-type-posts-lite.php';
298
  require_once DITTY_DIR . 'includes/class-ditty-singles.php';
 
299
 
300
  //require_once DITTY_DIR . 'blocks/ditty-block/index.php';
301
 
123
  */
124
  public $extensions;
125
 
126
+ /**
127
+ * Ditty WPML object.
128
+ *
129
+ * @since 3.0
130
+ * @access public
131
+ * @var object Ditty_WPML
132
+ */
133
+ public $wpml;
134
+
135
  /**
136
  * Ditty error object.
137
  *
177
  self::$instance->extensions = new Ditty_Extensions();
178
  self::$instance->layouts = new Ditty_Layouts();
179
  self::$instance->singles = new Ditty_Singles();
180
+ self::$instance->items = new Ditty_Items();
181
+ self::$instance->wpml = new Ditty_WPML();
182
  }
183
 
184
  return self::$instance;
306
  require_once DITTY_DIR . 'includes/class-ditty-item-type-wp-editor.php';
307
  require_once DITTY_DIR . 'includes/class-ditty-item-type-posts-lite.php';
308
  require_once DITTY_DIR . 'includes/class-ditty-singles.php';
309
+ require_once DITTY_DIR . 'includes/class-ditty-wpml.php';
310
 
311
  //require_once DITTY_DIR . 'blocks/ditty-block/index.php';
312
 
includes/css/ditty.css CHANGED
@@ -1066,6 +1066,14 @@
1066
  overflow-y: scroll;
1067
  -webkit-overflow-scrolling: touch; }
1068
 
 
 
 
 
 
 
 
 
1069
  .ditty-editor-layout {
1070
  cursor: pointer; }
1071
  .ditty-editor-layout:not(.active):hover .ditty-data-list__item__edit_html,
1066
  overflow-y: scroll;
1067
  -webkit-overflow-scrolling: touch; }
1068
 
1069
+ #ditty-editor__settings .ditty-display-type-options--ticker .ditty-input--group__container > .ditty-field.ditty-field--minHeight {
1070
+ width: 50%;
1071
+ padding-right: 7.5px; }
1072
+
1073
+ #ditty-editor__settings .ditty-display-type-options--ticker .ditty-input--group__container > .ditty-field.ditty-field--maxHeight {
1074
+ width: 50%;
1075
+ padding-left: 7.5px; }
1076
+
1077
  .ditty-editor-layout {
1078
  cursor: pointer; }
1079
  .ditty-editor-layout:not(.active):hover .ditty-data-list__item__edit_html,
includes/helpers.php CHANGED
@@ -1184,7 +1184,7 @@ function ditty_prepare_display_items( $meta ) {
1184
  /**
1185
  * Render the Ditty container
1186
  *
1187
- * @since 3.0
1188
  */
1189
  function ditty_render( $atts ) {
1190
  global $ditty_singles;
@@ -1202,6 +1202,9 @@ function ditty_render( $atts ) {
1202
  'load_type' => '',
1203
  );
1204
  $args = shortcode_atts( $defaults, $atts );
 
 
 
1205
 
1206
  // Make sure the ditty exists & is published
1207
  if ( ! ditty_exists( intval( $args['id'] ) ) ) {
1184
  /**
1185
  * Render the Ditty container
1186
  *
1187
+ * @since 3.0.9
1188
  */
1189
  function ditty_render( $atts ) {
1190
  global $ditty_singles;
1202
  'load_type' => '',
1203
  );
1204
  $args = shortcode_atts( $defaults, $atts );
1205
+
1206
+ // Check for WPML language posts
1207
+ $args['id'] = function_exists('icl_object_id') ? icl_object_id( $args['id'], 'ditty', true ) : $args['id'];
1208
 
1209
  // Make sure the ditty exists & is published
1210
  if ( ! ditty_exists( intval( $args['id'] ) ) ) {
includes/js/class-ditty-display-ticker.js CHANGED
@@ -852,19 +852,19 @@
852
  var height = this.settings.height ? this.settings.height : '100%',
853
  minHeight = this.settings.minHeight ? this.settings.minHeight : 0,
854
  maxHeight = this.settings.maxHeight ? this.settings.maxHeight : 'none';
855
- this.$elmt.css( {
856
  height: height,
857
  minHeight: minHeight,
858
  maxHeight: maxHeight
859
  } );
860
- this.$contents.css( { height: height } );
861
  } else {
862
- this.$elmt.css( {
863
  height: 'auto',
864
- minHeight: 0,
865
- maxHeight: 'none'
866
  } );
867
- this.$contents.css( { height: 'auto' } );
868
  }
869
  },
870
 
@@ -931,6 +931,10 @@
931
  case 'items':
932
  this.updateItems( value );
933
  break;
 
 
 
 
934
  case 'minHeight':
935
  case 'maxHeight':
936
  case 'bgColor':
852
  var height = this.settings.height ? this.settings.height : '100%',
853
  minHeight = this.settings.minHeight ? this.settings.minHeight : 0,
854
  maxHeight = this.settings.maxHeight ? this.settings.maxHeight : 'none';
855
+ this.$items.css( {
856
  height: height,
857
  minHeight: minHeight,
858
  maxHeight: maxHeight
859
  } );
860
+ //this.$contents.css( { height: height } );
861
  } else {
862
+ this.$items.css( {
863
  height: 'auto',
864
+ minHeight: '',
865
+ maxHeight: ''
866
  } );
867
+ //this.$contents.css( { height: 'auto' } );
868
  }
869
  },
870
 
931
  case 'items':
932
  this.updateItems( value );
933
  break;
934
+ case 'direction':
935
+ this.settings[key] = value;
936
+ this._styleDisplay();
937
+ break;
938
  case 'minHeight':
939
  case 'maxHeight':
940
  case 'bgColor':
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,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:{},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.$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;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,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.$contents.on("mouseenter",{self:this},this._mouseenter),this.$contents.on("mouseleave",{self:this},this._mouseleave),this.settings.showEditor?dittyEditorInit(this):this.trigger("start_live_updates"),setTimeout((function(){for(var t=0;t<this.total;t++)this._preloadItem(this.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.settings.items[t].html);if(e.css({top:0,left:0}),this.$items.children(".ditty-item--"+this.settings.items[t].id).not(".ditty-item--clone").length>0&&e.addClass("ditty-item--clone"),this._styleItem(e),this.settings.items[t].css&&dittyLayoutCss(this.settings.items[t].css,this.settings.items[t].layout_id),this._itemSpacing(e),this._itemSetTransform(e,this._itemResetPosition(e)),this.$items.append(e),e.css({display:"block",top:0,left:0,opacity:1}),e.addClass("ditty-item--current"),null!==this.$currentItem&&this.$currentItem.removeClass("ditty-item--current"),this.$currentItem=e,null===this.$lastItem&&(e.addClass("ditty-item--last"),this.$lastItem=e),this.settings.item=t,this.nextItem=this._getNextItem(t),"custom"!==i){var s=this._itemResetPosition(e);this._itemSetTransform(e,s),this.visibleItems.push({$item:e,itemId:this.settings.items[t].id,posX:s.posX,posY:s.posY}),this._setCurrentHeight()}return this.trigger("active_items_update"),e},_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,a=null;this._isItemEnabled(h)||(h=this._getNextItem(h)),"right"===this.settings.direction?s=i:"down"===this.settings.direction&&(n=e),a=setInterval((function(){var o=t._initializeItem(h),m=t._filledItemInit(h,o,s,n,i,e);s=m.posX,n=m.posY,r=m.filled,h=t._getNextItem(h),r&&(clearInterval(a),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"),a=parseFloat(i.outerWidth()),o=parseFloat(i.outerHeight()),m=0,l=0,d=!1;switch(i.css({display:"block",opacity:0}),this.settings.direction){case"left":m=e,this._itemSetTransform(i,{posX:m,posY:s}),(e+=a)>n&&(d=!0);break;case"right":m=e-=a,this._itemSetTransform(i,{posX:m,posY:s}),e<0&&(d=!0);break;case"up":l=s,this._itemSetTransform(i,{posX:e,posY:l}),(s+=o)>r&&(d=!0);break;case"down":l=s-=o,this._itemSetTransform(i,{posX:e,posY:l}),s<0&&(d=!0)}return i.stop().animate({opacity:1},1e3,"linear",(function(){})),this.visibleItems.push({$item:i,itemId:h,posX:m,posY:l}),this._setCurrentHeight(),{posX:e,posY:s,filled:d}},_setDirection:function(t){return!!$.inArray(t,this.settings.directions)&&(t!==this.settings.directions&&(this.settings.direction=t,this._timerStop(),this._resetItems(),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.padding),this.$elmt.css(this.settings.margin),this.$elmt.css(this.settings.borderRadius),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.height?this.settings.height:"100%",i=this.settings.minHeight?this.settings.minHeight:0,e=this.settings.maxHeight?this.settings.maxHeight:"none";this.$elmt.css({height:t,minHeight:i,maxHeight:e}),this.$contents.css({height:t})}else this.$elmt.css({height:"auto",minHeight:0,maxHeight:"none"}),this.$contents.css({height:"auto"})},_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"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=[],a=!1;$.each(r,(function(s,r){String(r.id)===String(i)?"after"===e?(h.push(r),$.each(t,(function(t,i){h.push(i)})),a=!0):"before"===e?($.each(t,(function(t,i){h.push(i)})),h.push(r),a=!0):a||($.each(t,(function(t,i){h.push(i),n.push(String(i.uniq_id))})),a=!0):h.push(r)})),a||($.each(this.settings.items,(function(t,i){h.push(i)})),a=!0),t=h}this.settings.items=t,this.total=t.length,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},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.$contents.off("mouseenter",{self:this},this._mouseenter),this.$contents.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,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:{},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.$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;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,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.$contents.on("mouseenter",{self:this},this._mouseenter),this.$contents.on("mouseleave",{self:this},this._mouseleave),this.settings.showEditor?dittyEditorInit(this):this.trigger("start_live_updates"),setTimeout((function(){for(var t=0;t<this.total;t++)this._preloadItem(this.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.settings.items[t].html);if(e.css({top:0,left:0}),this.$items.children(".ditty-item--"+this.settings.items[t].id).not(".ditty-item--clone").length>0&&e.addClass("ditty-item--clone"),this._styleItem(e),this.settings.items[t].css&&dittyLayoutCss(this.settings.items[t].css,this.settings.items[t].layout_id),this._itemSpacing(e),this._itemSetTransform(e,this._itemResetPosition(e)),this.$items.append(e),e.css({display:"block",top:0,left:0,opacity:1}),e.addClass("ditty-item--current"),null!==this.$currentItem&&this.$currentItem.removeClass("ditty-item--current"),this.$currentItem=e,null===this.$lastItem&&(e.addClass("ditty-item--last"),this.$lastItem=e),this.settings.item=t,this.nextItem=this._getNextItem(t),"custom"!==i){var s=this._itemResetPosition(e);this._itemSetTransform(e,s),this.visibleItems.push({$item:e,itemId:this.settings.items[t].id,posX:s.posX,posY:s.posY}),this._setCurrentHeight()}return this.trigger("active_items_update"),e},_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,a=null;this._isItemEnabled(h)||(h=this._getNextItem(h)),"right"===this.settings.direction?s=i:"down"===this.settings.direction&&(n=e),a=setInterval((function(){var o=t._initializeItem(h),m=t._filledItemInit(h,o,s,n,i,e);s=m.posX,n=m.posY,r=m.filled,h=t._getNextItem(h),r&&(clearInterval(a),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"),a=parseFloat(i.outerWidth()),o=parseFloat(i.outerHeight()),m=0,l=0,d=!1;switch(i.css({display:"block",opacity:0}),this.settings.direction){case"left":m=e,this._itemSetTransform(i,{posX:m,posY:s}),(e+=a)>n&&(d=!0);break;case"right":m=e-=a,this._itemSetTransform(i,{posX:m,posY:s}),e<0&&(d=!0);break;case"up":l=s,this._itemSetTransform(i,{posX:e,posY:l}),(s+=o)>r&&(d=!0);break;case"down":l=s-=o,this._itemSetTransform(i,{posX:e,posY:l}),s<0&&(d=!0)}return i.stop().animate({opacity:1},1e3,"linear",(function(){})),this.visibleItems.push({$item:i,itemId:h,posX:m,posY:l}),this._setCurrentHeight(),{posX:e,posY:s,filled:d}},_setDirection:function(t){return!!$.inArray(t,this.settings.directions)&&(t!==this.settings.directions&&(this.settings.direction=t,this._timerStop(),this._resetItems(),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.padding),this.$elmt.css(this.settings.margin),this.$elmt.css(this.settings.borderRadius),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.height?this.settings.height:"100%",i=this.settings.minHeight?this.settings.minHeight:0,e=this.settings.maxHeight?this.settings.maxHeight:"none";this.$items.css({height:t,minHeight:i,maxHeight:e})}else this.$items.css({height:"auto",minHeight:"",maxHeight:""})},_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();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=[],a=!1;$.each(r,(function(s,r){String(r.id)===String(i)?"after"===e?(h.push(r),$.each(t,(function(t,i){h.push(i)})),a=!0):"before"===e?($.each(t,(function(t,i){h.push(i)})),h.push(r),a=!0):a||($.each(t,(function(t,i){h.push(i),n.push(String(i.uniq_id))})),a=!0):h.push(r)})),a||($.each(this.settings.items,(function(t,i){h.push(i)})),a=!0),t=h}this.settings.items=t,this.total=t.length,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},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.$contents.off("mouseenter",{self:this},this._mouseenter),this.$contents.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-editor.js CHANGED
@@ -14,6 +14,7 @@
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/ditty-list-display-editor.js';
 
17
 
18
  jQuery( document ).ready( function( $ ) {
19
 
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/ditty-list-display-editor.js';
17
+ // @codekit-append 'editor/ditty-ticker-display-editor.js';
18
 
19
  jQuery( document ).ready( function( $ ) {
20
 
includes/js/ditty-editor.min.js CHANGED
@@ -14,6 +14,7 @@
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/ditty-list-display-editor.js';
 
17
 
18
  jQuery( document ).ready( function( $ ) {
19
 
@@ -5534,7 +5535,7 @@ function dittyDraftDisplayGet( elmt, displayId, key ) {
5534
  }
5535
 
5536
  if ( response.code ) {
5537
- dittyLayoutCss( response.code, self.layoutId );
5538
  } else {
5539
  self._showErrorNotice();
5540
  }
@@ -5781,4 +5782,42 @@ jQuery( document ).ready( function( $ ) {
5781
 
5782
  }() );
5783
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5784
  } );
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/ditty-list-display-editor.js';
17
+ // @codekit-append 'editor/ditty-ticker-display-editor.js';
18
 
19
  jQuery( document ).ready( function( $ ) {
20
 
5535
  }
5536
 
5537
  if ( response.code ) {
5538
+ dittyLayoutCss( response.code, self.layoutId, 'update' );
5539
  } else {
5540
  self._showErrorNotice();
5541
  }
5782
 
5783
  }() );
5784
 
5785
+ } );
5786
+
5787
+ /* global dittyVars:true */
5788
+
5789
+ jQuery( document ).ready( function( $ ) {
5790
+
5791
+ // Setup strict mode
5792
+ (function() {
5793
+
5794
+ "use strict";
5795
+
5796
+ function modifyHeights( $minHeight, $maxHeight, directionValue ) {
5797
+ console.log( directionValue );
5798
+ if ( 'down' === directionValue || 'up' === directionValue ) {
5799
+ $minHeight.show();
5800
+ $maxHeight.show();
5801
+ } else {
5802
+ $minHeight.hide();
5803
+ $maxHeight.hide();
5804
+ }
5805
+ }
5806
+
5807
+ $( '#ditty-editor' ).on( 'ditty_display_editor_panel_init', '.ditty-editor__panel--displayEditor', function( e, editorPanel ) {
5808
+ if ( 'ticker' === editorPanel.displayType ) {
5809
+ var $form = editorPanel.$form,
5810
+ $minHeight = $form.find( '.ditty-field--minHeight' ),
5811
+ $maxHeight = $form.find( '.ditty-field--maxHeight' );
5812
+
5813
+ // Set heights
5814
+ modifyHeights( $minHeight, $maxHeight, $form.find( 'input[name="direction"]:checked' ).val() );
5815
+ $form.find( 'input[name="direction"]' ).on( 'change', function() {
5816
+ modifyHeights( $minHeight, $maxHeight, $( this ).val() );
5817
+ } );
5818
+ }
5819
+ } );
5820
+
5821
+ }() );
5822
+
5823
  } );
includes/js/ditty-editor.min.min.js DELETED
@@ -1,6 +0,0 @@
1
- function dittyEditorInit(t){if(!t)return!1;var i="auto-draft"===t.options("status")&&"settings";jQuery("#ditty-editor__settings").ditty_editor({ditty:t,panel:i})}function dittyGetItemsById(t,i){var e=[];return jQuery.each(t,(function(t,s){String(s.id)===String(i)&&e.push(s)})),e}function dittyItemsReorder(t,i){var e=[];return jQuery.each(i,(function(i,s){e=jQuery.merge(e,dittyGetItemsById(t,s))})),e}function dittyDraftUpdate(t,i,e,s){var a=t.settings.editor.getDraftValues(i);return a||(a={}),e?a[e]=s:a=s,t.settings.editor.updateDraftValues(i,a)}function dittyDraftGet(t,i,e){var s=t.settings.editor.getDraftValues(i);return!!s&&(e&&s[e]?s[e]:s)}function dittyDraftDelete(t,i,e){var s=i.settings.editor.getDraftValues(t),a={};return jQuery.each(s,(function(t,i){String(e)!==String(t)&&(a[t]=i)})),"new-"!==String(e).substring(0,4)&&(a[e]="DELETE"),i.settings.editor.updateDraftValues(t,a)}function dittyDraftItemDelete(t,i){return dittyDraftDelete("items",t,i)}function dittyDraftLayoutDelete(t,i){return dittyDraftDelete("layouts",t,i)}function dittyDraftDisplayDelete(t,i){return dittyDraftDelete("displays",t,i)}function dittyDraftItemUpdateData(t,i,e,s){var a=t.settings.editor.getDraftValues("items");return a||(a={}),a[i]||(a[i]={}),a[i].data||(a[i].data={}),e?a[i].data[e]=s:a[i].data=s,t.settings.editor.updateDraftValues("items",a)}function dittyDraftItemGetData(t,i,e){var s=t.settings.editor.getDraftValues("items");return!!s[i]&&(!!s[i].data&&(e?s[i].data[e]?s[i].data[e]:void 0:s[i].data))}function dittyDraftItemUpdateMeta(t,i,e,s){var a=t.settings.editor.getDraftValues("items");return a||(a={}),a[i]||(a[i]={}),a[i].meta||(a[i].meta={}),e?a[i].meta[e]=s:a[i].meta=s,t.settings.editor.updateDraftValues("items",a)}function dittyDraftItemGetMeta(t,i,e){var s=t.settings.editor.getDraftValues("items");return!!s[i]&&(!!s[i].meta&&(e?s[i].meta[e]?s[i].meta[e]:void 0:s[i].meta))}function dittyDraftLayoutUpdate(t,i,e,s){var a=t.settings.editor.getDraftValues("layouts");return a||(a={}),a[i]||(a[i]={}),e?a[i][e]=s:a[i]=s,t.settings.editor.updateDraftValues("layouts",a)}function dittyDraftLayoutGet(t,i,e){var s=t.settings.editor.getDraftValues("layouts");return!!s[i]&&(e?s[i][e]?s[i][e]:void 0:s[i])}function dittyDraftDisplayUpdate(t,i,e,s){var a=t.settings.editor.getDraftValues("displays");return a||(a={}),a[i]||(a[i]={}),e?a[i][e]=s:a[i]=s,t.settings.editor.updateDraftValues("displays",a)}function dittyDraftDisplayGet(t,i,e){var s=t.settings.editor.getDraftValues("layouts");return!!s[i]&&(e?s[i][e]?s[i][e]:void 0:s[i])}function dittyGetItemsById(t,i){var e=[];return jQuery.each(t,(function(t,s){String(s.id)===String(i)&&e.push(s)})),e}function dittyItemsReorder(t,i){var e=[];return jQuery.each(i,(function(i,s){e=jQuery.merge(e,dittyGetItemsById(t,s))})),e}function dittyDraftUpdate(t,i,e,s){var a=t.settings.editor.getDraftValues(i);return a||(a={}),e?a[e]=s:a=s,t.settings.editor.updateDraftValues(i,a)}function dittyDraftGet(t,i,e){var s=t.settings.editor.getDraftValues(i);return!!s&&(e&&s[e]?s[e]:s)}function dittyDraftDelete(t,i,e){var s=i.settings.editor.getDraftValues(t),a={};return jQuery.each(s,(function(t,i){String(e)!==String(t)&&(a[t]=i)})),"new-"!==String(e).substring(0,4)&&(a[e]="DELETE"),i.settings.editor.updateDraftValues(t,a)}function dittyDraftItemDelete(t,i){return dittyDraftDelete("items",t,i)}function dittyDraftLayoutDelete(t,i){return dittyDraftDelete("layouts",t,i)}function dittyDraftDisplayDelete(t,i){return dittyDraftDelete("displays",t,i)}function dittyDraftItemUpdateData(t,i,e,s){var a=t.settings.editor.getDraftValues("items");return a||(a={}),a[i]||(a[i]={}),a[i].data||(a[i].data={}),e?a[i].data[e]=s:a[i].data=s,t.settings.editor.updateDraftValues("items",a)}function dittyDraftItemGetData(t,i,e){var s=t.settings.editor.getDraftValues("items");return!!s[i]&&(!!s[i].data&&(e?s[i].data[e]?s[i].data[e]:void 0:s[i].data))}function dittyDraftItemUpdateMeta(t,i,e,s){var a=t.settings.editor.getDraftValues("items");return a||(a={}),a[i]||(a[i]={}),a[i].meta||(a[i].meta={}),e?a[i].meta[e]=s:a[i].meta=s,t.settings.editor.updateDraftValues("items",a)}function dittyDraftItemGetMeta(t,i,e){var s=t.settings.editor.getDraftValues("items");return!!s[i]&&(!!s[i].meta&&(e?s[i].meta[e]?s[i].meta[e]:void 0:s[i].meta))}function dittyDraftLayoutUpdate(t,i,e,s){var a=t.settings.editor.getDraftValues("layouts");return a||(a={}),a[i]||(a[i]={}),e?a[i][e]=s:a[i]=s,t.settings.editor.updateDraftValues("layouts",a)}function dittyDraftLayoutGet(t,i,e){var s=t.settings.editor.getDraftValues("layouts");return!!s[i]&&(e?s[i][e]?s[i][e]:void 0:s[i])}function dittyDraftDisplayUpdate(t,i,e,s){var a=t.settings.editor.getDraftValues("displays");return a||(a={}),a[i]||(a[i]={}),e?a[i][e]=s:a[i]=s,t.settings.editor.updateDraftValues("displays",a)}function dittyDraftDisplayGet(t,i,e){var s=t.settings.editor.getDraftValues("layouts");return!!s[i]&&(e?s[i][e]?s[i][e]:void 0:s[i])}jQuery(document).ready((function($){!function(){"use strict";$("body").on("ditty_editor_before_panel_update",(function(t,i,e,s,a,d){switch(d.delayedSubmitDisable(),$.protip({defaults:{position:"top",size:"small",scheme:"black",classes:"ditty-protip"}}),i){case"settings":e.hasClass("init")||e.ditty_settings_panel({editor:d});break;case"items":e.hasClass("init")?e.ditty_items_panel("panelVisible"):e.ditty_items_panel({editor:d});break;case"displays":e.find(".ditty-data-list__item").removeClass("editing"),e.hasClass("init")?e.ditty_displays_panel("panelVisible"):e.ditty_displays_panel({editor:d});break;case"item_types":e.find(".ditty-data-list__item").removeClass("editing"),e.hasClass("init")?e.ditty_item_types_panel("panelVisible"):e.ditty_item_types_panel({editor:d});break;case"item_editor":e.ditty_item_editor_panel({editor:d});break;case"display_editor":e.ditty_display_editor_panel({editor:d});break;case"layouts":"layoutHtmlEditor"!==s&&"layoutCssEditor"!==s&&e.ditty_layouts_panel({editor:d});break;case"layout_variations":e.hasClass("init")?e.ditty_layout_variations_panel("panelVisible"):e.ditty_layout_variations_panel({editor:d});break;case"layout_html_editor":e.ditty_layout_html_editor_panel({editor:d,prevPanel:s});break;case"layout_css_editor":e.ditty_layout_css_editor_panel({editor:d,prevPanel:s})}})),$("body").on("ditty_editor_panel_removed",(function(t,i,e){switch(i){case"item_editor":e.ditty_item_editor_panel&&e.ditty_item_editor_panel("destroy");break;case"display_editor":e.ditty_display_editor_panel&&e.ditty_display_editor_panel("destroy");break;case"layouts":case"layouts":e.ditty_layouts_panel&&e.ditty_layouts_panel("destroy");break;case"layout_variations":e.ditty_layout_variations_panel&&e.ditty_layout_variations_panel("destroy");break;case"layout_html_editor":e.ditty_layout_html_editor_panel&&e.ditty_layout_html_editor_panel("destroy");break;case"layout_css_editor":e.ditty_layout_css_editor_panel&&e.ditty_layout_css_editor_panel("destroy")}}))}()})),dittyEditorInit(),function($){"use strict";var t={listType:"toggle",showAll:!0,activeFilter:"*",filter:".ditty-data-list__filter",filterSelector:"filter",item:".ditty-data-list__item",itemSelector:"filter"},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_ui_data_list.defaults,e),this.$elmt=$(i),this.filters=[],this._init()};i.prototype={_init:function(){var t=this;this.$elmt.on("click",this.settings.filter,{self:this},this._filterClick),this.$elmt.find(this.settings.filter+".active").each((function(){t._filterList($(this).data(t.settings.filterSelector))})),"*"!==this.settings.activeFilter&&this._filterList(this.settings.activeFilter),setTimeout((function(){t.trigger("init")}),1)},_filterList:function(t){var i=this,e=this.filters;if("toggle"===this.settings.listType)this.filters.includes(t)?this.settings.showAll&&(this.filters=[],this.$elmt.find(this.settings.filter).removeClass("active"),this.$elmt.find(this.settings.item).show()):(this.filters=[t],this.$elmt.find(this.settings.filter).removeClass("active"),this.$elmt.find(this.settings.filter+"[data-"+this.settings.filterSelector+'="'+t+'"]').addClass("active"),this.$elmt.find(this.settings.item).hide(),this.$elmt.find(this.settings.item+"[data-"+this.settings.itemSelector+'="'+t+'"]').show());else if("filter"===this.settings.listType){if(this.$elmt.find(this.settings.item).hide(),this.filters.includes(t)){this.$elmt.find(this.settings.filter+"[data-"+this.settings.filterSelector+'="'+t+'"]').removeClass("active");for(var s=0;s<this.filters.length;s++)i.filters[s]===t&&i.filters.splice(s,1)}else this.$elmt.find(this.settings.filter+"[data-"+this.settings.filterSelector+'="'+t+'"]').addClass("active"),this.filters.push(t);$.each(this.filters,(function(t,e){i.$elmt.find(this.settings.item+"[data-"+this.settings.itemSelector+'="'+e+'"]').show()})),0===this.filters.length&&i.$elmt.find(this.settings.item).show()}e!==this.filters&&i.trigger("update")},_filterClick:function(t){t.preventDefault();var i=t.data.self,e=$(t.target);e.is("a")||(e=e.parents("a")),i._filterList(e.data(i.settings.filterSelector))},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings,this.filters];i&&(e=i),this.$elmt.trigger("ditty_ui_data_list_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_ui_data_list.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.off("click",this.settings.filter,{self:this},this._filterClick),this.trigger("destroy"),this.elmt._ditty_ui_data_list=null}},$.fn.ditty_ui_data_list=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_ui_data_list||(this._ditty_ui_data_list=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_ui_data_list;if(!i)throw new Error("No Ditty_UI_Data_List applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_UI_Data_List.');return void 0!==e?e:this}},$.ditty_ui_data_list={},$.ditty_ui_data_list.defaults=t}(jQuery),function($){"use strict";var t={screen:"admin",ditty:null,panel:""},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_editor.defaults,e),this.$elmt=$(i),this.ditty=this.settings.ditty,this.dittyId=this.settings.ditty.options("id"),this.dittyType=this.settings.ditty.options("type"),this.displayId=0,this.panelsLoaded=0,this.unsavedUpdates={},this.draftValues={},this.$overlay=null,this.$contents=null,this.$header=null,this.$update=null,this.$updateCount=null,this.$updateLabel=null,this.$tabs=null,this.$panels=null,this.currentTab=0,this.currentPanel=this.settings.panel,this.delayedSubmit=!1,this.tabs=[],this.panels=[],this.activeItems=[],this._init()};i.prototype={_init:function(){var t,i,e,s,a,d,r,o=this;t=$('<div class="ditty-editor__contents"></div>'),this.$contents=t,i=$('<div class="ditty-editor__header"></div>'),this.$header=i,e=$('<span class="ditty-editor__update__count"></span>'),this.$updateCount=e,s=$('<span class="ditty-editor__update__label">Save Ditty</span>'),this.$updateLabel=s,a=$('<button type="submit" class="ditty-editor__update ditty-button ditty-button--primary"></button>'),this.$update=a,d=$('<div class="ditty-editor__tabs"></div>'),this.$tabs=d,r=$('<div class="ditty-editor__panels"></div>'),this.$panels=r,a.prepend(e,s),i.append(a),t.append(i,d,r),this.$elmt.append(t),this.$overlay=$('<div class="ditty-updating-overlay ditty-admin-item__overlay"><div class="ditty-updating-overlay__inner"><i class="fas fa-sync-alt fa-spin"></i></div></div>'),this.$elmt.append(this.$overlay),$(document).on("postbox-moved",{self:this},this._postboxMoved),$(document).on("postboxes-columnchange",{self:this},this._postboxMoved),$(window).on("beforeunload",{self:this},this._beforeunload),this.ditty.$elmt.on("ditty_active_items_update",{self:this},this._dittyItemsUpdated),this.ditty.$elmt.on("ditty_disabled_items_update",{self:this},this._disabledItemsUpdate),this.$tabs.on("click",".ditty-editor__tab",{self:this},this._showPanel),this.$update.on("click",{self:this},this._saveClick),this.$panels.on("ditty_slider_init",{self:this},this._editorLoaded),this.$panels.on("ditty_slider_before_slide_update",{self:this},this._beforeSlideUpdate),this.$panels.on("ditty_slider_after_slide_update",{self:this},this._afterSlideUpdate),this.$panels.on("ditty_slider_slide_removed",{self:this},this._slideRemoved),this._loadContents(),this.trigger("stop_live_updates"),setTimeout((function(){o.trigger("init")}),1)},_loadContents:function(){var t=this,i={action:"ditty_editor_load_contents",ditty_id:this.dittyId,security:dittyVars.security};$.post(dittyVars.ajaxurl,i,(function(i){t._initTabs(i.tabs),t._initPanels(i.panels),t._initSlider()}),"json")},_editorLoaded:function(t){var i=t.data.self;$("body").trigger("ditty_editor_loaded",[i])},_setUpdateCount:function(){},_initSlider:function(){var t=this.tabs[0].id;this.currentPanel&&""!==this.currentPanel&&(t=this.currentPanel),this.$panels.ditty_slider({transition:"fade",transitionSpeed:.75,heightSpeed:.75,touchSwipe:!1,slides:this.panels,slideId:t})},_beforeSlideUpdate:function(t,i,e,s,a){var d=t.data.self;d.updateStart(),d._updateTab(e.id),$("body").trigger("ditty_editor_before_panel_update",[e.id,e.$elmt,a.id,a.$elmt,d])},_afterSlideUpdate:function(t,i,e,s,a){var d=t.data.self;d.updateStop(),$("body").trigger("ditty_editor_after_panel_update",[e.id,e.$elmt,a.id,a.$elmt,d])},_slideRemoved:function(t,i){var e=t.data.self;$("body").trigger("ditty_editor_panel_removed",[i.id,i.$elmt,e])},_showPanel:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("a")?$(t.target):$(t.target).parent("a"),s=e.data("panel"),a=parseInt(e.data("index"));if(s===i.currentTab)return!1;var d=a>i.currentTab?"slideLeft":"slideRight";i.$panels.ditty_slider("options","transition",d),i.$panels.ditty_slider("showSlideById",s),i.currentTab=a,i.$elmt.trigger("ditty_editor_add_drafts")},_updateTab:function(t){var i=$('.ditty-editor__tab[data-panel="'+t+'"]');void 0!==i[0]&&($(".ditty-editor__tab").removeClass("active"),i.addClass("active"),this.currentTab=parseInt(i.data("index")))},_initTabs:function(t){var i=this,e=0;$.each(t,(function(t,s){var a=$('<a href="#" class="ditty-editor__tab ditty-editor__tab--'+t+'" data-panel="'+t+'" data-index="'+e+'"><i class="'+s.icon+'"></i><span>'+s.label+"</span></a>");i.$tabs.append(a),i.tabs.push({id:t,tab:a}),e++}))},_initPanels:function(t){var i=this;$.each(t,(function(t,e){var s='<div class="ditty-editor__panel ditty-editor__panel--'+t+'">'+e+"</div>";i.panels.push({id:t,html:s,cache:!0})}))},_initFields:function(t){t.find(".ditty-data-list").ditty_ui_data_list(),t.trigger("ditty_init_fields"),$.protip({defaults:{position:"top",size:"small",scheme:"black",classes:"ditty-protip"}})},saveDitty:function(t){var i=this,e=i.dittyId;i.$updateLabel.text("Updating..."),i.updateStart();var s={action:"ditty_editor_save",ditty_id:e,draft_values:i.draftValues,return_items:1,security:dittyVars.security};s=$.extend({},s,t),$.post(dittyVars.ajaxurl,s,(function(t){$("body").trigger("ditty_editor_save_ditty_response",[t]),t.display_items&&i.ditty.options("items",t.display_items),i.draftValues={},i.unsavedUpdates={},i._setUpdateCount(),i.$elmt.removeClass("ditty-editor--updates-exist"),i.$updateLabel.text("Ditty Saved!"),setTimeout((function(){i.$updateLabel.text("Save Ditty")}),2e3),i.updateStop(),t.new_ditty_url&&window.history.pushState(null,"","/wp-admin/post.php?post="+e+"&action=edit")}))},_saveClick:function(t){t.preventDefault();var i=t.data.self;i.$elmt.trigger("ditty_editor_save_drafts"),i.delayedSubmit||i.saveDitty()},_dittyItemsUpdated:function(t,i,e){var s=t.data.self;s.activeItems=e,s.trigger("active_items_update")},_disabledItemsUpdate:function(t,i){var e=t.data.self;$.each(i,(function(t,i){"disabled"===i?e.$elmt.find("#ditty-editor-item--"+t).addClass("ditty-editor-item--disabled"):e.$elmt.find("#ditty-editor-item--"+t).removeClass("ditty-editor-item--disabled")}))},_postboxMoved:function(t,i){if(!window.tinymce)return!1;$(i).find(".wp-editor-area").each((function(){var t=$(this).attr("id");tinymce.execCommand("mceRemoveEditor",!0,t),tinymce.execCommand("mceAddEditor",!0,t)}))},_beforeunload:function(t){var i=t.data.self;return Object.keys(i.unsavedUpdates).length>0||void 0},_windowResize:function(t){t.preventDefault()},_options:function(t){return this.settings[t]},panelExists:function(t){var i=this.$panels.ditty_slider("options","slides"),e=!1;return $.each(i,(function(i,s){String(s.id)!==String(t)||(e=!0)})),e},showPanel:function(t,i){i&&this.$panels.ditty_slider("addSlideById",t,i),this.$panels.ditty_slider("showSlideById",t,!0)},updateExists:function(t,i){if(void 0===this.unsavedUpdates[t]&&(this.unsavedUpdates[t]=[]),-1!==$.inArray(i,this.unsavedUpdates[t]))return!0},addUpdate:function(t,i){var e=!1;return void 0===this.unsavedUpdates[t]&&(this.unsavedUpdates[t]=[]),-1===$.inArray(i,this.unsavedUpdates[t])&&(e=!0,this.unsavedUpdates[t].push(i)),this._setUpdateCount(),this.$elmt.addClass("ditty-editor--updates-exist"),e},removeUpdate:function(t,i){if(void 0===this.unsavedUpdates[t])return!1;if(-1===$.inArray(i,this.unsavedUpdates[t]))return!1;var e=!1,s=[];return $.each(this.unsavedUpdates[t],(function(t,a){String(i)===String(a)?e=!0:s.push(a)})),this.unsavedUpdates[t]=s,this._setUpdateCount(),""===this.$updateCount.text()&&this.$elmt.removeClass("ditty-editor--updates-exist"),e},updateStart:function(){this.$overlay.fadeIn()},updateStop:function(){this.$overlay.fadeOut()},initFields:function(t){this._initFields(t)},updateDraftValues:function(t,i){return this.$elmt.addClass("ditty-editor--updates-exist"),t?(this.draftValues[t]=i,"development"===dittyVars.mode&&window.console&&console.log("draftValues:",this.draftValues),this.draftValues[t]):(this.draftValues=i,"development"===dittyVars.mode&&window.console&&console.log("draftValues:",this.draftValues),this.draftValues)},getDraftValues:function(t){return t?!!this.draftValues[t]&&this.draftValues[t]:this.draftValues},delayedSubmitEnable:function(){this.delayedSubmit=!0},delayedSubmitDisable:function(){this.delayedSubmit=!1},trigger:function(t,i){var e=[];switch(t){case"active_items_update":e=[this.ditty,this.activeItems];break;case"stop_live_updates":e=[this.dittyId];break;default:e=[this.settings]}i&&(e=i),this.$elmt.trigger("ditty_editor_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e),$("body").trigger("ditty_"+t,e)},_getPanelOption:function(t){return"elmnt"===t?this.$panels:this.settings[t]},_setPanelOption:function(t,i){if(void 0===i)return!1;this.$panels.ditty_slider("options",t,i),this.trigger("update")},panelOptions:function(t,i){var e=this;if("object"==typeof t)$.each(t,(function(t,i){e._setPanelOption(t,i)}));else{if("string"!=typeof t)return e.$panels.ditty_slider("options");if(void 0===i)return e._getPanelOption(t);e._setPanelOption(t,i)}},_getOption:function(t){return"elmnt"===t?this:this.settings[t]},_setOption:function(t,i){if(void 0===i)return!1;this.settings[t]=i,this.trigger("update")},options:function(t,i){var e=this;if("object"==typeof t)$.each(t,(function(t,i){e._setOption(t,i)}));else{if("string"!=typeof t)return e.settings;if(void 0===i)return e._getOption(t);e._setOption(t,i)}},destroy:function(){this.$panels.ditty_slider&&this.$panels.ditty_slider("destroy"),$(document).off("postbox-moved",{self:this},this._postboxMoved),$(document).off("postboxes-columnchange",{self:this},this._postboxMoved),$(window).off("beforeunload",{self:this},this._beforeunload),this.ditty.$elmt.off("ditty_active_items_update",{self:this},this._dittyItemsUpdated),this.ditty.$elmt.off("ditty_disabled_items_update",{self:this},this._disabledItemsUpdate),this.$tabs.off("click","ditty-editor__tab",{self:this},this._showPanel),this.$update.off("click",{self:this},this._saveClick),this.$panels.off("ditty_slider_init",{self:this},this._editorLoaded),this.$panels.off("ditty_slider_before_slide_update",{self:this},this._beforeSlideUpdate),this.$panels.off("ditty_slider_after_slide_update",{self:this},this._afterSlideUpdate),this.$panels.off("ditty_slider_slide_removed",{self:this},this._slideRemoved),this.trigger("destroy"),this.elmt._ditty_editor=null}},$.fn.ditty_editor=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_editor||(this._ditty_editor=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_editor;if(!i)throw new Error("No Ditty_Editor applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Editor.');return void 0!==e?e:this}},$.ditty_editor={},$.ditty_editor.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_settings_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$title=this.$elmt.find('input[name="title]'),this.$previewBg=this.$elmt.find('input[name="previewBg"]'),this.$previewPaddingTop=this.$elmt.find('input[name="previewPadding[paddingTop]"]'),this.$previewPaddingBottom=this.$elmt.find('input[name="previewPadding[paddingBottom]"]'),this.$previewPaddingLeft=this.$elmt.find('input[name="previewPadding[paddingLeft]"]'),this.$previewPaddingRight=this.$elmt.find('input[name="previewPadding[paddingRight]"]'),this.$postTitle=$(".ditty-post__title"),this.$editorPreview=$("#ditty-editor__preview"),this.dittyId=this.$form.data("ditty_id"),this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this.settings.editor.initFields(this.$elmt),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.on("submit",{self:this},this._submitForm),this.$form.on("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.on("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.on("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.on("keyup change",'input[name="title"]',{self:this},this._titleChange),this.$form.on("keyup change",".ditty-field--preview_settings *",{self:this},this._previewBgChange),this.$elmt.addClass("init")},_checkUpdates:function(t){var i=t?t.data.self:this;i.$form.serialize()!==i.initData?(i.settings.editor.addUpdate("settings",i.itemId),i.settings.editor.delayedSubmitEnable()):i.settings.editor.removeUpdate("settings",i.itemId)},_titleChange:function(t){var i=t?t.data.self:this,e=$(t.target).val();i.$postTitle.text(e)},_previewBgChange:function(t){var i=t?t.data.self:this,e={backgroundColor:i.$previewBg.val(),paddingTop:i.$previewPaddingTop.val(),paddingBottom:i.$previewPaddingBottom.val(),paddingLeft:i.$previewPaddingLeft.val(),paddingRight:i.$previewPaddingRight.val()};i.$editorPreview.css(e)},_addDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.dittyId;i.settings.editor.updateStart();var s={action:"ditty_editor_settings_update",ditty_id:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:s,success:function(t){i.initData=i.$form.serialize(),dittyDraftUpdate(i,"settings",!1,t),i.settings.editor.delayedSubmitDisable(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty({return_items:0}),i.afterUpdateAction=""}})},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_settings_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_settings_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.$form.off("submit",{self:this},this._submitForm),this.$form.off("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.off("keyup change",'input[name="previewBg"]',{self:this},this._previewBg_cahnge),this.$form.off("keyup change",'input[name="title"]',{self:this},this._titleChange),this.$form.off("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.off("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.trigger("destroy"),this.elmt._ditty_settings_panel=null}},$.fn.ditty_settings_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_settings_panel||(this._ditty_settings_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_settings_panel;if(!i)throw new Error("No Ditty_Settings_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Settings_Panel.');return void 0!==e?e:this}},$.ditty_settings_panel={},$.ditty_settings_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_items_panel.defaults,e),this.$elmt=$(i),this.$add=$(i).find(".ditty-editor-options__add"),this.$contents=$(i).find(".ditty-editor__panel__contents"),this.$list=$(i).find(".ditty-data-list"),this.$listItems=$(i).find(".ditty-data-list__items"),this.isEmptyTicker=!1,this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.settings.editor.$elmt.on("ditty_editor_aactive_items_update",{self:this},this._dittyActiveItemsUpdated),this.$add.on("click",{self:this},this._add_item),this.$elmt.on("click",".ditty-data-list__item",{self:this},this._showItem),this.$elmt.on("click",".ditty-data-list__item__icon",{self:this},this._editType),this.$elmt.on("click",".ditty-data-list__item__edit",{self:this},this._editItem),this.$elmt.on("click",".ditty-data-list__item__layout",{self:this},this._editLayoutVariations),this.$elmt.on("click",".ditty-data-list__item__clone",{self:this},this._cloneItem),this.$elmt.on("click",".ditty-data-list__item__delete",{self:this},this._deleteItem),this.$list.on("click",".ditty-editor-item > a",{self:this},this._actionClick),$("body").on("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),1>this.$elmt.find(".ditty-data-list__item").length&&(this.isEmptyTicker=!0,this.$add.trigger("click")),this._initializeSorting(),this._highlightListItems(this.settings.editor.activeItems)},dittyUpdateSavedDraftLayouts:function(t,i){$.each($(".ditty-editor-item"),(function(){var e=$(this).data("layout_value");$.each(e,(function(s,a){String(a)===String(t)&&(e[s]=String(i))})),$(this).attr("data-layout_value",e).data("layout_value",e)}))},_dittyEditorSaveResponse:function(t,i){var e=t.data.self;i.ditty_new_item_ids&&$.each(i.ditty_new_item_ids,(function(t,i){var e=$("#ditty-editor-item--"+t);e.length&&(e.attr("id","ditty-editor-item--"+i),e.attr("data-item_id",i).data("item_id",i))})),i.ditty_new_layout_ids&&$.each(i.ditty_new_layout_ids,(function(t,i){e.dittyUpdateSavedDraftLayouts(t,i)}))},_highlightListItem:function(t){var i=t.id+"";i=i.split("_"),this.$elmt.find("#ditty-editor-item--"+i[0]).addClass("active")},_highlightListItems:function(t){this.$elmt.find(".ditty-data-list__item").removeClass("active");var i=this;Array.isArray(t)?$.each(t,(function(t,e){i._highlightListItem(e)})):i._highlightListItem(t)},_dittyActiveItemsUpdated:function(t,i,e){t.data.self._highlightListItems(e)},_initializeSorting:function(){var t=this;this.$listItems.sortable({handle:".ditty-data-list__item__move",items:".ditty-data-list__item",axis:"y",start:function(t,i){$(i.item).addClass("ditty-data-list__item--moving")},stop:function(i,e){$(e.item).removeClass("ditty-data-list__item--moving"),t.settings.editor.addUpdate("item_order",t.settings.editor.dittyId)},update:function(){t._updateItemIndexes("updateDitty")}})},_showItem:function(t){t.preventDefault();var i=t.data.self;if(!$(t.target).is("a")&&!$(t.target).parent().is("a")){var e=($(t.target).is(".ditty-data-list__item")?$(t.target):$(t.target).parents(".ditty-data-list__item")).data("item_id");i.settings.editor.ditty.showItem(e)}},_actionClick:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("a")?$(t.target):$(t.target).parent("a"),s=e.parents(".ditty-data-list__item"),a=s.data("ditty_id"),d=s.data("item_id");dittyVars.editor.currentItem=s,$("body").trigger("ditty_editor_item_action_click",[e,s,d,a,i.settings.editor])},_editType:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item");e.trigger("click"),e.addClass("editing"),i.settings.editor.updateStart(),i.settings.editor.panelOptions("transition","slideRight"),i.settings.editor.showPanel("item_types")},_editItem:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("item_id");e.trigger("click"),e.addClass("editing"),i.settings.editor.updateStart();var a={action:"ditty_editor_item_fields",item_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--item_editor">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("item_editor",e)}}))},_editLayoutVariations:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("item_type"),a=e.data("layout_value"),d=e.find(".ditty-data-list__item__label").html();e.trigger("click"),e.addClass("editing"),i.settings.editor.updateStart();var r={action:"ditty_editor_layout_variations",ditty_id:i.settings.editor.dittyId,item_type:s,item_label:d,layout_value:a,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,r,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--layout-variations">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("layout_variations",e)}}))},_add_item:function(t){t.preventDefault();var i=t.data.self,e={action:"ditty_editor_item_add",ditty_id:i.settings.editor.dittyId,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,e,(function(t){if(t.display_items){if(i.isEmptyTicker){var e=i.settings.editor.ditty.options("items");$.each(e,(function(t,e){i.settings.editor.ditty.deleteItem(e.id)})),i.isEmptyTicker=!1}$.each(t.display_items,(function(t,e){i.settings.editor.ditty.addItem(e,0)}))}if(t.editor_item){var s=$(t.editor_item);s.hide(),i.$listItems.prepend(s),s.slideDown(),i._updateItemIndexes()}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),t.draft_id&&t.draft_meta&&dittyDraftItemUpdateMeta(i,t.draft_id,null,t.draft_meta)}),"json")},_cloneItem:function(t){t.preventDefault()
2
- ;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},this._editLayoutVariations),this.$elmt.off("click",".ditty-data-list__item__clone",{self:this},this._cloneItem),this.$elmt.off("click",".ditty-data-list__item__delete",{self:this},this._deleteItem),this.$list.off("click",".ditty-editor-item > a",{self:this},this._actionClick),$("body").off("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this.trigger("destroy"),this.elmt._ditty_items_panel=null}},$.fn.ditty_items_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_items_panel||(this._ditty_items_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_items_panel;if(!i)throw new Error("No Ditty_Items_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Items_Panel.');return void 0!==e?e:this}},$.ditty_items_panel={},$.ditty_items_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_item_types_panel.defaults,e),this.$elmt=$(i),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$editorItem=this.settings.editor.$panels.find(".ditty-editor__panel--items").find(".ditty-data-list__item.editing"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.currentType=null,this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.settings.editor.initFields(this.$elmt),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("click",".ditty-editor-item-type",{self:this},this._typeClick),this.panelVisible()},_showItemsList:function(){this.settings.editor.panelOptions("transition","slideLeft"),this.settings.editor.showPanel("items")},_backClick:function(t){t.preventDefault(),t.data.self._showItemsList()},_typeClick:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is(".ditty-editor-item-type")?$(t.target):$(t.target).parents(".ditty-editor-item-type")).data("item_type");if(e===i.currentType)i._showItemsList();else{i.settings.editor.updateStart();var s={action:"ditty_editor_item_type_update",item_id:i.editorItemId,item_type:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,s,(function(t){if(t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,i.editorItemId),t.editor_item){var e=$(t.editor_item);i.$editorItem.after(e),i.$editorItem.remove(),i.$editorItem=e}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),i._showItemsList(),i.settings.editor.updateStop()}),"json")}},panelVisible:function(){this.$editorItem=this.settings.editor.$panels.find(".ditty-editor__panel--items").find(".ditty-data-list__item.editing"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.currentType=this.$editorItem.data("item_type"),this.$elmt.find(".ditty-editor-item-type").removeClass("active"),this.$elmt.find('.ditty-editor-item-type[data-itemType="'+this.currentType+'"]').addClass("active")},panelHidden:function(){var t=this.$editorItem.find(".ditty-data-list__item__icon").children("i");t.attr("class",t.data("class"))},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_item_types_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_item_types_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$back.off("click",{self:this},this._backClick),this.$elmt.off("click",".ditty-editor-item-type",{self:this},this._typeClick),this.trigger("destroy"),this.elmt._ditty_item_types_panel=null}},$.fn.ditty_item_types_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_item_types_panel||(this._ditty_item_types_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_item_types_panel;if(!i)throw new Error("No Ditty_Item_Types_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Item_Types_Panel.');return void 0!==e?e:this}},$.ditty_item_types_panel={},$.ditty_item_types_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_item_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$preview=this.$elmt.find(".ditty-editor-options__preview"),this.$title=this.$elmt.find(".ditty-editor-options__title"),this.itemId=this.$form.data("item_id"),this.itemType=this.$form.data("item_type"),this.dittyId=this.$form.data("ditty_id"),this.$editorItem=this.settings.editor.$panels.find(".ditty-editor__panel--items").find(".ditty-data-list__item.editing"),this.$editorItemTitle=this.$editorItem.find(".ditty-data-list__item__label"),this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this.settings.editor.initFields(this.$elmt),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.on("submit",{self:this},this._submitForm),this.$back.on("click",{self:this},this._backClick),this.$preview.on("click",{self:this},this._previewClick),this.$form.on("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.on("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.on("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.on("ditty_field_update",".ditty-field__input",{self:this},this._checkUpdates)},_showItemList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","items")},_enablePreviewButton:function(){this.$preview.addClass("ditty-has-updates")},_disablePreviewButton:function(){this.$preview.removeClass("ditty-has-updates"),this.$preview.children("i").attr("class",this.$preview.children("i").data("class"))},_checkUpdates:function(t){var i=t?t.data.self:this;i.$form.serialize()!==i.initData?(i._enablePreviewButton(),i.settings.editor.addUpdate("item_settings",i.itemId),i.settings.editor.delayedSubmitEnable()):(i._disablePreviewButton(),i.settings.editor.removeUpdate("item_settings",i.itemId))},_addDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.$form.serialize()===i.initData?i._showItemList():(i.afterUpdateAction="return",i.$form.trigger("submit"))},_previewClick:function(t){t.preventDefault();var i=t.data.self;i.$form.serialize()!==i.initData&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit"))},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.itemId;i.settings.editor.updateStart();var s={action:"ditty_editor_item_update",item_id:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:s,error:function(){},success:function(t){if(t.value_updates&&i._updateValues(t.value_updates),i.initData=i.$form.serialize(),i._disablePreviewButton(),t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,e),t.editor_item){var s=$(t.editor_item).children(".ditty-data-list__item__label").text();i.$title.html(s),i.$editorItemTitle.html(s)}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),t.draft_id&&t.draft_meta&&dittyDraftItemUpdateMeta(i,t.draft_id,null,t.draft_meta),i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showItemList(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty({return_items:0}),i.afterUpdateAction=""}})},_updateValues:function(t){var i=this;$.each(t,(function(t,e){var s=i.$form.find('[name="'+t+'"]');s.length&&s.val(e)}))},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_item_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_item_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._saveDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.off("submit",{self:this},this._submitForm),this.$back.off("click",{self:this},this._backClick),this.$preview.off("click",{self:this},this._previewClick),this.$form.off("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.off("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.off("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.off("ditty_field_update",".ditty-field__input",{self:this},this._checkUpdates),this.elmt._ditty_item_editor_panel=null}},$.fn.ditty_item_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_item_editor_panel||(this._ditty_item_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_item_editor_panel;if(!i)throw new Error("No Ditty_Item_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Item_Editor_Panel.');return void 0!==e?e:this}},$.ditty_item_editor_panel={},$.ditty_item_editor_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_displays_panel.defaults,e),this.$elmt=$(i),this.$list=$(i).find(".ditty-data-list__items"),this.$contents=$(i).find(".ditty-editor__panel__contents"),this.initDisplay=null,this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.$elmt.ditty_ui_data_list({filter:".ditty-display-panel__filter",item:".ditty-editor-display",itemSelector:"display_type"}),this.initDisplay=this.$list.data("active"),this._activateDisplay(this.$list.find("#ditty-editor-display--"+this.initDisplay)),this.$elmt.on("click",".ditty-data-list__item",{self:this},this._selectDisplay),this.$elmt.on("click",".ditty-data-list__item__edit",{self:this},this._editDisplay),this.$elmt.on("click",".ditty-data-list__item__clone",{self:this},this._cloneDisplay),this.$elmt.on("click",".ditty-data-list__item__delete",{self:this},this._deleteDisplay),this.settings.editor.$elmt.on("ditty_editor_saveDrafts",{self:this},this._saveDrafts)},_saveDrafts:function(t){var i=t.data.self;i.initDisplay=i.$list.find(".ditty-editor-display.active").data("display_id")},_activateDisplay:function(t){this.$list.find(".ditty-editor-display").removeClass("active"),t.addClass("active")},_initDitty:function(t,i,e){var s=this.settings.editor.ditty.$elmt;e.display=i,e.id=this.settings.editor.ditty.options("id"),e.items=this.settings.editor.ditty.options("items"),e.height=this.settings.editor.ditty.options("height"),this.settings.editor.ditty.destroy(),s["ditty_"+t](e),this.settings.editor.ditty=s["ditty_"+t]("options","ditty")},_selectDisplay:function(t){t.preventDefault();var i=t.data.self;if($(t.target).parent().is("a"))return!1;var e=$(t.target).is(".ditty-data-list__item")?$(t.target):$(t.target).parents(".ditty-data-list__item"),s=e.data("display_id"),a=e.data("display_type");if(e.hasClass("active"))return!1;i.settings.editor.updateStart(),dittyDraftUpdate(i,"post_meta","_ditty_display",s),i._activateDisplay(e);var d={action:"ditty_editor_select_display",display_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,d,(function(t){if(!t)return!1;i._initDitty(a,s,t),i.settings.editor.updateStop()}),"json")},_cloneDisplay:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("display_id");i.settings.editor.updateStart();var a={action:"ditty_editor_display_clone",display_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t.editor_display){var s=$(t.editor_display);s.hide(),e.after(s),s.slideDown()}t.draft_id&&t.draft_data&&dittyDraftDisplayUpdate(i,t.draft_id,null,t.draft_data),i.settings.editor.updateStop()}),"json")},_deleteDisplay:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=null,a=e.data("display_id");e.hasClass("active")&&(e.prev().length?s=e.prev():e.next().length&&(s=e.next())),e.slideUp((function(){$(this).remove()})),dittyDraftDisplayDelete(i,a),null!==s&&s.trigger("click")},_editDisplay:function(t){t.preventDefault();var i=t.data.self;i.$displayEdit=$(this).parents(".ditty-data-list__item");var e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("display_id");i.settings.editor.updateStart(),e.addClass("editing");var a={action:"ditty_editor_display_fields",display_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--displayEditor">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("display_editor",e)}}))},panelVisible:function(){this.$elmt.find(".ditty-data-list__item").removeClass("editing")},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_displays_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_displays_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$elmt.ditty_ui_data_list("destroy"),this.$elmt.off("click",".ditty-data-list__item",{self:this},this._selectDisplay),this.$elmt.off("click",".ditty-data-list__item__edit",{self:this},this._editDisplay),this.$elmt.off("click",".ditty-data-list__item__clone",{self:this},this._cloneDisplay),this.$elmt.off("click",".ditty-data-list__item__delete",{self:this},this._deleteDisplay),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.trigger("destroy"),this.elmt._ditty_displays_panel=null}},$.fn.ditty_displays_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_displays_panel||(this._ditty_displays_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_displays_panel;if(!i)throw new Error("No Ditty_Displays_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Displays_Panel.');return void 0!==e?e:this}},$.ditty_displays_panel={},$.ditty_displays_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_display_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$optionsTitle=this.$elmt.find(".ditty-editor-options__title"),this.$importExportField=this.$elmt.find(".ditty-editor__import-export__field"),this.$importExportUpdate=this.$elmt.find(".ditty-editor__import-export__update"),this.displayTitle=null,this.displayId=this.settings.editor.ditty.options("display"),this.displayType=this.settings.editor.ditty.options("type"),this.$editorDisplay=this.settings.editor.$panels.find(".ditty-editor__panel--displays").find(".ditty-data-list__item.editing"),this.$editorDisplayTitle=this.$editorDisplay.find(".ditty-data-list__item__label"),this.displayOptions=null,this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){var t,i=this;this.initData=this.$form.serialize(),this.settings.editor.initFields(this.$elmt),t=this.settings.editor.ditty.$elmt["ditty_"+this.displayType]("options"),this.displayOptions=$.extend({},t),this.displayTitle=this.$optionsTitle.val(),this.$importExportUpdate.on("click",{self:this},this._importUpdate),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.on("submit",{self:this},this._submitForm),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("change",'input[type="text"], input[type="number"]',{self:this},this._textfieldListeners),this.$form.on("click",'input[type="radio"]',{self:this},this._radioListeners),this.$form.on("click",'input[type="checkbox"]',{self:this},this._checkboxListeners),this.$form.on("change","select",{self:this},this._selectListeners),this.$form.on("ditty_field_clone_update",{self:this},this._cloneListeners),setTimeout((function(){i.trigger("init",[i])}),1)},_showDisplayList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","displays")},_checkUpdates:function(){this.$form.serialize()!==this.initData?(this.settings.editor.addUpdate("displaySettings",this.displayId),this.settings.editor.delayedSubmitEnable()):this.settings.editor.removeUpdate("displaySettings",this.displayId)},_addDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.$form.serialize()===i.initData?i._showDisplayList():(i.afterUpdateAction="return",i.$form.trigger("submit"))},_submitForm:function(t){t.preventDefault();var i=t.data.self;i.settings.editor.updateStart();var e={action:"ditty_editor_display_update",display_id:i.displayId,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:e,success:function(t){i.initData=i.$form.serialize(),t.draft_id&&t.draft_label&&(i.displayTitle=t.draft_label,i.$editorDisplayTitle.text(t.draft_label),dittyDraftDisplayUpdate(i,t.draft_id,"label",t.draft_label)),t.draft_id&&t.draft_settings&&(i.displayOptions=t.draft_settings,dittyDraftDisplayUpdate(i,t.draft_id,"settings",t.draft_settings)),t.draft_settings_json&&i.$importExportField.length&&i.$importExportField.val(t.draft_settings_json),i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showDisplayList(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty(),i.afterUpdateAction=""}})},_importUpdate:function(t){t.preventDefault()},_cloneListeners:function(t,i,e){var s=t.data.self;$(t.target);s.settings.editor.ditty.options(e,i)},_textfieldListeners:function(t){var i=t.data.self,e=$(t.target),s=e.attr("name"),a=e.parents(".ditty-input--spacing__group, .ditty-input--radius__group");if(a.length){var d="",r={};a.find("input").each((function(){s=$(this).attr("name"),d=(d=s.split("["))[0];var t=s.match(/\[(.*)\]/);r[t[1]]=$(this).val()})),i.settings.editor.ditty.options(d,r)}else i.settings.editor.ditty.options(s,e.val());i._checkUpdates()},_radioListeners:function(t){var i=t.data.self,e=$(t.target),s=e.val(),a=e.attr("name");i.settings.editor.ditty.options(a,s),i._checkUpdates()},_checkboxListeners:function(t){var i=t.data.self,e=$(t.target),s=!!e.is(":checked")&&$(this).val(),a=e.attr("name");i.settings.editor.ditty.options(a,s),i._checkUpdates()},_selectListeners:function(t){var i=t.data.self,e=$(t.target),s=e.val(),a=e.attr("name");i.settings.editor.ditty.options(a,s),i._checkUpdates()},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_display_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_display_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.trigger("destroy",[this]),this.$importExportUpdate.off("click",{this:this},this._importUpdate),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.off("submit",{this:this},this._submitForm),this.$back.off("click",{this:this},this._cancel_click),this.$elmt.off("change",'input[type="text"], input[type="number"]',{self:this},this._textfieldListeners),this.$form.off("click",'input[type="radio"]',{self:this},this._radioListeners),this.$form.off("click",'input[type="checkbox"]',{self:this},this._checkboxListeners),this.$form.off("change","select",{self:this},this._selectListeners),this.$form.off("ditty_field_clone_update",{self:this},this._cloneListeners),this.elmt._ditty_display_editor_panel=null}},$.fn.ditty_display_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_display_editor_panel||(this._ditty_display_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_display_editor_panel;if(!i)throw new Error("No Ditty_Display_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Display_Editor_Panel.');return void 0!==e?e:this}},$.ditty_display_editor_panel={},$.ditty_display_editor_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layout_variations_panel.defaults,e),this.$elmt=$(i),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$list=$(i).find(".ditty-data-list__items"),this.$editorItem=dittyVars.editor.currentItem,this.editorItemLabel=this.$editorItem.find(".ditty-data-list__item__label").text(),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.editorItemType=this.$editorItem.data("item_type"),this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("click",".ditty-layout-variation__change",{self:this},this._changeTemplate),this.$elmt.on("click",".ditty-layout-variation__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.on("click",".ditty-layout-variation__edit_css",{self:this,editType:"css"},this._editLayout),$("body").on("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse)},_showItemList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","items")},_backClick:function(t){t.preventDefault(),t.data.self._showItemList()},_dittyEditorSaveResponse:function(t,i){t.data.self;i.ditty_new_layout_ids&&$.each(i.ditty_new_layout_ids,(function(t,i){var e=$('.ditty-layout-variation[data-layout_id="'+t+'"]');e.length&&e.attr("data-layout_id",i).data("layout_id",i)}))},_changeTemplate:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("layout_id"),a=e.data("layout_variation_id"),d=e.data("layout_variation_label");dittyVars.editor.currentLayoutVariation=e,i.settings.editor.updateStart(),e.addClass("editing");var r={action:"ditty_editor_layouts",ditty_id:i.editorDittyId,item_type:i.editorItemType,variation_id:a,variation_label:d,layout_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,r,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--layouts">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("layouts",e)}}))},_editLayout:function(t){t.preventDefault();var i=t.data.self,e=t.data.editType,s=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),a=s.data("layout_id"),d=s.data("item_type");dittyVars.editor.currentLayoutVariation=s,i.settings.editor.updateStart(),i.$list.find(".ditty-data-list__item").removeClass("editing"),s.addClass("editing");var r=[],o=i.settings.editor.ditty.options("items");$.each(o,(function(t,i){r.push(i.uniqId)}));var n={action:"ditty_editor_layout_fields",layout_id:a,item_type:d,ditty_id:i.editorDittyId,item_id:i.editorItemId,item_ids:r,edit_type:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,n,(function(t){if(t){var s="layout_"+e+"_editor",a='<div class="ditty-editor__panel ditty-editor__panel--'+s+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel(s,a)}}),"json")},panelVisible:function(){this.$list.find(".ditty-layout-variation").removeClass("editing")},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layout_variations_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layout_variations_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$back.off("click",{self:this},this._backClick),this.$elmt.off("click",".ditty-layout-variation__change",{self:this},this._changeTemplate),this.$elmt.off("click",".ditty-layout-variation__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.off("click",".ditty-layout-variation__edit_css",{self:this,editType:"css"},this._editLayout),$("body").off("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this.elmt._ditty_layout_variations_panel=null}},$.fn.ditty_layout_variations_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layout_variations_panel||(this._ditty_layout_variations_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layout_variations_panel;if(!i)throw new Error("No Ditty_Layout_Variations_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layout_Variations_Panel.');return void 0!==e?e:this}},$.ditty_layout_variations_panel={},$.ditty_layout_variations_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layouts_panel.defaults,e),this.$elmt=$(i),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$list=$(i).find(".ditty-data-list__items"),this.$editorItem=dittyVars.editor.currentItem,this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.editorItemtype=this.$editorItem.data("item_type"),this.$editorVariation=dittyVars.editor.currentLayoutVariation,this.editorVariationId=this.$editorVariation.data("layout_variation_id"),this.editorLayoutId=this.$editorVariation.data("layout_id"),this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("click",".ditty-data-list__item",{self:this},this._selectLayout),this.$elmt.on("click",".ditty-data-list__item__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.on("click",".ditty-data-list__item__edit_css",{self:this,editType:"css"},this._editLayout),this.$elmt.on("click",".ditty-data-list__item__clone",{self:this},this._cloneLayout),this.$elmt.on("click",".ditty-data-list__item__delete",{self:this},this._deleteLayout),this.$list.on("click",".ditty-editor-layout > a",{self:this},this._actionClick),$("body").on("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),
3
- this._activateLayout(this.$list.find("#ditty-editor-layout--"+this.editorLayoutId))},_activateLayout:function(t){this.$list.find(".ditty-editor-layout").removeClass("active"),t.addClass("active")},_showVariationsList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","layout_variations")},_backClick:function(t){t.preventDefault(),t.data.self._showVariationsList()},_dittyEditorSaveResponse:function(t,i){t.data.self;i.ditty_new_layout_ids&&$.each(i.ditty_new_layout_ids,(function(t,i){var e=$("#ditty-editor-layout--"+t);e.length&&(e.attr("id","ditty-editor-layout--"+i),e.attr("data-layout_id",i).data("layout_id",i))}))},_selectLayout:function(t){t.preventDefault();var i=t.data.self;if($(t.target).parent().is("a"))return!1;var e=$(t.target).is(".ditty-data-list__item")?$(t.target):$(t.target).parents(".ditty-data-list__item"),s=e.data("layout_id"),a=e.data("layout_version"),d=i.$editorItem.data("layout_value");if(e.hasClass("active"))return!1;$.each(d,(function(t){i.editorVariationId===t&&(d[t]=String(s))})),i.settings.editor.updateStart(),dittyDraftItemUpdateData(i,i.editorItemId,"layout_value",d),i._activateLayout(e);var r={action:"ditty_editor_select_layout",layout_id:s,item_id:i.editorItemId,ditty_id:i.editorDittyId,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,r,(function(t){if(i.settings.editor.updateStop(),t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,i.editorItemId),t.editor_item){var e=$(t.editor_item);i.$editorItem.replaceWith(e)}i.$editorItem.attr("data-layout_value",d).data("layout_value",d),i.$editorVariation.attr("data-layout_id",s).data("layout_id",s),i.$editorVariation.find(".ditty-layout-variation__template > span").text(t.layout_label),a?i.$editorVariation.find(".ditty-layout-variation__template > small").text("("+a+")"):i.$editorVariation.find(".ditty-layout-variation__template > small").text("")}),"json")},_cloneLayout:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("layout_id");i.settings.editor.updateStart();var a={action:"ditty_editor_layout_clone",layout_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t.editor_layout){var s=$(t.editor_layout);s.hide(),e.after(s),s.slideDown()}t.draft_id&&t.draft_meta&&dittyDraftLayoutUpdate(i,t.draft_id,null,t.draft_meta),i.settings.editor.updateStop()}),"json")},_deleteLayout:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=null,a=e.data("layout_id");e.hasClass("active")&&(e.prev().length?s=e.prev():e.next().length&&(s=e.next())),e.slideUp((function(){$(this).remove()})),dittyDraftLayoutDelete(i,a),null!==s&&s.trigger("click")},_editLayout:function(t){t.preventDefault();var i=t.data.self,e=t.data.editType,s=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),a=s.data("layout_id");i.settings.editor.updateStart(),i.$list.find(".ditty-data-list__item").removeClass("editing"),s.addClass("editing");var d={action:"ditty_editor_layout_fields",layout_id:a,item_id:i.editorItemId,edit_type:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,d,(function(t){if(t){var s="layout_"+e+"_editor",a='<div class="ditty-editor__panel ditty-editor__panel--'+s+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel(s,a)}}),"json")},_actionClick:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("a")?$(t.target):$(t.target).parent("a"),s=e.parents(".ditty-data-list__item"),a=s.data("layout_id");dittyVars.editor.currentLayout=s,$("body").trigger("ditty_editor_layout_action_click",[e,s,a,i.editorDittyId,i.settings.editor])},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layouts_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layouts_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$back.off("click",{self:this},this._backClick),this.$elmt.off("click",".ditty-data-list__item",{self:this},this._selectLayout),this.$elmt.off("click",".ditty-data-list__item__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.off("click",".ditty-data-list__item__edit_css",{self:this,editType:"css"},this._editLayout),this.$elmt.off("click",".ditty-data-list__item__clone",{self:this},this._cloneLayout),this.$elmt.off("click",".ditty-data-list__item__delete",{self:this},this._deleteLayout),this.$list.off("click",".ditty-editor-layout > a",{self:this},this._actionClick),$("body").off("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this.elmt._ditty_layouts_panel=null}},$.fn.ditty_layouts_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layouts_panel||(this._ditty_layouts_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layouts_panel;if(!i)throw new Error("No Ditty_Layouts_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layouts_Panel.');return void 0!==e?e:this}},$.ditty_layouts_panel={},$.ditty_layouts_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null,prevPanel:""},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layout_html_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$textarea=this.$elmt.find(".ditty-editor-options__code"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$preview=this.$elmt.find(".ditty-editor-options__preview"),this.$editCss=this.$elmt.find(".ditty-editor-options__edit-css"),this.$title=this.$elmt.find(".ditty-editor-options__title"),this.$tags=this.$elmt.find(".ditty-editor-options__tags"),this.itemType=this.$form.data("item_type"),this.layoutId=this.$form.data("layout_id"),this.$editorItem=dittyVars.editor.currentItem,this.$editorLayout=dittyVars.editor.currentLayout,this.$editorLayoutTitle=!!this.$editorLayout&&this.$editorLayout.find(".ditty-data-list__item__label"),this.$editorLayoutVariation=dittyVars.editor.currentLayoutVariation,this.$editorLayoutVariationTitle=this.$editorLayoutVariation.find(".ditty-layout-variation__template span"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.codeEditor=null,this.codeHasUpdates=!1,this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this._initEditor(),this.$back.on("click",{self:this},this._backClick),this.$preview.on("click",{self:this},this._previewClick),this.$editCss.on("click",{self:this},this._editCss),this.$form.on("submit",{self:this},this._submitForm),this.$form.on("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.on("keyup",{self:this},this._titleUpdate),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts)},_showPrevPanel:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById",this.settings.prevPanel)},_titleUpdate:function(t){var i=t.data.self;i.settings.editor.addUpdate("layoutUpdate",i.layoutId)},_enablePreviewButton:function(){this.$preview.addClass("ditty-has-updates")},_disablePreviewButton:function(){this.$preview.removeClass("ditty-has-updates"),this.$preview.children("i").attr("class",this.$preview.children("i").data("class"))},_getLayoutItems:function(){var t=this.settings.editor.ditty.options("items"),i=[];return $.each(t,(function(t,e){String(e.layoutId)===String(this.layoutId)&&i.push(e.id)})),i},_addDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),i.$form.serialize()!==i.initData||i.codeHasUpdates?(i.afterUpdateAction="return",i.$form.trigger("submit")):i._showPrevPanel()},_previewClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit"))},_editCss:function(t){t.preventDefault();var i=t.data.self,e="layout_css_editor";if(i.settings.editor.updateStart(),i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit")),i.settings.editor.panelExists(e))i.settings.editor.$elmt.find(".ditty-editor__panel--layout_css_editor input.ditty-editor-options__title").val(i.$title.val()),i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e);else{var s={action:"ditty_editor_layout_fields",layout_id:i.layoutId,layout_title:i.$title.val(),ditty_id:i.editorDittyId,item_id:i.editorItemId,item_type:i.itemType,edit_type:"css",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,s,(function(t){if(t){var s='<div class="ditty-editor__panel ditty-editor__panel--'+e+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e,s)}}),"json")}},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.layoutId,s=i.itemType,a=i._getLayoutItems();if(i.$form.hasClass("ditty-editor-has-errors"))return!1;i.codeEditor.codemirror.save(),i.settings.editor.updateStart();var d={action:"ditty_editor_layout_update",layout_id:e,item_type:s,item_ids:a,edit_type:"html",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:d,success:function(t){i.initData=i.$form.serialize(),i._disablePreviewButton(),t.label&&(i.$editorLayoutTitle&&i.$editorLayoutTitle.html(t.label),i.$editorLayoutVariationTitle.html(t.label)),i.$editorLayoutTitle&&i.$editorLayoutTitle.find(".ditty-layout-version").remove(),i.$editorLayoutVariationTitle&&i.$editorLayoutVariationTitle.find(".ditty-layout-version").remove(),t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,!1,!1,!0),t.draft_id&&t.draft_meta&&dittyDraftLayoutUpdate(i,t.draft_id,null,t.draft_meta),i.codeHasUpdates=!1,i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showPrevPanel(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty({return_items:0}),i.afterUpdateAction=""}})},_initEditor:function(){var t=this,i=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{};i.codemirror=_.extend({},i.codemirror,{indentUnit:2,tabSize:2}),this.codeEditor=wp.codeEditor.initialize(this.$textarea[0],i),this.codeEditor.codemirror.on("change",(function(){t.codeEditor.codemirror.save(),t.settings.editor.addUpdate("layout_html_update",t.layoutId),t.codeHasUpdates=!0,t._enablePreviewButton(),t.settings.editor.delayedSubmitEnable()}))},_insertTag:function(t){var i=t.data.self,e=$(t.target),s=e.text(),a=e.data("atts"),d=i.codeEditor.codemirror.getCursor();if(t.shiftKey&&a){var r="",o=s.length-1;$.each(a,(function(t,i){r+=" "+t+'="'+i.toString()+'"'})),s=s.substring(0,o)+r+s.substring(o)}i.codeEditor.codemirror.replaceRange(s,d),d.ch=d.ch+s.length,i.codeEditor.codemirror.setCursor(d)},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layout_html_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layout_html_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$back.off("click",{self:this},this._backClick),this.$preview.off("click",{self:this},this._previewClick),this.$editCss.off("click",{self:this},this._editCss),this.$form.off("submit",{self:this},this._submitForm),this.$form.off("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.off("keyup",{self:this},this._titleUpdate),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.codeEditor.codemirror.off("change"),this.codeEditor.codemirror.toTextArea(),this.elmt._ditty_layout_html_editor_panel=null}},$.fn.ditty_layout_html_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layout_html_editor_panel||(this._ditty_layout_html_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layout_html_editor_panel;if(!i)throw new Error("No Ditty_Layout_Html_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layout_Html_Editor_Panel.');return void 0!==e?e:this}},$.ditty_layout_html_editor_panel={},$.ditty_layout_html_editor_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null,prevPanel:""},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layout_css_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$textarea=this.$elmt.find(".ditty-editor-options__code"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$preview=this.$elmt.find(".ditty-editor-options__preview"),this.$editHtml=this.$elmt.find(".ditty-editor-options__edit-html"),this.$title=this.$elmt.find(".ditty-editor-options__title"),this.$body=this.$elmt.find(".ditty-editor-options__body"),this.$tags=this.$elmt.find(".ditty-editor-options__tags"),this.itemType=this.$form.data("item_type"),this.layoutId=this.$form.data("layout_id"),this.$editorItem=dittyVars.editor.currentItem,this.$editorLayout=dittyVars.editor.currentLayout,this.$editorLayoutTitle=!!this.$editorLayout&&this.$editorLayout.find(".ditty-data-list__item__label"),this.$editorLayoutVariation=dittyVars.editor.currentLayoutVariation,this.$editorLayoutVariationTitle=this.$editorLayoutVariation.find(".ditty-layout-variation__template span"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.itemSelector="",this.codeEditor=null,this.codeHasUpdates=!1,this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this._setCssSelector(),this._initEditor(),this.$back.on("click",{self:this},this._backClick),this.$preview.on("click",{self:this},this._previewClick),this.$editHtml.on("click",{self:this},this._editHtml),this.$form.on("submit",{self:this},this._submitForm),this.$form.on("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.on("keyup",{self:this},this._titleUpdate),this.$body.on("click",".ditty-editor-options__body__error",{self:this},this._removeErrorNotice),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts)},_setCssSelector:function(){dittyVars.isTickerPost?this.itemSelector="#poststuff .ditty-layout--"+this.layoutId:this.itemSelector=".ditty-layout--"+this.layoutId},_showPrevPanel:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById",this.settings.prevPanel)},_titleUpdate:function(t){var i=t.data.self;i.settings.editor.addUpdate("layoutUpdate",i.layoutId)},_enablePreviewButton:function(){this.$preview.addClass("ditty-has-updates")},_disablePreviewButton:function(){this.$preview.removeClass("ditty-has-updates"),this.$preview.children("i").attr("class",this.$preview.children("i").data("class"))},_addDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),i.$form.serialize()!==i.initData||i.codeHasUpdates?(i.afterUpdateAction="return",i.$form.trigger("submit")):i._showPrevPanel()},_previewClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit"))},_editHtml:function(t){t.preventDefault();var i=t.data.self,e="layout_html_editor";if(i.settings.editor.updateStart(),i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit")),i.settings.editor.panelExists(e))i.settings.editor.$elmt.find(".ditty-editor__panel--layout_html_editor input.ditty-editor-options__title").val(i.$title.val()),i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e);else{var s={action:"ditty_editor_layout_fields",layout_id:i.layoutId,layout_title:i.$title.val(),ditty_id:i.editorDittyId,item_id:i.editorItemId,item_type:i.itemType,edit_type:"html",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,s,(function(t){if(t){var s='<div class="ditty-editor__panel ditty-editor__panel--'+e+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e,s)}}),"json")}},_showErrorNotice:function(){var t=$('<div class="ditty-editor-options__body__error"><span>'+dittyVars.strings.layout_css_error+"</span></div>");this.$body.append(t)},_removeErrorNotice:function(t){t.data.self.$body.find(".ditty-editor-options__body__error").remove()},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.layoutId,s=i.itemType;if(i.$form.hasClass("ditty-editor-has-errors"))return!1;i.codeEditor.codemirror.save(),i.settings.editor.updateStart();var a={action:"ditty_editor_layout_update",layout_id:e,item_type:s,edit_type:"css",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:a,success:function(t){i.initData=i.$form.serialize(),i._disablePreviewButton(),t.label&&(i.$editorLayoutTitle&&i.$editorLayoutTitle.html(t.label),i.$editorLayoutVariationTitle.html(t.label)),i.$editorLayoutTitle&&i.$editorLayoutTitle.find(".ditty-layout-version").remove(),i.$editorLayoutVariationTitle&&i.$editorLayoutVariationTitle.find(".ditty-layout-version").remove(),t.code?dittyLayoutCss(t.code,i.layoutId):i._showErrorNotice(),t.draft_id&&t.draft_meta&&dittyDraftLayoutUpdate(i,t.draft_id,null,t.draft_meta),i.codeHasUpdates=!1,i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showPrevPanel(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty(),i.afterUpdateAction=""}})},_initEditor:function(){var t=this,i=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{},e=dittyVars.editor.ditty_layouts_sass?"sass":"css";i.codemirror=_.extend({},i.codemirror,{mode:e,indentUnit:2,tabSize:2}),this.codeEditor=wp.codeEditor.initialize(this.$textarea[0],i),this.codeEditor.codemirror.on("change",(function(){t.codeEditor.codemirror.save(),t.settings.editor.addUpdate("layoutCssUpdate",t.layoutId),t.codeHasUpdates=!0,t._enablePreviewButton(),t.settings.editor.delayedSubmitEnable()}))},_insertTag:function(t){var i=t.data.self,e=$(t.target).text(),s=i.codeEditor.codemirror.getCursor();i.codeEditor.codemirror.replaceRange(e,s),s.ch=s.ch+e.length,i.codeEditor.codemirror.setCursor(s)},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layout_css_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layout_css_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$back.off("click",{self:this},this._backClick),this.$preview.off("click",{self:this},this._previewClick),this.$editHtml.off("click",{self:this},this._editHtml),this.$form.off("submit",{self:this},this._submitForm),this.$form.off("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.off("keyup",{self:this},this._titleUpdate),this.$body.off("click",".ditty-editor-options__body__error",{self:this},this._removeErrorNotice),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.codeEditor.codemirror.off("change"),this.codeEditor.codemirror.toTextArea(),this.elmt._ditty_layout_css_editor_panel=null}},$.fn.ditty_layout_css_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layout_css_editor_panel||(this._ditty_layout_css_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layout_css_editor_panel;if(!i)throw new Error("No Ditty_Layout_Css_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layout_Css_Editor_Panel.');return void 0!==e?e:this}},$.ditty_layout_css_editor_panel={},$.ditty_layout_css_editor_panel.defaults=t}(jQuery),jQuery(document).ready((function($){!function(){"use strict";function t(t,i){0===parseInt(i)?t.hide():t.show()}function i(t,i){"none"===i?t.hide():t.show()}function e(t,i){"none"===i?t.hide():t.show()}$("#ditty-editor").on("ditty_display_editor_panel_init",".ditty-editor__panel--displayEditor",(function(s,a){if("list"===a.displayType){var d=a.$form,r=d.find(".ditty-field--perPage"),o=d.find(".ditty-field--arrows").siblings(),n=d.find(".ditty-field--bullets").siblings();t(r,d.find('input[name="paging"]:checked').val()),d.find('input[name="paging"]').on("change",(function(){t(r,$(this).val())})),i(o,d.find('select[name="arrows"]').val()),d.find('select[name="arrows"]').on("change",(function(){i(o,$(this).val())})),e(n,d.find('select[name="bullets"]').val()),d.find('select[name="bullets"]').on("change",(function(){e(n,$(this).val())}))}}))}()})),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]),
4
- t.display_items&&i.ditty.options("items",t.display_items),i.draftValues={},i.unsavedUpdates={},i._setUpdateCount(),i.$elmt.removeClass("ditty-editor--updates-exist"),i.$updateLabel.text("Ditty Saved!"),setTimeout((function(){i.$updateLabel.text("Save Ditty")}),2e3),i.updateStop(),t.new_ditty_url&&window.history.pushState(null,"","/wp-admin/post.php?post="+e+"&action=edit")}))},_saveClick:function(t){t.preventDefault();var i=t.data.self;i.$elmt.trigger("ditty_editor_save_drafts"),i.delayedSubmit||i.saveDitty()},_dittyItemsUpdated:function(t,i,e){var s=t.data.self;s.activeItems=e,s.trigger("active_items_update")},_disabledItemsUpdate:function(t,i){var e=t.data.self;$.each(i,(function(t,i){"disabled"===i?e.$elmt.find("#ditty-editor-item--"+t).addClass("ditty-editor-item--disabled"):e.$elmt.find("#ditty-editor-item--"+t).removeClass("ditty-editor-item--disabled")}))},_postboxMoved:function(t,i){if(!window.tinymce)return!1;$(i).find(".wp-editor-area").each((function(){var t=$(this).attr("id");tinymce.execCommand("mceRemoveEditor",!0,t),tinymce.execCommand("mceAddEditor",!0,t)}))},_beforeunload:function(t){var i=t.data.self;return Object.keys(i.unsavedUpdates).length>0||void 0},_windowResize:function(t){t.preventDefault()},_options:function(t){return this.settings[t]},panelExists:function(t){var i=this.$panels.ditty_slider("options","slides"),e=!1;return $.each(i,(function(i,s){String(s.id)!==String(t)||(e=!0)})),e},showPanel:function(t,i){i&&this.$panels.ditty_slider("addSlideById",t,i),this.$panels.ditty_slider("showSlideById",t,!0)},updateExists:function(t,i){if(void 0===this.unsavedUpdates[t]&&(this.unsavedUpdates[t]=[]),-1!==$.inArray(i,this.unsavedUpdates[t]))return!0},addUpdate:function(t,i){var e=!1;return void 0===this.unsavedUpdates[t]&&(this.unsavedUpdates[t]=[]),-1===$.inArray(i,this.unsavedUpdates[t])&&(e=!0,this.unsavedUpdates[t].push(i)),this._setUpdateCount(),this.$elmt.addClass("ditty-editor--updates-exist"),e},removeUpdate:function(t,i){if(void 0===this.unsavedUpdates[t])return!1;if(-1===$.inArray(i,this.unsavedUpdates[t]))return!1;var e=!1,s=[];return $.each(this.unsavedUpdates[t],(function(t,a){String(i)===String(a)?e=!0:s.push(a)})),this.unsavedUpdates[t]=s,this._setUpdateCount(),""===this.$updateCount.text()&&this.$elmt.removeClass("ditty-editor--updates-exist"),e},updateStart:function(){this.$overlay.fadeIn()},updateStop:function(){this.$overlay.fadeOut()},initFields:function(t){this._initFields(t)},updateDraftValues:function(t,i){return this.$elmt.addClass("ditty-editor--updates-exist"),t?(this.draftValues[t]=i,"development"===dittyVars.mode&&window.console&&console.log("draftValues:",this.draftValues),this.draftValues[t]):(this.draftValues=i,"development"===dittyVars.mode&&window.console&&console.log("draftValues:",this.draftValues),this.draftValues)},getDraftValues:function(t){return t?!!this.draftValues[t]&&this.draftValues[t]:this.draftValues},delayedSubmitEnable:function(){this.delayedSubmit=!0},delayedSubmitDisable:function(){this.delayedSubmit=!1},trigger:function(t,i){var e=[];switch(t){case"active_items_update":e=[this.ditty,this.activeItems];break;case"stop_live_updates":e=[this.dittyId];break;default:e=[this.settings]}i&&(e=i),this.$elmt.trigger("ditty_editor_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e),$("body").trigger("ditty_"+t,e)},_getPanelOption:function(t){return"elmnt"===t?this.$panels:this.settings[t]},_setPanelOption:function(t,i){if(void 0===i)return!1;this.$panels.ditty_slider("options",t,i),this.trigger("update")},panelOptions:function(t,i){var e=this;if("object"==typeof t)$.each(t,(function(t,i){e._setPanelOption(t,i)}));else{if("string"!=typeof t)return e.$panels.ditty_slider("options");if(void 0===i)return e._getPanelOption(t);e._setPanelOption(t,i)}},_getOption:function(t){return"elmnt"===t?this:this.settings[t]},_setOption:function(t,i){if(void 0===i)return!1;this.settings[t]=i,this.trigger("update")},options:function(t,i){var e=this;if("object"==typeof t)$.each(t,(function(t,i){e._setOption(t,i)}));else{if("string"!=typeof t)return e.settings;if(void 0===i)return e._getOption(t);e._setOption(t,i)}},destroy:function(){this.$panels.ditty_slider&&this.$panels.ditty_slider("destroy"),$(document).off("postbox-moved",{self:this},this._postboxMoved),$(document).off("postboxes-columnchange",{self:this},this._postboxMoved),$(window).off("beforeunload",{self:this},this._beforeunload),this.ditty.$elmt.off("ditty_active_items_update",{self:this},this._dittyItemsUpdated),this.ditty.$elmt.off("ditty_disabled_items_update",{self:this},this._disabledItemsUpdate),this.$tabs.off("click","ditty-editor__tab",{self:this},this._showPanel),this.$update.off("click",{self:this},this._saveClick),this.$panels.off("ditty_slider_init",{self:this},this._editorLoaded),this.$panels.off("ditty_slider_before_slide_update",{self:this},this._beforeSlideUpdate),this.$panels.off("ditty_slider_after_slide_update",{self:this},this._afterSlideUpdate),this.$panels.off("ditty_slider_slide_removed",{self:this},this._slideRemoved),this.trigger("destroy"),this.elmt._ditty_editor=null}},$.fn.ditty_editor=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_editor||(this._ditty_editor=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_editor;if(!i)throw new Error("No Ditty_Editor applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Editor.');return void 0!==e?e:this}},$.ditty_editor={},$.ditty_editor.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_settings_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$title=this.$elmt.find('input[name="title]'),this.$previewBg=this.$elmt.find('input[name="previewBg"]'),this.$previewPaddingTop=this.$elmt.find('input[name="previewPadding[paddingTop]"]'),this.$previewPaddingBottom=this.$elmt.find('input[name="previewPadding[paddingBottom]"]'),this.$previewPaddingLeft=this.$elmt.find('input[name="previewPadding[paddingLeft]"]'),this.$previewPaddingRight=this.$elmt.find('input[name="previewPadding[paddingRight]"]'),this.$postTitle=$(".ditty-post__title"),this.$editorPreview=$("#ditty-editor__preview"),this.dittyId=this.$form.data("ditty_id"),this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this.settings.editor.initFields(this.$elmt),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.on("submit",{self:this},this._submitForm),this.$form.on("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.on("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.on("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.on("keyup change",'input[name="title"]',{self:this},this._titleChange),this.$form.on("keyup change",".ditty-field--preview_settings *",{self:this},this._previewBgChange),this.$elmt.addClass("init")},_checkUpdates:function(t){var i=t?t.data.self:this;i.$form.serialize()!==i.initData?(i.settings.editor.addUpdate("settings",i.itemId),i.settings.editor.delayedSubmitEnable()):i.settings.editor.removeUpdate("settings",i.itemId)},_titleChange:function(t){var i=t?t.data.self:this,e=$(t.target).val();i.$postTitle.text(e)},_previewBgChange:function(t){var i=t?t.data.self:this,e={backgroundColor:i.$previewBg.val(),paddingTop:i.$previewPaddingTop.val(),paddingBottom:i.$previewPaddingBottom.val(),paddingLeft:i.$previewPaddingLeft.val(),paddingRight:i.$previewPaddingRight.val()};i.$editorPreview.css(e)},_addDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.dittyId;i.settings.editor.updateStart();var s={action:"ditty_editor_settings_update",ditty_id:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:s,success:function(t){i.initData=i.$form.serialize(),dittyDraftUpdate(i,"settings",!1,t),i.settings.editor.delayedSubmitDisable(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty({return_items:0}),i.afterUpdateAction=""}})},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_settings_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_settings_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.$form.off("submit",{self:this},this._submitForm),this.$form.off("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.off("keyup change",'input[name="previewBg"]',{self:this},this._previewBg_cahnge),this.$form.off("keyup change",'input[name="title"]',{self:this},this._titleChange),this.$form.off("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.off("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.trigger("destroy"),this.elmt._ditty_settings_panel=null}},$.fn.ditty_settings_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_settings_panel||(this._ditty_settings_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_settings_panel;if(!i)throw new Error("No Ditty_Settings_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Settings_Panel.');return void 0!==e?e:this}},$.ditty_settings_panel={},$.ditty_settings_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_items_panel.defaults,e),this.$elmt=$(i),this.$add=$(i).find(".ditty-editor-options__add"),this.$contents=$(i).find(".ditty-editor__panel__contents"),this.$list=$(i).find(".ditty-data-list"),this.$listItems=$(i).find(".ditty-data-list__items"),this.isEmptyTicker=!1,this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.settings.editor.$elmt.on("ditty_editor_aactive_items_update",{self:this},this._dittyActiveItemsUpdated),this.$add.on("click",{self:this},this._add_item),this.$elmt.on("click",".ditty-data-list__item",{self:this},this._showItem),this.$elmt.on("click",".ditty-data-list__item__icon",{self:this},this._editType),this.$elmt.on("click",".ditty-data-list__item__edit",{self:this},this._editItem),this.$elmt.on("click",".ditty-data-list__item__layout",{self:this},this._editLayoutVariations),this.$elmt.on("click",".ditty-data-list__item__clone",{self:this},this._cloneItem),this.$elmt.on("click",".ditty-data-list__item__delete",{self:this},this._deleteItem),this.$list.on("click",".ditty-editor-item > a",{self:this},this._actionClick),$("body").on("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),1>this.$elmt.find(".ditty-data-list__item").length&&(this.isEmptyTicker=!0,this.$add.trigger("click")),this._initializeSorting(),this._highlightListItems(this.settings.editor.activeItems)},dittyUpdateSavedDraftLayouts:function(t,i){$.each($(".ditty-editor-item"),(function(){var e=$(this).data("layout_value");$.each(e,(function(s,a){String(a)===String(t)&&(e[s]=String(i))})),$(this).attr("data-layout_value",e).data("layout_value",e)}))},_dittyEditorSaveResponse:function(t,i){var e=t.data.self;i.ditty_new_item_ids&&$.each(i.ditty_new_item_ids,(function(t,i){var e=$("#ditty-editor-item--"+t);e.length&&(e.attr("id","ditty-editor-item--"+i),e.attr("data-item_id",i).data("item_id",i))})),i.ditty_new_layout_ids&&$.each(i.ditty_new_layout_ids,(function(t,i){e.dittyUpdateSavedDraftLayouts(t,i)}))},_highlightListItem:function(t){var i=t.id+"";i=i.split("_"),this.$elmt.find("#ditty-editor-item--"+i[0]).addClass("active")},_highlightListItems:function(t){this.$elmt.find(".ditty-data-list__item").removeClass("active");var i=this;Array.isArray(t)?$.each(t,(function(t,e){i._highlightListItem(e)})):i._highlightListItem(t)},_dittyActiveItemsUpdated:function(t,i,e){t.data.self._highlightListItems(e)},_initializeSorting:function(){var t=this;this.$listItems.sortable({handle:".ditty-data-list__item__move",items:".ditty-data-list__item",axis:"y",start:function(t,i){$(i.item).addClass("ditty-data-list__item--moving")},stop:function(i,e){$(e.item).removeClass("ditty-data-list__item--moving"),t.settings.editor.addUpdate("item_order",t.settings.editor.dittyId)},update:function(){t._updateItemIndexes("updateDitty")}})},_showItem:function(t){t.preventDefault();var i=t.data.self;if(!$(t.target).is("a")&&!$(t.target).parent().is("a")){var e=($(t.target).is(".ditty-data-list__item")?$(t.target):$(t.target).parents(".ditty-data-list__item")).data("item_id");i.settings.editor.ditty.showItem(e)}},_actionClick:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("a")?$(t.target):$(t.target).parent("a"),s=e.parents(".ditty-data-list__item"),a=s.data("ditty_id"),d=s.data("item_id");dittyVars.editor.currentItem=s,$("body").trigger("ditty_editor_item_action_click",[e,s,d,a,i.settings.editor])},_editType:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item");e.trigger("click"),e.addClass("editing"),i.settings.editor.updateStart(),i.settings.editor.panelOptions("transition","slideRight"),i.settings.editor.showPanel("item_types")},_editItem:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("item_id");e.trigger("click"),e.addClass("editing"),i.settings.editor.updateStart();var a={action:"ditty_editor_item_fields",item_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--item_editor">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("item_editor",e)}}))},_editLayoutVariations:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("item_type"),a=e.data("layout_value"),d=e.find(".ditty-data-list__item__label").html();e.trigger("click"),e.addClass("editing"),i.settings.editor.updateStart();var r={action:"ditty_editor_layout_variations",ditty_id:i.settings.editor.dittyId,item_type:s,item_label:d,layout_value:a,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,r,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--layout-variations">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("layout_variations",e)}}))},_add_item:function(t){t.preventDefault();var i=t.data.self,e={action:"ditty_editor_item_add",ditty_id:i.settings.editor.dittyId,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,e,(function(t){if(t.display_items){if(i.isEmptyTicker){var e=i.settings.editor.ditty.options("items");$.each(e,(function(t,e){i.settings.editor.ditty.deleteItem(e.id)})),i.isEmptyTicker=!1}$.each(t.display_items,(function(t,e){i.settings.editor.ditty.addItem(e,0)}))}if(t.editor_item){var s=$(t.editor_item);s.hide(),i.$listItems.prepend(s),s.slideDown(),i._updateItemIndexes()}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),t.draft_id&&t.draft_meta&&dittyDraftItemUpdateMeta(i,t.draft_id,null,t.draft_meta)}),"json")},_cloneItem:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("item_id");i.settings.editor.updateStart();var a={action:"ditty_editor_item_clone",item_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t.display_items&&t.display_items.length&&i.settings.editor.ditty.updateItems(t.display_items,s,"after"),t.editor_item){var a=$(t.editor_item);a.hide(),e.after(a),a.slideDown(),i._updateItemIndexes()}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),t.draft_id&&t.draft_meta&&dittyDraftItemUpdateMeta(i,t.draft_id,null,t.draft_meta),i.settings.editor.updateStop()}),"json")},_deleteItem:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("item_id");1>=i.$elmt.find(".ditty-data-list__item").length&&i.$add.trigger("click"),e.slideUp((function(){$(this).remove()})),i.settings.editor.ditty.deleteItem(s),dittyDraftItemDelete(i,s)},_updateItemIndexes:function(t){var i=this,e=[];if(this.$elmt.find(".ditty-data-list__item").each((function(t){var s=$(this).data("item_id");e.push(s),dittyDraftItemUpdateData(i,s,"item_index",t)})),"updateDitty"===t){var s=dittyItemsReorder(i.settings.editor.ditty.options("items"),e);i.settings.editor.ditty.options("items",s)}},panelVisible:function(){this.$elmt.find(".ditty-data-list__item").removeClass("editing")},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_items_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_items_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.settings.editor.$elmt.off("ditty_editor_active_items_update",{self:this},this._dittyActiveItemsUpdated),this.$add.off("click",{self:this},this._add_item),this.$elmt.off("click",".ditty-data-list__item",{self:this},this._showItem),this.$elmt.off("click",".ditty-data-list__item__icon",{self:this},this._editType),this.$elmt.off("click",".ditty-data-list__item__edit",{self:this},this._editItem),this.$elmt.off("click",".ditty-data-list__item__layout",{self:this},this._editLayoutVariations),this.$elmt.off("click",".ditty-data-list__item__clone",{self:this},this._cloneItem),this.$elmt.off("click",".ditty-data-list__item__delete",{self:this},this._deleteItem),this.$list.off("click",".ditty-editor-item > a",{self:this},this._actionClick),$("body").off("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this.trigger("destroy"),this.elmt._ditty_items_panel=null}},$.fn.ditty_items_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_items_panel||(this._ditty_items_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_items_panel;if(!i)throw new Error("No Ditty_Items_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Items_Panel.');return void 0!==e?e:this}},$.ditty_items_panel={},$.ditty_items_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_item_types_panel.defaults,e),this.$elmt=$(i),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$editorItem=this.settings.editor.$panels.find(".ditty-editor__panel--items").find(".ditty-data-list__item.editing"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.currentType=null,this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.settings.editor.initFields(this.$elmt),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("click",".ditty-editor-item-type",{self:this},this._typeClick),this.panelVisible()},_showItemsList:function(){this.settings.editor.panelOptions("transition","slideLeft"),this.settings.editor.showPanel("items")},_backClick:function(t){t.preventDefault(),t.data.self._showItemsList()},_typeClick:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is(".ditty-editor-item-type")?$(t.target):$(t.target).parents(".ditty-editor-item-type")).data("item_type");if(e===i.currentType)i._showItemsList();else{i.settings.editor.updateStart();var s={action:"ditty_editor_item_type_update",item_id:i.editorItemId,item_type:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,s,(function(t){if(t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,i.editorItemId),t.editor_item){var e=$(t.editor_item);i.$editorItem.after(e),i.$editorItem.remove(),i.$editorItem=e}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),i._showItemsList(),i.settings.editor.updateStop()}),"json")}},panelVisible:function(){this.$editorItem=this.settings.editor.$panels.find(".ditty-editor__panel--items").find(".ditty-data-list__item.editing"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.currentType=this.$editorItem.data("item_type"),this.$elmt.find(".ditty-editor-item-type").removeClass("active"),this.$elmt.find('.ditty-editor-item-type[data-itemType="'+this.currentType+'"]').addClass("active")},panelHidden:function(){var t=this.$editorItem.find(".ditty-data-list__item__icon").children("i");t.attr("class",t.data("class"))},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_item_types_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_item_types_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$back.off("click",{self:this},this._backClick),this.$elmt.off("click",".ditty-editor-item-type",{self:this},this._typeClick),this.trigger("destroy"),this.elmt._ditty_item_types_panel=null}},$.fn.ditty_item_types_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_item_types_panel||(this._ditty_item_types_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_item_types_panel;if(!i)throw new Error("No Ditty_Item_Types_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Item_Types_Panel.');return void 0!==e?e:this}},$.ditty_item_types_panel={},$.ditty_item_types_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_item_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$preview=this.$elmt.find(".ditty-editor-options__preview"),this.$title=this.$elmt.find(".ditty-editor-options__title"),this.itemId=this.$form.data("item_id"),this.itemType=this.$form.data("item_type"),this.dittyId=this.$form.data("ditty_id"),this.$editorItem=this.settings.editor.$panels.find(".ditty-editor__panel--items").find(".ditty-data-list__item.editing"),this.$editorItemTitle=this.$editorItem.find(".ditty-data-list__item__label"),this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this.settings.editor.initFields(this.$elmt),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.on("submit",{self:this},this._submitForm),this.$back.on("click",{self:this},this._backClick),this.$preview.on("click",{self:this},this._previewClick),this.$form.on("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.on("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.on("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.on("ditty_field_update",".ditty-field__input",{self:this},this._checkUpdates)},_showItemList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","items")},_enablePreviewButton:function(){this.$preview.addClass("ditty-has-updates")},_disablePreviewButton:function(){this.$preview.removeClass("ditty-has-updates"),this.$preview.children("i").attr("class",this.$preview.children("i").data("class"))},_checkUpdates:function(t){var i=t?t.data.self:this;i.$form.serialize()!==i.initData?(i._enablePreviewButton(),i.settings.editor.addUpdate("item_settings",i.itemId),i.settings.editor.delayedSubmitEnable()):(i._disablePreviewButton(),i.settings.editor.removeUpdate("item_settings",i.itemId))},_addDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.$form.serialize()===i.initData?i._showItemList():(i.afterUpdateAction="return",i.$form.trigger("submit"))},_previewClick:function(t){t.preventDefault();var i=t.data.self;i.$form.serialize()!==i.initData&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit"))},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.itemId;i.settings.editor.updateStart();var s={action:"ditty_editor_item_update",item_id:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:s,error:function(){},success:function(t){if(t.value_updates&&i._updateValues(t.value_updates),i.initData=i.$form.serialize(),i._disablePreviewButton(),t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,e),t.editor_item){var s=$(t.editor_item).children(".ditty-data-list__item__label").text();i.$title.html(s),i.$editorItemTitle.html(s)}t.draft_id&&t.draft_data&&dittyDraftItemUpdateData(i,t.draft_id,null,t.draft_data),t.draft_id&&t.draft_meta&&dittyDraftItemUpdateMeta(i,t.draft_id,null,t.draft_meta),i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showItemList(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty({return_items:0}),i.afterUpdateAction=""}})},_updateValues:function(t){var i=this;$.each(t,(function(t,e){var s=i.$form.find('[name="'+t+'"]');s.length&&s.val(e)}))},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_item_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_item_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._saveDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.off("submit",{self:this},this._submitForm),this.$back.off("click",{self:this},this._backClick),this.$preview.off("click",{self:this},this._previewClick),this.$form.off("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.off("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.off("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.off("ditty_field_update",".ditty-field__input",{self:this},this._checkUpdates),this.elmt._ditty_item_editor_panel=null}},$.fn.ditty_item_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_item_editor_panel||(this._ditty_item_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_item_editor_panel;if(!i)throw new Error("No Ditty_Item_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Item_Editor_Panel.');return void 0!==e?e:this}},$.ditty_item_editor_panel={},$.ditty_item_editor_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_displays_panel.defaults,e),this.$elmt=$(i),this.$list=$(i).find(".ditty-data-list__items"),this.$contents=$(i).find(".ditty-editor__panel__contents"),this.initDisplay=null,this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.$elmt.ditty_ui_data_list({filter:".ditty-display-panel__filter",item:".ditty-editor-display",itemSelector:"display_type"}),this.initDisplay=this.$list.data("active"),this._activateDisplay(this.$list.find("#ditty-editor-display--"+this.initDisplay)),this.$elmt.on("click",".ditty-data-list__item",{self:this},this._selectDisplay),this.$elmt.on("click",".ditty-data-list__item__edit",{self:this},this._editDisplay),this.$elmt.on("click",".ditty-data-list__item__clone",{self:this},this._cloneDisplay),this.$elmt.on("click",".ditty-data-list__item__delete",{self:this},this._deleteDisplay),this.settings.editor.$elmt.on("ditty_editor_saveDrafts",{self:this},this._saveDrafts)},_saveDrafts:function(t){var i=t.data.self;i.initDisplay=i.$list.find(".ditty-editor-display.active").data("display_id")},_activateDisplay:function(t){this.$list.find(".ditty-editor-display").removeClass("active"),t.addClass("active")},_initDitty:function(t,i,e){var s=this.settings.editor.ditty.$elmt;e.display=i,e.id=this.settings.editor.ditty.options("id"),e.items=this.settings.editor.ditty.options("items"),e.height=this.settings.editor.ditty.options("height"),this.settings.editor.ditty.destroy(),s["ditty_"+t](e),this.settings.editor.ditty=s["ditty_"+t]("options","ditty")},_selectDisplay:function(t){t.preventDefault();var i=t.data.self;if($(t.target).parent().is("a"))return!1;var e=$(t.target).is(".ditty-data-list__item")?$(t.target):$(t.target).parents(".ditty-data-list__item"),s=e.data("display_id"),a=e.data("display_type");if(e.hasClass("active"))return!1;i.settings.editor.updateStart(),dittyDraftUpdate(i,"post_meta","_ditty_display",s),i._activateDisplay(e);var d={action:"ditty_editor_select_display",display_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,d,(function(t){if(!t)return!1
5
- ;i._initDitty(a,s,t),i.settings.editor.updateStop()}),"json")},_cloneDisplay:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("display_id");i.settings.editor.updateStart();var a={action:"ditty_editor_display_clone",display_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t.editor_display){var s=$(t.editor_display);s.hide(),e.after(s),s.slideDown()}t.draft_id&&t.draft_data&&dittyDraftDisplayUpdate(i,t.draft_id,null,t.draft_data),i.settings.editor.updateStop()}),"json")},_deleteDisplay:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=null,a=e.data("display_id");e.hasClass("active")&&(e.prev().length?s=e.prev():e.next().length&&(s=e.next())),e.slideUp((function(){$(this).remove()})),dittyDraftDisplayDelete(i,a),null!==s&&s.trigger("click")},_editDisplay:function(t){t.preventDefault();var i=t.data.self;i.$displayEdit=$(this).parents(".ditty-data-list__item");var e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("display_id");i.settings.editor.updateStart(),e.addClass("editing");var a={action:"ditty_editor_display_fields",display_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--displayEditor">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("display_editor",e)}}))},panelVisible:function(){this.$elmt.find(".ditty-data-list__item").removeClass("editing")},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_displays_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_displays_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$elmt.ditty_ui_data_list("destroy"),this.$elmt.off("click",".ditty-data-list__item",{self:this},this._selectDisplay),this.$elmt.off("click",".ditty-data-list__item__edit",{self:this},this._editDisplay),this.$elmt.off("click",".ditty-data-list__item__clone",{self:this},this._cloneDisplay),this.$elmt.off("click",".ditty-data-list__item__delete",{self:this},this._deleteDisplay),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.trigger("destroy"),this.elmt._ditty_displays_panel=null}},$.fn.ditty_displays_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_displays_panel||(this._ditty_displays_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_displays_panel;if(!i)throw new Error("No Ditty_Displays_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Displays_Panel.');return void 0!==e?e:this}},$.ditty_displays_panel={},$.ditty_displays_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_display_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$optionsTitle=this.$elmt.find(".ditty-editor-options__title"),this.$importExportField=this.$elmt.find(".ditty-editor__import-export__field"),this.$importExportUpdate=this.$elmt.find(".ditty-editor__import-export__update"),this.displayTitle=null,this.displayId=this.settings.editor.ditty.options("display"),this.displayType=this.settings.editor.ditty.options("type"),this.$editorDisplay=this.settings.editor.$panels.find(".ditty-editor__panel--displays").find(".ditty-data-list__item.editing"),this.$editorDisplayTitle=this.$editorDisplay.find(".ditty-data-list__item__label"),this.displayOptions=null,this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){var t,i=this;this.initData=this.$form.serialize(),this.settings.editor.initFields(this.$elmt),t=this.settings.editor.ditty.$elmt["ditty_"+this.displayType]("options"),this.displayOptions=$.extend({},t),this.displayTitle=this.$optionsTitle.val(),this.$importExportUpdate.on("click",{self:this},this._importUpdate),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.on("submit",{self:this},this._submitForm),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("change",'input[type="text"], input[type="number"]',{self:this},this._textfieldListeners),this.$form.on("click",'input[type="radio"]',{self:this},this._radioListeners),this.$form.on("click",'input[type="checkbox"]',{self:this},this._checkboxListeners),this.$form.on("change","select",{self:this},this._selectListeners),this.$form.on("ditty_field_clone_update",{self:this},this._cloneListeners),setTimeout((function(){i.trigger("init",[i])}),1)},_showDisplayList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","displays")},_checkUpdates:function(){this.$form.serialize()!==this.initData?(this.settings.editor.addUpdate("displaySettings",this.displayId),this.settings.editor.delayedSubmitEnable()):this.settings.editor.removeUpdate("displaySettings",this.displayId)},_addDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.$form.serialize()!==i.initData&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.$form.serialize()===i.initData?i._showDisplayList():(i.afterUpdateAction="return",i.$form.trigger("submit"))},_submitForm:function(t){t.preventDefault();var i=t.data.self;i.settings.editor.updateStart();var e={action:"ditty_editor_display_update",display_id:i.displayId,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:e,success:function(t){i.initData=i.$form.serialize(),t.draft_id&&t.draft_label&&(i.displayTitle=t.draft_label,i.$editorDisplayTitle.text(t.draft_label),dittyDraftDisplayUpdate(i,t.draft_id,"label",t.draft_label)),t.draft_id&&t.draft_settings&&(i.displayOptions=t.draft_settings,dittyDraftDisplayUpdate(i,t.draft_id,"settings",t.draft_settings)),t.draft_settings_json&&i.$importExportField.length&&i.$importExportField.val(t.draft_settings_json),i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showDisplayList(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty(),i.afterUpdateAction=""}})},_importUpdate:function(t){t.preventDefault()},_cloneListeners:function(t,i,e){var s=t.data.self;$(t.target);s.settings.editor.ditty.options(e,i)},_textfieldListeners:function(t){var i=t.data.self,e=$(t.target),s=e.attr("name"),a=e.parents(".ditty-input--spacing__group, .ditty-input--radius__group");if(a.length){var d="",r={};a.find("input").each((function(){s=$(this).attr("name"),d=(d=s.split("["))[0];var t=s.match(/\[(.*)\]/);r[t[1]]=$(this).val()})),i.settings.editor.ditty.options(d,r)}else i.settings.editor.ditty.options(s,e.val());i._checkUpdates()},_radioListeners:function(t){var i=t.data.self,e=$(t.target),s=e.val(),a=e.attr("name");i.settings.editor.ditty.options(a,s),i._checkUpdates()},_checkboxListeners:function(t){var i=t.data.self,e=$(t.target),s=!!e.is(":checked")&&$(this).val(),a=e.attr("name");i.settings.editor.ditty.options(a,s),i._checkUpdates()},_selectListeners:function(t){var i=t.data.self,e=$(t.target),s=e.val(),a=e.attr("name");i.settings.editor.ditty.options(a,s),i._checkUpdates()},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_display_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_display_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.trigger("destroy",[this]),this.$importExportUpdate.off("click",{this:this},this._importUpdate),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.$form.off("submit",{this:this},this._submitForm),this.$back.off("click",{this:this},this._cancel_click),this.$elmt.off("change",'input[type="text"], input[type="number"]',{self:this},this._textfieldListeners),this.$form.off("click",'input[type="radio"]',{self:this},this._radioListeners),this.$form.off("click",'input[type="checkbox"]',{self:this},this._checkboxListeners),this.$form.off("change","select",{self:this},this._selectListeners),this.$form.off("ditty_field_clone_update",{self:this},this._cloneListeners),this.elmt._ditty_display_editor_panel=null}},$.fn.ditty_display_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_display_editor_panel||(this._ditty_display_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_display_editor_panel;if(!i)throw new Error("No Ditty_Display_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Display_Editor_Panel.');return void 0!==e?e:this}},$.ditty_display_editor_panel={},$.ditty_display_editor_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layout_variations_panel.defaults,e),this.$elmt=$(i),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$list=$(i).find(".ditty-data-list__items"),this.$editorItem=dittyVars.editor.currentItem,this.editorItemLabel=this.$editorItem.find(".ditty-data-list__item__label").text(),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.editorItemType=this.$editorItem.data("item_type"),this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("click",".ditty-layout-variation__change",{self:this},this._changeTemplate),this.$elmt.on("click",".ditty-layout-variation__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.on("click",".ditty-layout-variation__edit_css",{self:this,editType:"css"},this._editLayout),$("body").on("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse)},_showItemList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","items")},_backClick:function(t){t.preventDefault(),t.data.self._showItemList()},_dittyEditorSaveResponse:function(t,i){t.data.self;i.ditty_new_layout_ids&&$.each(i.ditty_new_layout_ids,(function(t,i){var e=$('.ditty-layout-variation[data-layout_id="'+t+'"]');e.length&&e.attr("data-layout_id",i).data("layout_id",i)}))},_changeTemplate:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("layout_id"),a=e.data("layout_variation_id"),d=e.data("layout_variation_label");dittyVars.editor.currentLayoutVariation=e,i.settings.editor.updateStart(),e.addClass("editing");var r={action:"ditty_editor_layouts",ditty_id:i.editorDittyId,item_type:i.editorItemType,variation_id:a,variation_label:d,layout_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,r,(function(t){if(t){var e='<div class="ditty-editor__panel ditty-editor__panel--layouts">'+t+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel("layouts",e)}}))},_editLayout:function(t){t.preventDefault();var i=t.data.self,e=t.data.editType,s=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),a=s.data("layout_id"),d=s.data("item_type");dittyVars.editor.currentLayoutVariation=s,i.settings.editor.updateStart(),i.$list.find(".ditty-data-list__item").removeClass("editing"),s.addClass("editing");var r=[],o=i.settings.editor.ditty.options("items");$.each(o,(function(t,i){r.push(i.uniqId)}));var n={action:"ditty_editor_layout_fields",layout_id:a,item_type:d,ditty_id:i.editorDittyId,item_id:i.editorItemId,item_ids:r,edit_type:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,n,(function(t){if(t){var s="layout_"+e+"_editor",a='<div class="ditty-editor__panel ditty-editor__panel--'+s+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel(s,a)}}),"json")},panelVisible:function(){this.$list.find(".ditty-layout-variation").removeClass("editing")},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layout_variations_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layout_variations_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$back.off("click",{self:this},this._backClick),this.$elmt.off("click",".ditty-layout-variation__change",{self:this},this._changeTemplate),this.$elmt.off("click",".ditty-layout-variation__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.off("click",".ditty-layout-variation__edit_css",{self:this,editType:"css"},this._editLayout),$("body").off("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this.elmt._ditty_layout_variations_panel=null}},$.fn.ditty_layout_variations_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layout_variations_panel||(this._ditty_layout_variations_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layout_variations_panel;if(!i)throw new Error("No Ditty_Layout_Variations_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layout_Variations_Panel.');return void 0!==e?e:this}},$.ditty_layout_variations_panel={},$.ditty_layout_variations_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layouts_panel.defaults,e),this.$elmt=$(i),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$list=$(i).find(".ditty-data-list__items"),this.$editorItem=dittyVars.editor.currentItem,this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.editorItemtype=this.$editorItem.data("item_type"),this.$editorVariation=dittyVars.editor.currentLayoutVariation,this.editorVariationId=this.$editorVariation.data("layout_variation_id"),this.editorLayoutId=this.$editorVariation.data("layout_id"),this._init()};i.prototype={_init:function(){this.$elmt.addClass("init"),this.$back.on("click",{self:this},this._backClick),this.$elmt.on("click",".ditty-data-list__item",{self:this},this._selectLayout),this.$elmt.on("click",".ditty-data-list__item__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.on("click",".ditty-data-list__item__edit_css",{self:this,editType:"css"},this._editLayout),this.$elmt.on("click",".ditty-data-list__item__clone",{self:this},this._cloneLayout),this.$elmt.on("click",".ditty-data-list__item__delete",{self:this},this._deleteLayout),this.$list.on("click",".ditty-editor-layout > a",{self:this},this._actionClick),$("body").on("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this._activateLayout(this.$list.find("#ditty-editor-layout--"+this.editorLayoutId))},_activateLayout:function(t){this.$list.find(".ditty-editor-layout").removeClass("active"),t.addClass("active")},_showVariationsList:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById","layout_variations")},_backClick:function(t){t.preventDefault(),t.data.self._showVariationsList()},_dittyEditorSaveResponse:function(t,i){t.data.self;i.ditty_new_layout_ids&&$.each(i.ditty_new_layout_ids,(function(t,i){var e=$("#ditty-editor-layout--"+t);e.length&&(e.attr("id","ditty-editor-layout--"+i),e.attr("data-layout_id",i).data("layout_id",i))}))},_selectLayout:function(t){t.preventDefault();var i=t.data.self;if($(t.target).parent().is("a"))return!1;var e=$(t.target).is(".ditty-data-list__item")?$(t.target):$(t.target).parents(".ditty-data-list__item"),s=e.data("layout_id"),a=e.data("layout_version"),d=i.$editorItem.data("layout_value");if(e.hasClass("active"))return!1;$.each(d,(function(t){i.editorVariationId===t&&(d[t]=String(s))})),i.settings.editor.updateStart(),dittyDraftItemUpdateData(i,i.editorItemId,"layout_value",d),i._activateLayout(e);var r={action:"ditty_editor_select_layout",layout_id:s,item_id:i.editorItemId,ditty_id:i.editorDittyId,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,r,(function(t){if(i.settings.editor.updateStop(),t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,i.editorItemId),t.editor_item){var e=$(t.editor_item);i.$editorItem.replaceWith(e)}i.$editorItem.attr("data-layout_value",d).data("layout_value",d),i.$editorVariation.attr("data-layout_id",s).data("layout_id",s),i.$editorVariation.find(".ditty-layout-variation__template > span").text(t.layout_label),a?i.$editorVariation.find(".ditty-layout-variation__template > small").text("("+a+")"):i.$editorVariation.find(".ditty-layout-variation__template > small").text("")}),"json")},_cloneLayout:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=e.data("layout_id");i.settings.editor.updateStart();var a={action:"ditty_editor_layout_clone",layout_id:s,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(t){if(t.editor_layout){var s=$(t.editor_layout);s.hide(),e.after(s),s.slideDown()}t.draft_id&&t.draft_meta&&dittyDraftLayoutUpdate(i,t.draft_id,null,t.draft_meta),i.settings.editor.updateStop()}),"json")},_deleteLayout:function(t){t.preventDefault();var i=t.data.self,e=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),s=null,a=e.data("layout_id");e.hasClass("active")&&(e.prev().length?s=e.prev():e.next().length&&(s=e.next())),e.slideUp((function(){$(this).remove()})),dittyDraftLayoutDelete(i,a),null!==s&&s.trigger("click")},_editLayout:function(t){t.preventDefault();var i=t.data.self,e=t.data.editType,s=($(t.target).is("a")?$(t.target):$(t.target).parent("a")).parents(".ditty-data-list__item"),a=s.data("layout_id");i.settings.editor.updateStart(),i.$list.find(".ditty-data-list__item").removeClass("editing"),s.addClass("editing");var d={action:"ditty_editor_layout_fields",layout_id:a,item_id:i.editorItemId,edit_type:e,draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,d,(function(t){if(t){var s="layout_"+e+"_editor",a='<div class="ditty-editor__panel ditty-editor__panel--'+s+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","slideLeft"),i.settings.editor.showPanel(s,a)}}),"json")},_actionClick:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("a")?$(t.target):$(t.target).parent("a"),s=e.parents(".ditty-data-list__item"),a=s.data("layout_id");dittyVars.editor.currentLayout=s,$("body").trigger("ditty_editor_layout_action_click",[e,s,a,i.editorDittyId,i.settings.editor])},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layouts_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layouts_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$elmt.removeClass("init"),this.$back.off("click",{self:this},this._backClick),this.$elmt.off("click",".ditty-data-list__item",{self:this},this._selectLayout),this.$elmt.off("click",".ditty-data-list__item__edit_html",{self:this,editType:"html"},this._editLayout),this.$elmt.off("click",".ditty-data-list__item__edit_css",{self:this,editType:"css"},this._editLayout),this.$elmt.off("click",".ditty-data-list__item__clone",{self:this},this._cloneLayout),this.$elmt.off("click",".ditty-data-list__item__delete",{self:this},this._deleteLayout),this.$list.off("click",".ditty-editor-layout > a",{self:this},this._actionClick),$("body").off("ditty_editor_save_ditty_response",{self:this},this._dittyEditorSaveResponse),this.elmt._ditty_layouts_panel=null}},$.fn.ditty_layouts_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layouts_panel||(this._ditty_layouts_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layouts_panel;if(!i)throw new Error("No Ditty_Layouts_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layouts_Panel.');return void 0!==e?e:this}},$.ditty_layouts_panel={},$.ditty_layouts_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null,prevPanel:""},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layout_html_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$textarea=this.$elmt.find(".ditty-editor-options__code"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$preview=this.$elmt.find(".ditty-editor-options__preview"),this.$editCss=this.$elmt.find(".ditty-editor-options__edit-css"),this.$title=this.$elmt.find(".ditty-editor-options__title"),this.$tags=this.$elmt.find(".ditty-editor-options__tags"),this.itemType=this.$form.data("item_type"),this.layoutId=this.$form.data("layout_id"),this.$editorItem=dittyVars.editor.currentItem,this.$editorLayout=dittyVars.editor.currentLayout,this.$editorLayoutTitle=!!this.$editorLayout&&this.$editorLayout.find(".ditty-data-list__item__label"),this.$editorLayoutVariation=dittyVars.editor.currentLayoutVariation,this.$editorLayoutVariationTitle=this.$editorLayoutVariation.find(".ditty-layout-variation__template span"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.codeEditor=null,this.codeHasUpdates=!1,this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this._initEditor(),this.$back.on("click",{self:this},this._backClick),this.$preview.on("click",{self:this},this._previewClick),this.$editCss.on("click",{self:this},this._editCss),this.$form.on("submit",{self:this},this._submitForm),this.$form.on("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.on("keyup",{self:this},this._titleUpdate),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts)},_showPrevPanel:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById",this.settings.prevPanel)},_titleUpdate:function(t){var i=t.data.self;i.settings.editor.addUpdate("layoutUpdate",i.layoutId)},_enablePreviewButton:function(){this.$preview.addClass("ditty-has-updates")},_disablePreviewButton:function(){this.$preview.removeClass("ditty-has-updates"),this.$preview.children("i").attr("class",this.$preview.children("i").data("class"))},_getLayoutItems:function(){var t=this.settings.editor.ditty.options("items"),i=[];return $.each(t,(function(t,e){String(e.layoutId)===String(this.layoutId)&&i.push(e.id)})),i},_addDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),i.$form.serialize()!==i.initData||i.codeHasUpdates?(i.afterUpdateAction="return",i.$form.trigger("submit")):i._showPrevPanel()},_previewClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit"))},_editCss:function(t){t.preventDefault();var i=t.data.self,e="layout_css_editor";if(i.settings.editor.updateStart(),i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit")),i.settings.editor.panelExists(e))i.settings.editor.$elmt.find(".ditty-editor__panel--layout_css_editor input.ditty-editor-options__title").val(i.$title.val()),i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e);else{var s={action:"ditty_editor_layout_fields",layout_id:i.layoutId,layout_title:i.$title.val(),ditty_id:i.editorDittyId,item_id:i.editorItemId,item_type:i.itemType,edit_type:"css",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,s,(function(t){if(t){var s='<div class="ditty-editor__panel ditty-editor__panel--'+e+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e,s)}}),"json")}},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.layoutId,s=i.itemType,a=i._getLayoutItems();if(i.$form.hasClass("ditty-editor-has-errors"))return!1;i.codeEditor.codemirror.save(),i.settings.editor.updateStart();var d={action:"ditty_editor_layout_update",layout_id:e,item_type:s,item_ids:a,edit_type:"html",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:d,success:function(t){i.initData=i.$form.serialize(),i._disablePreviewButton(),t.label&&(i.$editorLayoutTitle&&i.$editorLayoutTitle.html(t.label),i.$editorLayoutVariationTitle.html(t.label)),i.$editorLayoutTitle&&i.$editorLayoutTitle.find(".ditty-layout-version").remove(),i.$editorLayoutVariationTitle&&i.$editorLayoutVariationTitle.find(".ditty-layout-version").remove(),t.display_items&&i.settings.editor.ditty.updateItems(t.display_items,!1,!1,!0),t.draft_id&&t.draft_meta&&dittyDraftLayoutUpdate(i,t.draft_id,null,t.draft_meta),i.codeHasUpdates=!1,i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showPrevPanel(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty({return_items:0}),i.afterUpdateAction=""}})},_initEditor:function(){var t=this,i=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{};i.codemirror=_.extend({},i.codemirror,{indentUnit:2,tabSize:2}),this.codeEditor=wp.codeEditor.initialize(this.$textarea[0],i),this.codeEditor.codemirror.on("change",(function(){t.codeEditor.codemirror.save(),t.settings.editor.addUpdate("layout_html_update",t.layoutId),t.codeHasUpdates=!0,t._enablePreviewButton(),t.settings.editor.delayedSubmitEnable()}))},_insertTag:function(t){var i=t.data.self,e=$(t.target),s=e.text(),a=e.data("atts"),d=i.codeEditor.codemirror.getCursor();if(t.shiftKey&&a){var r="",o=s.length-1;$.each(a,(function(t,i){r+=" "+t+'="'+i.toString()+'"'})),s=s.substring(0,o)+r+s.substring(o)}i.codeEditor.codemirror.replaceRange(s,d),d.ch=d.ch+s.length,i.codeEditor.codemirror.setCursor(d)},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layout_html_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layout_html_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$back.off("click",{self:this},this._backClick),this.$preview.off("click",{self:this},this._previewClick),this.$editCss.off("click",{self:this},this._editCss),this.$form.off("submit",{self:this},this._submitForm),this.$form.off("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.off("keyup",{self:this},this._titleUpdate),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.codeEditor.codemirror.off("change"),this.codeEditor.codemirror.toTextArea(),this.elmt._ditty_layout_html_editor_panel=null}},$.fn.ditty_layout_html_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layout_html_editor_panel||(this._ditty_layout_html_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layout_html_editor_panel;if(!i)throw new Error("No Ditty_Layout_Html_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layout_Html_Editor_Panel.');return void 0!==e?e:this}},$.ditty_layout_html_editor_panel={},$.ditty_layout_html_editor_panel.defaults=t}(jQuery),function($){"use strict";var t={editor:null,prevPanel:""},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_layout_css_editor_panel.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-editor-options"),this.$textarea=this.$elmt.find(".ditty-editor-options__code"),this.$back=this.$elmt.find(".ditty-editor-options__back"),this.$preview=this.$elmt.find(".ditty-editor-options__preview"),this.$editHtml=this.$elmt.find(".ditty-editor-options__edit-html"),this.$title=this.$elmt.find(".ditty-editor-options__title"),this.$body=this.$elmt.find(".ditty-editor-options__body"),this.$tags=this.$elmt.find(".ditty-editor-options__tags"),this.itemType=this.$form.data("item_type"),this.layoutId=this.$form.data("layout_id"),this.$editorItem=dittyVars.editor.currentItem,this.$editorLayout=dittyVars.editor.currentLayout,this.$editorLayoutTitle=!!this.$editorLayout&&this.$editorLayout.find(".ditty-data-list__item__label"),this.$editorLayoutVariation=dittyVars.editor.currentLayoutVariation,this.$editorLayoutVariationTitle=this.$editorLayoutVariation.find(".ditty-layout-variation__template span"),this.editorDittyId=this.$editorItem.data("ditty_id"),this.editorItemId=this.$editorItem.data("item_id"),this.itemSelector="",this.codeEditor=null,this.codeHasUpdates=!1,
6
- this.initData=null,this.afterUpdateAction="",this._init()};i.prototype={_init:function(){this.initData=this.$form.serialize(),this._setCssSelector(),this._initEditor(),this.$back.on("click",{self:this},this._backClick),this.$preview.on("click",{self:this},this._previewClick),this.$editHtml.on("click",{self:this},this._editHtml),this.$form.on("submit",{self:this},this._submitForm),this.$form.on("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.on("keyup",{self:this},this._titleUpdate),this.$body.on("click",".ditty-editor-options__body__error",{self:this},this._removeErrorNotice),this.settings.editor.$elmt.on("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.on("ditty_editor_save_drafts",{self:this},this._saveDrafts)},_setCssSelector:function(){dittyVars.isTickerPost?this.itemSelector="#poststuff .ditty-layout--"+this.layoutId:this.itemSelector=".ditty-layout--"+this.layoutId},_showPrevPanel:function(){this.settings.editor.$panels.ditty_slider("options","transition","slideRight"),this.settings.editor.$panels.ditty_slider("showSlideById",this.settings.prevPanel)},_titleUpdate:function(t){var i=t.data.self;i.settings.editor.addUpdate("layoutUpdate",i.layoutId)},_enablePreviewButton:function(){this.$preview.addClass("ditty-has-updates")},_disablePreviewButton:function(){this.$preview.removeClass("ditty-has-updates"),this.$preview.children("i").attr("class",this.$preview.children("i").data("class"))},_addDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&i.$form.trigger("submit")},_saveDrafts:function(t){var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.afterUpdateAction="save",i.$form.trigger("submit"))},_backClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),i.$form.serialize()!==i.initData||i.codeHasUpdates?(i.afterUpdateAction="return",i.$form.trigger("submit")):i._showPrevPanel()},_previewClick:function(t){t.preventDefault();var i=t.data.self;i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit"))},_editHtml:function(t){t.preventDefault();var i=t.data.self,e="layout_html_editor";if(i.settings.editor.updateStart(),i.codeEditor.codemirror.save(),(i.$form.serialize()!==i.initData||i.codeHasUpdates)&&(i.$preview.children("i").attr("class",dittyVars.updateIcon),i.$form.trigger("submit")),i.settings.editor.panelExists(e))i.settings.editor.$elmt.find(".ditty-editor__panel--layout_html_editor input.ditty-editor-options__title").val(i.$title.val()),i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e);else{var s={action:"ditty_editor_layout_fields",layout_id:i.layoutId,layout_title:i.$title.val(),ditty_id:i.editorDittyId,item_id:i.editorItemId,item_type:i.itemType,edit_type:"html",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};$.post(dittyVars.ajaxurl,s,(function(t){if(t){var s='<div class="ditty-editor__panel ditty-editor__panel--'+e+'">'+t.form+"</div>";i.settings.editor.panelOptions("transition","fade"),i.settings.editor.showPanel(e,s)}}),"json")}},_showErrorNotice:function(){var t=$('<div class="ditty-editor-options__body__error"><span>'+dittyVars.strings.layout_css_error+"</span></div>");this.$body.append(t)},_removeErrorNotice:function(t){t.data.self.$body.find(".ditty-editor-options__body__error").remove()},_submitForm:function(t){t.preventDefault();var i=t.data.self,e=i.layoutId,s=i.itemType;if(i.$form.hasClass("ditty-editor-has-errors"))return!1;i.codeEditor.codemirror.save(),i.settings.editor.updateStart();var a={action:"ditty_editor_layout_update",layout_id:e,item_type:s,edit_type:"css",draft_values:i.settings.editor.getDraftValues(),security:dittyVars.security};i.$form.ajaxSubmit({url:dittyVars.ajaxurl,type:"post",dataType:"json",data:a,success:function(t){i.initData=i.$form.serialize(),i._disablePreviewButton(),t.label&&(i.$editorLayoutTitle&&i.$editorLayoutTitle.html(t.label),i.$editorLayoutVariationTitle.html(t.label)),i.$editorLayoutTitle&&i.$editorLayoutTitle.find(".ditty-layout-version").remove(),i.$editorLayoutVariationTitle&&i.$editorLayoutVariationTitle.find(".ditty-layout-version").remove(),t.code?dittyLayoutCss(t.code,i.layoutId):i._showErrorNotice(),t.draft_id&&t.draft_meta&&dittyDraftLayoutUpdate(i,t.draft_id,null,t.draft_meta),i.codeHasUpdates=!1,i.settings.editor.updateStop(),i.settings.editor.delayedSubmitDisable(),"return"===i.afterUpdateAction&&i._showPrevPanel(),"save"===i.afterUpdateAction&&i.settings.editor.saveDitty(),i.afterUpdateAction=""}})},_initEditor:function(){var t=this,i=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{},e=dittyVars.editor.ditty_layouts_sass?"sass":"css";i.codemirror=_.extend({},i.codemirror,{mode:e,indentUnit:2,tabSize:2}),this.codeEditor=wp.codeEditor.initialize(this.$textarea[0],i),this.codeEditor.codemirror.on("change",(function(){t.codeEditor.codemirror.save(),t.settings.editor.addUpdate("layoutCssUpdate",t.layoutId),t.codeHasUpdates=!0,t._enablePreviewButton(),t.settings.editor.delayedSubmitEnable()}))},_insertTag:function(t){var i=t.data.self,e=$(t.target).text(),s=i.codeEditor.codemirror.getCursor();i.codeEditor.codemirror.replaceRange(e,s),s.ch=s.ch+e.length,i.codeEditor.codemirror.setCursor(s)},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_layout_css_editor_panel_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_layout_css_editor_panel.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){this.$back.off("click",{self:this},this._backClick),this.$preview.off("click",{self:this},this._previewClick),this.$editHtml.off("click",{self:this},this._editHtml),this.$form.off("submit",{self:this},this._submitForm),this.$form.off("click",".ditty-editor-options__tag",{self:this},this._insertTag),this.$title.off("keyup",{self:this},this._titleUpdate),this.$body.off("click",".ditty-editor-options__body__error",{self:this},this._removeErrorNotice),this.settings.editor.$elmt.off("ditty_editor_add_drafts",{self:this},this._addDrafts),this.settings.editor.$elmt.off("ditty_editor_save_drafts",{self:this},this._saveDrafts),this.codeEditor.codemirror.off("change"),this.codeEditor.codemirror.toTextArea(),this.elmt._ditty_layout_css_editor_panel=null}},$.fn.ditty_layout_css_editor_panel=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_layout_css_editor_panel||(this._ditty_layout_css_editor_panel=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_layout_css_editor_panel;if(!i)throw new Error("No Ditty_Layout_Css_Editor_Panel applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Layout_Css_Editor_Panel.');return void 0!==e?e:this}},$.ditty_layout_css_editor_panel={},$.ditty_layout_css_editor_panel.defaults=t}(jQuery),jQuery(document).ready((function($){!function(){"use strict";function t(t,i){0===parseInt(i)?t.hide():t.show()}function i(t,i){"none"===i?t.hide():t.show()}function e(t,i){"none"===i?t.hide():t.show()}$("#ditty-editor").on("ditty_display_editor_panel_init",".ditty-editor__panel--displayEditor",(function(s,a){if("list"===a.displayType){var d=a.$form,r=d.find(".ditty-field--perPage"),o=d.find(".ditty-field--arrows").siblings(),n=d.find(".ditty-field--bullets").siblings();t(r,d.find('input[name="paging"]:checked').val()),d.find('input[name="paging"]').on("change",(function(){t(r,$(this).val())})),i(o,d.find('select[name="arrows"]').val()),d.find('select[name="arrows"]').on("change",(function(){i(o,$(this).val())})),e(n,d.find('select[name="bullets"]').val()),d.find('select[name="bullets"]').on("change",(function(){e(n,$(this).val())}))}}))}()}));
 
 
 
 
 
 
includes/js/ditty.min.js CHANGED
@@ -272,14 +272,17 @@ jQuery( document ).ready( function( $ ) {
272
  * @since 3.0
273
  * @return null
274
  */
275
- function dittyLayoutCss( layoutCss, layoutId ) {
276
  var $styles = jQuery( 'style#ditty-layout--' + layoutId );
277
  if ( undefined === $styles[0] ) {
278
  $styles = jQuery( '<style id="ditty-layout--' + layoutId + '"></style>' );
279
  jQuery( 'head' ).append( $styles );
 
 
 
 
 
280
  }
281
- layoutCss = layoutCss.replace( '&gt;', '>' );
282
- $styles.html( layoutCss );
283
  }
284
 
285
  /**
@@ -307,8 +310,6 @@ function dittyDisplayCss( displayCss, displayId ) {
307
  function dittyUpdateItems( itemSwaps ) {
308
  var animationSpeed = 500;
309
 
310
- console.log( 'itemSwaps:', itemSwaps );
311
-
312
  jQuery.each( itemSwaps, function( index, data ) {
313
  var $current = data.currentItem,
314
  $new = data.newItem;
272
  * @since 3.0
273
  * @return null
274
  */
275
+ function dittyLayoutCss( layoutCss, layoutId, updateCSS ) {
276
  var $styles = jQuery( 'style#ditty-layout--' + layoutId );
277
  if ( undefined === $styles[0] ) {
278
  $styles = jQuery( '<style id="ditty-layout--' + layoutId + '"></style>' );
279
  jQuery( 'head' ).append( $styles );
280
+ updateCSS = 'update';
281
+ }
282
+ if ( 'update' === updateCSS ) {
283
+ layoutCss = layoutCss.replace( '&gt;', '>' );
284
+ $styles.html( layoutCss );
285
  }
 
 
286
  }
287
 
288
  /**
310
  function dittyUpdateItems( itemSwaps ) {
311
  var animationSpeed = 500;
312
 
 
 
313
  jQuery.each( itemSwaps, function( index, data ) {
314
  var $current = data.currentItem,
315
  $new = data.newItem;
includes/js/editor/class-ditty-layout-css-editor-panel.js CHANGED
@@ -315,7 +315,7 @@
315
  }
316
 
317
  if ( response.code ) {
318
- dittyLayoutCss( response.code, self.layoutId );
319
  } else {
320
  self._showErrorNotice();
321
  }
315
  }
316
 
317
  if ( response.code ) {
318
+ dittyLayoutCss( response.code, self.layoutId, 'update' );
319
  } else {
320
  self._showErrorNotice();
321
  }
includes/js/editor/ditty-ticker-display-editor.js ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* global dittyVars:true */
2
+
3
+ jQuery( document ).ready( function( $ ) {
4
+
5
+ // Setup strict mode
6
+ (function() {
7
+
8
+ "use strict";
9
+
10
+ function modifyHeights( $minHeight, $maxHeight, directionValue ) {
11
+ console.log( directionValue );
12
+ if ( 'down' === directionValue || 'up' === directionValue ) {
13
+ $minHeight.show();
14
+ $maxHeight.show();
15
+ } else {
16
+ $minHeight.hide();
17
+ $maxHeight.hide();
18
+ }
19
+ }
20
+
21
+ $( '#ditty-editor' ).on( 'ditty_display_editor_panel_init', '.ditty-editor__panel--displayEditor', function( e, editorPanel ) {
22
+ if ( 'ticker' === editorPanel.displayType ) {
23
+ var $form = editorPanel.$form,
24
+ $minHeight = $form.find( '.ditty-field--minHeight' ),
25
+ $maxHeight = $form.find( '.ditty-field--maxHeight' );
26
+
27
+ // Set heights
28
+ modifyHeights( $minHeight, $maxHeight, $form.find( 'input[name="direction"]:checked' ).val() );
29
+ $form.find( 'input[name="direction"]' ).on( 'change', function() {
30
+ modifyHeights( $minHeight, $maxHeight, $( this ).val() );
31
+ } );
32
+ }
33
+ } );
34
+
35
+ }() );
36
+
37
+ } );
includes/js/partials/helpers.js CHANGED
@@ -4,14 +4,17 @@
4
  * @since 3.0
5
  * @return null
6
  */
7
- function dittyLayoutCss( layoutCss, layoutId ) {
8
  var $styles = jQuery( 'style#ditty-layout--' + layoutId );
9
  if ( undefined === $styles[0] ) {
10
  $styles = jQuery( '<style id="ditty-layout--' + layoutId + '"></style>' );
11
  jQuery( 'head' ).append( $styles );
 
 
 
 
 
12
  }
13
- layoutCss = layoutCss.replace( '&gt;', '>' );
14
- $styles.html( layoutCss );
15
  }
16
 
17
  /**
@@ -39,8 +42,6 @@ function dittyDisplayCss( displayCss, displayId ) {
39
  function dittyUpdateItems( itemSwaps ) {
40
  var animationSpeed = 500;
41
 
42
- console.log( 'itemSwaps:', itemSwaps );
43
-
44
  jQuery.each( itemSwaps, function( index, data ) {
45
  var $current = data.currentItem,
46
  $new = data.newItem;
4
  * @since 3.0
5
  * @return null
6
  */
7
+ function dittyLayoutCss( layoutCss, layoutId, updateCSS ) {
8
  var $styles = jQuery( 'style#ditty-layout--' + layoutId );
9
  if ( undefined === $styles[0] ) {
10
  $styles = jQuery( '<style id="ditty-layout--' + layoutId + '"></style>' );
11
  jQuery( 'head' ).append( $styles );
12
+ updateCSS = 'update';
13
+ }
14
+ if ( 'update' === updateCSS ) {
15
+ layoutCss = layoutCss.replace( '&gt;', '>' );
16
+ $styles.html( layoutCss );
17
  }
 
 
18
  }
19
 
20
  /**
42
  function dittyUpdateItems( itemSwaps ) {
43
  var animationSpeed = 500;
44
 
 
 
45
  jQuery.each( itemSwaps, function( index, data ) {
46
  var $current = data.currentItem,
47
  $new = data.newItem;
includes/sass/editor/_displays_panel.scss CHANGED
@@ -31,4 +31,14 @@
31
  overflow-y: scroll;
32
  -webkit-overflow-scrolling: touch;
33
  }
 
 
 
 
 
 
 
 
 
 
34
  }
31
  overflow-y: scroll;
32
  -webkit-overflow-scrolling: touch;
33
  }
34
+ }
35
+ #ditty-editor__settings .ditty-display-type-options--ticker .ditty-input--group__container > .ditty-field {
36
+ &.ditty-field--minHeight {
37
+ width: 50%;
38
+ padding-right: 7.5px;
39
+ }
40
+ &.ditty-field--maxHeight {
41
+ width: 50%;
42
+ padding-left: 7.5px;
43
+ }
44
  }
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, news, news ticker, rotator, data rotator, lists, data, aggregator, latest posts
5
  Requires at least: 4.5
6
- Tested up to: 5.8.2
7
- Stable tag: 3.0.8
8
  License: GPL2
9
 
10
  Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
@@ -66,6 +66,11 @@ The most common cause for an unresponsive Ditty (when using scroll or rotate mod
66
 
67
  == Changelog ==
68
 
 
 
 
 
 
69
  = 3.0.8 =
70
  * Minor bug fix in widget.php file
71
  * Added legacy helper for old extension versions
@@ -621,4 +626,4 @@ The most common cause for an unresponsive Ditty (when using scroll or rotate mod
621
 
622
  == Upgrade Notice ==
623
 
624
- Widget bug fix, extension license updates
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FUZKZGAJSBAE6
4
  Tags: ticker, news, news ticker, rotator, data rotator, lists, data, aggregator, latest posts
5
  Requires at least: 4.5
6
+ Tested up to: 5.8.3
7
+ Stable tag: 3.0.9
8
  License: GPL2
9
 
10
  Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
66
 
67
  == Changelog ==
68
 
69
+ = 3.0.9 =
70
+ * Ditty editor Layout css update bug fix
71
+ * Added WPML functionality to Ditty post type
72
+ * Ticker Display vertical scrolling updates
73
+
74
  = 3.0.8 =
75
  * Minor bug fix in widget.php file
76
  * Added legacy helper for old extension versions
626
 
627
  == Upgrade Notice ==
628
 
629
+ WPML integration and Ticker Display vertical scrolling updates
wpml-config.xml CHANGED
@@ -66,5 +66,6 @@
66
  </custom-fields-texts>
67
  <custom-types>
68
  <custom-type translate="1">ditty_news_ticker</custom-type>
 
69
  </custom-types>
70
  </wpml-config>
66
  </custom-fields-texts>
67
  <custom-types>
68
  <custom-type translate="1">ditty_news_ticker</custom-type>
69
+ <custom-type translate="1">ditty</custom-type>
70
  </custom-types>
71
  </wpml-config>