From 5e703186fbf0c0cb689fc737de7c074249361ef9 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Feb 2010 08:23:43 -0800 Subject: Current state of organize. works for all browsers except IE. IE no longer implodes, but dragging doesn't work. Selecting works fine, either by using the lasso or clicking. Ctrl-Click adds to the selection. The problem is that when a drag is attempted, the selection gets lost and things start falling apart. --- modules/organize/js/organize.js | 56 ++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'modules/organize/js/organize.js') diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index 942e49e5..130c0f99 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -6,32 +6,30 @@ cursorAt: { left: -10, top: -10}, appendTo: "#g-organize-content-pane", helper: function(event, ui) { - var selected = $(".ui-draggable.ui-selected img"); - if (selected.length) { - var set = $('
') - .css({ - zIndex: 2000, - width: 80, - height: Math.ceil(selected.length / 5) * 16 - }); + var selected = $(".ui-selected"); + var set = $('
') + .css({ + zIndex: 2000, + width: 80, + height: Math.ceil(selected.length / 5) * 16 + }); - selected.each(function(i) { - var row = parseInt(i / 5); - var j = i - (row * 5); - var o = $(this).offset(); - var copy = $(this).clone() - .css({ - width: $(this).width(), height: $(this).height(), display: "block", - margin: 0, position: 'absolute', outline: '5px solid #fff', - left: o.left - event.pageX, top: o.top - event.pageY - }) - .appendTo(set) - .animate({ width: 10, height: 10, outlineWidth: 1, margin: 1, - left: (20 * j), top: (row * 20) }, 500); - }); - return set; - } - return null; + selected.each(function(i) { + var row = parseInt(i / 5); + var j = i - (row * 5); + var img = $("img", this); + var o = img.offset(); + var copy = img.clone() + .css({ + width: img.width(), height: img.height(), display: "block", + margin: 0, position: 'absolute', outline: '5px solid #fff', + left: o.left - event.pageX, top: o.top - event.pageY + }) + .appendTo(set) + .animate({ width: 10, height: 10, outlineWidth: 1, margin: 1, + left: (20 * j), top: (row * 20) }, 500); + }); + return set; }, start: function(event, ui) { @@ -138,6 +136,7 @@ }, grid_mouse_move_handler: function(event) { + var continue_events = true; if ($(".g-drag-helper").length) { var organizeData = $("#g-organize").data("organizeData"); var thumbGrid = $("#g-organize-microthumb-grid"); @@ -173,8 +172,13 @@ .data("drop_position", {id: $(item).attr("ref"), position: organizeData.rtl ? !before : before}); thumbGrid.append(set); + if ($.browser.msie) { + $(".g-drag-helper").offset({top: event.pageY, left: event.PageX}); + event.preventDefault(); + continue_events = false; + } } - return true; + return continue_events; }, /** -- cgit v1.2.3 From 67a8ef427798d37a9629c2f3d9672c03520b9987 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 27 Mar 2010 11:16:41 -0700 Subject: Convert the old organize to the new flex based organize --- modules/organize/controllers/organize.php | 163 ++--------- modules/organize/css/organize.css | 156 ---------- modules/organize/css/organize_theme.css | 18 +- modules/organize/helpers/organize_theme.php | 6 - modules/organize/js/organize.js | 317 --------------------- modules/organize/views/organize_dialog.html.php | 160 ++++++++--- .../organize/views/organize_thumb_grid.html.php | 22 -- modules/organize/views/organize_tree.html.php | 29 -- 8 files changed, 145 insertions(+), 726 deletions(-) delete mode 100644 modules/organize/css/organize.css delete mode 100644 modules/organize/js/organize.js delete mode 100644 modules/organize/views/organize_thumb_grid.html.php delete mode 100644 modules/organize/views/organize_tree.html.php (limited to 'modules/organize/js/organize.js') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 8dc8692c..8f9c3b5d 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -19,159 +19,30 @@ */ class Organize_Controller extends Controller { function dialog($album_id) { + $input = Input::instance(); + $album = ORM::factory("item", $album_id); access::required("view", $album); access::required("edit", $album); $v = new View("organize_dialog.html"); $v->album = $album; - $v->album_tree = self::_expanded_tree(ORM::factory("item", 1), $album); - $v->micro_thumb_grid = self::_get_micro_thumb_grid($album, 0); - print $v; - } - - function album($album_id, $offset) { - $album = ORM::factory("item", $album_id); - access::required("view", $album); - access::required("edit", $album); - - print json_encode( - array("grid" => (string)self::_get_micro_thumb_grid($album, $offset), - "sort_column" => $album->sort_column, - "sort_order" => $album->sort_order)); - } - - function move_to($target_album_id) { - access::verify_csrf(); - - $target_album = ORM::factory("item", $target_album_id); - access::required("view", $target_album); - access::required("add", $target_album); - - $source_album = null; - foreach (Input::instance()->post("source_ids") as $source_id) { - $source = ORM::factory("item", $source_id); - if (empty($source_album)) { // get the source_album - $source_album = $source->parent(); - } - if (!$source->contains($target_album)) { - access::required("edit", $source); - item::move($source, $target_album); - } + // @todo turn this into an api call. + $v->file_filter = json_encode(array("Images" => "*.jpg; *.jpeg; *.gif; *.png", + "Movies" => "*.flv; *.mp4")); + $v->domain = $input->server("SERVER_NAME"); + // @todo figure out how to connect this w/o a dependency + $v->base_url = url::abs_site("rest") . "/"; + + $v->sort_order = json_encode(array("ASC" => (string)t("Ascending"), "DESC" => (string)t("Descending"))); + $sort_fields = array(); + foreach (album::get_sort_order_options() as $field => $description) { + $sort_fields[$field] = (string)$description; } + $v->sort_fields = json_encode($sort_fields); - print json_encode( - array("tree" => (string)self::_expanded_tree(ORM::factory("item", 1), $source_album), - "grid" => (string)self::_get_micro_thumb_grid($source_album, 0))); - } - - function rearrange($target_id, $before_or_after) { - access::verify_csrf(); - - $target = ORM::factory("item", $target_id); - $album = $target->parent(); - access::required("view", $album); - access::required("edit", $album); - - //if (locales::is_rtl()) { // invert the position if the locale is rtl - // $before_or_after = $before_or_after == "after" ? "before" : "after"; - //} - - $source_ids = Input::instance()->post("source_ids", array()); - - if ($album->sort_column != "weight") { - $i = 0; - foreach ($album->children() as $child) { - // Do this directly in the database to avoid sending notifications - db::build() - ->update("items") - ->set("weight", ++$i) - ->where("id", "=", $child->id) - ->execute(); - } - $album->sort_column = "weight"; - $album->sort_order = "ASC"; - $album->save(); - $target->reload(); - } - - // Find the insertion point - $target_weight = $target->weight; - if ($before_or_after == "after") { - $target_weight++; - } - - // Make a hole - $count = count($source_ids); - db::build() - ->update("items") - ->set("weight", new Database_Expression("`weight` + $count")) - ->where("weight", ">=", $target_weight) - ->where("parent_id", "=", $album->id) - ->execute(); - - // Insert source items into the hole - foreach ($source_ids as $source_id) { - db::build() - ->update("items") - ->set("weight", $target_weight++) - ->where("id", "=", $source_id) - ->execute(); - } - - module::event("album_rearrange", $album); - - print json_encode( - array("grid" => (string)self::_get_micro_thumb_grid($album, 0), - "sort_column" => $album->sort_column, - "sort_order" => $album->sort_order)); - } - - public function sort_order($album_id, $col, $dir) { - access::verify_csrf(); - - $album = ORM::factory("item", $album_id); - access::required("view", $album); - access::required("edit", $album); - - $options = album::get_sort_order_options(); - if (!isset($options[$col])) { - return; - } - - $album->sort_column = $col; - $album->sort_order = $dir; - $album->save(); - - print json_encode( - array("grid" => (string)self::_get_micro_thumb_grid($album, 0), - "sort_column" => $album->sort_column, - "sort_order" => $album->sort_order)); - } - - private static function _get_micro_thumb_grid(Item_Model $album, $offset) { - $v = new View("organize_thumb_grid.html"); - $v->album = $album; - $v->offset = (int) $offset; - return $v; - } - - public function tree($album_id) { - $album = ORM::factory("item", $album_id); - access::required("view", $album); - - print self::_expanded_tree($album); - } - - /** - * Create an HTML representation of the tree from the root down to the selected album. We only - * include albums along the descendant hierarchy that includes the selected album, and the - * immediate child albums. - */ - private static function _expanded_tree($root, $selected_album=null) { - $v = new View("organize_tree.html"); - $v->album = $root; - $v->selected = $selected_album; - return $v; + $user = identity::active_user(); + $v->api_key = rest::get_access_token($user->id)->access_key; + print $v; } } diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css deleted file mode 100644 index 7a8c3a5f..00000000 --- a/modules/organize/css/organize.css +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************* - * Dialog wide styles - */ - -#g-organize { - margin: 0 !important; - min-height: auto; - padding: 0 !important; - position: relative; - width: 100%; -} - -#g-organize-content-pane { - height: 100%; - margin: 0 !important; - padding: 0 !important; - position: absolute; - width: 100%; -} - -/******************************************************************* - * Album Tree styles - */ - -#g-organize #g-organize-tree-container { - margin: 0; - min-height: 100%; - padding: 0; - position: relative; - width: 20%; -} - -#g-organize #g-organize-tree-container h3 { - margin-bottom: 0.1em; -} - -#g-organize-album-tree { - overflow: auto; -} - -#g-organize-album-tree ul li { - padding: 0 0 .2em 1.2em; - width: 90%; -} - -.rtl #g-organize-album-tree ul li { - padding: 0 1.2em .2em 0; - width: 90%; -} - -.g-organize-album span { - cursor: pointer; -} - -.g-organize-album-text { - cursor: pointer; - display: block; - margin: 2px 0px 1px 2px; - width: auto; -} - -.rtl .g-organize-album-text { - cursor: pointer; - display: block; - margin: 2px 2px 1px 1px; - width: auto; -} - -.g-organize-album-text:hover { - border-width: 1px; - border-style: dotted; -} - -/******************************************************************* - * Album panel styles - */ - -#g-organize #g-organize-detail { - margin: 0 !important; - min-height: 100%; - padding: 0 !important; - position: relative; - width: 80%; -} - -#g-organize #g-organize-detail .g-message-block { - margin: 0; -} - -#g-organize #g-organize-detail .g-message-block li { - padding-bottom: .2em; - padding-top: .2em; - width: auto; -} - -#g-organize-microthumb-grid { - border-width: 1px; - border-style: solid; - bottom: 1.8em; - left: 0; - margin: 0 !important; - overflow-x: hidden; - overflow-y: auto; - padding: .4em !important; - position: absolute; - right: 0; - top: 1.6em; -} -.g-organize-microthumb-grid-cell { - display: block; - height: 100px; - margin: 6px; - padding: .4em 0 !important; - position: relative; - text-align: center; - width: 110px; -} - -.ui-selectable-helper { - z-index: 2000 !important; -} - -.g-organize-microthumb-grid-cell .ui-icon { - bottom: 0; - left: 0; - position: absolute; - z-index: 4000; -} - -/**************************************************************** - * Controls styles - */ - -#g-organize-controls { - bottom: 0; - height: 1.9em; - left: 0; - margin: 0 !important; - padding: .1em .4em; - position: absolute; - right: 0; -} - -#g-organize-controls #g-organize-sort-order-text { - padding: .2em 0 0 0; -} - - -#g-organize-controls select { - margin-left: .42em; - display: inline; -} - -#g-organize-close { - margin-right: 12px; -} diff --git a/modules/organize/css/organize_theme.css b/modules/organize/css/organize_theme.css index 3d289755..e698f88d 100644 --- a/modules/organize/css/organize_theme.css +++ b/modules/organize/css/organize_theme.css @@ -1,16 +1,18 @@ /** ******************************************************************* * Organize styles that are theme overrideable *********************************************************************/ -.g-organize-microthumb-grid-cell.ui-selected { - background: #DFEFFC !important; +#g-organize { + background-color: #FFFFFF; + border: 0px solid #000000; + color: #0E2B52; } -#g-organize-microthumb-grid, -#g-organize-drop-target-marker, -.g-organize-album-text:hover { - border-color: #79B7E7; +#g-organize-hover { + background-color: #CFDEFF; + display: none; } -#g-organize-drop-target-marker { - background-color: #79B7E7; +#g-organize-active { + background-color: #6699CC; + display: none; } diff --git a/modules/organize/helpers/organize_theme.php b/modules/organize/helpers/organize_theme.php index da4a1b41..d69ab82c 100644 --- a/modules/organize/helpers/organize_theme.php +++ b/modules/organize/helpers/organize_theme.php @@ -21,12 +21,6 @@ class organize_theme { static function head($theme) { $item = $theme->item(); if ($item && access::can("edit", $item) && $item->is_album()) { - // @todo: Defer loading js/css until we're loading the organize dialog as + +" /> + + +
+

html::purify($album->title))) ?>

-
-
-

-
    - -
-
-
-
    -
  • -
-
"> - -
-
- -
-
    -
  • -
  • - "g-organize-sort-column"), - album::get_sort_order_options(), $album->sort_column) ?> -
  • -
  • - "g-organize-sort-order"), - array("ASC" => t("Ascending"), "DESC" => t("Descending")), $album->sort_order) ?> -
  • -
-
-
-
-
+
 
- - diff --git a/modules/organize/views/organize_thumb_grid.html.php b/modules/organize/views/organize_thumb_grid.html.php deleted file mode 100644 index f5db53d4..00000000 --- a/modules/organize/views/organize_thumb_grid.html.php +++ /dev/null @@ -1,22 +0,0 @@ - -children(25, $offset) as $child): ?> -
" - ref="id ?>"> - thumb_img(array("class" => "g-thumbnail", "ref" => $child->id), 90, true) ?> - is_album() ? " class=\"ui-icon ui-icon-note\"" : "" ?>> -
- - -children_count() > $offset): ?> - - diff --git a/modules/organize/views/organize_tree.html.php b/modules/organize/views/organize_tree.html.php deleted file mode 100644 index 044b6858..00000000 --- a/modules/organize/views/organize_tree.html.php +++ /dev/null @@ -1,29 +0,0 @@ - -
  • " - ref="id ?>"> - - - " - ref="id ?>"> - title) ?> - - viewable()->children(null, null, array(array("type", "=", "album"))); ?> - -
      - - contains($selected)): ?> - $selected, "album" => $child)); ?> - -
    • " - ref="id ?>"> - - " ref="id ?>"> - title) ?> - -
    • - - -
    - -
  • - -- cgit v1.2.3