Merge branch 'master' of https://github.com/tanerochris/iD into tanerochris-master

This commit is contained in:
Bryan Housel
2016-05-18 09:23:49 -04:00
2 changed files with 44 additions and 7 deletions
+2 -2
View File
@@ -482,7 +482,7 @@ button.save.has-count .count::before {
bottom: 0;
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-right: 6px solid rgba(255,255,255,.5);
border-right: 6px solid rgba(255,255,255,.9);
}
/* Icons */
@@ -3228,4 +3228,4 @@ div.full-screen > button:hover {
width: 100px;
background: rgba(0, 0, 0, 0) url(img/iD-sprite.svg) no-repeat -300px -460px;
margin: auto;
}
}
+42 -5
View File
@@ -1,6 +1,11 @@
iD.ui.Save = function(context) {
var history = context.history(),
key = iD.ui.cmd('⌘S');
key = iD.ui.cmd('⌘S'),
prevNumchange = 0 ,
color = 255 ,
saveBtnBackground = '';
function saving() {
return context.mode().id === 'save';
@@ -13,6 +18,35 @@ iD.ui.Save = function(context) {
}
}
function getBackground(numChanges) {
var step = parseInt(255 / 50);
var background = '';
if(numChanges < 50) {
prevNumchange = numChanges;
return 'rgba(255,255,255)';
}
else if(numChanges === 50) {
prevNumchange = numChanges;
return 'rgb(255 , 255 , 136)';
}
else if(numChanges > 50 && numChanges < 100) {
if(prevNumchange < numChanges) {
color = color - step;
background = 'rgb(255, ' + color + ' , 0)';
}
else if(prevNumchange > numChanges) {
color = color + step;
background = 'rgb(255 , '+ color + ' , 0)';
}
prevNumchange = numChanges;
return background;
}
else {
prevNumchange = numChanges;
return 'rgb(255 , 0 , 0 )';
}
}
return function(selection) {
var tooltip = bootstrap.tooltip()
.placement('bottom')
@@ -49,13 +83,16 @@ iD.ui.Save = function(context) {
tooltip.title(iD.ui.tooltipHtml(t(numChanges > 0 ?
'save.help' : 'save.no_changes'), key));
saveBtnBackground = getBackground(numChanges);
button
.classed('disabled', numChanges === 0)
.classed('has-count', numChanges > 0);
.classed('has-count', numChanges > 0)
.style('background' , saveBtnBackground);
button.select('span.count')
.text(numChanges);
.text(numChanges)
.style('background' , saveBtnBackground)
.style('opacity' , '0.5' );
});
context.on('enter.save', function() {