diff --git a/CHANGE.md b/CHANGE.md index 0c411ae..d8ab480 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,6 +1,23 @@ +version 1.7.3 +============= +**Date:** 15-Apr-2015 + +1. (enh #54): Auto guess input and set input options based on input type. +2. (enh #56): Reset/Clear help-block error messages before next validation. +3. (enh #57): Added translation support for Lithuanian language. +4. (enh #3, #58): Ability to render editable content INLINE as an alternative to a POPOVER. + - New `asPopover` boolean property added. + - Enhanced inline form styles + - INLINE templates and settings to control how content should be rendered + - Two built in inline templates +5. (enh #59): New `buttonsTemplate` property for rendering editable form action buttons (reset and submit). +6. (enh #60): Ability to configure action button `icon` and `label` separately. +7. (enh #61): New boolean property `showButtonLabels` to control the display of action button labels (will show the label as title on hover). +8. (enh #62): Enhance footer property to include tags for '{loading}' and '{buttons}'. + version 1.7.2 ============= -**Date:** 19-Mar-2015 +**Date:** 29-Mar-2015 1. (enh #39): Better validation for `valueIfNull`. 2. (enh #40): Enhanced styling for disabled editable button. @@ -9,7 +26,6 @@ version 1.7.2 5. (enh #47, #48): New property `submitOnEnter` to control save on ENTER key press. 6. (bug #49): Throw exception when an array value is passed as key to `displayValueConfig`. 7. (enh #53): Auto initialize `kv-editable-input` CSS for various input types and widgets. -8. (enh #54): Auto guess input and set input options based on input type. version 1.7.1 ============= diff --git a/Editable.php b/Editable.php index 69fcf93..9dd89cb 100644 --- a/Editable.php +++ b/Editable.php @@ -4,7 +4,7 @@ * @package yii2-editable * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - * @version 1.7.2 + * @version 1.7.3 */ namespace kartik\editable; @@ -35,7 +35,39 @@ class Editable extends InputWidget const FORMAT_BUTTON = 'button'; /** - * Edit input types + * Editable prebuilt inline templates + */ + const INLINE_BEFORE_1 = <<< HTML +
+
+ {loading} +
+HTML; + + const INLINE_AFTER_1 = <<< HTML +
+ {buttons}{close} +
+
+HTML; + + const INLINE_BEFORE_2 = <<< HTML +
+ {close} + {header} +
+
+HTML; + + const INLINE_AFTER_2 = <<< HTML +
+ +HTML; + + /** + * Editable input types */ // input types const INPUT_HIDDEN = 'hiddenInput'; @@ -71,6 +103,7 @@ class Editable extends InputWidget const INPUT_MONEY = '\kartik\money\MaskMoney'; const INPUT_CHECKBOX_X = '\kartik\checkbox\CheckboxX'; + const LOAD_INDICATOR = ''; const CSS_PARENT = "kv-editable-parent form-group"; /** @@ -89,6 +122,35 @@ class Editable extends InputWidget */ public $format = self::FORMAT_LINK; + /** + * @var boolean whether to show the editable input as a popover. Defaults to `true`. + * If set to `false`, it will be rendered inline. + */ + public $asPopover = true; + + /** + * @var array the settings for the inline editable when `asPopover` is `false`. + * The following properties are recognized: + * - options: array, the HTML attributes for the `div` panel container that will enclose the inline content. + * By default the options will be set to `['class' => 'panel panel-default']`. + * - closeButton: string, the markup for rendering the close button to close the inline panel. Note the + * markup must have the CSS class `kv-editable-close` to trigger the closure of the inline panel. The + * `closeButton` defaults to ``. + * - templateBefore: string, he template for inline content rendered before the input. + * Defaults to `Editable::INLINE_BEFORE_1`. + * - templateAfter: string, he template for inline content rendered after the input. + * Defaults to `Editable::INLINE_AFTER_1`. + * The following tags in the templates above will be automatically replaced: + * - '{header}': the header generated via `preHeader` and `header` properties. + * - '{inputs}': the main form input content (combining `beforeInput`, the input/widget + * generated based on `inputType`, and `afterInput`) + * - '{buttons}': the form action buttons (submit and reset). + * - '{loading}': the loading indicator. + * - '{close}': the close button to close the inline content as set in + * `inlineSettings['closeButton']`. + */ + public $inlineSettings = []; + /** * @var array the HTML attributes for the editable button to be displayed when the format * has been set to 'button': @@ -115,40 +177,44 @@ class Editable extends InputWidget /** * @var string the popover contextual type. Must be one of the [[PopoverX::TYPE]] constants - * Defaults to `PopoverX::TYPE_DEFAULT` or `default`. + * Defaults to `PopoverX::TYPE_DEFAULT` or `default`. This will be applied only if `asPopover` + * is `true`. */ public $type = PopoverX::TYPE_DEFAULT; /** - * @var string the size of the popover window. One of the [[PopoverX::SIZE]] constants + * @var string the size of the popover window. One of the [[PopoverX::SIZE]] constants. + * This will be applied only if `asPopover` is `true`. */ public $size; /** * @var string the popover placement. Must be one of the [[PopoverX::ALIGN]] constants - * Defaults to `PopoverX::ALIGN_RIGHT` or `right`. + * Defaults to `PopoverX::ALIGN_RIGHT` or `right`. This will be applied only if `asPopover` + * is `true`. */ public $placement = PopoverX::ALIGN_RIGHT; /** - * @var string the header content placed before the header text in the popover dialog. + * @var string the header content placed before the header text in the popover dialog or inline panel. * This defaults to ` Edit`; */ public $preHeader; /** - * @var string the header content in the popover dialog. If not set, this + * @var string the header content in the popover dialog or inline panel. If not set, this * will be auto generated based on the attribute label or set to null. */ public $header; /** - * @var string the footer content in the popover dialog. The following special + * @var string the footer content in the popover dialog or inline panel. The following special * tags/variables will be parsed and replaced in the footer: + * {loading} - string, will be replaced with the loading indicator. * {buttons} - string, will be replaced with the submit and reset button. * If this is set to null or an empty string, it will not be displayed. */ - public $footer = '{buttons}'; + public $footer = '{loading}{buttons}'; /** * @var string the value to be displayed. If not set, this will default to the @@ -201,16 +267,6 @@ class Editable extends InputWidget * set to [[Editable::INPUT_WIDGET]] */ public $widgetClass; - - /** - * @var boolean whether to auto guess the input type and set the editable input options. When - * this is set to `true` the Editable widget will automatically detect the core input options - * for common input types (including HTML input types, krajee widgets and DateControl) and append - * the `kv-editable-input` class to the input. You can set this to false to set the `kv-editable-input` - * class manually for any other custom/third party widgets. You would do this typically when you set - * inputType to `Editable::INPUT_WIDGET`. Defaults to `true`. - */ - public $autoGuessInput = true; /** * @var boolean additional ajax settings to pass to the plugin. @@ -276,16 +332,30 @@ class Editable extends InputWidget public $showButtons = true; /** - * @var array the HTML attributes for the form submit button. The following special property - * is recognized: - * - label: string, the label of the button. Defaults to ` `. + * @var boolean whether you want to show the button labels. Defaults to `false`. + */ + public $showButtonLabels = false; + + /** + * @var string the template for rendering the buttons + */ + public $buttonsTemplate = "{reset}{submit}"; + + /** + * @var array the HTML attributes for the form submit button. The following special properties + * are additionally recognized: + * - icon: string, the icon for the button. Defaults to ` `. + * - label: string, the label of the button. This is Html encoded. Defaults to 'Apply' and is + * translated via yii i18n message files. */ public $submitButton = ['class' => 'btn btn-sm btn-primary']; /** - * @var array the HTML attributes for the form reset button. The following special property - * is recognized: - * - label: string, the label of the button. Defaults to ` `. + * @var array the HTML attributes for the form reset button. The following special properties + * are additionally recognized: + * - icon: string, the icon for the button. Defaults to ` `. + * - label: string, the label of the button. This is Html encoded. Defaults to 'Reset' and is + * translated via yii i18n message files. */ public $resetButton = ['class' => 'btn btn-sm btn-default']; @@ -325,6 +395,9 @@ public function init() if (Config::isDropdownInput($this->inputType) && !isset($this->data)) { throw new InvalidConfigException("You must set the 'data' property for '{$this->inputType}'."); } + if (!empty($this->formClass) && !class_exists($this->formClass)) { + throw new InvalidConfigException("The form class '{$this->formClass}' does not exist."); + } Config::validateInputWidget($this->inputType); $this->initI18N(__DIR__); $this->initOptions(); @@ -335,19 +408,65 @@ public function init() if ($this->format == self::FORMAT_BUTTON) { echo Html::tag('div', $this->displayValue, $this->editableValueOptions); } - - PopoverX::begin($this->_popoverOptions); - - if (!empty($this->formClass) && !class_exists($this->formClass)) { - throw new InvalidConfigException("The form class '{$this->formClass}' does not exist."); + if ($this->asPopover === true) { + PopoverX::begin($this->_popoverOptions); + } elseif ($this->format !== self::FORMAT_BUTTON) { + echo $this->renderToggleButton(); } - $class = $this->formClass; echo Html::beginTag('div', $this->contentOptions); + $class = $this->formClass; $this->_form = $class::begin($this->formOptions); if (!$this->_form instanceof \yii\widgets\ActiveForm) { throw new InvalidConfigException("The form class '{$class}' MUST extend from \yii\widgets\ActiveForm."); } + } + /** + * @inheritdoc + */ + public function run() + { + if (!$this->asPopover) { + echo Html::beginTag('div', $this->inlineSettings['options']); + } + echo $this->renderFormFields(); + $class = $this->formClass; + $class::end(); + if (!$this->asPopover) { + echo "\n"; // inline options + } + echo "\n"; // content options + if ($this->asPopover === true) { + PopoverX::end(); + } elseif ($this->format == self::FORMAT_BUTTON) { + echo $this->renderToggleButton(); + } + echo "\n"; // options + } + + protected function renderToggleButton() + { + $options = $this->_popoverOptions['toggleButton']; + $label = ArrayHelper::remove($options, 'label', ''); + return Html::button($label, $options); + } + + /** + * Initializes the inline settings & options. + * + * @throws InvalidConfigException + */ + protected function initInlineOptions() + { + $title = Yii::t('kveditable', 'Close'); + $this->inlineSettings = array_replace_recursive([ + 'templateBefore' => self::INLINE_BEFORE_1, + 'templateAfter' => self::INLINE_AFTER_1, + 'options' => ['class' => 'panel panel-default'], + 'closeButton' => "" + ], $this->inlineSettings); + Html::addCssClass($this->contentOptions, 'kv-editable-inline'); + Html::addCssStyle($this->contentOptions, 'display:none'); } /** @@ -359,12 +478,15 @@ public function init() protected function initOptions() { Html::addCssClass($this->inputContainerOptions, self::CSS_PARENT); + if ($this->asPopover !== true) { + $this->initInlineOptions(); + } if ($this->hasModel()) { $options = ArrayHelper::getValue($this->inputFieldConfig, 'options', []); Html::addCssClass($options, self::CSS_PARENT); $this->inputFieldConfig['options'] = $options; } - if (!Config::isHtmlInput($this->inputType) && $this->autoGuessInput) { + if (!Config::isHtmlInput($this->inputType)) { if ($this->widgetClass === 'kartik\datecontrol\DateControl') { $options = ArrayHelper::getValue($this->options, 'options.options', []); Html::addCssClass($options, 'kv-editable-input'); @@ -404,6 +526,13 @@ protected function initOptions() Html::addCssClass($this->contentOptions, 'kv-editable-content'); Html::addCssClass($this->formOptions['options'], 'kv-editable-form'); if ($this->format == self::FORMAT_BUTTON) { + if (!$this->asPopover) { + if ($this->inlineSettings['templateBefore'] === self::INLINE_BEFORE_1) { + Html::addCssClass($this->containerOptions, 'kv-editable-inline-1'); + } elseif ($this->inlineSettings['templateBefore'] === self::INLINE_BEFORE_2) { + Html::addCssClass($this->containerOptions, 'kv-editable-inline-2'); + } + } Html::addCssClass($this->editableButtonOptions, 'kv-editable-button'); Html::addCssClass($this->editableValueOptions, 'kv-editable-value'); } else { @@ -444,27 +573,50 @@ protected function initOptions() } /** - * Generates the popover footer + * Generates the editable action buttons * * @return string */ - protected function renderFooter() + protected function renderActionButtons() { - $submitLabel = ArrayHelper::remove($this->submitButton, 'label', - ' ' . Yii::t('kveditable', 'Apply') - ); - $resetLabel = ArrayHelper::remove($this->resetButton, 'label', - ' ' . Yii::t('kveditable', 'Reset') - ); + $submitIcon = ArrayHelper::remove($this->submitButton, 'icon', ''); + $resetIcon = ArrayHelper::remove($this->resetButton, 'icon', ''); + $submitLabel = ArrayHelper::remove($this->submitButton, 'label', Yii::t('kveditable', 'Apply')); + $resetLabel = ArrayHelper::remove($this->resetButton, 'label', Yii::t('kveditable', 'Reset')); + if ($this->showButtonLabels === false) { + if (empty($this->submitButton['title'])) { + $this->submitButton['title'] = $submitLabel; + } + if (empty($this->resetButton['title'])) { + $this->resetButton['title'] = $resetLabel; + } + $submitLabel = $submitIcon; + $resetLabel = $resetIcon; + } else { + $submitLabel = $submitIcon . ' ' . Html::encode($submitLabel); + $resetLabel = $resetIcon . ' ' . Html::encode($resetLabel); + } + $this->submitButton['type'] = 'button'; $this->resetButton['type'] = 'button'; Html::addCssClass($this->submitButton, 'kv-editable-submit'); Html::addCssClass($this->resetButton, 'kv-editable-reset'); - $buttons = Html::button($submitLabel, $this->submitButton) . - Html::button($resetLabel, $this->resetButton); - return Html::tag('div', ' ', ['class' => 'kv-editable-loading', 'style' => 'display:none;']) . - strtr($this->footer, [ - '{buttons}' => $buttons + return strtr($this->buttonsTemplate, [ + '{reset}' => Html::button($resetLabel, $this->resetButton), + '{submit}' => Html::button($submitLabel, $this->submitButton) + ]); + } + + /** + * Generates the popover footer + * + * @return string + */ + protected function renderFooter() + { + return strtr($this->footer, [ + '{loading}' => self::LOAD_INDICATOR, + '{buttons}' => $this->renderActionButtons() ]); } @@ -477,6 +629,7 @@ public function registerAssets() EditableAsset::register($view); $this->pluginOptions = [ 'valueIfNull' => $this->valueIfNull, + 'asPopover' => $this->asPopover, 'placement' => $this->placement, 'target' => $this->format == self::FORMAT_BUTTON ? '.kv-editable-button' : '.kv-editable-link', 'displayValueConfig' => $this->displayValueConfig, @@ -490,22 +643,31 @@ public function registerAssets() $toggleButton = $this->_popoverOptions['toggleButton']['id']; $initPjaxVar = 'kvEdPjax_' . str_replace('-', '_', $this->_popoverOptions['options']['id']); $view->registerJs("var {$initPjaxVar} = false;", View::POS_HEAD); - $js = "initEditablePjax('{$this->pjaxContainerId}', '{$toggleButton}', '{$initPjaxVar}');"; - $view->registerJs($js); + if ($this->asPopover) { + $js = "initEditablePjax('{$this->pjaxContainerId}', '{$toggleButton}', '{$initPjaxVar}');"; + $view->registerJs($js); + } } } /** - * @inheritdoc + * Parses the inline template and returns the generated content + * + * @param string $template the template setting + * + * @return string */ - public function run() + protected function parseTemplate($template) { - $class = $this->formClass; - echo $this->renderFormFields(); - $class::end(); - echo "\n"; // content options - PopoverX::end(); - echo "\n"; // options + if ($this->asPopover) { + return ''; + } + return strtr($this->inlineSettings[$template], [ + '{header}' => $this->_popoverOptions['header'], + '{close}' => $this->inlineSettings['closeButton'], + '{loading}' => self::LOAD_INDICATOR, + '{buttons}' => $this->renderActionButtons() + ]); } /** @@ -515,31 +677,32 @@ public function run() */ protected function renderFormFields() { - $out = Html::hiddenInput('hasEditable', 0) . "\n"; + echo $this->parseTemplate('templateBefore'); + echo Html::hiddenInput('hasEditable', 0) . "\n"; if ($this->beforeInput !== null) { if (is_string($this->beforeInput)) { - $out .= $this->beforeInput . "\n"; + echo $this->beforeInput . "\n"; } else { - $out .= call_user_func($this->beforeInput, $this->_form, $this) . "\n"; + echo call_user_func($this->beforeInput, $this->_form, $this) . "\n"; } } if ($this->inputType === self::INPUT_HTML5_INPUT) { - $out .= $this->renderHtml5Input() . "\n"; + echo $this->renderHtml5Input() . "\n"; } elseif ($this->inputType === self::INPUT_WIDGET) { - $out .= $this->renderWidget($this->widgetClass) . "\n"; + echo $this->renderWidget($this->widgetClass) . "\n"; } elseif (Config::isHtmlInput($this->inputType)) { - $out .= $this->renderInput() . "\n"; + echo $this->renderInput() . "\n"; } elseif (Config::isInputWidget($this->inputType)) { - $out .= $this->renderWidget($this->inputType) . "\n"; + echo $this->renderWidget($this->inputType) . "\n"; } if ($this->afterInput !== null) { if (is_string($this->afterInput)) { - $out .= $this->afterInput . "\n"; + echo $this->afterInput . "\n"; } else { - $out .= call_user_func($this->afterInput, $this->_form, $this) . "\n"; + echo call_user_func($this->afterInput, $this->_form, $this) . "\n"; } } - return $out; + echo $this->parseTemplate('templateAfter'); } /** diff --git a/EditableAsset.php b/EditableAsset.php index 91eef20..1f9e839 100644 --- a/EditableAsset.php +++ b/EditableAsset.php @@ -4,7 +4,7 @@ * @package yii2-editable * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - * @version 1.7.2 + * @version 1.7.3 */ namespace kartik\editable; diff --git a/EditablePjaxAsset.php b/EditablePjaxAsset.php index f45fa52..f79424a 100644 --- a/EditablePjaxAsset.php +++ b/EditablePjaxAsset.php @@ -4,7 +4,7 @@ * @package yii2-editable * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - * @version 1.7.2 + * @version 1.7.3 */ namespace kartik\editable; diff --git a/README.md b/README.md index 910ebf5..dc53b5d 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ yii2-editable ============= -Easily set any displayed content as editable in Yii Framework 2.0. This is an enhanced editable widget for Yii 2.0 that allows easy editing of displayed data, using inputs, widgets and more with numerous configuration possibilities. The extension uses the enhanced [yii2-popover-x](http://demos.krajee.com/popover-x) extension as a popover modal for editing. This extension does not use any external jQuery plugin like X-Editable, instead it uses its own lean and extensible +Easily set any displayed content as editable in Yii Framework 2.0. This is an enhanced editable widget for Yii 2.0 that allows easy editing of displayed data, using inputs, widgets and more with numerous configuration possibilities. The extension uses the enhanced [yii2-popover-x](http://demos.krajee.com/popover-x) extension as a popover modal for editing. With release v1.7.3, this extension also allows you to render the editable content inline and offers advanced inline templates for configuration. This extension does not use any external jQuery plugin like X-Editable, instead it uses its own lean and extensible jQuery editable plugin - that elaborately reuses functionality available within Yii Framework 2.0. -> NOTE: The latest version of the extension v1.7.2 has been released. Refer the [CHANGE LOG](https://github.com/kartik-v/yii2-editable/blob/master/CHANGE.md) for details. +> NOTE: The latest version of the extension v1.7.3 has been released. Refer the [CHANGE LOG](https://github.com/kartik-v/yii2-editable/blob/master/CHANGE.md) for details. ## Features @@ -12,18 +12,20 @@ Easily set any displayed content as editable in Yii Framework 2.0. This is an en 2. Provides two display formats for setting up your editable content . - **Link**: Convert the editable content as a clickable link for popover. - **Button**: Do not convert the editable content to a link, but rather display a button beside it for editing content. -3. Uses Yii 2.0 ActiveForm for editing content. Hence all features of Yii ActiveForm, including model validation rules are available. -4. For editing the content, you can configure it to use any of the HTML inputs, or widgets available from **kartik-v/yii2-widgets** or other input widgets from https://github.com/kartik-v. +3. Ability to render the content as a POPOVER or INLINE. +4. Advanced configurable inline templates for rendering complex content. +5. Uses Yii 2.0 ActiveForm for editing content. Hence all features of Yii ActiveForm, including model validation rules are available. +6. For editing the content, you can configure it to use any of the HTML inputs, or widgets available from **kartik-v/yii2-widgets** or other input widgets from https://github.com/kartik-v. In addition, you can also use HTML 5 inputs or any custom input widget to edit your content. -5. Entirely control the way the form content is displayed in the popover. By default, the widget displays the input to be edited. In addition, you can place +7. Entirely control the way the form content is displayed in the popover. By default, the widget displays the input to be edited. In addition, you can place more form fields or markup before and after this default input. -6. Uses AJAX based form submission to process quick editing of data and provide a seamless user experience. -7. Uses advanced features of the [yii2-popover-x extension](http://demos.krajee.com/popover-x), to control display formats for your editable popover form. This +8. Uses AJAX based form submission to process quick editing of data and provide a seamless user experience. +9. Uses advanced features of the [yii2-popover-x extension](http://demos.krajee.com/popover-x), to control display formats for your editable popover form. This uses the enhanced [bootstrap-popover-x](http://plugins.krajee.com/popover-x) jQuery plugin by Krajee. -8. Easily extend the default editable field by adding more form fields for editing before or after the generated editable input. -9. Configure your own display value irrespective of the value stored internally. -10. Configurable css styles and labels for rendering editable content according to your application or theme. -11. Ability to render and reinitialize automatically the widget via Pjax. +10. Easily extend the default editable field by adding more form fields for editing before or after the generated editable input. +11. Configure your own display value irrespective of the value stored internally. +12. Configurable css styles and labels for rendering editable content according to your application or theme. +13. Ability to render and reinitialize automatically the widget via Pjax. > Note: Check the [composer.json](https://github.com/kartik-v/yii2-money/blob/master/composer.json) for this extension's requirements and dependencies. Read this [web tip /wiki](http://webtips.krajee.com/setting-composer-minimum-stability-application/) on setting the `minimum-stability` settings for your application's composer.json. diff --git a/assets/css/editable.css b/assets/css/editable.css index 45172dc..ca0a553 100644 --- a/assets/css/editable.css +++ b/assets/css/editable.css @@ -2,7 +2,7 @@ * @package yii2-editable * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - * @version 1.7.2 + * @version 1.7.3 * * Styling for the Editable widget * Built for Yii Framework 2.0 @@ -23,7 +23,6 @@ text-decoration: none; cursor: pointer; border-bottom: 1px dashed; - text-decoration: none; } .kv-editable-value { @@ -31,15 +30,13 @@ } .kv-editable-button.btn-sm, -button[disabled].kv-editable-button - { +button[disabled].kv-editable-button { border-radius: 15px; width: 30px; padding: 5px; } -button[disabled].kv-editable-button -{ +button[disabled].kv-editable-button { opacity: 0.65; filter: alpha(opacity=65); pointer-events: none; @@ -49,19 +46,6 @@ button[disabled].kv-editable-button border: 1px solid #ddd; } -.kv-editable-footer { - background-color: #fbfbfb; - margin: 10px -14px -9px -14px; - border-radius: 0 0 5px 5px; - border-top: 1px solid #ebebeb; - padding: 4px; - text-align: right; -} - -.kv-editable-footer .btn { - margin-left: 4px; -} - .kv-editable-link:hover, .kv-editable:focus { color: #2a6496; } @@ -166,4 +150,100 @@ button[disabled].kv-editable-button .kv-editable-processing { opacity: 0.5; cursor: wait; +} + +.kv-editable-inline .panel-footer { + text-align: right; + padding: 5px; +} + +.kv-editable-inline .panel-footer .btn { + margin-left: 4px; +} + +@media (min-width: 768px) { + .kv-editable-form-inline .form-group { + display: inline-block; + margin-bottom: 0; + vertical-align: top; + } + + .kv-editable-form-inline .form-control { + display: inline-block; + width: auto; + vertical-align: top; + } + + .kv-editable-form-inline .form-control-static { + display: inline-block; + } + + .kv-editable-form-inline .input-group { + display: inline-table; + vertical-align: top; + } + + .kv-editable-form-inline .input-group .input-group-addon, + .kv-editable-form-inline .input-group .input-group-btn, + .kv-editable-form-inline .input-group .form-control { + width: auto; + } + + .kv-editable-form-inline .input-group > .form-control { + width: 100%; + } + + .kv-editable-form-inline .control-label { + margin-bottom: 0; + vertical-align: middle; + } + + .kv-editable-form-inline .radio, + .kv-editable-form-inline .checkbox { + display: inline-block; + margin-top: 0; + margin-bottom: 0; + vertical-align: middle; + } + + .kv-editable-form-inline .radio label, + .kv-editable-form-inline .checkbox label { + padding-left: 0; + } + + .kv-editable-form-inline .radio input[type="radio"], + .kv-editable-form-inline .checkbox input[type="checkbox"] { + position: relative; + margin-left: 0; + } + + .kv-editable-form-inline .has-feedback .form-control-feedback { + top: 0; + } +} + +.kv-editable-inline-1 .kv-editable-inline, +.kv-editable-inline-2 .kv-editable-inline, +.kv-editable-inline-button .kv-editable-button { + display: inline-block; +} + +.kv-editable-inline-1 { + margin-top: -10px; +} + +.kv-editable-inline-1 .kv-inline-open { + margin-top: 20px; +} + +.panel .kv-editable-form-inline { + padding: 0 5px 5px 0; +} + +.kv-editable-form-inline .btn-sm { + margin: 2px 4px 0 0; +} + +.kv-editable-form-inline .kv-editable-close { + margin-top: 6px; } \ No newline at end of file diff --git a/assets/css/editable.min.css b/assets/css/editable.min.css index a40346b..7990a5b 100644 --- a/assets/css/editable.min.css +++ b/assets/css/editable.min.css @@ -2,11 +2,11 @@ * @package yii2-editable * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - * @version 1.7.2 + * @version 1.7.3 * * Styling for the Editable widget * Built for Yii Framework 2.0 * Author: Kartik Visweswaran * Year: 2015 * For more Yii related demos visit http://demos.krajee.com - */.kv-editable,.kv-editable-value{display:inline-block}.kv-editable-link{color:#428bca;background:0 0;border:none;margin:0;padding:2px 1px;cursor:pointer;border-bottom:1px dashed;text-decoration:none}.kv-editable-value{margin-right:5px}.kv-editable-button.btn-sm,button[disabled].kv-editable-button{border-radius:15px;width:30px;padding:5px}button[disabled].kv-editable-button{opacity:.65;cursor:not-allowed}.kv-editable-footer{background-color:#fbfbfb;margin:10px -14px -9px -14px;border-radius:0 0 5px 5px;border-top:1px solid #ebebeb;padding:4px;text-align:right}.kv-editable-footer .btn{margin-left:4px}.kv-editable-link:hover,.kv-editable:focus{color:#2a6496}.kv-editable-link:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.kv-editable-link.text-primary:hover{color:#3071a9}.kv-editable-link.text-success{color:#3c763d}.kv-editable-link.text-success:hover{color:#2b542c}.kv-editable-link.text-info{color:#31708f}.kv-editable-link.text-info:hover{color:#245269}.kv-editable-link.text-warning{color:#8a6d3b}.kv-editable-link.text-warning:hover{color:#66512c}.kv-editable-link.text-danger{color:#a94442}.kv-editable-link.text-danger:hover{color:#843534}.kv-editable-link.bg-primary{color:#fff;background-color:#428bca}.kv-editable-link.bg-primary:hover{background-color:#3071a9}.kv-editable-link.bg-success{background-color:#dff0d8}.kv-editable-link.bg-success:hover{background-color:#c1e2b3}.kv-editable-link.bg-info{background-color:#d9edf7}.kv-editable-link.bg-info:hover{background-color:#afd9ee}.kv-editable-link.bg-warning{background-color:#fcf8e3}.kv-editable-link.bg-warning:hover{background-color:#f7ecb5}.kv-editable-link.bg-danger{background-color:#f2dede}.kv-editable-link.bg-danger:hover{background-color:#e4b9b9}.kv-editable-content .form-group{margin:5px 0}.kv-editable-content .help-block{margin:0}.kv-editable-loading{float:left;width:30px;background:transparent url(../img/loading.gif) 8px 8px no-repeat}.kv-editable-processing{opacity:.5;cursor:wait} \ No newline at end of file + */.kv-editable,.kv-editable-value{display:inline-block}.kv-editable-link{color:#428bca;background:0 0;border:none;margin:0;padding:2px 1px;text-decoration:none;cursor:pointer;border-bottom:1px dashed}.kv-editable-value{margin-right:5px}.kv-editable-button.btn-sm,button[disabled].kv-editable-button{border-radius:15px;width:30px;padding:5px}button[disabled].kv-editable-button{opacity:.65;filter:alpha(opacity=65);pointer-events:none;cursor:not-allowed;-webkit-box-shadow:none;box-shadow:none;border:1px solid #ddd}.kv-editable-link:hover,.kv-editable:focus{color:#2a6496}.kv-editable-link:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.kv-editable-link.text-primary:hover{color:#3071a9}.kv-editable-link.text-success{color:#3c763d}.kv-editable-link.text-success:hover{color:#2b542c}.kv-editable-link.text-info{color:#31708f}.kv-editable-link.text-info:hover{color:#245269}.kv-editable-link.text-warning{color:#8a6d3b}.kv-editable-link.text-warning:hover{color:#66512c}.kv-editable-link.text-danger{color:#a94442}.kv-editable-link.text-danger:hover{color:#843534}.kv-editable-link.bg-primary{color:#fff;background-color:#428bca}.kv-editable-link.bg-primary:hover{background-color:#3071a9}.kv-editable-link.bg-success{background-color:#dff0d8}.kv-editable-link.bg-success:hover{background-color:#c1e2b3}.kv-editable-link.bg-info{background-color:#d9edf7}.kv-editable-link.bg-info:hover{background-color:#afd9ee}.kv-editable-link.bg-warning{background-color:#fcf8e3}.kv-editable-link.bg-warning:hover{background-color:#f7ecb5}.kv-editable-link.bg-danger{background-color:#f2dede}.kv-editable-link.bg-danger:hover{background-color:#e4b9b9}.kv-editable-content .form-group{margin:5px 0}.kv-editable-content .help-block{margin:0}.kv-editable-loading{float:left;width:30px;background:transparent url(../img/loading.gif) 8px 8px no-repeat}.kv-editable-processing{opacity:.5;cursor:wait}.kv-editable-inline .panel-footer{text-align:right;padding:5px}.kv-editable-inline .panel-footer .btn{margin-left:4px}@media (min-width:768px){.kv-editable-form-inline .form-group{display:inline-block;margin-bottom:0;vertical-align:top}.kv-editable-form-inline .form-control{display:inline-block;width:auto;vertical-align:top}.kv-editable-form-inline .form-control-static{display:inline-block}.kv-editable-form-inline .input-group{display:inline-table;vertical-align:top}.kv-editable-form-inline .input-group .form-control,.kv-editable-form-inline .input-group .input-group-addon,.kv-editable-form-inline .input-group .input-group-btn{width:auto}.kv-editable-form-inline .input-group>.form-control{width:100%}.kv-editable-form-inline .control-label{margin-bottom:0;vertical-align:middle}.kv-editable-form-inline .checkbox,.kv-editable-form-inline .radio{display:inline-block;margin-top:0;margin-bottom:0;vertical-align:middle}.kv-editable-form-inline .checkbox label,.kv-editable-form-inline .radio label{padding-left:0}.kv-editable-form-inline .checkbox input[type=checkbox],.kv-editable-form-inline .radio input[type=radio]{position:relative;margin-left:0}.kv-editable-form-inline .has-feedback .form-control-feedback{top:0}}.kv-editable-inline-1 .kv-editable-inline,.kv-editable-inline-2 .kv-editable-inline,.kv-editable-inline-button .kv-editable-button{display:inline-block}.kv-editable-inline-1{margin-top:-10px}.kv-editable-inline-1 .kv-inline-open{margin-top:20px}.panel .kv-editable-form-inline{padding:0 5px 5px 0}.kv-editable-form-inline .btn-sm{margin:2px 4px 0 0}.kv-editable-form-inline .kv-editable-close{margin-top:6px} \ No newline at end of file diff --git a/assets/js/editable-pjax.js b/assets/js/editable-pjax.js index 641d9ad..4970139 100644 --- a/assets/js/editable-pjax.js +++ b/assets/js/editable-pjax.js @@ -2,7 +2,7 @@ * @package yii2-editable * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - * @version 1.7.2 + * @version 1.7.3 * * Editable Extension - PJAX processing script for popover-x * diff --git a/assets/js/editable-pjax.min.js b/assets/js/editable-pjax.min.js index f234ba0..9f00ae0 100644 --- a/assets/js/editable-pjax.min.js +++ b/assets/js/editable-pjax.min.js @@ -2,7 +2,7 @@ * @package yii2-editable * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - * @version 1.7.2 + * @version 1.7.3 * * Editable Extension - PJAX processing script for popover-x * diff --git a/assets/js/editable.js b/assets/js/editable.js index 0c16ee8..abc2f97 100644 --- a/assets/js/editable.js +++ b/assets/js/editable.js @@ -2,7 +2,7 @@ * @package yii2-editable * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - * @version 1.7.2 + * @version 1.7.3 * * Editable Extension jQuery plugin * @@ -16,6 +16,9 @@ var isEmpty = function (value, trim) { return value === null || value === undefined || value.length === 0 || (trim && $.trim(value) === ''); }, + addCss = function ($el, css) { + $el.removeClass(css).addClass(css); + }, Editable = function (element, options) { this.$container = $(element); this.init(options); @@ -29,7 +32,9 @@ self.$input = self.$container.find('.kv-editable-input'); self.$form = self.$container.find('.kv-editable-form'); self.$value = self.$container.find('.kv-editable-value'); + self.$close = self.$container.find('.kv-editable-close'); self.$popover = self.$container.find('.kv-editable-popover'); + self.$inline = self.$container.find('.kv-editable-inline'); self.$btnSubmit = self.$container.find('button.kv-editable-submit'); self.$btnReset = self.$container.find('button.kv-editable-reset'); self.$loading = self.$container.find('.kv-editable-loading'); @@ -37,34 +42,42 @@ $.each(options, function (key, value) { self[key] = value; }); + self.asPopover = self.asPopover == 1 || self.asPopover === 'true'; }, - refreshPosition: function () { - var self = this, $dialog = self.$popover, placement = self.placement, $target = self.$target, - actualWidth = $dialog[0].offsetWidth, actualHeight = $dialog[0].offsetHeight, - position, pos = $.extend({}, ($target.position()), { - width: $target[0].offsetWidth, height: $target[0].offsetHeight + toggle: function (show, delay) { + var self = this, $value = self.$value, $inline = self.$inline; + delay = delay || 'fast'; + if (show) { + if (!self.asPopover) { + $value.fadeOut(delay, function () { + $inline.fadeIn(delay); + if (self.target === '.kv-editable-button') { + addCss(self.$target, 'kv-inline-open'); + } + }); + } + return; + } + if (self.asPopover) { + self.$popover.popoverX('hide'); + } else { + $inline.fadeOut(delay, function () { + $value.fadeIn(delay); + self.$target.removeClass('kv-inline-open'); }); - switch (placement) { - case 'bottom': - position = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}; - break; - case 'top': - position = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}; - break; - case 'left': - position = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}; - break; - case 'right': - position = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}; - break; - default: - throw ("Invalid editable placement '" + placement + "'!"); } - $dialog.css(position); + }, + refreshPopover: function () { + var self = this; + if (self.asPopover) { + self.$popover.popoverX('refreshPosition'); + } }, listen: function () { var self = this, $form = self.$form, $btnSubmit = self.$btnSubmit, $btnReset = self.$btnReset, - $cont = $form.parent(), $el = self.$container, $popover = self.$popover, $loading = self.$loading, $input = self.$input, + $cont = $form.parent(), $el = self.$container, $popover = self.$popover, $close = self.$close, + $target = self.target === '.kv-editable-button' ? self.$target : self.$value, $inline = self.$inline, + $loading = self.$loading, $input = self.$input, $parent = $input.closest('.field-' + $input.attr('id')), $parent2 = $input.closest('.kv-editable-parent'), $message = $parent.find('.help-block'), displayValueConfig = self.displayValueConfig, settings, $hasEditable = $form.find('input[name="hasEditable"]'), showError, chkError = '', out = '', @@ -77,9 +90,10 @@ } $msgBlock.html(message); } else { - $message.html(message).removeClass('kv-help-block').addClass('kv-help-block'); + $message.html(message); + addCss($message, 'kv-help-block'); } - $parent2.addClass('has-error'); + addCss($parent2, 'has-error'); $loading.hide(); $cont.removeClass('kv-editable-processing'); }; @@ -99,11 +113,11 @@ $parent.removeClass('has-error'); $message.html(' '); } - $popover.popoverX('refreshPosition'); + self.refreshPopover(); }, 200); }); $form.find('input, select').on('change', function () { - $popover.popoverX('refreshPosition'); + self.refreshPopover(); $el.trigger('editableChange', [$input.val()]); }); $btnReset.on('click', function () { @@ -113,14 +127,26 @@ }, 200); $el.trigger('editableReset'); }); + $close.on('click', function () { + self.toggle(false); + }); + $target.on('click', function () { + if (self.asPopover) { + self.toggle(true); + return; + } + var status = !self.$inline.is(':visible'); + self.toggle(status); + }); $btnSubmit.on('click', function () { - $cont.addClass('kv-editable-processing'); + var $wrapper = self.asPopover ? $cont : $inline; + addCss($wrapper, 'kv-editable-processing'); $loading.show(); $hasEditable.val(1); $form.find('input, select').each(function () { $(this).trigger('change'); }); - settings = $.extend(self.ajaxSettings, { + settings = $.extend({ type: $form.attr('method'), url: $form.attr('action'), data: $form.serialize(), @@ -132,8 +158,9 @@ $el.trigger('editableAjaxError', [request, status, message]); }, success: function (data) { + chkError = ''; out = !isEmpty(data.output) ? data.output : $input.val(); - $popover.popoverX('refreshPosition'); + self.refreshPopover(); if (!isEmpty(data.message)) { showError(data.message); $el.trigger('editableError', [$input.val(), $form, data]); @@ -146,12 +173,13 @@ } } $form.find('.help-block').each(function () { - chkError = $(this).text(); - if (!isEmpty(chkError.trim())) { + var str = $(this).text(); + chkError += str ? str.trim() : ''; + if (!isEmpty(chkError)) { $loading.hide(); } }); - if (isEmpty(chkError.trim())) { + if (isEmpty(chkError)) { $loading.hide(); if (isEmpty(out)) { out = self.valueIfNull; @@ -164,12 +192,12 @@ $parent2.find('.help-block').remove(); $parent2.removeClass('has-error'); $message.html(''); - $popover.popoverX('hide'); + self.toggle(false); self.$value.html(out); } else { $parent.removeClass('has-error'); $message.html(''); - $popover.popoverX('hide'); + self.toggle(false); self.$value.html(out); if (objActiveForm) { $form.yiiActiveForm('destroy'); @@ -180,9 +208,9 @@ } else { $el.trigger('editableError', [$input.val(), $form, data]); } - $cont.removeClass('kv-editable-processing'); + $wrapper.removeClass('kv-editable-processing'); } - }); + }, self.ajaxSettings); $.ajax(settings); $el.trigger('editableSubmit', [$input.val(), $form]); }); @@ -212,7 +240,8 @@ displayValueConfig: {}, ajaxSettings: {}, showAjaxErrors: true, - submitOnEnter: true + submitOnEnter: true, + asPopover: true }; $.fn.editable.Constructor = Editable; diff --git a/assets/js/editable.min.js b/assets/js/editable.min.js index 5940d67..3046127 100644 --- a/assets/js/editable.min.js +++ b/assets/js/editable.min.js @@ -2,7 +2,7 @@ * @package yii2-editable * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - * @version 1.7.2 + * @version 1.7.3 * * Editable Extension jQuery plugin * @@ -10,4 +10,4 @@ * Author: Kartik Visweswaran * Year: 2015 * For more Yii related demos visit http://demos.krajee.com - */!function(e){"use strict";var t=function(t,i){return null===t||void 0===t||0===t.length||i&&""===e.trim(t)},i=function(t,i){this.$container=e(t),this.init(i),this.listen()};i.prototype={constructor:i,init:function(t){var i=this;i.$input=i.$container.find(".kv-editable-input"),i.$form=i.$container.find(".kv-editable-form"),i.$value=i.$container.find(".kv-editable-value"),i.$popover=i.$container.find(".kv-editable-popover"),i.$btnSubmit=i.$container.find("button.kv-editable-submit"),i.$btnReset=i.$container.find("button.kv-editable-reset"),i.$loading=i.$container.find(".kv-editable-loading"),i.$target=i.$container.find(t.target),e.each(t,function(e,t){i[e]=t})},refreshPosition:function(){var t,i=this,a=i.$popover,o=i.placement,n=i.$target,r=a[0].offsetWidth,l=a[0].offsetHeight,s=e.extend({},n.position(),{width:n[0].offsetWidth,height:n[0].offsetHeight});switch(o){case"bottom":t={top:s.top+s.height,left:s.left+s.width/2-r/2};break;case"top":t={top:s.top-l,left:s.left+s.width/2-r/2};break;case"left":t={top:s.top+s.height/2-l/2,left:s.left-r};break;case"right":t={top:s.top+s.height/2-l/2,left:s.left+s.width};break;default:throw"Invalid editable placement '"+o+"'!"}a.css(t)},listen:function(){var i,a,o=this,n=o.$form,r=o.$btnSubmit,l=o.$btnReset,s=n.parent(),d=o.$container,c=o.$popover,h=o.$loading,f=o.$input,u=f.closest(".field-"+f.attr("id")),p=f.closest(".kv-editable-parent"),v=u.find(".help-block"),b=o.displayValueConfig,m=n.find('input[name="hasEditable"]'),g="",k="",$=o.$form.data("yiiActiveForm"),y=p.find(".kv-help-block"),C=t(u.attr("class"))||t(v.attr("class"));a=function(i){C?(t(y.attr("class"))&&(y=e(document.createElement("div")).attr({"class":"help-block kv-help-block"}).appendTo(p)),y.html(i)):v.html(i).removeClass("kv-help-block").addClass("kv-help-block"),p.addClass("has-error"),h.hide(),s.removeClass("kv-editable-processing")},n.on("submit",function(e){e.preventDefault()}).on("keyup",function(e){13===e.which&&o.submitOnEnter&&r.trigger("click")}).on("reset",function(){setTimeout(function(){n.data("kvEditableSubmit",!1),C?(p.find(".help-block").remove(),p.removeClass("has-error")):(u.removeClass("has-error"),v.html(" ")),c.popoverX("refreshPosition")},200)}),n.find("input, select").on("change",function(){c.popoverX("refreshPosition"),d.trigger("editableChange",[f.val()])}),l.on("click",function(){m.val(0),setTimeout(function(){n[0].reset()},200),d.trigger("editableReset")}),r.on("click",function(){s.addClass("kv-editable-processing"),h.show(),m.val(1),n.find("input, select").each(function(){e(this).trigger("change")}),i=e.extend(o.ajaxSettings,{type:n.attr("method"),url:n.attr("action"),data:n.serialize(),dataType:"json",error:function(e,t,i){o.showAjaxErrors&&a(i),d.trigger("editableAjaxError",[e,t,i])},success:function(i){return k=t(i.output)?f.val():i.output,c.popoverX("refreshPosition"),t(i.message)?(t(y.attr("class"))||(u.removeClass("has-error"),y.html("").hide(),v.html("")),n.find(".help-block").each(function(){g=e(this).text(),t(g.trim())||h.hide()}),t(g.trim())?(h.hide(),t(k)?k=o.valueIfNull:void 0!==b[k]&&(k=b[k]),C?(p.find(".help-block").remove(),p.removeClass("has-error"),v.html(""),c.popoverX("hide"),o.$value.html(k)):(u.removeClass("has-error"),v.html(""),c.popoverX("hide"),o.$value.html(k),$&&(n.yiiActiveForm("destroy"),n.yiiActiveForm($.attributes,$.settings))),d.trigger("editableSuccess",[f.val(),n,i])):d.trigger("editableError",[f.val(),n,i]),void s.removeClass("kv-editable-processing")):(a(i.message),void d.trigger("editableError",[f.val(),n,i]))}}),e.ajax(i),d.trigger("editableSubmit",[f.val(),n])})}},e.fn.editable=function(t){var a=Array.apply(null,arguments);return a.shift(),this.each(function(){var o=e(this),n=o.data("editable"),r="object"==typeof t&&t;n||(n=new i(this,e.extend({},e.fn.editable.defaults,r,e(this).data())),o.data("editable",n)),"string"==typeof t&&n[t].apply(n,a)})},e.fn.editable.defaults={valueIfNull:"(not set)",placement:"right",displayValueConfig:{},ajaxSettings:{},showAjaxErrors:!0,submitOnEnter:!0},e.fn.editable.Constructor=i}(window.jQuery); \ No newline at end of file + */!function(e){"use strict";var t=function(t,i){return null===t||void 0===t||0===t.length||i&&""===e.trim(t)},i=function(e,t){e.removeClass(t).addClass(t)},n=function(t,i){this.$container=e(t),this.init(i),this.listen()};n.prototype={constructor:n,init:function(t){var i=this;i.$input=i.$container.find(".kv-editable-input"),i.$form=i.$container.find(".kv-editable-form"),i.$value=i.$container.find(".kv-editable-value"),i.$close=i.$container.find(".kv-editable-close"),i.$popover=i.$container.find(".kv-editable-popover"),i.$inline=i.$container.find(".kv-editable-inline"),i.$btnSubmit=i.$container.find("button.kv-editable-submit"),i.$btnReset=i.$container.find("button.kv-editable-reset"),i.$loading=i.$container.find(".kv-editable-loading"),i.$target=i.$container.find(t.target),e.each(t,function(e,t){i[e]=t}),i.asPopover=1==i.asPopover||"true"===i.asPopover},toggle:function(e,t){var n=this,o=n.$value,r=n.$inline;return t=t||"fast",e?void(n.asPopover||o.fadeOut(t,function(){r.fadeIn(t),".kv-editable-button"===n.target&&i(n.$target,"kv-inline-open")})):void(n.asPopover?n.$popover.popoverX("hide"):r.fadeOut(t,function(){o.fadeIn(t),n.$target.removeClass("kv-inline-open")}))},refreshPopover:function(){var e=this;e.asPopover&&e.$popover.popoverX("refreshPosition")},listen:function(){var n,o,r=this,a=r.$form,l=r.$btnSubmit,s=r.$btnReset,c=a.parent(),v=r.$container,d=(r.$popover,r.$close),u=".kv-editable-button"===r.target?r.$target:r.$value,f=r.$inline,p=r.$loading,h=r.$input,b=h.closest(".field-"+h.attr("id")),g=h.closest(".kv-editable-parent"),m=b.find(".help-block"),$=r.displayValueConfig,k=a.find('input[name="hasEditable"]'),y="",C="",P=r.$form.data("yiiActiveForm"),E=g.find(".kv-help-block"),j=t(b.attr("class"))||t(m.attr("class"));o=function(n){j?(t(E.attr("class"))&&(E=e(document.createElement("div")).attr({"class":"help-block kv-help-block"}).appendTo(g)),E.html(n)):(m.html(n),i(m,"kv-help-block")),i(g,"has-error"),p.hide(),c.removeClass("kv-editable-processing")},a.on("submit",function(e){e.preventDefault()}).on("keyup",function(e){13===e.which&&r.submitOnEnter&&l.trigger("click")}).on("reset",function(){setTimeout(function(){a.data("kvEditableSubmit",!1),j?(g.find(".help-block").remove(),g.removeClass("has-error")):(b.removeClass("has-error"),m.html(" ")),r.refreshPopover()},200)}),a.find("input, select").on("change",function(){r.refreshPopover(),v.trigger("editableChange",[h.val()])}),s.on("click",function(){k.val(0),setTimeout(function(){a[0].reset()},200),v.trigger("editableReset")}),d.on("click",function(){r.toggle(!1)}),u.on("click",function(){if(r.asPopover)return void r.toggle(!0);var e=!r.$inline.is(":visible");r.toggle(e)}),l.on("click",function(){var l=r.asPopover?c:f;i(l,"kv-editable-processing"),p.show(),k.val(1),a.find("input, select").each(function(){e(this).trigger("change")}),n=e.extend({type:a.attr("method"),url:a.attr("action"),data:a.serialize(),dataType:"json",error:function(e,t,i){r.showAjaxErrors&&o(i),v.trigger("editableAjaxError",[e,t,i])},success:function(i){return y="",C=t(i.output)?h.val():i.output,r.refreshPopover(),t(i.message)?(t(E.attr("class"))||(b.removeClass("has-error"),E.html("").hide(),m.html("")),a.find(".help-block").each(function(){var i=e(this).text();y+=i?i.trim():"",t(y)||p.hide()}),t(y)?(p.hide(),t(C)?C=r.valueIfNull:void 0!==$[C]&&(C=$[C]),j?(g.find(".help-block").remove(),g.removeClass("has-error"),m.html(""),r.toggle(!1),r.$value.html(C)):(b.removeClass("has-error"),m.html(""),r.toggle(!1),r.$value.html(C),P&&(a.yiiActiveForm("destroy"),a.yiiActiveForm(P.attributes,P.settings))),v.trigger("editableSuccess",[h.val(),a,i])):v.trigger("editableError",[h.val(),a,i]),void l.removeClass("kv-editable-processing")):(o(i.message),void v.trigger("editableError",[h.val(),a,i]))}},r.ajaxSettings),e.ajax(n),v.trigger("editableSubmit",[h.val(),a])})}},e.fn.editable=function(t){var i=Array.apply(null,arguments);return i.shift(),this.each(function(){var o=e(this),r=o.data("editable"),a="object"==typeof t&&t;r||(r=new n(this,e.extend({},e.fn.editable.defaults,a,e(this).data())),o.data("editable",r)),"string"==typeof t&&r[t].apply(r,i)})},e.fn.editable.defaults={valueIfNull:"(not set)",placement:"right",displayValueConfig:{},ajaxSettings:{},showAjaxErrors:!0,submitOnEnter:!0,asPopover:!0},e.fn.editable.Constructor=n}(window.jQuery); \ No newline at end of file diff --git a/messages/config.php b/messages/config.php index a28e5e4..656533e 100644 --- a/messages/config.php +++ b/messages/config.php @@ -2,12 +2,12 @@ return [ // string, required, root directory of all source files - 'sourcePath' => __DIR__, + 'sourcePath' => __DIR__ . DIRECTORY_SEPARATOR . '..', // string, required, root directory containing message translations. - 'messagePath' => __DIR__ . DIRECTORY_SEPARATOR . 'messages', + 'messagePath' => __DIR__, // array, required, list of language codes that the extracted messages // should be translated to. For example, ['zh-CN', 'de']. - 'languages' => ['da', 'en', 'ru','it', 'es', 'lt'], + 'languages' => ['da', 'de', 'es', 'fr', 'hu', 'it', 'lt', 'pt-BR', 'ru', 'vi'], // string, the name of the function for translating messages. // Defaults to 'Yii::t'. This is used as a mark to find the messages to be // translated. You may use a string for single function name or an array for diff --git a/messages/da/kveditable.php b/messages/da/kveditable.php index 2eb5deb..fcb1703 100644 --- a/messages/da/kveditable.php +++ b/messages/da/kveditable.php @@ -17,8 +17,9 @@ * NOTE: this file must be saved in UTF-8 encoding. */ return [ + '(not set)' => '(ikke defineret)', 'Apply' => 'Anvend', - 'Reset' => 'Nulstil', + 'Close' => '', 'Edit' => 'Redigere', - '(not set)' => '(ikke defineret)', -]; \ No newline at end of file + 'Reset' => 'Nulstil', +]; diff --git a/messages/de/kveditable.php b/messages/de/kveditable.php index 11f0a84..2d4c702 100644 --- a/messages/de/kveditable.php +++ b/messages/de/kveditable.php @@ -17,8 +17,9 @@ * NOTE: this file must be saved in UTF-8 encoding. */ return [ + '(not set)' => '(nicht gesetzt)', 'Apply' => 'Übernehmen', - 'Reset' => 'Zurücksetzen', + 'Close' => '', 'Edit' => 'Bearbeiten', - '(not set)' => '(nicht gesetzt)', + 'Reset' => 'Zurücksetzen', ]; \ No newline at end of file diff --git a/messages/en/kveditable.php b/messages/en/kveditable.php deleted file mode 100644 index 19df1d4..0000000 --- a/messages/en/kveditable.php +++ /dev/null @@ -1,24 +0,0 @@ - '', - 'Reset' => '', - 'Edit' => '', - '(not set)' => '', -]; diff --git a/messages/es/kveditable.php b/messages/es/kveditable.php index f6cfa11..2bbe79a 100644 --- a/messages/es/kveditable.php +++ b/messages/es/kveditable.php @@ -17,8 +17,9 @@ * NOTE: this file must be saved in UTF-8 encoding. */ return [ + '(not set)' => '(vacio)', 'Apply' => 'Aplicar', - 'Reset' => 'Reiniciar', + 'Close' => '', 'Edit' => 'Editar', - '(not set)' => '(vacio)', + 'Reset' => 'Reiniciar', ]; diff --git a/messages/fr/kveditable.php b/messages/fr/kveditable.php index e432e13..8c6205f 100644 --- a/messages/fr/kveditable.php +++ b/messages/fr/kveditable.php @@ -17,8 +17,9 @@ * NOTE: this file must be saved in UTF-8 encoding. */ return [ + '(not set)' => '(non défini)', 'Apply' => 'Appliquer', - 'Reset' => 'Réinitialiser', + 'Close' => '', 'Edit' => 'Modifier', - '(not set)' => '(non défini)', + 'Reset' => 'Réinitialiser', ]; diff --git a/messages/hu/kveditable.php b/messages/hu/kveditable.php index 52b0435..9457304 100644 --- a/messages/hu/kveditable.php +++ b/messages/hu/kveditable.php @@ -17,8 +17,9 @@ * NOTE: this file must be saved in UTF-8 encoding. */ return [ + '(not set)' => '(nincs beállítva)', 'Apply' => 'Alkalmaz', - 'Reset' => 'Alaphelyzet', + 'Close' => '', 'Edit' => 'Szerkesztés', - '(not set)' => '(nincs beállítva)', + 'Reset' => 'Alaphelyzet', ]; \ No newline at end of file diff --git a/messages/it/kveditable.php b/messages/it/kveditable.php index 05f10cc..339534e 100644 --- a/messages/it/kveditable.php +++ b/messages/it/kveditable.php @@ -17,8 +17,9 @@ * NOTE: this file must be saved in UTF-8 encoding. */ return [ + '(not set)' => '(non impostato)', 'Apply' => 'Applica', - 'Reset' => 'Resetta', + 'Close' => '', 'Edit' => 'Modifica', - '(not set)' => '(non impostato)', + 'Reset' => 'Resetta', ]; diff --git a/messages/pt-BR/kveditable.php b/messages/pt-BR/kveditable.php index 90cc8e3..bdab3fd 100644 --- a/messages/pt-BR/kveditable.php +++ b/messages/pt-BR/kveditable.php @@ -17,8 +17,9 @@ * NOTE: this file must be saved in UTF-8 encoding. */ return [ + '(not set)' => '(não definido)', 'Apply' => 'Aplicar', - 'Reset' => 'Resetar', + 'Close' => '', 'Edit' => 'Editar', - '(not set)' => '(não definido)', + 'Reset' => 'Resetar', ]; \ No newline at end of file diff --git a/messages/ru/kveditable.php b/messages/ru/kveditable.php index 659dd69..f485559 100644 --- a/messages/ru/kveditable.php +++ b/messages/ru/kveditable.php @@ -17,8 +17,9 @@ * NOTE: this file must be saved in UTF-8 encoding. */ return [ + '(not set)' => '(не задано)', 'Apply' => 'Применить', - 'Reset' => 'Сбросить', + 'Close' => '', 'Edit' => 'Редактировать', - '(not set)' => '(не задано)', + 'Reset' => 'Сбросить', ]; diff --git a/messages/vi/kveditable.php b/messages/vi/kveditable.php index efe8bed..7fec502 100644 --- a/messages/vi/kveditable.php +++ b/messages/vi/kveditable.php @@ -18,8 +18,9 @@ * NOTE: this file must be saved in UTF-8 encoding. */ return [ + '(not set)' => '(chưa thiết lập)', 'Apply' => 'Thiết lập', - 'Reset' => 'Gán giá trị mặc định', + 'Close' => '', 'Edit' => 'Sửa', - '(not set)' => '(chưa thiết lập)', + 'Reset' => 'Gán giá trị mặc định', ];