<?php
/********************************************************************
 * Copyright (C) 2024 Darko Gjorgjijoski (https://darkog.com/)
 * Copyright (C) 2024 IDEOLOGIX MEDIA Dooel (https://ideologix.com/)
 *
 * This file is property of IDEOLOGIX MEDIA Dooel (https://ideologix.com)
 * This file is part of Vimeify Plugin - https://wordpress.org/plugins/vimeify/
 *
 * Vimeify - Formerly "WP Vimeo Videos" is free software: you can redistribute
 * it and/or modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 2 of the License,
 * or (at your option) any later version.
 *
 * Vimeify - Formerly "WP Vimeo Videos" is distributed in the hope that it
 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this plugin. If not, see <https://www.gnu.org/licenses/>.
 *
 * Code developed by Darko Gjorgjijoski <dg@darkog.com>.
 **********************************************************************/

namespace Vimeify\Core\Frontend;

use Vimeify\Core\Abstracts\BaseProvider;
use Vimeify\Core\Traits\ScriptQueue;

class Scripts extends BaseProvider {

	use ScriptQueue;

	/**
	 * Registers specific piece of functionality
	 * @return void
	 */
	public function register() {
		add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) );
	}

	/**
	 * Register scripts
	 * @return void
	 */
	public function register_scripts() {
		$this->register_styles();
		$this->register_gallery_scripts();
	}

	/**
	 * Register the stylesheets for the public-facing side of the site.
	 *
	 * @since    1.0.0
	 */
	private function register_styles() {
		// Register gallery styles
		$this->register_style(
			'vimeify-gallery',
			'public/frontend/gallery.min.css',
			[],
			'auto'
		);
	}

	/**
	 * Register gallery scripts and localize data
	 *
	 * @return void
	 */
	private function register_gallery_scripts() {
		// Register gallery script (no jQuery dependency)
		$this->register_script(
			'vimeify-gallery',
			'public/frontend/gallery.min.js',
			[],
			'auto',
			true
		);

		// Localize gallery script data for AJAX
		wp_localize_script( 'vimeify-gallery', 'vimeifyGallery', [
			'ajaxUrl' => admin_url( 'admin-ajax.php' ),
			'nonce'   => wp_create_nonce( 'vimeify_gallery_nonce' ),
		] );
	}
}