diff --git a/bootstrap-editable.css b/bootstrap-editable.css index 39ad8eb..182e2fc 100644 --- a/bootstrap-editable.css +++ b/bootstrap-editable.css @@ -134,7 +134,7 @@ top: 50%; right: 6px; margin-top: -6px; - + cursor: pointer; } .editable-clear-x:hover { diff --git a/editable.js b/editable.js index 6b611b1..e3f5b50 100644 --- a/editable.js +++ b/editable.js @@ -91,16 +91,16 @@ m_editable.events({ var val = mEditable.getVal(this.type)(tmpl.$('.editable-input')); - if (typeof self.onsubmit === 'function') { + if (typeof self.onSubmit === 'function') { if (self.async) { tmpl.Session.set('loading', true); - this.onsubmit.call(this, val, function () { + this.onSubmit.call(this, val, function () { tmpl.$('.m_editable-popup').trigger('hide'); doSavedTransition(tmpl); }); return; } - this.onsubmit.call(this, val); + this.onSubmit.call(this, val); } else { tmpl.$('.editable-click').text(val); } @@ -197,6 +197,7 @@ function resizePopover ($popover, placement) { $.fn.tooltip.Constructor.prototype.applyPlacement.call({ tip: function () { return $popover; }, + getViewportAdjustedDelta: function () { return { top: 0, left: 0 }; }, replaceArrow: function (delta, dimension, position) { $popover.find('.arrow').css(position, delta ? (50 * (1 - delta / dimension) + '%') : ''); } }, calculatedOffset, placement); } @@ -258,7 +259,7 @@ function generateSettings (settings) { select2: {}, combodate: {}, showbuttons: true, - onsubmit: null, + onSubmit: null, value: null, position: 'left', title: null, @@ -275,8 +276,8 @@ function doSavedTransition (tmpl) { if(bgColor === 'transparent') { bgColor = ''; } - $e.css('background-color', bgColor); $e.addClass('editable-bg-transition'); + $e.css('background-color', bgColor); setTimeout(function(){ $e.removeClass('editable-bg-transition'); }, 1700); diff --git a/inputs/text/text.js b/inputs/text/text.js index 320f653..5329201 100644 --- a/inputs/text/text.js +++ b/inputs/text/text.js @@ -23,9 +23,21 @@ _.each(types, function (t) { }); }); +Template.m_editable_form_text.rendered = function() { + this.$('.editable-clear-x').toggle(!!this.data.value); +}; + Template.m_editable_form_text.events({ 'input input[type="range"]': function (e, tmpl) { tmpl.$('.output').text(tmpl.$(e.target).val()); + }, + 'click .editable-clear-x': function (e, tmpl) { + tmpl.$('input').val(''); + tmpl.$('.editable-clear-x').hide(); + }, + 'keyup input, change input': function (e, tmpl) { + var value = tmpl.$('input').val(); + tmpl.$('.editable-clear-x').toggle(!!value); } }); Template.m_editable_form_text.helpers({ diff --git a/package.js b/package.js index c60f6a9..41de29a 100644 --- a/package.js +++ b/package.js @@ -31,6 +31,9 @@ Package.on_use(function (api) { // main files api.add_files([ + 'img/loading.gif', + 'img/clear.png', + 'bootstrap-editable.css', 'editable.html', 'editable.js'