Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Bloco de código
languagexml
<script type="text/template" class="social-timeline-edit-content-template">
	<div class="">
		<textarea name="content-text-edit-{{id}}" class="content-text-edit" id="content-text-edit" data-content-text-edit data-sociable-type="{{sociable}}">{{text}}</textarea>			
	</div>
	<div class="edit-buttons-area fr">
		<span class="post-text-limit-edit">{{count}}</span>
		<button class="btn btn-default" data-timeline-action="cancelEdit">Cancelar</button>
		<button class="btn btn-primary edit-content-button" data-timeline-action="saveEdit">Publicar</button>				
	</div>				
</script>
<script type="text/template" class="social-edited-date">
	<span class="timeline-header-no-link fs-no-bold"> - </span>
	<span class="fluigicon fluigicon-user-edit fs-cursor-default" title="{{editionDate}}"></span>				
</script>

 

socialtimeline.js

Nas linhas:

35: ADICIONAR o seguinte conteúdo:

Bloco de código
languagejs
mentionsObj: null,

 

90: ADICIONAR o seguinte conteúdo: 

Bloco de código
languagejs
'edit' :'${i18n.getTranslation("edit")}',
'edited' :'${i18n.getTranslation("edited")}',
'in' :'${i18n.getTranslation("in")}',

 

111: ADICIONAR o seguinte conteúdo:

Bloco de código
languagejs
'post.success.edited': '${i18n.getTranslation("post.success.edited")}',
'comment.success.edited': '${i18n.getTranslation("comment.success.edited")}'

 

116: ADICIONAR o seguinte conteúdo:

Bloco de código
languagejs
'content-text-edit': ['keyup_resetCountText', 'focus_resetCountText', 'blur_resetCountText', 'input_resetCountText']

 

276: ADICIONAR o seguinte conteúdo:

Bloco de código
languagejs
var that = this;

 

309: ADICIONAR o seguinte conteúdo:

Bloco de código
languagejs
posts[i].allowsEditActions = ((this.loggedUserAlias === posts[i].user.alias) && (this.hasPermission(posts[i].permissions,'EDIT')));
posts[i].editionDate =  posts[i].editionDate != null ? that.formatEditionDate(posts[i].editionDate) : false;

 

323: ADICIONAR o seguinte conteúdo:

Bloco de código
languagejs
posts[i].comments[j].editionDate =  posts[i].comments[j].editionDate != null ? that.formatEditionDate(posts[i].comments[j].editionDate) : false;

 

388: ADICIONAR o seguinte conteúdo:

Bloco de código
languagejs
data[i].allowsEditActions = (this.loggedUserAlias === data[i].user.alias && this.hasPermission(permissions,'EDIT'));

 

912: ADICIONAR o seguinte conteúdo:

Bloco de código
languagejs
/* --- EDIÇÃO DE POSTS E COMENTÁRIOS --- */
// ação para apendar um textarea e editar o post
editPostAction: function(el, ev, id) {
	var that = this;
	// clique no botão de editar do mesmo post, ação nula.
	if($('[name="content-text-edit-' + id +'"]').length > 0){
		return;
	}
	this.cancelEditAction();
	$(el).addClass('fs-transparent-25');
	that.mentionsObj = null;
	var postText = $('[data-timeline-content-' + id + ']', this.DOM);
	// recupera o conteúdo do post
	this.serviceFindPost(id, function(err, data) {
		if (err) {
			that.showListPostsMessage(err);
			return false;
		}
		if (data && data.content) {
			var count = 600 - data.content.text.length;
			postText.hide(0, function() {
				var html = Mustache.render(that.templates['social-timeline-edit-content-template'], {
					id: id,
					text: data.content.text,
					count: count,
					sociable: 'editPost'
				});
				$('[data-edit-area-' + id + ']', this.DOM).append(html);
				that.mentions();
				that.mentionsObj = data.content.mentions;
			});
		}
	});
},		
// ação para apendar um textarea e editar o comentário
editCommentAction: function(el, ev, id) {
	var that = this;
	// clique no botão de editar do mesmo comentário, ação nula.
	if($('[name="content-text-edit-' + id +'"]').length > 0){
		return;
	}
	this.cancelEditAction();
	$(el).addClass('fs-transparent-25');
	that.mentionsObj = null;
	// recupera o conteúdo do comentário
	var commentText = $('[data-timeline-content-' + id + ']', this.DOM);
	this.serviceFindComment(id, function(err, data) {
		if (err) {
			that.showListPostsMessage(err);
			return false;
		}
		if (data && data.content) {
			var count = 600 - data.content.commentWithoutMention.length;
			commentText.hide(0, function() {
				var html = Mustache.render(that.templates['social-timeline-edit-content-template'], {
					id: id,							
					text: data.content.comment,
					count: count,
					sociable: 'editComment'
				});
				$('[data-edit-area-' + id + ']', this.DOM).append(html);
				that.mentions();
				that.mentionsObj = data.content.mentions;
			});
		}
	});
},
// antes de abrir um textarea para edição, remove qualquer outra edição em aberto e volta a exibir o conteúdo atual
// ação padrão 
cancelEditAction: function(){
	$('a.fluigicon-pencil').removeClass('fs-transparent-25');
	$('.timeline-text-content').show();
	$('.timeline-edit-area').html("");
},
// publica a edição do posts/comentario
saveEditAction: function(el, ev, id){
	var that = this;
	var newText = "";
	var sociable = $('#content-text-edit').data('sociable-type');
	$('#content-text-edit').mentionsInput('val', function(text) {
		newText = text;
	});
	
	if (that.mentionsObj) {
		var listMentions = Object.keys(that.mentionsObj);
		listMentions.forEach(function(data, i) {
		    var regex = new RegExp(that.mentionsObj[data], 'g');
		    newText = newText.replace(regex, '@[' + data + ']');
		});
	}
	this.serviceEditPostOrComment(sociable, id, newText, function(err, data) {
		if (err) {
			that.showMessageError(err);
			return false;
		}
		var msg = 'post.success.edited';
		if(sociable == 'editComment'){
			msg = 'comment.success.edited';
		};
		FLUIGC.toast({
			message: that.i18n.messages[msg],
			type: 'success'
		});
		that.getNewContent(id, sociable);
	});
},

 

1617: ADICIONAR o seguinte conteúdo:

Bloco de código
languagejs
formatEditionDate: function(date){
	var d = new Date(date);
	return d.toLocaleDateString() + " " + d.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
},

 

1730: ADICIONAR o seguinte conteúdo:

Bloco de código
languagejs
serviceEditPostOrComment: function(sociable, postId, text, cb) {			
	var data = {
		sociableObjectId: postId,
		text: text
	};
	var options = {
		url: '/api/public/2.0/posts/' + sociable,
		contentType: 'application/json',
		dataType: 'json',
		type: 'POST',
		data: JSON.stringify(data)
	};
	this.baseAjax(options, cb);
},