Browse Source

Improved notifications for Safari and Chrome

Tobias Reich 11 years ago
parent
commit
ea10c68631
3 changed files with 20 additions and 10 deletions
  1. 0 0
      assets/js/min/main.js
  2. 0 3
      assets/js/modules/init.js
  3. 20 7
      assets/js/modules/upload.js

File diff suppressed because it is too large
+ 0 - 0
assets/js/min/main.js


+ 0 - 3
assets/js/modules/init.js

@@ -8,9 +8,6 @@ $(document).ready(function(){
 
 	/* Event Name */
 	var event_name = (mobileBrowser()) ? "touchend" : "click";
-
-	/* Notifications */
-	if (window.webkitNotifications) window.webkitNotifications.requestPermission();
 	
 	/* Disable ContextMenu */
 	$(document).bind("contextmenu", function(e) { e.preventDefault() });

+ 20 - 7
assets/js/modules/upload.js

@@ -35,6 +35,21 @@ upload = {
 		$(".upload_message").append("<p>" + text + "</p>");
 
 	},
+	
+	notify: function(title) {
+	
+		var popup;
+		
+		if (!window.webkitNotifications) return false;
+		
+		if (window.webkitNotifications.checkPermission()!=0) window.webkitNotifications.requestPermission();
+	
+		if (window.webkitNotifications.checkPermission()==0) {
+			popup = window.webkitNotifications.createNotification("", title, "You can now manage your new photo(s).");
+			popup.show();
+		}
+	
+	},
 
 	start: {
 
@@ -49,7 +64,7 @@ upload = {
 
 			if (files.length<=0) return false;
 			if (albumID===false) albumID = 0;
-
+						
 			formData.append("function", "upload");
 			formData.append("albumID", albumID);
 
@@ -75,12 +90,7 @@ upload = {
 				if (xhr.status===200) {
 
 					upload.close();
-
-					// WebKit Notification
-					if (window.webkitNotifications&&BrowserDetect.browser==="Safari") {
-						popup = window.webkitNotifications.createNotification("", "Upload complete", "You can now manage your new photo.");
-						popup.show();
-					}
+					upload.notify("Upload complete");
 
 					window.onbeforeunload = null;
 
@@ -146,6 +156,7 @@ upload = {
 						lychee.api(params, function(data) {
 
 							upload.close();
+							upload.notify("Import complete");
 
 							if (album.getID()===false) lychee.goto("0");
 							else album.load(albumID);
@@ -181,6 +192,7 @@ upload = {
 					lychee.api(params, function(data) {
 
 						upload.close();
+						upload.notify("Import complete");
 
 						if (album.getID()===false) lychee.goto("0");
 						else album.load(albumID);
@@ -222,6 +234,7 @@ upload = {
 						lychee.api(params, function(data) {
 
 							upload.close();
+							upload.notify("Import complete");
 
 							if (album.getID()===false) lychee.goto("0");
 							else album.load(albumID);

Some files were not shown because too many files changed in this diff