Fixed Sitemap Toggle
This commit is contained in:
		
							parent
							
								
									7ef2dacf00
								
							
						
					
					
						commit
						5c8a57e700
					
				| 
						 | 
				
			
			@ -1,13 +1,13 @@
 | 
			
		|||
<li>
 | 
			
		||||
<li class="map-block <%= 'disabled' if !sitemap_block.show_in_sitemap_for(temp_locale) %>">
 | 
			
		||||
  <h6>
 | 
			
		||||
    <input type="checkbox" class="toggle-check" data-deploy="right">
 | 
			
		||||
    <input type="checkbox" id="<%= sitemap_block.id %>" class="toggle-check onoff" temp_locale="<%= temp_locale %>" data-deploy="right">
 | 
			
		||||
    <span><%= sitemap_block_counter + 1 %> <%= sitemap_block.title_translations[temp_locale] %></span>
 | 
			
		||||
  </h6>
 | 
			
		||||
  <ul>
 | 
			
		||||
    <% sitemap_block.children.each_with_index do |child, i| %>
 | 
			
		||||
      <li "<%= 'disabled' if !child.show_in_sitemap_for(temp_locale)  %>">
 | 
			
		||||
      <li "clear <%= 'disabled' if !child.show_in_sitemap_for(temp_locale)  %>">
 | 
			
		||||
        <h6>
 | 
			
		||||
          <input type="checkbox" class="toggle-check" data-deploy="right">
 | 
			
		||||
          <input type="checkbox" id="<%= child.id %>" class="toggle-check onoff" temp_locale="<%= temp_locale %>" data-deploy="right">
 | 
			
		||||
          <span><%= "#{sitemap_block_counter + 1}-#{i + 1}" %> <%= child.title_translations[temp_locale] %></span>
 | 
			
		||||
        </h6>
 | 
			
		||||
      </li>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,3 +37,44 @@
 | 
			
		|||
        </div>         
 | 
			
		||||
      </div>
 | 
			
		||||
    </section>
 | 
			
		||||
 | 
			
		||||
    <% content_for :page_specific_javascript do %>
 | 
			
		||||
    <script>
 | 
			
		||||
      $(document).ready(function(){
 | 
			
		||||
        $('.site-map').masonry({
 | 
			
		||||
        itemSelector: '.map-block',
 | 
			
		||||
        columnWidth: 260
 | 
			
		||||
      });
 | 
			
		||||
      $('a[data-toggle="tab"]').on('shown', function (e) {
 | 
			
		||||
          $('.site-map').masonry({
 | 
			
		||||
              itemSelector: '.map-block',
 | 
			
		||||
              columnWidth: 260
 | 
			
		||||
          });
 | 
			
		||||
        })
 | 
			
		||||
      });
 | 
			
		||||
      $(document).on('click', 'li .onoff', function () {
 | 
			
		||||
          $(this).parents("li").toggleClass("disabled");
 | 
			
		||||
          if($(this).parents("li").attr("class").indexOf("disabled") > 0){
 | 
			
		||||
            $(this).text("<%= t('off_upcase') %>")
 | 
			
		||||
          } else {
 | 
			
		||||
            $(this).text("<%= t('on_upcase') %>")
 | 
			
		||||
          }
 | 
			
		||||
          $.getScript('<%= admin_sites_path %>' + '/' + $(this).attr('id') + '/sitemap_toggle?temp_locale=' + $(this).attr('temp_locale'));
 | 
			
		||||
        });
 | 
			
		||||
        $(document).on('click', 'h4 .onoff', function () {
 | 
			
		||||
          $(this).parents(".map-block").toggleClass("disabled");
 | 
			
		||||
          if($(this).parents("h4").parents("li").attr("class").indexOf("disabled") > 0){
 | 
			
		||||
            $(this).text("<%= t('off_upcase') %>")
 | 
			
		||||
            $(this).parents(".map-block").find('li').addClass('disabled')
 | 
			
		||||
            $(this).parents(".map-block").find('button').text("<%= t('off_upcase') %>")
 | 
			
		||||
            $(this).parents(".map-block").find('li button').attr('disabled', 'disabled')
 | 
			
		||||
          } else {
 | 
			
		||||
            $(this).text("<%= t('on_upcase') %>")
 | 
			
		||||
            $(this).parents(".map-block").find('li').removeClass('disabled')
 | 
			
		||||
            $(this).parents(".map-block").find('button').text("<%= t('on_upcase') %>")
 | 
			
		||||
            $(this).parents(".map-block").find('li button').removeAttr("disabled")
 | 
			
		||||
          }
 | 
			
		||||
          $.getScript('<%= admin_sites_path %>' + '/' + $(this).attr('id') + '/sitemap_toggle?parent=true&temp_locale=' + $(this).attr('temp_locale'));
 | 
			
		||||
        });
 | 
			
		||||
     </script>
 | 
			
		||||
    <% end %>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue