src/cm/media/js/client/c_addcomment_form.js
author gibus
Mon, 10 Mar 2014 13:24:19 +0100
changeset 600 fda73ac53450
parent 562 92e8e5aaacde
permissions -rw-r--r--
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     1
gICommentForm = null ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     2
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     3
instanciateICommentForm = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
     4
  gICommentForm = {
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
     5
      'position':[CY.WidgetPositionAlign.TL, CY.WidgetPositionAlign.TL],
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
     6
      'formId':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
     7
      'formTitleId':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
     8
      'titleInputId':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
     9
      'contentInputId':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    10
      'tagsInputId':CY.guid(),
504
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 421
diff changeset
    11
      'categoryInputId':CY.guid(),
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    12
      'formatInputId':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    13
      'startWrapperInputId':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    14
      'endWrapperInputId':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    15
      'startOffsetInputId':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    16
      'endOffsetInputId':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    17
      'selectionPlaceId':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    18
      'keyId':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    19
      'currentSelId':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    20
      'currentSelIdI':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    21
      'addBtnId':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    22
      'cancelBtnId':CY.guid(),
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    23
      'closeBtnId':CY.guid()
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    24
  } ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    25
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    26
  if (!sv_loggedIn) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    27
    gICommentForm ['nameInputId'] = CY.guid() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    28
    gICommentForm ['emailInputId'] = CY.guid() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    29
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    30
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    31
  var overlayHtml = getHtml(gICommentForm) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    32
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    33
  var width = gLayout.getTopICommentsWidth() ;
562
92e8e5aaacde Give maximum width for add_comment form and toc.
Simon Descarpentries <sid@sopinspace.com>
parents: 532
diff changeset
    34
  width += gLayout.iCommentsRequiredThreadPadding (); // SID: use max available space as there is no indentation on that box
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    35
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    36
  var overlay = new CY.Overlay( {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    37
    zIndex :3,
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    38
    shim :false, // until we really need it, no shim 
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    39
    visible :false,
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    40
    headerContent :overlayHtml['headerContent'],
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    41
    bodyContent :overlayHtml['bodyContent'],
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    42
    xy :[10,10],
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    43
    width : width
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    44
  });
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    45
  overlay.get('contentBox').addClass("c-newcomment") ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    46
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    47
  // attach to DOM
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    48
  overlay.render('#leftcolumn');
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    49
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    50
  if (!sv_loggedIn) {
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
    51
    CY.one("#"+gICommentForm['nameInputId']).set('value',gPrefs.get("user","name")) ;
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
    52
    CY.one("#"+gICommentForm['emailInputId']).set('value',gPrefs.get("user","email")) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    53
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    54
    
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
    55
  CY.one("#"+gICommentForm['formTitleId']).set('innerHTML', gettext('New comment')) ;
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
    56
  CY.one("#"+gICommentForm['formatInputId']).set('value',gConf['defaultCommentFormat']) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    57
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    58
  CY.on("click", onSubmitICommentFormClick, "#"+gICommentForm['addBtnId']);
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    59
  CY.on("click", onCancelICommentFormClick, "#"+gICommentForm['cancelBtnId']);
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    60
  CY.on("click", onCancelICommentFormClick, "#"+gICommentForm['closeBtnId']);
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    61
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    62
  gICommentForm['overlay'] = overlay ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    63
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    64
  var animationHide = null ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    65
  animationHide = new CY.Anim({
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    66
        node: overlay.get('boundingBox'),
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    67
        duration: .3, //gPrefs['general']['animduration'],
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    68
        easing: CY.Easing.easeOut
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    69
    });   
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    70
  gICommentForm['animationHide'] = animationHide ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    71
  animationHide.set('to', { opacity: 0});// height : 0 doesn't work
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    72
  gICommentForm['animationHide-handle'] = animationHide.on('end', onICommentFormHideAnimEnd, gICommentForm);
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    73
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    74
  var animationShow = null ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    75
  animationShow = new CY.Anim({
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    76
        node: overlay.get('boundingBox'),
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    77
        duration: .3, //gPrefs['general']['animduration'],
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    78
        easing: CY.Easing.easeOut
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    79
    });   
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    80
  gICommentForm['animationShow'] = animationShow ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    81
  animationShow.set('to', { opacity: 1});
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    82
  gICommentForm['animationShow-handle'] = animationShow.on('end', onICommentFormShowAnimEnd, gICommentForm);
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    83
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    84
  changeFormFieldsWidth(gICommentForm['formId'], width) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    85
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    86
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    87
cleanICommentForm = function() {
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
    88
  CY.one("#"+gICommentForm['currentSelIdI']).set('innerHTML', gNoSelectionYet) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    89
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    90
    var hostNode = gICommentForm['overlay'].getStdModNode(CY.WidgetStdMod.BODY) ;
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
    91
    hostNode.all(".comment_input").set('value', "") ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    92
  
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
    93
  CY.one("#"+gICommentForm['formatInputId']).set('value',gConf['defaultCommentFormat']) ;// for now ...
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    94
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    95
  if (!sv_loggedIn) {
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
    96
    hostNode.all(".user_input").set('value', "") ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    97
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    98
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    99
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   100
onICommentFormHideAnimEnd = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   101
//  iComment['overlay'].blur() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   102
  this.overlay.hide() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   103
  gSync.resume() ;    
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
onICommentFormShowAnimEnd = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   107
  gSync.resume() ;    
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   108
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   109
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   110
onSubmitICommentFormClick = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   111
  if (!sv_loggedIn) {
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
   112
    var name = CY.one("#"+gICommentForm['nameInputId']).get('value') ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   113
    gPrefs.persist("user", "name", name) ;  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   114
  
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
   115
    var email = CY.one("#"+gICommentForm['emailInputId']).get('value') ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   116
    gPrefs.persist("user", "email", email) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   117
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   118
  gSync.saveComment(gICommentForm['formId']) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   119
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   120
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   121
onCancelICommentFormClick = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   122
  gSync.cancelICommentForm() ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   123
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   124
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   125
// record selection info in hidden form fields
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   126
_updateICommentFormSelection = function(ids, displayedText, csStartSelection, csEndSelection) {
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
   127
  var node = CY.Node.one('#'+ids['currentSelIdI']) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   128
  if (node != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   129
    node.set('innerHTML', displayedText) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   130
  
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
   131
    node = CY.one('#'+ids['startWrapperInputId']) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   132
  if (node != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   133
    node.set('value', csStartSelection['elt'].id.substring("sv_".length)) ;
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
   134
    node = CY.one('#'+ids['startOffsetInputId']) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   135
  if (node != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   136
    node.set('value', csStartSelection['offset']) ;
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
   137
    node = CY.one('#'+ids['endWrapperInputId']) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   138
  if (node != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   139
    node.set('value', csEndSelection['elt'].id.substring("sv_".length)) ;
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
   140
    node = CY.one('#'+ids['endOffsetInputId']) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   141
  if (node != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   142
    node.set('value', csEndSelection['offset']) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   143
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   144
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   145
updateICommentFormSelection = function(selection) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   146
  var text = (selection == null) ? "" : selection['text'] ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   147
  if (text != "") {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   148
    // display text to be commented 
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   149
    var displayedText = text ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   150
    var maxLength = 100 ; // even number only
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   151
    if (text.length > maxLength ) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   152
      var start = text.substring(0, (text.substring(0, maxLength/2)).lastIndexOf(" ")) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   153
      var endPart = text.substring(text.length - maxLength/2) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   154
      var end = endPart.substring(endPart.indexOf(" ")) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   155
      displayedText = start + " ... " + end ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   156
    }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   157
        var csStartSelection = _convertSelectionFromCCToCS(selection['start']) ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   158
        var csEndSelection = _convertSelectionFromCCToCS(selection['end']) ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   159
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   160
        _updateICommentFormSelection(gICommentForm, displayedText, csStartSelection, csEndSelection);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   161
        if (gEdit != null)
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   162
          _updateICommentFormSelection(gEdit['ids'], displayedText, csStartSelection, csEndSelection);
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   163
      positionICommentForm() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
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
showICommentForm= function () {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   168
  removeFormErrMsg(gICommentForm['formId']) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   169
  if (!sv_loggedIn) {
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
   170
    if (CY.one("#"+gICommentForm['nameInputId']).get('value') == '') 
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
   171
      CY.one("#"+gICommentForm['nameInputId']).set('value', gPrefs.get('user','name')) ;
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
   172
    if (CY.one("#"+gICommentForm['emailInputId']).get('value') == '') 
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
   173
      CY.one("#"+gICommentForm['emailInputId']).set('value', gPrefs.get('user','email')) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   174
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   175
  gIComments.hide() ;
421
3ddbfa64f596 Adds a table of content.
gibus
parents: 382
diff changeset
   176
  hideToc();
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   177
  positionICommentForm() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   178
  gICommentForm['overlay'].show() ;
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
   179
  CY.one("#"+gICommentForm['titleInputId']).focus() ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   180
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   181
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   182
isICommentFormVisible = function () {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   183
  if (gICommentForm != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   184
    return gICommentForm['overlay'].get('visible') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   185
  return false ;
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
positionICommentForm = function () {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   189
  if (gICommentForm != null) { 
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   190
    var overlay = gICommentForm['overlay'] ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   191
    var boundingBox = overlay.get('boundingBox') ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   192
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   193
    var commentFormHeight = boundingBox.get('offsetHeight') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   194
    var windowHeight = boundingBox.get('winHeight') ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   195
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   196
    var pos = gICommentForm['position'] ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   197
    if (commentFormHeight > windowHeight) // trying to have save comment visible ... :
600
fda73ac53450 Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents: 562
diff changeset
   198
      pos = [CY.WidgetPositionAlign.BL, CY.WidgetPositionAlign.BL] ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   199
    
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   200
    overlay.set("align", {points:pos});
382
a3eaeeed9c6e better positioning of 'new comment' form
gibus
parents: 341
diff changeset
   201
    if (commentFormHeight <= windowHeight)
a3eaeeed9c6e better positioning of 'new comment' form
gibus
parents: 341
diff changeset
   202
      overlay.set("y", overlay.get("y") + 30);
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   203
    boundingBox.setX(boundingBox.getX() + gConf['iCommentLeftPadding']);
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   204
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   205
}