Version Description
- Ticker cloneItems bug fix
Download this release
Release Info
Developer | metaphorcreations |
Plugin | Ditty News Ticker |
Version | 3.0.14 |
Comparing to | |
See all releases |
Code changes from version 3.0.13 to 3.0.14
ditty-news-ticker.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Ditty (formerly Ditty News Ticker)
|
5 |
* Plugin URI: https://www.metaphorcreations.com/ditty
|
6 |
* Description: Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
|
7 |
-
* Version: 3.0.
|
8 |
* Author: Metaphor Creations
|
9 |
* Author URI: https://www.metaphorcreations.com
|
10 |
* License: GPL-2.0+
|
@@ -20,7 +20,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
20 |
|
21 |
// Plugin version.
|
22 |
if ( ! defined( 'DITTY_VERSION' ) ) {
|
23 |
-
define( 'DITTY_VERSION', '3.0.
|
24 |
}
|
25 |
|
26 |
// Plugin Folder Path.
|
4 |
* Plugin Name: Ditty (formerly Ditty News Ticker)
|
5 |
* Plugin URI: https://www.metaphorcreations.com/ditty
|
6 |
* Description: Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
|
7 |
+
* Version: 3.0.14
|
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.14' );
|
24 |
}
|
25 |
|
26 |
// Plugin Folder Path.
|
includes/js/class-ditty-display-ticker.js
CHANGED
@@ -317,7 +317,7 @@
|
|
317 |
return false;
|
318 |
}
|
319 |
|
320 |
-
var existingItems = this.$items.children( '.ditty-item--' + this.settings.items[index].
|
321 |
if ( 'yes' !== this.settings.cloneItems && existingItems.length ) {
|
322 |
return false;
|
323 |
}
|
317 |
return false;
|
318 |
}
|
319 |
|
320 |
+
var existingItems = this.$items.children( '.ditty-item--' + this.settings.items[index].uniq_id );
|
321 |
if ( 'yes' !== this.settings.cloneItems && existingItems.length ) {
|
322 |
return false;
|
323 |
}
|
includes/js/class-ditty-display-ticker.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function($){"use strict";var t={id:0,title:"",display:0,status:"",direction:"left",spacing:20,speed:10,cloneItems:"yes",hoverPause:0,height:null,minHeight:null,maxHeight:null,heightEase:"easeInOutQuint",heightSpeed:1.5,scrollInit:"empty",scrollDelay:2,maxWidth:"",bgColor:"",padding:{},margin:{},borderColor:{},borderStyle:{},borderWidth:{},borderRadius:{},contentsBgColor:"",contentsPadding:{},contentsBorderColor:{},contentsBorderStyle:{},contentsBorderWidth:{},contentsBorderRadius:{},titleDisplay:"none",titleElement:"h3",titleElementPosition:"topLeft",titleFontSize:"",titleLineHeight:"",titleColor:"",titleBgColor:"",titleMargin:{},titlePadding:{},titleBorderColor:{},titleBorderStyle:{},titleBorderWidth:{},titleBorderRadius:{},itemTextColor:"",itemBgColor:"",itemBorderColor:{},itemBorderStyle:{},itemBorderWidth:{},itemBorderRadius:{},itemPadding:{},itemMaxWidth:"",itemElementsWrap:"wrap",item:0,shuffle:0,showEditor:0,items:[]},i=function(i,e){this.displayType="ticker",this.elmt=i,this.settings=$.extend({},t,$.ditty_ticker.defaults,e),this.nextItem=null,this.total=this.settings.items.length,this.$elmt=$(i),this.$title=null,this.$titleContents=null,this.$contents=null,this.$items=null,this.$currentItem=null,this.$lastItem=null,this.scrollPercent=.13,this.running=!1,this.interval=!1,this.currentHeight=this.settings.height,this.visibleItems=[],1===parseInt(this.settings.shuffle)&&this.shuffle(),this._init()};i.prototype={_init:function(){var t,i,e=this;0===this.total&&this.hide(),this.$elmt.removeClass("ditty--pre"),this.$elmt.addClass("ditty ditty-ticker"),this.$elmt.attr("data-id",this.settings.id),this.$elmt.attr("data-type",this.displayType),this.$elmt.attr("data-display",this.settings.display),t=$('<div class="ditty-ticker__contents"></div>'),this.$contents=t,this.$title=$('<div class="ditty-ticker__title"></div>'),this.$titleContents=$('<div class="ditty-ticker__title__contents"></div>'),this.$title.append(this.$titleContents),i=$('<div class="ditty-ticker__items"></div>'),this.$items=i,this.$items.height(this.currentHeight),t.append(i),this.$elmt.append(t),this._styleDisplay(),this._styleTitle(),this.$elmt.on("mouseenter",{self:this},this._mouseenter),this.$elmt.on("mouseleave",{self:this},this._mouseleave),this.settings.showEditor?dittyEditorInit(this):this.trigger("start_live_updates"),setTimeout((function(){for(var t=0;t<e.total;t++)e._preloadItem(e.settings.items[t]);e._initializeItems(),e.trigger("init")}),1)},_initializeItems:function(){"filled"===this.settings.scrollInit?this._fillTicker():this.running||this._timerStart()},_preloadItem:function(t){$(t.html).find("img").each((function(){(new Image).src=$(this).attr("src")}))},_positionItems:function(t){var i=this;if(0===i.visibleItems.length){var e=i.settings.item;this._isItemEnabled(e)||(e=this._getNextItem(e)),i._initializeItem(e)}$.each(i.visibleItems,(function(e,s){if(s){var n=i.visibleItems[e].$item,r=i._calculateItemPosition(e,t);i.visibleItems[e].posX=r.posX,i.visibleItems[e].posY=r.posY,i._itemSetTransform(n,r),i._newItemShouldStart(n,r)&&i._initializeItem(parseInt(i.nextItem)),i._itemShouldTerminate(n,r)&&i._terminateItem(e)}}))},_timerStart:function(){var t=this;this.running=!0,this.trigger("start"),cancelAnimationFrame(this.interval),t.interval=requestAnimationFrame((function i(){t._positionItems(),t.interval=requestAnimationFrame(i)}))},_timerStop:function(){cancelAnimationFrame(this.interval),this.running=!1,this.trigger("stop")},_mouseenter:function(t){var i=t.data.self;i.settings.hoverPause&&i._timerStop()},_mouseleave:function(t){var i=t.data.self;i.settings.hoverPause&&i._timerStart()},_newItemShouldStart:function(t,i){if(this.$currentItem[0]!==t[0])return!1;var e=!1;switch(this.settings.direction){case"left":i.posX<=this.$items.outerWidth()-t.outerWidth()&&(e=!0);break;case"right":i.posX>=0&&(e=!0);break;case"down":i.posY>=0&&(e=!0);break;case"up":i.posY<=this.$items.outerHeight()-t.outerHeight()&&(e=!0)}return e},_initializeItem:function(t,i){if(void 0===this.settings.items[t])return!1;var e=this.$items.children(".ditty-item--"+this.settings.items[t].id);if("yes"!==this.settings.cloneItems&&e.length)return!1;var s=$(this.settings.items[t].html);if(s.css({top:0,left:0}),this.$items.children(".ditty-item--"+this.settings.items[t].id).not(".ditty-item--clone").length>0&&s.addClass("ditty-item--clone"),this._styleItem(s),this.settings.items[t].css&&dittyLayoutCss(this.settings.items[t].css,this.settings.items[t].layout_id),this._itemSpacing(s),this._itemSetTransform(s,this._itemResetPosition(s)),this.$items.append(s),s.css({display:"block",top:0,left:0,opacity:1}),s.addClass("ditty-item--current"),null!==this.$currentItem&&this.$currentItem.removeClass("ditty-item--current"),this.$currentItem=s,null===this.$lastItem&&(s.addClass("ditty-item--last"),this.$lastItem=s),this.settings.item=t,this.nextItem=this._getNextItem(t),"custom"!==i){var n=this._itemResetPosition(s);this._itemSetTransform(s,n),this.visibleItems.push({$item:s,itemId:this.settings.items[t].id,posX:n.posX,posY:n.posY}),this._setCurrentHeight()}return this.trigger("active_items_update"),s},_getNextItem:function(t){var i,e=this,s=!1;if(null!==this.nextItem&&t!==this.nextItem){var n=parseInt(this.nextItem);n<this.total&&n>=0&&e._isItemEnabled(n)&&(s=parseInt(this.nextItem))}if(!s)for(i=t;i<this.total;i++)if(i!==t&&e._isItemEnabled(i)){s=parseInt(i);break}if(!s)for(i=0;i<this.total;i++)if(e._isItemEnabled(i)){s=parseInt(i);break}return s},_itemShouldTerminate:function(t,i){var e=!1;switch(this.settings.direction){case"left":i.posX<-t.outerWidth()&&(e=!0);break;case"right":i.posX>this.$items.outerWidth()&&(e=!0);break;case"up":i.posY<-t.outerHeight()&&(e=!0);break;case"down":i.posY>this.$items.outerHeight()&&(e=!0)}return e},_terminateItem:function(t){var i=this.visibleItems[t].$item,e=i.next();i.remove(),this.visibleItems.splice(t,1),e.length&&(e.addClass("ditty-item--last"),this.$lastItem=e),this._setCurrentHeight(),this.trigger("active_items_update")},_setCurrentHeight:function(){var t=this.currentHeight;"up"===this.settings.direction||"down"===this.settings.direction?(t=this.$items.outerHeight(),this.$items.css({height:"100%"})):(t=0,$.each(this.visibleItems,(function(i,e){var s=e.$item.outerHeight();s>t&&(t=s)})),t!==this.currentHeight&&this.$items.stop().animate({height:t+"px"},1e3*parseFloat(this.settings.heightSpeed),this.settings.heightEase,(function(){}))),t!==this.currentHeight&&(this.currentHeight=t,this.trigger("height_updated"))},_itemSpacing:function(t){switch(this.settings.direction){case"left":case"right":t.css({paddingLeft:this.settings.spacing/2+"px",paddingRight:this.settings.spacing/2+"px",paddingTop:0,paddingBottom:0});break;case"up":case"down":t.css({paddingLeft:0,paddingRight:0,paddingTop:this.settings.spacing/2+"px",paddingBottom:this.settings.spacing/2+"px"})}},_itemSetTransform:function(t,i){var e=i.posX,s=i.posY;0!==e&&(e+="px"),0!==s&&(s+="px"),t.css({transform:"translate( "+e+", "+s+" )"})},_calculateItemPosition:function(t,i){var e=0,s=0,n=parseFloat(this.settings.speed)*this.scrollPercent;switch(i&&(n=i),this.settings.direction){case"left":e=parseFloat(this.visibleItems[t].posX)-n;break;case"right":e=parseFloat(this.visibleItems[t].posX)+n;break;case"up":s=parseFloat(this.visibleItems[t].posY)-n;break;case"down":s=parseFloat(this.visibleItems[t].posY)+n}return{posX:e,posY:s}},_itemResetPosition:function(t){var i=0,e=0;switch(this.settings.direction){case"left":i=this.$items.outerWidth();break;case"right":i="-"+t.outerWidth();break;case"up":e=this.$items.outerHeight();break;case"down":e="-"+t.outerHeight()}return{posX:i,posY:e}},_reverseItems:function(){if(this.$currentItem===this.$lastItem)return!1;var t=this.$currentItem,i=this.$lastItem;this.$currentItem=i,this.$lastItem=t,this.$currentItem.removeClass("ditty-item--last").addClass("ditty-item--current"),this.$lastItem.removeClass("ditty-item--current").addClass("ditty-item--last");var e=this.$items.children(".ditty-item");this.$items.append(e.get().reverse())},_resetItems:function(){this.$items.empty(),this.visibleItems=[],this.trigger("active_items_update")},_fillTicker:function(){var t=this,i=parseFloat(this.$items.outerWidth()),e=parseFloat(this.$items.outerHeight()),s=0,n=0,r=!1,h=this.settings.item,o=null;this._isItemEnabled(h)||(h=this._getNextItem(h)),"right"===this.settings.direction?s=i:"down"===this.settings.direction&&(n=e),o=setInterval((function(){var a=t._initializeItem(h);if(a){var l=t._filledItemInit(h,a,s,n,i,e);s=l.posX,n=l.posY,r=l.filled,h=t._getNextItem(h)}else r=!0;r&&(clearInterval(o),t.trigger("active_items_update"),setTimeout((function(){t.running||t._timerStart()}),1e3*parseFloat(t.settings.scrollDelay)))}),100)},_filledItemInit:function(t,i,e,s,n,r){var h=i.data("id"),o=parseFloat(i.outerWidth()),a=parseFloat(i.outerHeight()),l=0,d=0,m=!1;switch(i.css({display:"block",opacity:0}),this.settings.direction){case"left":l=e,this._itemSetTransform(i,{posX:l,posY:s}),(e+=o)>n&&(m=!0);break;case"right":l=e-=o,this._itemSetTransform(i,{posX:l,posY:s}),e<0&&(m=!0);break;case"up":d=s,this._itemSetTransform(i,{posX:e,posY:d}),(s+=a)>r&&(m=!0);break;case"down":d=s-=a,this._itemSetTransform(i,{posX:e,posY:d}),s<0&&(m=!0)}return i.stop().animate({opacity:1},1e3,"linear",(function(){})),this.visibleItems.push({$item:i,itemId:h,posX:l,posY:d}),this._setCurrentHeight(),{posX:e,posY:s,filled:m}},_setDirection:function(t){return!!$.inArray(t,this.settings.directions)&&(t!==this.settings.directions&&(this.settings.direction=t,this._timerStop(),this._resetItems(),this.settings.item=0,this._initializeItems(),void this.trigger("direction")))},_styleDisplay:function(){if(this.$elmt.css({maxWidth:this.settings.maxWidth,backgroundColor:this.settings.bgColor,borderColor:this.settings.borderColor,borderStyle:this.settings.borderStyle}),this.$elmt.css(this.settings.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.minHeight?this.settings.minHeight:0,i=this.settings.maxHeight?this.settings.maxHeight:"none";this.$items.css({minHeight:t,maxHeight:i})}else this.$items.css({minHeight:"",maxHeight:""})},_styleTitle:function(){if(this.$elmt.attr("data-title",this.settings.titleDisplay),this.$elmt.attr("data-title_position",this.settings.titleElementPosition),"none"===this.settings.titleDisplay)this.$title.remove();else{var t=$("<"+this.settings.titleElement+' class="ditty-ticker__title__element">'+this.settings.title+"</"+this.settings.titleElement+">");t.css({fontSize:this.settings.titleFontSize,lineHeight:this.settings.titleLineHeight,color:this.settings.titleColor,margin:0,padding:0}),this.$title.css({backgroundColor:this.settings.titleBgColor,borderColor:this.settings.titleBorderColor,borderStyle:this.settings.titleBorderStyle}),this.$title.css(this.settings.titleMargin),this.$title.css(this.settings.titlePadding),this.$title.css(this.settings.titleBorderRadius),this.$title.css(this.settings.titleBorderWidth),this.$titleContents.html(t),this.$elmt.prepend(this.$title)}},_styleItem:function(t){t.children(".ditty-item__elements").css({color:this.settings.itemTextColor,backgroundColor:this.settings.itemBgColor,borderColor:this.settings.itemBorderColor,borderStyle:this.settings.itemBorderStyle}),t.children(".ditty-item__elements").css(this.settings.itemPadding),t.children(".ditty-item__elements").css(this.settings.itemBorderRadius),t.children(".ditty-item__elements").css(this.settings.itemBorderWidth),""!==this.settings.itemElementsWrap&&t.children(".ditty-item__elements").css({whiteSpace:this.settings.itemElementsWrap}),""!==this.settings.itemMaxWidth&&t.children(".ditty-item__elements").css({maxWidth:this.settings.itemMaxWidth})},_getOption:function(t){switch(t){case"ditty":return this;case"type":return this.displayType;case"display":return this.settings.display;case"items":return this.settings.items;case"height":return this.currentHeight;default:return this.settings[t]}},_setOption:function(t,i){if(void 0===i)return!1;switch(t){case"items":this.updateItems(i);break;case"direction":this.settings[t]=i,this._styleDisplay(),this._setDirection(i);break;case"titleDisplay":case"titleElement":case"titleElementPosition":case"titleFontSize":case"titleLineHeight":case"titleColor":case"titleBgColor":case"titleMargin":case"titlePadding":case"titleBorderColor":case"titleBorderStyle":case"titleBorderWidth":case"titleBorderRadius":this.settings[t]=i,this._styleTitle();break;case"minHeight":case"maxHeight":case"bgColor":case"padding":case"borderColor":case"borderStyle":case"borderWidth":case"borderRadius":case"contentsBgColor":case"contentsPadding":case"contentsBorderRadius":this.settings[t]=i,this._styleDisplay(),this._setCurrentHeight();break;default:this.settings[t]=i}this.trigger("update")},shuffle:function(){for(var t,i,e=this.total-1;e>0;e--)i=Math.floor(Math.random()*(e+1)),t=this.settings.items[e],this.settings.items[e]=this.settings.items[i],this.settings.items[i]=t},play:function(){this.running||this._timerStart()},pause:function(){this.running&&this._timerStop()},direction:function(t){this._setDirection(t)},toggle:function(){this.running?this.pause():this.play()},running:function(){return this.running},current:function(){return this.$currentItem},_isItemEnabled:function(t){return void 0!==this.settings.items[parseInt(t)]&&(void 0===this.settings.items[parseInt(t)].is_disabled||!(this.settings.items[parseInt(t)].is_disabled.length>0))},_disabledItemsStatus:function(){var t=this,i={};return $.each(this.settings.items,(function(e,s){t._isItemEnabled(e)?i[s.id]="enabled":i[s.id]="disabled"})),i},addItemDisabled:function(t,i){var e=this;$.each(this.settings.items,(function(s,n){String(n.id)===String(t)&&($.isArray(e.settings.items[s].is_disabled)||(e.settings.items[s].is_disabled=[]),e.settings.items[s].is_disabled.push(i))})),this.trigger("disabled_items_update")},removeItemDisabled:function(t,i){var e=this;$.each(this.settings.items,(function(s,n){String(n.id)===String(t)&&$.isArray(e.settings.items[s].is_disabled)&&e.settings.items[s].is_disabled.length&&(e.settings.items[s].is_disabled=$.grep(e.settings.items[s].is_disabled,(function(t){return t!==i})))})),this.trigger("disabled_items_update")},showItem:function(t){var i=[];if($.each(this.settings.items,(function(e,s){String(s.id)===String(t)&&i.push(e)})),0!==i.length)return this.nextItem=i[0],this.nextItem},addItem:function(t,i,e){var s=this.settings.items.slice(),n=!0;(i>=this.total||i<0)&&(n=!1),"replace"===e&&n?s.splice(i,1,t):null===i||""===i?s.splice(this.nextItem,0,t):i>=this.total?s.push(t):i<0?s.splice(0,0,t):s.splice(i,0,t),this.updateItems(s)},deleteItem:function(t){var i=[];$.each(this.settings.items,(function(e,s){String(s.id)!==String(t)&&i.push(s)})),this.updateItems(i)},updateItems:function(t,i,e,s){if(void 0===t)return!1;var n=[];if(i){var r=this.settings.items.slice(),h=[],o=!1;$.each(r,(function(s,r){String(r.id)===String(i)?"after"===e?(h.push(r),$.each(t,(function(t,i){h.push(i)})),o=!0):"before"===e?($.each(t,(function(t,i){h.push(i)})),h.push(r),o=!0):o||($.each(t,(function(t,i){h.push(i),n.push(String(i.uniq_id))})),o=!0):h.push(r)})),o||($.each(this.settings.items,(function(t,i){h.push(i)})),o=!0),0!==this.total&&(t=h)}this.settings.items=t,this.total=t.length,0===this.total?this.hide():this.show(),this.nextItem>=this.total&&(this.nextItem=0),this.trigger("update")},getActiveItems:function(){var t=[];return $.each(this.visibleItems,(function(i,e){t.push({id:e.itemId})})),t},hide:function(){this.$elmt.hide(),this.pause()},show:function(){this.$elmt.show(),this.play()},trigger:function(t){var i=[];switch(t){case"active_items_update":i=[this,this.getActiveItems()];break;case"disabled_items_update":i=[this._disabledItemsStatus()];break;case"height_updated":i=[this.currentHeight,this.$elmt];break;case"start_live_updates":i=[this.settings.id];break;default:i=[this.settings,this.$elmt]}this.$elmt.trigger("ditty_"+t,i),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,i),$("body").trigger("ditty_"+t,i)},options:function(t,i){var e=this;if("object"==typeof t)$.each(t,(function(t,i){e._setOption(t,i)}));else{if("string"!=typeof t)return e.settings;if(void 0===i)return e._getOption(t);e._setOption(t,i)}},destroy:function(){this.$elmt.off("mouseenter",{self:this},this._mouseenter),this.$elmt.off("mouseleave",{self:this},this._mouseleave),cancelAnimationFrame(this.interval),this.$elmt.removeClass("ditty ditty-ticker"),this.$elmt.removeAttr("data-id"),this.$elmt.removeAttr("data-type"),this.$elmt.removeAttr("data-display"),this.$elmt.removeAttr("style"),this.$elmt.empty(),this.elmt._ditty_ticker=null}},$.fn.ditty_ticker=function(t){var e,s=arguments,n=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_ticker||(this._ditty_ticker=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_ticker;if(!i)throw new Error("No Ditty_Ticker applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):n=!0})),n)throw new Error('No method "'+t+'" in Ditty_Ticker.');return void 0!==e?e:this}},$.ditty_ticker={},$.ditty_ticker.defaults=t}(jQuery);
|
1 |
+
!function($){"use strict";var t={id:0,title:"",display:0,status:"",direction:"left",spacing:20,speed:10,cloneItems:"yes",hoverPause:0,height:null,minHeight:null,maxHeight:null,heightEase:"easeInOutQuint",heightSpeed:1.5,scrollInit:"empty",scrollDelay:2,maxWidth:"",bgColor:"",padding:{},margin:{},borderColor:{},borderStyle:{},borderWidth:{},borderRadius:{},contentsBgColor:"",contentsPadding:{},contentsBorderColor:{},contentsBorderStyle:{},contentsBorderWidth:{},contentsBorderRadius:{},titleDisplay:"none",titleElement:"h3",titleElementPosition:"topLeft",titleFontSize:"",titleLineHeight:"",titleColor:"",titleBgColor:"",titleMargin:{},titlePadding:{},titleBorderColor:{},titleBorderStyle:{},titleBorderWidth:{},titleBorderRadius:{},itemTextColor:"",itemBgColor:"",itemBorderColor:{},itemBorderStyle:{},itemBorderWidth:{},itemBorderRadius:{},itemPadding:{},itemMaxWidth:"",itemElementsWrap:"wrap",item:0,shuffle:0,showEditor:0,items:[]},i=function(i,e){this.displayType="ticker",this.elmt=i,this.settings=$.extend({},t,$.ditty_ticker.defaults,e),this.nextItem=null,this.total=this.settings.items.length,this.$elmt=$(i),this.$title=null,this.$titleContents=null,this.$contents=null,this.$items=null,this.$currentItem=null,this.$lastItem=null,this.scrollPercent=.13,this.running=!1,this.interval=!1,this.currentHeight=this.settings.height,this.visibleItems=[],1===parseInt(this.settings.shuffle)&&this.shuffle(),this._init()};i.prototype={_init:function(){var t,i,e=this;0===this.total&&this.hide(),this.$elmt.removeClass("ditty--pre"),this.$elmt.addClass("ditty ditty-ticker"),this.$elmt.attr("data-id",this.settings.id),this.$elmt.attr("data-type",this.displayType),this.$elmt.attr("data-display",this.settings.display),t=$('<div class="ditty-ticker__contents"></div>'),this.$contents=t,this.$title=$('<div class="ditty-ticker__title"></div>'),this.$titleContents=$('<div class="ditty-ticker__title__contents"></div>'),this.$title.append(this.$titleContents),i=$('<div class="ditty-ticker__items"></div>'),this.$items=i,this.$items.height(this.currentHeight),t.append(i),this.$elmt.append(t),this._styleDisplay(),this._styleTitle(),this.$elmt.on("mouseenter",{self:this},this._mouseenter),this.$elmt.on("mouseleave",{self:this},this._mouseleave),this.settings.showEditor?dittyEditorInit(this):this.trigger("start_live_updates"),setTimeout((function(){for(var t=0;t<e.total;t++)e._preloadItem(e.settings.items[t]);e._initializeItems(),e.trigger("init")}),1)},_initializeItems:function(){"filled"===this.settings.scrollInit?this._fillTicker():this.running||this._timerStart()},_preloadItem:function(t){$(t.html).find("img").each((function(){(new Image).src=$(this).attr("src")}))},_positionItems:function(t){var i=this;if(0===i.visibleItems.length){var e=i.settings.item;this._isItemEnabled(e)||(e=this._getNextItem(e)),i._initializeItem(e)}$.each(i.visibleItems,(function(e,s){if(s){var n=i.visibleItems[e].$item,r=i._calculateItemPosition(e,t);i.visibleItems[e].posX=r.posX,i.visibleItems[e].posY=r.posY,i._itemSetTransform(n,r),i._newItemShouldStart(n,r)&&i._initializeItem(parseInt(i.nextItem)),i._itemShouldTerminate(n,r)&&i._terminateItem(e)}}))},_timerStart:function(){var t=this;this.running=!0,this.trigger("start"),cancelAnimationFrame(this.interval),t.interval=requestAnimationFrame((function i(){t._positionItems(),t.interval=requestAnimationFrame(i)}))},_timerStop:function(){cancelAnimationFrame(this.interval),this.running=!1,this.trigger("stop")},_mouseenter:function(t){var i=t.data.self;i.settings.hoverPause&&i._timerStop()},_mouseleave:function(t){var i=t.data.self;i.settings.hoverPause&&i._timerStart()},_newItemShouldStart:function(t,i){if(this.$currentItem[0]!==t[0])return!1;var e=!1;switch(this.settings.direction){case"left":i.posX<=this.$items.outerWidth()-t.outerWidth()&&(e=!0);break;case"right":i.posX>=0&&(e=!0);break;case"down":i.posY>=0&&(e=!0);break;case"up":i.posY<=this.$items.outerHeight()-t.outerHeight()&&(e=!0)}return e},_initializeItem:function(t,i){if(void 0===this.settings.items[t])return!1;var e=this.$items.children(".ditty-item--"+this.settings.items[t].uniq_id);if("yes"!==this.settings.cloneItems&&e.length)return!1;var s=$(this.settings.items[t].html);if(s.css({top:0,left:0}),this.$items.children(".ditty-item--"+this.settings.items[t].id).not(".ditty-item--clone").length>0&&s.addClass("ditty-item--clone"),this._styleItem(s),this.settings.items[t].css&&dittyLayoutCss(this.settings.items[t].css,this.settings.items[t].layout_id),this._itemSpacing(s),this._itemSetTransform(s,this._itemResetPosition(s)),this.$items.append(s),s.css({display:"block",top:0,left:0,opacity:1}),s.addClass("ditty-item--current"),null!==this.$currentItem&&this.$currentItem.removeClass("ditty-item--current"),this.$currentItem=s,null===this.$lastItem&&(s.addClass("ditty-item--last"),this.$lastItem=s),this.settings.item=t,this.nextItem=this._getNextItem(t),"custom"!==i){var n=this._itemResetPosition(s);this._itemSetTransform(s,n),this.visibleItems.push({$item:s,itemId:this.settings.items[t].id,posX:n.posX,posY:n.posY}),this._setCurrentHeight()}return this.trigger("active_items_update"),s},_getNextItem:function(t){var i,e=this,s=!1;if(null!==this.nextItem&&t!==this.nextItem){var n=parseInt(this.nextItem);n<this.total&&n>=0&&e._isItemEnabled(n)&&(s=parseInt(this.nextItem))}if(!s)for(i=t;i<this.total;i++)if(i!==t&&e._isItemEnabled(i)){s=parseInt(i);break}if(!s)for(i=0;i<this.total;i++)if(e._isItemEnabled(i)){s=parseInt(i);break}return s},_itemShouldTerminate:function(t,i){var e=!1;switch(this.settings.direction){case"left":i.posX<-t.outerWidth()&&(e=!0);break;case"right":i.posX>this.$items.outerWidth()&&(e=!0);break;case"up":i.posY<-t.outerHeight()&&(e=!0);break;case"down":i.posY>this.$items.outerHeight()&&(e=!0)}return e},_terminateItem:function(t){var i=this.visibleItems[t].$item,e=i.next();i.remove(),this.visibleItems.splice(t,1),e.length&&(e.addClass("ditty-item--last"),this.$lastItem=e),this._setCurrentHeight(),this.trigger("active_items_update")},_setCurrentHeight:function(){var t=this.currentHeight;"up"===this.settings.direction||"down"===this.settings.direction?(t=this.$items.outerHeight(),this.$items.css({height:"100%"})):(t=0,$.each(this.visibleItems,(function(i,e){var s=e.$item.outerHeight();s>t&&(t=s)})),t!==this.currentHeight&&this.$items.stop().animate({height:t+"px"},1e3*parseFloat(this.settings.heightSpeed),this.settings.heightEase,(function(){}))),t!==this.currentHeight&&(this.currentHeight=t,this.trigger("height_updated"))},_itemSpacing:function(t){switch(this.settings.direction){case"left":case"right":t.css({paddingLeft:this.settings.spacing/2+"px",paddingRight:this.settings.spacing/2+"px",paddingTop:0,paddingBottom:0});break;case"up":case"down":t.css({paddingLeft:0,paddingRight:0,paddingTop:this.settings.spacing/2+"px",paddingBottom:this.settings.spacing/2+"px"})}},_itemSetTransform:function(t,i){var e=i.posX,s=i.posY;0!==e&&(e+="px"),0!==s&&(s+="px"),t.css({transform:"translate( "+e+", "+s+" )"})},_calculateItemPosition:function(t,i){var e=0,s=0,n=parseFloat(this.settings.speed)*this.scrollPercent;switch(i&&(n=i),this.settings.direction){case"left":e=parseFloat(this.visibleItems[t].posX)-n;break;case"right":e=parseFloat(this.visibleItems[t].posX)+n;break;case"up":s=parseFloat(this.visibleItems[t].posY)-n;break;case"down":s=parseFloat(this.visibleItems[t].posY)+n}return{posX:e,posY:s}},_itemResetPosition:function(t){var i=0,e=0;switch(this.settings.direction){case"left":i=this.$items.outerWidth();break;case"right":i="-"+t.outerWidth();break;case"up":e=this.$items.outerHeight();break;case"down":e="-"+t.outerHeight()}return{posX:i,posY:e}},_reverseItems:function(){if(this.$currentItem===this.$lastItem)return!1;var t=this.$currentItem,i=this.$lastItem;this.$currentItem=i,this.$lastItem=t,this.$currentItem.removeClass("ditty-item--last").addClass("ditty-item--current"),this.$lastItem.removeClass("ditty-item--current").addClass("ditty-item--last");var e=this.$items.children(".ditty-item");this.$items.append(e.get().reverse())},_resetItems:function(){this.$items.empty(),this.visibleItems=[],this.trigger("active_items_update")},_fillTicker:function(){var t=this,i=parseFloat(this.$items.outerWidth()),e=parseFloat(this.$items.outerHeight()),s=0,n=0,r=!1,h=this.settings.item,o=null;this._isItemEnabled(h)||(h=this._getNextItem(h)),"right"===this.settings.direction?s=i:"down"===this.settings.direction&&(n=e),o=setInterval((function(){var a=t._initializeItem(h);if(a){var l=t._filledItemInit(h,a,s,n,i,e);s=l.posX,n=l.posY,r=l.filled,h=t._getNextItem(h)}else r=!0;r&&(clearInterval(o),t.trigger("active_items_update"),setTimeout((function(){t.running||t._timerStart()}),1e3*parseFloat(t.settings.scrollDelay)))}),100)},_filledItemInit:function(t,i,e,s,n,r){var h=i.data("id"),o=parseFloat(i.outerWidth()),a=parseFloat(i.outerHeight()),l=0,d=0,m=!1;switch(i.css({display:"block",opacity:0}),this.settings.direction){case"left":l=e,this._itemSetTransform(i,{posX:l,posY:s}),(e+=o)>n&&(m=!0);break;case"right":l=e-=o,this._itemSetTransform(i,{posX:l,posY:s}),e<0&&(m=!0);break;case"up":d=s,this._itemSetTransform(i,{posX:e,posY:d}),(s+=a)>r&&(m=!0);break;case"down":d=s-=a,this._itemSetTransform(i,{posX:e,posY:d}),s<0&&(m=!0)}return i.stop().animate({opacity:1},1e3,"linear",(function(){})),this.visibleItems.push({$item:i,itemId:h,posX:l,posY:d}),this._setCurrentHeight(),{posX:e,posY:s,filled:m}},_setDirection:function(t){return!!$.inArray(t,this.settings.directions)&&(t!==this.settings.directions&&(this.settings.direction=t,this._timerStop(),this._resetItems(),this.settings.item=0,this._initializeItems(),void this.trigger("direction")))},_styleDisplay:function(){if(this.$elmt.css({maxWidth:this.settings.maxWidth,backgroundColor:this.settings.bgColor,borderColor:this.settings.borderColor,borderStyle:this.settings.borderStyle}),this.$elmt.css(this.settings.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.minHeight?this.settings.minHeight:0,i=this.settings.maxHeight?this.settings.maxHeight:"none";this.$items.css({minHeight:t,maxHeight:i})}else this.$items.css({minHeight:"",maxHeight:""})},_styleTitle:function(){if(this.$elmt.attr("data-title",this.settings.titleDisplay),this.$elmt.attr("data-title_position",this.settings.titleElementPosition),"none"===this.settings.titleDisplay)this.$title.remove();else{var t=$("<"+this.settings.titleElement+' class="ditty-ticker__title__element">'+this.settings.title+"</"+this.settings.titleElement+">");t.css({fontSize:this.settings.titleFontSize,lineHeight:this.settings.titleLineHeight,color:this.settings.titleColor,margin:0,padding:0}),this.$title.css({backgroundColor:this.settings.titleBgColor,borderColor:this.settings.titleBorderColor,borderStyle:this.settings.titleBorderStyle}),this.$title.css(this.settings.titleMargin),this.$title.css(this.settings.titlePadding),this.$title.css(this.settings.titleBorderRadius),this.$title.css(this.settings.titleBorderWidth),this.$titleContents.html(t),this.$elmt.prepend(this.$title)}},_styleItem:function(t){t.children(".ditty-item__elements").css({color:this.settings.itemTextColor,backgroundColor:this.settings.itemBgColor,borderColor:this.settings.itemBorderColor,borderStyle:this.settings.itemBorderStyle}),t.children(".ditty-item__elements").css(this.settings.itemPadding),t.children(".ditty-item__elements").css(this.settings.itemBorderRadius),t.children(".ditty-item__elements").css(this.settings.itemBorderWidth),""!==this.settings.itemElementsWrap&&t.children(".ditty-item__elements").css({whiteSpace:this.settings.itemElementsWrap}),""!==this.settings.itemMaxWidth&&t.children(".ditty-item__elements").css({maxWidth:this.settings.itemMaxWidth})},_getOption:function(t){switch(t){case"ditty":return this;case"type":return this.displayType;case"display":return this.settings.display;case"items":return this.settings.items;case"height":return this.currentHeight;default:return this.settings[t]}},_setOption:function(t,i){if(void 0===i)return!1;switch(t){case"items":this.updateItems(i);break;case"direction":this.settings[t]=i,this._styleDisplay(),this._setDirection(i);break;case"titleDisplay":case"titleElement":case"titleElementPosition":case"titleFontSize":case"titleLineHeight":case"titleColor":case"titleBgColor":case"titleMargin":case"titlePadding":case"titleBorderColor":case"titleBorderStyle":case"titleBorderWidth":case"titleBorderRadius":this.settings[t]=i,this._styleTitle();break;case"minHeight":case"maxHeight":case"bgColor":case"padding":case"borderColor":case"borderStyle":case"borderWidth":case"borderRadius":case"contentsBgColor":case"contentsPadding":case"contentsBorderRadius":this.settings[t]=i,this._styleDisplay(),this._setCurrentHeight();break;default:this.settings[t]=i}this.trigger("update")},shuffle:function(){for(var t,i,e=this.total-1;e>0;e--)i=Math.floor(Math.random()*(e+1)),t=this.settings.items[e],this.settings.items[e]=this.settings.items[i],this.settings.items[i]=t},play:function(){this.running||this._timerStart()},pause:function(){this.running&&this._timerStop()},direction:function(t){this._setDirection(t)},toggle:function(){this.running?this.pause():this.play()},running:function(){return this.running},current:function(){return this.$currentItem},_isItemEnabled:function(t){return void 0!==this.settings.items[parseInt(t)]&&(void 0===this.settings.items[parseInt(t)].is_disabled||!(this.settings.items[parseInt(t)].is_disabled.length>0))},_disabledItemsStatus:function(){var t=this,i={};return $.each(this.settings.items,(function(e,s){t._isItemEnabled(e)?i[s.id]="enabled":i[s.id]="disabled"})),i},addItemDisabled:function(t,i){var e=this;$.each(this.settings.items,(function(s,n){String(n.id)===String(t)&&($.isArray(e.settings.items[s].is_disabled)||(e.settings.items[s].is_disabled=[]),e.settings.items[s].is_disabled.push(i))})),this.trigger("disabled_items_update")},removeItemDisabled:function(t,i){var e=this;$.each(this.settings.items,(function(s,n){String(n.id)===String(t)&&$.isArray(e.settings.items[s].is_disabled)&&e.settings.items[s].is_disabled.length&&(e.settings.items[s].is_disabled=$.grep(e.settings.items[s].is_disabled,(function(t){return t!==i})))})),this.trigger("disabled_items_update")},showItem:function(t){var i=[];if($.each(this.settings.items,(function(e,s){String(s.id)===String(t)&&i.push(e)})),0!==i.length)return this.nextItem=i[0],this.nextItem},addItem:function(t,i,e){var s=this.settings.items.slice(),n=!0;(i>=this.total||i<0)&&(n=!1),"replace"===e&&n?s.splice(i,1,t):null===i||""===i?s.splice(this.nextItem,0,t):i>=this.total?s.push(t):i<0?s.splice(0,0,t):s.splice(i,0,t),this.updateItems(s)},deleteItem:function(t){var i=[];$.each(this.settings.items,(function(e,s){String(s.id)!==String(t)&&i.push(s)})),this.updateItems(i)},updateItems:function(t,i,e,s){if(void 0===t)return!1;var n=[];if(i){var r=this.settings.items.slice(),h=[],o=!1;$.each(r,(function(s,r){String(r.id)===String(i)?"after"===e?(h.push(r),$.each(t,(function(t,i){h.push(i)})),o=!0):"before"===e?($.each(t,(function(t,i){h.push(i)})),h.push(r),o=!0):o||($.each(t,(function(t,i){h.push(i),n.push(String(i.uniq_id))})),o=!0):h.push(r)})),o||($.each(this.settings.items,(function(t,i){h.push(i)})),o=!0),0!==this.total&&(t=h)}this.settings.items=t,this.total=t.length,0===this.total?this.hide():this.show(),this.nextItem>=this.total&&(this.nextItem=0),this.trigger("update")},getActiveItems:function(){var t=[];return $.each(this.visibleItems,(function(i,e){t.push({id:e.itemId})})),t},hide:function(){this.$elmt.hide(),this.pause()},show:function(){this.$elmt.show(),this.play()},trigger:function(t){var i=[];switch(t){case"active_items_update":i=[this,this.getActiveItems()];break;case"disabled_items_update":i=[this._disabledItemsStatus()];break;case"height_updated":i=[this.currentHeight,this.$elmt];break;case"start_live_updates":i=[this.settings.id];break;default:i=[this.settings,this.$elmt]}this.$elmt.trigger("ditty_"+t,i),"function"==typeof this.settings[t]&&this.settings[t].apply(this.$elmt,i),$("body").trigger("ditty_"+t,i)},options:function(t,i){var e=this;if("object"==typeof t)$.each(t,(function(t,i){e._setOption(t,i)}));else{if("string"!=typeof t)return e.settings;if(void 0===i)return e._getOption(t);e._setOption(t,i)}},destroy:function(){this.$elmt.off("mouseenter",{self:this},this._mouseenter),this.$elmt.off("mouseleave",{self:this},this._mouseleave),cancelAnimationFrame(this.interval),this.$elmt.removeClass("ditty ditty-ticker"),this.$elmt.removeAttr("data-id"),this.$elmt.removeAttr("data-type"),this.$elmt.removeAttr("data-display"),this.$elmt.removeAttr("style"),this.$elmt.empty(),this.elmt._ditty_ticker=null}},$.fn.ditty_ticker=function(t){var e,s=arguments,n=!1;if(void 0===t||"object"==typeof t)return this.each((function(){this._ditty_ticker||(this._ditty_ticker=new i(this,t))}));if("string"==typeof t){if(this.each((function(){var i=this._ditty_ticker;if(!i)throw new Error("No Ditty_Ticker applied to this element.");"function"==typeof i[t]&&"_"!==t[0]?e=i[t].apply(i,[].slice.call(s,1)):n=!0})),n)throw new Error('No method "'+t+'" in Ditty_Ticker.');return void 0!==e?e:this}},$.ditty_ticker={},$.ditty_ticker.defaults=t}(jQuery);
|
includes/upgrades.php
CHANGED
@@ -18,8 +18,8 @@ function ditty_updates() {
|
|
18 |
if ( version_compare( $current_version, '3.0.6', '<' ) ) {
|
19 |
ditty_v3_0_6_upgrades();
|
20 |
}
|
21 |
-
if ( version_compare( $current_version, '3.0.
|
22 |
-
|
23 |
}
|
24 |
|
25 |
if ( DITTY_VERSION != $current_version ) {
|
@@ -35,7 +35,7 @@ add_action( 'admin_init', 'ditty_updates' );
|
|
35 |
* @since 3.0.13
|
36 |
* @return void
|
37 |
*/
|
38 |
-
function
|
39 |
|
40 |
// Update the database
|
41 |
$db_items = new Ditty_DB_Items();
|
18 |
if ( version_compare( $current_version, '3.0.6', '<' ) ) {
|
19 |
ditty_v3_0_6_upgrades();
|
20 |
}
|
21 |
+
if ( version_compare( $current_version, '3.0.14', '<' ) ) {
|
22 |
+
ditty_v3_0_14_upgrades();
|
23 |
}
|
24 |
|
25 |
if ( DITTY_VERSION != $current_version ) {
|
35 |
* @since 3.0.13
|
36 |
* @return void
|
37 |
*/
|
38 |
+
function ditty_v3_0_14_upgrades() {
|
39 |
|
40 |
// Update the database
|
41 |
$db_items = new Ditty_DB_Items();
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: ticker, post ticker, news ticker, content aggregator, latest posts, live refresh, rotator, data rotator, lists, data, aggregator
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 5.9
|
7 |
-
Stable tag: 3.0.
|
8 |
License: GPL2
|
9 |
|
10 |
Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
|
@@ -66,6 +66,9 @@ The most common cause for an unresponsive Ditty (when using scroll or rotate mod
|
|
66 |
|
67 |
== Changelog ==
|
68 |
|
|
|
|
|
|
|
69 |
= 3.0.13 =
|
70 |
* Added Ditty Wizard (Beta)
|
71 |
* Ditty settings page updates
|
4 |
Tags: ticker, post ticker, news ticker, content aggregator, latest posts, live refresh, rotator, data rotator, lists, data, aggregator
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 5.9
|
7 |
+
Stable tag: 3.0.14
|
8 |
License: GPL2
|
9 |
|
10 |
Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
|
66 |
|
67 |
== Changelog ==
|
68 |
|
69 |
+
= 3.0.14 =
|
70 |
+
* Ticker cloneItems bug fix
|
71 |
+
|
72 |
= 3.0.13 =
|
73 |
* Added Ditty Wizard (Beta)
|
74 |
* Ditty settings page updates
|