aboutsummaryrefslogtreecommitdiff
path: root/mod/embed
diff options
context:
space:
mode:
Diffstat (limited to 'mod/embed')
-rw-r--r--mod/embed/js/embed.js10
-rw-r--r--mod/embed/start.php4
-rw-r--r--mod/embed/views/default/embed/embed.php10
-rw-r--r--mod/embed/views/default/embed/js.php21
-rw-r--r--mod/embed/views/default/embed/lightbox_init.php4
-rw-r--r--mod/embed/views/default/embed/upload/content.php16
6 files changed, 39 insertions, 26 deletions
diff --git a/mod/embed/js/embed.js b/mod/embed/js/embed.js
new file mode 100644
index 000000000..c29083af7
--- /dev/null
+++ b/mod/embed/js/embed.js
@@ -0,0 +1,10 @@
+$(function() {
+
+ // change for dropdown
+ $('#embed_upload').live('change', function() {
+ var upload_section = $(this).val();
+ var url = elgg.get_site_url() + 'embed/embed?active_section=upload&active_upload_section=' + upload_section;
+ $('#facebox .body .content').load(url);
+ });
+
+}); \ No newline at end of file
diff --git a/mod/embed/start.php b/mod/embed/start.php
index f5d17b18c..78f06c158 100644
--- a/mod/embed/start.php
+++ b/mod/embed/start.php
@@ -14,12 +14,14 @@ elgg_register_event_handler('init', 'system', 'embed_init');
function embed_init() {
elgg_extend_view('css/elgg', 'embed/css');
elgg_extend_view('js/elgg', 'embed/js');
- elgg_extend_view('footer/analytics', 'embed/lightbox_init');
+ elgg_extend_view('js/elgg', 'embed/lightbox_init');
elgg_register_plugin_hook_handler('register', 'menu:longtext', 'embed_longtext_menu');
// Page handler for the modal media embed
elgg_register_page_handler('embed', 'embed_page_handler');
+
+ elgg_register_js('elgg.embed', 'mod/embed/js/embed.js', 'footer');
}
function embed_longtext_menu($hook, $type, $items, $vars) {
diff --git a/mod/embed/views/default/embed/embed.php b/mod/embed/views/default/embed/embed.php
index e64160852..84b005c8c 100644
--- a/mod/embed/views/default/embed/embed.php
+++ b/mod/embed/views/default/embed/embed.php
@@ -125,7 +125,7 @@ echo $content;
<?php //@todo: JS 1.8: ugly ?>
<script type="text/javascript">
-$(document).ready(function() {
+$(function() {
var internal_name = '<?php echo addslashes($internal_name); ?>';
// insert embed codes
@@ -135,7 +135,7 @@ $(document).ready(function() {
});
// tabs
- $('.embed_section').click(function() {
+ $('.embed_section').live('click', function() {
var section = $(this).attr('id');
var url = elgg.config.wwwroot + 'embed/embed?active_section=' + section + '&internal_name=' + internal_name;
$('#facebox .body .content').load(url);
@@ -149,9 +149,9 @@ $(document).ready(function() {
return false;
}
- $('.pagination-number').click(elggPaginationClick);
- $('.pagination-next').click(elggPaginationClick);
- $('.pagination-previous').click(elggPaginationClick);
+ $('.pagination-number').live('click', elggPaginationClick);
+ $('.pagination-next').live('click', elggPaginationClick);
+ $('.pagination-previous').live('click', elggPaginationClick);
});
</script>
diff --git a/mod/embed/views/default/embed/js.php b/mod/embed/views/default/embed/js.php
index fc34c2442..f80d7367d 100644
--- a/mod/embed/views/default/embed/js.php
+++ b/mod/embed/views/default/embed/js.php
@@ -6,6 +6,26 @@
*/
?>
+$(function() {
+ $('a[rel*=facebox]').facebox();
+
+ // fire off the ajax upload
+ $('#file_embed_upload').submit(function() {
+ var options = {
+ success: function(data) {
+ var info = jQuery.parseJSON(data);
+
+ if (info.status == 'success') {
+ $('.popup .content').load(elgg.get_site_url() + 'embed/embed?active_section=file');
+ } else {
+ $('.popup .content').find('form').prepend('<p>' + info.message + '</p>');
+ }
+ }
+ };
+ $(this).ajaxSubmit(options);
+ return false;
+ });
+});
function elggEmbedInsertContent(content, textAreaName) {
content = ' ' + content + ' ';
@@ -33,7 +53,6 @@ function elggEmbedInsertContent(content, textAreaName) {
$.facebox.close();
}
-
/*
* Facebox (for jQuery)
* version: 1.2 (05/05/2008)
diff --git a/mod/embed/views/default/embed/lightbox_init.php b/mod/embed/views/default/embed/lightbox_init.php
deleted file mode 100644
index 2c385a578..000000000
--- a/mod/embed/views/default/embed/lightbox_init.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php //@todo JS 1.8: no ?>
-<script type="text/javascript">
- $(function() { $('a[rel*=facebox]').facebox() });
-</script>
diff --git a/mod/embed/views/default/embed/upload/content.php b/mod/embed/views/default/embed/upload/content.php
index 5eb9b31a2..b7bcc76a0 100644
--- a/mod/embed/views/default/embed/upload/content.php
+++ b/mod/embed/views/default/embed/upload/content.php
@@ -28,21 +28,7 @@ if ($upload_sections) {
echo $upload_content . "</div>";
-?>
- <?php //@todo: JS 1.8: ugly ?>
- <script type="text/javascript">
- $(function() {
-
- // change for dropdown
- $('#embed_upload').change(function() {
- var upload_section = $(this).val();
- var url = elgg.get_site_url() + 'embed/embed?active_section=upload&active_upload_section=' + upload_section;
- $('#facebox .body .content').load(url);
- });
-
- });
- </script>
-<?php
+ elgg_load_js('elgg.embed');
} else {
echo elgg_echo('embed:no_upload_sections');