Some special .js for the bookmark plugin, so we can control the form in the second step

This commit is contained in:
Zach Copley 2011-04-17 18:37:51 -07:00
parent eaca17be58
commit f3e0cd0b30
2 changed files with 42 additions and 0 deletions

View 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
*

View File

@ -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();
});