<?php
/**
 * Class for invoking wp_enqueue_scripts action
 * in a single place.
 *
 * This is done this way so themer can easily
 * queue scripts and styles.
 *
 * The ordering of calling loadAsset or wp_enqueue_script
 * will also reorder the queueing of the particular styles
 * providing no other plugin or modules altering the queue
 * after this class.
 *
 *
 * @author jason.xie@victheme.com
 *
 */
class VTCore_Zeus_Actions_Wp__Enqueue__Scripts
extends VTCore_Wordpress_Models_Hook {

  public function hook() {

    // Core scripts, cannot be disabled!
    $enqueueArgs = array(
      'deps' => 'jquery',
      'footer' => true,
    );

    VTCore_Wordpress_init::getFactory('assets')
      ->get('queues')
      ->add('jquery-aspect-ratio', $enqueueArgs)
      ->add('jquery-easing', $enqueueArgs)
      ->add('bootstrap', $enqueueArgs)
      ->add('font-awesome', $enqueueArgs)
      ->add('jquery-resizeend', $enqueueArgs)
      ->add('jquery-totop', $enqueueArgs)
      ->add('jquery-viewport', $enqueueArgs)
      ->add('jquery-verticalcenter', $enqueueArgs)
      ->add('css-animation', $enqueueArgs)
      ->add('jquery-smoothscroll', $enqueueArgs)
      ->add('timeline-front', $enqueueArgs)
      ->add('jquery-knob-skins', $enqueueArgs)
    ;




    // Load animsition
    if (VTCore_Zeus_Utility::getOption('animsition', 'enable')) {
      VTCore_Wordpress_Utility::loadAsset('jquery-animsition');
    }

    // Only load headline assets if headline is enabled
    if (defined('VTCORE_HEADLINE_LOADED')) {
      VTCore_Wordpress_Utility::loadAsset('jquery-videobg');
      VTCore_Wordpress_Utility::loadAsset('headline-front');
    }

    // Only load slick assets if enabled
    if (VTCore_Zeus_Utility::getOption('menu', 'enable_slick')) {
      VTCore_Wordpress_Utility::loadAsset('jquery-slicknav');
    }

    // Only load sticky header assets if enabled
    if (VTCore_Zeus_Utility::getOption('menu', 'enable_sticky')) {
      VTCore_Wordpress_Utility::loadAsset('jquery-hcsticky');
    }

    // Load the controller javascript and main theme css
    VTCore_Wordpress_Utility::loadAsset('theme');

    // Remove theme responsive css when user dont want responsive
    if (VTCore_Zeus_Utility::getOption('page', 'responsive') == 'bs-fixed') {
      VTCore_Wordpress_init::getFactory('assets')
        ->get('queues')
        ->remove('theme.css.theme-responsive-css');
    }

    // Load the active schema extra css
    VTCore_Wordpress_init::getFactory('assets')
      ->get('queues')
      ->add(VTCore_Zeus_Utility::getActiveSchema(), $enqueueArgs);


    VTCore_Wordpress_Init::getFactory('assets')
      ->get('library')

      // Nuke default bootstrap styling
      ->remove('bootstrap.css.bootstrap-theme-css')

      // Note: the style name must be any previously registered css!
      // Load the dynamic style last to override other CSS.
      ->add('theme.css.style-css.inline.schema', VTCore_Zeus_Utility::getSchemaCSS())

      // Load user custom css
      ->add('theme.css.style-css.inline.custom', get_theme_mod('custom_css', ''));

    // Allow user to create custom.css or custom.js file
    // and get loaded automatically.
    VTCore_Wordpress_init::getFactory('assets')
      ->get('queues')
      ->add('custom', $enqueueArgs);

    // Don't Proceed any further if no VicTheme Headline plugin is enabled.
    if (defined('VTCORE_HEADLINE_LOADED')) {
      $instance = VTCore_Headline_Utility::getHeadline();
      if (VTCore_Headline_Utility::checkEnabled('general', $instance)) {
        $inlineStyle = VTCore_Headline_Utility::getMaskingCSS($instance) . VTCore_Headline_Utility::getBackgroundCSS($instance);
        VTCore_Wordpress_Init::getFactory('assets')
          ->get('library')
          ->add('theme.css.style-css.inline.headline', $inlineStyle);
      }
    }


  }
}