aboutsummaryrefslogtreecommitdiff
path: root/mod/blog/views/default/js
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-05 21:38:36 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-05 21:38:36 +0000
commit79128c747888ac2f586f6679e1af78b4aa1b711a (patch)
tree5508e5583b9b3a0807be92f69c842a5ff1e48b9d /mod/blog/views/default/js
parent9f543bb8999de2db20e71f9d5c7e1fdda13f29a8 (diff)
downloadelgg-79128c747888ac2f586f6679e1af78b4aa1b711a.tar.gz
elgg-79128c747888ac2f586f6679e1af78b4aa1b711a.tar.bz2
blog plugin now uses the new elgg_view_form() function
git-svn-id: http://code.elgg.org/elgg/trunk@7540 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/blog/views/default/js')
-rw-r--r--mod/blog/views/default/js/blog/save_draft.php97
1 files changed, 97 insertions, 0 deletions
diff --git a/mod/blog/views/default/js/blog/save_draft.php b/mod/blog/views/default/js/blog/save_draft.php
new file mode 100644
index 000000000..177ecc1df
--- /dev/null
+++ b/mod/blog/views/default/js/blog/save_draft.php
@@ -0,0 +1,97 @@
+<?php
+/**
+ * Save draft through ajax
+ *
+ * @package Blog
+ */
+?>
+
+<script type="text/javascript">
+ setInterval("blogSaveDraft()", 60000);
+
+ /*
+ * 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]');
+
+ // 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();
+
+ 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'); ?>");
+ }
+ }
+
+ 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');
+ }
+
+ $(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);
+
+ // bind on key up event
+ $(this).keyup(function(){
+ var counter_value = ((allowed - ($(this).val().length)));
+
+ $("#countervalue").removeClass();
+
+ 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");
+ }
+
+ // insert new length
+ $('#countervalue').text(counter_value);
+
+ });
+ });
+*/
+ });
+
+</script>