Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
8.3 kB
2
Indexable
Never
<div class="col-md-12"><div class="col-md-12" style="text-align: center;"><nav style="color: rgb(113, 89, 72);">
         <ul class="list-unstyled main-menu" style="font-family: &quot;Stalinist One&quot;, cursive; color: rgb(0, 0, 0);">
          <li class="text-right open"><a href="#" id="nav-close" draggable="false"><i class="icon ion-android-close" style="color:#fff"></i></a><br></li>
           <p style="text-align: center; color: rgb(255, 255, 255); line-height: 1; font-weight: bold; font-family: &quot;Stalinist One&quot;, cursive; font-size: 20px;"> <a href="#" title="" draggable="false"><img src="https://phpmysqlappdiag454.blob.core.windows.net/blob/assets/images/koswinery/Asset 1.png" alt="" data-filename="Asset 1.png" style="height: auto; width: 50%;" draggable="false"></a></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><br><p></p></ul><ul class="list-unstyled main-menu"><p style="font-family: &quot;Stalinist One&quot;, cursive; color: rgb(0, 0, 0);"></p>
          
          <li><b><span style="color: rgb(42, 42, 42); font-size: 20px; font-weight: 400;"><a href="#element-LDwYYvu" title="" draggable="false">Winery tour&nbsp;</a></span></b></li><li><b><span style="font-family: lato; color: rgb(42, 42, 42); font-size: 20px; font-weight: 400;"><a href="#element-cAvuKo1" title="" draggable="false">Winery tour - Winetasting</a></span></b></li>
          <li style="font-family: lato; font-size: 20px; color: rgb(42, 42, 42); font-weight: 400;"><a href="#element-jfR1jlw" title="" draggable="false">Experiences</a></li>
          <li style="font-family: lato; font-weight: 400;"><a href="#element-amcfsZ9" title="" draggable="false">Lunch Suggestion</a>&nbsp;</li><li style="font-family: lato; font-weight: 400;"><a href="https://koswinery.workadu.com/el_GR/safety" title="" draggable="false">Safety Rules</a>&nbsp;</li><li style="font-family: &quot;Stalinist One&quot;, cursive; color: rgb(0, 0, 0); font-size: 19px;" class="open"><a id="nav-expander" class="nav-expander fixed" style="display: inline !important;" draggable="false">&nbsp;&nbsp;<i class="fa fa-bars fa-lg white"></i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</a></li></ul></nav>


<script>
  
(function($) {

	"use strict";
	var Plugin = function(el, options, idx) {
		this.el = el;
		this.$el = $(el);
		this.options = options;
		this.uuid = this.$el.attr('id') ? this.$el.attr('id') : idx;
		this.state = {};
		this.init();
		return this;
	};

	Plugin.prototype = {
		init: function() {
			var self = this;
			self._load();
			self.$el.find('ul').each(function(idx) {
				var sub = $(this);
				sub.attr('data-index', idx);
				if (self.options.save && self.state.hasOwnProperty(idx)) {
					sub.parent().addClass(self.options.openClass);
					sub.show();
				} else if (sub.parent().hasClass(self.options.openClass)) {
					sub.show();
					self.state[idx] = 1;
				} else {
					sub.hide();
				}
			});

			if (self.options.caret) {
				self.$el.find("li:has(ul) > a").append(self.options.caret);
			}

			var links = self.$el.find("li > a");
			links.on('click', function(event) {
				event.stopPropagation();
				var sub = $(this).next();
				sub = sub.length > 0 ? sub : false;
				self.options.onClickBefore.call(this, event, sub);
				if (sub) {
					event.preventDefault();
					self._toggle(sub, sub.is(":hidden"));
					self._save();
				} else {
					if (self.options.accordion) {
						var allowed = self.state = self._parents($(this));
						self.$el.find('ul').filter(':visible').each(function() {
							var sub = $(this),
								idx = sub.attr('data-index');

							if (!allowed.hasOwnProperty(idx)) {
								self._toggle(sub, false);
							}
						});
						self._save();
					}
				}
				self.options.onClickAfter.call(this, event, sub);
			});
		},
  
		_toggle: function(sub, open) {
			var self = this,
				idx = sub.attr('data-index'),
				parent = sub.parent();

			self.options.onToggleBefore.call(this, sub, open);
			if (open) {
				parent.addClass(self.options.openClass);
				sub.slideDown(self.options.slide);
				self.state[idx] = 1;

				if (self.options.accordion) {
					var allowed = self.state = self._parents(sub);
					allowed[idx] = self.state[idx] = 1;

					self.$el.find('ul').filter(':visible').each(function() {
						var sub = $(this),
							idx = sub.attr('data-index');

						if (!allowed.hasOwnProperty(idx)) {
							self._toggle(sub, false);
						}
					});
				}
			} else {
				parent.removeClass(self.options.openClass);
				sub.slideUp(self.options.slide);
				self.state[idx] = 0;
			}
			self.options.onToggleAfter.call(this, sub, open);
		},
		
		_parents: function(sub, obj) {
			var result = {},
				parent = sub.parent(),
				parents = parent.parents('ul');

			parents.each(function() {
				var par = $(this),
					idx = par.attr('data-index');

				if (!idx) {
					return false;
				}
				result[idx] = obj ? par : 1;
			});
			return result;
		},
	
		_save: function() {
			if (this.options.save) {
				var save = {};
				for (var key in this.state) {
					if (this.state[key] === 1) {
						save[key] = 1;
					}
				}
				cookie[this.uuid] = this.state = save;
				$.cookie(this.options.cookie.name, JSON.stringify(cookie), this.options.cookie);
			}
		},
		
		_load: function() {
			if (this.options.save) {
				if (cookie === null) {
					var data = $.cookie(this.options.cookie.name);
					cookie = (data) ? JSON.parse(data) : {};
				}
				this.state = cookie.hasOwnProperty(this.uuid) ? cookie[this.uuid] : {};
			}
		},
	
		toggle: function(open) {
			var self = this,
				length = arguments.length;

			if (length <= 1) {
				self.$el.find('ul').each(function() {
					var sub = $(this);
					self._toggle(sub, open);
				});
			} else {
				var idx,
					list = {},
					args = Array.prototype.slice.call(arguments, 1);
				length--;

				for (var i = 0; i < length; i++) {
					idx = args[i];
					var sub = self.$el.find('ul[data-index="' + idx + '"]').first();
					if (sub) {
						list[idx] = sub;
						if (open) {
							var parents = self._parents(sub, true);
							for (var pIdx in parents) {
								if (!list.hasOwnProperty(pIdx)) {
									list[pIdx] = parents[pIdx];
								}
							}
						}
					}
				}

				for (idx in list) {
					self._toggle(list[idx], open);
				}
			}
			self._save();
		},
	
		destroy: function() {
			$.removeData(this.$el);
			this.$el.find("li:has(ul) > a").unbind('click');
		}
	};


	$.fn.navgoco = function(options) {
		if (typeof options === 'string' && options.charAt(0) !== '_' && options !== 'init') {
			var callback = true,
				args = Array.prototype.slice.call(arguments, 1);
		} else {
			options = $.extend({}, $.fn.navgoco.defaults, options || {});
			if (!$.cookie) {
				options.save = false;
			}
		}
		return this.each(function(idx) {
			var $this = $(this),
				obj = $this.data('navgoco');

			if (!obj) {
				obj = new Plugin(this, callback ? $.fn.navgoco.defaults : options, idx);
				$this.data('navgoco', obj);
			}
			if (callback) {
				obj[options].apply(obj, args);
			}
		});
	};

	var cookie = null;

	
	$.fn.navgoco.defaults = {
		caret: '<span class="caret"></span>',
		accordion: false,
		openClass: 'open',
		save: true,
		cookie: {
			name: 'navgoco',
			expires: false,
			path: '/'
		},
		slide: {
			duration: 400,
			easing: 'swing'
		},
		onClickBefore: $.noop,
		onClickAfter: $.noop,
		onToggleBefore: $.noop,
		onToggleAfter: $.noop
	};
})(jQuery);


$(document).ready(function(){												
       
       //Navigation Menu Slider
        $('#nav-expander').on('click',function(e){
      		e.preventDefault();
      		$('body').toggleClass('nav-expanded');
      	});
      	$('#nav-close').on('click',function(e){
      		e.preventDefault();
      		$('body').removeClass('nav-expanded');
      	});
    
        $(".main-menu").navgoco({
            caret: '<span class="caret"></span>',
            accordion: false,
            openClass: 'open',
            save: true,
            cookie: {
                name: 'navgoco',
                expires: false,
                path: '/'
            },
            slide: {
                duration: 300,
                easing: 'swing'
            }
        });
      });
</script></div></div>
Leave a Comment