diff --git a/css/swad18.60.5.css b/css/swad18.61.css similarity index 99% rename from css/swad18.60.5.css rename to css/swad18.61.css index a5707a418..8d3befbb7 100644 --- a/css/swad18.60.5.css +++ b/css/swad18.61.css @@ -2988,6 +2988,12 @@ a:hover img.CENTRE_PHOTO_SHOW color:#202020; font-size:13pt; } +.TL_EXPAND_COMMENTS + { + text-align:center; + vertical-align:top; + padding-bottom:10px; + } .TL_ICO_COMMENT { display:inline-block; diff --git a/js/swad18.60.js b/js/swad18.61.js similarity index 99% rename from js/swad18.60.js rename to js/swad18.61.js index c5a4861b3..37fc0af0b 100644 --- a/js/swad18.60.js +++ b/js/swad18.61.js @@ -775,6 +775,16 @@ function AJAXCreateObject () { return obj; } +/*****************************************************************************/ +/*************** Change display of comments in a social note *****************/ +/*****************************************************************************/ + +function toggleComments (notID) { + toggleDisplay('exp_' + notID); + toggleDisplay('con_' + notID); + toggleDisplay('com_' + notID); +} + /*****************************************************************************/ /************************ Change display of a project ************************/ /*****************************************************************************/ diff --git a/swad_changelog.h b/swad_changelog.h index 808763b2a..6e86a35ad 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -429,10 +429,11 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.60.5 (2019-02-26)" -#define CSS_FILE "swad18.60.5.css" -#define JS_FILE "swad18.60.js" +#define Log_PLATFORM_VERSION "SWAD 18.61 (2019-02-27)" +#define CSS_FILE "swad18.61.css" +#define JS_FILE "swad18.61.js" /* + Version 18.61: Feb 27, 2019 Hide/show comments in a social publishing. (237855 lines) Version 18.60.5: Feb 26, 2019 Changes in CSS for responsive design in timeline. (237788 lines) Version 18.60.4: Feb 26, 2019 Images lazy load using attribute lazyload in timeline. Image quality in timeline improved from 50 to 75. (237910 lines) diff --git a/swad_social.c b/swad_social.c index 9410b46ee..d36d21ace 100644 --- a/swad_social.c +++ b/swad_social.c @@ -57,7 +57,8 @@ /***************************** Private constants *****************************/ /*****************************************************************************/ -#define Soc_WIDTH_TIMELINE "560px" +#define Soc_NUM_VISIBLE_COMMENTS 3 // Maximum number of comments visible before expanding them + #define Soc_MAX_SHARERS_FAVERS_SHOWN 7 // Maximum number of users shown who have share/fav a social note #define Soc_MAX_CHARS_IN_POST 1000 @@ -191,7 +192,11 @@ static void Soc_PutIconCommentDisabled (void); static void Soc_PutHiddenFormToWriteNewCommentToSocialNote (long NotCod, const char IdNewComment[Frm_MAX_BYTES_ID + 1]); static unsigned long Soc_GetNumCommentsInSocialNote (long NotCod); -static void Soc_WriteCommentsInSocialNote (const struct SocialNote *SocNot); +static void Soc_WriteCommentsInSocialNote (const struct SocialNote *SocNot, + bool ShowNoteAlone); +static void Soc_WriteOneSocialCommentInList (MYSQL_RES *mysql_res); +static void Soc_PutIconToToggleComments (const char *UniqueId, + const char *Icon,const char *Text); static void Soc_WriteSocialComment (struct SocialComment *SocCom, Soc_TopMessage_t TopMessage,long UsrCod, bool ShowCommentAlone); @@ -969,8 +974,6 @@ static void Soc_ShowTimeline (char *Query, Query); /***** Start box *****/ - // Box_StartBox (Soc_WIDTH_TIMELINE,Title,Soc_PutIconsTimeline, - // Hlp_SOCIAL_Timeline,Box_NOT_CLOSABLE); Box_StartBox (NULL,Title,Soc_PutIconsTimeline, Hlp_SOCIAL_Timeline,Box_NOT_CLOSABLE); @@ -1667,7 +1670,7 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot, /* Show comments */ if (NumComments) - Soc_WriteCommentsInSocialNote (SocNot); + Soc_WriteCommentsInSocialNote (SocNot,ShowNoteAlone); /* End of bottom right */ fprintf (Gbl.F.Out,""); @@ -2592,17 +2595,20 @@ static unsigned long Soc_GetNumCommentsInSocialNote (long NotCod) } /*****************************************************************************/ -/******************* Form to comment a social publishing *********************/ +/********************* Write comments in a social note ***********************/ /*****************************************************************************/ // All forms in this function and nested functions must have unique identifiers -static void Soc_WriteCommentsInSocialNote (const struct SocialNote *SocNot) +static void Soc_WriteCommentsInSocialNote (const struct SocialNote *SocNot, + bool ShowNoteAlone) { + extern const char *Txt_See_more; + extern const char *Txt_See_less; MYSQL_RES *mysql_res; - MYSQL_ROW row; unsigned long NumComments; + unsigned long NumCommentsInitiallyVisible; unsigned long NumCom; - struct SocialComment SocCom; + char IdComments[Frm_MAX_BYTES_ID + 1]; /***** Get comments of this social note from database *****/ NumComments = DB_QuerySELECT (&mysql_res,"can not get social comments", @@ -2625,38 +2631,92 @@ static void Soc_WriteCommentsInSocialNote (const struct SocialNote *SocNot) /***** List comments *****/ if (NumComments) // Comments to this social note found { - /***** Start list *****/ + /***** First list with comments initially visible *****/ + NumCommentsInitiallyVisible = (ShowNoteAlone || + NumComments < Soc_NUM_VISIBLE_COMMENTS) ? NumComments : + Soc_NUM_VISIBLE_COMMENTS; fprintf (Gbl.F.Out,""); + + if (NumComments > NumCommentsInitiallyVisible) + { + /***** Create unique id for new comment *****/ + Frm_SetUniqueId (IdComments); + + /***** Link to toggle on/off comments *****/ + fprintf (Gbl.F.Out,"
", + IdComments); + Soc_PutIconToToggleComments (IdComments,"angle-down.svg",Txt_See_more); + fprintf (Gbl.F.Out,"
"); + + fprintf (Gbl.F.Out,"
", // Initially hidden + IdComments); + Soc_PutIconToToggleComments (IdComments,"angle-up.svg",Txt_See_less); + fprintf (Gbl.F.Out,"
"); + + /***** Second list with comments initially hidden *****/ + fprintf (Gbl.F.Out,""); + } } /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); } +static void Soc_WriteOneSocialCommentInList (MYSQL_RES *mysql_res) + { + MYSQL_ROW row; + struct SocialComment SocCom; + + /***** Initialize image *****/ + Img_ImageConstructor (&SocCom.Image); + + /***** Get data of social comment *****/ + row = mysql_fetch_row (mysql_res); + Soc_GetDataOfSocialCommentFromRow (row,&SocCom); + + /***** Write social comment *****/ + Soc_WriteSocialComment (&SocCom, + Soc_TOP_MESSAGE_NONE,-1L, + false); + + /***** Free image *****/ + Img_ImageDestructor (&SocCom.Image); + } + +/*****************************************************************************/ +/******* Put an icon to toggle on/off comments in a social publishing ********/ +/*****************************************************************************/ + +static void Soc_PutIconToToggleComments (const char *UniqueId, + const char *Icon,const char *Text) + { + extern const char *The_ClassFormInBox[The_NUM_THEMES]; + + /***** Link to toggle on/off some fields of project *****/ + fprintf (Gbl.F.Out,"", + Text,The_ClassFormInBox[Gbl.Prefs.Theme], + UniqueId); + Ico_PutIconTextLink (Icon,Text); + fprintf (Gbl.F.Out,""); + } + /*****************************************************************************/ /**************************** Write social comment ***************************/ /*****************************************************************************/ @@ -2683,7 +2743,7 @@ static void Soc_WriteSocialComment (struct SocialComment *SocCom, if (ShowCommentAlone) { - Box_StartBox (Soc_WIDTH_TIMELINE,NULL,NULL, + Box_StartBox (NULL,NULL,NULL, NULL,Box_NOT_CLOSABLE); /***** Write sharer/commenter if distinct to author *****/ diff --git a/swad_theme.h b/swad_theme.h index 7b377940e..21077bb4a 100644 --- a/swad_theme.h +++ b/swad_theme.h @@ -47,7 +47,7 @@ typedef enum The_THEME_PINK = 5, The_THEME_UNKNOWN = 6, } The_Theme_t; -#define The_THEME_DEFAULT The_THEME_GREY +#define The_THEME_DEFAULT The_THEME_PINK /*****************************************************************************/ /***************************** Public prototypes *****************************/