/***** mThreads.js *****/ mThreads = { visible: false, dirty: false, jsConversations: null, javaConversations: null, maxConversations: 0, currentFolderSet:null, currentFolderId:null, currentFolderName:null, currentSearch:null, currentPosition:0, threadsPerPage: 25, showSpecials: function(currentFolderSet, currentFolderName) { var isTrash = currentFolderName == 'Trash' && currentFolderSet == 'system'; if (isTrash) { $('#_mThreads_content_header_delete').hide(); $('#_mThreads_content_header_destroy').show(); $('#_mThreads_content_header_undelete').show(); } else { $('#_mThreads_content_header_delete').show(); $('#_mThreads_content_header_undelete').hide(); $('#_mThreads_content_header_destroy').hide(); } $('#_mThreads_content_header_select_all').prop('checked', false); }, show: function(folderSet, folderId) { log("mThreads.show begin"); if (mThreads.currentFolderSet != folderSet || mThreads.currentFolderId != folderId) { mThreads.dirty = true; mThreads.currentFolderSet = folderSet; mThreads.currentFolderId = folderId; mThreads.currentPosition = 0; var folder = mFolders.getFolder(folderSet, folderId); mThreads.currentFolderName = folder.getName(); mThreads.showSpecials(folderSet, mThreads.currentFolderName); } if (mThreads.dirty) mThreads.render(); if (!mThreads.visible) { mThreads.visible = true; $('#_mThreads_content_header').show(); $('#_mThreads_container').show(); } log("mThreads.show end"); }, close: function() { log("mThreads.close begin"); mThreads.visible = false; $('#_mThreads_content_header').hide(); $('#_mThreads_container').hide(); log("mThreads.close end"); }, onDirty: function() { mThreads.dirty = true; if (mThreads.visible) mThreads.render(); }, onSearch: function(s) { if (s == "") s = null; mThreads.currentSearch = s; mThreads.onDirty(); }, onDirtyFolder: function(folderName) { if (startsWith(folderName, mThreads.currentFolderId)) { mThreads.dirty = true; if (mThreads.visible) mThreads.render(); } }, applyToMarked: function(f) { var marked = []; for (var i=0; i'; var ae = ''; var content = null; if (d.loaded) { var clazz = "unread"; if (d.state.indexOf("READ")!=-1) clazz = "read"; var draftMarker = ""; if (d.state.indexOf("DRAFT")!=-1) draftMarker= 'Draft'; var sendMarker = ""; if (d.state.indexOf("SENDING")!=-1) sendMarker= 'Sending'; var attachmentMarker = ""; if (d.state.indexOf("ATTACHMENT")!=-1) attachmentMarker= ''; var numItems = d.numItems > 1 ? (' (' + d.numItems + ')') : ''; content = '' + '' + d.participants + numItems + draftMarker + sendMarker + attachmentMarker + '' + '' + ab + '' + htmlEncode(d.subject) + '' + '' + htmlEncode(d.brief) + '' + ae + '' + '' + d.date + ''; } else { content = 'Loading...'; } var row = '' + content + ''; all.push(row); } $('#_mThreads').html(NOHREF(all.join(''))); $('#_mMain_content_header_range_numbers').html(NOHREF( mThreads.currentPosition + "-" + (mThreads.currentPosition + mThreads.jsConversations.length) + " of " + ((mThreads.currentSearch == null) ? mThreads.maxConversations : "?") )); log("mThreads.renderData end"); }, markUiRead: function(i, read) { mThreads.jsConversations[i].read = read; $('#mThread_' + i).attr("class", read ? "read" : "unread"); }, openConversation: function(i) { log("mThreads.openConversation"); mThreads.close(); mThreads.markUiRead(i, true); mReader.open(mThreads.javaConversations[i]); var set = mThreads.currentFolderSet; var id = mThreads.currentFolderId; var name = mThreads.currentFolderName; $('#mReader_content_header_navigation').html( NOHREF('Back to #NAME#') .replace("#SET#", set) .replace("#ID#", id) .replace("#NAME#", name) ); log("mThreads.openConversation end"); }, clipPosition: function() { var maxPosition = mThreads.maxConversations - (mThreads.maxConversations % mThreads.threadsPerPage); if (mThreads.currentPosition > maxPosition) mThreads.currentPosition = maxPosition; if (mThreads.currentPosition < 0) mThreads.currentPosition = 0; }, onMove: function(d) { mThreads.currentPosition += d * mThreads.threadsPerPage; mThreads.clipPosition(); mThreads.dirty = true; mThreads.render(); }, onNewest: function() { mThreads.currentPosition = 0; mThreads.dirty = true; mThreads.render(); }, onOldest: function() { mThreads.currentPosition = 0xFFFFFF; mThreads.clipPosition(); mThreads.dirty = true; mThreads.render(); }, initialize: function() { } } ; /***** mThreads.js *****/