src/cm/media/js/client/c_icomment.js
changeset 103 61fd17f9ab78
parent 11 7b8167c4aa6f
child 106 36165e7cd1f0
equal deleted inserted replaced
78:dda94db1149a 103:61fd17f9ab78
    24 	var deleteComment = gettext("delete comment") ;
    24 	var deleteComment = gettext("delete comment") ;
    25 	var edit = gettext("edit") ;
    25 	var edit = gettext("edit") ;
    26 	var del = gettext("delete") ;
    26 	var del = gettext("delete") ;
    27 	var close = gettext("close") ;
    27 	var close = gettext("close") ;
    28 	var showScope = gettext("show scope") ;
    28 	var showScope = gettext("show scope") ;
       
    29 	var scopeRemoved = gettext("Comment is detached : it was created on a previous version and text it applied to has been modified or removed.") ;
    29 	
    30 	
    30 	// no header, no body yet 
    31 	// no header, no body yet 
    31 	this.overlay = new CY.Overlay( {
    32 	this.overlay = new CY.Overlay( {
    32 		zIndex :3,
    33 		zIndex :3,
    33 		shim :false, /* until we really need it, no shim */
    34 		shim :false, /* until we really need it, no shim */
    44 								changeTo + ' ' +
    45 								changeTo + ' ' +
    45 								'<a class="c-state-pending c-action" title="' + changeToPending + '" alt="' + changeToPending + '">'+ pending +'</a>' + " " +  
    46 								'<a class="c-state-pending c-action" title="' + changeToPending + '" alt="' + changeToPending + '">'+ pending +'</a>' + " " +  
    46 								'<a class="c-state-approved c-action" title="' + changeToApprove + '" alt="' + changeToApprove + '">'+ approved +'</a>' + " " +  
    47 								'<a class="c-state-approved c-action" title="' + changeToApprove + '" alt="' + changeToApprove + '">'+ approved +'</a>' + " " +  
    47 								'<a class="c-state-unapproved c-action" title="' + changeToUnapprove + '" alt="' + changeToUnapprove + '">'+ unapproved +'</a>' + " " +  
    48 								'<a class="c-state-unapproved c-action" title="' + changeToUnapprove + '" alt="' + changeToUnapprove + '">'+ unapproved +'</a>' + " " +  
    48 								'<a class="c-state-cancel c-action" title="' + cancelChange + '" alt="' + cancelChange + '">' + cancel +'</a>' + " " +  
    49 								'<a class="c-state-cancel c-action" title="' + cancelChange + '" alt="' + cancelChange + '">' + cancel +'</a>' + " " +  
       
    50 							'</div>' + 
       
    51 							'<div class="c-no-scope-msg">' +
       
    52 								scopeRemoved +  
    49 							'</div>' + 
    53 							'</div>' + 
    50 							'<a class="c-show-scope c-action" title="'+ showScope + '" alt="' + showScope + '"><em>-</em></a>' +
    54 							'<a class="c-show-scope c-action" title="'+ showScope + '" alt="' + showScope + '"><em>-</em></a>' +
    51 							'<a class="c-close c-action" title="'+ close + '" alt="' + close + '"><em>X</em></a>' +
    55 							'<a class="c-close c-action" title="'+ close + '" alt="' + close + '"><em>X</em></a>' +
    52 						'</div>',
    56 						'</div>',
    53 		bodyContent :	'<div class="icomment-body">' +
    57 		bodyContent :	'<div class="icomment-body">' +
   175 					}
   179 					}
   176 				}
   180 				}
   177 			}
   181 			}
   178 			else {
   182 			else {
   179 				if (gShowingAllComments) {
   183 				if (gShowingAllComments) {
   180 					// next special dirty case test explained : when editing/replying to a comment with gShowingAllComments a click in the edit/reply form also is a click on the iComment, in this case we don't want to showSingleComment .... 
   184 					// next special dirty case test explained : when editing/replying to a comment with gShowingAllComments a click in the edit/reply form also is a click on the iComment, in this case we don't want to showSingleComment ....
       
   185 					// should be handled via a preventDefault in some way
   181 					if (!this._isHostingAForm()) {
   186 					if (!this._isHostingAForm()) {
   182 						var comment = gDb.getComment(this.commentId) ;
   187 						var comment = gDb.getComment(this.commentId) ;
   183 						checkForOpenedDialog(null, function() {
   188 						checkForOpenedDialog(null, function() {
   184 							if (comment != null) 
   189 							if (comment != null) 
   185 								gSync.showSingleComment(comment) ;
   190 								gSync.showSingleComment(comment) ;
   274 	},
   279 	},
   275 	fetch : function(comment) {
   280 	fetch : function(comment) {
   276 		this.commentId = comment.id ;
   281 		this.commentId = comment.id ;
   277 		var boundingBoxNode = this.overlay.get('boundingBox') ;
   282 		var boundingBoxNode = this.overlay.get('boundingBox') ;
   278 		
   283 		
       
   284 		if (comment['start_wrapper'] != -1){ 
       
   285 			boundingBoxNode.addClass('c-has-scope') ;
       
   286 			boundingBoxNode.removeClass('c-has-no-scope') ;
       
   287 		}
       
   288 		else { 
       
   289 			boundingBoxNode.addClass('c-has-no-scope') ;
       
   290 			boundingBoxNode.removeClass('c-has-scope') ;
       
   291 		}
       
   292 		
       
   293 		if (comment['reply_to_id'] != null){ 
       
   294 			boundingBoxNode.addClass('c-is-reply') ;
       
   295 		}
       
   296 		else { 
       
   297 			boundingBoxNode.removeClass('c-is-reply') ;
       
   298 		}
       
   299 		
   279 		// TITLE
   300 		// TITLE
   280 		var titleInfos = interpolate(gettext('last modified on %(date)s'),{'date':comment.modified_user_str}, true) ;
   301 		var titleInfos = interpolate(gettext('last modified on %(date)s'),{'date':comment.modified_user_str}, true) ;
   281 		
   302 		
   282 		var modifDateTooltip = (comment.modified == comment.created) ? '' : '<a title="' + titleInfos + '"> * </a>' ;
   303 		var modifDateTooltip = (comment.modified == comment.created) ? '' : '<a title="' + titleInfos + '"> * </a>' ;
   283 		var permaTitle = gettext('Permalink to this comment') ;
   304 		var permaTitle = gettext('Permalink to this comment') ;
   316 		// PERMALINK
   337 		// PERMALINK
   317 		boundingBoxNode.query(".c-permalink").set("href",sv_site_url + comment.permalink) ;
   338 		boundingBoxNode.query(".c-permalink").set("href",sv_site_url + comment.permalink) ;
   318 
   339 
   319 		// MODERATION
   340 		// MODERATION
   320 		this.changeModeration(comment) ;
   341 		this.changeModeration(comment) ;
       
   342 /* useless : use implemendted permanentlink instead
       
   343  * 
   321 		// also change link title to give users the possibility to know comment id (to be able to reference this exact comment in GET arguments) 
   344 		// also change link title to give users the possibility to know comment id (to be able to reference this exact comment in GET arguments) 
   322 		var moderationLnk = this.overlay.get('contentBox').query(".c-moderate") ;
   345 		var moderationLnk = this.overlay.get('contentBox').query(".c-moderate") ;
   323 		//var cid = (comment.reply_to_id == null) ? this.commentId : "" ;
   346 		//var cid = (comment.reply_to_id == null) ? this.commentId : "" ;
   324 		moderationLnk.set("title", "click to change comment ID visibility".replace(/ID/, this.commentId).replace(/  /, " ")) ;
   347 		moderationLnk.set("title", "click to change comment ID visibility".replace(/ID/, this.commentId).replace(/  /, " ")) ;
   325 		
   348 		
       
   349  */		
   326 		// open links in new window :
   350 		// open links in new window :
   327 		var links = boundingBoxNode.queryAll(".c-content a") ;
   351 		var links = boundingBoxNode.queryAll(".c-content a") ;
   328 		if (links != null)
   352 		if (links != null)
   329 			links.setAttribute( "target" , "_blank" ) ;
   353 			links.setAttribute( "target" , "_blank" ) ;
   330 		links = boundingBoxNode.queryAll(".c-header-title a") ;
   354 		links = boundingBoxNode.queryAll(".c-header-title a") ;