Better distinguish between user data and ViewPort added entries
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 16 Dec 2009 06:39:12 +0000 (23:39 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 16 Dec 2009 19:45:58 +0000 (12:45 -0700)
imp/js/DimpBase.js
imp/js/ViewPort.js
imp/js/mailbox-dimp.js

index 336c1f8..36a8d1c 100644 (file)
@@ -125,7 +125,7 @@ var DimpBase = {
 
             case 1:
                 curr_row = sel.get('dataob').first();
-                curr = curr_row.rownum + num;
+                curr = curr_row.VP_rownum + num;
                 break;
 
             default:
@@ -140,7 +140,7 @@ var DimpBase = {
         if (row.size()) {
             row_data = row.get('dataob').first();
             if (!curr_row || row_data.imapuid != curr_row.imapuid) {
-                this.viewport.scrollTo(row_data.rownum);
+                this.viewport.scrollTo(row_data.VP_rownum);
                 this.viewport.select(row, { delay: 0.3 });
             }
         } else {
@@ -395,7 +395,7 @@ var DimpBase = {
                             }
                             r.status += ptr.elt;
 
-                            r.bg.push(ptr.c);
+                            r.VP_bg.push(ptr.c);
 
                             if (ptr.b) {
                                 bg = ptr.b;
@@ -426,17 +426,17 @@ var DimpBase = {
                     r.subject = r.subjecttitle = '[' + DIMP.text.badsubject + ']';
                 }
 
-                r.bg.push('vpRow');
+                r.VP_bg.push('vpRow');
 
                 switch (mode) {
                 case 'vert':
-                    r.bg.unshift('vpRowVert');
-                    r.className = r.bg.join(' ');
+                    r.VP_bg.unshift('vpRowVert');
+                    r.className = r.VP_bg.join(' ');
                     return this.template.vert.evaluate(r);
 
                 default:
-                    r.bg.unshift('vpRowHoriz');
-                    r.className = r.bg.join(' ');
+                    r.VP_bg.unshift('vpRowHoriz');
+                    r.className = r.VP_bg.join(' ');
                     return this.template.horiz.evaluate(r);
                 }
             }.bind(this),
@@ -514,8 +514,8 @@ var DimpBase = {
 
             e.memo.each(function(row) {
                 // Add context menu
-                this._addMouseEvents({ id: row.domid, type: row.menutype });
-                new Drag(row.domid, this._msgDragConfig);
+                this._addMouseEvents({ id: row.VP_domid, type: row.menutype });
+                new Drag(row.VP_domid, this._msgDragConfig);
             }, this);
 
             if (this.uid) {
@@ -1592,7 +1592,7 @@ var DimpBase = {
         case Event.KEY_BACKSPACE:
             r = sel.get('dataob');
             if (e.shiftKey) {
-                this.moveSelected((r.last().rownum == this.viewport.getMetaData('total_rows')) ? (r.first().rownum - 1) : (r.last().rownum + 1), true);
+                this.moveSelected((r.last().rownum == this.viewport.getMetaData('total_rows')) ? (r.first().VP_rownum - 1) : (r.last().VP_rownum + 1), true);
             }
             this.deleteMsg({ vs: sel });
             e.stop();
@@ -1604,8 +1604,8 @@ var DimpBase = {
                 row = this.viewport.createSelection('rownum', this.lastrow + ((kc == Event.KEY_UP) ? -1 : 1));
                 if (row.size()) {
                     row = row.get('dataob').first();
-                    this.viewport.scrollTo(row.rownum);
-                    this.msgSelect(row.domid, { shift: true });
+                    this.viewport.scrollTo(row.VP_rownum);
+                    this.msgSelect(row.VP_domid, { shift: true });
                 }
             } else {
                 this.moveSelected(kc == Event.KEY_UP ? -1 : 1);
@@ -2089,7 +2089,7 @@ var DimpBase = {
                 });
             });
 
-            search = this.viewport.getSelection().search({ vp_id: { equal: uids } });
+            search = this.viewport.getSelection().search({ VP_id: { equal: uids } });
         } else {
             r.uids = r.uids[this.folder];
             r.uids.each(function(f, u) {
index ada91ec..4e087c9 100644 (file)
@@ -20,8 +20,8 @@
  *            This function MUST return the HTML representation of the row.
  *
  *            This representation MUST include both the DOM ID (stored in
- *            the domid field) and the CSS class name (stored as an array in
- *            the bg field) in the outermost element.
+ *            the VP_domid data entry) and the CSS class name (stored as an
+ *            array in the VP_bg data entry) in the outermost element.
  *
  *            Selected rows will contain the classname 'vpRowSelected'.
  *
  * data: (object) Data for each entry that is passed to the template to create
  *       the viewable rows. Keys are a unique ID (see also the 'rowlist'
  *       entry). Values are the data objects. Internal keys for these data
- *       objects must NOT begin with the string 'vp'.
+ *       objects must NOT begin with the string 'VP_'.
  * label: (string) [REQUIRED when initial is true] The label to use for the
  *        view.
  * metadata [optional]: (object) Metadata for the view. Entries in buffer are
  * view: (string) The view ID of the request.
  *
  *
+ * Data entries:
+ * -------------
+ * In addition to the data provided from the server, the following
+ * dynamically created entries are also available:
+ *   VP_domid: (string) The DOM ID of the row.
+ *   VP_id: (string) The unique ID used to store the data entry.
+ *   VP_rownum: (integer) The row number of the row.
+ *
+ *
  * Scroll bars use ars styled using these CSS class names:
  * -------------------------------------------------------
  * vpScroll - The scroll bar container.
@@ -882,20 +891,16 @@ var ViewPort = Class.create({
     {
         var r = Object.clone(row);
 
-        r.bg = r.bg
-            ? row.bg.clone()
+        r.VP_bg = this.getSelected().contains('uid', r.VP_id)
+            ? [ 'vpRowSelected' ]
             : [];
 
-        if (this.getSelected().contains('uid', r.vp_id)) {
-            r.bg.push('vpRowSelected');
-        }
-
         return this.opts.onContent(r, this.pane_mode);
     },
 
     updateRow: function(row)
     {
-        var d = $(row.domid);
+        var d = $(row.VP_domid);
         if (d) {
             this.opts.container.fire('ViewPort:clear', [ d ]);
 
@@ -903,7 +908,6 @@ var ViewPort = Class.create({
 
             this.opts.container.fire('ViewPort:contentComplete', [ row ]);
         }
-
     },
 
     _handleWait: function(call)
@@ -978,7 +982,7 @@ var ViewPort = Class.create({
         if (!this.split_pane[mode].lh) {
             // To avoid hardcoding the line height, create a temporary row to
             // figure out what the CSS says.
-            var d = new Element('DIV', { className: this.opts.list_class }).insert(this.prepareRow({ domid: null }, mode)).hide();
+            var d = new Element('DIV', { className: this.opts.list_class }).insert(this.prepareRow({ VP_domid: null }, mode)).hide();
             $(document.body).insert(d);
             this.split_pane[mode].lh = d.getHeight();
             d.remove();
@@ -1435,9 +1439,9 @@ ViewPort_Buffer = Class.create({
             if (!Object.isUndefined(e)) {
                 // We can directly write the rownum to the original object
                 // since we will always rewrite when creating rows.
-                e.domid = 'vp_row' + u;
-                e.rownum = this.uidlist.get(u);
-                e.vp_id = u;
+                e.VP_domid = 'VP_row' + u;
+                e.VP_rownum = this.uidlist.get(u);
+                e.VP_id = u;
                 return e;
             }
         }, this).compact();
@@ -1583,11 +1587,13 @@ ViewPort_Selection = Class.create({
     {
         d = Object.isArray(d) ? d : [ d ];
 
+        // Data is stored internally as UIDs.
         switch (format) {
         case 'dataob':
-            return d.pluck('vp_id');
+            return d.pluck('VP_id');
 
         case 'div':
+            // ID here is the DOM ID of the element object.
             return d.pluck('id').invoke('substring', 6);
 
         case 'domid':
@@ -1619,13 +1625,13 @@ ViewPort_Selection = Class.create({
             return d;
 
         case 'div':
-            return d.pluck('domid').collect(function(e) { return $(e); }).compact();
+            return d.pluck('VP_domid').collect(function(e) { return $(e); }).compact();
 
         case 'domid':
-            return d.pluck('domid');
+            return d.pluck('VP_domid');
 
         case 'rownum':
-            return d.pluck('rownum');
+            return d.pluck('VP_rownum');
         }
     },
 
@@ -1665,7 +1671,7 @@ ViewPort_Selection = Class.create({
                     }
                 });
             });
-        }).pluck('vp_id'));
+        }).pluck('VP_id'));
     },
 
     size: function()
index a50ebc0..d7c76ad 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 DimpBase.msglist_template_horiz =
-'<div class="#{className}" id="#{domid}" style="#{style}">' +
+'<div class="#{className}" id="#{VP_domid}" style="#{style}">' +
  '<div class="msgStatus sep">' +
   '<div class="msCheck"></div>' +
   '#{status}' +
@@ -24,7 +24,7 @@ DimpBase.msglist_template_horiz =
 '</div>';
 
 DimpBase.msglist_template_vert =
-'<div class="#{className}" id="#{domid}" style="#{style}">' +
+'<div class="#{className}" id="#{VP_domid}" style="#{style}">' +
  '<div class="msgStatus">' +
   '<div class="msCheck"></div>' +
   '#{status}' +