From beb63a83804e57050a23b3a90ebed93be41b6769 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 6 Nov 2009 23:05:20 -0800 Subject: Clean up the In place edit api: 1) Only allow 1 in place edit to be active at a time (gets around the issue of using an id to identify the form 2) remove the add_ prefix from some of the api methods 3) clean up inconsistent naming --- modules/gallery/libraries/InPlaceEdit.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'modules/gallery') diff --git a/modules/gallery/libraries/InPlaceEdit.php b/modules/gallery/libraries/InPlaceEdit.php index 057874e3..67ab3805 100644 --- a/modules/gallery/libraries/InPlaceEdit.php +++ b/modules/gallery/libraries/InPlaceEdit.php @@ -35,22 +35,22 @@ class InPlaceEdit_Core { return $instance; } - public function add_action($action) { + public function action($action) { $this->action = $action; return $this; } - public function add_rules($rules) { + public function rules($rules) { $this->rules += $rules; return $this; } - public function add_messages($messages) { + public function messages($messages) { $this->messages += $messages; return $this; } - public function add_callback($callback) { + public function callback($callback) { $this->callback = $callback; return $this; } -- cgit v1.2.3 From f176bc7299abc035d44b4b014781b4649585c639 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 6 Nov 2009 23:19:48 -0800 Subject: Correct spacing --- modules/gallery/tests/Item_Model_Test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules/gallery') diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index fefc9383..e7dce893 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -232,6 +232,7 @@ class Item_Model_Test extends Unit_Test_Case { $this->assert_equal("resize", file_get_contents($photo->resize_path())); $this->assert_equal("file", file_get_contents($photo->file_path())); } + public function move_album_fails_invalid_target_test() { // Create an album with a photo in it $root = ORM::factory("item", 1); -- cgit v1.2.3 From cbde32b0d2869396ce2863f2e9ce211a1d9fb555 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 6 Nov 2009 23:20:30 -0800 Subject: Make sure the position method works for both ascending and descending sort orders. --- modules/gallery/models/item.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/gallery') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 9735ed62..d27e331b 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -444,11 +444,11 @@ class Item_Model extends ORM_MPTT { $position = $db->from("items") ->where("parent_id", $this->id) - ->where("$sort_column < ", $child->$sort_column) + ->where("$sort_column $comp ", $child->$sort_column) ->where($where) ->count_records(); - // We stopped short of our target value in the sort (notice that we're using a < comparator + // We stopped short of our target value in the sort (notice that we're using a < comparator // above) because it's possible that we have duplicate values in the sort column. An // equality check would just arbitrarily pick one of those multiple possible equivalent // columns, which would mean that if you choose a sort order that has duplicates, it'd pick -- cgit v1.2.3 From e300ede3d8311bf236594480355f710b39aaa451 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 7 Nov 2009 00:05:49 -0800 Subject: 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. --- lib/gallery.in_place_edit.js | 27 ++++++++++++++++++--------- modules/gallery/css/gallery.css | 2 +- modules/gallery/views/in_place_edit.html.php | 4 ++-- themes/admin_wind/css/screen.css | 2 +- themes/night_wind/css/screen.css | 2 +- themes/wind/css/screen.css | 2 +- 6 files changed, 24 insertions(+), 15 deletions(-) (limited to 'modules/gallery') 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 @@ - "post", "id" => "g-inplace-edit-form", "class" => "g-short-form"), $hidden) ?> + "post", "id" => "g-in-place-edit-form", "class" => "g-short-form"), $hidden) ?>
  • class="g-error"> @@ -11,6 +11,6 @@
-
+
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; } -- cgit v1.2.3