<?php 
/**
 * Ahead WebSoft Technologies Pvt Ltd.
 * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
 * @license    https://www.socialengine.com/policies
*/
?>
<?php $url = $this->viewer()->getIdentity() ? $this->url(array('action'=>'home'), 'user_general', true) : $this->url(array(), 'default', true); ?>

<script>
	function redirectToHome(e){
		let url = "<?php echo $url ?>";
		if(url != window.location.pathname){
			window.proxyLocation.href = url;
		}
	}
</script>
<?php if(!empty($this->viewer()->getIdentity())){ ?>
	<div class="pulse_mobile_menu <?php if(empty($this->viewer()->getIdentity())){ ?>pulse_mobile_menu_guest<?php } else{?>pulse_mobile_menu_user<?php } ?>" >
		<div class="pulse_mobile_menu_inner">
			<ul>
				<li class="menu-item  pulse_mobile_menu_home <?php echo $url == $_SERVER["REQUEST_URI"] ? 'active' : '' ?>"  data-menu="home">
					<a href="javascript:;" onclick="redirectToHome(this);">
						<i><svg fill="currentColor" viewBox="0 0 24 24"><path d="M23.121,9.069,15.536,1.483a5.008,5.008,0,0,0-7.072,0L.879,9.069A2.978,2.978,0,0,0,0,11.19v9.817a3,3,0,0,0,3,3H21a3,3,0,0,0,3-3V11.19A2.978,2.978,0,0,0,23.121,9.069ZM15,22.007H9V18.073a3,3,0,0,1,6,0Zm7-1a1,1,0,0,1-1,1H17V18.073a5,5,0,0,0-10,0v3.934H3a1,1,0,0,1-1-1V11.19a1.008,1.008,0,0,1,.293-.707L9.878,2.9a3.008,3.008,0,0,1,4.244,0l7.585,7.586A1.008,1.008,0,0,1,22,11.19Z"/></svg></i>
					</a>
				</li>

				<?php if(engine_in_array('miniMenu',$this->options) && $this->viewer()->getIdentity()) { ?>
					<li class="menu-item pulse_mobile_menu_meesage" data-menu="message">
						<a href="javascript:void(0);" data-class="notifications_donotclose" id="minimenu_message" onclick="showMessageBox();">
							<i><svg fill="currentColor" viewBox="0 0 24 24"><path d="M19,1H5A5.006,5.006,0,0,0,0,6V18a5.006,5.006,0,0,0,5,5H19a5.006,5.006,0,0,0,5-5V6A5.006,5.006,0,0,0,19,1ZM5,3H19a3,3,0,0,1,2.78,1.887l-7.658,7.659a3.007,3.007,0,0,1-4.244,0L2.22,4.887A3,3,0,0,1,5,3ZM19,21H5a3,3,0,0,1-3-3V7.5L8.464,13.96a5.007,5.007,0,0,0,7.072,0L22,7.5V18A3,3,0,0,1,19,21Z"/></svg></i>
							<?php if($this->message_count && $this->showIcons){ ?>
								<span id="mobile_minimenu_message_count_bubble" class="counts position-absolute badge rounded-pill bg-danger <?php echo $subclass ?>"><?php echo $this->message_count; 
							?></span>
							<?php } ?>
						</a>
					</li>
				<?php } ?>

				<?php if(!empty($this->quickcreate) && engine_count($this->quickcreate) > 0) { ?>
					<li class="menu-item pulse_mobile_menu_dashboard" data-menu="dashboard">
						<a href="javascript:void(0);">
							<i><svg fill="currentColor" viewBox="0 0 24 24"><path d="m12 0a12 12 0 1 0 12 12 12.013 12.013 0 0 0 -12-12zm0 22a10 10 0 1 1 10-10 10.011 10.011 0 0 1 -10 10zm5-10a1 1 0 0 1 -1 1h-3v3a1 1 0 0 1 -2 0v-3h-3a1 1 0 0 1 0-2h3v-3a1 1 0 0 1 2 0v3h3a1 1 0 0 1 1 1z"/></svg></i>
						</a>
					</li>
				<?php } ?>

				<?php if(engine_in_array('miniMenu',$this->options) && $this->viewer()->getIdentity()) { ?>
					<li class="menu-item pulse_mobile_menu_notification"data-menu="notification">
						<a href="javascript:void(0);" onclick="showNotifications();">
							<i><svg fill="currentColor" viewBox="0 0 24 24"><path d="M22.555,13.662l-1.9-6.836A9.321,9.321,0,0,0,2.576,7.3L1.105,13.915A5,5,0,0,0,5.986,20H7.1a5,5,0,0,0,9.8,0h.838a5,5,0,0,0,4.818-6.338ZM12,22a3,3,0,0,1-2.816-2h5.632A3,3,0,0,1,12,22Zm8.126-5.185A2.977,2.977,0,0,1,17.737,18H5.986a3,3,0,0,1-2.928-3.651l1.47-6.616a7.321,7.321,0,0,1,14.2-.372l1.9,6.836A2.977,2.977,0,0,1,20.126,16.815Z"/></svg></i>
							<span id="mobile_updates_toggle" class="counts position-absolute badge rounded-pill bg-danger"></span>
						</a>
					</li>
				<?php } ?>

				<li class="menu-item pulse_mobile_menu_profile" data-menu="profile">
					<a href="javascript:void(0);">
						<?php if(empty($this->viewer->getIdentity())){ ?>
							<i><svg fill="currentColor" viewBox="0 0 24 24"><path d="m12,0C5.383,0,0,5.383,0,12s5.383,12,12,12,12-5.383,12-12S18.617,0,12,0Zm-4,21.164v-.164c0-2.206,1.794-4,4-4s4,1.794,4,4v.164c-1.226.537-2.578.836-4,.836s-2.774-.299-4-.836Zm9.925-1.113c-.456-2.859-2.939-5.051-5.925-5.051s-5.468,2.192-5.925,5.051c-2.47-1.823-4.075-4.753-4.075-8.051C2,6.486,6.486,2,12,2s10,4.486,10,10c0,3.298-1.605,6.228-4.075,8.051Zm-5.925-15.051c-2.206,0-4,1.794-4,4s1.794,4,4,4,4-1.794,4-4-1.794-4-4-4Zm0,6c-1.103,0-2-.897-2-2s.897-2,2-2,2,.897,2,2-.897,2-2,2Z"/></svg></i>
						<?php } else{?>
							<i class="_profile_icon"><?php echo Zend_Registry::get('Zend_View')->itemBackgroundPhoto($this->viewer, 'thumb.icon'); ?></i>
						<?php }; ?>
					</a>
				</li>
			</ul>
		</div>
	</div>
<?php } ?>

<!-- MENU CONTENT PANELS -->
<div class="pulse_mobile_menu_content" id="menu-message">
	<div class="pulse_mobile_menu_content_header">
		<h2><?php echo $this->translate("Messages"); ?></h2>
		<a href="messages/compose" title="<?php echo $this->translate('Compose New Message'); ?>"><i class="icon_add"></i></a>
	</div>
	<div class="pulse_mobile_menu_messages pulse_mobile_menu_content_inner pt-0">
		<ul class="messages_menu" id="mobile_menu_messages">
			<li class="notifications_loading" style="padding:10px;">
				<div class="pulldown_content_loading">
					<div class="pulldown_content_loading_item">
						<div class="circle loading-animation"></div>
						<div class="column">
							<div class="line line1 loading-animation"></div>
							<div class="line line2 loading-animation"></div>
					</div>
					</div>
					<div class="pulldown_content_loading_item">
						<div class="circle loading-animation"></div>
						<div class="column">
							<div class="line line1 loading-animation"></div>
							<div class="line line2 loading-animation"></div>
					</div>
					</div>
					<div class="pulldown_content_loading_item">
						<div class="circle loading-animation"></div>
						<div class="column">
							<div class="line line1 loading-animation"></div>
							<div class="line line2 loading-animation"></div>
					</div>
					</div>
				</div>
			</li>
		</ul>
	</div>
	<div class="pulse_mobile_menu_options">
		<a id="messages_viewall_link" href="<?php echo $this->url(array('action' => 'inbox'), 'messages_general', true) ?>"><?php echo $this->translate("View All Messages") ?></a>
		<a href="javascript:void(0);" id="messages_markread_link" onclick="markAllReadMessages();"><?php echo $this->translate("Mark All Read") ?></a>
	</div>
</div>

<?php if(!empty($this->quickcreate) && engine_count($this->quickcreate) > 0 && $this->viewer->getIdentity()) { ?>
	<div class="pulse_mobile_menu_content" id="menu-dashboard">
		<div class="pulse_mobile_menu_content_header">
			<h2><?php echo $this->translate("Create"); ?></h2>
		</div>
		<div class="pulse_mobile_menu_main pulse_mobile_menu_content_inner pt-0">
			<div class="pulse_mobile_create_menu">
				<?php foreach ($this->quickcreate as $link): ?>
					<?php 
						$explodedString = explode(' ', $link->class);
						$menuName = end($explodedString); 
						$moduleName = str_replace('core_main_', '', $menuName);
						if(strpos($moduleName, 'custom_') !== 0){
							$moduleName = $moduleName.'_main';
						}
					?>
					<div class="pulse_mobile_create_menu_item">
						<a href='<?php echo $link->getHref() ?>' <?php if( $link->get('target') ): ?> target='<?php echo $link->get('target') ?>' <?php endif; ?> >
							<i class="pulse_mobile_create_menu_item_icon <?php echo $link->get('icon') ? $link->get('icon') : 'fa fa-star' ?>"></i>
							<p class="pulse_mobile_create_menu_item_title">
								<?php echo $this->translate($link->getlabel()) ?>
							</p>
						</a>
					</div>
				<?php endforeach; ?>
			</div>
		</div>
	</div>
<?php } ?>

<div class="pulse_mobile_menu_content" id="menu-notification">
	<div class="pulse_mobile_menu_content_header">
		<h2><?php echo $this->translate("Notifications"); ?></h2>
	</div>
	<div class="pulse_mobile_menu_notification pulse_mobile_menu_content_inner pt-0">
		<ul id="mobile_menu_notification">
			<li class="notifications_loading" style="padding:10px;">
				<div class="pulldown_content_loading">
					<div class="pulldown_content_loading_item">
						<div class="circle loading-animation"></div>
						<div class="column">
							<div class="line line1 loading-animation"></div>
							<div class="line line2 loading-animation"></div>
					</div>
					</div>
					<div class="pulldown_content_loading_item">
						<div class="circle loading-animation"></div>
						<div class="column">
							<div class="line line1 loading-animation"></div>
							<div class="line line2 loading-animation"></div>
					</div>
					</div>
					<div class="pulldown_content_loading_item">
						<div class="circle loading-animation"></div>
						<div class="column">
							<div class="line line1 loading-animation"></div>
							<div class="line line2 loading-animation"></div>
					</div>
					</div>
				</div>
			</li>
		</ul>
	</div>
	<div class="pulse_mobile_menu_options">
		<?php echo $this->htmlLink(array('route' => 'default', 'module' => 'activity', 'controller' => 'notifications'), $this->translate('View All Updates'), array('id' => 'notifications_viewall_link')) ?>
		<?php echo $this->htmlLink('javascript:void(0);', $this->translate('Mark All Read'), array('id' => 'notifications_markread_link')) ?>
	</div>
</div>

<div class="pulse_mobile_menu_content <?php if(empty($this->viewer->getIdentity())){ ?>pulse_mobile_profile_menu_guest<?php }?>" id="menu-profile">
	<?php include APPLICATION_PATH . '/application/modules/Pulse/widgets/mobile-menu/_dashboardmenu.tpl'; ?>
</div>

<script>
	document.querySelectorAll('.menu-item').forEach(item => {

		item.addEventListener('click', function(e) {

			const menu = this.getAttribute('data-menu');
			const htmlTag = document.documentElement;
			const target = document.getElementById('menu-' + menu);

			if (menu === 'home') {
				document.querySelectorAll('.pulse_mobile_menu_content').forEach(el => {
					el.style.display = 'none';
				});
				document.querySelectorAll('.menu-item').forEach(el => {
					el.classList.remove('active');
				});
				this.classList.add('active');
				htmlTag.classList.remove('pulse_mobile_menu_open');
				return;
			}

			e.preventDefault();
			const isOpen = target.classList.contains('open');

			document.querySelectorAll('.pulse_mobile_menu_content').forEach(el => {
				el.style.display = 'none';
				el.classList.remove('open');
			});

			document.querySelectorAll('.menu-item').forEach(el => {
				el.classList.remove('active');
			});

			if (isOpen) {
				htmlTag.classList.remove('pulse_mobile_menu_open');
				return;
			}

			this.classList.add('active');
			target.style.display = 'flex';
			target.classList.add('open');

			htmlTag.classList.add('pulse_mobile_menu_open');

		});

	});
</script>