Fixed save as a project not showing overwrite confirmation, no background color
This commit is contained in:
parent
353aa1e410
commit
83a2b4d394
@ -14,6 +14,10 @@ $(document).ready(function() {
|
||||
url: href
|
||||
}
|
||||
})
|
||||
return false;
|
||||
}).click(function(e) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
})
|
||||
|
||||
$('a[href^="mailto"]').tap(function(e) {
|
||||
@ -25,6 +29,10 @@ $(document).ready(function() {
|
||||
url: $(this).attr('href')
|
||||
}
|
||||
})
|
||||
return false;
|
||||
}).click(function(e) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
})
|
||||
|
||||
window.save = function() {
|
||||
@ -51,7 +59,7 @@ $(document).ready(function() {
|
||||
var list = JSON.parse(localStorage.getItem('projects'));
|
||||
var index;
|
||||
if( list && list.some(function(a, i) { if( a.name == save['file name'] ) {index = i; return true} return false }) ) {
|
||||
if( confirm('A sketch with this name already exists. Do you want to overwrite ' + save['file name']) + '?' ) {
|
||||
if( confirm('A sketch with this name already exists. Do you want to overwrite ' + save['file name'] + '?') ) {
|
||||
console.log(index);
|
||||
list[index] = {
|
||||
name: save['file name'],
|
||||
@ -66,11 +74,13 @@ $(document).ready(function() {
|
||||
list ? list.push({
|
||||
name: save['file name'],
|
||||
data: data,
|
||||
points: window.points
|
||||
points: window.points,
|
||||
settings: settings
|
||||
}) : list = [{
|
||||
name: save['file name'],
|
||||
data: data,
|
||||
points: window.points
|
||||
points: window.points,
|
||||
settings: settings
|
||||
}];
|
||||
localStorage.setItem('projects', JSON.stringify(list));
|
||||
}
|
||||
@ -83,8 +93,6 @@ $(document).ready(function() {
|
||||
}
|
||||
req.onerror = function(e) {
|
||||
alert('Something bad happened trying to save your sketch ' + save['file name'] + '\n Possible reasons:\n Duplicate Name \n Not enough permission')
|
||||
console.log(e);
|
||||
console.log(this);
|
||||
}
|
||||
}
|
||||
c.putImageData(f, 0, 0);
|
||||
|
@ -28,7 +28,13 @@ $(document).ready(function() {
|
||||
$(this).attr('aria-selected', 'true');
|
||||
})
|
||||
$('#pro').on('click tap', function() {
|
||||
$('#save ol:nth-of-type(2)').addClass('hidden');
|
||||
$('#save ol:nth-of-type(2) li').each(function() {
|
||||
if( $(this).find('span').html() !== 'Current Color' ) {
|
||||
$(this).addClass('hidden');
|
||||
$(this).removeAttr('aria-selected');
|
||||
}
|
||||
else $(this).attr('aria-selected', 'true');
|
||||
})
|
||||
})
|
||||
$('#exp').on('click tap', function() {
|
||||
$('#save ol:nth-of-type(2)').removeClass('hidden');
|
||||
@ -36,7 +42,7 @@ $(document).ready(function() {
|
||||
})
|
||||
$('#pro').on('click tap', function() {
|
||||
$('#save ol:nth-of-type(2) li').each(function() {
|
||||
if( $(this).find('span').html() !== 'Transparent' ) {
|
||||
if( $(this).find('span').html() !== 'Current Color' ) {
|
||||
$(this).addClass('hidden');
|
||||
$(this).removeAttr('aria-selected');
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ $(document).ready(function() {
|
||||
var list = JSON.parse(localStorage.getItem('projects'));
|
||||
var index;
|
||||
if( list && list.some(function(a, i) { if( a.name == save['file name'] ) {index = i; return true} return false }) ) {
|
||||
if( confirm('A sketch with this name already exists. Do you want to overwrite ' + save['file name']) + '?' ) {
|
||||
if( confirm('A sketch with this name already exists. Do you want to overwrite ' + save['file name'] + '?') ) {
|
||||
console.log(index);
|
||||
list[index] = {
|
||||
name: save['file name'],
|
||||
@ -51,11 +51,13 @@ $(document).ready(function() {
|
||||
list ? list.push({
|
||||
name: save['file name'],
|
||||
data: data,
|
||||
points: window.points
|
||||
points: window.points,
|
||||
settings: settings
|
||||
}) : list = [{
|
||||
name: save['file name'],
|
||||
data: data,
|
||||
points: window.points
|
||||
points: window.points,
|
||||
settings: settings
|
||||
}];
|
||||
localStorage.setItem('projects', JSON.stringify(list));
|
||||
} else {
|
||||
|
@ -1 +1 @@
|
||||
$(document).ready(function(){$("*").off("click mousemove mousedown mouseup mouseleave").on("click mousemove mousedown mouseup mouseleave",function(a){a.preventDefault}),$('a[href^="http"]').tap(function(a){a.preventDefault();{var b=$(this).attr("href");new MozActivity({name:"view",data:{type:"url",url:b}})}}),$('a[href^="mailto"]').tap(function(a){a.preventDefault();new MozActivity({name:"new",data:{type:"mail",url:$(this).attr("href")}})}),window.save=function(){var a=c.getImageData(0,0,width(),height());switch(save.background){case"white":c.fillStyle="white",c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.fillStyle=settings.color,c.globalCompositeOperation=settings.composite;break;case"current color":c.fillStyle=settings.bg,c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.globalCompositeOperation=settings.composite}var b=$c[0].toDataURL();if("sketchy project"==save.type){var d,e=JSON.parse(localStorage.getItem("projects"));e&&e.some(function(a,b){return a.name==save["file name"]?(d=b,!0):!1})?(console.log(d),e[d]={name:save["file name"],data:b,points:window.points,settings:settings},localStorage.setItem("projects",JSON.stringify(e))):(e?e.push({name:save["file name"],data:b,points:window.points}):e=[{name:save["file name"],data:b,points:window.points}],localStorage.setItem("projects",JSON.stringify(e)))}else{var f=navigator.getDeviceStorage("pictures"),g=dataToBlob(b),h=f.addNamed(g,save["file name"]+".png");h.onsuccess=function(){alert("Your Sketch was saved successfuly: "+this.result)},h.onerror=function(a){alert("Something bad happened trying to save your sketch "+save["file name"]+"\n Possible reasons:\n Duplicate Name \n Not enough permission"),console.log(a),console.log(this)}}c.putImageData(a,0,0)},window.load=function(){var a=JSON.parse(localStorage.getItem("projects")).filter(function(a){return a.name==load.file})[0],b=document.createElement("img");b.src=a.data,b.onload=function(){c.clearRect(0,0,width(),height()),c.drawImage(b,0,0),window.points=a.points,window.points.history=[{data:c.createImageData($c.width(),$c.height()),points:[]},{data:c.getImageData(0,0,width(),height()),points:a.points}],$c.first().css("background",a.settings.bg),window.settings.bg=a.settings.bg}},localStorage.getItem("sawTips")!=settings.version&&($(".tour").removeClass("hidden"),localStorage.setItem("sawTips",settings.version))});
|
||||
$(document).ready(function(){$("*").off("click mousemove mousedown mouseup mouseleave").on("click mousemove mousedown mouseup mouseleave",function(a){a.preventDefault}),$('a[href^="http"]').tap(function(a){a.preventDefault();{var b=$(this).attr("href");new MozActivity({name:"view",data:{type:"url",url:b}})}return!1}).click(function(a){return a.preventDefault(),!1}),$('a[href^="mailto"]').tap(function(a){a.preventDefault();new MozActivity({name:"new",data:{type:"mail",url:$(this).attr("href")}});return!1}).click(function(a){return a.preventDefault(),!1}),window.save=function(){var a=c.getImageData(0,0,width(),height());switch(save.background){case"white":c.fillStyle="white",c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.fillStyle=settings.color,c.globalCompositeOperation=settings.composite;break;case"current color":c.fillStyle=settings.bg,c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.globalCompositeOperation=settings.composite}var b=$c[0].toDataURL();if("sketchy project"==save.type){var d,e=JSON.parse(localStorage.getItem("projects"));e&&e.some(function(a,b){return a.name==save["file name"]?(d=b,!0):!1})?confirm("A sketch with this name already exists. Do you want to overwrite "+save["file name"]+"?")&&(console.log(d),e[d]={name:save["file name"],data:b,points:window.points,settings:settings},localStorage.setItem("projects",JSON.stringify(e))):(e?e.push({name:save["file name"],data:b,points:window.points,settings:settings}):e=[{name:save["file name"],data:b,points:window.points,settings:settings}],localStorage.setItem("projects",JSON.stringify(e)))}else{var f=navigator.getDeviceStorage("pictures"),g=dataToBlob(b),h=f.addNamed(g,save["file name"]+".png");h.onsuccess=function(){alert("Your Sketch was saved successfuly: "+this.result)},h.onerror=function(){alert("Something bad happened trying to save your sketch "+save["file name"]+"\n Possible reasons:\n Duplicate Name \n Not enough permission")}}c.putImageData(a,0,0)},window.load=function(){var a=JSON.parse(localStorage.getItem("projects")).filter(function(a){return a.name==load.file})[0],b=document.createElement("img");b.src=a.data,b.onload=function(){c.clearRect(0,0,width(),height()),c.drawImage(b,0,0),window.points=a.points,window.points.history=[{data:c.createImageData($c.width(),$c.height()),points:[]},{data:c.getImageData(0,0,width(),height()),points:a.points}],$c.first().css("background",a.settings.bg),window.settings.bg=a.settings.bg}},localStorage.getItem("sawTips")!=settings.version&&($(".tour").removeClass("hidden"),localStorage.setItem("sawTips",settings.version))});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
"use strict";$(document).ready(function(){function a(){var b=c.getImageData(0,0,width(),height());switch(a.background){case"white":c.fillStyle="white",c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.fillStyle=settings.color,c.globalCompositeOperation=settings.composite;break;case"current color":c.fillStyle=settings.bg,c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.globalCompositeOperation=settings.composite}var d=$c[0].toDataURL();if("sketchy project"==a.type){var e,f=JSON.parse(localStorage.getItem("projects"));f&&f.some(function(b,c){return b.name==a["file name"]?(e=c,!0):!1})?(console.log(e),f[e]={name:a["file name"],data:d,points:window.points,settings:settings},localStorage.setItem("projects",JSON.stringify(f))):f?f.push({name:a["file name"],data:d,points:window.points}):f=[{name:a["file name"],data:d,points:window.points}],localStorage.setItem("projects",JSON.stringify(f))}else window.open(d,"_blank").focus();c.putImageData(b,0,0)}function b(){var a=JSON.parse(localStorage.getItem("projects")).filter(function(a){return a.name==b.file})[0],d=document.createElement("img");d.src=a.data,d.onload=function(){c.clearRect(0,0,width(),height()),c.drawImage(d,0,0),window.points=a.points,window.points.history=[{data:c.createImageData($c.width(),$c.height()),points:[]},{data:c.getImageData(0,0,width(),height()),points:a.points}],$c.first().css("background",a.settings.bg),window.settings.bg=a.settings.bg}}yepnope({test:window.mobile,yep:["js/mobile.js","js/libs/color-picker-touch.js"],nope:["js/libs/color-picker.js"]}),$(window).resize(sizeAndPos),window.load=b,window.save=a});
|
||||
"use strict";$(document).ready(function(){function a(){var b=c.getImageData(0,0,width(),height());switch(a.background){case"white":c.fillStyle="white",c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.fillStyle=settings.color,c.globalCompositeOperation=settings.composite;break;case"current color":c.fillStyle=settings.bg,c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.globalCompositeOperation=settings.composite}var d=$c[0].toDataURL();if("sketchy project"==a.type){var e,f=JSON.parse(localStorage.getItem("projects"));f&&f.some(function(b,c){return b.name==a["file name"]?(e=c,!0):!1})?confirm("A sketch with this name already exists. Do you want to overwrite "+a["file name"]+"?")&&(console.log(e),f[e]={name:a["file name"],data:d,points:window.points,settings:settings},localStorage.setItem("projects",JSON.stringify(f))):f?f.push({name:a["file name"],data:d,points:window.points,settings:settings}):f=[{name:a["file name"],data:d,points:window.points,settings:settings}],localStorage.setItem("projects",JSON.stringify(f))}else window.open(d,"_blank").focus();c.putImageData(b,0,0)}function b(){var a=JSON.parse(localStorage.getItem("projects")).filter(function(a){return a.name==b.file})[0],d=document.createElement("img");d.src=a.data,d.onload=function(){c.clearRect(0,0,width(),height()),c.drawImage(d,0,0),window.points=a.points,window.points.history=[{data:c.createImageData($c.width(),$c.height()),points:[]},{data:c.getImageData(0,0,width(),height()),points:a.points}],$c.first().css("background",a.settings.bg),window.settings.bg=a.settings.bg}}yepnope({test:window.mobile,yep:["js/mobile.js","js/libs/color-picker-touch.js"],nope:["js/libs/color-picker.js"]}),$(window).resize(sizeAndPos),window.load=b,window.save=a});
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user