]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
cleaned up the embed item view and removed the inline js
authorcash <cash.costello@gmail.com>
Sat, 1 Oct 2011 20:30:04 +0000 (16:30 -0400)
committercash <cash.costello@gmail.com>
Sat, 1 Oct 2011 20:30:04 +0000 (16:30 -0400)
mod/embed/start.php
mod/embed/views/default/embed/css.php
mod/embed/views/default/embed/item.php
mod/embed/views/default/js/embed/embed.php

index a87776c7e795151f28fbcae2b92776e1b4bf379e..015c0c0e41eddc41d3f27130e5ed31c5661787d1 100644 (file)
@@ -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);
index f654a208af1f6d6fb9c8cd074105ecdd38195024..324ed1038cdf9fac8c5713423a4ba6fd002a9fdc 100644 (file)
 .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;
 }
index c6faa450bf84ded51d6090706f9c85fdaadc0130..4087b7408452d613a4f55a0a6a9c43fd0a5cacb5 100644 (file)
@@ -7,25 +7,33 @@
 
 $entity = $vars['entity'];
 
-$image = elgg_view_entity_icon($entity, 'small');
-
-$body = "<h4>" . $entity->title . "</h4>";
-
-$icon = "<img src=\"{$entity->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 "<div class=\"embed_data\" id=\"embed_{$entity->getGUID()}\">";
 echo elgg_view_image_block($image, $body);
-echo '</div>';
-
-// @todo JS 1.8: is this approach better than inline js?
-echo "<script type=\"text/javascript\">
-       $('#embed_{$entity->getGUID()}').data('embed_code', " . json_encode($embed_code) . ");
-</script>";
index e60c6b367bbdf689c3d8af924283269b51b5d8ee..37246ee8a70d7b1c1ab7ec347a25194b8832683f 100644 (file)
@@ -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 + ' ');
-
-       <?php echo elgg_view('embed/custom_insert_js'); ?>
+       // generalize this based on a css class attached to what should be inserted
+       var content = ' ' + $(this).find(".elgg-image").html() + ' ';
+       
+<?php
+// If a wysiwyg editor has been registered, it handles the insertion by
+// overriding the embed/custom_insert_js view. See the TinyMCE plugin for an
+// example of this.
+$custom_insert_code = elgg_view('embed/custom_insert_js');
+if ($custom_insert_code) {
+       echo $custom_insert_code;
+} else {
+?>
+       $('#' + textAreaId).val($('#' + textAreaId).val() + content);
+       $('#' + textAreaId).focus();
+<?php
+}
+?>
 
        $.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);
                                }
                        }