Added oc.inputPreset.beforeUpdate plugin hook (#4217)

Refs: https://github.com/rainlab/translate-plugin/issues/429
This commit is contained in:
Marc Jauvin 2019-04-02 10:48:53 -04:00 committed by Luke Towers
parent b3eb95bb62
commit eaaf8a6b3d
2 changed files with 28 additions and 25 deletions

View File

@ -222,25 +222,26 @@
this.$src = $(options.inputPreset, parent)
this.$src.on('input', function() {
if (self.cancelled)
return
$el
.val(prefix + self.formatValue())
.trigger('oc.inputPreset.afterUpdate')
})
this.$src.on('paste', function() {
if (self.cancelled)
return
setTimeout(function() {
$el
.val(prefix + self.formatValue())
.trigger('oc.inputPreset.afterUpdate')
}, 100)
})
this.$src.on('input paste', function(event) {
if (self.cancelled)
return
var timeout = event.type === 'paste' ? 100 : 0
var updateValue = function(self, el, prefix) {
if (el.data('update') === false) {
return
}
el
.val(prefix + self.formatValue())
.trigger('oc.inputPreset.afterUpdate')
}
var src = $(this)
setTimeout(function() {
$el.trigger('oc.inputPreset.beforeUpdate', [src])
setTimeout(updateValue, 100, self, $el, prefix)
}, timeout)
})
this.$el.on('change', function() {
self.cancelled = true

View File

@ -4201,14 +4201,16 @@ if(prefix===undefined)
prefix=''
if($el.val().length&&$el.val()!=prefix)
return
$el.val(prefix).trigger('oc.inputPreset.afterUpdate')
this.$src=$(options.inputPreset,parent)
this.$src.on('input',function(){if(self.cancelled)
$el.val(prefix).trigger('oc.inputPreset.afterUpdate')
this.$src.on('input paste',function(event){if(self.cancelled)
return
$el.val(prefix+self.formatValue()).trigger('oc.inputPreset.afterUpdate')})
this.$src.on('paste',function(){if(self.cancelled)
return
setTimeout(function(){$el.val(prefix+self.formatValue()).trigger('oc.inputPreset.afterUpdate')},100)})
var timeout=event.type==='paste'?100:0
var updateValue=function(self,el,prefix){if(el.data('update')===false){return}
el.val(prefix+self.formatValue()).trigger('oc.inputPreset.afterUpdate')}
var src=$(this)
setTimeout(function(){$el.trigger('oc.inputPreset.beforeUpdate',[src])
setTimeout(updateValue,100,self,$el,prefix)},timeout)})
this.$el.on('change',function(){self.cancelled=true})}
InputPreset.prototype.formatNamespace=function(){var value=this.toCamel(this.$src.val())
return value.substr(0,1).toUpperCase()+value.substr(1)}