This repository has been archived by the owner on Oct 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from blockchain/de-coffee
De coffee
- Loading branch information
Showing
17 changed files
with
185 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
|
||
angular | ||
.module('walletApp') | ||
.directive('contextualMessage', contextualMessage); | ||
|
||
contextualMessage.$inject = ['$cookies', '$window', 'Wallet', 'SecurityCenter', 'filterFilter']; | ||
|
||
function contextualMessage($cookies, $window, Wallet, SecurityCenter, filterFilter) { | ||
const directive = { | ||
restrict: 'E', | ||
replace: true, | ||
templateUrl: 'templates/contextual-message.jade', | ||
link: link | ||
}; | ||
return directive; | ||
|
||
function link(scope, elem, attrs) { | ||
scope.presets = ['SECURE_WALLET_MSG_1', 'SECURE_WALLET_MSG_2']; | ||
scope.msgCookie = $cookies.getObject('contextual-message'); | ||
scope.reveal = false; | ||
|
||
scope.nextWeek = () => new Date(Date.now() + 604800000).getTime(); | ||
|
||
scope.showMessage = (index) => { | ||
scope.messageIndex = index; | ||
scope.message = scope.presets[index]; | ||
}; | ||
|
||
scope.dismissMessage = (nextIndex, time) => { | ||
time = time || scope.nextWeek(); | ||
scope.dismissed = true; | ||
scope.reveal = false; | ||
$cookies.putObject('contextual-message', { | ||
index: nextIndex, | ||
when: time | ||
}); | ||
}; | ||
|
||
scope.shouldShow = () => { | ||
let balance = Wallet.total(''); | ||
let security = SecurityCenter.security.score; | ||
let isTime = scope.msgCookie ? Date.now() > scope.msgCookie.when : true; | ||
return balance > 20000000 && security < 0.5 && isTime; | ||
}; | ||
|
||
scope.revealMsg = () => | ||
scope.reveal = true; | ||
|
||
let unwatch = scope.$watch('shouldShow()', function(show) { | ||
if (show) { | ||
unwatch(); | ||
let idx = scope.msgCookie ? scope.msgCookie.index : 0; | ||
scope.showMessage(idx); | ||
} | ||
}); | ||
|
||
// dynamically position beacon | ||
let n = elem.parent()[0]; | ||
let h = n.offsetHeight; | ||
let s = n.children[5]; | ||
let o = () => s.offsetTop; | ||
let w = () => $window.location.hash; | ||
|
||
let activeAddressCount = filterFilter(Wallet.legacyAddresses(), {archived: false}).length; | ||
elem.css('top', activeAddressCount > 0 ? 135 : 95); | ||
|
||
let a = (newVal) => { | ||
if (newVal.indexOf('transactions') !== -1) elem.css('top', o); | ||
}; | ||
|
||
scope.$watch(w, a); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
angular | ||
.module('walletApp') | ||
.directive('helperButton', helperButton); | ||
|
||
helperButton.$inject = ['$translate']; | ||
|
||
function helperButton($translate) { | ||
const directive = { | ||
restrict: "E", | ||
replace: true, | ||
scope: { | ||
content: '@', | ||
url: '@', | ||
placement: '@' | ||
}, | ||
templateUrl: "templates/helper-button.jade", | ||
link: link | ||
}; | ||
return directive; | ||
|
||
function link(scope, elem, attrs) { | ||
scope.isActive = false; | ||
scope.warning = attrs.warning != null; | ||
|
||
$translate(scope.content).then((translation) => { | ||
scope.content = translation; | ||
}); | ||
|
||
scope.helperText = { | ||
templateUrl: 'templates/helper-popover.jade', | ||
placement: scope.placement || 'right' | ||
}; | ||
|
||
scope.toggleActive = () => | ||
scope.isActive = !scope.isActive; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
angular | ||
.module('walletApp') | ||
.directive('ipWhitelistRestrict', ipWhitelistRestrict); | ||
|
||
ipWhitelistRestrict.$inject = ['$translate', 'Wallet']; | ||
|
||
function ipWhitelistRestrict($translate, Wallet) { | ||
const directive = { | ||
restrict: 'E', | ||
replace: true, | ||
scope: {}, | ||
templateUrl: 'templates/ip-whitelist-restrict.jade', | ||
link: link | ||
}; | ||
return directive; | ||
|
||
function link(scope, elem, attrs) { | ||
scope.settings = Wallet.settings; | ||
|
||
scope.enableIpWhitelistRestrict = () => | ||
Wallet.enableRestrictToWhiteListedIPs(); | ||
|
||
scope.disableIpWhitelistRestrict = () => | ||
Wallet.disableRestrictToWhiteListedIPs(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
angular | ||
.module('walletApp') | ||
.directive('isNotEqual', isNotEqual); | ||
|
||
isNotEqual.$inject = ['Wallet']; | ||
|
||
function isNotEqual(Wallet) { | ||
const directive = { | ||
restrict: 'A', | ||
require: 'ngModel', | ||
link: link | ||
}; | ||
return directive; | ||
|
||
function link(scope, elem, attrs, ctrl) { | ||
ctrl.$validators.isNotEqual = (modelValue, viewValue) => { | ||
return attrs.isNotEqual !== viewValue; | ||
}; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
angular | ||
.module('walletApp') | ||
.directive('isValid', isValid); | ||
|
||
function isValid() { | ||
const directive = { | ||
restrict: 'A', | ||
require: 'ngModel', | ||
link: link | ||
}; | ||
return directive; | ||
|
||
function link(scope, elem, attrs, ctrl) { | ||
ctrl.$viewChangeListeners.push(() => { | ||
ctrl.$setValidity('isValid', scope.$eval(attrs.isValid)); | ||
}); | ||
} | ||
} |
Oops, something went wrong.