62 $.fn.editable =
function(target, options) {
64 if (
'disable' == target) {
65 $(
this).data(
'disabled.editable',
true);
68 if (
'enable' == target) {
69 $(
this).data(
'disabled.editable',
false);
72 if (
'destroy' == target) {
74 .unbind($(
this).data(
'event.editable'))
75 .removeData(
'disabled.editable')
76 .removeData(
'event.editable');
80 var
settings = $.extend({}, $.fn.editable.defaults, {target:target}, options);
83 var plugin = $.editable.types[settings.type].plugin ||
function() { };
84 var
submit = $.editable.types[settings.type].submit ||
function() { };
85 var buttons = $.editable.types[settings.type].buttons
86 || $.editable.types[
'defaults'].buttons;
87 var
content = $.editable.types[settings.type].content
88 || $.editable.types[
'defaults'].content;
89 var element = $.editable.types[settings.type].element
90 || $.editable.types[
'defaults'].element;
91 var reset = $.editable.types[settings.type].reset
92 || $.editable.types[
'defaults'].reset;
93 var callback = settings.callback ||
function() { };
94 var onedit = settings.onedit ||
function() { };
95 var onsubmit = settings.onsubmit ||
function() { };
96 var onreset = settings.onreset ||
function() { };
97 var onerror = settings.onerror || reset;
100 if (settings.tooltip) {
101 $(
this).attr(
'title', settings.tooltip);
104 settings.autowidth =
'auto' == settings.width;
105 settings.autoheight =
'auto' == settings.height;
107 return this.each(
function() {
114 var savedwidth = $(
self).
width();
115 var savedheight = $(
self).
height();
118 $(
this).data(
'event.editable', settings.event);
121 if (!$.trim($(
this).html())) {
122 $(
this).
html(settings.placeholder);
125 $(
this).bind(settings.event,
function(e) {
128 if (
true === $(
this).data(
'disabled.editable')) {
138 if (
false === onedit.apply(
this, [settings,
self])) {
147 if (settings.tooltip) {
148 $(
self).removeAttr(
'title');
153 if (0 == $(
self).width()) {
154 settings.width = savedwidth;
155 settings.height = savedheight;
157 if (settings.width !=
'none') {
159 settings.autowidth ? $(
self).
width() : settings.width;
161 if (settings.height !=
'none') {
163 settings.autoheight ? $(
self).
height() : settings.height;
168 if ($(
this).html().toLowerCase().replace(/(;|
"|\/)/g, '') == 169 settings.placeholder.toLowerCase().replace(/(;|"|\/)/g,
'')) {
174 self.revert = $(
self).
html();
178 var
form = $(
'<form />');
181 if (settings.cssclass) {
182 if (
'inherit' == settings.cssclass) {
183 form.attr(
'class', $(
self).attr(
'class'));
185 form.attr(
'class', settings.cssclass);
189 if (settings.style) {
190 if (
'inherit' == settings.style) {
191 form.attr(
'style', $(
self).attr(
'style'));
193 form.css(
'display', $(
self).css(
'display'));
195 form.attr(
'style', settings.style);
200 var
input = element.apply(form, [settings,
self]);
205 if (settings.loadurl) {
206 var t = setTimeout(
function() {
207 input.disabled =
true;
208 content.apply(form, [settings.loadtext, settings,
self]);
212 loaddata[settings.id] =
self.id;
214 $.extend(loaddata, settings.loaddata.apply(
self, [
self.revert, settings]));
216 $.extend(loaddata, settings.loaddata);
219 type : settings.loadtype,
220 url : settings.loadurl,
224 window.clearTimeout(t);
225 input_content = result;
226 input.disabled =
false;
229 }
else if (settings.data) {
230 input_content = settings.data;
232 input_content = settings.data.apply(
self, [
self.revert, settings]);
235 input_content =
self.revert;
237 content.apply(form, [input_content, settings,
self]);
239 input.attr(
'name', settings.name);
242 buttons.apply(form, [settings,
self]);
245 $(
self).append(form);
248 plugin.apply(form, [settings,
self]);
251 $(
':input:visible:enabled:first',
form).focus();
254 if (settings.select) {
259 input.keydown(
function(e) {
260 if (e.keyCode == 27) {
262 reset.apply(form, [settings, self]);
269 if (
'cancel' == settings.onblur) {
270 input.blur(
function(e) {
272 t = setTimeout(
function() {
273 reset.apply(form, [settings,
self]);
276 }
else if (
'submit' == settings.onblur) {
277 input.blur(
function(e) {
279 t = setTimeout(
function() {
284 input.blur(
function(e) {
285 settings.onblur.apply(
self, [input.val(),
settings]);
288 input.blur(
function(e) {
293 form.submit(
function(e) {
304 if (
false !== onsubmit.apply(form, [settings,
self])) {
307 if (
false !== submit.apply(form, [settings,
self])) {
311 var str = settings.target.apply(
self, [input.val(),
settings]);
313 self.editing =
false;
314 callback.apply(
self, [
self.innerHTML, settings]);
316 if (!$.trim($(
self).
html())) {
317 $(
self).
html(settings.placeholder);
322 submitdata[settings.name] = input.val();
323 submitdata[settings.id] =
self.id;
326 $.extend(submitdata, settings.submitdata.apply(
self, [
self.revert, settings]));
328 $.extend(submitdata, settings.submitdata);
332 if (
'PUT' == settings.method) {
333 submitdata[
'_method'] =
'put';
337 $(
self).
html(settings.indicator);
344 url : settings.target,
345 success :
function(result, status) {
346 if (ajaxoptions.dataType ==
'html') {
347 $(
self).
html(result);
349 self.editing =
false;
350 callback.apply(
self, [result, settings]);
351 if (!$.trim($(
self).
html())) {
352 $(
self).
html(settings.placeholder);
356 onerror.apply(form, [settings,
self, xhr]);
361 $.extend(ajaxoptions, settings.ajaxoptions);
369 $(
self).attr(
'title', settings.tooltip);
376 this.reset =
function(
form) {
380 if (
false !== onreset.apply(form, [settings,
self])) {
381 $(
self).
html(
self.revert);
382 self.editing =
false;
383 if (!$.trim($(
self).html())) {
384 $(
self).
html(settings.placeholder);
387 if (settings.tooltip) {
388 $(
self).attr(
'title', settings.tooltip);
402 var input = $(
'<input type="hidden"></input>');
403 $(
this).append(input);
407 $(
':input:first',
this).val(
string);
414 if (settings.submit) {
416 if (settings.submit.match(/>$/)) {
417 var submit = $(settings.submit).
click(
function() {
418 if (submit.attr(
"type") !=
"submit") {
424 var submit = $(
'<button type="submit" />');
425 submit.html(settings.submit);
427 $(
this).append(submit);
429 if (settings.cancel) {
431 if (settings.cancel.match(/>$/)) {
432 var
cancel = $(settings.cancel);
435 var
cancel = $(
'<button type="cancel" />');
436 cancel.html(settings.cancel);
442 var reset = $.editable.types[settings.type].reset;
444 var reset = $.editable.types[
'defaults'].reset;
446 reset.apply(form, [settings,
original]);
454 var input = $(
'<input />');
455 if (settings.width !=
'none') { input.width(settings.width); }
456 if (settings.height !=
'none') { input.height(settings.height); }
459 input.attr(
'autocomplete',
'off');
460 $(
this).append(input);
466 var textarea = $(
'<textarea />');
468 textarea.attr(
'rows', settings.rows);
469 }
else if (settings.height !=
"none") {
470 textarea.height(settings.height);
473 textarea.attr(
'cols', settings.cols);
474 }
else if (settings.width !=
"none") {
475 textarea.width(settings.width);
477 $(
this).append(textarea);
483 var
select = $(
'<select />');
484 $(
this).append(select);
489 if (String == data.constructor) {
490 eval (
'var json = ' + data);
495 for (var key in json) {
496 if (!json.hasOwnProperty(key)) {
499 if (
'selected' == key) {
502 var option = $(
'<option />').val(key).append(json[key]);
503 $(
'select',
this).append(option);
506 $(
'select',
this).children().each(
function() {
507 if ($(
this).val() == json[
'selected'] ||
509 $(this).attr(
'selected',
'selected');
513 if (!settings.submit) {
515 $(
'select',
this).change(
function() {
530 $.fn.editable.defaults = {
536 event :
'click.editable',
539 loadtext :
'Loading...',
elgg message elgg state error
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the original
function elgg combo checkbox click(function(){if($(this).is(':checked')){$(this).prev().attr('disabled', true);$(this).prev().val('');}else{$(this).prev().attr('disabled', false);}})
elgg isFunction
Check if the value is a function.
elgg message elgg state success
if(!$site) if(!($site instanceof ElggSite)) $site url
elgg table input[type=checkbox]