add functionality to buttons for no contacts
This commit is contained in:
parent
1f48ee36ef
commit
06f46129fc
@ -1006,6 +1006,49 @@ define([
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var noContactsMessage = function(common){
|
||||||
|
var metadataMgr = common.getMetadataMgr();
|
||||||
|
var data = metadataMgr.getUserData();
|
||||||
|
var origin = metadataMgr.getPrivateData().origin;
|
||||||
|
if (common.isLoggedIn()) {
|
||||||
|
return {
|
||||||
|
content: h('p', Messages.share_noContactsLoggedIn),
|
||||||
|
buttons: [{
|
||||||
|
className: 'secondary',
|
||||||
|
name: Messages.share_copyProfileLink,
|
||||||
|
onClick: function () {
|
||||||
|
var profile = data.profile ? (origin + '/profile/#' + data.profile) : '';
|
||||||
|
var success = Clipboard.copy(profile);
|
||||||
|
if (success) { UI.log(Messages.shareSuccess); }
|
||||||
|
},
|
||||||
|
keys: [13]
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
content: h('p', Messages.share_noContactsNotLoggedIn),
|
||||||
|
buttons: [{
|
||||||
|
className: 'secondary',
|
||||||
|
name: Messages.login_register,
|
||||||
|
onClick: function () {
|
||||||
|
common.setLoginRedirect(function () {
|
||||||
|
common.openURL('/login/');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
className: 'secondary',
|
||||||
|
name: Messages.login_login,
|
||||||
|
onClick: function () {
|
||||||
|
common.setLoginRedirect(function () {
|
||||||
|
common.openURL('/register/');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
UIElements.createShareModal = function (config) {
|
UIElements.createShareModal = function (config) {
|
||||||
var origin = config.origin;
|
var origin = config.origin;
|
||||||
var pathname = config.pathname;
|
var pathname = config.pathname;
|
||||||
@ -1126,41 +1169,8 @@ define([
|
|||||||
var hasFriends = Object.keys(config.friends || {}).length !== 0;
|
var hasFriends = Object.keys(config.friends || {}).length !== 0;
|
||||||
var onFriendShare = Util.mkEvent();
|
var onFriendShare = Util.mkEvent();
|
||||||
|
|
||||||
var noContactsMessage = function(){
|
|
||||||
if (common.isLoggedIn()) {
|
|
||||||
return {
|
|
||||||
content: h('p', Messages.share_noContactsLoggedIn),
|
|
||||||
buttons: [{
|
|
||||||
className: 'secondary',
|
|
||||||
name: Messages.share_copyProfileLink,
|
|
||||||
onClick: function () {
|
|
||||||
// XXX copy profile link
|
|
||||||
},
|
|
||||||
keys: [13]
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
content: h('p', Messages.share_noContactsNotLoggedIn),
|
|
||||||
buttons: [{
|
|
||||||
className: 'secondary',
|
|
||||||
name: Messages.login_register,
|
|
||||||
onClick: function () {
|
|
||||||
// XXX link to register
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
className: 'secondary',
|
|
||||||
name: Messages.login_login,
|
|
||||||
onClick: function () {
|
|
||||||
// XXX link to log in
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var friendsObject = hasFriends ? createShareWithFriends(config, onFriendShare, getLinkValue) : noContactsMessage();
|
var friendsObject = hasFriends ? createShareWithFriends(config, onFriendShare, getLinkValue) : noContactsMessage(common);
|
||||||
var friendsList = friendsObject.content;
|
var friendsList = friendsObject.content;
|
||||||
|
|
||||||
onFriendShare.reg(saveValue);
|
onFriendShare.reg(saveValue);
|
||||||
@ -1332,17 +1342,14 @@ define([
|
|||||||
// share with contacts tab
|
// share with contacts tab
|
||||||
var hasFriends = Object.keys(config.friends || {}).length !== 0;
|
var hasFriends = Object.keys(config.friends || {}).length !== 0;
|
||||||
|
|
||||||
var friendsObject = hasFriends ? createShareWithFriends(config, null, getLinkValue) : {
|
var friendsObject = hasFriends ? createShareWithFriends(config, null, getLinkValue) : noContactsMessage(common);
|
||||||
content: h('p', Messages.share_noContacts),
|
|
||||||
button: {}
|
|
||||||
};
|
|
||||||
var friendsList = friendsObject.content;
|
var friendsList = friendsObject.content;
|
||||||
|
|
||||||
var contactsContent = h('div.cp-share-modal');
|
var contactsContent = h('div.cp-share-modal');
|
||||||
$(contactsContent).append(friendsList);
|
$(contactsContent).append(friendsList);
|
||||||
|
|
||||||
var contactButtons = [makeCancelButton(),
|
var contactButtons = friendsObject.buttons;
|
||||||
friendsObject.button];
|
contactButtons.unshift(makeCancelButton());
|
||||||
|
|
||||||
var frameContacts = UI.dialog.customModal(contactsContent, {
|
var frameContacts = UI.dialog.customModal(contactsContent, {
|
||||||
buttons: contactButtons,
|
buttons: contactButtons,
|
||||||
|
|||||||
@ -484,6 +484,11 @@ define([
|
|||||||
Cryptpad.mailbox.execCommand(data, cb);
|
Cryptpad.mailbox.execCommand(data, cb);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
sframeChan.on('Q_SET_LOGIN_REDIRECT', function (data, cb) {
|
||||||
|
sessionStorage.redirectTo = window.location.href;
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
|
||||||
sframeChan.on('Q_STORE_IN_TEAM', function (data, cb) {
|
sframeChan.on('Q_STORE_IN_TEAM', function (data, cb) {
|
||||||
Cryptpad.storeInTeam(data, cb);
|
Cryptpad.storeInTeam(data, cb);
|
||||||
});
|
});
|
||||||
@ -634,11 +639,6 @@ define([
|
|||||||
Notifier.notify(data);
|
Notifier.notify(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
sframeChan.on('Q_SET_LOGIN_REDIRECT', function (data, cb) {
|
|
||||||
sessionStorage.redirectTo = window.location.href;
|
|
||||||
cb();
|
|
||||||
});
|
|
||||||
|
|
||||||
sframeChan.on('Q_MOVE_TO_TRASH', function (data, cb) {
|
sframeChan.on('Q_MOVE_TO_TRASH', function (data, cb) {
|
||||||
cb = cb || $.noop;
|
cb = cb || $.noop;
|
||||||
if (readOnly && hashes.editHash) {
|
if (readOnly && hashes.editHash) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user