src/cm/media/js/client/c_addcomment_form.js
author Simon Descarpentries <sid@sopinspace.com>
Mon, 21 Oct 2013 16:37:07 +0200
changeset 553 bf26fb47a14c
parent 532 0bad3613f59d
child 562 92e8e5aaacde
permissions -rw-r--r--
To allow scrolling in Safari mobile, we set the content of text_view_comments frame in a jQuery UI layout. So the automated scrolling operations in c_sync.js must be adjustable to the right part to scroll. Also, if a comment have to be shown outside of the current viewport, we scroll the correct part to that viewport and then set the comment top Y offset to juste what it needs to avoid the "Add comment" button after scrolling operation. If not in Safari mobile, we add an offset here to avoid comment to display under the "Add comment" button.
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 = {
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
     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(),
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() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    34
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    35
  var overlay = new CY.Overlay( {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    36
    zIndex :3,
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    37
    shim :false, // until we really need it, no shim 
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    38
    visible :false,
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    39
    headerContent :overlayHtml['headerContent'],
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    40
    bodyContent :overlayHtml['bodyContent'],
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    41
    xy :[10,10],
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    42
    width : width
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    43
  });
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    44
  overlay.get('contentBox').addClass("c-newcomment") ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    45
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    46
  // attach to DOM
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    47
  overlay.render('#leftcolumn');
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    48
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    49
  if (!sv_loggedIn) {
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
    50
    CY.get("#"+gICommentForm['nameInputId']).set('value',gPrefs.get("user","name")) ;
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
    51
    CY.get("#"+gICommentForm['emailInputId']).set('value',gPrefs.get("user","email")) ;
341
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
    
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
    54
  CY.get("#"+gICommentForm['formTitleId']).set('innerHTML', gettext('New comment')) ;
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
    55
  CY.get("#"+gICommentForm['formatInputId']).set('value',gConf['defaultCommentFormat']) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    56
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    57
  CY.on("click", onSubmitICommentFormClick, "#"+gICommentForm['addBtnId']);
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    58
  CY.on("click", onCancelICommentFormClick, "#"+gICommentForm['cancelBtnId']);
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    59
  CY.on("click", onCancelICommentFormClick, "#"+gICommentForm['closeBtnId']);
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    60
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    61
  gICommentForm['overlay'] = overlay ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    62
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    63
  var animationHide = null ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    64
  animationHide = new CY.Anim({
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    65
        node: overlay.get('boundingBox'),
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    66
        duration: .3, //gPrefs['general']['animduration'],
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    67
        easing: CY.Easing.easeOut
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    68
    });   
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    69
  gICommentForm['animationHide'] = animationHide ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    70
  animationHide.set('to', { opacity: 0});// height : 0 doesn't work
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    71
  gICommentForm['animationHide-handle'] = animationHide.on('end', onICommentFormHideAnimEnd, gICommentForm);
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    72
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    73
  var animationShow = null ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    74
  animationShow = new CY.Anim({
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    75
        node: overlay.get('boundingBox'),
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    76
        duration: .3, //gPrefs['general']['animduration'],
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    77
        easing: CY.Easing.easeOut
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    78
    });   
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    79
  gICommentForm['animationShow'] = animationShow ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    80
  animationShow.set('to', { opacity: 1});
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    81
  gICommentForm['animationShow-handle'] = animationShow.on('end', onICommentFormShowAnimEnd, gICommentForm);
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    82
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    83
  changeFormFieldsWidth(gICommentForm['formId'], width) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    84
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    85
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    86
cleanICommentForm = function() {
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
    87
  CY.get("#"+gICommentForm['currentSelIdI']).set('innerHTML', gNoSelectionYet) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    88
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    89
    var hostNode = gICommentForm['overlay'].getStdModNode(CY.WidgetStdMod.BODY) ;
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
    90
    hostNode.queryAll(".comment_input").set('value', "") ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    91
  
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
    92
  CY.get("#"+gICommentForm['formatInputId']).set('value',gConf['defaultCommentFormat']) ;// for now ...
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    93
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    94
  if (!sv_loggedIn) {
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
    95
    hostNode.queryAll(".user_input").set('value', "") ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    96
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    97
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    98
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    99
onICommentFormHideAnimEnd = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   100
//  iComment['overlay'].blur() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   101
  this.overlay.hide() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   102
  gSync.resume() ;    
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   103
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   104
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   105
onICommentFormShowAnimEnd = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   106
  gSync.resume() ;    
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   107
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   108
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   109
onSubmitICommentFormClick = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   110
  if (!sv_loggedIn) {
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
   111
    var name = CY.get("#"+gICommentForm['nameInputId']).get('value') ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   112
    gPrefs.persist("user", "name", name) ;  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   113
  
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
   114
    var email = CY.get("#"+gICommentForm['emailInputId']).get('value') ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   115
    gPrefs.persist("user", "email", email) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   116
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   117
  gSync.saveComment(gICommentForm['formId']) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   118
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   119
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   120
onCancelICommentFormClick = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   121
  gSync.cancelICommentForm() ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   122
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   123
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   124
// record selection info in hidden form fields
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   125
_updateICommentFormSelection = function(ids, displayedText, csStartSelection, csEndSelection) {
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
   126
  var node = CY.Node.get('#'+ids['currentSelIdI']) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   127
  if (node != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   128
    node.set('innerHTML', displayedText) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   129
  
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
   130
    node = CY.get('#'+ids['startWrapperInputId']) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   131
  if (node != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   132
    node.set('value', csStartSelection['elt'].id.substring("sv_".length)) ;
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
   133
    node = CY.get('#'+ids['startOffsetInputId']) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   134
  if (node != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   135
    node.set('value', csStartSelection['offset']) ;
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
   136
    node = CY.get('#'+ids['endWrapperInputId']) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   137
  if (node != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   138
    node.set('value', csEndSelection['elt'].id.substring("sv_".length)) ;
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
   139
    node = CY.get('#'+ids['endOffsetInputId']) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   140
  if (node != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   141
    node.set('value', csEndSelection['offset']) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   142
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   143
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   144
updateICommentFormSelection = function(selection) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   145
  var text = (selection == null) ? "" : selection['text'] ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   146
  if (text != "") {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   147
    // display text to be commented 
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   148
    var displayedText = text ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   149
    var maxLength = 100 ; // even number only
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   150
    if (text.length > maxLength ) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   151
      var start = text.substring(0, (text.substring(0, maxLength/2)).lastIndexOf(" ")) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   152
      var endPart = text.substring(text.length - maxLength/2) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   153
      var end = endPart.substring(endPart.indexOf(" ")) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   154
      displayedText = start + " ... " + end ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   155
    }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   156
        var csStartSelection = _convertSelectionFromCCToCS(selection['start']) ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   157
        var csEndSelection = _convertSelectionFromCCToCS(selection['end']) ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   158
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   159
        _updateICommentFormSelection(gICommentForm, displayedText, csStartSelection, csEndSelection);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   160
        if (gEdit != null)
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   161
          _updateICommentFormSelection(gEdit['ids'], displayedText, csStartSelection, csEndSelection);
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   162
      positionICommentForm() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   163
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   164
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   165
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   166
showICommentForm= function () {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   167
  removeFormErrMsg(gICommentForm['formId']) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   168
  if (!sv_loggedIn) {
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
   169
    if (CY.get("#"+gICommentForm['nameInputId']).get('value') == '') 
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
   170
      CY.get("#"+gICommentForm['nameInputId']).set('value', gPrefs.get('user','name')) ;
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
   171
    if (CY.get("#"+gICommentForm['emailInputId']).get('value') == '') 
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
   172
      CY.get("#"+gICommentForm['emailInputId']).set('value', gPrefs.get('user','email')) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   173
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   174
  gIComments.hide() ;
421
3ddbfa64f596 Adds a table of content.
gibus
parents: 382
diff changeset
   175
  hideToc();
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   176
  positionICommentForm() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   177
  gICommentForm['overlay'].show() ;
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
   178
  CY.get("#"+gICommentForm['titleInputId']).focus() ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   179
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   180
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   181
isICommentFormVisible = function () {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   182
  if (gICommentForm != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   183
    return gICommentForm['overlay'].get('visible') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   184
  return false ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   185
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   186
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   187
positionICommentForm = function () {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   188
  if (gICommentForm != null) { 
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   189
    var overlay = gICommentForm['overlay'] ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   190
    var boundingBox = overlay.get('boundingBox') ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   191
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   192
    var commentFormHeight = boundingBox.get('offsetHeight') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   193
    var windowHeight = boundingBox.get('winHeight') ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   194
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   195
    var pos = gICommentForm['position'] ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   196
    if (commentFormHeight > windowHeight) // trying to have save comment visible ... :
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
   197
      pos = [CY.WidgetPositionExt.BL, CY.WidgetPositionExt.BL] ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   198
    
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   199
    overlay.set("align", {points:pos});
382
a3eaeeed9c6e better positioning of 'new comment' form
gibus
parents: 341
diff changeset
   200
    if (commentFormHeight <= windowHeight)
a3eaeeed9c6e better positioning of 'new comment' form
gibus
parents: 341
diff changeset
   201
      overlay.set("y", overlay.get("y") + 30);
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   202
    boundingBox.setX(boundingBox.getX() + gConf['iCommentLeftPadding']);
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   203
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
   204
}