Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*global control_settings*/
  2.  
  3. /**
  4.  * File customizer_sections_order.js
  5.  *
  6.  * The main file for sections order.
  7.  */
  8.  
  9. jQuery(document).ready(function(){
  10.     'use strict';
  11.  
  12.     var sections_container = control_settings.sections_container;
  13.     var blocked_items = control_settings.blocked_items;
  14.     var saved_data_input = control_settings.saved_data_input;
  15.  
  16.     jQuery( sections_container ).sortable({
  17.         items: '> li:not(.panel-meta, '+ blocked_items +')',
  18.         update: function(){
  19.             update_order();
  20.         },
  21.         placeholder: "ui-state-highlight"
  22.     });
  23.  
  24.     function update_order(){
  25.         var values = {};
  26.         var idsInOrder = jQuery( sections_container ).sortable({
  27.             items: '> li:not(.panel-meta, '+ blocked_items +')',
  28.             placeholder: "ui-state-highlight"
  29.         });
  30.         var sections = idsInOrder.sortable('toArray');
  31.         for(var i = 0; i < sections.length; i++){
  32.             var section_id =  sections[i].replace('accordion-section-','');
  33.             values[section_id] = (i+2)*5;
  34.         }
  35.         var data_to_send = JSON.stringify(values);
  36.         jQuery(saved_data_input).val(data_to_send);
  37.         jQuery(saved_data_input).trigger('change');
  38.     }
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement