Commit 938b0afd authored by KR Moorhouse's avatar KR Moorhouse

Resolved merge conflicts.

parents fa2cd7b6 65cf34fd
......@@ -10,7 +10,7 @@ define([], function() {
var dateFormat = view.model.get( 'date_format' );
// For "default" date format, convert PHP format to JS compatible format.
if( 'default' == dateFormat ){
if( '' == dateFormat || 'default' == dateFormat ){
dateFormat = this.convertDateFormat( nfi18n.dateFormat );
}
......
......@@ -12,15 +12,22 @@ define([], function() {
initRating: function( view ){
jQuery( view.el ).find( '.starrating' ).rating();
},
renderRatings: function() {
var html = document.createElement( 'span' );
for (var i = 0; i <= this.default - 1; i++) {
// changed from 'default' to 'number_of_stars'
for (var i = 0; i <= this.number_of_stars - 1; i++) {
var template = nfRadio.channel( 'app' ).request( 'get:template', '#tmpl-nf-field-starrating-star' );
var num = i + 1;
var htmlFragment = template( { id: this.id, classes: this.classes, num: num } );
var checked = '';
// Check to see if current 'star' matches the default value
if ( this.value == num ) {
checked = 'checked';
}
var htmlFragment = template( { id: this.id, classes: this.classes, num: num, checked: checked } );
html.appendChild(
document.createRange().createContextualFragment( htmlFragment )
);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -470,7 +470,7 @@ return apply_filters( 'ninja_forms_field_settings', array(
'value' => 'dddd, MMMM D YYYY',
),
),
'value' => '',
'value' => 'default',
),
/*
......
......@@ -53,8 +53,8 @@ class NF_Fields_Checkbox extends NF_Abstracts_Input
*/
public function admin_form_element( $id, $value )
{
// If the checkboxes value is one...
if( 1 == $value ) {
// If the checkboxes value is 1 or on...
if( 'on' == $value || 1 == $value ) {
// ...this variable to checked.
$checked = 'checked';
} else {
......@@ -81,14 +81,14 @@ class NF_Fields_Checkbox extends NF_Abstracts_Input
// If the field type is equal to checkbox...
if( 'checkbox' == $field->get_setting( 'type' ) ) {
// Backwards compatibility check for the new checked value setting.
if( null == $field->get_setting( 'checked_value' ) && 1 == $value ) {
if( null == $field->get_setting( 'checked_value' ) && 1 == $value || 'on' == $value ) {
return __( 'Checked', 'ninja-forms' );
} elseif( null == $field->get_setting( 'unchecked_value' ) && 0 == $value ) {
return __( 'Unchecked', 'ninja-forms');
}
// If the field value is set to 1....
if( 1 == $value ) {
if( 1 == $value || 'on' == $value) {
// Set the value to the checked value setting.
$value = $field->get_setting( 'checked_value' );
} else {
......@@ -151,13 +151,25 @@ class NF_Fields_Checkbox extends NF_Abstracts_Input
// If value is equal to checked or unchecked return the value
if ( __( 'checked', 'ninja-forms' ) == $value ||
__( 'unchecked', 'ninja-forms' ) == $value ) return $value;
// If the value is a boolean...
if ( $value ) {
// ...if true return checked
return $field->get_setting( 'checked_value' );
} else {
// ...else return unchecked.
return $field->get_setting( 'unchecked_value' );
// Creating settings variables for our check.
$checked_setting = $field->get_setting( 'checked_value' );
$unchecked_setting = $field->get_setting( 'unchecked_value' );
// If the the value and check to see if we have checked and unchecked settings...
if ( 1 == $value && ! empty( $checked_setting ) ) {
// ...if we do return checked setting
return $checked_setting;
} elseif ( 0 == $value && ! empty( $unchecked_setting ) ) {
// ...else return unchecked setting.
return $unchecked_setting;
/*
* These checks are for checkbox fields that were created before version 3.2.7.
*/
} elseif ( 1 == $value ) {
return __( 'checked', 'ninja-forms' );
} elseif ( 0 == $value ) {
return __( 'unchecked', 'ninja-forms' );
}
}
}
......@@ -17,21 +17,15 @@ class NF_Fields_StarRating extends NF_Abstracts_Input
protected $_templates = 'starrating';
protected $_settings_only = array( 'label', 'label_pos', 'default', 'required', 'classes', 'key', 'admin_label' );
protected $_settings_only = array( 'label', 'label_pos', 'default',
'number_of_stars', 'required', 'classes', 'key', 'admin_label' );
public function __construct()
{
parent::__construct();
$this->_settings[ 'default' ][ 'group' ] = 'primary';
$this->_settings[ 'default' ][ 'label' ] = __( 'Number of Stars', 'ninja-forms' );
$this->_settings[ 'default' ][ 'width' ] = 'one-half';
$this->_settings[ 'default' ][ 'use_merge_tags' ] = FALSE;
$this->_settings[ 'default' ][ 'value' ] = 5;
// Put this in the primary settings group
$this->_settings['number_of_stars']['group'] = 'primary';
$this->_nicename = __( 'Star Rating', 'ninja-forms' );
}
......
......@@ -5,5 +5,7 @@
</script>
<script id="tmpl-nf-field-starrating-star" type="text/template">
<input type="radio" name="nf-field-{{{ data.id }}}" class="{{{ data.classes }}} nf-element" value="{{{ data.num }}}" />
<input type="radio" name="nf-field-{{{ data.id }}}"
class="{{{ data.classes }}} nf-element" value="{{{ data.num }}}"
{{{ data.checked }}}/>
</script>
<script id="tmpl-nf-form-layout" type="text/template">
<!--<form>-->
<div>
<div class="nf-before-form-content"></div>
<div class="nf-form-content {{{ data.element_class }}}"></div>
<div class="nf-after-form-content"></div>
</div>
<!--</form>-->
</script>
\ No newline at end of file
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