Ditty News Ticker - Version 3.0.19

Version Description

  • Added input sanitization updates to extensions settings
  • Bug fix for List display type autoplay speed
Download this release

Release Info

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

Code changes from version 3.0.18 to 3.0.19

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.18
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.18' );
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.19
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.19' );
24
  }
25
 
26
  // Plugin Folder Path.
includes/class-ditty-display-type-list.php CHANGED
@@ -22,7 +22,7 @@ class Ditty_Display_Type_List extends Ditty_Display_Type {
22
  * Setup the display settings
23
  *
24
  * @access public
25
- * @since 3.0.14
26
  */
27
  public function fields( $values = array() ) {
28
  $fields = array(
@@ -149,7 +149,7 @@ class Ditty_Display_Type_List extends Ditty_Display_Type {
149
  'max' => 60,
150
  'step' => 0.25,
151
  ),
152
- 'std' => isset( $values['autoplay'] ) ? $values['autoplay'] : false,
153
  ),
154
  'shuffle' => array(
155
  'type' => 'checkbox',
22
  * Setup the display settings
23
  *
24
  * @access public
25
+ * @since 3.0.19
26
  */
27
  public function fields( $values = array() ) {
28
  $fields = array(
149
  'max' => 60,
150
  'step' => 0.25,
151
  ),
152
+ 'std' => isset( $values['autoplaySpeed'] ) ? $values['autoplaySpeed'] : false,
153
  ),
154
  'shuffle' => array(
155
  'type' => 'checkbox',
includes/class-ditty-extensions.php CHANGED
@@ -666,9 +666,10 @@ class Ditty_Extensions {
666
  }
667
 
668
  $panel_data = array(
669
- 'post_data' => $_POST,
670
- 'extension' => $extension_ajax,
671
- 'panel' => $panel_ajax,
 
672
  );
673
  $panel_data = apply_filters( 'ditty_extension_panel_update', $panel_data );
674
  wp_send_json( $panel_data );
666
  }
667
 
668
  $panel_data = array(
669
+ 'post_data' => $_POST,
670
+ 'extension' => $extension_ajax,
671
+ 'panel' => $panel_ajax,
672
+ 'input_updates' => array(),
673
  );
674
  $panel_data = apply_filters( 'ditty_extension_panel_update', $panel_data );
675
  wp_send_json( $panel_data );
includes/fields/helpers.php CHANGED
@@ -7,6 +7,9 @@
7
  * @since 3.0
8
  */
9
  function ditty_field( $args = array() ) {
 
 
 
10
  if ( ! isset( $args['type'] ) ) {
11
  return '<div class="ditty-field ditty-field--error"><i class="fas fa-exclamation-circle"></i>' . __( 'No field type specified.', 'ditty-news-ticker' ) . '</div>';
12
  }
7
  * @since 3.0
8
  */
9
  function ditty_field( $args = array() ) {
10
+ if ( empty( $args ) ) {
11
+ return false;
12
+ }
13
  if ( ! isset( $args['type'] ) ) {
14
  return '<div class="ditty-field ditty-field--error"><i class="fas fa-exclamation-circle"></i>' . __( 'No field type specified.', 'ditty-news-ticker' ) . '</div>';
15
  }
includes/js/admin/class-ditty-extension.js CHANGED
@@ -95,10 +95,24 @@
95
  self.$panels.ditty_slider( 'showSlideById', slideId );
96
  },
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  /**
99
  * Panel update listener
100
  *
101
- * @since 3.0
102
  * @return null
103
  */
104
  _updatePanel: function ( e ) {
@@ -130,10 +144,13 @@
130
  panel : panel,
131
  security : dittyAdminVars.security
132
  },
133
- success: function( response ) {
134
  $icon.attr( 'class', iconClass );
135
  self.$elmt.removeClass( 'updating' );
136
- $( '#ditty-extensions' ).trigger( 'ditty_extension_panel_updated', [ response, self.$elmt, $panel ] );
 
 
 
137
  }
138
  } );
139
  },
95
  self.$panels.ditty_slider( 'showSlideById', slideId );
96
  },
97
 
98
+ /**
99
+ * Update inputs after save and sanitize
100
+ *
101
+ * @since 3.0.19
102
+ * @return null
103
+ */
104
+ _upateInputs: function( updates ) {
105
+ $.each( updates, function( inputName, updatedValue ) {
106
+ if ( $( 'input[name="' + inputName + '"]' ).length ) {
107
+ $( 'input[name="' + inputName + '"]' ).val( updatedValue );
108
+ }
109
+ } );
110
+ },
111
+
112
  /**
113
  * Panel update listener
114
  *
115
+ * @since 3.0.19
116
  * @return null
117
  */
118
  _updatePanel: function ( e ) {
144
  panel : panel,
145
  security : dittyAdminVars.security
146
  },
147
+ success: function( data ) {
148
  $icon.attr( 'class', iconClass );
149
  self.$elmt.removeClass( 'updating' );
150
+ if ( data.input_updates ) {
151
+ self._upateInputs( data.input_updates );
152
+ }
153
+ $( '#ditty-extensions' ).trigger( 'ditty_extension_panel_updated', [ data, self.$elmt, $panel ] );
154
  }
155
  } );
156
  },
includes/js/ditty-admin.min.js CHANGED
@@ -1 +1,1241 @@
1
- jQuery((function($){!function(){"use strict";$("#poststuff").trigger("ditty_init_fields"),$("#ditty-settings").ditty_settings()}()})),jQuery((function($){!function(){"use strict";$("#menu-posts-ditty .wp-submenu li").each((function(){var t=$(this),i=t.children("a");if(i.length){var e=i[0].href.split("="),s=e[e.length-1];t.addClass(s)}}))}()})),function($){"use strict";var t={},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_settings.defaults,e),this.$elmt=$(i),this.$form=this.$elmt.find(".ditty-settings__form"),this.$panels=this.$elmt.find(".ditty-settings__panels"),this.saveBtns=this.$elmt.find(".ditty-settings__save"),this.tabs=this.$elmt.find(".ditty-settings__tab"),this.$notice_update=this.$elmt.find(".ditty-notification--updated"),this.$notice_error=this.$elmt.find(".ditty-notification--error"),this.$notice_warning=this.$elmt.find(".ditty-notification--warning"),this.initData=null,this.url=window.location.href,this._init()};i.prototype={_init:function(){if(this._initSlider(),$("body").on("ditty_field_clone_update",{self:this},this._enableSettingsUpdates),this.saveBtns.on("click",{self:this},this._submitForm),this.$panels.on("ditty_slider_init",{self:this},this._sliderInit),this.$panels.on("ditty_slider_before_slide_update",{self:this},this._beforeSlideUpdate),this.$form.on("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.on("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.on("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.on("click",".ditty-default-layout-install",{self:this},this._installLayout),this.$form.on("click",".ditty-default-display-install",{self:this},this._installDisplay),this.$form.on("click",'.ditty-export-posts input[type="checkbox"]',{self:this},this._exportCheckboxClick),this.$elmt.hasClass("dynamic-tabs")&&this.tabs.on("click",{self:this},this._tabClick),this.$elmt.hasClass("dynamic-tabs")&&this.url.indexOf("#")>0){var t=this.url.substring(this.url.indexOf("#")+1);this._activatePanel(t)}},_initSlider:function(){if(this.$elmt.hasClass("dynamic-tabs")){var t=this.$panels.data("init_panel");this.$panels.ditty_slider({transition:"fade",transitionEase:"linear",transitionSpeed:0,heightSpeed:0,initTransition:"fade",initTransitionEase:"linear",initTransitionSpeed:0,initHeightEase:"linear",initHeightSpeed:0,touchSwipe:!1,slidesEl:".ditty-settings__panel",slideId:""!==t&&t})}},_sliderInit:function(t){var i=t.data.self;i.initData=i.$form.serialize()},_beforeSlideUpdate:function(t,i,e){var s=t.data.self;s._initFields(e.$elmt),s.$elmt.find(".ditty-settings__tab").removeClass("active"),s.$elmt.find('.ditty-settings__tab[data-panel="'+e.id+'"]').addClass("active")},_enableSettingsUpdates:function(t){(t?t.data.self:this).saveBtns.addClass("has-updates")},_disableSettingsUpdates:function(){this.saveBtns.removeClass("has-updates")},_checkUpdates:function(t){var i=t?t.data.self:this;i.$form.serialize()!==i.initData?i._enableSettingsUpdates():i._disableSettingsUpdates()},_initFields:function(t){t.find(".ditty-data-list").ditty_ui_data_list(),t.trigger("ditty_init_fields"),$.protip({defaults:{position:"top",size:"small",scheme:"black",classes:"ditty-protip"}})},_togglePostTypes:function(){if($('input[name="ditty_layout_ui"]').length){var t=$('input[name="ditty_layout_ui"]:checked').val(),i=$('#adminmenu .wp-submenu > li > a[href="edit.php?post_type=ditty_layout"]');"disabled"===t?i.hide():i.css("display","block")}if($('input[name="ditty_display_ui"]').length){var e=$('input[name="ditty_display_ui"]:checked').val(),s=$('#adminmenu .wp-submenu > li > a[href="edit.php?post_type=ditty_display"]');"disabled"===e?s.hide():s.css("display","block")}},_activatePanel:function(t){var i=this.$elmt.find('.ditty-settings__tab[data-panel="'+t+'"]');if(!i.length)return!1;this.$elmt.find(".ditty-settings__tab").removeClass("active"),i.addClass("active"),this.$panels.ditty_slider("showSlideById",t)},_tabClick:function(t){t.preventDefault();var i,e=t.data.self,s=$(t.target).is("a")?$(t.target):$(t.target).parent("a"),a=s.data("panel");if(e.$elmt.find(".ditty-settings__tab.active")===s)return!1;if(a){var n="#"+a;i=e.url.split("#")[0]+n}else i=e.url.split("#")[0];history.replaceState(null,null,i),e._activatePanel(a)},_upateInputs:function(t){$.each(t,(function(t,i){$('input[name="'+t+'"]').length&&$('input[name="'+t+'"]').val(i)}))},_submitForm:function(t){t.preventDefault();var i=t.data.self;if(i.$elmt.hasClass("updating"))return!1;i.$elmt.trigger("ditty_pre_save_fields"),i.$elmt.addClass("updating"),i.saveBtns.text(dittyAdminVars.adminStrings.settingsSaving),i.$form.ajaxSubmit({url:dittyAdminVars.ajaxurl,type:"post",dataType:"json",data:{action:"ditty_settings_save",security:dittyAdminVars.security},success:function(t){t.input_updates&&i._upateInputs(t.input_updates),i.initData=i.$form.serialize(),i.saveBtns.text(dittyAdminVars.adminStrings.settings_updated),setTimeout((function(){i.saveBtns.text(dittyAdminVars.adminStrings.settings_save)}),2e3),i.$elmt.removeClass("updating"),i._disableSettingsUpdates(),i._togglePostTypes()}})},_installLayout:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("button")?$(t.target):$(t.target).parents("button"),s=e.find("i"),a=s.attr("class");if(e.hasClass("updating"))return!1;e.addClass("updating"),s.attr("class",dittyAdminVars.updateIcon);var n={action:"ditty_install_layout",layout_template:e.data("layout_template"),layout_version:e.data("layout_version"),security:dittyAdminVars.security};$.post(dittyAdminVars.ajaxurl,n,(function(t){s.attr("class",a),i.$elmt.removeClass("updating"),t&&e.replaceWith(t.button)}))},_installDisplay:function(t){t.preventDefault();var i=t.data.self,e=$(t.target).is("button")?$(t.target):$(t.target).parents("button"),s=e.find("i"),a=s.attr("class");if(e.hasClass("updating"))return!1;e.addClass("updating"),s.attr("class",dittyAdminVars.updateIcon);var n={action:"ditty_install_display",display_type:e.data("display_type"),display_template:e.data("display_template"),display_version:e.data("display_version"),security:dittyAdminVars.security};$.post(dittyAdminVars.ajaxurl,n,(function(t){s.attr("class",a),i.$elmt.removeClass("updating"),t&&e.replaceWith(t.button)}))},_exportCheckboxClick:function(t){var i=$(t.target),e=i.parents(".ditty-input--checkboxes__group"),s=(i.parents(".ditty-field__input"),$(".ditty-export-button")),a=e.find('input[type="checkbox"]'),n=i.is(":checked");"select_all"===i.attr("value")&&a.each((function(){$(this)[0]!==i[0]&&$(this).prop("checked",n)}));var d=!1;a.each((function(){$(this).is(":checked")&&(d=!0)})),d?s.attr("disabled",!1):s.attr("disabled","disabled")},_options:function(t){return this.settings[t]},trigger:function(t,i){var e=[this.settings];i&&(e=i),this.$elmt.trigger("ditty_settings_"+t,e),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,e)},options:function(i,e){if("object"==typeof i)this.settings=$.extend({},t,$.ditty_settings.defaults,i);else{if("string"!=typeof i)return this.settings;if(void 0===e)return this.settings[i];this.settings[i]=e}this.trigger("options_update")},destroy:function(){$("body").off("ditty_field_clone_update",{self:this},this._enableSettingsUpdates),this.saveBtns.off("click",{self:this},this._submitForm),this.tabs.off("click",{self:this},this._tabClick),this.$panels.off("ditty_slider_init",{self:this},this._sliderInit),this.$panels.off("ditty_slider_before_slide_update",{self:this},this._beforeSlideUpdate),this.$form.off("keyup change",'input[type="text"], input[type="number"], textarea, select',{self:this},this._checkUpdates),this.$form.off("click",'input[type="radio"], input[type="checkbox"]',{self:this},this._checkUpdates),this.$form.off("ditty_input_wysiwyg_update",".ditty-input--wysiwyg",{self:this},this._checkUpdates),this.$form.off("click",".ditty-default-layout-install",{self:this},this._installLayout),this.$form.off("click",".ditty-default-display-install",{self:this},this._installDisplay),this.$form.off("click",'.ditty-export-posts input[type="checkbox"]',{self:this},this._exportCheckboxClick),this.$panels.ditty_slider("destroy"),this.elmt._ditty_settings=null}},$.fn.ditty_settings=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_settings||(this._ditty_settings=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_settings;if(!i)throw new Error("No Ditty_Settings applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Settings.');return void 0!==e?e:this}},$.ditty_settings={},$.ditty_settings.defaults=t}(jQuery),function($){"use strict";var t={},i=function(i,e){this.elmt=i,this.settings=$.extend({},t,$.ditty_extension.defaults,e),this.$elmt=$(i),this.$panels=$(i).find(".ditty-extension__panels"),this.initPanel=this.$panels.data("init_panel"),this._init()};i.prototype={_init:function(){this.$elmt.on("click",".ditty-extension__tab",{self:this},this._tabClick),this.$elmt.on("click",'button[name="submit"]',{self:this},this._updatePanel),this.$elmt.on("click",".ditty-extension__license__submit",{self:this,action:"ditty_extension_license_activate"},this._licenseUpdate),this.$elmt.on("click",".ditty-extension__license__refresh",{self:this,action:"ditty_extension_license_refresh"},this._licenseUpdate),this.$elmt.on("click",".ditty-extension__license__deactivate",{self:this,action:"ditty_extension_license_deactivate"},this._licenseUpdate),this.$panels.on("ditty_slider_before_slide_update",{self:this},this._beforePanelUpdate),this._initSlider()},_initSlider:function(){var t={transition:"fade",transitionSpeed:.75,heightSpeed:.75,touchSwipe:!1,slidesEl:".ditty-extension__panel",slideId:""!==this.initPanel&&this.initPanel};this.$panels.ditty_slider(t)},_beforePanelUpdate:function(t,i,e){var s=t.data.self;s.$elmt.find(".ditty-extension__tab").removeClass("active"),s.$elmt.find('.ditty-extension__tab[data-slide_id="'+e.id+'"]').addClass("active")},_tabClick:function(t){t.preventDefault();var i=t.data.self,e=$(this),s=e.data("slide_id"),a="slideLeft",n=i.$elmt.find(".ditty-extension__tab.active");if(n===e)return!1;e.index()<n.index()&&(a="slideRight"),i.$panels.ditty_slider("options","transition",a),i.$panels.ditty_slider("showSlideById",s)},_updatePanel:function(t){t.preventDefault();var i=t.data.self,e=$(this),s=e.parents(".ditty-extension__panel"),a=e.parents(".ditty-extension__form"),n=e.find("i"),d=n.attr("class"),l=i.$elmt.data("extension"),o=s.data("slide_id");if(i.$elmt.hasClass("updating"))return!1;i.$elmt.addClass("updating"),n.attr("class",dittyAdminVars.updateIcon),a.ajaxSubmit({url:dittyAdminVars.ajaxurl,type:"post",dataType:"json",data:{action:"ditty_extension_panel_update",extension:l,panel:o,security:dittyAdminVars.security},success:function(t){n.attr("class",d),i.$elmt.removeClass("updating"),$("#ditty-extensions").trigger("ditty_extension_panel_updated",[t,i.$elmt,s])}})},_licenseUpdate:function(t){t.preventDefault();var i=t.data.self,e=t.data.action,s=$(this),a=i.$elmt.find(".ditty-extension__license__message"),n=s.siblings(".ditty-extension__license__input"),d=n.val(),l=s.data("extension"),o=s.data("extension_id"),r=s.data("extension_name"),c=s.children("i");if(i.$elmt.hasClass("updating"))return!1;i.$elmt.addClass("updating"),c.attr("class",dittyAdminVars.updateIcon);var p={action:e,license:d,extension:l,extension_id:o,extension_name:r,security:dittyAdminVars.security};$.post(dittyAdminVars.ajaxurl,p,(function(t){t&&(i.$elmt.attr("data-license_status",t.status),a.html(t.message)),t.license_key&&("DELETE"===t.license_key?n.val(""):n.val(t.license_key)),c.attr("class",c.data("class")),i.$elmt.removeClass("updating")}),"json")},_getOption:function(t){return this.settings[t]},_setOption:function(t,i){if(void 0===i)return!1;this.settings[t]=i},options:function(t,i){var e=this;if("object"==typeof t)$.each(t,(function(t,i){e._setOption(t,i)}));else{if("string"!=typeof t)return e.settings;if(void 0===i)return e._getOption(t);e._setOption(t,i)}},destroy:function(){this.$elmt.off("click",".ditty-extension__tab",{self:this},this._tabClick),this.$elmt.off("click",'button[name="submit"]',{self:this},this._updatePanel),this.$elmt.off("click",".ditty-extension__license__submit, .ditty-extension__license__refresh",{self:this,action:"ditty_extension_license_activate"},this._licenseUpdate),this.$elmt.off("click",".ditty-extension__license__deactivate",{self:this,action:"ditty_extension_license_deactivate"},this._licenseUpdate),this.$panels.off("ditty_slider_after_slide_update",{self:this},this._afterPanelUpdate),this.$panels.ditty_slider("destroy"),this.elmt._ditty_extension=null}},$.fn.ditty_extension=function(t){var e,s=arguments,a=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_extension||(this._ditty_extension=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_extension;if(!i)throw new Error("No Ditty_Extension applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):a=!0})),a)throw new Error('No method "'+t+'" in Ditty_Extension.');return void 0!==e?e:this}},$.ditty_extension={},$.ditty_extension.defaults=t}(jQuery),jQuery((function($){!function(){"use strict";$.protip({defaults:{position:"top",size:"small",scheme:"black",classes:"ditty-protip"}}),$("#ditty-extensions").find(".ditty-extension").each((function(t){var i=$(this);i.find(".ditty-extension__panels").length&&i.ditty_extension(),$("#ditty-extensions").trigger("ditty_init_fields"),setTimeout((function(){i.addClass("ditty-extension--init")}),250*t)}))}()})),jQuery((function($){!function(){"use strict";var t=$('input[name="post_type"]').length&&"ditty_display"==$('input[name="post_type"]').val(),i=!1;$("form#post").on("submit",(function(e){if(t&&!i){e.preventDefault();var s=$("#publishing-action").children('input[type="submit"]'),a=$("#publishing-action").children(".spinner");s.attr("disabled","disabled"),a.css("visibility","visible");var n={action:"ditty_admin_display_update",display_id:$('input[name="post_ID"]').val(),security:dittyAdminVars.security};$("#ditty-display-settings").ajaxSubmit({url:dittyAdminVars.ajaxurl,type:"post",dataType:"json",data:n,success:function(t){i=!0,$("form#post").submit()}})}}))}()})),jQuery((function($){!function(){"use strict";var t={};$('.ditty-wizard-setting--title input[name="ditty_title"]').on("keyup",(function(){var i=$(this).parents(".ditty-wizard-setting"),e=$(this).val();""!==e&&(i.addClass("complete"),$(".ditty-wizard-setting--item-type").css("display","flex")),t.title=e})),$(".ditty-wizard-setting--item-type .ditty-option-grid__item").on("click",(function(i){i.preventDefault();var e=$(this).parents(".ditty-wizard-setting"),s=$(this).data("value");if(!$(this).hasClass("active")){$(this).siblings().removeClass("active"),$(this).addClass("active"),$(".ditty-wizard-setting--item-type-settings").removeClass("complete"),$(".ditty-wizard-setting--item-type-settings .ditty-option-submit").addClass("ditty-button--primary"),$(".ditty-wizard-setting--item-type-settings").css("display","flex");var a=$('.ditty-item-type-settings__group[data-id="'+s+'"]');$(".ditty-item-type-settings__group").removeClass("active").hide(),a.addClass("active").show(),a.trigger("ditty_init_fields"),a.hasClass("init")||(a.trigger("ditty_wizard_init",[s]),a.addClass("init")),$(".ditty-wizard-setting--layout").removeClass("complete"),$(".ditty-wizard-setting--layout .ditty-option-grid__item").removeClass("active"),$(".ditty-wizard-setting--layout").hide(),$(".ditty-wizard-setting--layout__variation").removeClass("complete").removeClass("active").hide(),$(".ditty-wizard-setting--layout__variation."+s).addClass("active").show(),$(".ditty-wizard-setting--display").removeClass("complete"),$(".ditty-wizard-setting--display .ditty-option-grid__item").removeClass("active"),$(".ditty-wizard-setting--display").hide(),$(".ditty-wizard-setting--submit").hide(),t.itemType=$(this).data("value"),e.hasClass("complete")||(e.addClass("complete"),$([document.documentElement,document.body]).stop().animate({scrollTop:$(".ditty-wizard-setting--item-type-settings").offset().top},700))}})),$(".ditty-wizard-setting--item-type-settings .ditty-option-submit").on("click",(function(i){i.preventDefault();var e=$(this).parents(".ditty-wizard-setting"),s=e.find(".ditty-item-type-settings__group.active"),a={};$(this).removeClass("ditty-button--primary"),s.find(":input").each((function(){var t=$(this).prop("type");"checkbox"===t||"radio"===t?this.checked&&(a[$(this).attr("name")]=$(this).val()):"button"!==t&&"submit"!==t&&(a[$(this).attr("name")]=$(this).val())})),$(".ditty-wizard-setting--layout").css("display","flex"),t.itemTypeValues=a,e.hasClass("complete")||(e.addClass("complete"),$([document.documentElement,document.body]).stop().animate({scrollTop:$(".ditty-wizard-setting--layout").offset().top},700))})),$(".ditty-wizard-setting--layout .ditty-option-grid__item").on("click",(function(i){i.preventDefault();var e=$(this).parents(".ditty-wizard-setting"),s=$(this).parents(".ditty-wizard-setting--layout__variation");if(!$(this).hasClass("active")&&($(this).siblings().removeClass("active"),$(this).addClass("active"),s.addClass("complete"),$(".ditty-wizard-setting--layout__variation.active").length===$(".ditty-wizard-setting--layout__variation.complete").length)){var a={};$(".ditty-wizard-setting--layout__variation.complete").each((function(){a[$(this).data("id")]=$(this).find(".ditty-option-grid__item.active").data("value")})),$(".ditty-wizard-setting--display").css("display","flex"),t.layoutVariations=a,e.hasClass("complete")||(e.addClass("complete"),$([document.documentElement,document.body]).stop().animate({scrollTop:$(".ditty-wizard-setting--display").offset().top},700))}})),$(".ditty-wizard-setting--display .ditty-option-grid__item").on("click",(function(i){i.preventDefault();var e=$(this).parents(".ditty-wizard-setting"),s=$(this).data("value");$(this).hasClass("active")||($(this).siblings().removeClass("active"),$(this).addClass("active"),$(".ditty-wizard-setting--submit").css("display","flex"),t.display=s,e.hasClass("complete")||(e.addClass("complete"),$([document.documentElement,document.body]).stop().animate({scrollTop:$(".ditty-wizard-setting--submit").offset().top},700)))})),$("#ditty-wizard-submit").on("click",(function(i){i.preventDefault();var e=$(this).data("ditty_id");$("#ditty-wizard-overlay").addClass("active");var s={action:"ditty_submit_wizard",ditty_id:e,init_values:t,security:dittyVars.security};$.post(dittyVars.ajaxurl,s,(function(t){window.history.pushState(null,"","/wp-admin/post.php?post="+e+"&action=edit"),location.reload()}),"json")}))}()}));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* global jQuery:true */
2
+ /* global dittyAdminVars:true */
3
+ /* global console:true */
4
+
5
+ // @codekit-append 'admin/general.js';
6
+ // @codekit-append 'admin/class-ditty-settings.js';
7
+ // @codekit-append 'admin/class-ditty-extension.js';
8
+ // @codekit-append 'admin/ditty-extensions.js';
9
+ // @codekit-append 'admin/ditty-displays.js';
10
+ // @codekit-append 'admin/ditty-wizard.js';
11
+
12
+ jQuery( function( $ ) {
13
+
14
+ // Setup strict mode
15
+ (function() {
16
+
17
+ "use strict";
18
+
19
+ $( '#poststuff' ).trigger( 'ditty_init_fields' );
20
+ $( '#ditty-settings' ).ditty_settings();
21
+
22
+ }() );
23
+
24
+ } );
25
+
26
+ /* global jQuery:true */
27
+
28
+ jQuery( function( $ ) {
29
+
30
+ // Setup strict mode
31
+ (function() {
32
+
33
+ "use strict";
34
+
35
+ $( '#menu-posts-ditty .wp-submenu li' ).each( function() {
36
+ var $item = $( this ),
37
+ $link = $item.children( 'a' );
38
+
39
+ if ( $link.length ) {
40
+ var href = $link[0].href,
41
+ parts = href.split( '=' ),
42
+ lastPart = parts[parts.length-1];
43
+
44
+ $item.addClass( lastPart );
45
+ }
46
+ } );
47
+
48
+ }() );
49
+
50
+ } );
51
+
52
+ /**
53
+ * Ditty Settings
54
+ *
55
+ * @since 3.0
56
+ * @return null
57
+ */
58
+
59
+ (function ($) {
60
+ 'use strict';
61
+
62
+ var defaults = {
63
+ };
64
+
65
+ var Ditty_Settings = function ( elmt, options ) {
66
+
67
+ this.elmt = elmt;
68
+ this.settings = $.extend( {}, defaults, $.ditty_settings.defaults, options );
69
+ this.$elmt = $( elmt );
70
+ this.$form = this.$elmt.find( '.ditty-settings__form' );
71
+ this.$panels = this.$elmt.find( '.ditty-settings__panels' );
72
+ this.saveBtns = this.$elmt.find( '.ditty-settings__save' );
73
+ this.tabs = this.$elmt.find( '.ditty-settings__tab' );
74
+ this.$notice_update = this.$elmt.find( '.ditty-notification--updated' );
75
+ this.$notice_error = this.$elmt.find( '.ditty-notification--error' );
76
+ this.$notice_warning = this.$elmt.find( '.ditty-notification--warning' );
77
+ this.initData = null;
78
+ this.url = window.location.href;
79
+ this._init();
80
+ };
81
+
82
+
83
+ Ditty_Settings.prototype = {
84
+
85
+ /**
86
+ * Initialize the data list
87
+ *
88
+ * @since 3.0
89
+ * @return null
90
+ */
91
+ _init: function () {
92
+
93
+ // Initialize the slider
94
+ this._initSlider();
95
+
96
+ // Add listeners
97
+ $( 'body' ).on( 'ditty_field_clone_update', { self: this }, this._enableSettingsUpdates );
98
+ this.saveBtns.on( 'click', { self: this }, this._submitForm );
99
+ this.$panels.on( 'ditty_slider_init', { self: this }, this._sliderInit );
100
+ this.$panels.on( 'ditty_slider_before_slide_update', { self: this }, this._beforeSlideUpdate );
101
+ this.$form.on( 'keyup change', 'input[type="text"], input[type="number"], textarea, select', { self: this }, this._checkUpdates );
102
+ this.$form.on( 'click', 'input[type="radio"], input[type="checkbox"]', { self: this }, this._checkUpdates );
103
+ this.$form.on( 'ditty_input_wysiwyg_update', '.ditty-input--wysiwyg', { self: this }, this._checkUpdates );
104
+ this.$form.on( 'click', '.ditty-default-layout-install', { self: this }, this._installLayout );
105
+ this.$form.on( 'click', '.ditty-default-display-install', { self: this }, this._installDisplay );
106
+
107
+ this.$form.on( 'click', '.ditty-export-posts input[type="checkbox"]', { self: this }, this._exportCheckboxClick );
108
+
109
+ if ( this.$elmt.hasClass( 'dynamic-tabs' ) ) {
110
+ this.tabs.on( 'click', { self: this }, this._tabClick );
111
+ }
112
+ if ( this.$elmt.hasClass( 'dynamic-tabs' ) && this.url.indexOf( "#" ) > 0 ) {
113
+ var activePanel = this.url.substring( this.url.indexOf( "#" ) + 1 );
114
+ this._activatePanel( activePanel );
115
+ }
116
+ },
117
+
118
+ /**
119
+ * Initialize the slider
120
+ *
121
+ * @since 3.0.13
122
+ * @return null
123
+ */
124
+ _initSlider: function () {
125
+ if ( this.$elmt.hasClass( 'dynamic-tabs' ) ) {
126
+ var initPanel = this.$panels.data( 'init_panel' );
127
+ this.$panels.ditty_slider( {
128
+ transition : 'fade',
129
+ transitionEase : 'linear',
130
+ transitionSpeed : 0,
131
+ heightSpeed : 0,
132
+ initTransition : 'fade',
133
+ initTransitionEase : 'linear',
134
+ initTransitionSpeed : 0,
135
+ initHeightEase : 'linear',
136
+ initHeightSpeed : 0,
137
+ touchSwipe : false,
138
+ slidesEl : '.ditty-settings__panel',
139
+ slideId : ( '' !== initPanel ) ? initPanel : false
140
+ } );
141
+ }
142
+ },
143
+
144
+ /**
145
+ * Slider init
146
+ *
147
+ * @since 3.0
148
+ * @return null
149
+ */
150
+ _sliderInit: function( e ) {
151
+ var self = e.data.self;
152
+ self.initData = self.$form.serialize();
153
+ },
154
+
155
+ /**
156
+ * Before slide update
157
+ *
158
+ * @since 3.0
159
+ * @return null
160
+ */
161
+ _beforeSlideUpdate: function( e, index, slide ) {
162
+ var self = e.data.self;
163
+ self._initFields( slide.$elmt );
164
+ self.$elmt.find( '.ditty-settings__tab' ).removeClass( 'active' );
165
+ self.$elmt.find( '.ditty-settings__tab[data-panel="' + slide.id + '"]' ).addClass( 'active' );
166
+ },
167
+
168
+ /**
169
+ * Preview button add updates class
170
+ *
171
+ * @since 3.0
172
+ * @return null
173
+ */
174
+ _enableSettingsUpdates: function( e ) {
175
+ var self = ( e ) ? e.data.self : this;
176
+ self.saveBtns.addClass( 'has-updates' );
177
+ //self.notice_warning.slideDown();
178
+ },
179
+
180
+ /**
181
+ * Preview button remove updates class
182
+ *
183
+ * @since 3.0
184
+ * @return null
185
+ */
186
+ _disableSettingsUpdates: function() {
187
+ this.saveBtns.removeClass( 'has-updates' );
188
+ },
189
+
190
+ /**
191
+ * Check for updates
192
+ *
193
+ * @since 3.0
194
+ * @return null
195
+ */
196
+ _checkUpdates: function( e ) {
197
+ var self = e ? e.data.self : this;
198
+ var currentData = self.$form.serialize();
199
+ if ( currentData !== self.initData ) {
200
+ self._enableSettingsUpdates();
201
+ } else {
202
+ self._disableSettingsUpdates();
203
+ }
204
+ },
205
+
206
+ /**
207
+ * Initialize dynamic fields
208
+ *
209
+ * @since 3.0
210
+ * @return null
211
+ */
212
+ _initFields: function ( $fields ) {
213
+ $fields.find( '.ditty-data-list' ).ditty_ui_data_list();
214
+ $fields.trigger( 'ditty_init_fields' );
215
+ $.protip( {
216
+ defaults: {
217
+ position: 'top',
218
+ size: 'small',
219
+ scheme: 'black',
220
+ classes: 'ditty-protip'
221
+ }
222
+ } );
223
+ },
224
+
225
+ /**
226
+ * Show or hide post types
227
+ *
228
+ * @since 3.0
229
+ * @return null
230
+ */
231
+ _togglePostTypes: function () {
232
+ if ( $( 'input[name="ditty_layout_ui"]' ).length ) {
233
+ var layoutUiVal = $( 'input[name="ditty_layout_ui"]:checked' ).val(),
234
+ $layoutMenu = $( '#adminmenu .wp-submenu > li > a[href="edit.php?post_type=ditty_layout"]' );
235
+ if ( 'disabled' === layoutUiVal ) {
236
+ $layoutMenu.hide();
237
+ } else {
238
+ $layoutMenu.css( 'display', 'block' );
239
+ }
240
+ }
241
+ if ( $( 'input[name="ditty_display_ui"]' ).length ) {
242
+ var displayUiVal = $( 'input[name="ditty_display_ui"]:checked' ).val(),
243
+ $displayMenu = $( '#adminmenu .wp-submenu > li > a[href="edit.php?post_type=ditty_display"]' );
244
+ if ( 'disabled' === displayUiVal ) {
245
+ $displayMenu.hide();
246
+ } else {
247
+ $displayMenu.css( 'display', 'block' );
248
+ }
249
+ }
250
+ },
251
+
252
+ /**
253
+ * Activate a panel
254
+ *
255
+ * @since 3.0.13
256
+ * @return null
257
+ */
258
+ _activatePanel: function( panelId ) {
259
+ var $tab = this.$elmt.find( '.ditty-settings__tab[data-panel="' + panelId + '"]' );
260
+ if ( ! $tab.length ) {
261
+ return false;
262
+ }
263
+
264
+ this.$elmt.find( '.ditty-settings__tab' ).removeClass( 'active' );
265
+ $tab.addClass( 'active' );
266
+
267
+ this.$panels.ditty_slider( 'showSlideById', panelId );
268
+ },
269
+
270
+ /**
271
+ * Listen for a tab click
272
+ *
273
+ * @since 3.0
274
+ * @return null
275
+ */
276
+ _tabClick: function( e ) {
277
+ e.preventDefault();
278
+ var self = e.data.self,
279
+ $tab = $( e.target ).is( 'a' ) ? $( e.target ) : $( e.target ).parent( 'a' ),
280
+ slideId = $tab.data( 'panel' ),
281
+ $currentTab = self.$elmt.find( '.ditty-settings__tab.active' );
282
+
283
+ if ( $currentTab === $tab ) {
284
+ return false;
285
+ }
286
+
287
+ var newUrl;
288
+ if ( slideId ) {
289
+ var hash = '#' + slideId;
290
+ newUrl = self.url.split("#")[0] + hash;
291
+ } else {
292
+ newUrl = self.url.split("#")[0];
293
+ }
294
+ history.replaceState( null, null, newUrl );
295
+
296
+ self._activatePanel( slideId );
297
+ },
298
+
299
+ /**
300
+ * Update inputs after save and sanitize
301
+ *
302
+ * @since 3.0
303
+ * @return null
304
+ */
305
+ _upateInputs: function( updates ) {
306
+ $.each( updates, function( inputName, updatedValue ) {
307
+ if ( $( 'input[name="' + inputName + '"]' ).length ) {
308
+ $( 'input[name="' + inputName + '"]' ).val( updatedValue );
309
+ }
310
+ } );
311
+ },
312
+
313
+ /**
314
+ * Submit updates
315
+ *
316
+ * @since 3.0
317
+ * @return null
318
+ */
319
+ _submitForm: function( e ) {
320
+ e.preventDefault();
321
+ var self = e.data.self;
322
+
323
+ if ( self.$elmt.hasClass( 'updating' ) ) {
324
+ return false;
325
+ }
326
+
327
+ self.$elmt.trigger( 'ditty_pre_save_fields' );
328
+ self.$elmt.addClass( 'updating' );
329
+ self.saveBtns.text( dittyAdminVars.adminStrings.settingsSaving );
330
+
331
+ self.$form.ajaxSubmit( {
332
+ url : dittyAdminVars.ajaxurl,
333
+ type : 'post',
334
+ dataType : 'json',
335
+ data : {
336
+ action : 'ditty_settings_save',
337
+ security : dittyAdminVars.security
338
+ },
339
+ success: function( data ) {
340
+ if ( data.input_updates ) {
341
+ self._upateInputs( data.input_updates );
342
+ }
343
+ self.initData = self.$form.serialize();
344
+ self.saveBtns.text( dittyAdminVars.adminStrings.settings_updated );
345
+ setTimeout( function() {
346
+ self.saveBtns.text( dittyAdminVars.adminStrings.settings_save );
347
+ }, 2000 );
348
+ self.$elmt.removeClass( 'updating' );
349
+ self._disableSettingsUpdates();
350
+
351
+ //self.$notice_update.slideDown();
352
+
353
+ // Check the post types display
354
+ self._togglePostTypes();
355
+ }
356
+ } );
357
+ },
358
+
359
+ /**
360
+ * Install a layout
361
+ *
362
+ * @since 3.0
363
+ * @return null
364
+ */
365
+ _installLayout: function( e ) {
366
+ e.preventDefault();
367
+ var self = e.data.self,
368
+ $button = $( e.target ).is( 'button' ) ? $( e.target ) : $( e.target ).parents( 'button' ),
369
+ $icon = $button.find( 'i' ),
370
+ iconClass = $icon.attr( 'class' );
371
+
372
+ if ( $button.hasClass( 'updating' ) ) {
373
+ return false;
374
+ }
375
+ $button.addClass( 'updating' );
376
+ $icon.attr( 'class', dittyAdminVars.updateIcon );
377
+
378
+ var data = {
379
+ action : 'ditty_install_layout',
380
+ layout_template : $button.data( 'layout_template' ),
381
+ layout_version : $button.data( 'layout_version' ),
382
+ security : dittyAdminVars.security
383
+ };
384
+ $.post( dittyAdminVars.ajaxurl, data, function( response ) {
385
+ $icon.attr( 'class', iconClass );
386
+ self.$elmt.removeClass( 'updating' );
387
+ if ( response ) {
388
+ $button.replaceWith( response.button );
389
+ }
390
+ } );
391
+ },
392
+
393
+ /**
394
+ * Install a display
395
+ *
396
+ * @since 3.0
397
+ * @return null
398
+ */
399
+ _installDisplay: function( e ) {
400
+ e.preventDefault();
401
+ var self = e.data.self,
402
+ $button = $( e.target ).is( 'button' ) ? $( e.target ) : $( e.target ).parents( 'button' ),
403
+ $icon = $button.find( 'i' ),
404
+ iconClass = $icon.attr( 'class' );
405
+
406
+ if ( $button.hasClass( 'updating' ) ) {
407
+ return false;
408
+ }
409
+ $button.addClass( 'updating' );
410
+ $icon.attr( 'class', dittyAdminVars.updateIcon );
411
+
412
+ var data = {
413
+ action : 'ditty_install_display',
414
+ display_type : $button.data( 'display_type' ),
415
+ display_template : $button.data( 'display_template' ),
416
+ display_version : $button.data( 'display_version' ),
417
+ security : dittyAdminVars.security
418
+ };
419
+ $.post( dittyAdminVars.ajaxurl, data, function( response ) {
420
+ $icon.attr( 'class', iconClass );
421
+ self.$elmt.removeClass( 'updating' );
422
+ if ( response ) {
423
+ $button.replaceWith( response.button );
424
+ }
425
+ } );
426
+ },
427
+
428
+ /**
429
+ * Listen for export checkbox click
430
+ *
431
+ * @since 3.0.17
432
+ * @return null
433
+ */
434
+ _exportCheckboxClick: function( e ) {
435
+ var $checkbox = $( e.target ),
436
+ $group = $checkbox.parents( '.ditty-input--checkboxes__group' ),
437
+ $container = $checkbox.parents( '.ditty-field__input' ),
438
+ $button = $( '.ditty-export-button' ),
439
+ checkboxes = $group.find( 'input[type="checkbox"]' ),
440
+ isChecked = $checkbox.is( ':checked' ),
441
+ value = $checkbox.attr( 'value' );
442
+
443
+ if ( 'select_all' === value ) {
444
+ checkboxes.each( function() {
445
+ if ( $( this )[0] !== $checkbox[0] ) {
446
+ $( this ).prop( 'checked', isChecked );
447
+ }
448
+ } );
449
+ }
450
+
451
+ // Check if any checkboxes are selected
452
+ var enableButton = false;
453
+ checkboxes.each( function() {
454
+ if ( $( this ).is( ':checked' ) ) {
455
+ enableButton = true;
456
+ }
457
+ } );
458
+
459
+ if ( enableButton ) {
460
+ $button.attr( 'disabled', false );
461
+ } else {
462
+ $button.attr( 'disabled', 'disabled' );
463
+ }
464
+ },
465
+
466
+ /**
467
+ * Return a specific setting
468
+ *
469
+ * @since 3.0
470
+ * @return null
471
+ */
472
+ _options: function ( key ) {
473
+ return this.settings[key];
474
+ },
475
+
476
+ /**
477
+ * Setup triggers
478
+ *
479
+ * @since 3.0
480
+ * @return null
481
+ */
482
+ trigger: function ( fn, customParams ) {
483
+ var params = [this.settings];
484
+ if ( customParams ) {
485
+ params = customParams;
486
+ }
487
+
488
+ this.$elmt.trigger( 'ditty_settings_' + fn, params );
489
+
490
+ if ( typeof this.settings[fn] === 'function' ) {
491
+ this.settings[fn].apply( this.$elmt, params );
492
+ }
493
+ },
494
+
495
+ /**
496
+ * Allow settings to be modified
497
+ *
498
+ * @since 3.0
499
+ * @return null
500
+ */
501
+ options: function ( key, value ) {
502
+
503
+ if ( typeof key === 'object' ) {
504
+ this.settings = $.extend( {}, defaults, $.ditty_settings.defaults, key );
505
+ } else if ( typeof key === 'string' ) {
506
+ if ( value === undefined ) {
507
+ return this.settings[key];
508
+ }
509
+ this.settings[key] = value;
510
+ } else {
511
+ return this.settings;
512
+ }
513
+
514
+ this.trigger( 'options_update' );
515
+ },
516
+
517
+ /**
518
+ * Destroy the editor
519
+ *
520
+ * @since 3.0
521
+ * @return null
522
+ */
523
+ destroy: function () {
524
+
525
+ // Remove listeners
526
+ $( 'body' ).off( 'ditty_field_clone_update', { self: this }, this._enableSettingsUpdates );
527
+ this.saveBtns.off( 'click', { self: this }, this._submitForm );
528
+ this.tabs.off( 'click', { self: this }, this._tabClick );
529
+ this.$panels.off( 'ditty_slider_init', { self: this }, this._sliderInit );
530
+ this.$panels.off( 'ditty_slider_before_slide_update', { self: this }, this._beforeSlideUpdate );
531
+ this.$form.off( 'keyup change', 'input[type="text"], input[type="number"], textarea, select', { self: this }, this._checkUpdates );
532
+ this.$form.off( 'click', 'input[type="radio"], input[type="checkbox"]', { self: this }, this._checkUpdates );
533
+ this.$form.off( 'ditty_input_wysiwyg_update', '.ditty-input--wysiwyg', { self: this }, this._checkUpdates );
534
+ this.$form.off( 'click', '.ditty-default-layout-install', { self: this }, this._installLayout );
535
+ this.$form.off( 'click', '.ditty-default-display-install', { self: this }, this._installDisplay );
536
+
537
+ this.$form.off( 'click', '.ditty-export-posts input[type="checkbox"]', { self: this }, this._exportCheckboxClick );
538
+
539
+ this.$panels.ditty_slider( 'destroy' );
540
+ this.elmt._ditty_settings = null;
541
+ }
542
+ };
543
+
544
+ /**
545
+ * Create the data list
546
+ *
547
+ * @since 3.0
548
+ * @return null
549
+ */
550
+ $.fn.ditty_settings = function( options ) {
551
+ var args = arguments,
552
+ error = false,
553
+ returns;
554
+
555
+ if ( options === undefined || typeof options === 'object' ) {
556
+ return this.each( function () {
557
+ if ( ! this._ditty_settings ) {
558
+ this._ditty_settings = new Ditty_Settings( this, options );
559
+ }
560
+ });
561
+ } else if ( typeof options === 'string' ) {
562
+ this.each( function () {
563
+ var instance = this._ditty_settings;
564
+
565
+ if ( ! instance ) {
566
+ throw new Error( 'No Ditty_Settings applied to this element.' );
567
+ }
568
+ if ( typeof instance[options] === 'function' && options[0] !== '_' ) {
569
+ returns = instance[options].apply( instance, [].slice.call( args, 1 ) );
570
+ } else {
571
+ error = true;
572
+ }
573
+ } );
574
+
575
+ if ( error ) {
576
+ throw new Error( 'No method "' + options + '" in Ditty_Settings.' );
577
+ }
578
+
579
+ return returns !== undefined ? returns : this;
580
+ }
581
+ };
582
+
583
+ $.ditty_settings = {};
584
+ $.ditty_settings.defaults = defaults;
585
+
586
+ } )( jQuery );
587
+
588
+
589
+ /**
590
+ * Ditty Extension class
591
+ *
592
+ * @since 3.0
593
+ * @return null
594
+ */
595
+
596
+ (function ($) {
597
+ 'use strict';
598
+
599
+ var defaults = {
600
+ };
601
+
602
+ var Ditty_Extension = function ( elmt, options ) {
603
+
604
+ this.elmt = elmt;
605
+ this.settings = $.extend( {}, defaults, $.ditty_extension.defaults, options );
606
+ this.$elmt = $( elmt );
607
+ this.$panels = $( elmt ).find( '.ditty-extension__panels' );
608
+ this.initPanel = this.$panels.data( 'init_panel' );
609
+
610
+ this._init();
611
+ };
612
+
613
+ Ditty_Extension.prototype = {
614
+
615
+ _init: function () {
616
+
617
+ // Add listeners
618
+ this.$elmt.on( 'click', '.ditty-extension__tab', { self: this }, this._tabClick );
619
+ this.$elmt.on( 'click', 'button[name="submit"]', { self: this }, this._updatePanel );
620
+ this.$elmt.on( 'click', '.ditty-extension__license__submit', { self: this, action: 'ditty_extension_license_activate' }, this._licenseUpdate );
621
+ this.$elmt.on( 'click', '.ditty-extension__license__refresh', { self: this, action: 'ditty_extension_license_refresh' }, this._licenseUpdate );
622
+ this.$elmt.on( 'click', '.ditty-extension__license__deactivate', { self: this, action: 'ditty_extension_license_deactivate' }, this._licenseUpdate );
623
+ this.$panels.on( 'ditty_slider_before_slide_update', { self: this }, this._beforePanelUpdate );
624
+ this._initSlider();
625
+ },
626
+
627
+ /**
628
+ * Initialize the slider
629
+ *
630
+ * @since 3.0
631
+ * @return null
632
+ */
633
+ _initSlider: function () {
634
+ var args = {
635
+ transition : 'fade',
636
+ transitionSpeed : 0.75,
637
+ heightSpeed : 0.75,
638
+ touchSwipe : false,
639
+ slidesEl : '.ditty-extension__panel',
640
+ slideId : ( '' !== this.initPanel ) ? this.initPanel : false
641
+ };
642
+ this.$panels.ditty_slider( args );
643
+ },
644
+
645
+ /**
646
+ * Initialize the slider
647
+ *
648
+ * @since 3.0
649
+ * @return null
650
+ */
651
+ _beforePanelUpdate: function ( e, index, slide ) {
652
+ var self = e.data.self;
653
+ self.$elmt.find( '.ditty-extension__tab' ).removeClass( 'active' );
654
+ self.$elmt.find( '.ditty-extension__tab[data-slide_id="' + slide.id + '"]' ).addClass( 'active' );
655
+ },
656
+
657
+ /**
658
+ * Tab click
659
+ *
660
+ * @since 3.0
661
+ * @return null
662
+ */
663
+ _tabClick: function ( e ) {
664
+ e.preventDefault();
665
+ var self = e.data.self;
666
+ var $tab = $( this ),
667
+ slideId = $tab.data( 'slide_id' ),
668
+ transition = 'slideLeft',
669
+ $currentTab = self.$elmt.find( '.ditty-extension__tab.active' );
670
+
671
+ if ( $currentTab === $tab ) {
672
+ return false;
673
+ }
674
+
675
+ if ( $tab.index() < $currentTab.index() ) {
676
+ transition = 'slideRight';
677
+ }
678
+
679
+ //self.$elmt.find( '.ditty-extension__tab' ).removeClass( 'active' );
680
+ //$tab.addClass( 'active' );
681
+
682
+ self.$panels.ditty_slider( 'options', 'transition', transition );
683
+ self.$panels.ditty_slider( 'showSlideById', slideId );
684
+ },
685
+
686
+ /**
687
+ * Update inputs after save and sanitize
688
+ *
689
+ * @since 3.0.19
690
+ * @return null
691
+ */
692
+ _upateInputs: function( updates ) {
693
+ $.each( updates, function( inputName, updatedValue ) {
694
+ if ( $( 'input[name="' + inputName + '"]' ).length ) {
695
+ $( 'input[name="' + inputName + '"]' ).val( updatedValue );
696
+ }
697
+ } );
698
+ },
699
+
700
+ /**
701
+ * Panel update listener
702
+ *
703
+ * @since 3.0.19
704
+ * @return null
705
+ */
706
+ _updatePanel: function ( e ) {
707
+ e.preventDefault();
708
+ var self = e.data.self;
709
+
710
+ var $button = $( this ),
711
+ $panel = $button.parents( '.ditty-extension__panel' ),
712
+ $form = $button.parents( '.ditty-extension__form' ),
713
+ $icon = $button.find( 'i' ),
714
+ iconClass = $icon.attr( 'class' ),
715
+ extension = self.$elmt.data( 'extension' ),
716
+ panel = $panel.data( 'slide_id' );
717
+
718
+ if ( self.$elmt.hasClass( 'updating' ) ) {
719
+ return false;
720
+ }
721
+
722
+ self.$elmt.addClass( 'updating' );
723
+ $icon.attr( 'class', dittyAdminVars.updateIcon );
724
+
725
+ $form.ajaxSubmit( {
726
+ url : dittyAdminVars.ajaxurl,
727
+ type : 'post',
728
+ dataType : 'json',
729
+ data : {
730
+ action : 'ditty_extension_panel_update',
731
+ extension : extension,
732
+ panel : panel,
733
+ security : dittyAdminVars.security
734
+ },
735
+ success: function( data ) {
736
+ $icon.attr( 'class', iconClass );
737
+ self.$elmt.removeClass( 'updating' );
738
+ if ( data.input_updates ) {
739
+ self._upateInputs( data.input_updates );
740
+ }
741
+ $( '#ditty-extensions' ).trigger( 'ditty_extension_panel_updated', [ data, self.$elmt, $panel ] );
742
+ }
743
+ } );
744
+ },
745
+
746
+ /**
747
+ * Update a license
748
+ *
749
+ * @since 3.0
750
+ * @return null
751
+ */
752
+ _licenseUpdate: function ( e ) {
753
+ e.preventDefault();
754
+ var self = e.data.self,
755
+ action = e.data.action;
756
+
757
+ var $button = $( this ),
758
+ $message = self.$elmt.find( '.ditty-extension__license__message' ),
759
+ $input = $button.siblings( '.ditty-extension__license__input' ),
760
+ license = $input.val(),
761
+ extension = $button.data( 'extension' ),
762
+ extensionId = $button.data( 'extension_id' ),
763
+ extensionName = $button.data( 'extension_name' ),
764
+ $icon = $button.children( 'i' );
765
+
766
+ if ( self.$elmt.hasClass( 'updating' ) ) {
767
+ return false;
768
+ }
769
+
770
+ self.$elmt.addClass( 'updating' );
771
+ $icon.attr( 'class', dittyAdminVars.updateIcon );
772
+
773
+ // Load the new display data
774
+ var data = {
775
+ action : action,
776
+ license : license,
777
+ extension : extension,
778
+ extension_id : extensionId,
779
+ extension_name : extensionName,
780
+ security : dittyAdminVars.security
781
+ };
782
+ $.post( dittyAdminVars.ajaxurl, data, function( response ) {
783
+ if ( response ) {
784
+ self.$elmt.attr( 'data-license_status', response.status );
785
+ $message.html( response.message );
786
+ }
787
+ if ( response.license_key ) {
788
+ if ( 'DELETE' === response.license_key ) {
789
+ $input.val( '' );
790
+ } else {
791
+ $input.val( response.license_key );
792
+ }
793
+ }
794
+ $icon.attr( 'class', $icon.data( 'class' ) );
795
+ self.$elmt.removeClass( 'updating' );
796
+ }, 'json' );
797
+ },
798
+
799
+ /**
800
+ * Return data for the object
801
+ *
802
+ * @since 3.0
803
+ * @return null
804
+ */
805
+ _getOption: function( key ) {
806
+ switch( key ) {
807
+ default:
808
+ return this.settings[key];
809
+ }
810
+ },
811
+
812
+ /**
813
+ * Set data for the object
814
+ *
815
+ * @since 3.0
816
+ * @return null
817
+ */
818
+ _setOption: function( key, value ) {
819
+ if ( undefined === value ) {
820
+ return false;
821
+ }
822
+
823
+ this.settings[key] = value;
824
+ },
825
+
826
+ /**
827
+ * Get or set ditty options
828
+ *
829
+ * @since 3.0
830
+ * @return null
831
+ */
832
+ options: function ( key, value ) {
833
+ var self = this;
834
+ if ( typeof key === 'object' ) {
835
+ $.each( key, function( k, v ) {
836
+ self._setOption( k, v );
837
+ });
838
+ } else if ( typeof key === 'string' ) {
839
+ if ( value === undefined ) {
840
+ return self._getOption( key );
841
+ }
842
+ self._setOption( key, value );
843
+ } else {
844
+ return self.settings;
845
+ }
846
+ },
847
+
848
+ /**
849
+ * Destroy this object
850
+ *
851
+ * @since 3.0
852
+ * @return null
853
+ */
854
+ destroy: function () {
855
+ // Remove listeners
856
+ this.$elmt.off( 'click', '.ditty-extension__tab', { self: this }, this._tabClick );
857
+ this.$elmt.off( 'click', 'button[name="submit"]', { self: this }, this._updatePanel );
858
+ this.$elmt.off( 'click', '.ditty-extension__license__submit, .ditty-extension__license__refresh', { self: this, action: 'ditty_extension_license_activate' }, this._licenseUpdate );
859
+ this.$elmt.off( 'click', '.ditty-extension__license__deactivate', { self: this, action: 'ditty_extension_license_deactivate' }, this._licenseUpdate );
860
+ this.$panels.off( 'ditty_slider_after_slide_update', { self: this }, this._afterPanelUpdate );
861
+
862
+ this.$panels.ditty_slider( 'destroy' );
863
+ this.elmt._ditty_extension = null;
864
+ }
865
+ };
866
+
867
+ $.fn.ditty_extension = function( options ) {
868
+ var args = arguments,
869
+ error = false,
870
+ returns;
871
+
872
+ if ( options === undefined || typeof options === 'object' ) {
873
+ return this.each( function () {
874
+ if ( ! this._ditty_extension ) {
875
+ this._ditty_extension = new Ditty_Extension( this, options );
876
+ }
877
+ });
878
+ } else if ( typeof options === 'string' ) {
879
+ this.each( function () {
880
+ var instance = this._ditty_extension;
881
+
882
+ if ( ! instance ) {
883
+ throw new Error( 'No Ditty_Extension applied to this element.' );
884
+ }
885
+ if ( typeof instance[options] === 'function' && options[0] !== '_' ) {
886
+ returns = instance[options].apply( instance, [].slice.call( args, 1 ) );
887
+ } else {
888
+ error = true;
889
+ }
890
+ } );
891
+
892
+ if ( error ) {
893
+ throw new Error( 'No method "' + options + '" in Ditty_Extension.' );
894
+ }
895
+
896
+ return returns !== undefined ? returns : this;
897
+ }
898
+ };
899
+
900
+ $.ditty_extension = {};
901
+ $.ditty_extension.defaults = defaults;
902
+
903
+ } )( jQuery );
904
+
905
+
906
+
907
+ jQuery( function( $ ) {
908
+ // Setup strict mode
909
+ (function() {
910
+
911
+ "use strict";
912
+
913
+ // Setup protip
914
+ $.protip( {
915
+ defaults: {
916
+ position: 'top',
917
+ size: 'small',
918
+ scheme: 'black',
919
+ classes: 'ditty-protip'
920
+ }
921
+ } );
922
+
923
+ /**
924
+ * Listen for an accordion toggle click
925
+ *
926
+ * @since 3.0
927
+ * @return null
928
+ */
929
+ // $( '#ditty-extensions' ).on( 'click', '.ditty-accordion__toggle', function( e ) {
930
+ // e.preventDefault();
931
+ // var $accordion = $( this ).parent(),
932
+ // $content = $( this ).next();
933
+ //
934
+ // if ( $accordion.hasClass( 'active' ) ) {
935
+ // $accordion.removeClass( 'active' );
936
+ // $content.stop().slideUp( { duration: 750, easing: "easeInOutQuint" } );
937
+ // } else {
938
+ // $accordion.addClass( 'active' );
939
+ // $content.stop().slideDown( { duration: 750, easing: "easeInOutQuint" }, function() {
940
+ // $content.css( 'height', 'auto' );
941
+ // } );
942
+ // }
943
+ // } );
944
+ //
945
+ /**
946
+ * Initialize the extensions
947
+ *
948
+ * @since 3.0
949
+ * @return null
950
+ */
951
+ function ditty_extensions_init() {
952
+ $( '#ditty-extensions' ).find( '.ditty-extension' ).each( function( index ) {
953
+
954
+ var $extension = $( this ),
955
+ $panels = $extension.find( '.ditty-extension__panels' );
956
+
957
+ if ( $panels.length ) {
958
+ $extension.ditty_extension();
959
+ }
960
+
961
+ $( '#ditty-extensions' ).trigger( 'ditty_init_fields' );
962
+
963
+ setTimeout( function() {
964
+ $extension.addClass( 'ditty-extension--init' );
965
+ }, index * 250 );
966
+
967
+ } );
968
+ }
969
+ ditty_extensions_init();
970
+
971
+ }() );
972
+
973
+ } );
974
+
975
+
976
+ jQuery( function( $ ) {
977
+ // Setup strict mode
978
+ (function() {
979
+
980
+ "use strict";
981
+
982
+ var isDisplayPost = ( $( 'input[name="post_type"]' ).length && 'ditty_display' == $( 'input[name="post_type"]' ).val() ),
983
+ ajaxSubmitComplete = false;
984
+
985
+ $( 'form#post' ).on( 'submit', function( e ) {
986
+ if ( isDisplayPost && ! ajaxSubmitComplete ) {
987
+ e.preventDefault();
988
+
989
+ var $button = $( '#publishing-action' ).children( 'input[type="submit"]' ),
990
+ $spinner = $( '#publishing-action' ).children( '.spinner' );
991
+
992
+ $button.attr( 'disabled', 'disabled' );
993
+ $spinner.css( 'visibility', 'visible' );
994
+
995
+ var data = {
996
+ action : 'ditty_admin_display_update',
997
+ display_id : $( 'input[name="post_ID"]' ).val(),
998
+ security : dittyAdminVars.security
999
+ };
1000
+ $( '#ditty-display-settings' ).ajaxSubmit( {
1001
+ url : dittyAdminVars.ajaxurl,
1002
+ type : 'post',
1003
+ dataType : 'json',
1004
+ data : data,
1005
+ success: function( response ) {
1006
+ ajaxSubmitComplete = true;
1007
+ $( 'form#post' ).submit();
1008
+ }
1009
+ } );
1010
+ }
1011
+ } );
1012
+
1013
+ }() );
1014
+
1015
+ } );
1016
+
1017
+
1018
+ jQuery( function( $ ) {
1019
+ // Setup strict mode
1020
+ (function() {
1021
+
1022
+ "use strict";
1023
+
1024
+ var dittyWizardValues = {};
1025
+
1026
+ /**
1027
+ * Ditty title
1028
+ *
1029
+ * @since 3.0.13
1030
+ */
1031
+ $( '.ditty-wizard-setting--title input[name="ditty_title"]' ).on( 'keyup', function() {
1032
+ var $setting = $( this ).parents( '.ditty-wizard-setting' ),
1033
+ val = $( this ).val();
1034
+
1035
+ if ( '' !== val ) {
1036
+ $setting.addClass( 'complete' );
1037
+
1038
+ // Show the layout settings
1039
+ $( '.ditty-wizard-setting--item-type').css( 'display', 'flex' );
1040
+ }
1041
+ dittyWizardValues.title = val;
1042
+ } );
1043
+
1044
+ /**
1045
+ * Item Type
1046
+ *
1047
+ * @since 3.0.13
1048
+ */
1049
+ $( '.ditty-wizard-setting--item-type .ditty-option-grid__item' ).on( 'click', function( e ) {
1050
+ e.preventDefault();
1051
+ var $setting = $( this ).parents( '.ditty-wizard-setting' ),
1052
+ slug = $( this ).data( 'value' );
1053
+
1054
+ if ( ! $( this ).hasClass( 'active' ) ) {
1055
+
1056
+ $( this ).siblings().removeClass( 'active' );
1057
+ $( this ).addClass( 'active' );
1058
+
1059
+ // Reset & show item type settings
1060
+ $( '.ditty-wizard-setting--item-type-settings' ).removeClass( 'complete' );
1061
+ $( '.ditty-wizard-setting--item-type-settings .ditty-option-submit' ).addClass( 'ditty-button--primary' );
1062
+ $( '.ditty-wizard-setting--item-type-settings').css( 'display', 'flex' );
1063
+
1064
+ // Display the correct item type settings group
1065
+ var $itemSettings = $( '.ditty-item-type-settings__group[data-id="' + slug + '"]' );
1066
+ $( '.ditty-item-type-settings__group' ).removeClass( 'active' ).hide();
1067
+ $itemSettings.addClass( 'active' ).show();
1068
+ $itemSettings.trigger( 'ditty_init_fields' );
1069
+ if ( ! $itemSettings.hasClass( 'init' ) ) {
1070
+ $itemSettings.trigger( 'ditty_wizard_init', [slug] );
1071
+ $itemSettings.addClass( 'init' );
1072
+ }
1073
+
1074
+ // Reset the layout settings
1075
+ $( '.ditty-wizard-setting--layout' ).removeClass( 'complete' );
1076
+ $( '.ditty-wizard-setting--layout .ditty-option-grid__item' ).removeClass( 'active' );
1077
+ $( '.ditty-wizard-setting--layout').hide();
1078
+
1079
+ // Display the correct layout variation settings group
1080
+ $( '.ditty-wizard-setting--layout__variation' ).removeClass( 'complete' ).removeClass( 'active' ).hide();
1081
+ $( '.ditty-wizard-setting--layout__variation.' + slug ).addClass( 'active' ).show();
1082
+
1083
+ // Reset the display settings
1084
+ $( '.ditty-wizard-setting--display' ).removeClass( 'complete' );
1085
+ $( '.ditty-wizard-setting--display .ditty-option-grid__item' ).removeClass( 'active' );
1086
+ $( '.ditty-wizard-setting--display').hide();
1087
+
1088
+ // Reset the submit settings
1089
+ $( '.ditty-wizard-setting--submit').hide();
1090
+
1091
+ // Add to the initialize object
1092
+ dittyWizardValues.itemType = $( this ).data( 'value' );
1093
+
1094
+ // Animate to the next setting
1095
+ if ( ! $setting.hasClass( 'complete' ) ) {
1096
+ $setting.addClass( 'complete' );
1097
+ $( [document.documentElement, document.body] ).stop().animate( {
1098
+ scrollTop: $( '.ditty-wizard-setting--item-type-settings' ).offset().top
1099
+ }, 700 );
1100
+ }
1101
+ }
1102
+ } );
1103
+
1104
+ /**
1105
+ * Item Type Settings Submit
1106
+ *
1107
+ * @since 3.0.13
1108
+ */
1109
+ $( '.ditty-wizard-setting--item-type-settings .ditty-option-submit' ).on( 'click', function( e ) {
1110
+ e.preventDefault();
1111
+ var $setting = $( this ).parents( '.ditty-wizard-setting' ),
1112
+ $settings_group = $setting.find( '.ditty-item-type-settings__group.active' ),
1113
+ values = {};
1114
+
1115
+ $( this ).removeClass( 'ditty-button--primary' );
1116
+
1117
+ $settings_group.find( ':input' ).each( function() {
1118
+ var type = $( this ).prop( 'type' );
1119
+
1120
+ // checked radios/checkboxes
1121
+ if ( ( type === "checkbox" || type === "radio" ) ) {
1122
+ if ( this.checked ) {
1123
+ values[$( this ).attr( 'name' )] = $( this ).val();
1124
+ }
1125
+ } else if ( type !== "button" && type !== "submit" ) {
1126
+ values[$( this ).attr( 'name' )] = $( this ).val();
1127
+ }
1128
+ } );
1129
+
1130
+ // Show the layout settings
1131
+ $( '.ditty-wizard-setting--layout').css( 'display', 'flex' );
1132
+
1133
+ // Add to the initialize object
1134
+ dittyWizardValues.itemTypeValues = values;
1135
+
1136
+ // Animate to the next setting
1137
+ if ( ! $setting.hasClass( 'complete' ) ) {
1138
+ $setting.addClass( 'complete' );
1139
+ $( [document.documentElement, document.body] ).stop().animate( {
1140
+ scrollTop: $( '.ditty-wizard-setting--layout' ).offset().top
1141
+ }, 700 );
1142
+ }
1143
+ } );
1144
+
1145
+ /**
1146
+ * Variation Layout
1147
+ *
1148
+ * @since 3.0.13
1149
+ */
1150
+ $( '.ditty-wizard-setting--layout .ditty-option-grid__item' ).on( 'click', function( e ) {
1151
+ e.preventDefault();
1152
+ var $setting = $( this ).parents( '.ditty-wizard-setting' ),
1153
+ $variations = $( this ).parents( '.ditty-wizard-setting--layout__variation' );
1154
+
1155
+ if ( ! $( this ).hasClass( 'active' ) ) {
1156
+ $( this ).siblings().removeClass( 'active' );
1157
+ $( this ).addClass( 'active' );
1158
+ $variations.addClass( 'complete' );
1159
+
1160
+ // Check for all variations complete
1161
+ if ( $( '.ditty-wizard-setting--layout__variation.active' ).length === $( '.ditty-wizard-setting--layout__variation.complete' ).length ) {
1162
+ var layoutVariations = {};
1163
+ $( '.ditty-wizard-setting--layout__variation.complete' ).each( function() {
1164
+ layoutVariations[$( this ).data( 'id' )] = $( this ).find( '.ditty-option-grid__item.active' ).data( 'value' );
1165
+ } );
1166
+
1167
+ // Show the display settings
1168
+ $( '.ditty-wizard-setting--display').css( 'display', 'flex' );
1169
+
1170
+ dittyWizardValues.layoutVariations = layoutVariations;
1171
+
1172
+ // Animate to the next setting
1173
+ if ( ! $setting.hasClass( 'complete' ) ) {
1174
+ $setting.addClass( 'complete' );
1175
+ $( [document.documentElement, document.body] ).stop().animate( {
1176
+ scrollTop: $( '.ditty-wizard-setting--display' ).offset().top
1177
+ }, 700 );
1178
+ }
1179
+ }
1180
+ }
1181
+ } );
1182
+
1183
+ /**
1184
+ * Display
1185
+ *
1186
+ * @since 3.0.13
1187
+ */
1188
+ $( '.ditty-wizard-setting--display .ditty-option-grid__item' ).on( 'click', function( e ) {
1189
+ e.preventDefault();
1190
+ var $setting = $( this ).parents( '.ditty-wizard-setting' ),
1191
+ id = $( this ).data( 'value' );
1192
+
1193
+ if ( ! $( this ).hasClass( 'active' ) ) {
1194
+ $( this ).siblings().removeClass( 'active' );
1195
+ $( this ).addClass( 'active' );
1196
+
1197
+ // Show the submit settings
1198
+ $( '.ditty-wizard-setting--submit').css( 'display', 'flex' );
1199
+
1200
+ dittyWizardValues.display = id;
1201
+
1202
+ // Animate to the next setting
1203
+ if ( ! $setting.hasClass( 'complete' ) ) {
1204
+ $setting.addClass( 'complete' );
1205
+ $( [document.documentElement, document.body] ).stop().animate( {
1206
+ scrollTop: $( '.ditty-wizard-setting--submit' ).offset().top
1207
+ }, 700 );
1208
+ }
1209
+ }
1210
+ } );
1211
+
1212
+ /**
1213
+ * Submit the wizard
1214
+ *
1215
+ * @since 3.0.13
1216
+ */
1217
+ $( '#ditty-wizard-submit' ).on( 'click', function( e ) {
1218
+ e.preventDefault();
1219
+
1220
+ var dittyId = $( this ).data( 'ditty_id' );
1221
+
1222
+ $( '#ditty-wizard-overlay' ).addClass( 'active' );
1223
+
1224
+ //$( this ).text( $( this ).data( 'submitting' ) );
1225
+
1226
+ var data = {
1227
+ action : 'ditty_submit_wizard',
1228
+ ditty_id : dittyId,
1229
+ init_values : dittyWizardValues,
1230
+ security : dittyVars.security
1231
+ };
1232
+ $.post( dittyVars.ajaxurl, data, function( response ) {
1233
+ window.history.pushState( null, '', '/wp-admin/post.php?post=' + dittyId + '&action=edit' );
1234
+ location.reload();
1235
+ }, 'json' );
1236
+
1237
+ } );
1238
+
1239
+ }() );
1240
+
1241
+ } );
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: metaphorcreations
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FUZKZGAJSBAE6
4
  Tags: ticker, post ticker, news ticker, content aggregator, latest posts, live refresh, rotator, data rotator, lists, data, aggregator
5
  Requires at least: 4.5
6
- Tested up to: 5.9.2
7
- Stable tag: 3.0.18
8
  License: GPL2
9
 
10
  Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
@@ -66,6 +66,10 @@ The most common cause for an unresponsive Ditty (when using scroll or rotate mod
66
 
67
  == Changelog ==
68
 
 
 
 
 
69
  = 3.0.18 =
70
  * Added Title settings for Posts feed lite
71
  * Added Content settings for Posts feed lite
@@ -700,4 +704,4 @@ The most common cause for an unresponsive Ditty (when using scroll or rotate mod
700
 
701
  == Upgrade Notice ==
702
 
703
- Added additional Post feed lite settings
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FUZKZGAJSBAE6
4
  Tags: ticker, post ticker, news ticker, content aggregator, latest posts, live refresh, rotator, data rotator, lists, data, aggregator
5
  Requires at least: 4.5
6
+ Tested up to: 5.9.3
7
+ Stable tag: 3.0.19
8
  License: GPL2
9
 
10
  Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
66
 
67
  == Changelog ==
68
 
69
+ = 3.0.19 =
70
+ * Added input sanitization updates to extensions settings
71
+ * Bug fix for List display type autoplay speed
72
+
73
  = 3.0.18 =
74
  * Added Title settings for Posts feed lite
75
  * Added Content settings for Posts feed lite
704
 
705
  == Upgrade Notice ==
706
 
707
+ Bug fix for List display type autoplay speed