diff -r d255fe9cd479 -r 00ac8f60d73f wp/wp-content/plugins/codecanyon-3027163-content-timeline-responsive-wordpress-plugin/js/ctimeline_admin.js --- a/wp/wp-content/plugins/codecanyon-3027163-content-timeline-responsive-wordpress-plugin/js/ctimeline_admin.js Tue Oct 15 15:48:13 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,509 +0,0 @@ -(function($){ -$(document).ready(function(){ - - // COLORPICKER - var colPickerOn = false, - colPickerShow = false, - pluginUrl = $('#plugin-url').val(), - timthumb = pluginUrl + 'timthumb/timthumb.php'; - // colorpicker field - $('.cw-color-picker').each(function(){ - var $this = $(this), - id = $this.attr('rel'); - - $this.farbtastic('#' + id); - $this.click(function(){ - $this.show(); - }); - $('#' + id).click(function(){ - $('.cw-color-picker:visible').hide(); - $('#' + id + '-picker').show(); - colPickerOn = true; - colPickerShow = true; - }); - $this.click(function(){ - colPickerShow = true; - }); - - }); - $('body').click(function(){ - if(colPickerShow) colPickerShow = false; - else { - colPickerOn = false; - $('.cw-color-picker:visible').hide(); - } - }); - - // IMAGE UPLOAD - var thickboxId = '', - thickItem = false; - - // backgorund images - $('.cw-image-upload').click(function(e) { - e.preventDefault(); - thickboxId = '#' + $(this).attr('id'); - formfield = $(thickboxId + '-input').attr('name'); - tb_show('', 'media-upload.php?type=image&TB_iframe=true'); - return false; - }); - - - window.send_to_editor = function(html) { - imgurl = $('img',html).attr('src'); - $(thickboxId + '-input').val(imgurl); - if (thickItem) { - thickItem = false; - $(thickboxId).attr('src', timthumb + '?src=' + imgurl + '&w=258&h=50'); - } - else { - $(thickboxId).css('background', 'url('+imgurl+') repeat'); - } - tb_remove(); - } - - $('.remove-image').click(function(e){ - e.preventDefault(); - $(this).parent().parent().find('input').val(''); - $(this).parent().parent().find('.cw-image-upload').css('background-image', 'url(' + pluginUrl + '/images/no_image.jpg)'); - }); - - // CATEGORIES - if ($('#cat-type').val() == 'categories') { - $('.cat-display').show(); - $('.data_id').css('color', 'gray'); - } - else { - $('.category_id').css('color', 'gray'); - } - $('#cat-type').change(function(){ - if ($(this).val() == 'months') { - $('.cat-display').hide(); - $('.category_id').css('color', 'gray'); - $('.data_id').css('color', ''); - alert('Check the Date field of your items before you save!'); - } - else { - $('.cat-display').show(); - $('.data_id').css('color', 'gray'); - $('.category_id').css('color', ''); - alert('Check the Category field of your items, and pick categoryes you want to show before you save!'); - } - }); - - $('#cat-check-all').click(function(){ - $('.cat-name').attr('checked', true); - }); - - $('#cat-uncheck-all').click(function(){ - $('.cat-name').attr('checked', false); - }); - - - // SORTABLE - - $('#timeline-sortable').sortable({ - placeholder: "tsort-placeholder" - }); - - //--------------------------------------------- - // Ctimeline Sortable Actions - //--------------------------------------------- - - // add - $('#tsort-add-new').click(function(e){ - e.preventDefault(); - ctimelineAddNew(pluginUrl); - }); - - // open item - $('.tsort-plus').live('click', function(){ - if (!$(this).hasClass('open')) { - $(this).addClass('open'); - $(this).html('-').css('padding', '5px 8px'); - $(this).next().next('.tsort-content').show(); - } - else { - $(this).removeClass('open'); - $(this).html('+').css('padding', '7px 5px'); - $(this).next().next('.tsort-content').hide(); - } - }); - // delete - $('.tsort-delete').live('click', function(e){ - e.preventDefault(); - $(this).parent().parent().remove(); - }); - - $('.tsort-remove').live('click', function(e){ - e.preventDefault(); - $(this).parent().find('input').val(''); - $(this).parent().find('img').attr('src', pluginUrl + '/images/no_image.jpg'); - }); - - - // item images - $('.tsort-change').live('click', function(e) { - e.preventDefault(); - thickItem = true; - thickboxId = '#' + $(this).parent().find('img').attr('id'); - formfield = $(thickboxId + '-input').attr('name'); - tb_show('', 'media-upload.php?type=image&TB_iframe=true'); - return false; - }); - - // item images - $('.tsort-start-item').live('click', function(e) { - $('.tsort-start-item').attr('checked', false); - $(this).attr('checked', 'checked'); - }); - - // ---------------------------------------- - - // AJAX subbmit - $('#save-timeline').click(function(e){ - e.preventDefault(); - $('#save-loader').show(); - $.ajax({ - type:'POST', - url: 'admin-ajax.php', - data:'action=ctimeline_save&' + $('#post_form').serialize(), - success: function(response) { - $('#timeline_id').val(response); - $('#save-loader').hide(); - } - }); - }); - - $('#preview-timeline').click(function(e){ - e.preventDefault(); - var html = '
'; - html += '
'; - html += '
Preview
'; - html += '
Close
'; - html += '
'; - html += '
'; - html += ''; - html += '
'; - html += '
'; - html += ''; - $('body').append(html); - var postForm = $('#post_form').serialize(); - $.ajax({ - type:'POST', - url: 'admin-ajax.php', - data:'action=ctimeline_preview&' + postForm, - success: function(response) { - $('#TBct_loader').hide(); - $('#TBct_window').animate({width: '100%', marginLeft:'-50%', marginTop: '-250px', height: '500px'}, 500, function(){ - $('#timelineHolder').html(response); - $('#timelineHolder').css({'overflow-y':'scroll', 'position': 'relative', 'width':'100%', 'height':'470px'}); - - if($('#read-more').val() == 'whole-item') { - var $read_more = '.item'; - var $swipeOn = false; - } - else if ($('#read-more').val() == 'button') { - var $read_more = '.read_more'; - var $swipeOn = true; - } - else { - var $read_more = '.none'; - var $swipeOn = true; - } - - var startItem = $('#ctimeline-preview-start-item').val(); - - - var $cats = []; - var $numOfItems = []; - var numGet = parseInt($('#number-of-posts').val()); - $('input[name|="cat-name"]:checked').each(function(){ - $cats.push($(this).val()); - $numOfItems.push(numGet); - - }); - - - - - var jsonOptions = { - itemMargin : parseInt($('#item-margin').val()), - swipeOn : $swipeOn, - scrollSpeed : parseInt($('#scroll-speed').val()), - easing : $('#easing').val(), - openTriggerClass : $read_more, - startItem : startItem, - yearsOn : ($('#years-on:checked').length > 0 ), - hideTimeline : ($('#hide-line:checked').length > 0 ), - hideControles : ($('#hide-nav:checked').length > 0 ) - } - - if (typeof $cats[0] != 'undefined' && $('#cat-type').val() == 'categories') { - jsonOptions.yearsOn = false; - jsonOptions.categories = $cats; - jsonOptions.numberOfSegments = $numOfItems; - } - $(".scrollable-content").mCustomScrollbar(); - $('.timeline').timeline(jsonOptions); - $('#preview-loader').hide(); - - $('#TBct_closeWindowButton').click(function(ev){ - ev.preventDefault(); - $('.timeline').timeline('destroy'); - $('#TBct_overlay').remove(); - $('#TBct_window').remove(); - }); - }); - - } - }); - }); - - -}); - - -function ctimelineSortableActions(pluginUrl) { - - - - -} - -function ctimelineAddNew(pluginUrl) { - var searches = new Array(); - searches[''] = ''; - var html = '
'; - html += '
'; - html += '
Add new timeline item
' - html += '
Close
'; - html += '
'; - html += 'Add'; - html += ''; - html += ''; - html += '
'; - $('body').prepend(html); - - - $('#TBct_closeWindowButton').click(function(e){ - e.preventDefault(); - $('#TBct_overlay').remove(); - $('#TBct_window').remove(); - }); - - $('#TBct_timelineSelect').change(function(){ - if ($(this).val() == 'new') { - $('#TBct_window').css({marginTop:'-35px', height:'70px'}); - $('#TBct_timelineFromPost').hide(); - $('#TBct_timelineWholeCategory').hide(); - } - if ($(this).val() == 'category') { - $('#TBct_window').css({marginTop:'-60px', height:'120px'}); - $('#TBct_timelineWholeCategory').show(); - $('#TBct_timelineFromPost').hide(); - } - else { - $('#TBct_window').css({marginTop:'-150px', height:'300px'}); - $('#TBct_timelineFromPost').show(); - $('#TBct_timelineWholeCategory').hide(); - } - }); - - $('#TBct_timelineSubmit').click(function(e){ - e.preventDefault(); - var timelineItem = ''; - if ($('#TBct_timelineSelect').val() == 'new') { - timelineItem = timelineGenerateItem(); - $('#timeline-sortable').append(timelineItem); - $('.tsort-start-item').eq($('.tsort-start-item').length-1).trigger('click').attr('checked', 'checked'); - $('#TBct_overlay').remove(); - $('#TBct_window').remove(); - } - else if ($('#TBct_timelineSelect').val() == 'category') { - $('#TBct_timelineSubmitLoader').show(); - $.ajax({ - url:"admin-ajax.php", - type:"POST", - data:'action=ctimeline_post_category_get&cat_name='+$('TBct_timelineCategorySelect').val(), - - success:function(results){ - var resultsArray = results.split('||'); - var ii = 0; - while (typeof resultsArray[0+ii] != 'undefined') { - - var properties = { - 'title' : resultsArray[0+ii], - 'dataId' : resultsArray[1+ii], - 'categoryId' : resultsArray[2+ii], - 'itemContent' : resultsArray[3+ii], - 'itemImage' : resultsArray[4+ii], - 'itemOpenContent' : resultsArray[5+ii] - } - timelineItem = timelineGenerateItem(properties); - $('#timeline-sortable').append(timelineItem); - ii +=6; - } - $('.tsort-start-item').eq($('.tsort-start-item').length-1).trigger('click').attr('checked', 'checked'); - $('#TBct_overlay').remove(); - $('#TBct_window').remove(); - } - }); - } - - else if($('#timelineFromPostComplete li a.active').length < 1) { - alert('You have to select post you want to add, or choose add new!'); - } - else { - var postId = $('#timelineFromPostComplete li a.active').attr('href'); - $('#TBct_timelineSubmitLoader').show(); - $.ajax({ - url:"admin-ajax.php", - type:"POST", - data:'action=ctimeline_post_get&post_id='+postId, - - success:function(results){ - var resultsArray = results.split('||'); - var properties = { - 'title' : resultsArray[0], - 'dataId' : resultsArray[1], - 'categoryId' : resultsArray[2], - 'itemContent' : resultsArray[3], - 'itemImage' : resultsArray[4], - 'itemOpenContent' : resultsArray[5] - } - timelineItem = timelineGenerateItem(properties); - $('#timeline-sortable').append(timelineItem); - $('.tsort-start-item').eq($('.tsort-start-item').length-1).trigger('click').attr('checked', 'checked'); - $('#TBct_overlay').remove(); - $('#TBct_window').remove(); - } - }); - } - - }) - - $('#timelineFromPost').keyup(function(e){ - var icall = null, - qinput = $('#timelineFromPost').val(); - - if(qinput in searches) { - if(icall != null) icall.abort(); - $('#timelineFromPostComplete').html(searches[qinput]).show(); - $('#timelineFromPostComplete li a').click(function(e){ - e.preventDefault(); - $('#timelineFromPostComplete li a.active').removeClass('active'); - $(this).addClass('active'); - }); - $('#timelineFromPostLoader').hide(); - } - else { - $('#timelineFromPostLoader').show(); - if(icall != null) icall.abort(); - icall = $.ajax({ - url:"admin-ajax.php", - type:"POST", - data:'action=ctimeline_post_search&query='+qinput, - - success:function(results){ - $('#timelineFromPostComplete').html(results).show(); - searches[qinput] = results; - $('#timelineFromPostComplete li a').click(function(e){ - e.preventDefault(); - $('#timelineFromPostComplete li a.active').removeClass('active'); - $(this).addClass('active'); - }); - $('#timelineFromPostLoader').hide(); - } - }); - } - }); -} - -function timelineGenerateItem(properties) { - // set globals - var pluginUrl = $('#plugin-url').val(), - timthumb = pluginUrl + '/timthumb/timthumb.php'; - - // calculate item number - var itemNumber = 1; - while($('#sort'+itemNumber).length > 0) { - itemNumber++; - } - - // get current date - var today = new Date(); - var dd = today.getDate(); - var mm = today.getMonth()+1; - var yyyy = today.getFullYear(); - if(dd<10){dd='0'+dd} - if(mm<10){mm='0'+mm} - today = dd+'/'+mm+'/'+yyyy; - - // get input properties - var pr = $.extend({ - 'title' : 'Title', - 'dataId' : today, - 'categoryId' : '', - 'itemContent' : 'Content', - 'itemImage' : '', - 'itemOpenContent' : 'Content' - }, properties); - - // bring all the pieces together - var itemHtml = '\n'+ -'
  • \n'+ -'
    +
    \n'+ -'
    Item '+itemNumber+' - '+pr.title+'  delete
    \n'+ -'
    \n'+ -'
    \n'+ -' '+ -' ? Argument by which are elements organised (date - dd/mm/yyyy, Category - full category name) Different field is used for different categorizing type.'+ -' '+ -' '+ -' '+ -' '+ -'
    \n'+ -'
    \n'+ -'

    ? Base item content (image, title and content).Item Options

    \n'+ -'
    Change\n' + -' \n'+ -' Remove\n'+ -'
    \n'+ -' \n'+ -'
    \n'+ -' \n'+ -'
    \n'+ -'
    \n'+ -'

    ? Opened item content (image, title and content).Item Open Options

    \n'+ -'
    Change'+ -' \n'+ -' Remove\n'+ -'
    \n'+ -' \n'+ -'
    \n'+ -' \n'+ -'
    \n'+ -'
    \n'+ -'
  • \n'; - return itemHtml; -} - - -})(jQuery) -