(function ($) {
  'use strict'

  function toggleSetup () {
    /* Toggle Setup --------------------- */
    $('.organic-widgets-toggles .organic-widgets-trigger').on('click', function () {
      $(this).toggleClass('active').next().fadeToggle('slow')
    })
    /* Tab Setup --------------------- */
    $('.organic-widgets-tabs').tabs()
    /* Accordion Setup --------------------- */
    $('.organic-widgets-accordion').accordion({
      collapsible: true,
      heightStyle: 'content'
    })
  }

  // On Window Load, Bind Functions
  $(window).on('load', function () {
    // Check for customizer and listen for changes that require rebindings.
    if (typeof wp.customize !== 'undefined') {
      wp.customize.selectiveRefresh.bind('partial-content-rendered', function () {
        toggleSetup()
      })
    }
  })

  $(window).on('load', toggleSetup)

})(jQuery)
