diff options
| author | Greg Roach <fisharebest@gmail.com> | 2014-05-04 00:03:48 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2014-05-04 00:03:48 +0100 |
| commit | 842c8f4a74336c3fc790f86d7f0122e10270f7d9 (patch) | |
| tree | deeee465355925dd037bcd9ac2d540607220c327 /js | |
| parent | 705acf9d6d2f3492716456d54afa336fc9593fe1 (diff) | |
| download | webtrees-842c8f4a74336c3fc790f86d7f0122e10270f7d9.tar.gz webtrees-842c8f4a74336c3fc790f86d7f0122e10270f7d9.tar.bz2 webtrees-842c8f4a74336c3fc790f86d7f0122e10270f7d9.zip | |
Upgrade jquery.jeditable from 1.7.1 to 1.7.3
Diffstat (limited to 'js')
| -rw-r--r-- | js/jquery.jeditable-1.7.3.js (renamed from js/jquery.jeditable-1.7.1.js) | 119 |
1 files changed, 61 insertions, 58 deletions
diff --git a/js/jquery.jeditable-1.7.1.js b/js/jquery.jeditable-1.7.3.js index 003000ed8e..49b2612a58 100644 --- a/js/jquery.jeditable-1.7.1.js +++ b/js/jquery.jeditable-1.7.3.js @@ -1,7 +1,7 @@ /* * Jeditable - jQuery in place edit plugin * - * Copyright (c) 2006-2009 Mika Tuupola, Dylan Verheul + * Copyright (c) 2006-2013 Mika Tuupola, Dylan Verheul * * Licensed under the MIT license: * http://www.opensource.org/licenses/mit-license.php @@ -15,7 +15,7 @@ */ /** - * Version 1.7.1 + * Version 1.7.3 * * ** means there is basic unit tests for this parameter. * @@ -96,7 +96,7 @@ var onreset = settings.onreset || function() { }; var onerror = settings.onerror || reset; - /* show tooltip */ + /* Show tooltip. */ if (settings.tooltip) { $(this).attr('title', settings.tooltip); } @@ -106,52 +106,51 @@ return this.each(function() { - /* save this to self because this changes when scope changes */ + /* Save this to self because this changes when scope changes. */ var self = this; - /* inlined block elements lose their width and height after first edit */ - /* save them for later use as workaround */ + /* Inlined block elements lose their width and height after first edit. */ + /* Save them for later use as workaround. */ var savedwidth = $(self).width(); var savedheight = $(self).height(); - - /* save so it can be later used by $.editable('destroy') */ + + /* Save so it can be later used by $.editable('destroy') */ $(this).data('event.editable', settings.event); - /* if element is empty add something clickable (if requested) */ + /* If element is empty add something clickable (if requested) */ if (!$.trim($(this).html())) { $(this).html(settings.placeholder); } $(this).bind(settings.event, function(e) { - /* abort if disabled for this element */ + /* Abort if element is disabled. */ if (true === $(this).data('disabled.editable')) { return; } - /* prevent throwing an exeption if edit field is clicked again */ + /* Prevent throwing an exeption if edit field is clicked again. */ if (self.editing) { return; } - /* abort if onedit hook returns false */ + /* Abort if onedit hook returns false. */ if (false === onedit.apply(this, [settings, self])) { return; } - /* prevent default action and bubbling */ + /* Prevent default action and bubbling. */ e.preventDefault(); e.stopPropagation(); - /* remove tooltip */ + /* Remove tooltip. */ if (settings.tooltip) { $(self).removeAttr('title'); } - /* figure out how wide and tall we are, saved width and height */ - /* are workaround for http://dev.jquery.com/ticket/2190 */ + /* Figure out how wide and tall we are, saved width and height. */ + /* Workaround for http://dev.jquery.com/ticket/2190 */ if (0 == $(self).width()) { - //$(self).css('visibility', 'hidden'); settings.width = savedwidth; settings.height = savedheight; } else { @@ -164,11 +163,10 @@ settings.autoheight ? $(self).height() : settings.height; } } - //$(this).css('visibility', ''); - /* remove placeholder text, replace is here because of IE */ - if ($(this).html().toLowerCase().replace(/(;|")/g, '') == - settings.placeholder.toLowerCase().replace(/(;|")/g, '')) { + /* Remove placeholder text, replace is here because of IE. */ + if ($(this).html().toLowerCase().replace(/(;|"|\/)/g, '') == + settings.placeholder.toLowerCase().replace(/(;|"|\/)/g, '')) { $(this).html(''); } @@ -176,10 +174,10 @@ self.revert = $(self).html(); $(self).html(''); - /* create the form object */ + /* Create the form object. */ var form = $('<form />'); - /* apply css or style or both */ + /* Apply css or style or both. */ if (settings.cssclass) { if ('inherit' == settings.cssclass) { form.attr('class', $(self).attr('class')); @@ -191,17 +189,17 @@ if (settings.style) { if ('inherit' == settings.style) { form.attr('style', $(self).attr('style')); - /* IE needs the second line or display wont be inherited */ + /* IE needs the second line or display wont be inherited. */ form.css('display', $(self).css('display')); } else { form.attr('style', settings.style); } } - /* add main input element to form and store it in input */ + /* Add main input element to form and store it in input. */ var input = element.apply(form, [settings, self]); - /* set input content via POST, GET, given data or existing value */ + /* Set input content via POST, GET, given data or existing value. */ var input_content; if (settings.loadurl) { @@ -240,19 +238,19 @@ input.attr('name', settings.name); - /* add buttons to the form */ + /* Add buttons to the form. */ buttons.apply(form, [settings, self]); - /* add created form to self */ + /* Add created form to self. */ $(self).append(form); - /* attach 3rd party plugin if requested */ + /* Attach 3rd party plugin if requested. */ plugin.apply(form, [settings, self]); - /* focus to first visible form element */ + /* Focus to first visible form element. */ $(':input:visible:enabled:first', form).focus(); - /* highlight input contents when requested */ + /* Highlight input contents when requested. */ if (settings.select) { input.select(); } @@ -261,24 +259,23 @@ input.keydown(function(e) { if (e.keyCode == 27) { e.preventDefault(); - //self.reset(); reset.apply(form, [settings, self]); } }); - /* discard, submit or nothing with changes when clicking outside */ - /* do nothing is usable when navigating with tab */ + /* Discard, submit or nothing with changes when clicking outside. */ + /* Do nothing is usable when navigating with tab. */ var t; if ('cancel' == settings.onblur) { input.blur(function(e) { - /* prevent canceling if submit was clicked */ + /* Prevent canceling if submit was clicked. */ t = setTimeout(function() { reset.apply(form, [settings, self]); }, 500); }); } else if ('submit' == settings.onblur) { input.blur(function(e) { - /* prevent double submit if submit was clicked */ + /* Prevent double submit if submit was clicked. */ t = setTimeout(function() { form.submit(); }, 200); @@ -299,17 +296,17 @@ clearTimeout(t); } - /* do no submit */ + /* Do no submit. */ e.preventDefault(); - /* call before submit hook. */ - /* if it returns false abort submitting */ + /* Call before submit hook. */ + /* If it returns false abort submitting. */ if (false !== onsubmit.apply(form, [settings, self])) { - /* custom inputs call before submit hook. */ - /* if it returns false abort submitting */ + /* Custom inputs call before submit hook. */ + /* If it returns false abort submitting. */ if (false !== submit.apply(form, [settings, self])) { - /* check if given target is function */ + /* Check if given target is function */ if ($.isFunction(settings.target)) { var str = settings.target.apply(self, [input.val(), settings]); $(self).html(str); @@ -320,26 +317,26 @@ $(self).html(settings.placeholder); } } else { - /* add edited content and id of edited element to POST */ + /* Add edited content and id of edited element to POST. */ var submitdata = {}; submitdata[settings.name] = input.val(); submitdata[settings.id] = self.id; - /* add extra data to be POST:ed */ + /* Add extra data to be POST:ed. */ if ($.isFunction(settings.submitdata)) { $.extend(submitdata, settings.submitdata.apply(self, [self.revert, settings])); } else { $.extend(submitdata, settings.submitdata); } - /* quick and dirty PUT support */ + /* Quick and dirty PUT support. */ if ('PUT' == settings.method) { submitdata['_method'] = 'put'; } - /* show the saving indicator */ + /* Show the saving indicator. */ $(self).html(settings.indicator); - /* defaults for ajaxoptions */ + /* Defaults for ajaxoptions. */ var ajaxoptions = { type : 'POST', data : submitdata, @@ -360,7 +357,7 @@ } }; - /* override with what is given in settings.ajaxoptions */ + /* Override with what is given in settings.ajaxoptions. */ $.extend(ajaxoptions, settings.ajaxoptions); $.ajax(ajaxoptions); @@ -368,25 +365,25 @@ } } - /* show tooltip again */ + /* Show tooltip again. */ $(self).attr('title', settings.tooltip); return false; }); }); - /* privileged methods */ + /* Privileged methods */ this.reset = function(form) { - /* prevent calling reset twice when blurring */ + /* Prevent calling reset twice when blurring. */ if (this.editing) { - /* before reset hook, if it returns false abort reseting */ + /* Before reset hook, if it returns false abort reseting. */ if (false !== onreset.apply(form, [settings, self])) { $(self).html(self.revert); self.editing = false; if (!$.trim($(self).html())) { $(self).html(settings.placeholder); } - /* show tooltip again */ + /* Show tooltip again. */ if (settings.tooltip) { $(self).attr('title', settings.tooltip); } @@ -415,14 +412,14 @@ buttons : function(settings, original) { var form = this; if (settings.submit) { - /* if given html string use that */ + /* If given html string use that. */ if (settings.submit.match(/>$/)) { var submit = $(settings.submit).click(function() { if (submit.attr("type") != "submit") { form.submit(); } }); - /* otherwise use button with given string as text */ + /* Otherwise use button with given string as text. */ } else { var submit = $('<button type="submit" />'); submit.html(settings.submit); @@ -430,7 +427,7 @@ $(this).append(submit); } if (settings.cancel) { - /* if given html string use that */ + /* If given html string use that. */ if (settings.cancel.match(/>$/)) { var cancel = $(settings.cancel); /* otherwise use button with given string as text */ @@ -441,7 +438,6 @@ $(this).append(cancel); $(cancel).click(function(event) { - //original.reset(); if ($.isFunction($.editable.types[settings.type].reset)) { var reset = $.editable.types[settings.type].reset; } else { @@ -513,6 +509,13 @@ $(this).attr('selected', 'selected'); } }); + /* Submit on change if no submit button defined. */ + if (!settings.submit) { + var form = this; + $('select', this).change(function() { + form.submit(); + }); + } } } }, @@ -523,7 +526,7 @@ } }; - // publicly accessible defaults + /* Publicly accessible defaults. */ $.fn.editable.defaults = { name : 'value', id : 'id', |
