src/cm/media/js/site/c_text_view_comments.js
author Simon Descarpentries <sid@sopinspace.com>
Wed, 30 Oct 2013 18:08:42 +0100
changeset 556 69503659fe8f
parent 532 0bad3613f59d
child 600 fda73ac53450
permissions -rw-r--r--
[c_selection.js] If safari_mobile, get current selection from a previously created global variable [c_sync.js] ref where the safari_mobile global is used [c_text_view_comments.js] if safari_mobile update selection also on selectionChange event [text_view_comments.html] if safari_mobile store a clone of the current selection on each selectionChange set layout width to 99% to improve display factorize safari mobile detection code
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
556
69503659fe8f [c_selection.js] If safari_mobile, get current selection from a previously created global variable
Simon Descarpentries <sid@sopinspace.com>
parents: 532
diff changeset
   167
// safari_mobile defined in media/js/client/c_sync.js
69503659fe8f [c_selection.js] If safari_mobile, get current selection from a previously created global variable
Simon Descarpentries <sid@sopinspace.com>
parents: 532
diff changeset
   168
if (safari_mobile)
69503659fe8f [c_selection.js] If safari_mobile, get current selection from a previously created global variable
Simon Descarpentries <sid@sopinspace.com>
parents: 532
diff changeset
   169
	onSelectionChange = onTextMouseUp;
69503659fe8f [c_selection.js] If safari_mobile, get current selection from a previously created global variable
Simon Descarpentries <sid@sopinspace.com>
parents: 532
diff changeset
   170
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   171
gLastScrollTime = null ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   172
checkForAlignement = function () {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   173
  var now = (new Date()).getTime() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   174
  if ((gLastScrollTime != null) && (now - gLastScrollTime) > 200) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   175
    positionICommentForm() ;      
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   176
    gLastScrollTime = null ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   177
  }
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
onFrameScroll = function () {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   181
  gLastScrollTime = (new Date()).getTime() ;
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
browse = function(order, whereto) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   185
  gSync.browse(order, whereto) ; 
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   186
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   187
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   188
initialConnect = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   189
  CY.on("mouseup", onTextMouseUp, "#textcontainer");
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   190
  gTimer = CY.Lang.later(200, this, checkForAlignement, [], true) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   191
  CY.on('scroll', onFrameScroll, window, this, true);
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   192
  CY.on('resize', onFrameScroll, window, this, true);
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   193
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   194
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   195
preventLinksInText = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   196
  var interceptLink = function(e) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   197
    var a = e.target;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   198
    var href = null;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   199
    while (a != null && href == null) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   200
      a = a.get('parentNode');
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   201
      href = a.get("href");
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
    
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   204
    if (a != null && href != null) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   205
      //alert(window.location) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   206
      var clean_window_location = window.location.href ;
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
      var ind = clean_window_location.indexOf('#') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   209
      if (ind != -1)
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   210
        clean_window_location = clean_window_location.substring(0, ind) ;
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
      if (href.indexOf(clean_window_location) == -1 ) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   213
        window.open(a.get("href"));
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   214
        e.preventDefault(); ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   215
      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   216
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   217
  } ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   218
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   219
  CY.all("#textcontainer a").on("click", interceptLink);
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   220
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   221
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   222
onDomReady = function(arg1) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   223
  preventLinksInText();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   224
  var q1 = new CY.AsyncQueue(); //  
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   225
  // doesn't behave like the doc says :
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   226
  // no timeout -> seems in blocking mode
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   227
  q1.add( {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   228
    fn : function() {
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   229
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   230
      if (gLayout.isInComentSite()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   231
        parent.toInitialSize();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   232
      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   233
      if (sv_withComments) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   234
        instanciateICommentForm();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   235
      }
421
3ddbfa64f596 Adds a table of content.
gibus
parents: 341
diff changeset
   236
      instanciateToc();
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   237
    },
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   238
    timeout :5
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   239
  }, {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   240
    fn : function() {
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   241
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   242
      gGETValues = CY.JSON.parse(sv_get_params);
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   243
      
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
   244
      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
   245
      CY.get('#textcontainer').setStyle('display', 'block');
341
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
      var val = (sv_withComments) ? gPrefs.get('layout','comments_col_width') : 0 ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   248
      var colWidth = sliderValToPx(val) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   249
      gLayout.setLeftColumnWidth(colWidth) ;
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
      if (gLayout.isInFrame()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   252
        parent.f_initFrame();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   253
        parent.f_layoutFrames();
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   254
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   255
        if (sv_withComments) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   256
          parent.f_fillTopToolbar() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   257
          if (hasPerm("can_create_comment"))    
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   258
            parent.$("#add_comment_btn").removeClass('initially_hidden');
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   259
          //parent.enqueueLoadingMsg(); // no more loading message ? TODO
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_fillFilterTab() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   262
          parent.f_fillPreferencesTab() ;
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
//          parent.f_fillBrowseSection() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   265
          
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   266
          var firstTimeFilterData = CY.JSON.parse(sv_filter_data);
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   267
          parent.f_updateFilterData(firstTimeFilterData);
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
          parent.f_setFilterValue(gGETValues) ;         
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
        parent.f_fillTextPreferencesTab() ;
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
      
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   274
      if (gLayout.isInComentSite()) 
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   275
        parent.$("#c_fullscreen_btn").show();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   276
      else {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   277
        parent.$("#c_fullscreen_btn").hide();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   278
      }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   279
422
37cd1c72115d Hides button if table of contents is empty.
gibus
parents: 421
diff changeset
   280
      if (gToc['empty'])
37cd1c72115d Hides button if table of contents is empty.
gibus
parents: 421
diff changeset
   281
        parent.$("#c_toc_btn").hide();
37cd1c72115d Hides button if table of contents is empty.
gibus
parents: 421
diff changeset
   282
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   283
    },
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   284
    timeout :5
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   285
  }, {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   286
    fn : function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   287
      if (sv_withComments) {
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
        reinit(gGETValues);
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   290
        initialConnect();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   291
      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   292
    },
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   293
    timeout :5
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   294
  }, {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   295
    fn : function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   296
      if (gLayout.isInFrame()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   297
        parent.f_interfaceUnfreeze() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   298
        parent.f_removeLoadingMsg();
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   299
      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   300
      // if there is a comment id in the url display it
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   301
      if ("comment_id_key" in gGETValues) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   302
        var id_key = gGETValues["comment_id_key"] ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   303
        var comment = gDb.getCommentByIdKey(id_key) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   304
        if (comment != null) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   305
          var path = gDb.getPath(comment) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   306
          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
   307
          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
   308
          // 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
   309
          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
   310
            gSync.showFocusSingleComment(topParentComment, focusComment, true) ;
614669e0e313 Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents: 329
diff changeset
   311
          }
614669e0e313 Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents: 329
diff changeset
   312
          else {
614669e0e313 Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents: 329
diff changeset
   313
            gSync.showFocusSingleComment(topParentComment, focusComment, false) ;
614669e0e313 Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents: 329
diff changeset
   314
          }
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   315
        }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   316
      }
337
614669e0e313 Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents: 329
diff changeset
   317
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   318
      // if comment_auto_display: show all comments
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   319
      if ("comments_auto_display" in gGETValues) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   320
        gSync.showAllComments();
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
//      else {
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   324
//      gSync.showAllComments() ;// show all
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   325
//      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   326
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   327
  });
053551f213fb Coding style for js: expand tabs
gibus
parents: 340
diff changeset
   328
  q1.run();
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   329
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   330