diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-07 00:05:49 -0800 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-07 00:05:49 -0800 |
commit | e300ede3d8311bf236594480355f710b39aaa451 (patch) | |
tree | 382d16032be71f7ea280660bbbdac24b77e254f3 | |
parent | ad8579e11a0860006cecf9312c86c1a2c4e8418a (diff) |
1) Change the name of the form and message to g-in-place-edit-form and g-in-place-edit-message.
2) Make sure the cancel button works and cleans up the dom appropriately.
-rw-r--r-- | lib/gallery.in_place_edit.js | 27 | ||||
-rw-r--r-- | modules/gallery/css/gallery.css | 2 | ||||
-rw-r--r-- | modules/gallery/views/in_place_edit.html.php | 4 | ||||
-rw-r--r-- | themes/admin_wind/css/screen.css | 2 | ||||
-rw-r--r-- | themes/night_wind/css/screen.css | 2 | ||||
-rw-r--r-- | themes/wind/css/screen.css | 2 |
6 files changed, 24 insertions, 15 deletions
diff --git a/lib/gallery.in_place_edit.js b/lib/gallery.in_place_edit.js index 4a90581b..681688e5 100644 --- a/lib/gallery.in_place_edit.js +++ b/lib/gallery.in_place_edit.js @@ -2,7 +2,6 @@ $.widget("ui.gallery_in_place_edit", { _init: function() { var self = this; - $(self).data("parent", self.element.parent()); this.element.click(function(event) { event.preventDefault(); self._show(event.currentTarget); @@ -15,11 +14,9 @@ var tag_width = $(target).width(); $(self).data("tag_width", tag_width); - var form = $("#g-inplace-edit-form"); + var form = $("#g-in-place-edit-form"); if (form.length > 0) { - var parent = form.parent(); - form.remove(); - parent.children().show(); + self._cancel(); } $.get(self.options.form_url.replace("__ID__", $(target).attr('rel')), function(data) { @@ -31,8 +28,7 @@ .focus(); $(".g-short-form").gallery_short_form(); parent.find("form .g-cancel").click(function(event) { - parent.find("form").remove(); - parent.children().show(); + self._cancel(); event.preventDefault(); return false; }); @@ -41,21 +37,34 @@ }, + _cancel: function() { + var parent = $("#g-in-place-edit-form").parent(); + $(parent).find("form").remove(); + $(parent).children().show(); + $("#g-in-place-edit-message").remove(); + }, + _ajaxify_edit: function() { var self = this; - var form = $($(self).data("parent")).find("form"); + var form = $("#g-in-place-edit-form"); $(form).ajaxForm({ dataType: "json", success: function(data) { if (data.result == "success") { window.location.reload(); } else { + var parent = $(form).parent(); $(form).replaceWith(data.form); var width = $(self).data("tag_width"); - $($(self).data("parent")).find("form :text") + $(parent).find("form :text") .width(width) .focus(); $(".g-short-form").gallery_short_form(); + $(parent).find("form .g-cancel").click(function(event) { + self._cancel(); + event.preventDefault(); + return false; + }); self._ajaxify_edit(); } } diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index 18d9a522..3262dee2 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -50,7 +50,7 @@ /* In-place edit ~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#g-inplace-edit-form ul { +#g-in-place-edit-form ul { margin: 0; } diff --git a/modules/gallery/views/in_place_edit.html.php b/modules/gallery/views/in_place_edit.html.php index 64671d57..03cbdc69 100644 --- a/modules/gallery/views/in_place_edit.html.php +++ b/modules/gallery/views/in_place_edit.html.php @@ -1,5 +1,5 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<?= form::open($action, array("method" => "post", "id" => "g-inplace-edit-form", "class" => "g-short-form"), $hidden) ?> +<?= form::open($action, array("method" => "post", "id" => "g-in-place-edit-form", "class" => "g-short-form"), $hidden) ?> <ul> <li <? if (!empty($errors["input"])): ?> class="g-error"<? endif ?>> <?= form::input("input", $form["input"], " class='textbox'") ?> @@ -11,6 +11,6 @@ </ul> <?= form::close() ?> <? if (!empty($errors["input"])): ?> -<div id="g-inplace-edit-message" class="g-error"><?= $errors["input"] ?></div> +<div id="g-in-place-edit-message" class="g-error"><?= $errors["input"] ?></div> <? endif ?> diff --git a/themes/admin_wind/css/screen.css b/themes/admin_wind/css/screen.css index 5fe47d76..3342bd83 100644 --- a/themes/admin_wind/css/screen.css +++ b/themes/admin_wind/css/screen.css @@ -383,7 +383,7 @@ th { } /* In-line editing ~~~~~~~~~~~~~~~~~~~~~~ */ -#g-inplace-edit-message { +#g-in-place-edit-message { background-color: #FFF; } diff --git a/themes/night_wind/css/screen.css b/themes/night_wind/css/screen.css index 1d5e5e2b..cd1824d1 100644 --- a/themes/night_wind/css/screen.css +++ b/themes/night_wind/css/screen.css @@ -456,7 +456,7 @@ li.g-error select { } /* In-line editing ~~~~~~~~~~~~~~~~~~~~~~ */ -#g-inplace-edit-message { +#g-in-place-edit-message { background-color: #FFF; } diff --git a/themes/wind/css/screen.css b/themes/wind/css/screen.css index 2ac37fb6..74771e07 100644 --- a/themes/wind/css/screen.css +++ b/themes/wind/css/screen.css @@ -300,7 +300,7 @@ td { } /* In-line editing ~~~~~~~~~~~~~~~~~~~~~~ */ -#g-inplace-edit-message { +#g-in-place-edit-message { background-color: #FFF; } |