diff options
author | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-22 07:00:35 +0000 |
---|---|---|
committer | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-22 07:00:35 +0000 |
commit | 131b559a6136fc6f6f9b1c9aac54898b9a3aa74c (patch) | |
tree | 79c1a64bdaa28b714a234f8e588f2e176967501c /mod/blog/views | |
parent | 567de1ec8eed575003d6e4f96f4b3a364854df78 (diff) | |
download | elgg-131b559a6136fc6f6f9b1c9aac54898b9a3aa74c.tar.gz elgg-131b559a6136fc6f6f9b1c9aac54898b9a3aa74c.tar.bz2 |
Cleaned up blog js
git-svn-id: http://code.elgg.org/elgg/trunk@8419 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/blog/views')
-rw-r--r-- | mod/blog/views/default/forms/blog/save.php | 2 | ||||
-rw-r--r-- | mod/blog/views/default/input/datetime.php | 10 | ||||
-rw-r--r-- | mod/blog/views/default/js/blog/save_draft.php | 121 |
3 files changed, 51 insertions, 82 deletions
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 |