aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-14 23:54:38 +0000
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-14 23:54:38 +0000
commit1e94b4e29b3d4989eff8d5344bf3415b3fb44b94 (patch)
treefe807ae882366a5f20a831c12ec88b6a8131a18b /mod
parentcaf11e94744c49e1b1533b45f0a44d0aa97704df (diff)
downloadelgg-1e94b4e29b3d4989eff8d5344bf3415b3fb44b94.tar.gz
elgg-1e94b4e29b3d4989eff8d5344bf3415b3fb44b94.tar.bz2
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
Diffstat (limited to 'mod')
-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
-rw-r--r--mod/file/views/default/file/embed_upload.php22
-rw-r--r--mod/groups/start.php1
-rw-r--r--mod/groups/views/default/groups/js.php3
-rw-r--r--mod/groups/views/default/groups/profile/widgets.php7
-rw-r--r--mod/messages/start.php3
-rw-r--r--mod/messages/views/default/forms/messages/process.php10
-rw-r--r--mod/messages/views/default/forms/messages/reply.php11
-rw-r--r--mod/messages/views/default/messages/js.php9
-rw-r--r--mod/profile/start.php1
-rw-r--r--mod/profile/views/default/profile/js.php3
-rw-r--r--mod/profile/views/default/profile/wrapper.php8
-rw-r--r--mod/thewire/start.php4
-rw-r--r--mod/thewire/views/default/forms/thewire/add.php36
19 files changed, 66 insertions, 117 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');
diff --git a/mod/file/views/default/file/embed_upload.php b/mod/file/views/default/file/embed_upload.php
index 9014809c1..e5076b052 100644
--- a/mod/file/views/default/file/embed_upload.php
+++ b/mod/file/views/default/file/embed_upload.php
@@ -5,26 +5,4 @@
echo elgg_view_form('file/upload', array('id' => 'file_embed_upload'), array('ajax' => TRUE));
-?>
-<?php //@todo JS 1.8: no ?>
-<script type="text/javascript">
-$(document).ready(function() {
- // 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('<?php echo elgg_get_site_url() . 'embed/embed'; ?>?active_section=file');
- } else {
- $('.popup .content').find('form').prepend('<p>' + info.message + '</p>');
- }
- }
- };
- $(this).ajaxSubmit(options);
- return false;
- });
-});
-</script>
diff --git a/mod/groups/start.php b/mod/groups/start.php
index 8c3246660..18fb9abd5 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -63,6 +63,7 @@ function groups_init() {
//extend some views
elgg_extend_view('css/elgg', 'groups/css');
+ elgg_extend_view('js/elgg', 'groups/js');
// Access permissions
elgg_register_plugin_hook_handler('access:collections:write', 'all', 'groups_write_acl_plugin_hook');
diff --git a/mod/groups/views/default/groups/js.php b/mod/groups/views/default/groups/js.php
new file mode 100644
index 000000000..df74d52ee
--- /dev/null
+++ b/mod/groups/views/default/groups/js.php
@@ -0,0 +1,3 @@
+$(function() {
+ $('#groups-tools').find('.elgg-module:odd').addClass('odd');
+}); \ No newline at end of file
diff --git a/mod/groups/views/default/groups/profile/widgets.php b/mod/groups/views/default/groups/profile/widgets.php
index 027503560..28e43fdc4 100644
--- a/mod/groups/views/default/groups/profile/widgets.php
+++ b/mod/groups/views/default/groups/profile/widgets.php
@@ -12,11 +12,4 @@ echo '<div id="groups-tools" class="mtl clearfix">';
echo elgg_view("groups/tool_latest", array('entity' => $vars['entity']));
echo "</div>";
-?>
-<?php //@todo JS 1.8: no ?>
-<script type="text/javascript">
-$(function () { // subclass every other group tool widget
- $('#groups-tools').find('.elgg-module:odd').addClass('odd');
-});
-</script>
diff --git a/mod/messages/start.php b/mod/messages/start.php
index 24787ae03..5c4081a7b 100644
--- a/mod/messages/start.php
+++ b/mod/messages/start.php
@@ -49,7 +49,8 @@ function messages_init() {
// Extend system CSS with our own styles, which are defined in the messages/css view
elgg_extend_view('css/elgg', 'messages/css');
-
+ elgg_extend_view('js/elgg', 'messages/js');
+
// Register a page handler, so we can have nice URLs
elgg_register_page_handler('messages', 'messages_page_handler');
diff --git a/mod/messages/views/default/forms/messages/process.php b/mod/messages/views/default/forms/messages/process.php
index e415a092b..8eab26297 100644
--- a/mod/messages/views/default/forms/messages/process.php
+++ b/mod/messages/views/default/forms/messages/process.php
@@ -31,13 +31,3 @@ echo elgg_view('input/button', array(
));
echo '</div>';
-
-?>
-<?php //@todo JS 1.8: no ?>
-<script type="text/javascript">
-$(document).ready(function() {
- $("#messages-toggle").click(function() {
- $('input[type=checkbox]').click();
- });
-});
-</script>
diff --git a/mod/messages/views/default/forms/messages/reply.php b/mod/messages/views/default/forms/messages/reply.php
index 2288f25f4..e8a27f03e 100644
--- a/mod/messages/views/default/forms/messages/reply.php
+++ b/mod/messages/views/default/forms/messages/reply.php
@@ -35,13 +35,4 @@ echo elgg_view('input/hidden', array(
</div>
<div>
<?php echo elgg_view('input/submit', array('value' => elgg_echo('messages:send'))); ?>
-</div>
-
-<script type="text/javascript">
-$(document).ready(function() {
- $("#messages-show-reply").click(function() {
- $('#messages-reply-form').slideToggle('medium');
- });
-});
-
-</script> \ No newline at end of file
+</div> \ No newline at end of file
diff --git a/mod/messages/views/default/messages/js.php b/mod/messages/views/default/messages/js.php
new file mode 100644
index 000000000..7ae5f8a08
--- /dev/null
+++ b/mod/messages/views/default/messages/js.php
@@ -0,0 +1,9 @@
+$(function() {
+ $("#messages-toggle").click(function() {
+ $('input[type=checkbox]').click();
+ });
+
+ $("#messages-show-reply").click(function() {
+ $('#messages-reply-form').slideToggle('medium');
+ });
+}); \ No newline at end of file
diff --git a/mod/profile/start.php b/mod/profile/start.php
index 9f4e37b6d..2106ee0ac 100644
--- a/mod/profile/start.php
+++ b/mod/profile/start.php
@@ -31,6 +31,7 @@ function profile_init() {
elgg_extend_view('html_head/extend', 'profile/metatags');
elgg_extend_view('css/elgg', 'profile/css');
+ elgg_extend_view('js/elgg', 'profile/js');
// allow ECML in parts of the profile
elgg_register_plugin_hook_handler('get_views', 'ecml', 'profile_ecml_views_hook');
diff --git a/mod/profile/views/default/profile/js.php b/mod/profile/views/default/profile/js.php
new file mode 100644
index 000000000..edf68543c
--- /dev/null
+++ b/mod/profile/views/default/profile/js.php
@@ -0,0 +1,3 @@
+elgg.register_hook_handler('init', 'system', function() {
+ $('#elgg-widget-col-1').css('min-height', $('.profile').outerHeight(true) + 1);
+}); \ No newline at end of file
diff --git a/mod/profile/views/default/profile/wrapper.php b/mod/profile/views/default/profile/wrapper.php
index 7bc0397f8..73b7934f2 100644
--- a/mod/profile/views/default/profile/wrapper.php
+++ b/mod/profile/views/default/profile/wrapper.php
@@ -9,10 +9,4 @@
<?php echo elgg_view('profile/owner_block'); ?>
<?php echo elgg_view('profile/details'); ?>
</div>
-</div>
-<?php //@todo JS 1.8: no ?>
-<script type="text/javascript">
- $(document).ready(function() {
- $('#elgg-widget-col-1').css('min-height', $('.profile').outerHeight(true) + 1);
- });
-</script> \ No newline at end of file
+</div> \ No newline at end of file
diff --git a/mod/thewire/start.php b/mod/thewire/start.php
index 1724a33a9..c2006ddb0 100644
--- a/mod/thewire/start.php
+++ b/mod/thewire/start.php
@@ -20,6 +20,8 @@ function thewire_init() {
if (!update_subtype('object', 'thewire', 'ElggWire')) {
add_subtype('object', 'thewire', 'ElggWire');
}
+
+ elgg_register_js('elgg.thewire', 'mod/thewire/js/thewire.js', 'footer');
// add a site navigation item
$item = new ElggMenuItem('thewire', elgg_echo('thewire'), 'thewire/all');
@@ -261,7 +263,7 @@ function thewire_save_post($text, $userid, $access_id, $parent_guid = 0, $method
if ($parent_guid) {
$post->addRelationship($parent_guid, 'parent');
- // name conversation threads by guid of first post (works even if first post deleted)
+ // name conversation threads by guid of first post (works even if first post deleted)
$parent_post = get_entity($parent_guid);
$post->wire_thread = $parent_post->wire_thread;
} else {
diff --git a/mod/thewire/views/default/forms/thewire/add.php b/mod/thewire/views/default/forms/thewire/add.php
index 956ec7c27..67585b0df 100644
--- a/mod/thewire/views/default/forms/thewire/add.php
+++ b/mod/thewire/views/default/forms/thewire/add.php
@@ -5,6 +5,8 @@
* @uses $vars['post']
*/
+elgg_load_js('elgg.thewire');
+
$post = elgg_extract('post', $vars);
$text = elgg_echo('post');
@@ -30,37 +32,5 @@ echo elgg_view('input/submit', array(
'value' => $text,
'id' => 'thewire-submit-button',
));
-
?>
-</div>
-<script type="text/javascript">
-
-$(document).ready(function() {
- $("#thewire-textarea").bind('keydown', function() {
- textCounter(this, $("#thewire-characters-remaining span"), 140);
- });
- $("#thewire-textarea").bind('keyup', function() {
- textCounter(this, $("#thewire-characters-remaining span"), 140);
- });
-});
-
-function textCounter(textarea, status, limit) {
-
- var remaining_chars = limit - textarea.value.length;
- status.html(remaining_chars);
-
- if (remaining_chars < 0) {
- status.parent().css("color", "#D40D12");
- $("#thewire-submit-button").attr('disabled', 'disabled');
- $("#thewire-submit-button").css('background', '#999999');
- $("#thewire-submit-button").css('border-color', '#999999');
- $("#thewire-submit-button").css('cursor', 'default');
- } else {
- status.parent().css("color", "");
- $("#thewire-submit-button").removeAttr('disabled', 'disabled');
- $("#thewire-submit-button").css('background', '#4690d6');
- $("#thewire-submit-button").css('border-color', '#4690d6');
- $("#thewire-submit-button").css('cursor', 'pointer');
- }
-}
-</script>
+</div> \ No newline at end of file