init
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
{{#if params.label}}
|
||||
<p>
|
||||
<label>{{ params.label }}{{#if params.required}} *{{/if}}</label>
|
||||
</p>
|
||||
{{/if}}
|
||||
{{#ifCond params.date_type "==" "year_month_day"}}
|
||||
{{#unless params.date_format}}
|
||||
{{> _settings_date_months }}
|
||||
{{> _settings_date_days }}
|
||||
{{> _settings_date_years }}
|
||||
{{/unless}}
|
||||
{{#ifCond params.date_format "==" "MM/DD/YYYY"}}
|
||||
{{> _settings_date_months }}
|
||||
{{> _settings_date_days }}
|
||||
{{> _settings_date_years }}
|
||||
{{/ifCond}}
|
||||
{{#ifCond params.date_format "==" "DD/MM/YYYY"}}
|
||||
{{> _settings_date_days }}
|
||||
{{> _settings_date_months }}
|
||||
{{> _settings_date_years }}
|
||||
{{/ifCond}}
|
||||
{{#ifCond params.date_format "==" "YYYY/MM/DD"}}
|
||||
{{> _settings_date_years }}
|
||||
{{> _settings_date_months }}
|
||||
{{> _settings_date_days }}
|
||||
{{/ifCond}}
|
||||
{{/ifCond}}
|
||||
|
||||
{{#ifCond params.date_type "==" "year_month"}}
|
||||
{{#unless params.date_format}}
|
||||
{{> _settings_date_months }}
|
||||
{{> _settings_date_years }}
|
||||
{{/unless}}
|
||||
{{#ifCond params.date_format "==" "MM/YYYY"}}
|
||||
{{> _settings_date_months }}
|
||||
{{> _settings_date_years }}
|
||||
{{/ifCond}}
|
||||
{{#ifCond params.date_format "==" "YYYY/MM"}}
|
||||
{{> _settings_date_years }}
|
||||
{{> _settings_date_months }}
|
||||
{{/ifCond}}
|
||||
{{/ifCond}}
|
||||
|
||||
{{#ifCond params.date_type "==" "year"}}
|
||||
{{> _settings_date_years }}
|
||||
{{/ifCond}}
|
||||
|
||||
{{#ifCond params.date_type "==" "month"}}
|
||||
{{> _settings_date_months }}
|
||||
{{/ifCond}}
|
||||
@@ -0,0 +1,11 @@
|
||||
<% set currentDay = 'now' | date('d') | number_format %>
|
||||
<select id="{{ id }}_days">
|
||||
<option value=""><%= __('Day') %></option>
|
||||
<% for day in 1..31 %>
|
||||
<option
|
||||
<% if(currentDay == day) %>
|
||||
{{#if params.is_default_today}}selected="selected"{{/if}}
|
||||
<% endif %>
|
||||
><%= day %></option>
|
||||
<% endfor %>
|
||||
</select>
|
||||
@@ -0,0 +1,13 @@
|
||||
<% set currentMonth = 'now'|date('n') %>
|
||||
<select id="{{ id }}_months">
|
||||
<option value=""><%= __('Month') %></option>
|
||||
<% for month in 1..12 %>
|
||||
<option
|
||||
<% if(currentMonth == month) %>
|
||||
{{#if params.is_default_today}}selected="selected"{{/if}}
|
||||
<% endif %>
|
||||
>
|
||||
<%= month_names[month - 1] %>
|
||||
</option>
|
||||
<% endfor %>
|
||||
</select>
|
||||
@@ -0,0 +1,13 @@
|
||||
<% set currentYear = "now"|date("Y") %>
|
||||
<% set minYear = currentYear - 100 %>
|
||||
|
||||
<select id="{{ id }}_years">
|
||||
<option value=""><%= __('Year') %></option>
|
||||
<% for year in currentYear..minYear %>
|
||||
<option
|
||||
<% if(currentYear == year) %>
|
||||
{{#if params.is_default_today}}selected="selected"{{/if}}
|
||||
<% endif %>
|
||||
><%= year %></option>
|
||||
<% endfor %>
|
||||
</select>
|
||||
@@ -0,0 +1 @@
|
||||
<?php
|
||||
@@ -0,0 +1 @@
|
||||
<?php
|
||||
@@ -0,0 +1,23 @@
|
||||
<p class="clearfix">
|
||||
<label><%= __("Preselect today's date:") %></label>
|
||||
<span class="group">
|
||||
<label>
|
||||
<input
|
||||
class="mailpoet_radio"
|
||||
type="radio"
|
||||
name="params[is_default_today]"
|
||||
value="1"
|
||||
{{#if params.is_default_today}}checked="checked"{{/if}}
|
||||
/><%= __('Yes') %>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
class="mailpoet_radio"
|
||||
type="radio"
|
||||
name="params[is_default_today]"
|
||||
value=""
|
||||
{{#unless params.is_default_today}}checked="checked"{{/unless}}
|
||||
/><%= __('No') %>
|
||||
</label>
|
||||
</span>
|
||||
</p>
|
||||
@@ -0,0 +1,23 @@
|
||||
<% for date_type, formats in date_formats %>
|
||||
{{#ifCond params.date_type "===" "<%= date_type %>"}}
|
||||
<% if(formats | length == 1) %>
|
||||
<!-- display format as hidden value -->
|
||||
<input type="hidden" name="params[date_format]" value="<%= formats[0] %>" />
|
||||
<% else %>
|
||||
<!-- display label -->
|
||||
<p class="clearfix">
|
||||
<label><%= __('Order') %></label>
|
||||
<!-- display all possible date formats -->
|
||||
<select name="params[date_format]">
|
||||
<% for format in formats %>
|
||||
<option
|
||||
{{#ifCond params.date_format "===" "<%= format %>"}}
|
||||
selected="selected"
|
||||
{{/ifCond}}
|
||||
value="<%= format %>"><%= format %></option>
|
||||
<% endfor %>
|
||||
</select>
|
||||
</p>
|
||||
<% endif %>
|
||||
{{/ifCond}}
|
||||
<% endfor %>
|
||||
@@ -0,0 +1,28 @@
|
||||
<p class="clearfix">
|
||||
<label><%= __('Type of date') %></label>
|
||||
<select name="params[date_type]">
|
||||
<% for type, label in date_types %>
|
||||
<option
|
||||
{{#ifCond params.date_type "==" "<%= type %>"}}
|
||||
selected="selected"
|
||||
{{/ifCond}}
|
||||
data-format="<%= date_formats[type][0] %>" value="<%= type %>"
|
||||
><%= label %></option>
|
||||
<% endfor %>
|
||||
</select>
|
||||
<input type="hidden" name="params[date_format]" value="" />
|
||||
</p>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$('select[name="params[date_type]"]').on('change', function() {
|
||||
// set default date format depending on date type
|
||||
$('input[name="params[date_format]"]')
|
||||
.val($(this)
|
||||
.find('option:selected')
|
||||
.data('format'));
|
||||
});
|
||||
// set default format
|
||||
$('select[name="params[date_type]"]').trigger('change');
|
||||
});
|
||||
<{{!}}/script>
|
||||
@@ -0,0 +1,77 @@
|
||||
<form id="form_field_settings" name="form_field_settings" action="" method="post">
|
||||
{{#ifCond type 'in' 'submit'}}
|
||||
{{> _settings_label }}
|
||||
{{/ifCond}}
|
||||
|
||||
{{#ifCond type '==' 'text'}}
|
||||
{{> _settings_label }}
|
||||
{{> _settings_label_within }}
|
||||
{{#ifCond id 'in' 'first_name,last_name' }}
|
||||
{{> _settings_required }}
|
||||
{{/ifCond}}
|
||||
{{/ifCond}}
|
||||
|
||||
{{#ifCond type '==' 'textarea'}}
|
||||
{{> _settings_label }}
|
||||
{{> _settings_label_within }}
|
||||
|
||||
<p class="clearfix">
|
||||
<label><%= __('Number of lines:') %></label>
|
||||
<select name="params[lines]">
|
||||
<% for i in 1..5 %>
|
||||
<option value="<%= i %>"
|
||||
{{#ifCond params.lines '==' <%= i %>}}selected="selected"{{/ifCond}}
|
||||
><%= _n('1 line', '%d lines', i) | format(i) %></option>
|
||||
<% endfor %>
|
||||
</select>
|
||||
</p>
|
||||
{{/ifCond}}
|
||||
|
||||
{{#ifCond type 'in' 'checkbox,radio'}}
|
||||
{{> _settings_label }}
|
||||
{{/ifCond}}
|
||||
|
||||
{{#ifCond type '==' 'segment'}}
|
||||
{{> _settings_label }}
|
||||
{{> _settings_segment_selection }}
|
||||
{{/ifCond}}
|
||||
|
||||
{{#ifCond type '==' 'select'}}
|
||||
{{> _settings_label }}
|
||||
{{> _settings_label_within }}
|
||||
{{/ifCond}}
|
||||
|
||||
{{#ifCond type '==' 'date'}}
|
||||
{{> _settings_label }}
|
||||
{{> _settings_date_default }}
|
||||
{{> _settings_date_format }}
|
||||
{{/ifCond}}
|
||||
|
||||
{{#ifCond type '==' 'html'}}
|
||||
<textarea name="params[text]" class="mailpoet_form_field_settings_text">{{ params.text }}</textarea>
|
||||
<p class="clearfix">
|
||||
<label>
|
||||
<input type="hidden" name="params[nl2br]" value="0" />
|
||||
<input
|
||||
class="mailpoet_checkbox"
|
||||
type="checkbox"
|
||||
name="params[nl2br]"
|
||||
{{#ifCond params.nl2br ">" 0}}checked="checked"{{/ifCond}}
|
||||
value="1"
|
||||
/> <%= __('Automatically add paragraphs') %>
|
||||
</label>
|
||||
</p>
|
||||
{{/ifCond}}
|
||||
|
||||
{{> _settings_submit }}
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$(document).on('submit', '#form_field_settings', function(e) {
|
||||
// trigger callback
|
||||
MailPoet.Modal.success();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
<{{!}}/script>
|
||||
@@ -0,0 +1,96 @@
|
||||
|
||||
<form
|
||||
id="form_field_new"
|
||||
name="form_field_new"
|
||||
action=""
|
||||
method="post"
|
||||
data-parsley-validate="true"
|
||||
>
|
||||
{{#if id}}<input type="hidden" id="field_id" name="id" value="{{ id }}" />{{/if}}
|
||||
<p>
|
||||
<label for="field_type"><%= __('Select a field type:') %></label>
|
||||
<select
|
||||
id="field_type"
|
||||
name="type"
|
||||
data-parsley-required="true"
|
||||
data-parsley-required-message="<%= __('Please specify a type.') %>"
|
||||
>
|
||||
<option value="">--</option>
|
||||
<option
|
||||
{{#ifCond type '==' 'text'}}selected="selected"{{/ifCond}}
|
||||
value="text"><%= __('Text Input') %>
|
||||
</option>
|
||||
<option
|
||||
{{#ifCond type '==' 'textarea'}}selected="selected"{{/ifCond}}
|
||||
value="textarea"><%= __('Text Area') %>
|
||||
</option>
|
||||
<option
|
||||
{{#ifCond type '==' 'radio'}}selected="selected"{{/ifCond}}
|
||||
value="radio"><%= __('Radio buttons') %>
|
||||
</option>
|
||||
<option
|
||||
{{#ifCond type '==' 'checkbox'}}selected="selected"{{/ifCond}}
|
||||
value="checkbox"><%= __('Checkbox') %>
|
||||
</option>
|
||||
<option
|
||||
{{#ifCond type '==' 'select'}}selected="selected"{{/ifCond}}
|
||||
value="select"><%= _x('Select', 'Form input type') %>
|
||||
</option>
|
||||
<option
|
||||
{{#ifCond type '==' 'date'}}selected="selected"{{/ifCond}}
|
||||
value="date"><%= __('Date') %>
|
||||
</option>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="field_name"><%= __("Field name:") %></label>
|
||||
<input
|
||||
id="field_name"
|
||||
type="text"
|
||||
name="name"
|
||||
value="{{ name }}"
|
||||
data-parsley-required="true"
|
||||
data-parsley-required-message="<%= __('Please specify a name.') %>"
|
||||
/>
|
||||
</p>
|
||||
<hr />
|
||||
|
||||
<div class="field_type_form"></div>
|
||||
|
||||
<p class="mailpoet_align_right">
|
||||
<input type="submit" value="<%= __('Done') %>" class="button-primary" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
|
||||
$(function() {
|
||||
loadFieldForm();
|
||||
});
|
||||
|
||||
$('#form_field_new #field_type').on('change', function() {
|
||||
loadFieldForm($(this).val());
|
||||
});
|
||||
|
||||
function loadFieldForm(type) {
|
||||
type = (type === undefined) ? $('#form_field_new #field_type').val() : type;
|
||||
if(type !== '') {
|
||||
var template = Handlebars.compile($('#form_template_field_'+type).html()),
|
||||
data = {type: type},
|
||||
field_id = $('#form_field_new #field_id').val();
|
||||
|
||||
if(field_id !== undefined && field_id.length > 0) {
|
||||
var params = $('.mailpoet_form_field[wysija_id="'+field_id+'"]').attr('wysija_params');
|
||||
if(params !== undefined) {
|
||||
data.params = JSON.parse(params);
|
||||
}
|
||||
}
|
||||
// render field template
|
||||
$('#form_field_new .field_type_form').html(template(data));
|
||||
} else {
|
||||
$('#form_field_new .field_type_form').html('');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1 @@
|
||||
<?php
|
||||
@@ -0,0 +1,4 @@
|
||||
<p class="clearfix">
|
||||
<label for="label"><%= __('Label:') %></label>
|
||||
<input id="label" type="text" name="params[label]" value="{{ params.label }}" />
|
||||
</p>
|
||||
@@ -0,0 +1,11 @@
|
||||
<p class="clearfix">
|
||||
<label><%= __('Display label within input:') %></label>
|
||||
<span class="group">
|
||||
<label>
|
||||
<input class="mailpoet_radio" type="radio" name="params[label_within]" value="1" {{#if params.label_within}}checked="checked"{{/if}} /><%= __('Yes') %>
|
||||
</label>
|
||||
<label>
|
||||
<input class="mailpoet_radio" type="radio" name="params[label_within]" value="" {{#unless params.label_within}}checked="checked"{{/unless}} /><%= __('No') %>
|
||||
</label>
|
||||
</span>
|
||||
</p>
|
||||
@@ -0,0 +1,20 @@
|
||||
<p class="clearfix">
|
||||
<label><%= __('Is this field mandatory?') %></label>
|
||||
<span class="group">
|
||||
<label>
|
||||
<input type="radio"
|
||||
class="mailpoet_radio"
|
||||
name="params[required]"
|
||||
value="1"
|
||||
{{#if params.required}}checked="checked"{{/if}} /><%= __('Yes') %>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
class="mailpoet_radio"
|
||||
type="radio"
|
||||
name="params[required]"
|
||||
value=""
|
||||
{{#unless params.required}}checked="checked"{{/unless}} /><%= __('No') %>
|
||||
</label>
|
||||
</span>
|
||||
</p>
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
<ul id="mailpoet_segment_selection" class="clearfix"></ul>
|
||||
|
||||
<div id="mailpoet_segment_available_container">
|
||||
<h3><%= __('Select the list that you want to add:') %></h3>
|
||||
|
||||
<select class="mailpoet_segment_available"></select>
|
||||
|
||||
<a href="javascript:;" class="mailpoet_segment_add"><span><%= __('Add') %></span></a>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
<% autoescape false %>
|
||||
var selected_segments = {{#if params.values}}{{{ json_encode params.values }}}
|
||||
{{else}}[]{{/if}};
|
||||
<% endautoescape %>
|
||||
|
||||
$(function() {
|
||||
mailpoet_segment_available_render();
|
||||
mailpoet_segment_selection_render();
|
||||
|
||||
setInputNames();
|
||||
|
||||
// add segment
|
||||
$('.mailpoet_segment_add').on('click', function() {
|
||||
// add currently selected segment to the selection
|
||||
var selected_segment = $('.mailpoet_segment_available :selected');
|
||||
|
||||
// add segment to selection
|
||||
selected_segments.push({
|
||||
id: selected_segment.val(),
|
||||
name: selected_segment.text(),
|
||||
is_checked: 0
|
||||
});
|
||||
|
||||
// remove segment from available segments
|
||||
selected_segment.remove();
|
||||
|
||||
// render selection
|
||||
mailpoet_segment_selection_render();
|
||||
|
||||
setInputNames();
|
||||
});
|
||||
|
||||
// remove segment
|
||||
$('#mailpoet_segment_selection').on('click', '.remove', function(e) {
|
||||
if($('#mailpoet_segment_selection').children().length === 1) {
|
||||
return e.preventDefault();
|
||||
}
|
||||
var element = $(this).parents('li');
|
||||
// remove currently selected segment to the selection
|
||||
var selected_segment = parseInt(element.data('segment'), 10);
|
||||
|
||||
// remove segment from selection
|
||||
selected_segments = selected_segments.filter(function(segment) {
|
||||
return (parseInt(segment.id, 10) !== selected_segment);
|
||||
});
|
||||
|
||||
// remove element
|
||||
element.remove();
|
||||
|
||||
// render available segment
|
||||
mailpoet_segment_available_render();
|
||||
|
||||
setInputNames();
|
||||
});
|
||||
});
|
||||
|
||||
function setupSortableSegments() {
|
||||
// make segment selection sortable
|
||||
Sortable.create('mailpoet_segment_selection', {
|
||||
handles: $$('#mailpoet_segment_selection .handle'),
|
||||
onChange: function(item) {
|
||||
setInputNames();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function mailpoet_segment_available_render() {
|
||||
// clear available segments
|
||||
$('.mailpoet_segment_available').html('');
|
||||
|
||||
var selected_segment_ids = selected_segments.map(function(segment) {
|
||||
return segment.id;
|
||||
});
|
||||
|
||||
// display available segments
|
||||
$.each(mailpoet_segments, function(i, segment) {
|
||||
if($.inArray(segment.id, selected_segment_ids) < 0) {
|
||||
$('.mailpoet_segment_available').append(
|
||||
'<option value="'+segment.id+'">'+segment.name+'</option>'
|
||||
);
|
||||
}
|
||||
});
|
||||
mailpoet_segment_available_toggle();
|
||||
}
|
||||
|
||||
function mailpoet_segment_selection_render() {
|
||||
// segment item template
|
||||
var template = Handlebars.compile(
|
||||
$('#field_settings_segment_selection_item').html()
|
||||
);
|
||||
|
||||
// update view
|
||||
$('#mailpoet_segment_selection').html(
|
||||
template({ segments: selected_segments })
|
||||
);
|
||||
|
||||
mailpoet_segment_available_toggle();
|
||||
}
|
||||
|
||||
function mailpoet_segment_available_toggle() {
|
||||
// toggle visibility of available segments
|
||||
if($('.mailpoet_segment_available option').length === 0) {
|
||||
$('#mailpoet_segment_available_container').hide();
|
||||
} else {
|
||||
$('#mailpoet_segment_available_container').show();
|
||||
}
|
||||
}
|
||||
|
||||
function setInputNames() {
|
||||
$('#mailpoet_segment_selection li').each(function(index, item) {
|
||||
$(item).find('.mailpoet_is_checked').attr('name', 'params[values]['+index+'][is_checked]');
|
||||
$(item).find('.mailpoet_segment_id').attr('name', 'params[values]['+index+'][id]');
|
||||
$(item).find('.mailpoet_segment_name').attr('name', 'params[values]['+index+'][name]');
|
||||
});
|
||||
setupSortableSegments();
|
||||
}
|
||||
});
|
||||
<{{!}}/script>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
{{#each segments}}
|
||||
<li data-segment="{{ id }}">
|
||||
<label>
|
||||
<input class="mailpoet_segment_id" type="hidden" value="{{ id }}" />
|
||||
<input class="mailpoet_is_checked" type="checkbox" value="1"
|
||||
{{#ifCond is_checked '>' 0}}checked="checked"{{/ifCond}} />
|
||||
<input class="mailpoet_segment_name" type="hidden" value="{{ name }}" />
|
||||
{{ name }}
|
||||
</label>
|
||||
<a class="remove" href="javascript:;"><%= __('Remove') %></a>
|
||||
<a class="handle" href="javascript:;"><%= __('Move') %></a>
|
||||
</li>
|
||||
{{/each}}
|
||||
@@ -0,0 +1,3 @@
|
||||
<p class="mailpoet_align_right">
|
||||
<input type="submit" value="<%= __('Done') %>" class="button-primary" />
|
||||
</p>
|
||||
@@ -0,0 +1,24 @@
|
||||
<p class="clearfix">
|
||||
<label><%= __('Validate for:') %></label>
|
||||
<select name="params[validate]">
|
||||
<option {{#ifCond params.validate '==' ''}}selected="selected"{{/ifCond}}
|
||||
value="">
|
||||
<%= __('Nothing') %>
|
||||
</option>
|
||||
|
||||
<option {{#ifCond params.validate '==' 'number'}}selected="selected"{{/ifCond}}
|
||||
value="number">
|
||||
<%= __('Numbers only') %>
|
||||
</option>
|
||||
|
||||
<option {{#ifCond params.validate '==' 'alphanum'}}selected="selected"{{/ifCond}}
|
||||
value="alphanum">
|
||||
<%= __('Alphanumerical') %>
|
||||
</option>
|
||||
|
||||
<option {{#ifCond params.validate '==' 'phone'}}selected="selected"{{/ifCond}}
|
||||
value="phone">
|
||||
<%= __('Phone number, (+,-,#,(,) and spaces allowed)') %>
|
||||
</option>
|
||||
</select>
|
||||
</p>
|
||||
@@ -0,0 +1,82 @@
|
||||
<div class="mailpoet_multiple_values">
|
||||
<ul></ul>
|
||||
{{#ifCond type 'in' 'radio,select'}}
|
||||
<a href="javascript:;" class="add"><span></span><%= __('Add item') %></a>
|
||||
{{/ifCond}}
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
{{#if params.values}}
|
||||
var field_values = {{{ json_encode params.values }}};
|
||||
{{else}}
|
||||
var field_values = [{ value: '' }];
|
||||
{{/if}}
|
||||
var field_type = "{{ type }}";
|
||||
var template = Handlebars.compile($('#field_settings_values_item').html());
|
||||
|
||||
// set default value for checkbox type if there is no value defined
|
||||
if(field_type === 'checkbox' && field_values.length !== 1) {
|
||||
if(field_values.length > 1) {
|
||||
field_values = [field_values[0]];
|
||||
} else {
|
||||
// push a default empty value
|
||||
field_values = [{}];
|
||||
}
|
||||
}
|
||||
$(function() {
|
||||
// render all values by creating inputs
|
||||
for(var i = 0, count = field_values.length; i < count; i++) {
|
||||
createInput(template, field_values[i]);
|
||||
}
|
||||
// set inputs name
|
||||
setInputNames();
|
||||
|
||||
// add value
|
||||
$('.mailpoet_multiple_values .add').on('click', function() {
|
||||
createInput(template);
|
||||
setInputNames();
|
||||
});
|
||||
// remove value
|
||||
$(document).on('click', '.mailpoet_multiple_values li .remove', function() {
|
||||
$(this).parent('li').remove();
|
||||
setInputNames();
|
||||
});
|
||||
// create an input
|
||||
function createInput(template, values) {
|
||||
var data = values || {};
|
||||
// set field type
|
||||
data.type = field_type;
|
||||
// add input to selection
|
||||
$('.mailpoet_multiple_values ul').append(template(data));
|
||||
}
|
||||
// set input names (since their index is based on their position)
|
||||
function setInputNames() {
|
||||
$('.mailpoet_multiple_values li').each(function(index, item) {
|
||||
$(item).find('.is_checked').attr('name', 'params[values]['+index+'][is_checked]');
|
||||
$(item).find('.value').attr('name', 'params[values]['+index+'][value]');
|
||||
});
|
||||
|
||||
// hide remove button if only one item remains
|
||||
if ($('.mailpoet_multiple_values li').length > 1) {
|
||||
$('.mailpoet_multiple_values .remove').show();
|
||||
} else {
|
||||
$('.mailpoet_multiple_values .remove').hide();
|
||||
}
|
||||
}
|
||||
{{#ifCond type '!=' 'checkbox'}}
|
||||
$('.mailpoet_multiple_values').on('click', '.is_checked', function() {
|
||||
// get click checkbox's state
|
||||
var is_checked = $(this).is(':checked');
|
||||
// uncheck all checkboxes
|
||||
$('.mailpoet_multiple_values .is_checked').removeProp('checked');
|
||||
// toggle clicked checkbox
|
||||
if(is_checked === false) {
|
||||
$(this).removeProp('checked');
|
||||
} else {
|
||||
$(this).prop('checked', 'checked');
|
||||
}
|
||||
});
|
||||
{{/ifCond}}
|
||||
});
|
||||
});
|
||||
<{{!}}/script>
|
||||
@@ -0,0 +1,22 @@
|
||||
<li class="clearfix">
|
||||
{{#ifCond type 'in' 'radio,select'}}
|
||||
<input class="is_checked radio" type="radio" name=""
|
||||
{{#if is_checked}}checked="checked"{{/if}} value="1"/>
|
||||
{{else}}
|
||||
<input class="is_checked checkbox" type="checkbox" name=""
|
||||
{{#if is_checked}}checked="checked"{{/if}} value="1"/>
|
||||
{{/ifCond}}
|
||||
|
||||
<input
|
||||
type="text"
|
||||
name=""
|
||||
class="value"
|
||||
value="{{ value }}"
|
||||
data-parsley-errors-messages-disabled="true"
|
||||
data-parsley-required="true"
|
||||
/>
|
||||
|
||||
{{#ifCond type 'in' 'radio,select'}}
|
||||
<a class="remove" href="javascript:;"><%= __('Remove') %></a>
|
||||
{{/ifCond}}
|
||||
</li>
|
||||
Reference in New Issue
Block a user