public override void HandleRequest(string jsonString, AjaxBase ajax)
        {
            MangaListItemDetailsRequest request = Utility.ParseJson<MangaListItemDetailsRequest>(jsonString);
            Manga manga = Manga.GetById(request.id);

            if (manga == null || !manga.ParentCollection.Accessible(ajax))
            {
                ajax.BadRequest();
                return;
            }

            MangaListItemDetailsResponse response = new MangaListItemDetailsResponse();
            response.author = manga.Meta.Author;
            response.series = manga.Meta.Series;
            response.volume = manga.Meta.Volume;
            response.year = manga.Meta.Year;
            response.publisher = manga.Meta.Publisher;
            response.tags = manga.GetTags();
            ajax.ReturnJson(response);
        }
Esempio n. 2
0
        private void DetailsRequestSuccess(MangaListItemDetailsResponse response)
        {
            bool fadeIn = true;
            jQueryObject detailsDiv = Template.Get("client", "mangas-list-item-details", true).AppendTo(jQuery.Select(".caption", attachedObject));

            if (Settings.UseAnimation)
            {
                detailsDiv.AddClass("fade");
            }

            if (String.IsNullOrEmpty(response.author))
            {
                jQuery.Select(".mangas-list-item-details-author-p", detailsDiv).Remove();
            }
            else
            {
                jQuery.Select(".mangas-list-item-details-author", detailsDiv).Text(response.author);
            }

            if (String.IsNullOrEmpty(response.series))
            {
                jQuery.Select(".mangas-list-item-details-series-p", detailsDiv).Remove();
            }
            else
            {
                jQuery.Select(".mangas-list-item-details-series", detailsDiv).Text(response.series);
            }

            if (response.volume < 0)
            {
                jQuery.Select(".mangas-list-item-details-volume-p", detailsDiv).Remove();
            }
            else
            {
                jQuery.Select(".mangas-list-item-details-volume", detailsDiv).Text(response.volume.ToString());
            }

            if (response.year < 0)
            {
                jQuery.Select(".mangas-list-item-details-year-p", detailsDiv).Remove();
            }
            else
            {
                jQuery.Select(".mangas-list-item-details-year", detailsDiv).Text(response.year.ToString());
            }

            if (String.IsNullOrEmpty(response.publisher))
            {
                jQuery.Select(".mangas-list-item-details-publisher-p", detailsDiv).Remove();
            }
            else
            {
                jQuery.Select(".mangas-list-item-details-publisher", detailsDiv).Text(response.publisher);
            }

            if (response.tags == null || response.tags.Length == 0)
            {
                jQuery.Select(".mangas-list-item-details-tags-p", detailsDiv).Remove();
            }
            else
            {
                for (int i = 0; i < response.tags.Length; i++)
                {
                    string tag = response.tags[i];

                    Template.Get("client", "mangas-list-item-details-tag-link", true)
                        .AppendTo(jQuery.Select(".mangas-list-item-details-tags", detailsDiv))
                        .Text(tag)
                        .Attribute("data-tag", tag)
                        .Click(TagClicked);

                    if (i < response.tags.Length - 1)
                    {
                        jQuery.Select(".mangas-list-item-details-tags", detailsDiv).Append(", ");
                    }
                }
            }

            if (detailsDiv.Children().Length == 0)
            {
                detailsDiv.Remove();
                fadeIn = false;
            }

            if (!Settings.UseAnimation)
            {
                return;
            }

            Action removeFrameHeight = delegate
            {
                jQuery.Select(".mangas-list-item-frame", attachedObject).AddClass("height-transition-suppress").CSS("height", "");
                Window.SetTimeout(
                    delegate
                    {
                        jQuery.Select(".mangas-list-item-frame", attachedObject).RemoveClass("height-transition-suppress");
                    },
                    1);
            };

            Utility.OnTransitionEnd(
                jQuery.Select(".mangas-list-item-frame", attachedObject).RemoveClass("height-transition-suppress").Height(jQuery.Select(".mangas-list-item-inner", attachedObject).GetHeight()),
                delegate
                {
                    if (fadeIn)
                    {
                        Utility.OnTransitionEnd(detailsDiv.AddClass("in"), removeFrameHeight);
                    }
                    else
                    {
                        removeFrameHeight();
                    }
                });
        }