Your IP : 216.73.216.41


Current Path : /home/purehotels/public_html/media/com_easyfolderlistingpro/scripts/
Upload File :
Current File : /home/purehotels/public_html/media/com_easyfolderlistingpro/scripts/eflpJQy.js

/**
* @version		3.0
* @author		Michael A. Gilkes (jaido7@yahoo.com)
* @copyright	Michael Albert Gilkes
* @license		GNU/GPLv3
*

Easy Folder Listing Pro Companion Content Plugin
Copyright (C) 2013-2016 Michael Albert Gilkes (Valor Apps)

This program 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 3 of the License, or
(at your option) any later version.

This program 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 program.  If not, see <http://www.gnu.org/licenses/>.
*/

/**
* These functions REQUIRE jQuery!
*/

/*
* + Check to see if jQuery was loaded!
*/
if (typeof jQuery == 'undefined')
{
	//jQuery is not loaded
	if (console.error)
	{
		console.error("EFLPRO Critical: jQuery is not loaded!");
	}
	else
	{
		alert("EFLPRO Critical: jQuery is not loaded!");
	}
}
else //jQuery is loaded!
{
	function EFLPJQyTable(listname, options) {
		var defaults = {
			speed: 400,
			easing: 'swing',
			transition: 'fadeToggle',
			collapsed: true
		};
		
		this.listname = listname;
		this.options = jQuery.extend({}, defaults, options);
		
		this.setupListing = function() {
			jQuery('#'+this.listname+' tr').each(jQuery.proxy(function(i, row) {
				row = jQuery(row);
				var identity = row.attr('id');
				if (identity && identity != 'undefined') {
					jQuery('#'+this.listname+' tr.child-of-'+identity).each(jQuery.proxy(function(j, childrow){
						childrow = jQuery(childrow);
						if (this.options.collapsed == true) {
							if (this.options.transition == 'fadeToggle') {
								childrow.fadeToggle(this.options.speed, this.options.easing);
							}
							else if (this.options.transition == 'slideToggle') {
								childrow.slideToggle(this.options.speed, this.options.easing);
							}
							else {
								childrow.toggle(this.options.speed, this.options.easing);
							}
						}
					}, this));
					
					if (row.hasClass('trigger')) {
						row.on('click', jQuery.proxy(function(){
							var parent = row.attr('id');
							jQuery('#'+this.listname+' tr.child-of-'+parent).each(jQuery.proxy(function(k, childrow){
								childrow = jQuery(childrow);
								if (childrow.css('display') == 'none')
								{
									if (this.options.transition == 'fadeToggle') {
										childrow.fadeIn(this.options.speed, this.options.easing);
									}
									else if (this.options.transition == 'slideToggle') {
										childrow.slideDown(this.options.speed, this.options.easing);
									}
									else {
										childrow.show(this.options.speed, this.options.easing);
									}
								}
								else
								{
									if (this.options.transition == 'fadeToggle') {
										childrow.fadeOut(this.options.speed, this.options.easing);
									}
									else if (this.options.transition == 'slideToggle') {
										childrow.slideUp(this.options.speed, this.options.easing);
									}
									else {
										childrow.hide(this.options.speed, this.options.easing);
									}
									this.dissolveDescendents(childrow);
								}
							}, this));
						}, this));
						row.on('mouseenter', function() { row.css({'cursor' : 'pointer'}); }).on('mouseleave', function() { row.css({'cursor' : 'default'}); } );
					}
				}
			}, this));
			
			var collapse = jQuery('#'+this.listname+"_collapse");
			var expand = jQuery('#'+this.listname+"_expand");
			if (collapse) {
				if (this.options.collapsed == true) {
					collapse.hide(0);
				}
				collapse.on('click', jQuery.proxy(function(event) {
					event.preventDefault();
					this.collapseAll();
					collapse.hide(0);
					expand.show(0);
				}, this));
			}
			if (expand) {
				if (this.options.collapsed != true) {
					expand.hide(0);
				}
				expand.on('click', jQuery.proxy(function(event) {
					event.preventDefault();
					this.expandAll();
					expand.hide(0);
					collapse.show(0);
				}, this));
			}
		}
		
		this.collapseAll = function() {
			jQuery('#'+this.listname+' tr').each(jQuery.proxy(function(i, row) {
				row = jQuery(row);
				var classlist = row.attr('class');
				if (!classlist || classlist == 'undefined') { classlist=""; }
				var patt = new RegExp("child-of");
				if (patt.test(classlist) == true)
				{
					if (this.options.transition == 'fadeToggle') {
						row.fadeOut(this.options.speed, this.options.easing);
					}
					else if (this.options.transition == 'slideToggle') {
						row.slideUp(this.options.speed, this.options.easing);
					}
					else {
						row.hide(this.options.speed, this.options.easing);
					}
				}
				else
				{
					if (this.options.transition == 'fadeToggle') {
						row.fadeIn(this.options.speed, this.options.easing);
					}
					else if (this.options.transition == 'slideToggle') {
						row.slideDown(this.options.speed, this.options.easing);
					}
					else {
						row.show(this.options.speed, this.options.easing);
					}
				}
			}, this));
		}
		
		this.expandAll = function() {
			jQuery('#'+this.listname+' tr').each(jQuery.proxy(function(i, row) {
				row = jQuery(row);
				if (this.options.transition == 'fadeToggle') {
					row.fadeIn(this.options.speed, this.options.easing);
				}
				else if (this.options.transition == 'slideToggle') {
					row.slideDown(this.options.speed, this.options.easing);
				}
				else {
					row.show(this.options.speed, this.options.easing);
				}
			}, this));
		}
		
		this.dissolveDescendents = function(parent){
			var parent_id = parent.attr('id');
			if (parent_id && parent_id != 'undefined') {
				jQuery('#'+this.listname+' tr.child-of-'+parent_id).each(jQuery.proxy(function(i, child) {
					child = jQuery(child);
					if (child.css('display') != 'none') {
						if (this.options.transition == 'fadeToggle') {
							child.fadeOut(this.options.speed, this.options.easing);
						}
						else if (this.options.transition == 'slideToggle') {
							child.slideUp(this.options.speed, this.options.easing);
						}
						else {
							child.hide(this.options.speed, this.options.easing);
						}
						this.dissolveDescendents(child);
					}
				}, this));
			}
		}
	}
	
	function EFLPJQyList(listname, options) {
		var defaults = {
			speed: 400,
			easing: 'swing',
			transition: 'fadeToggle',
			collapsed: true
		};
		
		this.listname = listname;
		this.options = jQuery.extend({}, defaults, options);
		
		this.setupListing = function(){
			jQuery('#'+this.listname+' li').each(jQuery.proxy(function(i, row) {
				row = jQuery(row);
				var identity = row.attr('id');
				if (identity && identity != 'undefined') {
					jQuery('#'+this.listname+' li.child-of-'+identity).each(jQuery.proxy(function(j, childrow){
						childrow = jQuery(childrow);
						if (this.options.collapsed == true) {
							if (this.options.transition == 'fadeToggle') {
								childrow.fadeToggle(this.options.speed, this.options.easing);
							}
							else if (this.options.transition == 'slideToggle') {
								childrow.slideToggle(this.options.speed, this.options.easing);
							}
							else {
								childrow.toggle(this.options.speed, this.options.easing);
							}
						}
					}, this));
					
					if (row.hasClass('trigger')) {
						row.on('click', jQuery.proxy(function(){
							var parent = row.attr('id');
							jQuery('#'+this.listname+' li.child-of-'+parent).each(jQuery.proxy(function(k, childrow){
								childrow = jQuery(childrow);
								if (childrow.css('display') == 'none')
								{
									if (this.options.transition == 'fadeToggle') {
										childrow.fadeIn(this.options.speed, this.options.easing);
									}
									else if (this.options.transition == 'slideToggle') {
										childrow.slideDown(this.options.speed, this.options.easing);
									}
									else {
										childrow.show(this.options.speed, this.options.easing);
									}
								}
								else
								{
									if (this.options.transition == 'fadeToggle') {
										childrow.fadeOut(this.options.speed, this.options.easing);
									}
									else if (this.options.transition == 'slideToggle') {
										childrow.slideUp(this.options.speed, this.options.easing);
									}
									else {
										childrow.hide(this.options.speed, this.options.easing);
									}
								}
							}, this));
						}, this));
						row.on('mouseenter', function() { row.css({'cursor' : 'pointer'}); }).on('mouseleave', function() { row.css({'cursor' : 'default'}); } );
					}
				}
			}, this));
			
			var collapse = jQuery('#'+this.listname+"_collapse");
			var expand = jQuery('#'+this.listname+"_expand");
			if (collapse) {
				if (this.options.collapsed == true) {
					collapse.hide(0);
				}
				collapse.on('click', jQuery.proxy(function(event) {
					event.preventDefault();
					this.collapseAll();
					collapse.hide(0);
					expand.show(0);
				}, this));
			}
			if (expand) {
				if (this.options.collapsed != true) {
					expand.hide(0);
				}
				expand.on('click', jQuery.proxy(function(event) {
					event.preventDefault();
					this.expandAll();
					expand.hide(0);
					collapse.show(0);
				}, this));
			}
		}
		
		this.collapseAll = function() {
			jQuery('#'+this.listname+' li').each(jQuery.proxy(function(i, row) {
				row = jQuery(row);
				var classlist = row.attr('class');
				if (!classlist) { classlist=""; }
				if (classlist.test('child-of-') == true)
				{
					if (this.options.transition == 'fadeToggle') {
						row.fadeOut(this.options.speed, this.options.easing);
					}
					else if (this.options.transition == 'slideToggle') {
						row.slideUp(this.options.speed, this.options.easing);
					}
					else {
						row.hide(this.options.speed, this.options.easing);
					}
				}
				else
				{
					if (this.options.transition == 'fadeToggle') {
						row.fadeIn(this.options.speed, this.options.easing);
					}
					else if (this.options.transition == 'slideToggle') {
						row.slideDown(this.options.speed, this.options.easing);
					}
					else {
						row.show(this.options.speed, this.options.easing);
					}
				}
			}, this));
		}
		
		this.expandAll = function() {
			jQuery('#'+this.listname+' li').each(jQuery.proxy(function(i, row) {
				row = jQuery(row);
				if (this.options.transition == 'fadeToggle') {
					row.fadeIn(this.options.speed, this.options.easing);
				}
				else if (this.options.transition == 'slideToggle') {
					row.slideDown(this.options.speed, this.options.easing);
				}
				else {
					row.show(this.options.speed, this.options.easing);
				}
			}, this));
		}
	}
	
	function eflp_jqy_pageoptions(idtext, select) {
		var listingData = jQuery('#'+idtext).attr('data-listing');
		var token = jQuery('#'+idtext).attr('data-token');
		var limit = select.options[select.selectedIndex].value;
		var obj = { 'data' : listingData, 'listingId' : idtext, 'pagenumber' : 1, 'pagelimit' : limit , 'token' : token };
		obj[token] = 1;
		jQuery.ajax({
				type : 'POST',
				url : 'index.php?option=com_easyfolderlistingpro&task=pagination.change&format=raw',
				data : obj,
				dataType : 'html',
			}).done(function(code) { 
				jQuery('#'+idtext).parent().html(code);
			});
	}

	function eflp_jqy_pagination(idtext, pagenumber, pagelimit) {
		var listingData = jQuery('#'+idtext).attr('data-listing');
		var token = jQuery('#'+idtext).attr('data-token');
		var obj = { 'data' : listingData, 'listingId' : idtext, 'pagenumber' : pagenumber, 'pagelimit' : pagelimit, 'token' : token };
		obj[token] = 1;
		jQuery.ajax({
			type : 'POST',
			url : 'index.php?option=com_easyfolderlistingpro&task=pagination.change&format=raw',
			data : obj,
			dataType : 'html',
		}).done(function(code) { 
			jQuery('#'+idtext).parent().html(code);
		});
	}

	function eflp_jqy_explore(idtext, status) {
		var listingData = jQuery('#'+idtext).attr('data-listing');
		var token = jQuery('#'+idtext).attr('data-token');
		var obj = { 'data' : listingData, 'listingId' : idtext, 'status' : status , 'token' : token };
		obj[token] = 1;
		jQuery.ajax({
			type : 'POST',
			url : 'index.php?option=com_easyfolderlistingpro&task=explorer.folder&format=raw',
			data : obj,
			dataType : 'html',
		}).done(function(code) { 
			jQuery('#'+idtext).parent().html(code);
		});
	}

	function EFLPJQySearch(listname, textLength, options) {
		var defaults = {
			esc: true,
			wait: 500
		};
		
		this.listname = listname;
		this.textLength = textLength;
		this.timer = null;
		this.options = jQuery.extend({}, defaults, options);
		
		this.setupSearch = function(){
			/* Add the delayed search function */
			var textbox = jQuery('#'+this.listname+'_textbox');
			if (textbox)
			{
				textbox.on('keyup', jQuery.proxy(function(event){
					var text = textbox.val();
					if (text.length > this.textLength)
					{
						if (this.timer != null)
						{
							clearTimeout(this.timer);
						}
				
						this.timer = setTimeout(jQuery.proxy(this.applyFilter(text), this), this.options.wait);
					}
					else if (text.length == 0)
					{
						this.handleFilterCancel();
					}
				}, this));
			}
			/* Add the ESC key event */
			if (textbox)
			{
				textbox.on('keydown', jQuery.proxy(function(e){
					if (e.keyCode == 27 && this.options.esc == true) //esc = 27
					{
						var text = textbox.val();
						if (text.length > 0)
						{
							this.handleFilterCancel();
						}
					}
				}, this));
			}
			/* Add event to the cancel icon */
			var cancelimg = jQuery('#'+this.listname+'_cancelimg');
			if (cancelimg)
			{
				cancelimg.on('click', jQuery.proxy(function(event) {
					this.handleFilterCancel();
				}, this));
			}
		}
		
		this.applyFilter = function(text){
			/* Send the ajax search and display results */
			var listingData = jQuery('#'+this.listname).attr('data-listing');
			var token = jQuery('#'+this.listname).attr('data-token');
			var obj = { 'data' : listingData, 'listingId' : this.listname, 'text' : text };
			obj[token] = 1;
			var req = jQuery.ajax({
				type : 'POST',
				url : 'index.php?option=com_easyfolderlistingpro&task=search.filter&format=raw',
				data : obj,
				dataType : 'html',
			}).done(jQuery.proxy(function(code) { 
				jQuery('#'+this.listname+'_search_results').html(code);
			}, this));
	
			/* Show the cancel button */
			jQuery('#'+this.listname+'_cancelimg').show();
		}
		
		this.handleFilterCancel = function(){
			/* clear the text box */
			jQuery('#'+this.listname+'_textbox').val('');
	
			/* clear the search results */
			jQuery('#'+this.listname+'_search_results').empty();
	
			/* hide the cancel icon */
			jQuery('#'+this.listname+'_cancelimg').hide();
	
			/* return focus to text box */
			jQuery('#'+this.listname+'_textbox').focus();
		}
	}
	
	function EFLPJQyLimits(listname, options) {
		var defaults = {
			totalsize: 0.0,
			totalnumber: 0,
			maxsize: 10.0, /* size in megabytes */
			maxnumber: 10
		};
		
		this.listname = listname;
		this.options = jQuery.extend({}, defaults, options);
		
		this.setupLimits = function(){
			jQuery(document).ready(jQuery.proxy(function() {
				/* hide the limits div */
				jQuery('#'+this.listname+'_multidownload_limits').hide();
		
				/* disable the multidownload button */
				jQuery('#'+this.listname+'_download_button').prop('disabled', true);
			}, this));
		}
		
		this.checkFile = function(elem){
			elem = jQuery(elem);
			var fsize = elem.attr('data-bytes');
			if (elem.prop('checked')) {
				this.options.totalsize += parseFloat(fsize);
				this.options.totalnumber += 1;
				this.checkLimits();
			}
			else {
				this.options.totalsize -= parseFloat(fsize);
				if (this.options.totalsize < 0) { this.options.totalsize = 0.0; }
				this.options.totalnumber -= 1;
				if (this.options.totalnumber < 0) { this.options.totalnumber = 0; }
				this.checkLimits();
			}
		}
		
		this.checkLimits = function(){
			/* update the text */
			var sizetext = (this.options.totalsize / (1024 * 1024));
			sizetext = sizetext.toFixed(2);
	
			jQuery('#'+this.listname+'_totalsize').text(sizetext.toString()+' / '+this.options.maxsize.toString()+' MB');
			jQuery('#'+this.listname+'_totalnumber').text(this.options.totalnumber.toString()+' / '+this.options.maxnumber.toString());
			if (this.options.totalnumber > this.options.maxnumber || this.options.totalsize > (this.options.maxsize * 1024 * 1024))	{
				/* show the limits div */
				jQuery('#'+this.listname+'_multidownload_limits').show();
		
				/* disable the multidownload button */
				jQuery('#'+this.listname+'_download_button').prop("disabled", true);
			}
			else if (this.options.totalnumber == 0) {
				/* hide the limits div */
				jQuery('#'+this.listname+'_multidownload_limits').hide();
		
				/* disable the multidownload button */
				jQuery('#'+this.listname+'_download_button').prop("disabled", true);
			}
			else {
				/* hide the limits div */
				jQuery('#'+this.listname+'_multidownload_limits').hide();
		
				/* enable the multidownload button */
				jQuery('#'+this.listname+'_download_button').prop("disabled", false);
			}
		}
	}
}