Uses jeditable for key value prevalue editor inline edit, should support all chars now

This commit is contained in:
starfighter83
2011-04-26 10:00:41 -02:00
parent 7b66d80f5c
commit f1196aa088
5 changed files with 550 additions and 82 deletions

View File

@@ -1,7 +1,7 @@
jQuery(document).ready(function () {
jQuery("#prevalues .text").valuesInlineEdit();
jQuery("#prevalues .text").editable(function (value, settings) { $(this).html(value); ResetValues(); }, { onblur: 'submit', tooltip: 'Click to edit', cssclass: 'inlineEditor' });
jQuery("#prevalues tbody").sortable({
items: "tr:not(.header)",
@@ -35,83 +35,3 @@ function ResetValues() {
jQuery(".valuesHiddenInput").val(val);
}
//inline edit
(function ($) {
$.fn.valuesInlineEdit = function (options) {
options = $.extend({
hover: 'hover',
value: '',
save: '',
placeholder: 'Click to edit'
}, options);
return $.each(this, function () {
$.valuesInlineEdit(this, options);
});
}
$.valuesInlineEdit = function (obj, options) {
var self = $(obj),
placeholderHtml = '<span class="inlineEdit-placeholder">' + options.placeholder + '</span>';
self.value = function (newValue) {
if (arguments.length) {
self.data('value', $(newValue).hasClass('inlineEdit-placeholder') ? '' : newValue);
}
return self.data('value');
}
self.value($.trim(self.text()) || options.value);
self.bind('click', function (event) {
var $this = $(event.target);
if ($this.is(self[0].tagName) || $this.hasClass('inlineEdit-placeholder')) {
self
.html('<input type="text" value="' + self.value() + '">')
.find('input')
.bind('blur', function () {
if ($this.children('input').val().length > 0) {
try {
self.value($this.children('input').val());
} catch (err) { }
}
else {
self.value('Click to edit');
}
if (self.timer) {
window.clearTimeout(self.timer);
}
self.timer = window.setTimeout(function () {
self.html(self.value() || placeholderHtml);
self.removeClass(options.hover);
ResetValues();
}, 200);
})
.focus();
}
})
.hover(
function () {
$(this).addClass(options.hover);
},
function () {
$(this).removeClass(options.hover);
}
);
if (!self.value()) {
self.html($(placeholderHtml));
}
}
})(jQuery);