Commit 284f334e authored by Eric Windham's avatar Eric Windham

finished functionality

parent e752605c
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
/**
* Handles actions related to our toggle field.
* When we change the toggle, the setting value will be 'on' or ''.
* We need to change this to 1 or 0.
*
* @package Ninja Forms builder
* @subpackage Fields - Edit Field Drawer
* @copyright (c) 2015 WP Ninjas
* @since 3.0
*/
define( [], function() {
var controller = Marionette.Object.extend( {
initialize: function() {
// We don't want the RTE setting to re-render when the value changes.
nfRadio.channel( 'setting-type-button-toggle' ).reply( 'renderOnChange', function(){ console.log('here');return false } );
// Respond to requests for field setting filtering.
nfRadio.channel( 'button-toggle' ).reply( 'before:updateSetting', this.updateSetting, this );
},
/**
* Return either 1 or 0, depending upon the toggle position.
*
* @since 3.0
* @param Object e event
* @param backbone.model fieldModel field model
* @param string name setting name
* @param backbone.model settingTypeModel field type model
* @return int 1 or 0
*/
updateSetting: function( e, fieldModel, name, settingTypeModel ) {
return e.target.value;
}
});
return controller;
} );
\ No newline at end of file
......@@ -34,6 +34,7 @@ define(
'controllers/app/changeSettingDefault',
'controllers/app/fieldset',
'controllers/app/toggleSetting',
'controllers/app/buttonToggleSetting',
'controllers/app/radioSetting',
'controllers/app/itemControls',
'controllers/app/mergeTags',
......@@ -138,6 +139,7 @@ define(
ChangeSettingDefault,
Fieldset,
ToggleSetting,
ButtonToggleSetting,
RadioSetting,
ItemControls,
MergeTags,
......@@ -273,6 +275,7 @@ define(
new MainContentFieldsSortable();
new ChangeSettingDefault();
new ToggleSetting();
new ButtonToggleSetting();
new RadioSetting();
new DrawerSettingChildView();
new FieldsEditActive();
......
This diff is collapsed.
This diff is collapsed.
......@@ -237,6 +237,31 @@
}
}
}
.button-toggle {
text-align: center;
border: #ccc 1px;
border-radius: 5px;
background: #f1f1f1;
margin-top: 5px;
padding: 5px;
width: 100%;
label {
width: 49.5%;
display: inline-block;
span {
width: 100%;
display: inline-block;
}
input:checked + span {
background-color: #1ea9ea;
border-color: #1ea9ea;
}
input + span {
background-color: #ccc;
border-color: #ccc;
}
}
}
}
.nf-drawer-buttons {
display: none;
......
......@@ -7,15 +7,15 @@ return apply_filters( 'ninja_forms_action_email_settings', array(
*/
'fields_save_toggle' => array(
'name' => 'fields_save_toggle',
'type' => 'button_toggle',
'name' => 'fields-save-toggle',
'type' => 'button-toggle',
'width' => 'full',
'options' => array(
array( 'label' => __( 'Save All', 'ninja-forms' ), 'value' => 'save_all' ),
array( 'label' => __( 'Save None', 'ninja-forms' ), 'value' => 'save_none' )
),
'group' => 'primary',
'label' => __( 'Fields Save', 'ninja-forms' ),
'label' => __( 'Fields', 'ninja-forms' ),
'value' => 'save_all',
),
/*
......
......@@ -554,11 +554,10 @@ Label Three, value-three, 3
</script>
<script id="tmpl-nf-edit-setting-button_toggle" type="text/template">
<script id="tmpl-nf-edit-setting-button-toggle" type="text/template">
<span class="nf-setting-label">{{{ data.label }}}{{{ data.renderTooltip() }}}</span>
<div class="nf-setting button-toggle" style="background: #f1f1f1; padding:
5px;width: 100%;">
<div class="nf-setting button-toggle">
<#
_.each( data.options, function( option ) {
#>
......@@ -566,6 +565,7 @@ Label Three, value-three, 3
data-option_value="{{{ option.value }}}">
<input type="radio" id="field-{{{ option.value }}}"
style="display:none;"
class="nf-button-toggle setting"
value="{{{ option.value }}}" name="{{{data.name }}}"
{{{ data.value == option.value ? "checked" : '' }}}>
<span class="nf-button primary {{{ data.value != option.value ?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment