Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function($){
  2.     "use strict";
  3.  
  4.     /*--------------------------------------------------------*/
  5.     /* TABLE OF CONTENTS: */
  6.     /*--------------------------------------------------------*/
  7.     /* 01 - VARIABLES */
  8.     /* 02 - page calculations */
  9.     /* 03 - function on document ready */
  10.     /* 04 - function on page load */
  11.     /* 05 - function on page resize */
  12.     /* 06 - swiper sliders */
  13.     /* 07 - buttons, clicks, hovers */
  14.     /*-------------------------------------------------------------------------------------------------------------------------------*/
  15.  
  16.     $('.sub_footer_menu a').each(function(){
  17.         $(this).addClass('btn color-7 size-2 hover-9');
  18.     });
  19.  
  20.  
  21.     // VC Row Overlay
  22.     $('div[data-overlay]').each(function(){
  23.         var $row = $(this);
  24.         var $overlay = $('<div class="vc-row-overlay" style="background-color:'+$row.data('overlay')+'; opacity:'+$row.data('overlay-alpha')+';"></div>');
  25.         $row.prepend( $overlay );
  26.     });
  27.  
  28.  
  29.     // like button
  30.     $('.like-button').each(function(){
  31.         var $btn = $(this);
  32.  
  33.         $btn.on('click', function(){
  34.             var _id = $btn.data('id');
  35.             if( !$btn.hasClass('spinning') ){
  36.                 $btn.addClass('spinning');
  37.                 $.post(theme_options.ajax_url, { action:'post_like_action', post_id:_id }, function(data){
  38.                     if( data=='1' ){
  39.                         if( $btn.hasClass('active') ){
  40.                             $btn.removeClass('active');
  41.                         }
  42.                         else{
  43.                             $btn.addClass('active');
  44.                         }
  45.                         $btn.removeClass('spinning');
  46.                     }
  47.  
  48.                 });
  49.             }
  50.         });
  51.     });
  52.  
  53.  
  54.     // like button
  55.     $('.like-button-blog').each(function(){
  56.         var $btn = $(this);
  57.  
  58.         $btn.on('click', function(){
  59.             var _id = $btn.data('id');
  60.             $.post(theme_options.ajax_url, { action:'post_like_action', post_id:_id }, function(data){
  61.                 $btn.append(' <i class="fa fa-spinner"></i>');
  62.                 $.post(theme_options.ajax_url, { action:'post_like_blog_action', post_id:_id }, function(data){
  63.                     $btn.html('<i class="fa fa-thumbs-o-up"></i> '+data);
  64.                 });
  65.             });
  66.         });
  67.     });
  68.  
  69.  
  70.     // no-logged-in
  71.     $('.no-logged-in').each(function(){
  72.         $(this).on('click', function(){
  73.             $(".large-popup.login").slideToggle();
  74.             return false;
  75.         });
  76.     });
  77.  
  78.     // add to collection
  79.     $('.btn-add2collection:not(.no-logged-in)').each(function(){
  80.         var $btn = $(this);
  81.         var _id = $btn.data('id');
  82.  
  83.         $btn.on('click', function(){
  84.  
  85.             if( $('#add2collection-view').length ){
  86.                 $('#add2collection-view').dialog('destroy').remove();
  87.             }
  88.  
  89.             var $form = $('#tpl-add2collection').clone();
  90.             var dlg = $("<div id='add2collection-view' />")
  91.                         .html($form.html())
  92.                         .appendTo("body");
  93.  
  94.             dlg.dialog({
  95.                 'dialogClass' : 'wp-dialog',
  96.                 'modal' : true,
  97.                 'autoOpen' : false,
  98.                 'closeOnEscape' : true,
  99.                 'title': 'Add to Collections',
  100.                 'resizable': false,
  101.                 'width': '300px',
  102.                 'buttons' : [
  103.                     {
  104.                         'text' : 'Save',
  105.                         'class' : 'be-button-vidget blue-style',
  106.                         'click' : function() {
  107.  
  108.                             if( !$("#add2collection-view").hasClass('loading-form') ){
  109.                                 $("#add2collection-view").addClass('loading-form');
  110.                                 var _selected = '';
  111.                                 $("#add2collection-view").find('.add2col-list a.selected').each(function(){
  112.                                     _selected += $(this).data('col-id') + '|';
  113.                                 });
  114.  
  115.                                 $.post(theme_options.ajax_url, { action: 'add2col_save_col', post_id:_id, collections:_selected }, function(data){
  116.                                     dlg.dialog('close');
  117.                                 });
  118.                             }
  119.  
  120.                         }
  121.                     }
  122.                 ]
  123.             })
  124.             .dialog('open');
  125.  
  126.  
  127.             $.post(theme_options.ajax_url, { action: 'add2col_get_list', post_id:_id }, function(data){
  128.                 if( $("#add2collection-view").find('.add2col-list').length ){
  129.                     $("#add2collection-view").find('.add2col-list').html( data );
  130.  
  131.                     $("#add2collection-view").find('.add2col-list a').off('click').on('click', function(){
  132.                         $(this).toggleClass('selected');
  133.                     });
  134.                 }
  135.             });
  136.             // <li><a href="javascript:;">New List <i class="fa fa-check"></i></a></li>
  137.  
  138.             $('#add2col-btn').off('click').on('click', function(){
  139.                 var $col_btn = $(this);
  140.                 if( $("#add2collection-view").find('#new-collection').val()!='' && !$col_btn.hasClass('clicked') ){
  141.                     $col_btn.addClass('clicked');
  142.                     $.post(theme_options.ajax_url, { action: 'add2col_new', name:$("#add2collection-view").find('#new-collection').val(), post_id:_id }, function(data){
  143.                         if( data!='0' ){
  144.                             $('#add2collection-view').find('.add2col-list').html(data);
  145.  
  146.                             $("#add2collection-view").find('.add2col-list a').off('click').on('click', function(){
  147.                                 $(this).toggleClass('selected');
  148.                             });
  149.                         }
  150.                         $col_btn.removeClass('clicked');
  151.                     });
  152.                 }
  153.             });
  154.  
  155.         });
  156.  
  157.     });
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.     // Follow action
  165.     var follow_button_handler = function(_icon){
  166.         $('.bp-follow-action').each(function(){
  167.             var $btn = $(this);
  168.  
  169.             $btn.on('click', function(){
  170.                 var _user = $(this).attr('data-user-id');
  171.                 var _nonce = $(this).attr('data-nounce');
  172.                 var _follow = $(this).data('text-follow');
  173.                 var _following = $(this).data('text-following');
  174.  
  175.                 $(".be-loader").fadeIn("slow");
  176.  
  177.                 var _args = { action:'net_addremove_friend', fid:_user };
  178.  
  179.                 $.post(theme_options.ajax_url, _args, function(data){
  180.  
  181.                     var _json = $.parseJSON(data);
  182.  
  183.                     if(  typeof _json.following!=='undefined' && _json.following=='1' ){
  184.                         $btn.html( _following );
  185.                     }
  186.                     else{
  187.                         if(_icon){
  188.                             $btn.html( '<i class="fa fa-plus"></i>' + _follow );
  189.                         }
  190.                         else{
  191.                             $btn.html( _follow );
  192.                         }
  193.                     }
  194.  
  195.                     $(".be-loader").fadeOut("fast");
  196.                 });
  197.  
  198.             });
  199.  
  200.         });
  201.     }
  202.  
  203.     follow_button_handler(true);
  204.  
  205.  
  206.  
  207.  
  208.     // edit image
  209.     $('#edit-avatar').on('click', function(){
  210.         var send_attachment_bkp = wp.media.editor.send.attachment;
  211.         wp.media.editor.send.attachment = function(props, attachment){
  212.             wp.media.editor.send.attachment = send_attachment_bkp;
  213.  
  214.             $('#user-avatar').find('img').attr('src', attachment.url);
  215.             $('#user-avatar-attach').val(attachment.id);
  216.  
  217.         }
  218.         wp.media.editor.open();
  219.     });
  220.  
  221.     // save profile
  222.     $('#save-profile').on('click', function(){
  223.  
  224.         var _pass = $('.cs-new-pass').val() + '';
  225.         if( _pass!='' && _pass!=$('.cs-repeat-pass').val() ){
  226.             alert('Please check your password!');
  227.             return false;
  228.         }
  229.  
  230.         if( _pass!='' && _pass.length<4 ){
  231.             alert('Please check your password!');
  232.             return false;
  233.         }
  234.  
  235.         var custom_sections = [];
  236.         $('.custom-section-block').each(function(){
  237.             var $cs = $(this);
  238.             var _id = $cs.hasClass('saved-section') ? $cs.attr('id') : 0;
  239.             custom_sections.push( _id + '$$$' + $cs.find('.cs-input').val() + '$$$' + $cs.find('.cs-textarea').val() );
  240.         });
  241.  
  242.         var args = {
  243.             action: 'net_save_profile',
  244.             fname:      $('.cs-fname').val(),
  245.             lname:      $('.cs-lname').val(),
  246.             user_image: $('#user-avatar-attach').val(),
  247.             occupation: $('.cs-occupation').val(),
  248.             company:    $('.cs-company').val(),
  249.             country:    $('.cs-country').val(),
  250.             city:       $('.cs-city').val(),
  251.             website:    $('.cs-website').val(),
  252.                 base_style: $('.cs-base-style').val(),
  253.                 region:     $('.cs-region').val(),
  254.                 sex:        $('.cs-sex').val(),
  255.                 federal_district: $('.cs-federal-district').val(),
  256.                 vk:         $('#vk').val(),
  257.             facebook:   $('#facebook').val(),
  258.             twitter:    $('#twitter').val(),
  259.             instagram:  $('#instagram').val(),
  260.             description: $('.cs-description').val(),
  261.             password:   $('.cs-new-pass').val(),
  262.             custom_sections: custom_sections
  263.         };
  264.  
  265.         $(".be-loader").fadeIn("slow");
  266.         $.post( theme_options.ajax_url, args, function(data){
  267.             window.location.reload();
  268.         });
  269.  
  270.     });
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.     // Search
  280.     var folio_filters_hook = function(){
  281.  
  282.         $(".be-loader").fadeIn("slow");
  283.  
  284.         var icon_close = ' <i class="fa keyword fa-times"></i>';
  285.         if( $('.s_keywords').length<1 ){
  286.             $('#main-content-panel').before( $('#tpl-search-filter').html() );
  287.         }
  288.  
  289.  
  290.         $('.sk-clears').off('click').on('click', function(){
  291.             $('#folio_filter_search').val('');
  292.  
  293.             var _items = ['type', 'category', 'features', 'worldwide', 'base_style', 'age_from', 'age_to', 'height_from', 'height_to', 'weight_from', 'weight_to', 'region', 'federal_district', 'sex', 'project_district'];
  294.             for( var i=0; i<_items.length; i++ ){
  295.                 var _pst = _items[i];
  296.                 var _id = 'folio_filter_' + _pst;
  297.                 $('#'+_id).parent().find('.be-dropdown-content').text( $('#'+_id).parent().find('ul li:first-child a').eq(0).text() );
  298.                 $('#'+_id).val( $('#'+_id).parent().find('ul li:first-child a').eq(0).data('id') );
  299.             }
  300.  
  301.             $('.sk-item').each(function(){ $(this).remove(); });
  302.  
  303.             $('#net_meta_field1').val('');
  304.             $('#net_meta_field2').val('');
  305.             $('#net_meta_field3').val('');
  306.             $('#net_meta_field_color').find('li.active-color').removeClass('active-color');
  307.  
  308.             folio_filters_hook();
  309.  
  310.             $('.s_keywords').remove();
  311.         });
  312.  
  313.  
  314.  
  315.         if( $('#folio_filter_search').val()=='' ){
  316.             $('.sk-item-search').remove();
  317.         }
  318.         else{
  319.             if( $('.sk-item-search').length ){
  320.                 $('.sk-item-search').html( $('#folio_filter_search').val() + icon_close );
  321.             }
  322.             else{
  323.                 $('.s_keywords .custom-container').append( $('<a class="btn color-6 size-3 hover-10 sk-item sk-item-search" data-elem="sk-item-search" data-field="folio_filter_search"></a>').html($('#folio_filter_search').val() + icon_close) );
  324.             }
  325.         }
  326.  
  327.  
  328.         var _items = ['type', 'category', 'features', 'worldwide', 'base_style', 'age_from', 'age_to', 'height_from', 'height_to', 'weight_from', 'weight_to', 'region', 'federal_district', 'sex', 'project_district'];
  329.         for( var i=0; i<_items.length; i++ ){
  330.             var _pst = _items[i];
  331.             var _id = 'folio_filter_' + _pst;
  332.             var _class = 'sk-item-' + _pst;
  333.             var _std = $('#'+_id).parent().find('ul li:first-child a').eq(0).data('id');
  334.  
  335.             if( $('#'+_id).val()==_std ){
  336.                 $('.'+_class).remove();
  337.             }
  338.             else{
  339.                 var _text = $('#'+_id).parent().find('.be-dropdown-content').text() + icon_close;
  340.                 if( $('.'+_class).length ){
  341.                     $('.'+_class).html( _text );
  342.                 }
  343.                 else{
  344.                     $('.s_keywords .custom-container').append( $('<a class="btn color-6 size-3 hover-10 sk-item '+_class+'" data-elem="'+_class+'" data-field="'+_id+'"></a>').html(_text) );
  345.                 }
  346.             }
  347.         }
  348.  
  349.  
  350.  
  351.         $('.sk-item').off('click').on('click', function(){
  352.             var $btn_close = $(this);
  353.             var _id = $btn_close.data('field');
  354.             if( $btn_close.hasClass('sk-item-search') ){
  355.                 $('#'+_id).val('');
  356.                 $('#folio_filter_type').trigger('change');
  357.             }
  358.             else if( $btn_close.hasClass('sk-item-mf') ){
  359.                 var _elem = $btn_close.data('elem');
  360.                 if( _elem=='net_meta_field_color' ){
  361.                     $('#net_meta_field_color li.active-color').removeClass('active-color');
  362.                     $btn_close.remove();
  363.                     folio_filters_hook();
  364.                 }
  365.                 else{
  366.                     $('#'+_elem).val('');
  367.                     $btn_close.remove();
  368.                     folio_filters_hook();
  369.                 }
  370.             }
  371.             else{
  372.                 $('#'+_id).parent().find('.be-dropdown-content').text( $('#'+_id).parent().find('ul li:first-child a').eq(0).text() );
  373.                 $('#'+_id).val( $('#'+_id).parent().find('ul li:first-child a').eq(0).data('id') );
  374.                 $('#'+_id).trigger('change');
  375.             }
  376.             return false;
  377.         });
  378.  
  379.  
  380.  
  381.  
  382.         var args = {
  383.             action:         'net_search_portfolios',
  384.             search:         $('#folio_filter_search').val(),
  385.             types:          $('#folio_filter_type').val(),
  386.             category:       $('#folio_filter_category').val(),
  387.             base_style:     $('#folio_filter_base_style').val(),
  388.                 region:             $('#folio_filter_region').val(),
  389.                 sex:                  $('#folio_filter_sex').val(),
  390.                 federal_district: $('#folio_filter_federal_district').val(),
  391.             age_from:       $('#folio_filter_age_from').val(),
  392.             age_to:         $('#folio_filter_age_to').val(),
  393.             height_from:    $('#folio_filter_height_from').val(),
  394.             folowers:         $('#folio_filter_folowers').val(),
  395.             height_to:      $('#folio_filter_height_to').val(),
  396.             weight_from:    $('#folio_filter_weight_from').val(),
  397.             weight_to:      $('#folio_filter_weight_to').val(),
  398.             worldwide:      $('#folio_filter_worldwide').val(),
  399.             features:       $('#folio_filter_features').val(),
  400.             project_district: $('#folio_filter_project_district').val(),
  401.             paged:          0
  402.         };
  403.  
  404.         if( $('#projects_type').length ){
  405.             $.extend(args, { projects_type:$('#projects_type').val() });
  406.         }
  407.  
  408.         if( $('#net_meta_field1').length ){
  409.             $.extend(args, { meta_field1:$('#net_meta_field1').val() });
  410.             $.extend(args, { meta_field2:$('#net_meta_field2').val() });
  411.             $.extend(args, { meta_field3:$('#net_meta_field3').val() });
  412.         }
  413.  
  414.         if( $('#net_meta_field_color').find('li.active-color').length ){
  415.             var _class = $('#net_meta_field_color').find('li.active-color').attr('class') + '';
  416.             _class = _class.replace('color filter ', '').replace(' active-color', '');
  417.             $.extend(args, { meta_field_color:_class });
  418.         }
  419.  
  420.  
  421.         $.post(theme_options.ajax_url, args, function(data){
  422.             if( data!='0' && data!='' ){
  423.                 var _json = $.parseJSON(data);
  424.                 if( typeof _json.types!=='undefined' ){
  425.  
  426.                     if( _json.count>0 ){
  427.                         var $data = $('<div></div>').append(_json.result);
  428.                         $('._post-container_').html( $data.html() );
  429.  
  430.                         $('#netsearch_paged').val(_json.paged);
  431.                         $('#netsearch_args').html(_json.args);
  432.  
  433.                         if( _json.count<16 ){ $('#netsearch_btn_pager').hide(); }
  434.                         else{ $('#netsearch_btn_pager').show(); }
  435.  
  436.                         follow_button_handler(false);
  437.                     }
  438.                     else{
  439.                         $('._post-container_').html('<h4 class="text-center">'+_json.error+'</h4>');
  440.                         $('#netsearch_btn_pager').hide();
  441.                     }
  442.  
  443.                 }
  444.             }
  445.  
  446.             $(".be-loader").fadeOut("fast");
  447.         });
  448.  
  449.     };
  450.  
  451.  
  452.     // Search Pager
  453.     $('#netsearch_btn_pager').on('click', function(){
  454.         $(".be-loader").fadeIn("slow");
  455.  
  456.         var args = {
  457.             action:     'net_search_portfolios',
  458.             search:     $('#folio_filter_search').val(),
  459.             types:      $('#folio_filter_type').val(),
  460.             category:   $('#folio_filter_category').val(),
  461.             features:   $('#folio_filter_features').val(),
  462.             worldwide:  $('#folio_filter_worldwide').val(),
  463.             paged:      $('#netsearch_paged').val(),
  464.             encrypted_args: $('#netsearch_args').html()
  465.         };
  466.  
  467.  
  468.         if( $('#net_meta_field1').length ){
  469.             $.extend(args, { meta_field1:$('#net_meta_field1').val() });
  470.             $.extend(args, { meta_field2:$('#net_meta_field2').val() });
  471.             $.extend(args, { meta_field3:$('#net_meta_field3').val() });
  472.         }
  473.  
  474.         if( $('#net_meta_field_color').find('li.active-color').length ){
  475.             var _class = $('#net_meta_field_color').find('li.active-color').attr('class') + '';
  476.             _class = _class.replace('color filter ', '').replace(' active-color', '');
  477.             $.extend(args, { meta_field_color:_class });
  478.         }
  479.  
  480.  
  481.         $.post(theme_options.ajax_url, args, function(data){
  482.             if( data!='0' && data!='' ){
  483.                 var _json = $.parseJSON(data);
  484.                 if( typeof _json.types!=='undefined' ){
  485.                     var $data = $('<div></div>').append(_json.result);
  486.                     $('._post-container_').append( $data.html() );
  487.  
  488.                     $('#netsearch_paged').val(_json.paged);
  489.                     $('#netsearch_args').html(_json.args);
  490.  
  491.                     if( _json.count<16 ){ $('#netsearch_btn_pager').hide(); }
  492.                     else{ $('#netsearch_btn_pager').show(); }
  493.  
  494.                     follow_button_handler(false);
  495.  
  496.                 }
  497.             }
  498.  
  499.             $(".be-loader").fadeOut("fast");
  500.         });
  501.  
  502.     });
  503.  
  504.  
  505.  
  506.  
  507.  
  508.     $('#search-form-folio').on('submit', function(){
  509.         folio_filters_hook();
  510.         return false;
  511.     });
  512.  
  513.     $('.filter-projects input.form-input, .filter-categories input.form-input, .filter-features input.form-input, .filter-worldwide input.form-input').on('change', function(){
  514.         folio_filters_hook();
  515.         return false;
  516.     });
  517.  
  518.  
  519.  
  520.  
  521.  
  522.     $('#net_meta_field1, #net_meta_field2, #net_meta_field3').on('keyup', function(e){
  523.         var $this = $(this);
  524.         var _id = $this.attr('id');
  525.         var icon_close = ' <i class="fa keyword fa-times"></i>';
  526.  
  527.         if( e.which==13 && this.value!='' ){
  528.             if( $('.s_keywords').length<1 ){
  529.                 $('#main-content-panel').before( $('#tpl-search-filter').html() );
  530.             }
  531.             $('.s_keywords .custom-container').find('a.sk-item-mf[data-elem="'+_id+'"]').remove();
  532.             $('.s_keywords .custom-container').append( $('<a class="btn color-6 size-3 hover-10 sk-item sk-item-mf" data-elem="'+_id+'" data-field="'+_id+'"></a>').html($this.val()+icon_close) );
  533.             folio_filters_hook();
  534.  
  535.             $this.parents('.be-popup').hide();
  536.             $this.parents('.be-popup').parents('li.be-active').removeClass('be-active');
  537.             $('.be-fixed-filter.active-fixed').removeClass('active-fixed');
  538.         }
  539.         return false;
  540.     });
  541.  
  542.  
  543.  
  544.     $('#net_meta_field_color').find('li').on('click', function(){
  545.         var _classes = this.classList;
  546.         var _class = '';
  547.         var icon_close = ' <i class="fa keyword fa-times"></i>';
  548.  
  549.         for( var i=0; i<_classes.length; i++ ){
  550.             if( _classes[i]!='active-color' && _classes[i]!='color' && _classes[i]!='filter' ){
  551.                 _class = _classes[i];
  552.             }
  553.         }
  554.  
  555.         if( _class!='' ){
  556.             if( $('.s_keywords').length<1 ){
  557.                 $('#main-content-panel').before( $('#tpl-search-filter').html() );
  558.             }
  559.             $('.s_keywords .custom-container').find('a.sk-item-mf[data-elem="net_meta_field_color"]').remove();
  560.             $('.s_keywords .custom-container').append( $('<a class="btn color-6 size-3 hover-10 sk-item sk-item-mf '+_class+'" data-elem="net_meta_field_color" data-field="net_meta_field_color"></a>').html('color'+icon_close) );
  561.             folio_filters_hook();
  562.  
  563.             $(this).parents('.be-popup').hide();
  564.             $(this).parents('.be-popup').parents('li.be-active').removeClass('be-active');
  565.             $('.be-fixed-filter.active-fixed').removeClass('active-fixed');
  566.         }
  567.  
  568.     });
  569.  
  570.  
  571.     $('#folowers').on('click', function(){
  572.         folio_filters_hook();
  573.     });
  574.  
  575.  
  576.     $('#reg_frontend_form').on('submit', function(){
  577.         var $form = $(this);
  578.         if( $form.find('input[name="reg_email"]').val()=='' ){
  579.             alert('Please check your email!');
  580.             return false;
  581.         }
  582.  
  583.         if( $form.find('input[name="reg_pass"]').val()=='' ){
  584.             alert('Please check your password!');
  585.             return false;
  586.         }
  587.  
  588.         if( $form.find('input[name="reg_username"]').val()=='' ){
  589.             alert('Please check your username!');
  590.             return false;
  591.         }
  592.  
  593.         $(".be-loader").fadeIn("slow");
  594.         $.post(theme_options.ajax_url, $form.serialize(), function(data){
  595.  
  596.             $(".be-loader").fadeOut("slow");
  597.  
  598.             if( data=='1' ){
  599.                 $form.parent().find('.close-button').trigger('click');
  600.                 $(".large-popup.login").slideToggle();
  601.             }
  602.             else{
  603.                 alert(data);
  604.             }
  605.         });
  606.  
  607.         return false;
  608.     });
  609.  
  610.  
  611.  
  612.  
  613.     $('#msg_button_send').on('click', function(){
  614.  
  615.         if( $('#msg_content').val()!='' ){
  616.  
  617.             $(".be-loader").fadeIn("slow");
  618.  
  619.             $.post(theme_options.ajax_url, { action: 'net_frontend_message', user: $('#msg_username').val(), content: $('#msg_content').val()}, function(data){
  620.  
  621.                 $(".be-loader").fadeOut("slow");
  622.  
  623.                 if( data=='1' ){
  624.                     $('.msg-popup-window').slideUp();
  625.                     $('#msg_content').val('');
  626.                 }
  627.                 else{
  628.                     alert(data);
  629.                 }
  630.             });
  631.         }
  632.  
  633.     });
  634.  
  635.  
  636.  
  637.     $('#frontend_mail_form').on('submit', function(){
  638.         var $form = $(this);
  639.  
  640.         if( $form.find('input[name="msg_mail"]').val()=='' ){
  641.             alert('Please check your email!');
  642.             return false;
  643.         }
  644.  
  645.         if( $form.find('textarea').val()=='' ){
  646.             alert('Please check your message!');
  647.             return false;
  648.         }
  649.  
  650.         $(".be-loader").fadeIn("slow");
  651.         $.post(theme_options.ajax_url, $form.serialize(), function(data){
  652.  
  653.             $(".be-loader").fadeOut("fast");
  654.  
  655.             if( data=='1' ){
  656.                 $form.parent().find('.close-button').trigger('click');
  657.             }
  658.             else{
  659.                 alert(data);
  660.             }
  661.         });
  662.  
  663.         return false;
  664.     });
  665.  
  666.  
  667.  
  668.  
  669.     $('#btn_remove_project').on('click', function(){
  670.         var _id = $(this).data('post');
  671.         var _nonce = $(this).data('nonce');
  672.         var _confirm = confirm("Delete this item?");
  673.  
  674.         if( _confirm && _id!='' && _nonce!='' ){
  675.             $(".be-loader").fadeIn("slow");
  676.             $.post(theme_options.ajax_url, { action:'net_frontend_remove', post_id:_id, nonce:_nonce }, function(data){
  677.                 $(".be-loader").fadeOut("fast");
  678.  
  679.                 var _json = $.parseJSON(data);
  680.                 if( typeof _json.result!=='undefined' && _json.result=='yes' ){
  681.                     window.location.href = _json.redirect;
  682.                 }
  683.                 else{
  684.                     alert('Something wrong, Please check your internet connection and try again.');
  685.                 }
  686.             });
  687.         }
  688.  
  689.     });
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.     $('.collection-actions a.coll_edit_action').on('click', function(){
  697.         var $this = $(this);
  698.         var _id = $this.data('id');
  699.         var _nonce = $this.data('nonce');
  700.         var _name = $this.parents('.collection').find('.menu-article').text();
  701.         var _prompt = prompt('Rename Collection', _name);
  702.         if (_prompt != null && _prompt!=''){
  703.  
  704.             $(".be-loader").fadeIn("slow");
  705.             $.post(theme_options.ajax_url, { action:'net_edit_coll_rename', id:_id, name:_prompt, nonce:_nonce }, function(data){
  706.                 $(".be-loader").fadeOut("fast");
  707.  
  708.                 var _json = $.parseJSON(data);
  709.                 if( typeof _json.result!=='undefined' && _json.result=='yes' ){
  710.                     $this.parents('.collection').find('.menu-article').html(_prompt);
  711.                 }
  712.                 else{
  713.                     alert('Something wrong, Please check your internet connection and try again.');
  714.                 }
  715.             });
  716.  
  717.         }
  718.     });
  719.  
  720.     $('.collection-actions a.col_remove_action').on('click', function(){
  721.         var $this = $(this);
  722.         var _id = $this.data('id');
  723.         var _nonce = $this.data('nonce');
  724.  
  725.         var _confirm = confirm('Remove this collection?');
  726.         if (_confirm ){
  727.  
  728.             $(".be-loader").fadeIn("slow");
  729.             $.post(theme_options.ajax_url, { action:'net_edit_coll_remove', id:_id, nonce:_nonce }, function(data){
  730.                 $(".be-loader").fadeOut("fast");
  731.  
  732.                 var _json = $.parseJSON(data);
  733.                 if( typeof _json.result!=='undefined' && _json.result=='yes' ){
  734.                     $this.parents('.collection').remove();
  735.                 }
  736.                 else{
  737.                     alert('Something wrong, Please check your internet connection and try again.');
  738.                 }
  739.             });
  740.  
  741.         }
  742.     });
  743.  
  744.  
  745.     $('.author-collection-view .collection-item-remove').on('click', function(){
  746.         var $this = $(this);
  747.         var _id = $this.data('id');
  748.         var _nonce = $this.data('nonce');
  749.         var _coll = $this.data('coll');
  750.  
  751.         var _confirm = confirm('Remove this item?');
  752.         if (_confirm ){
  753.  
  754.             $(".be-loader").fadeIn("slow");
  755.             $.post(theme_options.ajax_url, { action:'net_edit_coll_remove_item', id:_id, nonce:_nonce, coll:_coll }, function(data){
  756.                 $(".be-loader").fadeOut("fast");
  757.  
  758.                 var _json = $.parseJSON(data);
  759.                 if( typeof _json.result!=='undefined' && _json.result=='yes' ){
  760.                     $this.parents('.author-collection-view').parent().remove();
  761.                 }
  762.                 else{
  763.                     alert('Something wrong, Please check your internet connection and try again.');
  764.                 }
  765.             });
  766.  
  767.         }
  768.  
  769.     });
  770.  
  771.  
  772.  
  773.  
  774.     $(function() {
  775.  
  776.         /*================*/
  777.         /* 01 - VARIABLES */
  778.         /*================*/
  779.         var swipers = [], winW, winH, winScr, _isresponsive, smPoint = 768, mdPoint = 992, lgPoint = 1200, addPoint = 1600, _ismobile = navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i);
  780.  
  781.         /*========================*/
  782.         /* 02 - page calculations */
  783.         /*========================*/
  784.         function pageCalculations(){
  785.             winW = $(window).width();
  786.             winH = $(window).height();
  787.             if($('.menu-button').is(':visible')) _isresponsive = true;
  788.             else _isresponsive = false;
  789.             if(winW <= 992)
  790.                 $(".header-menu").css({"max-height":winH - 20 +  "px"});
  791.         }
  792.  
  793.         /*=================================*/
  794.         /* 03 - function on document ready */
  795.         /*=================================*/
  796.         pageCalculations();
  797.  
  798.         //center all images inside containers
  799.         $('.center-image').each(function(){
  800.             var bgSrc = $(this).attr('src');
  801.             $(this).parent().addClass('background-block').css({'background-image':'url('+bgSrc+')'});
  802.             $(this).hide();
  803.         });
  804.  
  805.         /*============================*/
  806.         /* 04 - function on page load */
  807.         /*============================*/
  808.         $(window).load(function(){
  809.  
  810.             $(".be-loader").fadeOut("slow");
  811.  
  812.             $(".be-loader").addClass('inner-loader');
  813.  
  814.             initSwiper();
  815.             notification();
  816.             // $('.isotope-grid').isotope({
  817.             //  itemSelector: '.isotope-item ',
  818.             //  percentPosition: true
  819.             // });
  820.             setTimeout(function() {
  821.                 $('.tab-wrapper.style-2 .tab-info').addClass('none');
  822.             }, 100);
  823.  
  824.  
  825.  
  826.  
  827.             $('.tabs-content').find('.tab-info').each(function(){
  828.                 var $tab_info = $(this);
  829.                 if( $tab_info.find('.tab-info-viewport').length ){
  830.                     $tab_info.find('.tab-info-viewport > .row').isotope({
  831.                         itemSelector: '.netauthor-item'
  832.                     });
  833.                 }
  834.             });
  835.  
  836.         });
  837.  
  838.         /*==============================*/
  839.         /* 05 - function on page resize */
  840.         /*==============================*/
  841.         $(window).resize(function(){
  842.                 resizeCall();
  843.                 notification();
  844.         });
  845.  
  846.         function resizeCall(){
  847.             pageCalculations();
  848.  
  849.             $('.swiper-container.initialized[data-slides-per-view="responsive"]').each(function(){
  850.                 var thisSwiper = swipers['swiper-'+$(this).attr('id')], $t = $(this), slidesPerViewVar = updateSlidesPerView($t);
  851.                 thisSwiper.params.slidesPerView = slidesPerViewVar;
  852.                 thisSwiper.reInit();
  853.                 var paginationSpan = $t.find('.pagination span');
  854.                 var paginationSlice = paginationSpan.hide().slice(0,(paginationSpan.length+1-slidesPerViewVar));
  855.                 if(paginationSlice.length<=1 || slidesPerViewVar>=$t.find('.swiper-slide').length) $t.addClass('pagination-hidden');
  856.                 else $t.removeClass('pagination-hidden');
  857.                 paginationSlice.show();
  858.                 updateSlidesPerView(this);
  859.             });
  860.                 var a = $(window).height() - 70;
  861.                 $("#one").css("max-height",a + "px");
  862.         }
  863.  
  864.         /*=====================*/
  865.         /* 06 - swiper sliders */
  866.         /*=====================*/
  867.         function initSwiper(){
  868.             var initIterator = 0;
  869.             $('.swiper-container').each(function(){
  870.                 var $t = $(this);
  871.  
  872.                 var index = 'swiper-unique-id-'+initIterator;
  873.  
  874.                 $t.addClass('swiper-'+index + ' initialized').attr('id', index);
  875.                 $t.find('.pagination').addClass('pagination-'+index);
  876.  
  877.                 var autoPlayVar = parseInt($t.attr('data-autoplay'));
  878.                 var centerVar = parseInt($t.attr('data-center'));
  879.                 var simVar = ($t.closest('.circle-description-slide-box').length)?false:true;
  880.  
  881.                 var slidesPerViewVar = $t.attr('data-slides-per-view');
  882.                 if(slidesPerViewVar == 'responsive'){
  883.                     slidesPerViewVar = updateSlidesPerView($t);
  884.                 }
  885.                 else slidesPerViewVar = parseInt(slidesPerViewVar);
  886.  
  887.                 var loopVar = parseInt($t.attr('data-loop'));
  888.                 var speedVar = parseInt($t.attr('data-speed'));
  889.  
  890.                 var slidesPerGroup = parseInt($t.attr('data-slides-per-group'));
  891.                 if(!slidesPerGroup){slidesPerGroup=1;}
  892.  
  893.                 swipers['swiper-'+index] = new Swiper('.swiper-'+index,{
  894.                     speed: speedVar,
  895.                     pagination: '.pagination-'+index,
  896.                     loop: loopVar,
  897.                     paginationClickable: true,
  898.                     autoplay: autoPlayVar,
  899.                     slidesPerView: slidesPerViewVar,
  900.                     slidesPerGroup: slidesPerGroup,
  901.                     keyboardControl: true,
  902.                     calculateHeight: true,
  903.                     simulateTouch: simVar,
  904.                     centeredSlides: centerVar,
  905.                     roundLengths: true,
  906.                     onSlideChangeEnd: function(swiper){
  907.                         var activeIndex = (loopVar===1)?swiper.activeLoopIndex:swiper.activeIndex;
  908.                         var qVal = $t.find('.swiper-slide-active').attr('data-val');
  909.                         $t.find('.swiper-slide[data-val="'+qVal+'"]').addClass('active');
  910.                     },
  911.                     onSlideChangeStart: function(swiper){
  912.                         $t.find('.swiper-slide.active').removeClass('active');
  913.                         if($t.hasClass('thumbnails-preview')){
  914.                             var activeIndex = (loopVar===1)?swiper.activeLoopIndex:swiper.activeIndex;
  915.                             swipers['swiper-'+$t.next().attr('id')].swipeTo(activeIndex);
  916.                             $t.next().find('.current').removeClass('current');
  917.                             $t.next().find('.swiper-slide[data-val="'+activeIndex+'"]').addClass('current');
  918.                         }
  919.                     },
  920.                     onSlideClick: function(swiper){
  921.                         if($t.hasClass('thumbnails')) {
  922.                             swipers['swiper-'+$t.prev().attr('id')].swipeTo(swiper.clickedSlideIndex);
  923.                         }
  924.                     },
  925.                     onResize: function(swiper){
  926.                         var browserWidthResize2 = $(window).width();
  927.                         if (browserWidthResize2 < 750) {
  928.                                 swiper.params.slidesPerGroup=1;
  929.                         } else {
  930.                           swiper.params.slidesPerGroup=slidesPerGroup;
  931.                           swiper.resizeFix(true);
  932.                         }
  933.                     }
  934.                 });
  935.                 swipers['swiper-'+index].reInit();
  936.                 if($t.attr('data-slides-per-view')=='responsive'){
  937.                     var paginationSpan = $t.find('.pagination span');
  938.                     var paginationSlice = paginationSpan.hide().slice(0,(paginationSpan.length+1-slidesPerViewVar));
  939.                     if(paginationSlice.length<=1 || slidesPerViewVar>=$t.find('.swiper-slide').length) $t.addClass('pagination-hidden');
  940.                     else $t.removeClass('pagination-hidden');
  941.                     paginationSlice.show();
  942.                 }
  943.                 initIterator++;
  944.             });
  945.  
  946.         }
  947.  
  948.         function updateSlidesPerView(swiperContainer){
  949.             if(winW>=addPoint) return parseInt($(swiperContainer).attr('data-add-slides'));
  950.             else if(winW>=lgPoint) return parseInt($(swiperContainer).attr('data-lg-slides'));
  951.             else if(winW>=mdPoint) return parseInt($(swiperContainer).attr('data-md-slides'));
  952.             else if(winW>=smPoint) return parseInt($(swiperContainer).attr('data-sm-slides'));
  953.             else return parseInt($(swiperContainer).attr('data-xs-slides'));
  954.             // else return 0;
  955.         }
  956.  
  957.         //swiper arrows
  958.         $('.swiper-arrow-left.be-out').on('click', function(){
  959.             swipers['swiper-'+$(this).parent().parent().find(".swiper-container").attr('id')].swipePrev();
  960.             return false;
  961.         });
  962.  
  963.         $('.swiper-arrow-right.be-out').on('click', function(){
  964.             swipers['swiper-'+$(this).parent().parent().find(".swiper-container").attr('id')].swipeNext();
  965.             return false;
  966.         });
  967.  
  968.         $('.swiper-arrow-left').on('click', function(){
  969.             if(!$(this).hasClass("be-out")) swipers['swiper-'+$(this).parent().attr('id')].swipePrev();
  970.         });
  971.  
  972.         $('.swiper-arrow-right').on('click', function(){
  973.             if(!$(this).hasClass("be-out")) swipers['swiper-'+$(this).parent().attr('id')].swipeNext();
  974.         });
  975.  
  976.         /*==============================*/
  977.         /* 07 - buttons, clicks, hovers */
  978.         /*==============================*/
  979.  
  980.         // central images background
  981.         $('.be-center-image').each(function(){
  982.             var bgSrc = $(this).attr('src');
  983.             $(this).parent().css({'background-image':'url('+bgSrc+')'});
  984.             $(this).hide();
  985.         });
  986.  
  987.  
  988.         /*==============================*/
  989.         /* Top menu */
  990.         /*==============================*/
  991.         $(".cmn-toggle-switch").on("click", function(){
  992.             if ($(this).hasClass("active")){
  993.                 $(this).removeClass("active");
  994.                 $('body').removeClass('menu-open')
  995.             } else{
  996.                 $(this).addClass("active");
  997.                 $('body').addClass('menu-open')
  998.             }
  999.             $(".header-menu").stop().slideToggle();
  1000.             $(".large-popup").slideUp();
  1001.             return false;
  1002.         });
  1003.  
  1004.         $(".header-menu i").on("click", function(){
  1005.             if($(window).width() < 1200){
  1006.                 if ( $(this).hasClass("fa-angle-down") ) {
  1007.                     $(this).removeClass("fa-angle-down");
  1008.                     $(this).addClass("fa-angle-up") ;
  1009.                     $(this).parent().find("ul:first").stop().slideToggle();
  1010.                 }
  1011.                 else {
  1012.                     $(this).removeClass("fa-angle-up");
  1013.                     $(this).addClass("fa-angle-down") ;
  1014.                     $(this).parent().find("ul:first").stop().slideToggle();
  1015.                 }
  1016.             }
  1017.         });
  1018.  
  1019.         /*================================*/
  1020.         /* MOBILE MENU navigation control */
  1021.         /*================================*/
  1022.         $('.header-menu li.menu-item-has-children,.header-menu li.page_item_has_children').each(function(){
  1023.             $(this).append('<span class="sub-menu-indicator"></span>');
  1024.         });
  1025.         $('.sub-menu-indicator').on('click', function(){
  1026.             if($(this).parent().hasClass('expanded')) {
  1027.                 $(this).parent().removeClass('expanded');
  1028.                 $(this).parent().find('>ul').slideUp();
  1029.             } else {
  1030.                 $(this).parent().siblings().removeClass('expanded');
  1031.                 $(this).parent().siblings().find('>ul').slideUp();
  1032.                 $(this).parent().addClass('expanded');
  1033.                 $(this).parent().find('>ul').slideDown();
  1034.             }
  1035.         });
  1036.  
  1037.         if ($(window).width()<992) {
  1038.             $('.header-menu li.menu-item-has-children > a,.header-menu li.page_item_has_children > a').on('click', function(){
  1039.                 if(!$(this).parent().hasClass('expanded')) {
  1040.                     $(this).parent().siblings().removeClass('expanded');
  1041.                     $(this).parent().siblings().find('>ul').slideUp();
  1042.                     $(this).parent().addClass('expanded');
  1043.                     $(this).parent().find('>ul').slideDown();
  1044.                     return false;
  1045.                 }
  1046.             });
  1047.         }
  1048.  
  1049.  
  1050.         /*================================*/
  1051.         /* Add work button */
  1052.         /*================================*/
  1053.         if( netvars.addnew_force_disable=='1' ){
  1054.             if( $('.login-user-down').length ){
  1055.                 $('header .header-menu').append('<li id="ad-work-li"><a id="add-work-btn" class="btn color-1" href="'+netvars.addnew+'">'+netvars.addnew_text+'</a></li>');
  1056.             }
  1057.             else{
  1058.                 if( netvars.addnew_disable!='1' ){
  1059.                     $('header .header-menu').append('<li id="ad-work-li"><a id="add-work-btn" class="btn color-1 btn-login" href="javascript:;">'+netvars.addnew_text+'</a></li>');
  1060.                 }
  1061.             }
  1062.         }
  1063.  
  1064.  
  1065.         $(".filter-block a").on("click", function(){
  1066.             $(".filter-block li").removeClass("be-active");
  1067.             if($(window).width() > 1199){
  1068.                 $(".be-popup").fadeOut();
  1069.                 $(this).parent().find(".be-popup").fadeIn();
  1070.             }
  1071.             else{
  1072.                 $(".be-popup").slideUp();
  1073.                 $(this).parent().find(".be-popup").slideDown();
  1074.             }
  1075.             $(this).parent().addClass("be-active");
  1076.             $(".be-fixed-filter").addClass("active-fixed");
  1077.         });
  1078.         $(".be-fixed-filter, .be-popup .fa").on("click", function(){
  1079.             $(".filter-block li").removeClass("be-active");
  1080.             if($(window).width() > 1199)
  1081.                 $(".be-popup").fadeOut();
  1082.             else
  1083.                 $(".be-popup").slideUp();
  1084.             $(".be-fixed-filter").removeClass("active-fixed");
  1085.         });
  1086.  
  1087.         //
  1088.         $(".color").on("click", function(){
  1089.             $(".color").removeClass("active-color");
  1090.             $(this).addClass("active-color");
  1091.         });
  1092.  
  1093.         $(".be-drop-down").on("click" ,function(){
  1094.             $(this).toggleClass("be-dropdown-active");
  1095.             $(this).find(".drop-down-list").stop().slideToggle();
  1096.         });
  1097.  
  1098.         $('.drop-down-list').each(function(){
  1099.             var $list = $(this);
  1100.             $list.find('a').on('click', function(){
  1101.  
  1102.                 if( !$list.parent().hasClass('login-user-down') ){
  1103.                     $list.parent().find('.be-dropdown-content').text( $(this).text() );
  1104.  
  1105.                     if( typeof $(this).attr('data-id')!=='undefined' ){
  1106.                         $list.parent().find('input').val( $(this).data('id') );
  1107.                         $list.parent().find('input').trigger('change');
  1108.                     }
  1109.                     else{
  1110.                         $list.parent().find('input').val( $(this).text() );
  1111.                         $list.parent().find('input').trigger('change');
  1112.                     }
  1113.                 }
  1114.  
  1115.             });
  1116.         });
  1117.  
  1118.         $('.spoiler-body').hide();
  1119.         $('.spoiler-title').click(function(){
  1120.           // console.log("test");
  1121.           // $('.spoiler-title').hide();
  1122.           if ($('.spoiler-body').hasClass('opened')) {
  1123.             $('.spoiler-body').hide("slow");
  1124.             $('.spoiler-body').removeClass("opened");
  1125.           } else {
  1126.             $('.spoiler-body').show("slow");
  1127.             $('.spoiler-body').addClass("opened");
  1128.           }
  1129.         });
  1130.  
  1131.  
  1132.         //
  1133.         $(document).on('mouseleave', '.be-drop-down.be-dropdown-active', function(){
  1134.             $(this).trigger('click');
  1135.         });
  1136.  
  1137.         $(".login_block .btn-login, #add-work-btn.btn-login").on("click",function(){
  1138.             $(".large-popup.register").slideUp();
  1139.             $(".large-popup.login").slideToggle();
  1140.             return false;
  1141.         });
  1142.  
  1143.         $(".be-signup-link").on("click", function(){
  1144.             $(".large-popup.register").slideUp();
  1145.             $(".large-popup.login").slideDown();
  1146.             return false;
  1147.         });
  1148.         $(".large-popup.login .close-button").on("click", function(){
  1149.             $(".large-popup.login").slideUp();
  1150.         });
  1151.  
  1152.         $(".be-register").on("click",function(){
  1153.             $(".large-popup.login").slideUp();
  1154.             $(".large-popup.register").slideDown();
  1155.             return false;
  1156.         });
  1157.         $(".large-popup.register .close-button").on("click", function(){
  1158.             $(".large-popup.register").slideUp();
  1159.         });
  1160.         $(".btn-share").on("click", function(){
  1161.             $(this).find(".share-buttons").animate({width:'toggle'},350);
  1162.         });
  1163.  
  1164.         $(".btn-message").on("click", function(event){
  1165.             event.stopPropagation();
  1166.  
  1167.             var $tgt=jQuery(event.target);
  1168.  
  1169.             if( $('.msg-popup-window').length ){
  1170.  
  1171.                 if( $('.msg-popup-window').parent().hasClass('btn-message') ){
  1172.                     if( $tgt.is('.close-button') ){
  1173.                         $('.msg-popup-window').slideUp();
  1174.                     }
  1175.                     else{
  1176.                         $('.msg-popup-window').slideDown();
  1177.                     }
  1178.                 }
  1179.                 else{
  1180.                     $('.msg-popup-window').slideDown();
  1181.                     $('.msg-popup-window').off('click').find('.close-button').on('click', function(){
  1182.                         $('.msg-popup-window').slideUp();
  1183.                     });
  1184.                 }
  1185.  
  1186.             }
  1187.             else{
  1188.                 $('.msg-frontend-email').find('input[name="msg_author"]').val( $(this).data('author') );
  1189.                 $('.msg-frontend-email').slideDown();
  1190.                 $('.msg-frontend-email').off('click').find('.close-button').on('click', function(){
  1191.                     $('.msg-frontend-email').slideUp();
  1192.                 });
  1193.             }
  1194.  
  1195.         });
  1196.  
  1197.         $(".btn-rename").on("click", function(event){
  1198.             event.stopPropagation();
  1199.             var $tgt=jQuery(event.target);
  1200.             if ($tgt.is('.close-button') ){
  1201.                   $(this).find(".message-popup").slideUp();
  1202.                 }else{
  1203.                   $(this).find(".message-popup").slideDown();
  1204.                 }
  1205.         });
  1206.  
  1207.         $(".edit-collection").on("click",function(){
  1208.             $(this).find(".c_edit").slideToggle();
  1209.             return false;
  1210.         });
  1211.  
  1212.         //scroll left menu
  1213.        $('#scrollspy').affix({
  1214.             offset: {
  1215.               top: function () { return (this.top = $('#scrollspy').offset().top-85)},
  1216.               bottom: 464
  1217.             }
  1218.         });
  1219.  
  1220.  
  1221.         $(".s_keywords a").eq(0).on("click",function(){
  1222.             $(this).parent().find(".color-6").fadeOut();
  1223.         })
  1224.  
  1225.         $(".s_keywords i").on("click",function(){
  1226.             if($(this).parent().index()!=0)
  1227.                     $(this).parent().fadeOut();
  1228.         })
  1229.  
  1230.         /*notification*/
  1231.         $(".messages-popup").on("click", function(){
  1232.             $(".notofications-block").hide();
  1233.             $(".messages-block").slideToggle();
  1234.             return false;
  1235.         });
  1236.  
  1237.         $(".notofications-popup").on("click", function(){
  1238.             $(".messages-block").hide();
  1239.             $(".notofications-block").slideToggle();
  1240.  
  1241.             $.post(theme_options.ajax_url, {action:'net_check_notification'}, function(data){
  1242.                 if( data=='1' ){
  1243.                     $(".notofications-popup").find('span').hide();
  1244.                 }
  1245.             });
  1246.  
  1247.             return false;
  1248.         });
  1249.  
  1250.  
  1251.         function notification(){
  1252.             $('.noto-body').css("max-height",winH-150);
  1253.         }
  1254.  
  1255.         /*accordion*/
  1256.         $('.accordion').each(function(){
  1257.             $(this).find('.acc-title').on("click", function(){
  1258.                 if($(this).hasClass('active')){
  1259.                     $(this).removeClass('active');
  1260.                     $(this).siblings('.acc-body').slideUp();
  1261.                 } else{
  1262.                     $(this).closest('.accordion').find('.active').removeClass('active');
  1263.                     $(this).closest('.accordion').find('.acc-body').slideUp('slow');
  1264.                     $(this).toggleClass('active');
  1265.                     $(this).siblings('.acc-body').slideToggle('slow');
  1266.                 }
  1267.             });
  1268.         });
  1269.  
  1270.         //statistic counters
  1271.         $('.counter-entry').each(function(){
  1272.             var $this = $(this);
  1273.             $this.viewportChecker({
  1274.                 classToAdd: 'counted',
  1275.                 offset: 100,
  1276.                 callbackFunction: function(elem, action){
  1277.                     $(elem).find('.stat-number').countTo();
  1278.                 }
  1279.             });
  1280.         });
  1281.  
  1282.  
  1283.         //Tabs
  1284.         var tabFinish = 0;
  1285.         $('.nav-tab-item').on('click',  function(){
  1286.             var $t = $(this);
  1287.             if(tabFinish || $t.hasClass('active')) return false;
  1288.             tabFinish = 1;
  1289.             $t.closest('.nav-tab').find('.nav-tab-item').removeClass('active');
  1290.             $t.addClass('active');
  1291.             var index = $t.parent().parent().find('.nav-tab-item').index(this);
  1292.             $t.closest('.tab-wrapper').find('.tab-info:visible').fadeOut(500, function(){
  1293.                 $t.closest('.tab-wrapper').find('.tab-info').eq(index).css('opacity', '0');
  1294.                 $t.closest('.tab-wrapper').find('.tab-info').eq(index).fadeIn(200, function() {
  1295.                     tabFinish = 0;
  1296.                     if( $(this).find('.tab-info-viewport').length ){
  1297.                         $(this).find('.tab-info-viewport > .row').isotope('layout');
  1298.                     }
  1299.                     $(this).animate({ 'opacity':1 }, 200);
  1300.                 });
  1301.             });
  1302.         });
  1303.  
  1304.  
  1305.  
  1306.         $('#btn_load_projects, #btn_load_likes').on('click', function(){
  1307.             var _btn = $(this);
  1308.             var _parent = _btn.parents('.tab-info');
  1309.             var _encrypted = _btn.next();
  1310.             var _type = _btn.hasClass('btn_load_projects') ? 'projects' : 'liked';
  1311.  
  1312.             $(".be-loader").fadeIn("slow");
  1313.             $.post(theme_options.ajax_url, {action: 'net_get_pager_folios', type: 'projects', encrypt_args: _encrypted.html()}, function(data){
  1314.                 var _json = $.parseJSON(data);
  1315.                 if( typeof _json!=='undefined' ){
  1316.                     if( parseInt(_json.count, 10)>0 ){
  1317.                         var _html = $('<div/>').append(_json.result);
  1318.  
  1319.                         _html.imagesLoaded().always( function( instance ) {
  1320.                             _html.find('>div').each(function(){
  1321.                                 _parent.find('.tab-info-viewport > .row').append( $(this) ).isotope( 'appended', $(this) );
  1322.                             });
  1323.                             _parent.find('.tab-info-viewport > .row').isotope('layout');
  1324.                         });
  1325.  
  1326.                         _encrypted.html( _json.args );
  1327.                     }
  1328.                     else{
  1329.                         _btn.hide();
  1330.                     }
  1331.                 }
  1332.  
  1333.                 $(".be-loader").fadeOut("fast");
  1334.             });
  1335.         });
  1336.  
  1337.  
  1338.         $('.select-all').change( function(){
  1339.             if($(this).prop('checked')) {
  1340.                 $(this).closest('form').find('.noto-entry .form-checkbox input').prop('checked',true);
  1341.             } else {
  1342.                 $(this).closest('form').find('.noto-entry .form-checkbox input').prop('checked',false);
  1343.             }
  1344.         });
  1345.  
  1346.  
  1347.         var custom_section_id = 1;
  1348.         $("a.add_section").on("click",function(){
  1349.  
  1350.             $(".creative_filds_block ul").append("<li><a href='#"+custom_section_id+"'>New section</a>");
  1351.             var $csection = $('#tpl-custom-section').clone();
  1352.             $csection.find('.custom-section-block').attr('id', 'cs-' + custom_section_id);
  1353.             $(this).before( $csection.html() );
  1354.  
  1355.             $("#scrollspy li a[href^='#']").on('click', function(e) {
  1356.                e.preventDefault();
  1357.                var hash = this.hash;
  1358.                $('html, body').animate({
  1359.                    scrollTop: $(this.hash).offset().top
  1360.                  }, 1200, function(){
  1361.                    window.location.hash = hash;
  1362.                  });
  1363.                return false;
  1364.             });
  1365.  
  1366.             $(".creative_filds_block ul li:last-child a")[0].trigger('click');
  1367.  
  1368.             $(".close-w").off('click').on("click",function(){
  1369.                 var id = $(this).parent().parent().parent().attr("id");
  1370.                 $(this).parent().parent().parent().fadeOut();
  1371.                 $(".creative_filds_block a").each(function(){
  1372.                     if($(this).attr("href") == "#" + id){
  1373.                         $(this).parent().fadeOut();
  1374.                     }
  1375.                 });
  1376.             });
  1377.             custom_section_id++;
  1378.         });
  1379.  
  1380.         $(".close-w").on("click",function(){
  1381.             var id = $(this).parent().parent().parent().attr("id");
  1382.             $(this).parent().parent().parent().remove();
  1383.             $(".creative_filds_block a").each(function(){
  1384.                 if($(this).attr("href") == "#" + id){
  1385.                     $(this).parent().fadeOut();
  1386.                 }
  1387.             });
  1388.         });
  1389.  
  1390.  
  1391.  
  1392.         $('.m-close').on('click', function() {
  1393.             $('.noto-popup').slideUp();
  1394.         });
  1395.  
  1396.  
  1397.         $('.s-color').on('click', function() {
  1398.                 $('.s-color').removeClass('active');
  1399.                 $(this).addClass('active');
  1400.         });
  1401.  
  1402.  
  1403.         $('.open-custom').on('click', function (e) {
  1404.             e.preventDefault();
  1405.             $(this).next('.inner-filter-info').fadeToggle();
  1406.         });
  1407.  
  1408.  
  1409.  
  1410.  
  1411.         // Navigation Handler
  1412.         $('.en-nav').on('click', function (e) {
  1413.             e.preventDefault();
  1414.             $('.en-nav').removeClass('active');
  1415.             $(this).addClass('active');
  1416.         });
  1417.  
  1418.         // Show Content
  1419.         $('#content-w').on('click', function (e) {
  1420.             $('.cover-popup').add('.setting-popup').fadeOut();
  1421.  
  1422.             $('#tt_frontend_prev').hide();
  1423.             $('#tt_frontend_next').show();
  1424.         });
  1425.  
  1426.         // Cover Popup
  1427.         $('#cover-w').on('click', function (e) {
  1428.             $('.cover-popup').fadeIn();
  1429.             $('.setting-popup').fadeOut();
  1430.  
  1431.             $('html,body').animate({
  1432.                 scrollTop: $('.cover-popup .cover-box').offset().top-100
  1433.             }, 'slow');
  1434.  
  1435.             $('.cover-popup').find('textarea').val( $('#tt_fontend_title').html() );
  1436.             $('.cover-popup').find('.btn-success').off('click').on('click', function(){
  1437.                 $('#tt_fontend_title').html( $('.cover-popup').find('textarea').val() );
  1438.                 $('#setting-w').trigger('click');
  1439.             });
  1440.  
  1441.             $('.cover-popup').find('.btn-cancel').off('click').on('click', function(){
  1442.                 $('#content-w').trigger('click');
  1443.             });
  1444.  
  1445.             $('#tt_frontend_prev').show();
  1446.             $('#tt_frontend_next').show();
  1447.         });
  1448.  
  1449.         // Settings Popup
  1450.         $('#setting-w').on('click', function (e) {
  1451.             $('.cover-popup').fadeOut();
  1452.             $('.setting-popup').fadeIn();
  1453.  
  1454.             $('html,body').animate({
  1455.                 scrollTop: $('.setting-popup .cover-box').offset().top-100
  1456.             }, 'slow');
  1457.  
  1458.             $('.setting-popup').find('.btn-cancel').off('click').on('click', function(){
  1459.                 $('#content-w').trigger('click');
  1460.             });
  1461.  
  1462.             $('.setting-popup').find('.btn-success').off('click').on('click', function(){
  1463.                 $('#tt_frontend_save').trigger('click');
  1464.             });
  1465.  
  1466.  
  1467.  
  1468.             $('#tt_frontend_prev').show();
  1469.             $('#tt_frontend_next').hide();
  1470.         });
  1471.  
  1472.  
  1473.         // Top Navigation
  1474.         $('#tt_frontend_prev').on('click', function(){
  1475.             var _active = $('.editor-nav').find('.en-nav').index( $('.editor-nav').find('.en-nav.active') );
  1476.             if( _active>0 ){
  1477.                 $('.editor-nav').find('.en-nav').eq(_active-1).trigger('click');
  1478.             }
  1479.         });
  1480.         $('#tt_frontend_prev').hide();
  1481.  
  1482.         $('#tt_frontend_next').on('click', function(){
  1483.             var _active = $('.editor-nav').find('.en-nav').index( $('.editor-nav').find('.en-nav.active') );
  1484.             if( _active<2 ){
  1485.                 $('.editor-nav').find('.en-nav').eq(_active+1).trigger('click');
  1486.             }
  1487.         });
  1488.  
  1489.  
  1490.         if( $('#post_id').val()!='' && parseInt($('#post_id').val(), 10)>0 ){
  1491.             $('#tt_frontend_save').show();
  1492.         }
  1493.         else{
  1494.             $('#tt_frontend_save').hide();
  1495.         }
  1496.  
  1497.         // $('.publish').find('.btn-success').off('click').on('click', function() {
  1498.         //  $('#tt_frontend_save').trigger('click');
  1499.         // });
  1500.  
  1501.     $("#publish").click(function () {
  1502.       // console.log("publisj");
  1503.       $('#tt_frontend_save').trigger('click');
  1504.     })
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.         $('#edit-brand, #edit-tools, #edit-copyright').on('click', function(){
  1511.             var $this = $(this);
  1512.  
  1513.             $('.mini-popup-wrapper').fadeOut();
  1514.  
  1515.             $('.extra-popup').find('h3').html( $(this).html().replace('+ ', '') );
  1516.             $('.extra-popup').find('.mini-popup-text').val( $this.parent().find('input').val() );
  1517.             $('.extra-popup').fadeIn();
  1518.  
  1519.             $('.extra-popup').find('button').off('click').on('click', function(){
  1520.                 $this.parent().find('.grey').html( $('.extra-popup').find('.mini-popup-text').val() + ' ...' );
  1521.                 $this.parent().find('input').val( $('.extra-popup').find('.mini-popup-text').val() );
  1522.                 $('.mini-popup-wrapper').fadeOut();
  1523.             });
  1524.         });
  1525.  
  1526.         $('#edit-color').on('click', function(){
  1527.             var $this = $(this);
  1528.             var _cur_val = $this.parent().find('input').val();
  1529.             _cur_val = _cur_val!='' ? '.' + _cur_val : '.no-class';
  1530.  
  1531.             $('.mini-popup-wrapper').fadeOut();
  1532.             $('.color-popup').find('.mini-popup').css('max-width','436px');
  1533.             $('.color-popup').find('.active-color').removeClass('active-color');
  1534.             $('.color-popup').find(_cur_val).addClass('active-color');
  1535.             $('.color-popup').fadeIn();
  1536.  
  1537.             $('.color-popup').find('li.color').off('click').on('click', function(){
  1538.                 var _class = $(this).attr('class');
  1539.                 _class = _class.replace('color filter ', '').replace(' active-color', '');
  1540.                 $this.parent().find('.grey').html( _class + ' <span>...</span>' );
  1541.                 $this.parent().find('.grey').find('span').addClass(_class);
  1542.                 $this.parent().find('input').val( _class );
  1543.                 $('.mini-popup-wrapper').fadeOut();
  1544.             });
  1545.  
  1546.         });
  1547.  
  1548.  
  1549.  
  1550.         $('.close-mini').on('click', function (e) {
  1551.             $(this).closest('.mini-popup-wrapper').fadeOut();
  1552.         });
  1553.  
  1554.         $('.close-media').on('click', function (e) {
  1555.             $('.embed').slideUp();
  1556.         });
  1557.  
  1558.  
  1559.  
  1560.         //MIX UP
  1561.         if($('#container-mix').length) {
  1562.             $('#container-mix').mixItUp(
  1563.                 {
  1564.                     animation: {
  1565.                         duration: 400,
  1566.                         effects: 'fade translateZ(-360px) stagger(34ms)',
  1567.                         easing: 'ease'
  1568.                     }
  1569.                 }
  1570.             );};
  1571.  
  1572.  
  1573.  
  1574.         $('.popup-gallery').length && $('.popup-gallery').magnificPopup({
  1575.             delegate: 'a.popup-a',
  1576.             type: 'image',
  1577.             tLoading: 'Loading image #%curr%...',
  1578.             mainClass: 'mfp-img-mobile',
  1579.             gallery: {
  1580.                 enabled: true,
  1581.                 navigateByImgClick: true,
  1582.                 preload: [0,1] // Will preload 0 - before current, and 1 after the current image
  1583.             },
  1584.             image: {
  1585.                 tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
  1586.                 titleSrc: function(item) {
  1587.                     return item.el.attr('title') + '<small>by Marsel Van Oosten</small>';
  1588.                 }
  1589.             }
  1590.         });
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.         var _embed_tools = '<div class="entry-tools"> \
  1601.                                <a href="javascript:;" class="el-move"><i class="fa fa-arrows"></i></a> \
  1602.                                <a href="javascript:;" class="el-close"><i class="fa fa-close"></i></a> \
  1603.                            </div>';
  1604.  
  1605.  
  1606.         var _embed_tools_handler = function(){
  1607.             $('#tt_frontend_content').find('.tt-el-embed').each(function(){
  1608.                 var $el = $(this);
  1609.                 $el.find('.el-close').on('click', function(){
  1610.                     $el.remove();
  1611.                 });
  1612.             });
  1613.  
  1614.             if( $('#tt_frontend_content').length ){
  1615.                 $('#tt_frontend_content').sortable({
  1616.                     handle: ".el-move",
  1617.                     placeholder: "tt-el-embed-placeholder"
  1618.                 });
  1619.             }
  1620.         };
  1621.  
  1622.  
  1623.         var _build_embed_image = function(){
  1624.             var send_attachment_bkp = wp.media.editor.send.attachment;
  1625.             wp.media.editor.send.attachment = function(props, attachment){
  1626.                 wp.media.editor.send.attachment = send_attachment_bkp;
  1627.  
  1628.                 var _el = '<div class="tt-el-embed tt-el-embed-image has-image"> \
  1629.                                <div class="entry-image"></div> \
  1630.                            </div>';
  1631.                 var $el = $(_el);
  1632.                 $el.append(_embed_tools);
  1633.  
  1634.                 $el.find('.entry-image').html( '<img src="'+attachment.url+'">' );
  1635.                 $el.find('.entry-image').attr('data-img', attachment.id);
  1636.  
  1637.                 $('#tt_frontend_content').append( $el );
  1638.                 _embed_tools_handler();
  1639.             }
  1640.             wp.media.editor.open();
  1641.         };
  1642.  
  1643.  
  1644.         var _build_embed_text = function(_text){
  1645.             var _el = '<div class="tt-el-embed tt-el-embed-text"> \
  1646.                            <div class="entry-text" contenteditable="true"></div> \
  1647.                        </div>';
  1648.             var $el = $(_el);
  1649.             $el.append(_embed_tools);
  1650.             $el.find('.entry-text').html(_text);
  1651.  
  1652.             $('#tt_frontend_content').append( $el );
  1653.             _embed_tools_handler();
  1654.         };
  1655.  
  1656.  
  1657.         var _build_embed_media = function(_embed){
  1658.             var _el = '<div class="tt-el-embed tt-el-embed-media"> \
  1659.                            <div class="entry-embed"></div> \
  1660.                        </div>';
  1661.             var $el = $(_el);
  1662.             $el.append(_embed_tools);
  1663.             $el.find('.entry-embed').html( _embed );
  1664.  
  1665.             $('#tt_frontend_content').append( $el );
  1666.             _embed_tools_handler();
  1667.         };
  1668.  
  1669.  
  1670.  
  1671.         $('.embed_components').find('a.embed_com_image').on('click', function(){
  1672.             _build_embed_image();
  1673.         });
  1674.  
  1675.         $('.embed_components').find('a.embed_com_media').on('click', function(){
  1676.             $('.tpl-embed').slideDown();
  1677.         });
  1678.  
  1679.         $('.embed_components').find('a.embed_com_text').on('click', function(){
  1680.             _build_embed_text('Compellingly redefine timely interfaces vis-a-vis proactive web-readiness. Objectively synthesize impactful markets with client-centric channels. Proactively target granular meta-services via.');
  1681.         });
  1682.  
  1683.  
  1684.         // Embed form button handler
  1685.         $('#submit_embed_media').on('click', function(){
  1686.             // var $txtarea = $(this).parent().find('.main-textarea');
  1687.             // var _html = $txtarea.val();
  1688.             var _html = $('#video_code').val();
  1689.             var $obj = $('<div>').append( $(_html) );
  1690.             if( $obj.find('iframe, object').length ){
  1691.                 _build_embed_media( $obj.html() );
  1692.                 $('.tpl-embed').slideUp();
  1693.             }
  1694.             else{
  1695.                 alert('Invalid embed content!');
  1696.             }
  1697.         });
  1698.  
  1699.  
  1700.  
  1701.         var _custom_styles = {
  1702.             divider: $('.inner-filter-info input[name="divider"]:checked').val(),
  1703.             space: $("#amount").val(),
  1704.             padding: $("#amount-h").val(),
  1705.             color: $('#divider_color').val(),
  1706.             bg: $('#bg_color').val(),
  1707.             text: $('#text_color').val()
  1708.         }
  1709.  
  1710.         var _build_custom_style = function(){
  1711.             if( $('#custom_tag_style').length ){
  1712.                 $('#custom_tag_style').remove();
  1713.             }
  1714.  
  1715.             var _style = '';
  1716.  
  1717.             _style += '#tt_frontend_content .tt-el-embed + .tt-el-embed { \
  1718.                            border-top-width: 1px; \
  1719.                            '+ (_custom_styles.color!='inherit' && _custom_styles.color!='' ? 'border-top-color:'+_custom_styles.color+';' : '') +' \
  1720.                            border-top-style: '+_custom_styles.divider+'; \
  1721.                            margin-top: '+_custom_styles.space+'px; \
  1722.                            padding-top: '+_custom_styles.space+'px; \
  1723.                       } ';
  1724.  
  1725.             _style += '#tt_frontend_content { \
  1726.                            padding-top: '+_custom_styles.padding+'px; \
  1727.                            padding-bottom: '+_custom_styles.padding+'px; \
  1728.                       } ';
  1729.  
  1730.             // background color
  1731.             if( _custom_styles.bg!='inherit' && _custom_styles.bg!='' ){
  1732.                 _style += '#tt_frontend_container { \
  1733.                                background-color: '+_custom_styles.bg+'; \
  1734.                           } ';
  1735.             }
  1736.  
  1737.             // text color
  1738.             if( _custom_styles.text!='inherit' && _custom_styles.text!='' ){
  1739.                 _style += '#tt_frontend_content .tt-el-embed-text .entry-text { \
  1740.                                color: '+_custom_styles.text+'; \
  1741.                           } ';
  1742.             }
  1743.  
  1744.             $('head').append('<style type="text/css" id="custom_tag_style">'+_style+'</style>');
  1745.  
  1746.         };
  1747.  
  1748.  
  1749.         // Divider Options
  1750.         if($('#slider-range-max').length) {
  1751.  
  1752.             $( "#slider-range-max").slider({
  1753.                 range: "max",
  1754.                 min: 0,
  1755.                 max: 100,
  1756.                 value: $("#amount").val(),
  1757.                 slide: function( event, ui ) {
  1758.                     $( "#amount" ).val( ui.value );
  1759.                     _custom_styles.space = ui.value;
  1760.                     _build_custom_style();
  1761.                 }
  1762.             });
  1763.             $( "#amount" ).val( $( "#slider-range-max" ).slider( "value" ) );
  1764.  
  1765.             $( "#slider-head" ).slider({
  1766.                 range: "max",
  1767.                 min: 0,
  1768.                 max: 100,
  1769.                 value: $("#amount-h").val(),
  1770.                 slide: function( event, ui ) {
  1771.                     $( "#amount-h" ).val( ui.value );
  1772.                     _custom_styles.padding = ui.value;
  1773.                     _build_custom_style();
  1774.                 }
  1775.             });
  1776.             $( "#amount-h" ).val( $( "#slider-head" ).slider( "value" ) );
  1777.  
  1778.  
  1779.             // Divider Colors & Types
  1780.             $('.inner-filter-info input[name="divider"]').on('change', function(){
  1781.                 _custom_styles.divider = this.value;
  1782.                 _build_custom_style();
  1783.             });
  1784.  
  1785.             $('.color-i').length && $('.color-i').colorPicker();
  1786.  
  1787.             $('#divider_color').colorPicker();
  1788.             $('#divider_color').on('change', function(){
  1789.                 _custom_styles.color = this.value;
  1790.                 _build_custom_style();
  1791.             });
  1792.  
  1793.             $('#bg_color').colorPicker();
  1794.             $('#bg_color').on('change', function(){
  1795.                 _custom_styles.bg = this.value;
  1796.                 _build_custom_style();
  1797.             });
  1798.  
  1799.             $('#text_color').colorPicker();
  1800.             $('#text_color').on('change', function(){
  1801.                 _custom_styles.text = this.value;
  1802.                 _build_custom_style();
  1803.             });
  1804.  
  1805.  
  1806.         }
  1807.  
  1808.  
  1809.         $('#tt_frontend_cats').each(function(){
  1810.             $(this).select2({
  1811.                 maximumSelectionSize: 3
  1812.             });
  1813.         });
  1814.  
  1815.  
  1816.         // Check content
  1817.         if( $('#tt_frontend_content').find('.tt-el-embed').length<1 ){
  1818.             var _html = $('#tt_frontend_content').html();
  1819.             $('#tt_frontend_content').html('');
  1820.             _build_embed_text(_html);
  1821.         }
  1822.  
  1823.         // Set events for handlers
  1824.         _embed_tools_handler();
  1825.         _build_custom_style();
  1826.  
  1827.  
  1828.         $('.tt-el-embed-image').each(function(){
  1829.             var $el = $(this);
  1830.  
  1831.             $el.find('.browse-media').on('click', function(){
  1832.                 var send_attachment_bkp = wp.media.editor.send.attachment;
  1833.                 wp.media.editor.send.attachment = function(props, attachment){
  1834.                     wp.media.editor.send.attachment = send_attachment_bkp;
  1835.                     $el.find('.entry-image').html( '<img src="'+attachment.url+'">' );
  1836.                     $el.find('.entry-image').attr('data-img', attachment.id);
  1837.                     $el.addClass('has-image');
  1838.                 }
  1839.                 wp.media.editor.open();
  1840.             });
  1841.  
  1842.         });
  1843.  
  1844.  
  1845.         $('.tt-frontend-cover-upload').on('click', function(){
  1846.             var $btn = $(this);
  1847.             var send_attachment_bkp = wp.media.editor.send.attachment;
  1848.             wp.media.editor.send.attachment = function(props, attachment){
  1849.                 wp.media.editor.send.attachment = send_attachment_bkp;
  1850.                 $btn.parent().find('.tt-frontend-cover-img').html( '<img src="'+attachment.url+'">' );
  1851.                 $btn.parent().find('.tt-frontend-cover-img').attr('data-img', attachment.id);
  1852.             }
  1853.             wp.media.editor.open();
  1854.         });
  1855.  
  1856.  
  1857.         // frontend save post
  1858.         $('#tt_frontend_save').on('click', function(){
  1859.  
  1860.             if( typeof $('.tt-frontend-cover-img').data('img')==='undefined' ){
  1861.                 $('#cover-w').trigger('click');
  1862.                 return false;
  1863.             }
  1864.  
  1865.             if( $('#tt_frontend_content').find('.tt-el-embed').length<1 ){
  1866.                 $('#content-w').trigger('click');
  1867.                 return false;
  1868.             }
  1869.  
  1870.             if( $('#tt_frontend_cats').val()==null ){
  1871.                 $('#setting-w').trigger('click');
  1872.                 return false;
  1873.             }
  1874.  
  1875.             var _contents = '';
  1876.  
  1877.             $('#tt_frontend_content').find('.tt-el-embed').each(function(){
  1878.                 var $el = $(this);
  1879.  
  1880.                 if( $el.hasClass('tt-el-embed-image') && $el.hasClass('has-image') ){
  1881.                     _contents += '[tt_image id="'+ $el.find('.entry-image').data('img') +'"]';
  1882.                 }
  1883.                 else if( $el.hasClass('tt-el-embed-text') ){
  1884.                     _contents += '[tt_text]'+ $el.find('.entry-text').html().trim() +'[/tt_text]';
  1885.                 }
  1886.                 else if( $el.hasClass('tt-el-embed-media') ){
  1887.                     _contents += '[tt_embed]'+ $el.find('.entry-embed').html() +'[/tt_embed]';
  1888.                 }
  1889.  
  1890.  
  1891.  
  1892.             });
  1893.  
  1894.             var data_options = {
  1895.                 action: 'net_frontend_content',
  1896.                 post: $('#post_id').val(),
  1897.                 title: $('#tt_fontend_title').val(),
  1898.                 content: _contents,
  1899.                 cover: $('.tt-frontend-cover-img').data('img'),
  1900.                 cats: $('#tt_frontend_cats').val(),
  1901.                 tags: $('#tt_frontend_tags').val(),
  1902.                 desc: $('#tt_frontend_excerpt').val(),
  1903.                 extra: {
  1904.                     brand: $('#tt_extra_brand').val(),
  1905.                     tools: $('#tt_extra_tools').val(),
  1906.                     color: $('#tt_extra_color').val(),
  1907.                     copyright: $('#tt_extra_copyright').val(),
  1908.                     adult: $('#tt_extra_adult:checked').length ? 'adult' : ''
  1909.                 },
  1910.                 custom_styles: _custom_styles
  1911.             }
  1912.  
  1913.  
  1914.             $(".be-loader").fadeIn("slow");
  1915.             $.post(theme_options.ajax_url, data_options, function(response){
  1916.  
  1917.                 if( response!='' && response.indexOf('http')>-1 ){
  1918.                     window.location.href = response;
  1919.                 }
  1920.                 else{
  1921.                     $(".be-loader").fadeOut("slow");
  1922.                     alert('Please check contents and try again!');
  1923.                 }
  1924.             });
  1925.  
  1926.  
  1927.         });
  1928.  
  1929.  
  1930.  
  1931.  
  1932.         // Chart Statistics
  1933.         $('.stat-chartjs').each(function(){
  1934.             var $this = $(this);
  1935.             var $chart = $this.find('.chart-viewport');
  1936.             var $json = $.parseJSON( $this.find('.chart-data').html() );
  1937.  
  1938.             var chart_option = {
  1939.                 title: {
  1940.                     text: $this.find('.chart-data').data('label')
  1941.                 },
  1942.                 animationEnabled: true,
  1943.                 axisY: {
  1944.                     includeZero: false
  1945.                 },
  1946.                 axisX: {
  1947.                     interval: 1
  1948.                 },
  1949.                 data: [
  1950.                     {
  1951.                         type: "spline", //change it to line, area, column, pie, etc
  1952.                         dataPoints: $json
  1953.                     }
  1954.                 ]
  1955.             };
  1956.  
  1957.             $chart.CanvasJSChart(chart_option);
  1958.  
  1959.         });
  1960.  
  1961.  
  1962.  
  1963.  
  1964.         if( $('.single_add_to_cart_button').length ){
  1965.             $('.single_add_to_cart_button').addClass('btn color-1 size-2 hover-1').removeClass('button');
  1966.         }
  1967.         if( $('.woocommerce #review_form #respond .form-submit input').length ){
  1968.             $('.woocommerce #review_form #respond .form-submit input').addClass('btn color-1 size-2 hover-1');
  1969.         }
  1970.  
  1971.  
  1972.  
  1973.     });
  1974.  
  1975.  
  1976. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement