aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/blog/lib/blog.php8
-rw-r--r--mod/blog/views/default/forms/blog/save.php2
-rw-r--r--mod/blog/views/default/input/datetime.php10
-rw-r--r--mod/blog/views/default/js/blog/save_draft.php121
4 files changed, 57 insertions, 84 deletions
diff --git a/mod/blog/lib/blog.php b/mod/blog/lib/blog.php
index 326b224bb..5287844ab 100644
--- a/mod/blog/lib/blog.php
+++ b/mod/blog/lib/blog.php
@@ -309,9 +309,11 @@ function blog_get_page_content_edit($page, $guid = 0, $revision = NULL) {
elgg_push_breadcrumb($blog->title, $blog->getURL());
elgg_push_breadcrumb(elgg_echo('edit'));
+
+ $blog_js = elgg_get_simplecache_url('js', 'blog/save_draft');
+ elgg_register_js($blog_js, 'blog');
$content = elgg_view_form('blog/save', $vars, $body_vars);
- $content .= elgg_view('js/blog/save_draft');
$sidebar = elgg_view('blog/sidebar/revisions', $vars);
} else {
$content = elgg_echo('blog:error:cannot_edit_post');
@@ -328,7 +330,9 @@ function blog_get_page_content_edit($page, $guid = 0, $revision = NULL) {
$title = elgg_echo('blog:add');
$content = elgg_view_form('blog/save', $vars, $body_vars);
- $content .= elgg_view('js/blog/save_draft');
+
+ $blog_js = elgg_get_simplecache_url('js', 'blog/save_draft');
+ elgg_register_js($blog_js, 'blog');
}
$return['title'] = $title;
diff --git a/mod/blog/views/default/forms/blog/save.php b/mod/blog/views/default/forms/blog/save.php
index 6020ad4b0..c0c9ea7cd 100644
--- a/mod/blog/views/default/forms/blog/save.php
+++ b/mod/blog/views/default/forms/blog/save.php
@@ -19,7 +19,7 @@ if ($vars['guid']) {
$delete_link = elgg_view('output/confirmlink', array(
'href' => $delete_url,
'text' => elgg_echo('delete'),
- 'class' => 'elgg-button-action elgg-state-disabled'
+ 'class' => 'elgg-button elgg-button-delete elgg-state-disabled'
));
}
diff --git a/mod/blog/views/default/input/datetime.php b/mod/blog/views/default/input/datetime.php
index 3a7244b88..1f4a33ecd 100644
--- a/mod/blog/views/default/input/datetime.php
+++ b/mod/blog/views/default/input/datetime.php
@@ -18,31 +18,31 @@ $month = elgg_view('input/dropdown', array(
'name' => 'publish_month',
'value' => date('m', $publish_date),
'options_values' => $months,
- 'class' => 'blog_publish_month',
+ 'class' => 'elgg-input-datetime-month',
));
$day = elgg_view('input/text', array(
'name' => 'publish_day',
'value' => date('d', $publish_date),
- 'class' => 'blog_publish_day',
+ 'class' => 'elgg-input-datetime-day',
));
$year = elgg_view('input/text', array(
'name' => 'publish_year',
'value' => date('Y', $publish_date),
- 'class' => 'blog_publish_year',
+ 'class' => 'elgg-input-datetime-year',
));
$hour = elgg_view('input/text', array(
'name' => 'publish_hour',
'value' => date('H', $publish_date),
- 'class' => 'blog_publish_hour',
+ 'class' => 'elgg-input-datetime-hour',
));
$minute = elgg_view('input/text', array(
'name' => 'publish_minute',
'value' => date('i', $publish_date),
- 'class' => 'blog_publish_minute',
+ 'class' => 'elgg-input-datetime-minute',
));
echo "$month $day, $year @ $hour:$minute";
diff --git a/mod/blog/views/default/js/blog/save_draft.php b/mod/blog/views/default/js/blog/save_draft.php
index 7f3c3bb12..990ab357d 100644
--- a/mod/blog/views/default/js/blog/save_draft.php
+++ b/mod/blog/views/default/js/blog/save_draft.php
@@ -3,97 +3,66 @@
* Save draft through ajax
*
* @package Blog
- *
- * @todo JS 1.8: no. Convert to use elgg.blog.*
*/
?>
-<script type="text/javascript">
- setInterval("blogSaveDraft()", 60000);
+elgg.provide('elgg.blog');
- /*
- * Attempt to save and update the input with the guid.
- */
- function blogSaveDraftCallback(data, textStatus, XHR) {
- if (textStatus == 'success' && data.success == true) {
- var form = $('form[name=blog_post]');
+/*
+ * Attempt to save and update the input with the guid.
+ */
+elgg.blog.saveDraftCallback = function(data, textStatus, XHR) {
+ if (textStatus == 'success' && data.success == true) {
+ var form = $('form[name=blog_post]');
- // update the guid input element for new posts that now have a guid
- form.find('input[name=guid]').val(data.guid);
+ // update the guid input element for new posts that now have a guid
+ form.find('input[name=guid]').val(data.guid);
- oldDescription = form.find('textarea[name=description]').val();
+ oldDescription = form.find('textarea[name=description]').val();
- var d = new Date();
- var mins = d.getMinutes() + '';
- if (mins.length == 1) {
- mins = '0' + mins;
- }
- $(".blog-save-status-time").html(d.toLocaleDateString() + " @ " + d.getHours() + ":" + mins);
- } else {
- $(".blog-save-status-time").html("<?php echo elgg_echo('error'); ?>");
+ var d = new Date();
+ var mins = d.getMinutes() + '';
+ if (mins.length == 1) {
+ mins = '0' + mins;
}
+ $(".blog-save-status-time").html(d.toLocaleDateString() + " @ " + d.getHours() + ":" + mins);
+ } else {
+ $(".blog-save-status-time").html(elgg.echo('error'));
}
+}
- function blogSaveDraft() {
- if (typeof(tinyMCE) != 'undefined') {
- tinyMCE.triggerSave();
- }
-
- // only save on changed content
- var form = $('form[name=blog_post]');
- var description = form.find('textarea[name=description]').val();
- var title = form.find('input[name=title]').val();
-
- if (!(description && title) || (description == oldDescription)) {
- return false;
- }
-
- var draftURL = "<?php echo elgg_get_site_url(); ?>action/blog/auto_save_revision";
- var postData = form.serializeArray();
-
- // force draft status
- $(postData).each(function(i, e) {
- if (e.name == 'status') {
- e.value = 'draft';
- }
- });
-
- $.post(draftURL, postData, blogSaveDraftCallback, 'json');
+elgg.blog.saveDraft = function() {
+ if (typeof(tinyMCE) != 'undefined') {
+ tinyMCE.triggerSave();
}
- $(document).ready(function() {
- // get a copy of the body to compare for auto save
- oldDescription = $('form[name=blog_post]').find('textarea[name=description]').val();
-
-/* we don't seems to be using the text counter anymore�
- $('#excerpt.excerpt').each(function(){
- var allowed = 200;
-
- // set the initial value
- $('#countervalue').text(allowed);
+ // only save on changed content
+ var form = $('form[name=blog_post]');
+ var description = form.find('textarea[name=description]').val();
+ var title = form.find('input[name=title]').val();
- // bind on key up event
- $(this).keyup(function(){
- var counter_value = ((allowed - ($(this).val().length)));
+ if (!(description && title) || (description == oldDescription)) {
+ return false;
+ }
- $("#countervalue").removeClass();
+ var draftURL = elgg.config.wwwroot + "action/blog/auto_save_revision";
+ var postData = form.serializeArray();
- if ((counter_value > 10)) {
- $("#countervalue").addClass("positive");
- }
- else if ((counter_value <= 10) && (counter_value >= 0)) {
- $("#countervalue").addClass("gettingclose");
- }
- else if ((counter_value < 0)) {
- $("#countervalue").addClass("negative");
- }
+ // force draft status
+ $(postData).each(function(i, e) {
+ if (e.name == 'status') {
+ e.value = 'draft';
+ }
+ });
- // insert new length
- $('#countervalue').text(counter_value);
+ $.post(draftURL, postData, blogSaveDraftCallback, 'json');
+}
- });
- });
-*/
- });
+elgg.blog.init = function() {
+ // get a copy of the body to compare for auto save
+ oldDescription = $('form[name=blog_post]').find('textarea[name=description]').val();
+
+ setInterval(elgg.blog.saveDraft, 60000);
+};
-</script>
+elgg.register_event_handler('init', 'system', elgg.blog.init); \ No newline at end of file