]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Some special .js for the bookmark plugin, so we can control the form in the second...
authorZach Copley <zach@status.net>
Mon, 18 Apr 2011 01:37:51 +0000 (18:37 -0700)
committerZach Copley <zach@status.net>
Mon, 18 Apr 2011 01:37:51 +0000 (18:37 -0700)
plugins/Bookmark/BookmarkPlugin.php
plugins/Bookmark/js/bookmark.js [new file with mode: 0644]

index c6fe987dc75d943e813bb8a4b4aa5eb692f04990..9d92fd61a3c0fb4d8c065431c18426d7286e3695 100644 (file)
@@ -130,6 +130,11 @@ class BookmarkPlugin extends MicroAppPlugin
         return true;
     }
 
+    function onEndShowScripts($action)
+    {
+        $action->script($this->path('js/bookmark.js'));
+        return true;
+    }
     /**
      * Load related modules when needed
      *
diff --git a/plugins/Bookmark/js/bookmark.js b/plugins/Bookmark/js/bookmark.js
new file mode 100644 (file)
index 0000000..c56587c
--- /dev/null
@@ -0,0 +1,37 @@
+var Bookmark = {
+
+    // Special XHR that sends in some code to be run
+    // when the full bookmark form gets loaded
+    BookmarkXHR: function(form)
+    {
+        SN.U.FormXHR(form, Bookmark.InitBookmarkForm);
+        return false;
+    },
+
+    // Special initialization function just for the
+    // second step in the bookmarking workflow
+    InitBookmarkForm: function() {
+        alert('Gar!');
+
+        // Put fancy stuff here
+
+    }
+}
+
+$(document).ready(function() {
+
+    // Stop normal live event stuff
+    $('form.ajax').die();
+    $('form.ajax input[type=submit]').die();
+
+    // Make the bookmark submit super special
+    $('#form_initial_bookmark').bind('submit', function(e) {
+        Bookmark.BookmarkXHR($(this));
+        e.stopPropagation();
+        return false;
+    });
+
+    // Restore live event stuff to other forms & submit buttions
+    SN.Init.AjaxForms();
+
+});