Advertisement
vaibhavsharma56

Testing Template

May 21st, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.84 KB | None | 0 0
  1. <?php
  2. /**
  3. * The template for displaying all pages
  4. * Template Name: testing
  5. */
  6.  
  7. get_header(); ?>
  8. <span class='successMessage'>Success</span><br/>
  9. <span class='errorMessage'>Error</span><br/>
  10. <span class='processing'>Processing .. Please Wait ... </span><br/>
  11.            
  12. <div class="container" style='margin-top:100px'>
  13.  
  14.   <!--div class="VailuLine">THE COMPLETION OF THIS COURSE <span>0%</span></div-->
  15.   <div class="CollapseBox">
  16.     <div class="row">
  17.  
  18.         <!----------------- Show all categories --------------------------->
  19.         <div class='' id='allCategories'>
  20.        
  21.         <?php
  22.             $user_id = get_current_user_id();
  23.             $meta_key_val = get_user_meta($user_id, 'cats');
  24.             if(is_array($meta_key_val)){ p($meta_key_val);
  25.                 foreach($meta_key_val[0] as $catId){
  26.                     //p($catId);
  27.                     //global $catId;
  28.                     get_template_part( 'content', 'new-category' );
  29.                 }
  30.             }
  31.         ?>
  32.        
  33.         </div>
  34.         <!----------------- Add new category ------------------------------>
  35.         <form name='categories_create' id='categories_create' method='post'>
  36.            
  37.             <input name='addCatText' id='addCatText' class='hide' >
  38.             <span class='errorMsg'></span><br/>
  39.            
  40.             <a class="addCat" id='addCat' href="javascript:void(0)">ADD new category</a>
  41.        
  42.         </form>
  43.        
  44.  
  45.         <script>
  46.            
  47.             jQuery().ready(function($){
  48.            
  49.             // Fire Messages
  50.                 function flash(msg,mType){
  51.                     if(typeof mType !='undefined' && mType == 'success'){
  52.                         $('.successMessage').html(msg).slideDown();
  53.                         setTimeout(function(){ $('.successMessage').slideUp(); },3000);
  54.                     }
  55.                     else if(typeof mType !='undefined' && mType == 'error'){
  56.                         $('.errorMessage').html(msg).slideDown();
  57.                         setTimeout(function(){ $('.errorMessage').slideUp(); },3000);
  58.                     }
  59.                 }
  60.                
  61.                 // Add New Category
  62.                     $('#addCat').click(function(){
  63.                         if($('#addCatText').is(':visible')){
  64.                             $('#categories_create').submit();
  65.                         }else{
  66.                             $('#addCatText').slideDown().removeClass('hide');
  67.                         }
  68.                     });
  69.                     // Submit category form
  70.                     $('#categories_create').submit(function(){
  71.                        
  72.                        
  73.                             if($('#addCatText').val()==''){
  74.                                 $('#addCatText').next('span.errorMsg').html('Please fill category name.');
  75.                                 flash('Please fill category name.','error');
  76.                             }else{
  77.                                 $('#addCatText').next('span.errorMsg').html('');
  78.                                 var addCatText = $("#addCatText").val();
  79.                                 $.ajax({
  80.                                     type: 'POST',   // Adding Post method
  81.                                     url: my_js_data.ajaxurl, // Including ajax file
  82.                                     data: {"action": my_js_data.action, "addCatText":addCatText}, // Sending data dname to post_word_count function.
  83.                                     beforeSend: function(){
  84.                                         $('.processing').show();
  85.                                     },
  86.                                     success: function(data){ // Show returned data using the function.
  87.                                         $('.processing').fadeOut();
  88.                                         console.log(data);
  89.                                         var allData = $.parseJSON(data);
  90.                                         flash(allData.msg,allData.result);
  91.                                         //newlyAddedCategory(allData.newCategoryId,allData.newCategoryName)
  92.                                        
  93.                                     }
  94.                                 });
  95.                             }
  96.                        
  97.                         return false;
  98.                     });
  99.                    
  100.                
  101.            
  102.             });
  103.         </script>
  104.  
  105.         </div>
  106.     </div>
  107. </div>
  108. <style>
  109. .hide{ display:none; }
  110. .errorMsg{ color:red; }
  111. .successMessage {background: #fdc73b none repeat scroll 0 0;color: #000;font-size: 25px;height: 60px;opacity: 0.95;padding-top: 10px;position: fixed;text-align: center;top: 0;width: 100%;z-index: 999999; display:none}
  112. .errorMessage {background: #ff1125 none repeat scroll 0 0;color: #fff;font-size: 25px;height: 60px;opacity: 0.95;padding-top: 10px;position: fixed;text-align: center;top: 0;width: 100%;z-index: 999999; display:none}
  113. .processing {background: #a6a3b1 none repeat scroll 0 0;color: #fff;font-size: 25px;height: 60px;opacity: 0.95;padding-top: 10px;position: fixed;text-align: center;top: 0;width: 100%;z-index: 999999; display:none}
  114. </style>
  115. <?php
  116. get_footer();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement