结合Article和Gallery

 

Article可能包括很多图片,有的时候,可能希望点击Article中的某个图片,能自动显示一个Gallery,集中显示所有图片:

 


自动实现

 

实现这个功能很简单,只需将Article的UserGallery属性设置为True即可,参考下面的HttpRequest事件代码:

 

Select Case e.Path
    Case
"test.htm"
        Dim wb As new
WeUI

        With wb.AddArticle("","ar1")

            .UseGallery = True
'
启用Gallery,必须放在第一行
            .AddTitle("h1",
"
大标题")
            .AddTitle("h2",
"
章标题")
            .AddTitle("h3",
"1.1
节标题")

            .AddContent("Write your Sad Times in Sand, Write your Good Times in Stone.-- George Bernard Shaw")
            .AddImage("./images/001.jpg")

            .AddTitle("h3",
"1.2
节标题")

            .AddContent("Write your Sad Times in Sand, Write your Good Times in Stone.-- George Bernard Shaw")
            .AddImage("./images/002.jpg")

            .AddTitle("h2",
"
章标题")
            .AddTitle("h3",
"2.1
节标题")

            .AddContent("Write your Sad Times in Sand, Write your Good Times in Stone.-- George Bernard Shaw")
            .AddImage("./images/003.jpg")

            .AddTitle("h3",
"2.2
节标题")

            .AddContent("Write your Sad Times in Sand, Write your Good Times in Stone.-- George Bernard Shaw")
            .AddImage("./images/004.jpg")

        End
With

        e.WriteString(wb.Build)

End
Select

 

手工实现


你也可以自己编码完成同样的任务,自己编码的好处是可以进行更多的控制,例如排除部分图片,或为提高网页打开速度,在Article显示低分辨率的图,在Gallery中显示高分辨率的原图。
你还可以用这个方法,将Gallery和其他元素组合使用。

 

HttpRequest事件代码:
 

Select Case e.Path
    Case
"test.htm"
        Dim wb As new
WeUI

        With wb.AddArticle("","ar1")

            .AddTitle("h1",
"
大标题")
            .AddTitle("h2",
"
章标题")
            .AddTitle("h3",
"1.1
节标题")

            .AddContent("Write your Sad Times in Sand, Write your Good Times in Stone.-- George Bernard Shaw")
            .AddImage("./images/001.jpg","onclick=""showGallery('gla1','./images/001.jpg')""")

            .AddTitle("h3",
"1.2
节标题")

            .AddContent("Write your Sad Times in Sand, Write your Good Times in Stone.-- George Bernard Shaw")
            .AddImage("./images/002.jpg","onclick=""showGallery('gla1','./images/002.jpg')""")

            .AddTitle("h2",
"
章标题")
            .AddTitle("h3",
"2.1
节标题")

            .AddContent("Write your Sad Times in Sand, Write your Good Times in Stone.-- George Bernard Shaw")
            .AddImage("./images/003.jpg","onclick=""showGallery('gla1','./images/003.jpg')""")

            .AddTitle("h3",
"2.2
节标题")

            .AddContent("Write your Sad Times in Sand, Write your Good Times in Stone.-- George Bernard Shaw")
            .AddImage("./images/004.jpg","onclick=""showGallery('gla1','./images/004.jpg')""")

        End
With
       
'
增加Gallery,第三个参数False表示初始隐藏,第四个参数True表示点击图片自动隐藏

        With wb.AddGallery("","gla1",False,True)
            .AddImage("./images/001.jpg","./images/002.jpg","./images/003.jpg","./images/004.jpg")

       
End With
        e.WriteString(wb.Build)
'生成网页
End
Select

 

showGallery

showGallery是在框架文件"weui.me.js"中定义的一个函数(注意JavaScript是区分大小写的),用于显示Gallery,语法为:


showGallery(ID, Image)

 

ID Gallery的ID
Image 要在Gallery中显示的图片,必须事先添加到Gallery中。


本页地址:http://www.foxtable.com/mobilehelp/topics/0088.htm