diff --git a/modules/backend/formwidgets/recordfinder/assets/js/recordfinder.js b/modules/backend/formwidgets/recordfinder/assets/js/recordfinder.js
index aa655323b..f5ddea208 100644
--- a/modules/backend/formwidgets/recordfinder/assets/js/recordfinder.js
+++ b/modules/backend/formwidgets/recordfinder/assets/js/recordfinder.js
@@ -14,24 +14,38 @@
+function ($) { "use strict";
+ var Base = $.oc.foundation.base,
+ BaseProto = Base.prototype
+
// RECORDFINDER CLASS DEFINITION
// ============================
var RecordFinder = function(element, options) {
- var self = this
this.options = options
this.$el = $(element)
- this.$el.on('dblclick', function () {
- $('.btn:first', self.$el).trigger('click')
- })
+ Base.call(this)
+ this.init()
}
+
+ RecordFinder.prototype = Object.create(BaseProto)
+ RecordFinder.prototype.constructor = RecordFinder
+
RecordFinder.DEFAULTS = {
refreshHandler: null,
dataLocker: null
}
+ RecordFinder.prototype.init = function() {
+ var self = this
+ this.$el.on('dblclick', function () {
+ $('.btn.find-record', self.$el).trigger('click')
+ })
+
+ this.$el.on('click', '.clear-record', this.proxy(this.clearRecord))
+ }
+
RecordFinder.prototype.updateRecord = function(linkEl, recordId) {
if (!this.options.dataLocker) return
var self = this
@@ -45,7 +59,13 @@
}
})
- $(linkEl).closest('.recordfinder-popup').popup('hide')
+ if(linkEl){
+ $(linkEl).closest('.recordfinder-popup').popup('hide')
+ }
+ }
+
+ RecordFinder.prototype.clearRecord = function() {
+ this.updateRecord(false, '')
}
// RECORDFINDER PLUGIN DEFINITION
diff --git a/modules/backend/formwidgets/recordfinder/partials/_recordfinder.htm b/modules/backend/formwidgets/recordfinder/partials/_recordfinder.htm
index 9aed1f357..27ab401da 100644
--- a/modules/backend/formwidgets/recordfinder/partials/_recordfinder.htm
+++ b/modules/backend/formwidgets/recordfinder/partials/_recordfinder.htm
@@ -17,7 +17,12 @@
previewMode): ?>
+