-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.unform.js
38 lines (38 loc) · 1.59 KB
/
jquery.unform.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(function($) {
var YesNo = new Array();
YesNo["true"] = "Yes";
YesNo["false"] = "No";
$.fn.inline = function() {
var editable = $(this);
this.each(function() {
$(this).find('input, select, textarea').not('[type=button],[type=submit]').each(function() {
if ($(this).attr("type") == "checkbox") {
$(this).parent().append("<span class=\"editable\">" + YesNo[$(this).attr('checked')] + "</span>");
$(this).hide();
$(this).bind('blur', function() {
var t = YesNo[$(this).attr('checked')];
$(this).hide().next().show().text(t);
});
}
else {
$(this).parent().append("<span class=\"editable\">" + $(this).val() + "</span>");
$(this).hide();
$(this).bind('blur', function() {
var t = $(this).val();
$(this).hide().next().show().text(t);
});
}
});
$('.editable').live('dblclick', function() {
$(this).hide().prev().show().focus();
});
$('.make-editable').toggle(
function() {
$('.editable').hide().prev().show();
}, function() {
$('.editable').remove();
$(editable).inline();
});
});
};
})(jQuery);