uicommon

package
v0.0.0-...-5167b14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

View Source
const (
	ERR_SECS = 15 // how long to leave error on screen
)

Variables

View Source
var (
	BlogEntry  = s5.NewCssClass("blog-entry")
	ColOffset1 = s5.NewCssClass("col-sm-offset-1")
	Col1       = s5.NewCssClass("col-sm-1")
	Col2       = s5.NewCssClass("col-sm-2")
	Col10      = s5.NewCssClass("col-sm-10")
	Col11      = s5.NewCssClass("col-sm-11")
	Col12      = s5.NewCssClass("col-sm-12")
	Col3       = s5.NewCssClass("col-sm-3")
	Col9       = s5.NewCssClass("col-sm-9")
	H3         = s5.NewCssClass("h3")
	BlogText   = s5.NewCssClass("blog-text")
	Btn        = s5.NewCssClass("btn")
	BtnTiny    = s5.NewCssClass("btn-xs")
	BtnPrimary = s5.NewCssClass("btn-primary")
	BtnDanger  = s5.NewCssClass("btn-danger")
	TopSpace   = s5.NewCssClass("top-space")
	LeftSpace  = s5.NewCssClass("left-space")
	Shaded     = s5.NewCssClass("shaded")
	Hide       = s5.NewCssClass("hide")
	H5         = s5.NewCssClass("h5")
	Row        = s5.NewCssClass("row")
	BgDanger   = s5.NewCssClass("bg-danger")
	BgWarn     = s5.NewCssClass("bg-warning")
	Active     = s5.NewCssClass("active")
	Disabled   = s5.NewCssClass("disabled")
	TextCenter = s5.NewCssClass("text-center")
)

useful vars that connect with boostrap and our page's CSS

Functions

func AttemptLogin

func AttemptLogin(std *StandardPage, user, password string)

Attempt login tries to login to the server with the credentials provided. If this fails, it displays its error message using the provided standard page.

func SetCurrentPage

func SetCurrentPage(s string)

SetCurrentPage causes the browser to switch to the page given by s. This can be an absolute path, like /foo/bar.html, or a relative one, like bar.html.

func SlideDown

func SlideDown(id s5.HtmlId)

SlideDown is a utility for causing a particular HTML element to gradually appear (jquery "slideDown").

func SlideUp

func SlideUp(id s5.HtmlId)

SlideDown is a utility for causing a particular HTML element to gradually disappear (jquery "slideUp").

Types

type EditPostPage

type EditPostPage struct {
	*StandardPage

	Title       s5.StringAttribute
	Content     s5.StringAttribute
	SetupFunc   func()
	SuccessFunc func()
	NetworkFunc func(*shared.Post) (chan interface{}, chan s5.AjaxError)
	// contains filtered or unexported fields
}

This is per page state. This is common between the "new post" and "edit post" functionality.

func NewEditPostPage

func NewEditPostPage(curr string, setup func(), success func(),
	network func(*shared.Post) (chan interface{}, chan s5.AjaxError)) *EditPostPage

NewEditPostPage creates new post or edit post page. Note that the three functions here provide a callback-style API for instantiators of this type. The setup func is called at the time the page is loaded, to allow the caller to start any network loads that are needed. The success func is called after a successful PUT or POST is completed. The network func allows the caller to control PUT or POST ajax calls. Other than these functions, the UI for new post and edit post are the same.

func (*EditPostPage) FormIsBad

func (self *EditPostPage) FormIsBad(raw []s5.Equaler) s5.Equaler

FormIsBad returns true if either the title or the textual content of the blog post is empty. This is used to insure you can't press the post or update button if you don't have any content to send.

func (*EditPostPage) Start

func (self *EditPostPage) Start()

called after the dom is ready

func (*EditPostPage) SubmitPost

func (self *EditPostPage) SubmitPost()

SubmitPost is used to actually send the content from this client to the server. It uses the NetworkFunc supplied at the creation of this EditPostPage to allow either POST or PUT to be used. If the server responds with success, it calls the SuccessFunc to know what action should be performed.

type StandardPage

type StandardPage struct {
	// contains filtered or unexported fields
}

StandardPage is the type shared by all the pages in the application. It's primarily responsible for displaying errors in a consistent way and for managing the contents of the navigation bar at the top of the page.

func NewStandardPage

func NewStandardPage(logoutTarget string, includeRightNav bool, userArrival func(*shared.UserRecord)) *StandardPage

NewStandardPage creates a new standard page in the app. This should not be called "standalone" but should be called as part of the initialization of of another type. The logout target provides the url to navigate to, should the user click logout. The includeRightNav option, if set, creates extra navigation elements in the far right for sign up, login, or, if the user is logged in, the current user's name and a log out button. The userArrival function, if supplied, is called when the results of attempting to log in the user are known. See #GetLoggedInUser.

func (*StandardPage) AddBlogNav

func (self *StandardPage) AddBlogNav(isActive bool)

func (*StandardPage) AddCurrentUserNav

func (self *StandardPage) AddCurrentUserNav()

func (*StandardPage) AddLeftNav

func (self *StandardPage) AddLeftNav(target string, text string, isActive bool)

func (*StandardPage) AddLogInNav

func (self *StandardPage) AddLogInNav()

func (*StandardPage) AddLogOutNav

func (self *StandardPage) AddLogOutNav()

func (*StandardPage) AddNewPostNav

func (self *StandardPage) AddNewPostNav(isActive bool)

func (*StandardPage) AddRightNav

func (self *StandardPage) AddRightNav(target string, text string)

func (*StandardPage) AddSignUpNav

func (self *StandardPage) AddSignUpNav()

func (*StandardPage) CurrentUser

func (self *StandardPage) CurrentUser() *shared.UserRecord

func (*StandardPage) DisplayErrorText

func (self *StandardPage) DisplayErrorText(text string, danger bool)

DisplayErrorText displays the text provided at the top of the screen for a configurable number of seconds (see ERR_SECS). If the danger value is true, the error displayed will have a red danger background, otherwise it is yellow (warning).

func (*StandardPage) GetLoggedInUser

func (self *StandardPage) GetLoggedInUser()

GetLoggedInUser should be called during the initialization of a page based on StandardPage. This call will contact the server and see if there is a current user. If there is and you supplied a userArrival function in #NewStandardPage, it will be called with the logged in users details. If there is no logged in user, the userArrival function is still called but with nil as the parameter.

func (*StandardPage) PerformLogOut

func (self *StandardPage) PerformLogOut()

PerformLogOut is called when the user clicks the logout button. Note that this may fail!

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL