src/cm/media/js/site/c_text_view_comments.js
author gibus
Tue, 30 Nov 2010 09:53:35 +0100
changeset 341 053551f213fb
parent 340 9e2b9e568e42
child 421 3ddbfa64f596
permissions -rw-r--r--
Coding style for js: expand tabs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     1
CY = null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     2
gPrefs = null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     3
gLayout = null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     4
gDb = null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     5
gIComments = null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     6
gSync = null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     7
gGETValues = null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     8
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     9
gConf = {'iCommentLeftPadding':4, 
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    10
    'iCommentThreadPadding':12,
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    11
        'defaultCommentFormat':'markdown',
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    12
        'sliderFixedMin':.9,
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    13
        'sliderFixedMax':.1,
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    14
        'iCommentsInitAlloc':2,
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    15
        'defaultPrefs':{'text':{'style':'text-modern-style'}, 'user' : {'name' : '','email' : ''},'general': {'animduration' : '0.4'},'comments': {'threadpad' : '1'},'layout': {'comments_col_width' : '25'  /* out of 100 */}}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    16
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    17
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    18
//available text styles in c-text-styles.css
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    19
//classname(key) : will be added to #textcontainer, name(value) : the name to display in style dropdown choice"
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    20
gTextStyles = {'text-modern-style':gettext('modern'), 'text-classic-style':gettext('classic'), 'text-code-style':gettext('code')};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    21
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    22
YUI( {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    23
  base :sv_media_url + "/js/lib/yui/" + c_yui_base + "/build/",
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    24
  // filter: '{% if CLIENT_DEBUG %}debug{% else %}raw{% endif %}',
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    25
  // filter :'raw',
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    26
  timeout :10000
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    27
}).use(
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    28
      "text-modern-style",
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    29
    "cookie",
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    30
    "json",
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    31
    "overlay",
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    32
    "io-form",
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    33
    "async-queue",
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    34
    "event-mouseenter",   
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    35
    "anim",
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    36
    "collection",
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    37
    function(Y) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    38
          CY = Y;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    39
          
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    40
            gPrefs = new Preferences() ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    41
            gPrefs.init() ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    42
            
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    43
            gLayout = new Layout() ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    44
            gLayout.init() ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    45
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    46
        if (sv_withComments) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    47
              gDb = new Db() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    48
              gDb.init() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    49
              
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    50
              gIComments = new IComments() ;                            
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    51
              gIComments.init() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    52
        }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    53
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    54
            gSync = new Sync() ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    55
            gSync.init() ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    56
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    57
      CY.on("domready", onDomReady, this); 
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    58
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    59
    });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    60
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    61
_reinit = function(filterRes) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    62
  gIComments.hide();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    63
  gDb.initComments(filterRes['commentIds']);
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    64
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    65
  unpaintAllComments();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    66
  renderCommentScopes();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    67
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    68
  updateFilterResultsCount(filterRes['nbDiscussions'], filterRes['nbComments'], filterRes['nbReplies']);
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    69
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    70
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    71
reinit = function(filterGETValues) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    72
  var filterRes = gDb.computeFilterResults(filterGETValues);
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    73
  _reinit(filterRes);
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    74
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    75
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    76
hideAll = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    77
  _reinit({'commentIds':[],'nbDiscussions':0, 'nbComments':0, 'nbReplies':0});
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    78
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    79
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    80
updateFilterResultsCount = function(nbDiscussions, nbComments, nbReplies) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    81
  var r = gDb.getCommentsAndRepliesCounts(true);
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    82
  var nbAllComments = r[0], nbAllReplies = r[1];
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    83
  var detailedResults = (nbComments != 0 || nbReplies != 0) && (nbAllComments != nbComments || nbAllReplies != nbReplies) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    84
  if (gLayout.isInFrame()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    85
    parent.f_updateFilterCountDetailed(detailedResults) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    86
    parent.f_updateFilterCountResult(nbDiscussions, nbComments, nbReplies, nbAllComments, nbAllReplies);
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    87
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    88
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    89
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    90
updateResetFilterResultsCount = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    91
  var counts = gDb.getCommentsAndRepliesCounts(false)
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    92
  var nbComments = counts[0], nbReplies = counts[1];
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    93
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    94
  var nbDiscussions = nbComments;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
    95
  updateFilterResultsCount(nbDiscussions, nbComments, nbReplies);
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    96
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    97
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    98
// TODO MOVE
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    99
renderCommentScopes = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   100
  for (var i = 0 ; i < gDb.comments.length ; i++) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   101
    var comment = gDb.comments[i] ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   102
    paintCommentScope(comment) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   103
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   104
} ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   105
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   106
onTextMouseUp = function(e) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   107
  if (readyForAction()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   108
    var selection = getSelectionInfo() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   109
    if (selection != null) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   110
      updateICommentFormSelection(selection) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   111
      if (gEditICommentHost != null) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   112
        var modifyScope = CY.get("#"+gEdit['ids']['changeScopeInputId']+" input").get('checked') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   113
        if (modifyScope) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   114
          gEditICommentHost.scrollIntoView() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   115
        }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   116
      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   117
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   118
    else {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   119
      var node = e.target ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   120
      if (node.hasClass('c-c')) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   121
        var elt = CY.Node.getDOMNode(node) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   122
        var commentIds = getCommentIdsFromClasses(elt) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   123
        if (commentIds.length > 0) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   124
          checkForOpenedDialog(null, function() { // will only check for reply
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   125
            gSync.showComments(commentIds, [e.pageX, e.pageY], false) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   126
          }) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   127
        }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   128
      } 
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   129
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   130
//// FIRST UPDATE SELECTION IF ANY AND SCROLL TO EDITION IF ANY   
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   131
//    if (isICommentFormVisible() || gEditICommentHost != null) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   132
//      CY.log(selection) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   133
//      updateICommentFormSelection(selection) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   134
//      
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   135
//      if (gEditICommentHost != null) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   136
//        var modifyScope = CY.get("#"+gEdit['ids']['changeScopeInputId']+" input").get('checked') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   137
//        if (modifyScope) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   138
//          gEditICommentHost.scrollIntoView() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   139
//          didSomething = true ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   140
//        }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   141
//      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   142
//      if (isICommentFormVisible())
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   143
//      didSomething = true ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   144
//    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   145
//    else {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   146
//      checkForOpenedDialog(null, function() { // will only check for reply
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   147
//          var node = e.target ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   148
//          if (node.hasClass('c-c')) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   149
//            var elt = CY.Node.getDOMNode(node) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   150
//            var commentIds = getCommentIdsFromClasses(elt) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   151
//            if (commentIds.length > 0) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   152
//              //hideOverlay(gICommentForm) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   153
//              // gIComments.hide() ;20080814 moved it to gSync._showComments
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   154
//              gSync.showComments(commentIds, [e.pageX, e.pageY]) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   155
//            }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   156
//          }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   157
//        }) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   158
//    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   159
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   160
} ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   161
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   162
gLastScrollTime = null ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   163
checkForAlignement = function () {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   164
  var now = (new Date()).getTime() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   165
  if ((gLastScrollTime != null) && (now - gLastScrollTime) > 200) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   166
    positionICommentForm() ;      
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   167
    gLastScrollTime = null ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   168
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   169
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   170
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   171
onFrameScroll = function () {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   172
  gLastScrollTime = (new Date()).getTime() ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   173
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   174
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   175
browse = function(order, whereto) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   176
  gSync.browse(order, whereto) ; 
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   177
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   178
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   179
initialConnect = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   180
  CY.on("mouseup", onTextMouseUp, "#textcontainer");
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   181
  gTimer = CY.Lang.later(200, this, checkForAlignement, [], true) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   182
  CY.on('scroll', onFrameScroll, window, this, true);
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   183
  CY.on('resize', onFrameScroll, window, this, true);
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   184
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   185
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   186
preventLinksInText = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   187
  var interceptLink = function(e) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   188
    var a = e.target;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   189
    var href = null;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   190
    while (a != null && href == null) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   191
      a = a.get('parentNode');
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   192
      href = a.get("href");
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   193
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   194
    
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   195
    if (a != null && href != null) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   196
      //alert(window.location) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   197
      var clean_window_location = window.location.href ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   198
      
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   199
      var ind = clean_window_location.indexOf('#') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   200
      if (ind != -1)
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   201
        clean_window_location = clean_window_location.substring(0, ind) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   202
      
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   203
      if (href.indexOf(clean_window_location) == -1 ) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   204
        window.open(a.get("href"));
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   205
        e.preventDefault(); ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   206
      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   207
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   208
  } ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   209
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   210
  CY.all("#textcontainer a").on("click", interceptLink);
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   211
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   212
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   213
onDomReady = function(arg1) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   214
  preventLinksInText();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   215
  var q1 = new CY.AsyncQueue(); //  
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   216
  // doesn't behave like the doc says :
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   217
  // no timeout -> seems in blocking mode
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   218
  q1.add( {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   219
    fn : function() {
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   220
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   221
      if (gLayout.isInComentSite()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   222
        parent.toInitialSize();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   223
      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   224
      if (sv_withComments) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   225
        instanciateICommentForm();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   226
      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   227
    },
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   228
    timeout :5
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   229
  }, {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   230
    fn : function() {
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   231
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   232
      gGETValues = CY.JSON.parse(sv_get_params);
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   233
      
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   234
      CY.get('#maincontainer').setStyle('display', 'block');
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   235
      CY.get('#textcontainer').setStyle('display', 'block');
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   236
      
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   237
      var val = (sv_withComments) ? gPrefs.get('layout','comments_col_width') : 0 ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   238
      var colWidth = sliderValToPx(val) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   239
      gLayout.setLeftColumnWidth(colWidth) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   240
      
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   241
      if (gLayout.isInFrame()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   242
        parent.f_initFrame();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   243
        parent.f_layoutFrames();
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   244
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   245
        if (sv_withComments) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   246
          parent.f_fillTopToolbar() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   247
          if (hasPerm("can_create_comment"))    
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   248
            parent.$("#add_comment_btn").removeClass('initially_hidden');
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   249
          //parent.enqueueLoadingMsg(); // no more loading message ? TODO
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   250
          
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   251
          parent.f_fillFilterTab() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   252
          parent.f_fillPreferencesTab() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   253
          
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   254
//          parent.f_fillBrowseSection() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   255
          
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   256
          var firstTimeFilterData = CY.JSON.parse(sv_filter_data);
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   257
          parent.f_updateFilterData(firstTimeFilterData);
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   258
          
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   259
          parent.f_setFilterValue(gGETValues) ;         
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   260
        }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   261
        parent.f_fillTextPreferencesTab() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   262
      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   263
      
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   264
      if (gLayout.isInComentSite()) 
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   265
        parent.$("#c_fullscreen_btn").show();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   266
      else {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   267
        parent.$("#c_fullscreen_btn").hide();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   268
      }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   269
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   270
    },
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   271
    timeout :5
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   272
  }, {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   273
    fn : function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   274
      if (sv_withComments) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   275
        
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   276
        reinit(gGETValues);
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   277
        initialConnect();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   278
      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   279
    },
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   280
    timeout :5
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   281
  }, {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   282
    fn : function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   283
      if (gLayout.isInFrame()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   284
        parent.f_interfaceUnfreeze() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   285
        parent.f_removeLoadingMsg();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   286
      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   287
      // if there is a comment id in the url display it
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   288
      if ("comment_id_key" in gGETValues) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   289
        var id_key = gGETValues["comment_id_key"] ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   290
        var comment = gDb.getCommentByIdKey(id_key) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   291
        if (comment != null) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   292
          var path = gDb.getPath(comment) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   293
          var topParentComment = path[path.length - 1] ;
329
00df963f91fb When comment_id_key is passed as URL parameter, focus on this comment, instead of the top comment of the related thread.
gibus
parents: 276
diff changeset
   294
          var focusComment = gDb.getCommentByIdKey(id_key);
337
614669e0e313 Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents: 329
diff changeset
   295
          // if comment_op=reply, show reply form
340
9e2b9e568e42 Be more strict by controlling that value ofcomment_op url parameter is set to "reply"
gibus
parents: 337
diff changeset
   296
          if ("comment_op" in gGETValues && gGETValues["comment_op"] == 'reply') {
337
614669e0e313 Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents: 329
diff changeset
   297
            gSync.showFocusSingleComment(topParentComment, focusComment, true) ;
614669e0e313 Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents: 329
diff changeset
   298
          }
614669e0e313 Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents: 329
diff changeset
   299
          else {
614669e0e313 Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents: 329
diff changeset
   300
            gSync.showFocusSingleComment(topParentComment, focusComment, false) ;
614669e0e313 Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents: 329
diff changeset
   301
          }
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   302
        }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   303
      }
337
614669e0e313 Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents: 329
diff changeset
   304
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   305
      // if comment_auto_display: show all comments
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   306
      if ("comments_auto_display" in gGETValues) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   307
        gSync.showAllComments();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   308
      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   309
      
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   310
//      else {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   311
//      gSync.showAllComments() ;// show all
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   312
//      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   313
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   314
  });
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   315
  q1.run();
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   316
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   317