forked from mbk-lab/rui_orig
Added SetTitle and SetTitleColor functions to the Session
This commit is contained in:
parent
2288487f75
commit
d9b33167be
|
@ -4233,6 +4233,10 @@ Safari и Firefox.
|
||||||
|
|
||||||
* RootView() View - возвращает корневой View сессии
|
* RootView() View - возвращает корневой View сессии
|
||||||
|
|
||||||
|
* SetTitle(title string) - устанавливает текст заголовка окна/закладки браузера.
|
||||||
|
|
||||||
|
* SetTitleColor(color Color) устанавливает цвет панели навигации браузера. Поддерживается только в Safari и Chrome для Android.
|
||||||
|
|
||||||
* Get(viewID, tag string) interface{} - возвращает значение свойства View с именем tag. Эквивалентно
|
* Get(viewID, tag string) interface{} - возвращает значение свойства View с именем tag. Эквивалентно
|
||||||
|
|
||||||
rui.Get(session.RootView(), viewID, tag)
|
rui.Get(session.RootView(), viewID, tag)
|
||||||
|
|
|
@ -4198,6 +4198,10 @@ Returns false if no topic with this name was found. Themes named "" are the defa
|
||||||
|
|
||||||
* RootView() View returns the root View of the session
|
* RootView() View returns the root View of the session
|
||||||
|
|
||||||
|
* SetTitle(title string) sets the text of the browser title/tab
|
||||||
|
|
||||||
|
* SetTitleColor(color Color) sets the color of the browser navigation bar. Supported only in Safari and Chrome for android
|
||||||
|
|
||||||
* Get(viewID, tag string) interface{} returns the value of the View property named tag. Equivalent to
|
* Get(viewID, tag string) interface{} returns the value of the View property named tag. Equivalent to
|
||||||
|
|
||||||
rui.Get(session.RootView(), viewID, tag)
|
rui.Get(session.RootView(), viewID, tag)
|
||||||
|
|
|
@ -1336,3 +1336,19 @@ function startDowndload(url, filename) {
|
||||||
element.click();
|
element.click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setTitleColor(color) {
|
||||||
|
var metas = document.getElementsByTagName('meta');
|
||||||
|
if (metas) {
|
||||||
|
var item = metas.namedItem('theme-color');
|
||||||
|
if (item) {
|
||||||
|
item.setAttribute('content', color)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var meta = document.createElement('meta');
|
||||||
|
meta.setAttribute('name', 'theme-color');
|
||||||
|
meta.setAttribute('content', color);
|
||||||
|
document.getElementsByTagName('head')[0].appendChild(meta);
|
||||||
|
}
|
|
@ -113,6 +113,9 @@ func (demo *demoSession) CreateRootView(session rui.Session) rui.View {
|
||||||
|
|
||||||
rui.Set(demo.rootView, "rootTitleButton", rui.ClickEvent, demo.clickMenuButton)
|
rui.Set(demo.rootView, "rootTitleButton", rui.ClickEvent, demo.clickMenuButton)
|
||||||
demo.showPage(0)
|
demo.showPage(0)
|
||||||
|
if color, ok := rui.StringToColor("#ffc0ded9"); ok {
|
||||||
|
session.SetTitleColor(color)
|
||||||
|
}
|
||||||
|
|
||||||
return demo.rootView
|
return demo.rootView
|
||||||
}
|
}
|
||||||
|
@ -147,6 +150,7 @@ func (demo *demoSession) showPage(index int) {
|
||||||
stackLayout.MoveToFront(demo.pages[index].view)
|
stackLayout.MoveToFront(demo.pages[index].view)
|
||||||
}
|
}
|
||||||
rui.Set(demo.rootView, "rootTitleText", rui.Text, demo.pages[index].title)
|
rui.Set(demo.rootView, "rootTitleText", rui.Text, demo.pages[index].title)
|
||||||
|
demo.rootView.Session().SetTitle(demo.pages[index].title)
|
||||||
}
|
}
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
17
session.go
17
session.go
|
@ -40,9 +40,15 @@ type Session interface {
|
||||||
// GetString returns the text for the current language
|
// GetString returns the text for the current language
|
||||||
GetString(tag string) (string, bool)
|
GetString(tag string) (string, bool)
|
||||||
|
|
||||||
|
// Content returns the SessionContent of session
|
||||||
Content() SessionContent
|
Content() SessionContent
|
||||||
setContent(content SessionContent, self Session) bool
|
setContent(content SessionContent, self Session) bool
|
||||||
|
|
||||||
|
// SetTitle sets the text of the browser title/tab
|
||||||
|
SetTitle(title string)
|
||||||
|
// SetTitleColor sets the color of the browser navigation bar. Supported only in Safari and Chrome for android
|
||||||
|
SetTitleColor(color Color)
|
||||||
|
|
||||||
// RootView returns the root view of the session
|
// RootView returns the root view of the session
|
||||||
RootView() View
|
RootView() View
|
||||||
// Get returns a value of the view (with id defined by the first argument) property with name defined by the second argument.
|
// Get returns a value of the view (with id defined by the first argument) property with name defined by the second argument.
|
||||||
|
@ -53,7 +59,9 @@ type Session interface {
|
||||||
// a description of the error is written to the log
|
// a description of the error is written to the log
|
||||||
Set(viewID, tag string, value interface{}) bool
|
Set(viewID, tag string, value interface{}) bool
|
||||||
|
|
||||||
|
// DownloadFile downloads (saves) on the client side the file located at the specified path on the server.
|
||||||
DownloadFile(path string)
|
DownloadFile(path string)
|
||||||
|
//DownloadFileData downloads (saves) on the client side a file with a specified name and specified content.
|
||||||
DownloadFileData(filename string, data []byte)
|
DownloadFileData(filename string, data []byte)
|
||||||
|
|
||||||
registerAnimation(props []AnimatedProperty) string
|
registerAnimation(props []AnimatedProperty) string
|
||||||
|
@ -406,3 +414,12 @@ func (session *sessionData) handleViewEvent(command string, data DataObject) {
|
||||||
ErrorLog(`"id" property not found. Event: ` + command)
|
ErrorLog(`"id" property not found. Event: ` + command)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (session *sessionData) SetTitle(title string) {
|
||||||
|
title, _ = session.GetString(title)
|
||||||
|
session.runScript(`document.title = "` + title + `";`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (session *sessionData) SetTitleColor(color Color) {
|
||||||
|
session.runScript(`setTitleColor("` + color.cssString() + `");`)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue