var tdCategoriesTagsLoadMore={};jQuery().ready(function(){tdCategoriesTagsLoadMore.init()});
(function(){tdCategoriesTagsLoadMore={items:[],item:function(){this.blockObj=this.uid="";this._is_ended=this._is_loading=this._is_initialized=!1},init:function(){tdCategoriesTagsLoadMore.items=[];this._is_running=!1},addItem:function(a){if("undefined"===typeof a.uid)throw"item.uid is not defined";if("undefined"!==typeof a.blockObj&&a.blockObj&&a.blockObj.length){for(var b=0;b<tdCategoriesTagsLoadMore.items.length;b++)if(tdCategoriesTagsLoadMore.items[b].uid===a.uid)return;tdCategoriesTagsLoadMore.items.push(a);
tdCategoriesTagsLoadMore._initialize_item(a)}},deleteItem:function(a){for(var b=0;b<tdCategoriesTagsLoadMore.items.length;b++)if(tdCategoriesTagsLoadMore.items[b].uid===a)return tdCategoriesTagsLoadMore.items.splice(b,1),!0;return!1},resetItems:function(){tdCategoriesTagsLoadMore.items=[]},do_ajax_call:function(a,b,d){var c=tdCategoriesTagsLoadMore._build_payload(b);"undefined"!==typeof td_ajax_url&&td_ajax_url?jQuery.ajax({type:"POST",url:td_ajax_url,data:c,success:function(e){tdCategoriesTagsLoadMore.process_ajax_response(a,
b,d,e,c)},error:function(){},complete:function(){a._is_loading=!1;d.removeClass("is-loading").prop("disabled",!1)}}):(a._is_ended=!0,d.hide())},process_ajax_response:function(a,b,d,c,e){if("string"===typeof c)try{c=JSON.parse(c)}catch(g){c=null}if(c&&"undefined"!==typeof c.td_data){c.td_data&&b.append(c.td_data);e=e.offset+e.limit;if("undefined"!==typeof c.td_next_offset&&null!==c.td_next_offset){var f=parseInt(c.td_next_offset,10);isNaN(f)||(e=f)}b.attr("data-td-ct-offset",String(e));"undefined"===
typeof c.td_has_more||!1!==c.td_has_more&&"0"!==c.td_has_more&&0!==c.td_has_more||(a._is_ended=!0,d.hide())}else a._is_ended=!0,d.hide()},_build_payload:function(a){var b=parseInt(a.attr("data-td-ct-limit"),10);if(isNaN(b)||0>=b)b=6;var d=parseInt(a.attr("data-td-ct-offset"),10);if(isNaN(d)||0>d)d=b;return{action:"td_ct_load_more",nonce:a.attr("data-td-ct-nonce")||"",limit:b,offset:d,orderby:a.attr("data-td-ct-orderby")||"name",order:a.attr("data-td-ct-order")||"ASC",include:a.attr("data-td-ct-include")||
"",exclude:a.attr("data-td-ct-exclude")||"",type:a.attr("data-td-ct-type")||"",custom_tax:a.attr("data-td-ct-custom-tax")||"",show_count:a.attr("data-td-ct-show-count")||"",show_inline:a.attr("data-td-ct-show-inline")||"",sep_text:a.attr("data-td-ct-sep-text")||"",tdicon:a.attr("data-td-ct-tdicon")||""}},_initialize_item:function(a){if(!0!==a._is_initialized){var b=a.blockObj,d=b.find(".td-ct-wrap").first(),c=b.find(".td-ct-load-more").first();if(d.length&&c.length)c.off("click.tdCtLoadMore").on("click.tdCtLoadMore",
function(b){b.preventDefault();a._is_loading||a._is_ended||(a._is_loading=!0,c.addClass("is-loading").prop("disabled",!0),tdCategoriesTagsLoadMore.do_ajax_call(a,d,c))});a._is_initialized=!0}}}})();
