From 418078a8d4c157c1c88d196d3b24ff0f0893b764 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 1 Oct 2011 16:30:04 -0400 Subject: cleaned up the embed item view and removed the inline js --- mod/embed/start.php | 1 + mod/embed/views/default/embed/css.php | 6 +++- mod/embed/views/default/embed/item.php | 44 ++++++++++++++++++------------ mod/embed/views/default/js/embed/embed.php | 27 +++++++++++++----- 4 files changed, 52 insertions(+), 26 deletions(-) diff --git a/mod/embed/start.php b/mod/embed/start.php index a87776c7e..015c0c0e4 100644 --- a/mod/embed/start.php +++ b/mod/embed/start.php @@ -129,6 +129,7 @@ function embed_get_list_options($options = array()) { $defaults = array( 'limit' => 6, 'container_guid' => $container_guid, + 'item_class' => 'embed-item', ); $options = array_merge($defaults, $options); diff --git a/mod/embed/views/default/embed/css.php b/mod/embed/views/default/embed/css.php index f654a208a..324ed1038 100644 --- a/mod/embed/views/default/embed/css.php +++ b/mod/embed/views/default/embed/css.php @@ -28,6 +28,10 @@ .embed-wrapper p { color: #333; } -.embed-wrapper .elgg-image-block:hover { +.embed-item { + padding-left: 5px; + padding-right: 5px; +} +.embed-item:hover { background-color: #eee; } diff --git a/mod/embed/views/default/embed/item.php b/mod/embed/views/default/embed/item.php index c6faa450b..4087b7408 100644 --- a/mod/embed/views/default/embed/item.php +++ b/mod/embed/views/default/embed/item.php @@ -7,25 +7,33 @@ $entity = $vars['entity']; -$image = elgg_view_entity_icon($entity, 'small'); - -$body = "

" . $entity->title . "

"; - -$icon = "getIconURL('small')}\" />"; - -$embed_code = elgg_view('output/url', array( - 'href' => $entity->getURL(), +$title = $entity->title; +if (!$title) { + $title = $entity->name; +} + +// different entity types have different title attribute names. +$title = isset($entity->name) ? $entity->name : $entity->title; +// don't let it be too long +$title = elgg_get_excerpt($title); + +$owner = $entity->getOwnerEntity(); +if ($owner) { + $author_text = elgg_echo('byline', array($owner->name)); + $date = elgg_view_friendly_time($entity->time_created); + $subtitle = "$author_text $date"; +} else { + $subtitle = ''; +} + +$params = array( 'title' => $title, - 'text' => $icon, - 'encode_text' => FALSE -)); + 'entity' => $entity, + 'subtitle' => $subtitle, + 'tags' => FALSE, +); +$body = elgg_view('object/elements/summary', $params); +$image = elgg_view_entity_icon($entity, 'small'); -echo "
getGUID()}\">"; echo elgg_view_image_block($image, $body); -echo '
'; - -// @todo JS 1.8: is this approach better than inline js? -echo ""; diff --git a/mod/embed/views/default/js/embed/embed.php b/mod/embed/views/default/js/embed/embed.php index e60c6b367..37246ee8a 100644 --- a/mod/embed/views/default/js/embed/embed.php +++ b/mod/embed/views/default/js/embed/embed.php @@ -3,7 +3,7 @@ elgg.provide('elgg.embed'); elgg.embed.init = function() { // inserts the embed content into the textarea - $(".embed_data").live('click', elgg.embed.insert); + $(".embed-item").live('click', elgg.embed.insert); // caches the current textarea id $(".embed-control").live('click', function() { @@ -24,7 +24,7 @@ elgg.embed.init = function() { /** * Inserts data attached to an embed list item in textarea * - * @todo generalize lightbox closing and wysiwyg refreshing + * @todo generalize lightbox closing * * @param {Object} event * @return void @@ -32,10 +32,23 @@ elgg.embed.init = function() { elgg.embed.insert = function(event) { var textAreaId = elgg.embed.textAreaId; - var content = $(this).data('embed_code'); - $('#' + textAreaId).val($('#' + textAreaId).val() + ' ' + content + ' '); - - + // generalize this based on a css class attached to what should be inserted + var content = ' ' + $(this).find(".elgg-image").html() + ' '; + + + $('#' + textAreaId).val($('#' + textAreaId).val() + content); + $('#' + textAreaId).focus(); + $.fancybox.close(); @@ -68,7 +81,7 @@ elgg.embed.submit = function(event) { if (response.status >= 0) { // @todo - really this should forward to what the registered defined // For example, forward to images tab if an image was uploaded - var url = elgg.config.wwwroot + 'embed/embed?active_section=file'; + var url = elgg.config.wwwroot + 'embed/embed'; $('.embed-wrapper').parent().load(url); } } -- cgit v1.2.3