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