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