ReduxFramework_spinner

The Gravity Forms Advanced File Uploader ReduxFramework spinner class.

Defined (1)

The class is defined in the following location(s).

/inc/ReduxFramework/ReduxCore/inc/fields/spinner/field_spinner.php  
  1. class ReduxFramework_spinner { 
  2.  
  3. /** 
  4. * Field Constructor. 
  5. * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function 
  6. * @since ReduxFramework 3.0.0 
  7. */ 
  8. function __construct( $field = array(), $value = '', $parent ) { 
  9. $this->parent = $parent; 
  10. $this->field = $field; 
  11. $this->value = $value; 
  12. } //function 
  13.  
  14. /** 
  15. * Field Render Function. 
  16. * Takes the vars and outputs the HTML for the field in the settings 
  17. * @since ReduxFramework 3.0.0 
  18. */ 
  19. function render() { 
  20.  
  21. $params = array( 
  22. 'min' => '',  
  23. 'max' => '',  
  24. 'step' => '',  
  25. 'default' => '',  
  26. ); 
  27.  
  28. $this->field = wp_parse_args( $this->field, $params ); 
  29. $data_string = ""; 
  30. foreach($this->field as $key => $val) { 
  31. if (in_array($key, array('min', 'max', 'step', 'default'))) { 
  32. $data_string.= " data-".$key.'="'.$val.'"'; 
  33. $data_string .= ' data-val="'.$val.'"'; 
  34.  
  35.  
  36. // Don't allow input edit if there's a step 
  37. $readonly = ""; 
  38. if ( isset( $this->field['edit'] ) && $this->field['edit'] == false ) { 
  39. $readonly = ' readonly="readonly"'; 
  40.  
  41.  
  42. echo '<div id="' . $this->field['id'] . '-spinner" class="redux_spinner" rel="' . $this->field['id'] . '">'; 
  43. echo '<input type="text" '.$data_string.' name="' . $this->field['name'] . $this->field['name_suffix'] . '" id="' . $this->field['id'] . '" value="' . $this->value . '" class="mini spinner-input' . $this->field['class'] . '"' . $readonly . '/>'; 
  44. echo '</div>'; 
  45. } //function 
  46.  
  47. /** 
  48. * Clean the field data to the fields defaults given the parameters. 
  49. * @since Redux_Framework 3.1.1 
  50. */ 
  51. function clean() { 
  52.  
  53. if ( empty( $this->field['min'] ) ) { 
  54. $this->field['min'] = 0; 
  55. } else { 
  56. $this->field['min'] = intval( $this->field['min'] ); 
  57.  
  58. if ( empty( $this->field['max'] ) ) { 
  59. $this->field['max'] = intval( $this->field['min'] ) + 1; 
  60. } else { 
  61. $this->field['max'] = intval( $this->field['max'] ); 
  62.  
  63. if ( empty( $this->field['step'] ) || $this->field['step'] > $this->field['max'] ) { 
  64. $this->field['step'] = 1; 
  65. } else { 
  66. $this->field['step'] = intval( $this->field['step'] ); 
  67.  
  68. if ( empty( $this->value ) && ! empty( $this->field['default'] ) && intval( $this->field['min'] ) >= 1 ) { 
  69. $this->value = intval( $this->field['default'] ); 
  70.  
  71. if ( empty( $this->value ) && intval( $this->field['min'] ) >= 1 ) { 
  72. $this->value = intval( $this->field['min'] ); 
  73.  
  74. if ( empty( $this->value ) ) { 
  75. $this->value = 0; 
  76.  
  77. // Extra Validation 
  78. if ( $this->value < $this->field['min'] ) { 
  79. $this->value = intval( $this->field['min'] ); 
  80. } else if ( $this->value > $this->field['max'] ) { 
  81. $this->value = intval( $this->field['max'] ); 
  82.  
  83. /** 
  84. * Enqueue Function. 
  85. * If this field requires any scripts, or css define this function and register/enqueue the scripts/css 
  86. * @since ReduxFramework 3.0.0 
  87. */ 
  88. function enqueue() { 
  89.  
  90. wp_enqueue_script( 
  91. 'redux-field-spinner-custom-js',  
  92. ReduxFramework::$_url . 'inc/fields/spinner/vendor/spinner_custom.js',  
  93. array( 'jquery' ),  
  94. time(),  
  95. true 
  96. ); 
  97.  
  98. wp_enqueue_script( 
  99. 'redux-field-spinner-js',  
  100. ReduxFramework::$_url . 'inc/fields/spinner/field_spinner' . Redux_Functions::isMin() . '.js',  
  101. array( 
  102. 'jquery',  
  103. 'redux-field-spinner-custom-js',  
  104. 'jquery-ui-core',  
  105. 'jquery-ui-dialog',  
  106. 'redux-js' 
  107. ),  
  108. time(),  
  109. true 
  110. ); 
  111.  
  112. redux_enqueue_style( 
  113. $this->parent,  
  114. 'redux-field-spinner-css',  
  115. ReduxFramework::$_url . 'inc/fields/spinner/field_spinner.css',  
  116. ReduxFramework::$_dir . 'inc/fields/spinner',  
  117. array(),  
  118. time(),  
  119. false 
  120. );  
  121.  
  122. // wp_enqueue_style( 
  123. // 'redux-field-spinner-css',  
  124. // ReduxFramework::$_url . 'inc/fields/spinner/field_spinner.css',  
  125. // time(),  
  126. // true 
  127. // );