PageRenderTime 33ms CodeModel.GetById 9ms app.highlight 18ms RepoModel.GetById 1ms app.codeStats 0ms

/administrator/components/com_easysocial/themes/default/groups/default.js

https://gitlab.com/vnsoftdev/swc
JavaScript | 118 lines | 92 code | 24 blank | 2 comment | 14 complexity | 3cda722737bd37b2c2306415a463f523 MD5 | raw file
  1EasySocial.require()
  2.script( 'admin/grid/grid' )
  3.done(function($){
  4
  5	// Implement grid item.
  6	$( '[data-table-grid]' ).implement( EasySocial.Controller.Grid );
  7
  8	<?php if( $this->tmpl != 'component' ){ ?>
  9	$.Joomla('submitbutton', function(task) {
 10
 11		var selected = new Array;
 12
 13		$('[data-table-grid]').find('input[name=cid\\[\\]]:checked').each(function(i, el) {
 14			var val = $(el).val();
 15			selected.push(val);
 16		});
 17
 18		if (task == 'makeFeatured' || task == 'removeFeatured') {
 19
 20			$('[data-table-grid-task]').val(task);
 21
 22			$('[data-table-grid]').submit();
 23
 24			return false;
 25		}
 26
 27		if (task == 'create') {
 28			
 29			EasySocial.dialog({
 30				content 	: EasySocial.ajax( 'admin/views/groups/createDialog' , {} ),
 31				bindings	:
 32				{
 33					"{continueButton} click" : function()
 34					{
 35						var categoryId 	= this.category().val();
 36
 37						window.location.href	= '<?php echo rtrim( JURI::root() , '/' );?>/administrator/index.php?option=com_easysocial&view=groups&layout=form&category_id=' + categoryId;
 38
 39						return false;
 40					}
 41				}
 42			});
 43
 44			return false;
 45		}
 46
 47		if( task == 'switchOwner' )
 48		{
 49			EasySocial.dialog(
 50			{
 51				content		: EasySocial.ajax( 'admin/views/groups/switchOwner' , { "ids" : selected } )
 52			});
 53			return false;
 54		}
 55
 56		if( task == 'delete' )
 57		{
 58			EasySocial.dialog(
 59			{
 60				content 	: EasySocial.ajax( 'admin/views/groups/deleteConfirmation' , {} ),
 61				bindings	:
 62				{
 63					"{deleteButton} click" : function()
 64					{
 65						$.Joomla( 'submitform' , [task] );
 66					}
 67				}
 68			})
 69			return false;
 70		}
 71
 72		if (task === 'switchCategory') {
 73			EasySocial.dialog({
 74				content: EasySocial.ajax('admin/views/groups/switchCategory', {
 75					ids: selected
 76				})
 77			});
 78
 79			return false;
 80		}
 81
 82		$.Joomal( 'submitform' , [task] );
 83	});
 84
 85	window.switchOwner	= function( user , groupIds )
 86	{
 87		EasySocial.dialog(
 88		{
 89			content		: EasySocial.ajax( 'admin/views/groups/confirmSwitchOwner' , { "id" : groupIds , "userId" : user.id} ),
 90			bindings 	:
 91			{
 92
 93			}
 94		});
 95	}
 96
 97	<?php } else { ?>
 98		$( '[data-group-insert]' ).on('click', function( event )
 99		{
100			event.preventDefault();
101
102			// Supply all the necessary info to the caller
103			var id 		= $( this ).data( 'id' ),
104				avatar 	= $( this ).data( 'avatar' ),
105				title	= $( this ).data( 'title' ),
106				alias	= $(this).data( 'alias' );
107
108				obj 	= {
109							"id"	: id,
110							"title"	: title,
111							"avatar" : avatar,
112							"alias"	: alias
113						  };
114
115			window.parent["<?php echo JRequest::getCmd( 'jscallback' );?>" ]( obj );
116		});
117	<?php } ?>
118});