Location: PHPKode > scripts > Avatar Tools > views/extensions_templates.php
<?php
/**
 * @version		$Id: coolfeed.php 100 2012-04-14 17:42:51Z hide@address.com $
 * @copyright	JoomAvatar.com
 * @author		Nguyen Quang Trung
 * @link		http://joomavatar.com
 * @license		License GNU General Public License version 2 or later http://www.gnu.org/licenses/gpl-2.0.html
 * @package		Avatar Dream Framework Template
 * @facebook 	http://www.facebook.com/pages/JoomAvatar/120705031368683
 * @twitter	    https://twitter.com/#!/JoomAvatar
 * @support 	http://joomavatar.com/forum/
 */

// no direct access
defined('_JEXEC') or die; 
?>
<script type="text/javascript">
	
	jQuery.noConflict();
	
	(function($) 
	{ 
		$(document).ready( function()
		{	
			var searchTemplatesRequest;
			
			$('#avatar-tool-templates-search').keyup(function()
			{
				if (searchTemplatesRequest !== undefined) {
					searchTemplatesRequest.abort();
				}
				
				searchTemplatesRequest = $.ajax({
				  	url: "index.php?option=avatar-tool&controller=ajax&task=templateSearch",
				  	type: "POST",
				  	data: $("#avatar-tool-form-templates").serialize(),
				  	dataType: "json",
				});	
				
				searchTemplatesRequest.done(function(data) 
				{
					var items = $('#avatar-tool-templates-search-results');
					var html = '';
					
				  	data.each(function (el, index)
				  	{
				  		index++;
				  		var location = '';
				  		
				  		if (el.client_id == 1) {
				  			location = '<?php echo JText::_('AVATAR_TOOL_ADMINISTRATOR', true); ?>';
				  		} else {
				  			location = '<?php echo JText::_('AVATAR_TOOL_SITE', true); ?>';
				  		}
				  		
				  		if (el.published == '1') {
				  			publish = 'temp-publish';
				  		} else {
				  			publish = 'temp-unpublish';
				  		}
				  		
				  		html += '<li class="item ' + publish + '">';
				  		html += '<form id="template-'+ el.id +'">';
				  		html += '<input type="hidden" name="id" value="'+ el.id +'">';
				  		html += '<h3 class="title avatar-tool-title">' + index + ' - <span>' + el.title + '</span></h3>';
				  		html += '<input class="avatar-tool-input-title" type="text" name="title" value="'+ $.addslashes(el.title)  +'">';
				  		html += '<div class="details">';
				  		html += '<span class="action template"><strong><?php echo JText::_('AVATAR_TOOL_BUTTON_TEMPLATE'); ?></strong> <span class="text">'+ el.template +'</span></span>';
				  		html += '<span class="action location"><strong><?php echo JText::_('AVATAR_TOOL_BUTTON_LOCATION'); ?></strong> <span class="text">'+ location +'</span></span>';
				  		html += '<span class="action home"><strong><?php echo JText::_('AVATAR_TOOL_BUTTON_HOME'); ?></strong> <span class="text state'+ el.home +'"></span></span>';
				  		html += '<span class="action click assignment"><strong><?php echo JText::_('AVATAR_TOOL_ASSIGNMENT'); ?></strong></span>';
				  		html += '<span style="clear:both;"></span>';
				  		html += '</div>';
				  		html += '<div>';
				  		html += '<span class="avatar-tool-button">';
		  				html += '<a href="index.php?option=com_templates&task=style.edit&id='+ el.id +'"><?php echo JText::_('AVATAR_TOOL_BUTTON_EDIT',true); ?></a>';
		  				html += '</span>';
				  		html += '</div>';	
				  		html += '</form>';
				  		html += '</li>';
				  	})
				  	
				  	items.html(html);
				  	var templateForms = $('#avatar-tool-templates-search-results form');
			
				  	var buttonAssignments = $('#avatar-tool-templates-search-results .details .assignment');
					
				  	buttonAssignments.each(function(index)
				  	{
				  		var bttassignment = $(this);
				  		var itemIndex = index;
				  		
				  		bttassignment.click(function()
				  		{
				  			$('#avatar-tool-subview-assignment').dialog({
				  				width: 800,
				  				modal: true,
				  				title: "<?php echo JText::_('AVATAR_TOOL_VIEW_ASSIGNMENT_TITLE', true) ?>",
				  				buttons: { 
				  					"<?php echo JText::_('AVATAR_TOOL_UPDATE', true); ?>": function() { 
				  						$(this).dialog("close"); 
				  						request = $.ajax({
										  	url: "index.php?option=avatar-tool&controller=ajax&task=templateUpdateAssignment",
										  	type: "POST",
										  	data: $('#avatar-tool-form-assignment').serialize(),
										  	dataType: "json",
										});	
				  					} 
				  				},
				  				zIndex: 900,
				  				open: function(event, ui)
				  				{
				  					request = $.ajax({
									  	url: "index.php?option=avatar-tool&controller=ajax&task=templateGetAssignment",
									  	type: "GET",
									  	data: $('#' + templateForms[index].get('id')).serialize(),
									  	dataType: "json",
									});	
									
									request.done(function(data)
									{
										if ($.isPlainObject(data)) 
										{
											var html = '<div id="avatar-tool-tab-assignment" ><form id="avatar-tool-form-assignment">';
											html += '<input type="hidden" name="template_style_id" value="'+ $.addslashes(data.template_style_id) +'">';
											
											var menus = '';
											var tab = '<ul>';
											var slider = '';
											var strClass = 0;
											var checked = '';
											
											data.menus.each(function(el)
											{
												tab += '<li><a href="#avatar-tool-tab-assignment-'+ el.id +'">'+ el.title +'</a></li>';
												
												slider += '<div id="avatar-tool-tab-assignment-'+ el.id +'">';
												slider += '<span class="avatar-tool-button button-select selectall"><?php echo JText::_('AVATAR_TOOL_BUTTON_SELECT_ALL', true) ?></span>';
												slider += '<span class="avatar-tool-button button-select unselectall"><?php echo JText::_('AVATAR_TOOL_BUTTON_UNSELECT_ALL', true) ?></span><hr/>';
												slider += '<p><ul class="menu-links">';
												
												var count = el.links.length;
												var i = 0;
												
												if (count) 
												{
													el.links.each(function(link)
													{
														if (link.template_style_id == data.template_style_id) {
															checked = 'checked="checked"';
														} else {
															checked = '';
														}
														
														slider += '<li class="menu-link">';
														slider += '<input id="link-' + link.value + '" type="checkbox" name="assigned[]" value="'+ $.addslashes(link.value) +'" '+ checked +'>';
														slider += '<label for="link-' + link.value + '">'+ link.text +'</label>';
														slider += '</li>';
														
														if (count > 10 && ++i == Math.ceil(count/2)) {
															slider += '</ul><ul class="menu-links">';
														}
													});	
												}
												
												slider += '</ul><div style="clear: both;"></div></p></div>';
											});
											
											tab += '</ul>'
											html += tab + slider + '</div></form>';
											
											$('#avatar-tool-subview-assignment').html(html);
											
											$('#avatar-tool-tab-assignment').tabs();
											
											$('#avatar-tool-tab-assignment .ui-tabs-panel .button-select').each(function()
											{
												var parent = $(this).parent();
												
												if($(this).hasClass('selectall')) 
												{
													$(this).click(function(){
														
														$('.menu-link input', parent).each(function(){
															$(this).attr('checked', true);
															$(this).parent().addClass('selected');
														})			
													});
												}
												
												if($(this).hasClass('unselectall')) 
												{
													$(this).click(function() {
														$('.menu-link input', parent).each(function(){
															$(this).attr('checked', false);
															$(this).parent().removeClass('selected');
														})
													});
												}
											});
										}
									})
				  				}
				  			});
				  		});
				  	});
				  });
			});
		});
	})(jQuery);
</script>	
<div class="avatar-view" id="avatar-view-templates">
	<form id="avatar-tool-form-templates" name="avatar-tool-form-templates">
		<ul class="list-item">
			<li class="item">
				<p class="label"><?php echo JText::_('AVATAR_TOOL_TEMPLATES_SEARCH'); ?></p>
				<p class="description"><?php echo JText::_('AVATAR_TOOL_TEMPLATES_SEARCH_DESC') ?></p>
				<input id="avatar-tool-templates-search" size="50" name="search"/>	
				<p class="description"><?php echo JText::_('AVATAR_TOOL_TEMPlATES_SEARCH_OPTIONS_DESC') ?></p>
				<?php echo JText::_('AVATAR_TOOL_LIMIT'); ?> <input type="text" name="search-options[limit]" value="100" size="5"/> &nbsp;&nbsp;
				<br/><br/>
			</li>
		</ul>	
	</form>
	
	<ul id="avatar-tool-templates-search-results" class="list-item">
		
	</ul>	
</div>
Return current item: Avatar Tools