Show
Ignore:
Timestamp:
08/29/09 00:39:39 (3 months ago)
Author:
fumiakiy
Message:

Merged slapshot to trunk. "svn merge -r3786:4152 http://code.sixapart.com/svn/movabletype/branches/slapshot/ ."

Location:
trunk/default_templates
Files:
3 modified
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/default_templates/comments.mtml

    r3531 r4155  
    33</mt:Ignore> 
    44<mt:IfCommentsActive> 
     5 
    56<div id="comments" class="comments"> 
    67 
     
    910    <!-- Display comments --> 
    1011    </mt:Ignore> 
    11     <mt:Comments> 
     12    <mt:Comments lastn="$comments_per_page" sort_order="ascend"> 
    1213        <mt:CommentsHeader> 
    1314    <h2 class="comments-header"><$mt:EntryCommentCount singular="<__trans phrase="1 Comment">" plural="<__trans phrase="# Comments">" none="<__trans phrase="No Comments">"$></h2> 
    14     <div class="comments-content"> 
     15    <mt:If tag="EntryCommentCount" gt="$comments_per_page"> 
     16    <ul id="top-comment-nav"> 
     17      <li id="top-prev-comments"> 
     18        <a href="javascript://" id="top-prev-comments-link" title="<__trans phrase="Older Comments">">&lt;&lt;&nbsp;<__trans phrase="Older Comments"></a> 
     19      </li> 
     20      <li id="top-num-comments"><span id="top-current-comments"></span></li> 
     21      <li id="top-next-comments"> 
     22        <a href="javascript://" id="top-next-comments-link" title="<__trans phrase="Newer Comments">"><__trans phrase="Newer Comments">&nbsp;&gt;&gt;</a> 
     23      </li> 
     24    </ul> 
     25    </mt:If> 
     26    <div id="comments-content" class="comments-content" style="clear: left;"> 
    1527        </mt:CommentsHeader> 
    16         <div id="comment-<$mt:CommentID$>" class="comment<mt:IfCommentParent> comment-reply</mt:IfCommentParent><mt:IfCommenterIsEntryAuthor> entry-author-comment</mt:IfCommenterIsEntryAuthor>"> 
    17             <div class="inner"> 
    18                 <div class="comment-header"> 
    19                     <div class="asset-meta"> 
    20                         <span class="byline"> 
    21                             <$mt:CommentAuthorIdentity$> 
    22         <mt:IfCommentParent> 
    23                             <__trans phrase="[_1] replied to <a href="[_2]">comment from [_3]</a>" params="<span class="vcard author"><$mt:CommentAuthorLink$></span>%%<mt:CommentParent><$mt:CommentLink$></mt:CommentParent>%%<mt:CommentParent><$mt:CommentAuthor$></mt:CommentParent>"> 
    24         <mt:Else> 
    25                             <span class="vcard author"><$mt:CommentAuthorLink$></span> 
    26         </mt:IfCommentParent> 
    27                             | <a href="<$mt:CommentLink$>"><abbr class="published" title="<$mt:CommentDate format_name="iso8601"$>"><$mt:CommentDate$></abbr></a> 
    28         <mt:IfCommentsAccepted> 
    29                             | <$mt:CommentReplyToLink$> 
    30         </mt:IfCommentsAccepted> 
    31                         </span> 
    32                     </div> 
    33                 </div> 
    34                 <div class="comment-content"> 
    35                     <$mt:CommentBody$> 
    36                 </div> 
    37             </div> 
    38         </div> 
     28        <$mt:Include module="<__trans phrase="Comment Detail">"$> 
    3929        <mt:CommentsFooter> 
    4030    </div> 
    4131        </mt:CommentsFooter> 
    4232    </mt:Comments> 
    43  
     33    <mt:If tag="EntryCommentCount" gt="$comments_per_page"> 
     34        <mt:Ignore><__trans phrase="The data is modified by the paginate script"></mt:Ignore> 
     35        <ul id="comment-nav"> 
     36        <li id="prev-comments"> 
     37          <a href="javascript://" id="prev-comments-link" title="<__trans phrase="Older Comments">">&lt;&lt;&nbsp;<__trans phrase="Older Comments"></a> 
     38        </li> 
     39        <li id="num-comments"><span id="current-comments"></span></li> 
     40        <li id="next-comments"> 
     41          <a href="javascript://" id="next-comments-link" title="<__trans phrase="Newer Comments">"><__trans phrase="Newer Comments">&nbsp;&gt;&gt;</a> 
     42        </li> 
     43      </ul> 
     44    </mt:If> 
    4445 
    4546    <mt:Ignore> 
  • trunk/default_templates/entry.mtml

    r2733 r4155  
    44<head> 
    55    <$mt:Include module="<__trans phrase="HTML Head">"$> 
     6    <$mt:Var name="comments_per_page" value="50"$> 
    67    <mt:EntryPrevious><link rel="prev bookmark" href="<$mt:EntryPermalink$>" title="<$mt:EntryTitle encode_html="1"$>" /></mt:EntryPrevious> 
    78    <mt:EntryNext><link rel="next bookmark" href="<$mt:EntryPermalink$>" title="<$mt:EntryTitle encode_html="1"$>" /></mt:EntryNext> 
    89    <$mt:EntryTrackbackData$> 
     10    <mt:If tag="EntryCommentCount" gt="$comments_per_page"> 
     11            <script type="text/javascript"> 
     12         MT.entryID = <$mt:EntryID$>; 
     13         MT.commentsPerPage = <$mt:Var name="comments_per_page"$>; 
     14         MT.entryCommentCount = <$mt:EntryCommentCount$>; 
     15         MT.commentIds = [<mt:Comments sort_order="ascend" glue=","><mt:CommentID></mt:Comments>]; 
     16            </script> 
     17          </mt:If> 
    918    <title><$mt:EntryTitle encode_html="1"$> - <$mt:BlogName encode_html="1"$></title> 
    1019</head> 
  • trunk/default_templates/javascript.mtml

    r3531 r4155  
    7878    return; 
    7979} 
     80 
     81if(!this.JSON){JSON={};}(function(){function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z';};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}if(typeof rep==='function'){value=rep.call(holder,key,value);}switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}return str('',{'':value});};}if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}return reviver.call(holder,key,value);}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}throw new SyntaxError('JSON.parse');};}}()); 
     82 
     83var MT = window.MT || {}; 
     84 
     85MT.cons = function () { 
     86  return { 
     87    LOG : 'log', 
     88    WARN : 'warn', 
     89    DEBUG : 'debug', 
     90    INFO : 'info', 
     91    ERR : 'error', 
     92    JSON : 'json' 
     93  }; 
     94}(); 
     95 
     96<mt:Ignore> 
     97/** 
     98 * Used for base functionality related to MT 
     99 *  
     100 * @package MT 
     101 * @class core 
     102 * @global 
     103 * @param {Object} o optional configuration object 
     104 * Options: 
     105 */ 
     106</mt:Ignore> 
     107MT.core = function (o) { 
     108  var _debug = false; 
     109   
     110  return { 
     111    <mt:Ignore> 
     112    /** 
     113     * Makes remote call and handles response 
     114     *  
     115     * @param {String} url The URL endpoint 
     116     * @param {String} respType The type of response expected 
     117     * @param {Function} respHandler The function to handle the response 
     118     * @return void 
     119     */ 
     120    </mt:Ignore> 
     121    connect : function (url,respType,respHandler) { 
     122      var xh = mtGetXmlHttp(); 
     123      if (!xh) return false; 
     124       
     125      xh.onreadystatechange = function() { 
     126        if ( xh.readyState == 4 ) { 
     127          if ( xh.status && ( xh.status != 200 ) ) { 
     128            // error - ignore 
     129          } else { 
     130            switch (respType) { 
     131              case 'json': 
     132                respHandler(JSON.parse(xh.responseText)); 
     133                break; 
     134                 
     135              case 'xml': 
     136                break; 
     137                 
     138              case 'text': 
     139                break; 
     140            } 
     141          } 
     142        } 
     143      }; 
     144       
     145      xh.open('GET',url); 
     146      xh.send(null); 
     147    }, 
     148     
     149    getEl : function (el) { 
     150      return MT.util.checkNodeType(el)==='element' ? id : (document.getElementById(el) || false); 
     151    }, 
     152     
     153    addEvent : function (el,type,func,obj) { 
     154      if(!obj && document.addEventListener) { 
     155        el.addEventListener(type,func,false); 
     156      } else if(obj && document.addEventListener) { 
     157        el.addEventListener(type,function () { 
     158          func.call(obj,event); 
     159        },false); 
     160      } else { 
     161        if(obj) { 
     162          el.attachEvent('on' + type,function () { 
     163            func.call(obj,event); 
     164          }); 
     165        } else { 
     166          el.attachEvent('on' + type,function () {           
     167            func.call(el,event); 
     168          }); 
     169        } 
     170      } 
     171    }, 
     172     
     173    <mt:Ignore> 
     174    /** 
     175     * Basic logging function 
     176     *  
     177     * @param {String} level The log level (WARN|DEBUG|INFO|ERROR|LOG) 
     178     * Specified by one of the MT constants 
     179     * @param {String} msg The log message 
     180     * @return void 
     181     */ 
     182    </mt:Ignore> 
     183    log : function (level,msg) { 
     184      if(_debug && window.console) { 
     185        switch(level) { 
     186          case 'warn': 
     187          case 'debug': 
     188          case 'info': 
     189          case 'error': 
     190          case 'log': 
     191            console[level](msg); 
     192            break; 
     193             
     194          default: 
     195            return false;  
     196        } 
     197      } else { 
     198        return false; 
     199      } 
     200    } 
     201  } 
     202}(); 
     203 
     204<mt:Ignore> 
     205/** 
     206 * Utilities class 
     207 *  
     208 * @package MT 
     209 * @class util 
     210 * @global 
     211 * Options: 
     212 */ 
     213</mt:Ignore> 
     214MT.util = function () { 
     215  return { 
     216    toggleVisibility : { 
     217      show : function () { 
     218        var i = arguments.length; 
     219         
     220        while(i--) { 
     221          if(MT.util.checkNodeType(arguments[i])==='element') { 
     222            arguments[i].style.visibility = 'visible'; 
     223          } else { 
     224            MT.core.getEl(arguments[i]).style.visibility = 'visible'; 
     225          } 
     226        } 
     227      }, 
     228       
     229      hide : function () { 
     230        var i = arguments.length; 
     231        while(i--) { 
     232          if(MT.util.checkNodeType(arguments[i])==='element') { 
     233            arguments[i].style.visibility = 'hidden'; 
     234          } else { 
     235            MT.core.getEl(arguments[i]).style.visibility = 'hidden'; 
     236          } 
     237        } 
     238      } 
     239    }, 
     240     
     241    toggleDisplay : { 
     242      show : function () { 
     243        var i = arguments.length; 
     244        while(i--) { 
     245          if(MT.util.checkNodeType(arguments[i])==='element') { 
     246            arguments[i].style.display = ''; 
     247          } else { 
     248            MT.core.getEl(arguments[i]).style.display = ''; 
     249          } 
     250        } 
     251      }, 
     252       
     253      hide : function () { 
     254        var i = arguments.length; 
     255        while(i--) { 
     256          if(MT.util.checkNodeType(arguments[i])==='element') { 
     257            arguments[i].style.display = 'none'; 
     258          } else { 
     259            MT.core.getEl(arguments[i]).style.display = 'none'; 
     260          } 
     261        } 
     262      } 
     263    }, 
     264     
     265    <mt:Ignore> 
     266    /** 
     267     * Finds the nearest defining (i.e. with an id) parent to the given element 
     268     *  
     269     * @param {HTMLElement} origin the node from which to start the search 
     270     * @return {HTMLElement|Boolean} The parent node with an id attribute or false 
     271     */ 
     272    </mt:Ignore> 
     273    findDefiningParent : function (origin) { 
     274      if(MT.util.checkNodeType(origin)==='element') { 
     275        for(var node=origin.parentNode;node.parentNode;node=node.parentNode) { 
     276          if((node.hasAttribute && node.hasAttribute('id')) || node.getAttribute('id')) { 
     277            return node; 
     278          } 
     279        } 
     280      } 
     281      return false; 
     282    }, 
     283     
     284    <mt:Ignore> 
     285    /** 
     286     * Tests objects to verify if they are DOM nodes 
     287     *  
     288     * @param {Object} obj The object to be tested 
     289     * @return {String} the values 'element'|'textnode'|'whitespace' 
     290     */ 
     291    </mt:Ignore> 
     292    checkNodeType : function (obj) { 
     293      if (obj && obj.nodeName){ 
     294        switch (obj.nodeType) { 
     295          case 1: return 'element'; 
     296          case 3: return (/\S/).test(obj.nodeValue) ? 'textnode' : 'whitespace'; 
     297        } 
     298      } 
     299    } 
     300  } 
     301}(); 
     302 
     303<mt:Ignore> 
     304/** 
     305 * mtPaginateComments takes the currently generated static page and either: 
     306 *  - Attempts to find an individual comment link in the query string 
     307 *  - If no link is found, the static page loads 
     308 * In either case, the pagination event is set 
     309 */ 
     310</mt:Ignore> 
     311(function () { 
     312  var M = MT.core, 
     313      c = MT.cons, 
     314      u = MT.util, 
     315      cache, 
     316      isLoading, 
     317      direction, 
     318      currentComments, 
     319      commentAnchor, 
     320      commentArrId, 
     321      commentsPerPage, 
     322      commentsTotalPages, 
     323      loadingIcon, 
     324      pageNum, 
     325      commentsOffset, 
     326      totalComments, 
     327      entryID, 
     328      commentContentDiv, 
     329      topNav, 
     330      nav, 
     331      currentCommentsSpan, 
     332      topCurrentCommentsSpan; 
     333             
     334  M.addEvent(window,'load',_init); 
     335   
     336  /** 
     337   * Initializes the class 
     338   *  
     339   * @return void 
     340   */ 
     341  function _init () { 
     342    if(!MT.entryCommentCount) { 
     343      return; 
     344    } 
     345     
     346    _initializeVariables(); 
     347    _setCommentOffset(false); 
     348    _checkForAnchor(); 
     349                _setCurrentComments(); 
     350    _toggleNavLinks(); 
     351    _initializeEvents(); 
     352  } 
     353   
     354  <mt:Ignore> 
     355  /** 
     356   * Initializes variables to their initial values 
     357   *  
     358   * @return void 
     359   */ 
     360  </mt:Ignore> 
     361  function _initializeVariables() { 
     362    cache = {}; 
     363    isLoading = false; 
     364    commentAnchor = ''; 
     365    commentArrId = ''; 
     366    commentsPerPage = MT.commentsPerPage || 50; 
     367    currentComments = ''; 
     368    direction = 'ascend'; 
     369    entryID = MT.entryID; 
     370    totalComments = MT.entryCommentCount; 
     371    commentsTotalPages = Math.ceil(totalComments / commentsPerPage); 
     372    pageNum = 1; 
     373     
     374    loadingIcon = "<img title='Loading...' src='<$MTStaticWebPath$>images/indicator.white.gif' alt='Loading' />"; 
     375     
     376    commentContentDiv = M.getEl("comments-content"); 
     377    topNav = M.getEl("top-comment-nav"); 
     378    nav = M.getEl("comment-nav"); 
     379     
     380    currentCommentsSpan = M.getEl("current-comments"); 
     381    topCurrentCommentsSpan = M.getEl("top-current-comments"); 
     382  } 
     383   
     384  function _initializeEvents() { 
     385    if (commentsPerPage < totalComments) { 
     386      M.addEvent(nav,'click',_handleEvents); 
     387      M.addEvent(topNav,'click',_handleEvents); 
     388    } 
     389  } 
     390   
     391  <mt:Ignore> 
     392  /** 
     393   * Checks for an existing anchor tag in the query string 
     394   * If found, it looks for it on the current page 
     395   * If that fails, it tries to find it in comment list and loads 
     396   * the desired page 
     397   *  
     398   * @return void 
     399   */ 
     400  </mt:Ignore> 
     401  function _checkForAnchor() { 
     402    var found = String(window.location.hash).match( /comment-(\d{1,6})/ ); 
     403                 
     404                if (found) { 
     405                  M.log(c.DEBUG,found); 
     406                        if (!M.getEl(found[0]).hasOwnProperty('className')) { 
     407                                if (_findIdMatch(found[1])) { 
     408                        pageNum = Math.floor(commentArrId / commentsPerPage) + 1; 
     409                        M.log(c.DEBUG,'Comment Array Id: ' + commentArrId); 
     410                        M.log(c.DEBUG,'Comments Per Page: ' + commentsPerPage); 
     411                        M.log(c.DEBUG,'Page Number: ' + pageNum); 
     412                        M.log(c.DEBUG,'Comment Offset: ' + _getCommentOffset()); 
     413                        _updateComments(); 
     414                } 
     415                        } 
     416                } 
     417  } 
     418   
     419  <mt:Ignore> 
     420  /** 
     421   * Sets commentsOffset (i.e. the offset number to the remote list) 
     422   *  
     423   * @return void 
     424   */ 
     425  </mt:Ignore> 
     426  function _setCommentOffset() { 
     427    commentsOffset = commentsPerPage * (pageNum-1); 
     428  } 
     429   
     430  <mt:Ignore> 
     431  /** 
     432   * Gets the commentsOffset (i.e. the offset number to the remote list) 
     433   *  
     434   * @return void 
     435   */ 
     436  </mt:Ignore> 
     437  function _getCommentOffset() { 
     438    return commentsOffset; 
     439  } 
     440   
     441  <mt:Ignore> 
     442  /** 
     443   * General event handler 
     444   *  
     445   * @param {Event} e The event object 
     446   * @return void 
     447   */ 
     448  </mt:Ignore> 
     449  function _handleEvents (e) { 
     450    var origin = e.target || e.srcElement, 
     451        parentId; 
     452         
     453    // stupid IE 
     454    origin = origin.id && M.getEl(origin.id) || false; 
     455 
     456    if(origin) { 
     457      parentId = u.checkNodeType(origin.parentNode)==='element' && origin.parentNode.getAttribute('id') && origin.parentNode.id; 
     458    } else { 
     459      return false; 
     460    } 
     461     
     462    switch(origin.nodeName) { 
     463      case 'A': 
     464        switch (parentId) { 
     465          case 'prev-comments': 
     466          case 'top-prev-comments': 
     467            if(e.preventDefault) { 
     468              e.preventDefault(); 
     469            } else { 
     470              e.returnValue =   false; 
     471            } 
     472            if(!isLoading) { 
     473              _previousPage(); 
     474            } 
     475            break; 
     476          case 'next-comments': 
     477          case 'top-next-comments': 
     478            if(e.preventDefault) { 
     479              e.preventDefault(); 
     480            } else { 
     481              e.returnValue =   false; 
     482            } 
     483            if(!isLoading) { 
     484              _nextPage(); 
     485            } 
     486            break; 
     487        } 
     488        break; 
     489    } 
     490  } 
     491   
     492  <mt:Ignore> 
     493  /** 
     494   * Toggles the visibility of the navigation links 
     495   *  
     496   * @return void 
     497   */ 
     498  </mt:Ignore> 
     499  function _toggleNavLinks () { 
     500    M.log(c.DEBUG,M.getEl('top-prev-comments')); 
     501    if(pageNum <= commentsTotalPages && pageNum !== 1) { 
     502      u.toggleVisibility.show('prev-comments'); 
     503      u.toggleVisibility.show('top-prev-comments'); 
     504    } 
     505     
     506    if(pageNum >= 1 && pageNum !== commentsTotalPages) { 
     507      u.toggleVisibility.show('next-comments'); 
     508      u.toggleVisibility.show('top-next-comments'); 
     509    } 
     510     
     511    if(pageNum===1 || nav.style.visibility==='hidden') { 
     512      u.toggleVisibility.hide('prev-comments'); 
     513      u.toggleVisibility.hide('top-prev-comments'); 
     514    } 
     515     
     516    if(pageNum===commentsTotalPages || nav.style.visibility==='hidden') { 
     517      u.toggleVisibility.hide('next-comments'); 
     518      u.toggleVisibility.hide('top-next-comments'); 
     519    } 
     520  } 
     521   
     522  <mt:Ignore> 
     523  /** 
     524   * Determines appropriate action based on the id of the parent 
     525   * clicked link. Decrements pageNum based on id. 
     526   *  
     527   * @param {String} id the id of the parent of the clicked link 
     528   * @return void 
     529   */ 
     530  </mt:Ignore> 
     531  function _nextPage () { 
     532    if(pageNum < commentsTotalPages) { 
     533      pageNum++; 
     534      _updateComments(); 
     535    } 
     536  } 
     537   
     538  <mt:Ignore> 
     539  /** 
     540   * Determines appropriate action based on the id of the parent 
     541   * clicked link. Increments/decrements pageNum based on id. 
     542   *  
     543   * @param {String} id the id of the parent of the clicked link 
     544   * @return void 
     545   */ 
     546  </mt:Ignore> 
     547  function _previousPage() { 
     548    if(pageNum > 1) { 
     549      pageNum--; 
     550      _updateComments(); 
     551    } 
     552  } 
     553   
     554  <mt:Ignore> 
     555  /** 
     556   * Searches for a particular comment in the list of ids 
     557   *  
     558   * @param {String} id The id for which to search 
     559   * @return {Boolean} true, if found, false otherwise 
     560   */ 
     561  </mt:Ignore> 
     562  function _findIdMatch (id) { 
     563    var len = MT.commentIds.length; 
     564     
     565        while (len--) { 
     566                if (MT.commentIds[len] == id) { 
     567                        commentAnchor = "comment-" + id; 
     568                        commentArrId = len; 
     569                        return true; 
     570                } 
     571        } 
     572         
     573        return false; 
     574  } 
     575   
     576  <mt:Ignore> 
     577  /** 
     578   * Sets the current comment counts on the page 
     579   * 
     580   * @return void 
     581   */ 
     582  </mt:Ignore> 
     583  function _setCurrentComments() { 
     584    var commentsOnPage = pageNum != commentsTotalPages ? commentsOffset + commentsPerPage : totalComments; 
     585     
     586    _setCurrentCommentsContent([commentsOffset+1," - ",commentsOnPage].join('')); 
     587  } 
     588   
     589  <mt:Ignore> 
     590  /** 
     591   * Sets the "current-comments" element with the HTML value 
     592   *  
     593   * @param {String|Element} currentCommentsHTML The content to be set 
     594   * @return void 
     595   */ 
     596  </mt:Ignore> 
     597  function _setCurrentCommentsContent(currentCommentsHTML) { 
     598    currentCommentsSpan.innerHTML = currentCommentsHTML; 
     599    topCurrentCommentsSpan.innerHTML = currentCommentsHTML; 
     600  } 
     601   
     602  <mt:Ignore> 
     603  /** 
     604   * Sets the content of the comment list 
     605   *  
     606   * @param {String|Element} commentHTML The content to be set  
     607   * @return void 
     608   */ 
     609  </mt:Ignore> 
     610  function _setCommentContent(commentHTML) { 
     611    commentContentDiv.innerHTML = commentHTML; 
     612  } 
     613   
     614  <mt:Ignore> 
     615  /** 
     616   * Builds the appropriate URL to make a remote call to get the 
     617   * next set of comments 
     618   *  
     619   * @return void 
     620   */ 
     621  </mt:Ignore> 
     622  function _updateComments() { 
     623    var comments, jsonUrl; 
     624    isLoading = true; 
     625    _setCurrentCommentsContent(loadingIcon); 
     626    _setCommentOffset(); 
     627     
     628    jsonUrl = [ 
     629        "<$mt:CGIPath$>mt-comments.cgi?__mode=comment_listing&direction=", 
     630        direction, 
     631        "&entry_id=", 
     632        entryID, 
     633        "&limit=", 
     634        commentsPerPage, 
     635        "&offset=", 
     636        _getCommentOffset() 
     637      ].join(''); 
     638         
     639        if (!commentAnchor) { 
     640      commentAnchor = "comments-content"; 
     641    } 
     642     
     643    if(cache.hasOwnProperty(jsonUrl)) { 
     644      _refreshComments(cache[jsonUrl]); 
     645      isLoading = false; 
     646    } else { 
     647      M.connect(jsonUrl,c.JSON,function (json) { 
     648        cache[jsonUrl] = json.comments; 
     649          _refreshComments(json.comments); 
     650          isLoading = false; 
     651      }); 
     652    } 
     653  } 
     654   
     655  <mt:Ignore> 
     656  /** 
     657   * Refreshes the comment data with the current 
     658   *  
     659   * @param {String} commentData The data used to replace current comments 
     660   * @return void 
     661   */ 
     662  </mt:Ignore> 
     663  function _refreshComments(commentData) { 
     664    _setCommentContent(commentData); 
     665    _setCurrentComments(); 
     666    window.location.hash = 'reset'; 
     667    window.location.hash = commentAnchor; 
     668    _toggleNavLinks(); 
     669  } 
     670})(); 
    80671 
    81672<mt:Ignore>