this.open = function() { // open the message body, so you can read it $(this).find('.m_message_body').slideDown(320); this.is_open = 1; this.mark_read(); } this.close = function() { // close the message body $(this).find('.m_message_body').slideUp(180); this.is_open = 0; }
this.mark_read = function() { if ($(this).hasClass('unread')) { $.post('http://' + document.domain + '/?&siteformat=xml&elId=' + this.id, { "1_posttype": "update", "1_orb": "m", "1_where": "m.id = " + this.idnum, "1_read_unsignedint": 1 }, function(data) { var _s = this.url.split('='); var elId = _s[_s.length-1]; var that = $('##' + elId)[0]; /* do something with that? */ }); $(this).removeClass('unread'); $(this).addClass('read'); } } this.mark_unread = function() { if ($(this).hasClass('read')) { $.post('http://' + document.domain + '/?&siteformat=xml&elId=' + this.id, { "1_posttype": "update", "1_orb": "m", "1_where": "m.id = " + this.idnum, "1_read_unsignedint": 0 }, function(data) { var _s = this.url.split('='); var elId = _s[_s.length-1]; var that = $('##' + elId)[0]; /* do something with that? */ }); $(this).removeClass('read'); $(this).addClass('unread'); } }
$(this).find('.m_read_link').click(function() { var that = $(this).parents('.m_message')[0]; if (that.is_open == 1) { that.close(); $(that).find('.m_read_link').each(function() { if ($(this).html() == 'Close') { $(this).html('Open'); } }); } else { that.open(); $(that).find('.m_read_link').each(function() { if ($(this).html() == 'Open') { $(this).html('Close'); } }); } return false; });
$(this).find('.m_mark_unread_link').click(function() { var that = $(this).parents('.m_message')[0]; that.mark_unread(); return false; });