From b92bb77b547010cd770e1f79b12811c7b9c43fb4 Mon Sep 17 00:00:00 2001 From: Fernando San Julián Date: Fri, 31 Jul 2015 22:12:33 +0200 Subject: autofocus for new and edit issue forms --- public/js/app.js | 1 + 1 file changed, 1 insertion(+) (limited to 'public/js/app.js') diff --git a/public/js/app.js b/public/js/app.js index 61539148..6208dbed 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -770,6 +770,7 @@ function initIssue() { $("#issue-edit-btn").on("click", function () { $('#issue h1.title,#issue .issue-main > .issue-content .content,#issue-edit-btn').toggleHide(); $('#issue-edit-title,.issue-edit-content,.issue-edit-cancel,.issue-edit-save').toggleShow(); + $('#issue-edit-content').focus(); }); $('.issue-edit-cancel').on("click", function () { $('#issue h1.title,#issue .issue-main > .issue-content .content,#issue-edit-btn').toggleShow(); -- cgit v1.2.3 From eebcbf9d3438a9910dee56fd76ab624726eb207c Mon Sep 17 00:00:00 2001 From: Fernando San Julián Date: Mon, 3 Aug 2015 21:27:15 +0200 Subject: add clipboard API support --- public/js/app.js | 78 ++++++++++++++++++++++++++++++++++------------------ public/ng/js/gogs.js | 68 +++++++++++++++++++++++++++++++-------------- 2 files changed, 100 insertions(+), 46 deletions(-) (limited to 'public/js/app.js') diff --git a/public/js/app.js b/public/js/app.js index 6208dbed..3dbf29c1 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -269,36 +269,62 @@ var Gogits = {}; if ($(selector).hasClass('js-copy-bind')) { return; } - $(selector).zclip({ - path: "/js/ZeroClipboard.swf", - copy: function () { - var t = $(this).data("copy-val"); - var to = $($(this).data("copy-from")); - var str = ""; - if (t == "txt") { - str = to.text(); - } - if (t == 'val') { - str = to.val(); - } - if (t == 'html') { - str = to.html(); - } - return str; - }, - afterCopy: function () { + + if ( document.documentElement.classList.contains("is-copy-enabled") ) { + + $(selector).click(function(event) { var $this = $(this); - $this.tooltip('hide') - .attr('data-original-title', 'Copied OK'); + + var cfrom = $this.attr('data-copy-from'); + $(cfrom).select(); + document.execCommand('copy'); + getSelection().removeAllRanges(); + + $this.tipsy("hide").attr('original-title', $this.data('after-title')); setTimeout(function () { - $this.tooltip("show"); + $this.tipsy("show"); }, 200); setTimeout(function () { - $this.tooltip('hide') - .attr('data-original-title', 'Copy to Clipboard'); - }, 3000); - } - }).addClass("js-copy-bind"); + $this.tipsy('hide').attr('original-title', $this.data('original-title')); + }, 2000); + + this.blur(); + return; + }); + + $(selector).addClass("js-copy-bind"); + + } else { + + $(selector).zclip({ + path: Gogs.AppSubUrl + "/js/ZeroClipboard.swf", + copy: function () { + var t = $(this).data("copy-val"); + var to = $($(this).data("copy-from")); + var str = ""; + if (t == "txt") { + str = to.text(); + } + if (t == 'val') { + str = to.val(); + } + if (t == 'html') { + str = to.html(); + } + return str; + }, + afterCopy: function () { + var $this = $(this); + $this.tipsy("hide").attr('original-title', $this.data('after-title')); + setTimeout(function () { + $this.tipsy("show"); + }, 200); + setTimeout(function () { + $this.tipsy('hide').attr('original-title', $this.data('original-title')); + }, 2000); + } + }).addClass("js-copy-bind"); + } } // api working diff --git a/public/ng/js/gogs.js b/public/ng/js/gogs.js index 7ffef8af..38b34c61 100644 --- a/public/ng/js/gogs.js +++ b/public/ng/js/gogs.js @@ -333,25 +333,17 @@ var Gogs = {}; if ($(selector).hasClass('js-copy-bind')) { return; } - $(selector).zclip({ - path: Gogs.AppSubUrl + "/js/ZeroClipboard.swf", - copy: function () { - var t = $(this).data("copy-val"); - var to = $($(this).data("copy-from")); - var str = ""; - if (t == "txt") { - str = to.text(); - } - if (t == 'val') { - str = to.val(); - } - if (t == 'html') { - str = to.html(); - } - return str; - }, - afterCopy: function () { + + if ( document.documentElement.classList.contains("is-copy-enabled") ) { + + $(selector).click(function(event) { var $this = $(this); + + var cfrom = $this.attr('data-copy-from'); + $(cfrom).select(); + document.execCommand('copy'); + getSelection().removeAllRanges(); + $this.tipsy("hide").attr('original-title', $this.data('after-title')); setTimeout(function () { $this.tipsy("show"); @@ -359,8 +351,44 @@ var Gogs = {}; setTimeout(function () { $this.tipsy('hide').attr('original-title', $this.data('original-title')); }, 2000); - } - }).addClass("js-copy-bind"); + + this.blur(); + return; + }); + + $(selector).addClass("js-copy-bind"); + + } else { + + $(selector).zclip({ + path: Gogs.AppSubUrl + "/js/ZeroClipboard.swf", + copy: function () { + var t = $(this).data("copy-val"); + var to = $($(this).data("copy-from")); + var str = ""; + if (t == "txt") { + str = to.text(); + } + if (t == 'val') { + str = to.val(); + } + if (t == 'html') { + str = to.html(); + } + return str; + }, + afterCopy: function () { + var $this = $(this); + $this.tipsy("hide").attr('original-title', $this.data('after-title')); + setTimeout(function () { + $this.tipsy("show"); + }, 200); + setTimeout(function () { + $this.tipsy('hide').attr('original-title', $this.data('original-title')); + }, 2000); + } + }).addClass("js-copy-bind"); + } } })(jQuery); -- cgit v1.2.3 From b9527cd1bfabcce3be62b43f0c199b1418519549 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 5 Aug 2015 17:36:22 +0800 Subject: #1299 force downcase e-mail --- models/user.go | 22 +++++++++++++++------- public/js/app.js | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'public/js/app.js') diff --git a/models/user.go b/models/user.go index c5d4b9d9..4b6517d7 100644 --- a/models/user.go +++ b/models/user.go @@ -258,6 +258,8 @@ func IsEmailUsed(email string) (bool, error) { if len(email) == 0 { return false, nil } + + email = strings.ToLower(email) if has, err := x.Get(&EmailAddress{Email: email}); has || err != nil { return has, err } @@ -405,6 +407,7 @@ func ChangeUserName(u *User, newUserName string) (err error) { // UpdateUser updates user's information. func UpdateUser(u *User) error { + u.Email = strings.ToLower(u.Email) has, err := x.Where("id!=?", u.Id).And("type=?", u.Type).And("email=?", u.Email).Get(new(User)) if err != nil { return err @@ -641,6 +644,7 @@ func GetEmailAddresses(uid int64) ([]*EmailAddress, error) { } func AddEmailAddress(email *EmailAddress) error { + email.Email = strings.ToLower(email.Email) used, err := IsEmailUsed(email.Email) if err != nil { return err @@ -674,7 +678,7 @@ func DeleteEmailAddress(email *EmailAddress) error { return ErrEmailNotExist } - if _, err = x.Delete(email); err != nil { + if _, err = x.Id(email.Id).Delete(email); err != nil { return err } @@ -736,13 +740,15 @@ func ValidateCommitWithEmail(c *git.Commit) *User { // ValidateCommitsWithEmails checks if authors' e-mails of commits are corresponding to users. func ValidateCommitsWithEmails(oldCommits *list.List) *list.List { - emails := map[string]*User{} - newCommits := list.New() - e := oldCommits.Front() + var ( + u *User + emails = map[string]*User{} + newCommits = list.New() + e = oldCommits.Front() + ) for e != nil { c := e.Value.(*git.Commit) - var u *User if v, ok := emails[c.Author.Email]; !ok { u, _ = GetUserByEmail(c.Author.Email) emails[c.Author.Email] = u @@ -764,8 +770,10 @@ func GetUserByEmail(email string) (*User, error) { if len(email) == 0 { return nil, ErrUserNotExist{0, "email"} } + + email = strings.ToLower(email) // First try to find the user by primary email - user := &User{Email: strings.ToLower(email)} + user := &User{Email: email} has, err := x.Get(user) if err != nil { return nil, err @@ -775,7 +783,7 @@ func GetUserByEmail(email string) (*User, error) { } // Otherwise, check in alternative list for activated email addresses - emailAddress := &EmailAddress{Email: strings.ToLower(email), IsActivated: true} + emailAddress := &EmailAddress{Email: email, IsActivated: true} has, err = x.Get(emailAddress) if err != nil { return nil, err diff --git a/public/js/app.js b/public/js/app.js index 3dbf29c1..8eb19a0a 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -297,7 +297,7 @@ var Gogits = {}; } else { $(selector).zclip({ - path: Gogs.AppSubUrl + "/js/ZeroClipboard.swf", + path: Gogits.AppSubUrl + "/js/ZeroClipboard.swf", copy: function () { var t = $(this).data("copy-val"); var to = $($(this).data("copy-from")); -- cgit v1.2.3