Ejemplo n.º 1
0
        public MangaListItem(jQueryObject parent, MangaListItemJson data, int nextMangaId, Action loadFinishCallback)
        {
            attachedObject = Template.Get("client", "mangas-list-item", true).AppendTo(parent);
            jQuery.Select(".mangas-list-item-title", attachedObject).Text(data.title);
            jQuery.Select(".mangas-list-item-pages", attachedObject).Text(data.pages.ToString());
            coverLoaded = false;
            coverRequestDelay = 500;
            this.nextMangaId = nextMangaId;
            this.data = data;
            callback = loadFinishCallback;

            double size = data.size;
            string unit;
            if (size > 1000)
            {
                size /= 1024;

                if (size > 1000)
                {
                    size /= 1024;

                    if (size > 1000)
                    {
                        size /= 1024;
                        unit = Strings.Get("GigaBytes");
                    }
                    else
                    {
                        unit = Strings.Get("MegaBytes");
                    }
                }
                else
                {
                    unit = Strings.Get("KiloBytes");
                }
            }
            else
            {
                unit = Strings.Get("Bytes");
            }

            if (size < 10)
            {
                size = Math.Floor(size * 100) / 100;
            }
            else if (size < 100)
            {
                size = Math.Floor(size * 10) / 10;
            }
            else
            {
                size = Math.Floor(size);
            }

            jQuery.Select(".mangas-list-item-size", attachedObject).Text(size.ToString());
            jQuery.Select(".mangas-list-item-size-unit", attachedObject).Text(unit);
            jQuery.Select(".mangas-list-item-details-btn", attachedObject).AddClass("disabled").Click(DetailsButtonClicked);
            jQuery.Select(".mangas-list-item-thumbnail-link", attachedObject).Click(CoverClicked);

            if (!Settings.UseAnimation)
            {
                TryLoadFromCache();
                return;
            }

            attachedObject.AddClass("fade");
            Window.SetTimeout(
                delegate
                {
                    Utility.OnTransitionEnd(
                        attachedObject.AddClass("in"),
                        delegate
                        {
                            TryLoadFromCache();
                        });
                },
                1);
        }
Ejemplo n.º 2
0
 public MangaListItemJson ToMangaListItemJson()
 {
     MangaListItemJson obj = new MangaListItemJson();
     obj.id = Id;
     obj.title = Title;
     obj.pages = NumberOfPages;
     obj.size = Size;
     obj.date = ModifiedTime;
     return obj;
 }