app/javascript/spotlight/admin/edit_in_place.js in blacklight-spotlight-4.1.2 vs app/javascript/spotlight/admin/edit_in_place.js in blacklight-spotlight-4.2.0
- old
+ new
@@ -41,7 +41,34 @@
});
return false;
});
})
+
+ $("[data-behavior='restore-default']").each(function(){
+ var hidden = $("[data-default-value]", $(this));
+ var value = $($("[data-in-place-edit-target]", $(this)).data('in-place-edit-target'), $(this));
+ var button = $("[data-restore-default]", $(this));
+
+ hidden.on('keypress', function(e) {
+ if(e.which == 13) {
+ hidden.trigger('blur');
+ return false;
+ }
+ });
+
+ hidden.on('blur', function(){
+ if( $(this).val() == $(this).data('default-value') ) {
+ button.addClass('d-none');
+ } else {
+ button.removeClass('d-none');
+ }
+ });
+ button.on('click', function(e){
+ e.preventDefault();
+ hidden.val(hidden.data('default-value'));
+ value.text(hidden.data('default-value'));
+ button.hide();
+ });
+ });
}
}