diff --git a/ghost/admin/app/controllers/settings/general.js b/ghost/admin/app/controllers/settings/general.js index f587f08ff6..7149b0a331 100644 --- a/ghost/admin/app/controllers/settings/general.js +++ b/ghost/admin/app/controllers/settings/general.js @@ -104,18 +104,24 @@ export default class GeneralController extends Controller { @action validateFacebookUrl() { let newUrl = this._scratchFacebook; + let oldUrl = this.get('settings.facebook'); let errMessage = ''; // reset errors and validation this.get('settings.errors').remove('facebook'); this.get('settings.hasValidated').removeObject('facebook'); - if (!newUrl) { + if (newUrl === '') { // Clear out the Facebook url - this.set('settings.facebook', null); + this.set('settings.facebook', ''); return; } + // _scratchFacebook will be null unless the user has input something + if (!newUrl) { + newUrl = oldUrl; + } + try { // strip any facebook URLs out newUrl = newUrl.replace(/(https?:\/\/)?(www\.)?facebook\.com/i, ''); @@ -153,18 +159,24 @@ export default class GeneralController extends Controller { @action validateTwitterUrl() { let newUrl = this._scratchTwitter; + let oldUrl = this.get('settings.twitter'); let errMessage = ''; // reset errors and validation this.get('settings.errors').remove('twitter'); this.get('settings.hasValidated').removeObject('twitter'); - if (!newUrl) { + if (newUrl === '') { // Clear out the Twitter url this.set('settings.twitter', ''); return; } + // _scratchTwitter will be null unless the user has input something + if (!newUrl) { + newUrl = oldUrl; + } + if (newUrl.match(/(?:twitter\.com\/)(\S+)/) || newUrl.match(/([a-z\d.]+)/i)) { let username = []; diff --git a/ghost/admin/app/controllers/settings/staff/user.js b/ghost/admin/app/controllers/settings/staff/user.js index bf2aed6d85..b2a94bba8e 100644 --- a/ghost/admin/app/controllers/settings/staff/user.js +++ b/ghost/admin/app/controllers/settings/staff/user.js @@ -87,18 +87,24 @@ export default Controller.extend({ actions: { validateFacebookUrl() { let newUrl = this._scratchFacebook; + let oldUrl = this.get('user.facebook'); let errMessage = ''; // reset errors and validation this.get('user.errors').remove('facebook'); this.get('user.hasValidated').removeObject('facebook'); - if (!newUrl) { + if (newUrl === '') { // Clear out the Facebook url this.set('user.facebook', ''); return; } + // _scratchFacebook will be null unless the user has input something + if (!newUrl) { + newUrl = oldUrl; + } + try { // strip any facebook URLs out newUrl = newUrl.replace(/(https?:\/\/)?(www\.)?facebook\.com/i, ''); @@ -137,18 +143,24 @@ export default Controller.extend({ validateTwitterUrl() { let newUrl = this._scratchTwitter; + let oldUrl = this.get('user.twitter'); let errMessage = ''; // reset errors and validation this.get('user.errors').remove('twitter'); this.get('user.hasValidated').removeObject('twitter'); - if (!newUrl) { + if (newUrl === '') { // Clear out the Twitter url - this.set('user.twitter', null); + this.set('user.twitter', ''); return; } + // _scratchTwitter will be null unless the user has input something + if (!newUrl) { + newUrl = oldUrl; + } + if (newUrl.match(/(?:twitter\.com\/)(\S+)/) || newUrl.match(/([a-z\d.]+)/i)) { let username = []; @@ -381,18 +393,6 @@ export default Controller.extend({ } }).group('saveHandlers'), - saveViaKeyboard: action(function (event) { - event.preventDefault(); - event.stopImmediatePropagation(); - - // trigger a blur and wait for any resulting validation actions to complete - document.activeElement.blur(); - - run.schedule('actions', () => { - this.save.perform(); - }); - }), - copyContentKey: task(function* () { copyTextToClipboard(this.personalToken); yield timeout(this.isTesting ? 50 : 3000);