From acf2a62e2e28ab3c5fce116d3a6b9f6013730cda Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Sun, 26 Sep 2021 19:48:38 +0330 Subject: [PATCH] #208 preparing UI for bookmarking --- GanjooRazor/Pages/Index.cshtml | 1 + GanjooRazor/Pages/_BNumPartial.cshtml | 7 +++--- GanjooRazor/Pages/_BNumPartial.cshtml.cs | 29 +++++++++++++++++++++++- GanjooRazor/wwwroot/js/bj.js | 5 ++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/GanjooRazor/Pages/Index.cshtml b/GanjooRazor/Pages/Index.cshtml index a0373144..c8e43f4f 100644 --- a/GanjooRazor/Pages/Index.cshtml +++ b/GanjooRazor/Pages/Index.cshtml @@ -19,6 +19,7 @@ + diff --git a/GanjooRazor/Pages/_BNumPartial.cshtml b/GanjooRazor/Pages/_BNumPartial.cshtml index 32cb534d..941cf4b0 100644 --- a/GanjooRazor/Pages/_BNumPartial.cshtml +++ b/GanjooRazor/Pages/_BNumPartial.cshtml @@ -12,9 +12,10 @@ @if (Model.LoggedIn) { -
- ویرایش از اینجا -
+
+ @Model.BookmarkingIcon + edit +
} diff --git a/GanjooRazor/Pages/_BNumPartial.cshtml.cs b/GanjooRazor/Pages/_BNumPartial.cshtml.cs index 30274686..45103055 100644 --- a/GanjooRazor/Pages/_BNumPartial.cshtml.cs +++ b/GanjooRazor/Pages/_BNumPartial.cshtml.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Mvc.RazorPages; using RMuseum.Models.Ganjoor.ViewModels; using System.Collections.Generic; @@ -21,6 +21,33 @@ namespace GanjooRazor.Pages /// public int CoupletIndex { get; set; } + /// + /// is bookmarked + /// + public bool IsBookmarked { get; set; } + + /// + /// bookmaring text + /// + public string BookmarkingText + { + get + { + return IsBookmarked ? "حذف نشانه" : "نشانه‌گذاری"; + } + } + + /// + /// bookmarking icon + /// + public string BookmarkingIcon + { + get + { + return IsBookmarked ? "star" : "star_border"; + } + } + /// /// comments /// diff --git a/GanjooRazor/wwwroot/js/bj.js b/GanjooRazor/wwwroot/js/bj.js index 6d9ffea8..717d4c74 100644 --- a/GanjooRazor/wwwroot/js/bj.js +++ b/GanjooRazor/wwwroot/js/bj.js @@ -399,4 +399,9 @@ function editCouplet(poemId, coupletIndex) { var vIndex = getVerseIndexFromCoupleIndex(coupletIndex); location.href = '/User/Editor?id=' + poemId + '#id-' + String(vIndex + 1); +} + +function switchBookmark(poemId, coupletIndex) { + var iconElementId = 'bookmark-icon-' + String(coupletIndex); + document.getElementById(iconElementId).innerHTML = (document.getElementById(iconElementId).innerHTML == 'star') ? 'star_border' : 'star'; } \ No newline at end of file