|
1 |
|
2 // dialog related |
|
3 _afterDlg = function(args) { |
|
4 var yesFunction = args[0] ; |
|
5 var yesFunctionContext = args[1] ; |
|
6 var yesFunctionArgs = args[2] ; |
|
7 yesFunction.call(yesFunctionContext, yesFunctionArgs) ; |
|
8 } |
|
9 _abortNewCommentConfirmed = function(args) { |
|
10 if (isICommentFormVisible()) { |
|
11 if (gLayout.isInFrame()) { |
|
12 gSync.hideICommentForm({fn:function(){_afterDlg(args) ;}}) ; |
|
13 gSync.resume() ; |
|
14 } |
|
15 } |
|
16 } |
|
17 _abortNewReplyConfirmed = function(args) { |
|
18 if (gNewReplyHost != null) { |
|
19 if (gLayout.isInFrame()) { |
|
20 cancelNewReplyForm() ; |
|
21 _afterDlg(args) ; |
|
22 } |
|
23 } |
|
24 } |
|
25 _abortNewEditConfirmed = function(args) { |
|
26 if (gEditICommentHost != null) { |
|
27 if (gLayout.isInFrame()) { |
|
28 cancelEditForm() ; |
|
29 _afterDlg(args) ; |
|
30 } |
|
31 } |
|
32 } |
|
33 |
|
34 //if topIComment != null will check if edit or new reply is hosted by a child of topIComment |
|
35 //if topIComment == null will check if edit or a new reply is hosted somewhere |
|
36 checkForOpenedDialog = function(topIComment, yesFunction, yesFunctionContext, yesFunctionArgs) { |
|
37 var childrenIds = [] ; |
|
38 if (topIComment != null) { |
|
39 childrenIds = CY.Array.map(gDb.getThreads([gDb.getComment(topIComment.commentId)]), function(comment) { return comment.id ;}) ; |
|
40 } |
|
41 |
|
42 if (isICommentFormVisible() |
|
43 || |
|
44 (gNewReplyHost != null && (topIComment == null || CY.Array.indexOf(childrenIds, gNewReplyHost.commentId) != -1)) |
|
45 || |
|
46 (gEditICommentHost != null && (topIComment == null || CY.Array.indexOf(childrenIds, gEditICommentHost.commentId) != -1))) { |
|
47 if (gLayout.isInFrame()) { |
|
48 if (isICommentFormVisible()) |
|
49 parent.f_yesNoDialog(gettext("New comment will be canceled, continue?"), gettext("Warning"), null, null, null, _abortNewCommentConfirmed, this, [yesFunction, yesFunctionContext, yesFunctionArgs]) ; |
|
50 else if (gNewReplyHost != null) |
|
51 parent.f_yesNoDialog(gettext("Started reply will be canceled, continue?"), gettext("Warning"), null, null, null, _abortNewReplyConfirmed, this, [yesFunction, yesFunctionContext, yesFunctionArgs]) ; |
|
52 else if (gEditICommentHost != null) |
|
53 parent.f_yesNoDialog(gettext("Started comment edition will be canceled, continue?"), gettext("Warning"), null, null, null, _abortNewEditConfirmed, this, [yesFunction, yesFunctionContext, yesFunctionArgs]) ; |
|
54 } |
|
55 } |
|
56 else { |
|
57 yesFunction.call(yesFunctionContext, []) ; |
|
58 } |
|
59 } |
|
60 |