Skip to content

Commit

Permalink
Merge pull request #151 from Wybrenb/animation-delay
Browse files Browse the repository at this point in the history
Animation delay
  • Loading branch information
kartik-v committed Jan 30, 2017
2 parents d703b19 + 69b4772 commit 7d2afae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions Editable.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ class Editable extends InputWidget
* @var boolean whether to select all text in the input when editable is opened.
*/
public $selectAllOnEdit = true;

/**
* @var integer editable animation delay (in micro-seconds). Defaults to `200`.
*/
public $animationDelay = 200;

/**
* @var boolean whether to HTML encode the output via javascript after editable update. Defaults to `true`. Note that
Expand Down Expand Up @@ -537,6 +542,7 @@ public function registerAssets()
'selectAllOnEdit' => $this->selectAllOnEdit,
'encodeOutput' => $this->encodeOutput,
'validationDelay' => $this->validationDelay,
'animationDelay' => $this->animationDelay
];
$this->registerPlugin('editable', 'jQuery("#' . $this->containerOptions['id'] . '")');
if (!empty($this->pjaxContainerId)) {
Expand Down
13 changes: 7 additions & 6 deletions assets/js/editable.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@
}
},
closeClick: function () {
self.toggle(false);
self.toggle(false, self.animationDelay);
},
targetClick: function () {
var status;
if (self.asPopover) {
self.toggle(true);
self.toggle(true, self.animationDelay);
return;
}
status = !$inline.is(':visible');
self.toggle(status);
self.toggle(status, self.animationDelay);
},
resetClick: function () {
if (self.raise($el, 'editableReset')) {
Expand Down Expand Up @@ -207,12 +207,12 @@
$parent2.find('.help-block').remove();
$parent2.removeClass('has-error');
$message.html('');
self.toggle(false);
self.toggle(false, self.animationDelay);
self.$value.html(out);
} else {
$parent.removeClass('has-error');
$message.html('');
self.toggle(false);
self.toggle(false, self.animationDelay);
self.$value.html(out);
if (objActiveForm) {
$form.yiiActiveForm('destroy');
Expand Down Expand Up @@ -355,7 +355,8 @@
selectAllOnEdit: true,
asPopover: true,
encodeOutput: true,
validationDelay: 500
validationDelay: 500,
animationDelay: 200
};

$.fn.editable.Constructor = Editable;
Expand Down

0 comments on commit 7d2afae

Please sign in to comment.