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