0
editNewTitle: function(txtField) {
0
$('new_topic').innerHTML = (txtField.value.length > 5) ? txtField.value : 'New Topic';
0
@@ -18,38 +16,52 @@ var LoginForm = {
0
- init: function(postId) {
0
- $('edit-post-' + postId + '_spinner').show();
0
+ reply: Behavior.create({
0
+ $('post_body').focus();
0
+ edit: Behavior.create(Remote.Link, {
0
+ initialize: function($super, postId) {
0
+ onclick: function($super) {
0
+ $('edit-post-' + this.postId + '_spinner').show();
0
+ PostForm.clearPostId();
0
+ cancel: Behavior.create({
0
+ PostForm.clearPostId();
0
// sets the current post id we're editing
0
- setReplyId: function(postId) {
0
- $('edit').setAttribute('post_id', postId.toString());
0
+ editPost: function(postId) {
0
$('post_' + postId + '-row').addClassName('editing');
0
+ $('edit-post-' + postId + '_spinner').hide()
0
if($('reply')) $('reply').hide();
0
+ this.cancel.attach($('edit-cancel'))
0
+ $('edit-form').observe('submit', function() { $('editbox_spinner').show() })
0
+ setTimeout("$('edit_post_body').focus()", 250)
0
- // clears the current post id
0
- clearReplyId: function() {
0
- var currentId = this.currentReplyId()
0
- if(!currentId || currentId == '') return;
0
- var row = $('post_' + currentId + '-row');
0
- if(row) row.removeClassName('editing');
0
- $('edit').setAttribute('post_id', '');
0
- // gets the current post id we're editing
0
- currentReplyId: function() {
0
- return $('edit').getAttribute('post_id');
0
// checks whether we're editing this post already
0
isEditing: function(postId) {
0
- if (
this.currentReplyId() == postId.toString())
0
+ if (
PostForm.postId == postId.toString())
0
$('edit_post_body').focus();
0
@@ -58,40 +70,35 @@ var EditForm = {
0
- // close reply, clear current reply id
0
+ clearPostId: function() {
0
+ var currentId = PostForm.postId;
0
+ if(!currentId) return;
0
- // yes, i use setTimeout for a reason
0
- $('post_body').focus();
0
- // for Safari which is sometime weird
0
-// setTimeout('$(\"post_body\").focus();',50);
0
+ var row = $('post_' + currentId + '-row');
0
+ if(row) row.removeClassName('editing');
0
+ PostForm.postId = null;
0
-Ghost = Behavior.create({
0
- initialize: function() { this.element.hide() }
0
-SearchLink = Behavior.create({
0
+ 'span.time': toTimeAgoInWords,
0
+ '#search, #reply': function() { this.hide() },
0
+ '#search-link:click': function() {
0
$('search_box').focus();
0
+ 'tr.post': function() {
0
+ var postId = this.id.match(/^post_(\d+)-/)[1]
0
+ PostForm.edit.attach(this.down('.edit a'), postId);
0
+ '#reply-link': function() {
0
+ PostForm.reply.attach(this)
0
+ '#reply-cancel': function() {
0
+ PostForm.cancel.attach(this)
0
- '#search-link': SearchLink,
0
- 'span.time': RelativeTime
0
-document.observe("dom:loaded", function() {
0
\ No newline at end of file
Comments
No one has commented yet.