(function ($) {
	"use strict";
	var WidgetPdfViewer = function ($scope, $) {
		var wrapper = $scope.find( '.ec-pdf-viewer-wrapper' );
		if (wrapper.length) {
			wrapper.each(
				function () {
					var settings = $( this ).data( 'settings' );
					if (settings) {
						var pdfurl   = settings["data-pdfurl"];
						var uid      = settings["data-uid"];
						var fullpage = settings["data-fullpage"];
						if (fullpage != undefined && fullpage == true) {
							PDFObject.embed( pdfurl );
						} else {
							PDFObject.embed( pdfurl, "#" + uid );
						}
					}
				}
			);
		}
	};

	$( window ).on(
		'elementor/frontend/init',
		function () {
			elementorFrontend.hooks.addAction( 'frontend/element_ready/ecafe-pdf-viewer.default', WidgetPdfViewer );
		}
	);
})( jQuery );
