{extends file=$smarty.const.SMARTY_LAYOUT_MAIN_GENERAL_PAGINATED_LISTING}

{block name="js" append}
	<script type="text/javascript">
		MVC.scheduleOnLoad(function(){

			MVC.listing.prototype.moveUpCurrentItem = function(element){
				this.backend_callUpdateOperation('moveUp', {
					'listing[selection][add][]':	this.getItemId(element),
					'listing[selection][clear]' :	'all'
				});
			}

			MVC.listing.prototype.moveDownCurrentItem= function(element){
				this.backend_callUpdateOperation('moveDown', {
					'listing[selection][add][]':	this.getItemId(element),
					'listing[selection][clear]' :	'all'
				});
			}
			
			MVC.listing.prototype.moveUpSelected = function(button){
				this.backend_callUpdateOperation('moveUp', null, button);
			}

			MVC.listing.prototype.moveDownSelected= function(button){
				this.backend_callUpdateOperation('moveDown', null, button);
			}
			
			MVC.listing.prototype.setDefaultCurrentItem= function(element){
				this.backend_callUpdateOperation('setDefault', {
					'listing[selection][add][]':	this.getItemId(element),
					'listing[selection][clear]' :	'all'
				});
			}
			
			MVC.listing.prototype.unsetDefaultCurrentItem= function(element){
				this.backend_callUpdateOperation('unsetDefault', {
					'listing[selection][add][]':	this.getItemId(element),
					'listing[selection][clear]' :	'all'
				});
			}

			MVC.listing.prototype.blockCurrentItemWithConfirmation = function(element){
				MVC.callbackWithConfirmation(
					"{$lang['block']['title']}",
					"{$lang['block']['confirmation']}",
					this.backend_callUpdateOperation.bind(this, 'block', {
						'listing[selection][add][]':	this.getItemId(element),
						'listing[selection][clear]' :	'all'
					})
				);
			}
			
			MVC.listing.prototype.blockSelected = function(button){
				MVC.callbackWithConfirmation(
					"{$lang['bulkBlock']['title']}",
					"{$lang['bulkBlock']['confirmation']}",
					this.backend_callUpdateOperation.bind(this, 'block', null, button)
				);
			}
			
			MVC.listing.prototype.unblockSelected = function(button){
				MVC.callbackWithConfirmation(
					"{$lang['bulkUnblock']['title']}",
					"{$lang['bulkUnblock']['confirmation']}",
					this.backend_callUpdateOperation.bind(this, 'unblock', null, button)
				);
			}
			
			MVC.listing.prototype.unblockCurrentItemWithConfirmation = function(element){
				MVC.callbackWithConfirmation(
					"{$lang['unblock']['title']}",
					"{$lang['unblock']['confirmation']}",
					this.backend_callUpdateOperation.bind(this, 'unblock', {
						'listing[selection][add][]':	this.getItemId(element),
						'listing[selection][clear]' :	'all'
					})
				);
			}

			MVC.listing.prototype.resetWithConfirmation = function(element) {
				MVC.callbackWithConfirmation(
					"{$lang['reset']['title']}",
					"{$lang['reset']['confirmation']}",
					this.backend_callUpdateOperation.bind(this, 'reset', {	})
				);
			}

			MVC.listing.prototype.saveWithConfirmation = function(element) {
				MVC.callbackWithConfirmation(
					"{$lang['save']['title']}",
					"{$lang['save']['confirmation']}",
					this.backend_callUpdateOperation.bind(this, 'save', { })
				);
			}

		});
	</script>
{/block}
