aboutsummaryrefslogtreecommitdiff
path: root/mod/embed/views/default
diff options
context:
space:
mode:
Diffstat (limited to 'mod/embed/views/default')
-rw-r--r--mod/embed/views/default/embed/layout.php10
-rw-r--r--mod/embed/views/default/js/embed/embed.php62
-rw-r--r--mod/embed/views/default/navigation/menu/embed.php2
3 files changed, 65 insertions, 9 deletions
diff --git a/mod/embed/views/default/embed/layout.php b/mod/embed/views/default/embed/layout.php
index c1e43f13c..1ca263037 100644
--- a/mod/embed/views/default/embed/layout.php
+++ b/mod/embed/views/default/embed/layout.php
@@ -21,10 +21,20 @@ if ($selected->getData('view')) {
}
}
+$tab .= elgg_view('graphics/ajax_loader', array(
+ 'class' => 'embed-throbber mtl',
+));
+
+$container_info = elgg_view('input/hidden', array(
+ 'name' => 'embed_container_guid',
+ 'value' => elgg_get_page_owner_guid(),
+));
+
echo <<<HTML
<div class="embed-wrapper">
$title
$menu
$tab
+ $container_info
</div>
HTML;
diff --git a/mod/embed/views/default/js/embed/embed.php b/mod/embed/views/default/js/embed/embed.php
index 3126e12f7..e84427f24 100644
--- a/mod/embed/views/default/js/embed/embed.php
+++ b/mod/embed/views/default/js/embed/embed.php
@@ -1,3 +1,4 @@
+//<script>
elgg.provide('elgg.embed');
elgg.embed.init = function() {
@@ -19,7 +20,7 @@ elgg.embed.init = function() {
$('.embed-section').live('click', elgg.embed.forward);
$('.elgg-form-embed').live('submit', elgg.embed.submit);
-}
+};
/**
* Inserts data attached to an embed list item in textarea
@@ -35,20 +36,24 @@ elgg.embed.insert = function(event) {
// generalize this based on a css class attached to what should be inserted
var content = ' ' + $(this).find(".embed-insert").parent().html() + ' ';
-
+
+ // this is a temporary work-around for #3971
+ if (content.indexOf('thumbnail.php') != -1) {
+ content = content.replace('size=small', 'size=medium');
+ }
+
textArea.val(textArea.val() + content);
textArea.focus();
<?php
// See the TinyMCE plugin for an example of this view
- echo elgg_view('embed/custom_insert_js');
+echo elgg_view('embed/custom_insert_js');
?>
-
$.fancybox.close();
event.preventDefault();
-}
+};
/**
* Submit an upload form through Ajax
@@ -63,6 +68,8 @@ elgg.embed.insert = function(event) {
* @return bool
*/
elgg.embed.submit = function(event) {
+ $('.embed-wrapper .elgg-form-file-upload').hide();
+ $('.embed-throbber').show();
$(this).ajaxSubmit({
dataType : 'json',
@@ -76,16 +83,36 @@ elgg.embed.submit = function(event) {
if (response.status >= 0) {
var forward = $('input[name=embed_forward]').val();
var url = elgg.normalize_url('embed/tab/' + forward);
+ url = elgg.embed.addContainerGUID(url);
$('.embed-wrapper').parent().load(url);
+ } else {
+ // incorrect response, presumably an error has been displayed
+ $('.embed-throbber').hide();
+ $('.embed-wrapper .elgg-form-file-upload').show();
}
}
+
+ // ie 7 and 8 have a null response because of the use of an iFrame
+ // so just show the list after upload.
+ // http://jquery.malsup.com/form/#file-upload claims you can wrap JSON
+ // in a textarea, but a quick test didn't work, and that is fairly
+ // intrusive to the rest of the ajax system.
+ else if (response === undefined && $.browser.msie) {
+ var forward = $('input[name=embed_forward]').val();
+ var url = elgg.normalize_url('embed/tab/' + forward);
+ url = elgg.embed.addContainerGUID(url);
+ $('.embed-wrapper').parent().load(url);
+ }
+ },
+ error : function(xhr, status) {
+ // @todo nothing for now
}
});
// this was bubbling up the DOM causing a submission
event.preventDefault();
event.stopPropagation();
-}
+};
/**
* Loads content within the lightbox
@@ -94,8 +121,27 @@ elgg.embed.submit = function(event) {
* @return void
*/
elgg.embed.forward = function(event) {
- $('.embed-wrapper').parent().load($(this).attr('href'));
+ // make sure container guid is passed
+ var url = $(this).attr('href');
+ url = elgg.embed.addContainerGUID(url);
+
+ $('.embed-wrapper').parent().load(url);
event.preventDefault();
-}
+};
+
+/**
+ * Adds the container guid to a URL
+ *
+ * @param {string} url
+ * @return string
+ */
+elgg.embed.addContainerGUID = function(url) {
+ if (url.indexOf('container_guid=') == -1) {
+ var guid = $('input[name=embed_container_guid]').val();
+ return url + '?container_guid=' + guid;
+ } else {
+ return url;
+ }
+};
elgg.register_hook_handler('init', 'system', elgg.embed.init);
diff --git a/mod/embed/views/default/navigation/menu/embed.php b/mod/embed/views/default/navigation/menu/embed.php
index 1a6a18f05..bca673f59 100644
--- a/mod/embed/views/default/navigation/menu/embed.php
+++ b/mod/embed/views/default/navigation/menu/embed.php
@@ -10,7 +10,7 @@ foreach ($vars['menu']['default'] as $menu_item) {
$tabs[] = array(
'title' => $menu_item->getText(),
'url' => 'embed/tab/' . $menu_item->getName(),
- 'url_class' => 'embed-section',
+ 'link_class' => 'embed-section',
'selected' => $menu_item->getSelected(),
);
}