From 1e94b4e29b3d4989eff8d5344bf3415b3fb44b94 Mon Sep 17 00:00:00 2001 From: ewinslow Date: Mon, 14 Mar 2011 23:54:38 +0000 Subject: Refs #3016: Removes inline javascript from embed, file, groups, messages, profile, thewire git-svn-id: http://code.elgg.org/elgg/trunk@8711 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/embed/js/embed.js | 10 ++++++++++ mod/embed/start.php | 4 +++- mod/embed/views/default/embed/embed.php | 10 +++++----- mod/embed/views/default/embed/js.php | 21 ++++++++++++++++++++- mod/embed/views/default/embed/lightbox_init.php | 4 ---- mod/embed/views/default/embed/upload/content.php | 16 +--------------- 6 files changed, 39 insertions(+), 26 deletions(-) create mode 100644 mod/embed/js/embed.js delete mode 100644 mod/embed/views/default/embed/lightbox_init.php (limited to 'mod/embed') 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; 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('

' + info.message + '

'); + } + } + }; + $(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 @@ - - 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 . ""; -?> - - -