src/cm/media/js/client/c_dlg_intercept.js
author gibus
Tue, 15 May 2012 11:16:46 +0200
changeset 432 aad07a378d44
parent 341 053551f213fb
permissions -rw-r--r--
Respect order by scope in show all comments or show all detached comments.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     1
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     2
// dialog related
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     3
_afterDlg = function(args) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
     4
  var yesFunction = args[0] ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
     5
  var yesFunctionContext = args[1] ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
     6
  var yesFunctionArgs = args[2] ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
     7
  yesFunction.call(yesFunctionContext, yesFunctionArgs) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     8
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     9
_abortNewCommentConfirmed = function(args) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    10
  if (isICommentFormVisible()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    11
    if (gLayout.isInFrame()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    12
      gSync.hideICommentForm({fn:function(){_afterDlg(args) ;}}) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    13
      gSync.resume() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    14
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    15
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    16
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    17
_abortNewReplyConfirmed = function(args) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    18
  if (gNewReplyHost != null) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    19
    if (gLayout.isInFrame()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    20
      cancelNewReplyForm() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    21
      _afterDlg(args) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    22
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    23
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    24
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    25
_abortNewEditConfirmed = function(args) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    26
  if (gEditICommentHost != null) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    27
    if (gLayout.isInFrame()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    28
      cancelEditForm() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    29
      _afterDlg(args) ;
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
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    32
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    33
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    34
//if topIComment != null will check if edit or new reply is hosted by a child of topIComment
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    35
//if topIComment == null will check if edit or a new reply is hosted somewhere
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    36
checkForOpenedDialog = function(topIComment, yesFunction, yesFunctionContext, yesFunctionArgs) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    37
  var childrenIds = [] ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    38
  if (topIComment != null) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    39
    childrenIds = CY.Array.map(gDb.getThreads([gDb.getComment(topIComment.commentId)]), function(comment) { return comment.id ;}) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    40
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    41
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    42
  if (isICommentFormVisible()
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
    (gNewReplyHost != null && (topIComment == null || CY.Array.indexOf(childrenIds, gNewReplyHost.commentId) != -1))
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
    (gEditICommentHost != null && (topIComment == null || CY.Array.indexOf(childrenIds, gEditICommentHost.commentId) != -1))) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    47
    if (gLayout.isInFrame()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    48
      if (isICommentFormVisible()) 
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    49
        parent.f_yesNoDialog(gettext("New comment will be canceled, continue?"), gettext("Warning"), null, null, null, _abortNewCommentConfirmed, this, [yesFunction, yesFunctionContext, yesFunctionArgs]) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    50
      else if (gNewReplyHost != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    51
        parent.f_yesNoDialog(gettext("Started reply will be canceled, continue?"), gettext("Warning"), null, null, null, _abortNewReplyConfirmed, this, [yesFunction, yesFunctionContext, yesFunctionArgs]) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    52
      else if (gEditICommentHost != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    53
        parent.f_yesNoDialog(gettext("Started comment edition will be canceled, continue?"), gettext("Warning"), null, null, null, _abortNewEditConfirmed, this, [yesFunction, yesFunctionContext, yesFunctionArgs]) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    54
    }
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
  else {
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    57
    yesFunction.call(yesFunctionContext, []) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 0
diff changeset
    58
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    59
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    60