wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.js
/**
	 * Initialize a repeater
	 * 
	 * @param $this Can be an .InputfieldRepeater or an .InputfieldRepeaterItem
	 * 
	 */
Initialize a repeater

@param $this Can be an .InputfieldRepeater or an .InputfieldRepeaterItem
Initialize a repeater @param $this Can be an . InputfieldRepeater or an . InputfieldRepeaterItem
function initRepeater($this) {
		var $inputfields, $inputfieldRepeater, isItem;
		if($this.hasClass('InputfieldRepeaterItem')) {
			$inputfields = $this;
			$inputfieldRepeater = $this.closest('.InputfieldRepeater');
			isItem = true;
		} else {
			$inputfields = $this.find('.Inputfields:eq(0)');
			$inputfieldRepeater = $this;
			isItem = false;
		}
		if($inputfields.hasClass('InputfieldRepeaterInit')) return;
		var renderValueMode = $inputfields.closest('.InputfieldRenderValueMode').length > 0;
		$inputfields.addClass('InputfieldRepeaterInit');
		if(isItem) {
			initHeaders($this.children('.InputfieldHeader'), $inputfieldRepeater, renderValueMode);
		} else {
			initHeaders($(".InputfieldRepeaterItem > .InputfieldHeader", $this), $inputfieldRepeater, renderValueMode);
		}
		if(renderValueMode) {
			initDepths($inputfieldRepeater);
			return;
		}
		$(".InputfieldRepeaterTrash", $this).hover(function() {
			var $label = $(this).closest('label');
			if(!$label.parents().hasClass('InputfieldRepeaterDeletePending')) $label.addClass('ui-state-error');
			$label.find('.InputfieldRepeaterItemControls').css('background-color', $label.css('background-color'));
		}, function() {
			var $label = $(this).closest('label');
			if(!$label.parent().hasClass('InputfieldRepeaterDeletePending')) $label.removeClass('ui-state-error');
			$label.find('.InputfieldRepeaterItemControls').css('background-color', $label.css('background-color'));
		});
		if(isItem) $inputfields = $inputfieldRepeater.find('.Inputfields:eq(0)');
		initSortable($inputfieldRepeater, $inputfields);
		$(".InputfieldRepeaterAddLink:not(.InputfieldRepeaterAddLinkInit)", $inputfieldRepeater)
			.addClass('InputfieldRepeaterAddLinkInit')
			.click(eventAddLinkClick);
		if($inputfieldRepeater.hasClass('InputfieldRepeaterMax')) {
			checkMinMax($inputfieldRepeater);
		}
	}
function initRepeater ( $this ) { var $inputfields , $inputfieldRepeater , isItem ; if ( $this . hasClass ( 'InputfieldRepeaterItem' ) ) { $inputfields = $this ; $inputfieldRepeater = $this . closest ( '.InputfieldRepeater' ) ; isItem = true ; } else { $inputfields = $this . find ( '.Inputfields:eq(0)' ) ; $inputfieldRepeater = $this ; isItem = false ; } if ( $inputfields . hasClass ( 'InputfieldRepeaterInit' ) ) return ; var renderValueMode = $inputfields . closest ( '.InputfieldRenderValueMode' ) . length > 0 ; $inputfields . addClass ( 'InputfieldRepeaterInit' ) ; if ( isItem ) { initHeaders ( $this . children ( '.InputfieldHeader' ) , $inputfieldRepeater , renderValueMode ) ; } else { initHeaders ( $ ( ".InputfieldRepeaterItem > .InputfieldHeader" , $this ) , $inputfieldRepeater , renderValueMode ) ; } if ( renderValueMode ) { initDepths ( $inputfieldRepeater ) ; return ; } $ ( ".InputfieldRepeaterTrash" , $this ) . hover ( function ( ) { var $label = $ ( this ) . closest ( 'label' ) ; if ( ! $label . parents ( ) . hasClass ( 'InputfieldRepeaterDeletePending' ) ) $label . addClass ( 'ui-state-error' ) ; $label . find ( '.InputfieldRepeaterItemControls' ) . css ( 'background-color' , $label . css ( 'background-color' ) ) ; } , function ( ) { var $label = $ ( this ) . closest ( 'label' ) ; if ( ! $label . parent ( ) . hasClass ( 'InputfieldRepeaterDeletePending' ) ) $label . removeClass ( 'ui-state-error' ) ; $label . find ( '.InputfieldRepeaterItemControls' ) . css ( 'background-color' , $label . css ( 'background-color' ) ) ; } ) ; if ( isItem ) $inputfields = $inputfieldRepeater . find ( '.Inputfields:eq(0)' ) ; initSortable ( $inputfieldRepeater , $inputfields ) ; $ ( ".InputfieldRepeaterAddLink:not(.InputfieldRepeaterAddLinkInit)" , $inputfieldRepeater ) . addClass ( 'InputfieldRepeaterAddLinkInit' ) . click ( eventAddLinkClick ) ; if ( $inputfieldRepeater . hasClass ( 'InputfieldRepeaterMax' ) ) { checkMinMax ( $inputfieldRepeater ) ; } }
Initialize a repeater
Initialize a repeater
// single repeater item // enter repeater //$("input.InputfieldRepeaterDelete", $this).parents('.InputfieldCheckbox').hide(); // nothing further needed if only rendering the value // hovering the trash gives a preview of what clicking it would do // if we only init'd a single item, now make $inputfields refer to all repeater items for sortable init // setup the sortable // setup the add links // check for maximum items