Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
iwillhappy1314 committed Nov 24, 2019
1 parent 19cf764 commit f2dbf7d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 26 deletions.
1 change: 1 addition & 0 deletions frontend/assets/scripts/modules/ajax-uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jQuery(document).ready(function($) {
},
});


/**
* 删除缩略图
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Forms/Controls/CloneInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ public function getControl()

$action_button = Html::el('span class=input-group-btn')
->addHtml(
Html::el('a class="btn btn-default js-remove-button"')
Html::el('a class="rs-button js-remove-button"')
->setText(__('Remove', 'wprs'))
);

$clone_group = Html::el('div class=frm-group-input')
->setAttribute('id', $id);

$add_button = Html::el('button class="btn btn-default btn-sm js-more-button"')
$add_button = Html::el('button class="rs-button rs-button--sm js-more-button"')
->setText(__('Add More Fields', 'wprs'));

// 设置默认值
Expand Down
5 changes: 2 additions & 3 deletions src/Forms/Controls/DatePickerInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ public function __construct($label = null, array $settings = null)
public function getControl()
{

if (function_exists('wp_enqueue_script')) {
wp_enqueue_style('jquery-ui-datepicker');
wp_enqueue_style('wprs-datepicker');
wp_enqueue_script('jquery-ui-datepicker');
}


$el = parent::getControl();
$el->setAttribute('autocomplete', 'off');
Expand Down
2 changes: 1 addition & 1 deletion src/Forms/Controls/SmsInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getControl()
->addHtml(
Html::el('input type=button')
->setAttribute('id', $action_id)
->setAttribute('class', 'btn btn-primary')
->setAttribute('class', 'rs-button rs-button--primary')
->setAttribute('value', __('Get Code', 'wprs'))
);

Expand Down
6 changes: 3 additions & 3 deletions src/Forms/Controls/TableInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public function getControl()
'moveDown' => true,
],
'buttonClasses' => [
'append' => 'btn btn-sm btn-primary',
'removeLast' => 'btn btn-sm btn-danger',
'append' => 'rs-button rs-button--sm rs-button--primary',
'removeLast' => 'rs-button rs-button--sm rs-button--danger',
],
'columns' => $fields,
'initData' => $default_value,
Expand All @@ -78,7 +78,7 @@ public function getControl()
$settings = wp_parse_args($settings, $default);

$html = Html::el('table id=' . $name);
$html->setAttribute('class', 'table table-bordered c-table-input');
$html->setAttribute('class', 'table table-bordered rs-table-input');

$html .= "<script>
jQuery(document).ready(function ($) {
Expand Down
24 changes: 15 additions & 9 deletions src/Forms/Renders/FormRender.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class FormRender extends Nette\Forms\Rendering\DefaultFormRenderer
'.file' => 'text',
'.email' => 'text',
'.number' => 'text',
'.submit' => 'button',
'.image' => 'imagebutton',
'.submit' => 'rs-button',
'.image' => 'rs-button--image',
'.button' => 'button',
],

Expand All @@ -115,7 +115,7 @@ class FormRender extends Nette\Forms\Rendering\DefaultFormRenderer
/**
* 渲染控件组
*
* @param Nette\Forms\Container|Nette\Forms\ControlGroup
* @param Nette\Forms\Container|Nette\Forms\ControlGroup
*
* @return string
*/
Expand Down Expand Up @@ -180,20 +180,24 @@ public function renderPair(Nette\Forms\IControl $control)
// Add prefix and suffix
if (isset($control->prefix) || isset($control->suffix)) {

$group_parent = Html::el('div')
->setAttribute('class', 'col-md-9');

$group = Html::el('div')
->class($this->getValue('pair .addon'));
->setAttribute('class', [$this->getValue('pair .addon')]);

if (isset($control->prefix)) {
$group->insert(1, $control->prefix);
}

$group->addHtml($this->renderControl($control));
$group->addHtml(str_replace('class="text"', 'class="form-control"', $this->renderControl($control)
->getChildren()[ 0 ]));

if (isset($control->suffix)) {
$group->addHtml($control->suffix);
}

$pair->addHtml($group);
$pair->addHtml($group_parent->addHtml($group));

} else {

Expand All @@ -212,7 +216,7 @@ public function renderPair(Nette\Forms\IControl $control)
/**
* 在一行中渲染多个控件
*
* @param Nette\Forms\IControl[]
* @param Nette\Forms\IControl[]
*
* @return string
*/
Expand All @@ -231,7 +235,8 @@ public function renderPairMulti(array $controls)
if ($control instanceof Nette\Forms\Controls\BaseControl) {
$description = $control->translate($description);
}
$description = ' ' . $this->getWrapper('control description')->setText($description);
$description = ' ' . $this->getWrapper('control description')
->setText($description);

} else {
$description = '';
Expand All @@ -249,7 +254,8 @@ public function renderPairMulti(array $controls)

// wrapper class
$pair->class($control->getOption('class'), true);
$pair->addHtml($this->getWrapper('control container')->setHtml(implode(' ', $s)));
$pair->addHtml($this->getWrapper('control container')
->setHtml(implode(' ', $s)));

return $pair->render(0);
}
Expand Down
16 changes: 8 additions & 8 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ function wprs_form(Form $form, $type = 'horizontal')
$type = $control->getOption('type');

if ( ! $control->getOption('class')) {
$control->setOption('class', 'col-md-12 c-form--' . $type);
$control->setOption('class', 'col-md-12 rs-form--' . $type);
}

$control->setOption('id', 'grp-' . $control->name);

if ($type === 'button') {

$control->getControlPrototype()
->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
->addClass(empty($usedPrimary) ? 'rs-button rs-button--primary' : 'rs-button');
$usedPrimary = true;

} elseif (in_array($type, $text_control_type, true)) {
Expand Down Expand Up @@ -112,15 +112,15 @@ function wprs_admin_form(Form $form, $type = 'post_meta')
case 'term_meta':
if ($screen->base == 'term') {
$renderer->wrappers[ 'controls' ][ 'container' ] = 'table class=form-table';
$renderer->wrappers[ 'pair' ][ 'container' ] = 'tr class=c-form-field';
$renderer->wrappers[ 'pair' ][ 'container' ] = 'tr class=rs-form-field';
} else {
$renderer->wrappers[ 'controls' ][ 'container' ] = '';
$renderer->wrappers[ 'pair' ][ 'container' ] = 'div class="form-field wprs-form-field"';
}
break;
default:
$renderer->wrappers[ 'controls' ][ 'container' ] = 'table class=form-table';
$renderer->wrappers[ 'pair' ][ 'container' ] = 'tr class=c-form-field';
$renderer->wrappers[ 'pair' ][ 'container' ] = 'tr class=rs-form-field';
}

$renderer->wrappers[ 'label' ][ 'container' ] = 'th class=row scope=row';
Expand All @@ -136,15 +136,15 @@ function wprs_admin_form(Form $form, $type = 'post_meta')
$type = $control->getOption('type');

if ( ! $control->getOption('class')) {
$control->setOption('class', 'c-form--' . $type);
$control->setOption('class', 'rs-form--' . $type);
}

$control->setOption('id', 'grp-' . $control->name);

if ($type === 'button') {

$control->getControlPrototype()
->addClass(empty($usedPrimary) ? 'button button-primary' : 'button');
->addClass(empty($usedPrimary) ? 'rs-button rs-button-primary' : 'rs-button');
$usedPrimary = true;

} elseif (in_array($type, $text_control_type, true)) {
Expand Down Expand Up @@ -288,9 +288,9 @@ function wprs_dir_to_url($directory)

// Birthday Picker
wp_register_script('wprs-combodate', $enqueue->getUrl( $assets['combodate.js'] ), ['jquery', 'moment'], WENPRISE_FORM_VERSION, true);
//

// Datepicker 样式
wp_register_style('jquery-ui-datepicker', $enqueue->getUrl( $assets['datepicker.js'] ), ['jquery'], WENPRISE_FORM_VERSION);
wp_register_style('wprs-datepicker', $enqueue->getUrl( $assets['datepicker.css'] ), [], WENPRISE_FORM_VERSION);

// jQuery AutoComplete
wp_register_script('wprs-autocomplete', $enqueue->getUrl( $assets['autocomplete.js'] ), ['jquery'], WENPRISE_FORM_VERSION);
Expand Down

0 comments on commit f2dbf7d

Please sign in to comment.