diff --git a/OpenNote/.gitignore b/OpenNote/.gitignore index 75ce18e9..fe36ebf8 100644 --- a/OpenNote/.gitignore +++ b/OpenNote/.gitignore @@ -1,2 +1,3 @@ /bower_components /node_modules +/Service diff --git a/OpenNote/bower.json b/OpenNote/bower.json index ebbf8aa6..149688a5 100644 --- a/OpenNote/bower.json +++ b/OpenNote/bower.json @@ -8,12 +8,12 @@ "dependencies": { "jquery": "2.0.3", "bootstrap": "3.1.1", - "angular": "1.2.16", - "angular-route": "1.2.16", - "angular-resource": "1.2.16", - "angular-sanitize": "1.2.16", - "angular-animate": "1.2.16", - "angular-mocks": "1.2.16", + "angular": "1.2.21", + "angular-route": "1.2.21", + "angular-resource": "1.2.21", + "angular-sanitize": "1.2.21", + "angular-animate": "1.2.21", + "angular-mocks": "1.2.21", "ckeditor": "ckeditor/ckeditor-releases#full/4.4.x", "angular-ui-tree": "2.1.2", "alertify": "0.3.10", diff --git a/OpenNote/index.html b/OpenNote/index.html index 6d25a620..c2316703 100644 --- a/OpenNote/index.html +++ b/OpenNote/index.html @@ -3,6 +3,9 @@ + + + OpenNote @@ -42,13 +45,6 @@ - - - - - - - @@ -62,50 +58,19 @@ - - + + + + + + - + -
- -
+
-
-
+
diff --git a/OpenNote/openNote/animations/waveAnimation.js b/OpenNote/openNote/animations/waveAnimation.js deleted file mode 100644 index ad3313de..00000000 --- a/OpenNote/openNote/animations/waveAnimation.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Use to do a wave animation for folders and notes - */ -openNote.animation(".waveAnimation", function(config){ - return { - enter: function(element, done){ - element.fadeIn(config.fadeSpeedLong(), done); - }, - leave: function(element, done){ - element.fadeOut(config.fadeSpeedShort(),done); - } - } -}); \ No newline at end of file diff --git a/OpenNote/openNote/controllers/folderController.js b/OpenNote/openNote/controllers/folderController.js index ee3ffffd..811d1069 100644 --- a/OpenNote/openNote/controllers/folderController.js +++ b/OpenNote/openNote/controllers/folderController.js @@ -1,5 +1,11 @@ -openNote.controller("folderController", function($scope, $rootScope, $location, $routeParams, folderFactory, config) { +openNote.controller("folderController", function( $scope, + $rootScope, + $location, + $routeParams, + folderFactory, + config, + $timeout) { $rootScope.buttons = []; $scope.folderEditMode = false; $scope.currentFolder = new folderFactory(); @@ -54,12 +60,14 @@ openNote.controller("folderController", function($scope, $rootScope, $location, /** * Load folder contents */ - $scope.currentFolder.$get({id:$routeParams.id}).then(function(data){ - //Do they have anything to display? - if($scope.currentFolder.id==null && $scope.currentFolder.foldersInside.length==0){ - $scope.currentFolder.name=null;//resets title - alertify.alert("It looks like you dont have any folders. You can create one using the \"New Folder\" button in the top right of the page."); - } + $timeout(function(){ + $scope.currentFolder.$get({id:$routeParams.id}).then(function(data){ + //Do they have anything to display? + if($scope.currentFolder.id==null && $scope.currentFolder.foldersInside.length==0){ + $scope.currentFolder.name=null;//resets title + alertify.alert("It looks like you dont have any folders. You can create one using the \"New Folder\" button in the top right of the page."); + } + }); }); /** @@ -74,7 +82,7 @@ openNote.controller("folderController", function($scope, $rootScope, $location, * fade out all folders */ $scope.fadeOutFolders = function(callback){ - if($scope.currentFolder.foldersInside.length>0) + if($scope.currentFolder.foldersInside !=null && $scope.currentFolder.foldersInside.length>0) $(".folder").fadeOut(config.fadeSpeedShort(),function(){ $scope.$apply(function(){ callback(); diff --git a/OpenNote/openNote/controllers/listController.js b/OpenNote/openNote/controllers/listController.js index e8ed3863..1d001773 100644 --- a/OpenNote/openNote/controllers/listController.js +++ b/OpenNote/openNote/controllers/listController.js @@ -6,7 +6,11 @@ /** * Control */ -openNote.controller("listController", function($scope, $rootScope, folderFactory) { +openNote.controller("listController", function( $scope, + $rootScope, + folderFactory, + $timeout, + userService) { $scope.data = new folderFactory(); /** @@ -43,7 +47,11 @@ openNote.controller("listController", function($scope, $rootScope, folderFactory * Load list view */ $rootScope.$on("reloadListView", function(event, args) { - $scope.data.$get({levels:100, includeNotes: false}); + $scope.data.$get({levels:100, includeNotes: false}).then(function(result){ + $scope.treeBuffer = 0; + $scope.data=result; + increaseTreeBuffer(); + }); }); /** @@ -76,7 +84,6 @@ openNote.controller("listController", function($scope, $rootScope, folderFactory sourceFolder.__proto__=folderType.__proto__;//Cast this object as a resources - sourceFolder.parrentFolderID=destID; sourceFolder.$update().then(function(){//wait for a response //fire off an event to tell everyone we just modified a folder @@ -90,9 +97,24 @@ openNote.controller("listController", function($scope, $rootScope, folderFactory $rootScope.$emit("reloadListView", {}); //refresh either way //event.source.nodeScope.$$apply = false; //TODO if they cancel reset list instead of re pulling it - }); } } }; + + /** + * Render list slowly + */ + var increaseTreeBuffer = function(){ + if($scope.treeBuffer<=100) { + $scope.treeBuffer++; + $timeout(increaseTreeBuffer, 500); + } + else + $rootScope.$emit("listLoaded", {});//Tell the world we are done + } + + //Load the lists initially + if(userService.hasValidToken()) + $rootScope.$emit("reloadListView"); }); \ No newline at end of file diff --git a/OpenNote/openNote/controllers/loginController.js b/OpenNote/openNote/controllers/loginController.js index 98b6470d..86da21b5 100644 --- a/OpenNote/openNote/controllers/loginController.js +++ b/OpenNote/openNote/controllers/loginController.js @@ -92,7 +92,11 @@ openNote.controller("loginController", function($scope, $rootScope, userService, $scope.$apply(function(){ alertify.success("Credentials Accepted"); $rootScope.$emit("reloadListView", {}); //send and event to tell the list view to reload - $location.path("/folder/"); + + if($rootScope.entryURL==null)//send them to the page if they requested + $location.path("/folder/"); + else + $location.path($rootScope.entryURL) }); }); } diff --git a/OpenNote/openNote/controllers/noteController.js b/OpenNote/openNote/controllers/noteController.js index 18c12d90..64557d17 100644 --- a/OpenNote/openNote/controllers/noteController.js +++ b/OpenNote/openNote/controllers/noteController.js @@ -33,18 +33,7 @@ openNote.controller("noteController", function( $scope, $rootScope, $routeParams return { text: "Clear", action: function(){ - alertify.confirm("Are you sure you want to clear your changes?", - function(confirm) { - if(!confirm) - return; - - $(".notePartial").fadeOut(config.fadeSpeedShort(),function(){ - $scope.$apply(function(){ - $location.url("/folder/"+$scope.note.folderID); - }); - }); - } - ); + $scope.clear(); }, helpText: $rootScope.helpContent.clearButton }; @@ -63,6 +52,8 @@ openNote.controller("noteController", function( $scope, $rootScope, $routeParams CKEDITOR.replace("note", config); $rootScope.buttons=[]; + attachWindowUnload(); + //Add new buttons $rootScope.buttons.push(saveButton()); $rootScope.buttons.push(clearButton()); @@ -100,7 +91,6 @@ openNote.controller("noteController", function( $scope, $rootScope, $routeParams * Save a note */ $scope.save = function(){ - $scope.note.note = CKEDITOR.instances["note"].getData(); //Insert only logic @@ -109,6 +99,7 @@ openNote.controller("noteController", function( $scope, $rootScope, $routeParams $(".notePartial").fadeOut(config.fadeSpeedShort()); $scope.note.$save().then(function(){ + detachWindowUnload(); $location.url("/note/"+$scope.note.id) alertify.success("Note Saved"); //all done. close the notify dialog }); @@ -127,6 +118,7 @@ openNote.controller("noteController", function( $scope, $rootScope, $routeParams var folderID = $scope.note.folderID;//need to keep track of this because we are about to delete it $(".notePartial").fadeOut(config.fadeSpeedShort()); $scope.note.$remove({id: $scope.note.id}).then(function(){ + detachWindowUnload(); alertify.success("Note Deleted",5); //all done. close the notify dialog $location.url("/folder/"+folderID); }); @@ -134,10 +126,44 @@ openNote.controller("noteController", function( $scope, $rootScope, $routeParams ); } + /** + * Reset changes + */ + $scope.clear = function(){ + alertify.confirm("Are you sure you want to clear your changes?", + function(confirm) { + if(!confirm) + return; + + $(".notePartial").fadeOut(config.fadeSpeedShort(),function(){ + $scope.$apply(function(){ + detachWindowUnload(); + $location.url("/folder/"+$scope.note.folderID); + }); + }); + }); + }; + /** * Mark html as trusted */ $scope.trustHTML = function(html) { return $sce.trustAsHtml(html); } + + /** + * Attach window on-load listener + */ + var attachWindowUnload = function(){ + window.onbeforeunload = function() { + return "Are you sure you want to navigate away?";//Keep the page from closing + }; + } + + /** + * Remove window on-load listener + */ + var detachWindowUnload = function(){ + window.onbeforeunload = null; + } }); \ No newline at end of file diff --git a/OpenNote/openNote/controllers/searchController.js b/OpenNote/openNote/controllers/searchController.js index d97de7af..61f4e0fe 100644 --- a/OpenNote/openNote/controllers/searchController.js +++ b/OpenNote/openNote/controllers/searchController.js @@ -48,7 +48,7 @@ openNote.controller("searchController", function( $scope, * fade out all folders */ $scope.fadeOutFolders = function(callback){ - if($scope.currentFolder.foldersInside.length>0) + if($scope.currentFolder.foldersInside !=null && $scope.currentFolder.foldersInside.length>0) $(".folder").fadeOut(config.fadeSpeedShort(),function(){ $scope.$apply(function(){ callback(); diff --git a/OpenNote/openNote/directives/randomFadeInDirective.js b/OpenNote/openNote/directives/randomFadeInDirective.js index 261ed773..95063b1a 100644 --- a/OpenNote/openNote/directives/randomFadeInDirective.js +++ b/OpenNote/openNote/directives/randomFadeInDirective.js @@ -5,9 +5,7 @@ openNote.directive("randomFadeInDirective", function($timeout,config) { return { restrict: "C",//class link: function(scope, element, attrs) { - $timeout(function(){ - element.fadeIn(config.fadeSpeedLong()); - },500);//give everything time to load + element.hide().fadeIn(config.fadeSpeedLong()); } }; }); \ No newline at end of file diff --git a/OpenNote/openNote/openNote.config.js b/OpenNote/openNote/openNote.config.js index 201946db..fbeb5b4f 100644 --- a/OpenNote/openNote/openNote.config.js +++ b/OpenNote/openNote/openNote.config.js @@ -7,7 +7,7 @@ openNote.value("config", { * Get current version */ getVersion: function(){ - return "14.07.00"; + return "14.07.01"; }, /** @@ -21,7 +21,7 @@ openNote.value("config", { * http path to backend rest service */ servicePath: function(){ - return "//127.0.0.1/OpenNoteService-PHP/Service"; + return "./Service"; }, /** diff --git a/OpenNote/openNote/openNote.js b/OpenNote/openNote/openNote.js index bc0c5ea9..0e417668 100644 --- a/OpenNote/openNote/openNote.js +++ b/OpenNote/openNote/openNote.js @@ -4,60 +4,97 @@ */ //Module Declaration -var openNote = angular.module("openNote", ["ngRoute","ngResource", "ngSanitize", "ngAnimate", "ui.tree"]); +var openNote = angular.module("openNote", [ "ngRoute", + "ngResource", + "ngSanitize", + "ngAnimate", + "ui.tree"]); /** * Used to redirect users to login if their token has expired * Runs on every route */ -openNote.run(function ($rootScope, $location, userService, config, serverConfigService, $http){ +openNote.run(function ( $rootScope, + $location, + userService, + config, + serverConfigService, + $http){ $rootScope.$on("$routeChangeStart", function (event) { //server config values serverConfigService.getConfig().then(function(config){ - $rootScope.serverConfig=config; + if(!config) + alertify.error("Connection to service failed"); + else + $rootScope.serverConfig=config; }); //attach server config to root scope - /** - * Initial entry if not logged in - */ - if (!userService.hasValidToken()&&$location.path()!="/") { - event.preventDefault(); - $location.path("/"); - } - else{ + //Authentication and authorization enforcer + if (isLoggedInOrIsOnLoginScreen())//Initial entry if not logged in + forceLogin(event, $location.url()); + else//Initial entry after if logged in + if($location.path()!="/" && !$rootScope.showMenu && !$rootScope.showSideBar)//make sure we only fade in/run once + $rootScope.$emit("init"); + + }); + + /** + * Check to see if user is logged in or on the login screen + */ + var isLoggedInOrIsOnLoginScreen = function(){ + return !userService.hasValidToken()&&$location.path()!="/"; + } + + /** + * Force user to login + * @param event - the event this was called + * @param url - the url the user tried to get + */ + var forceLogin = function(event, url){ + if(event!=null) + event.preventDefault(); + + $rootScope.entryURL=url; + $location.path("/"); + } + + /** + * Initialize app and start fade in + */ + $rootScope.$on("init",function(){ + userService.useAPITokenHeader();//use token + + $rootScope.showMenu=true; + $rootScope.showSideBar=true; + + //options for humans + $rootScope.helpContent=config.getHelpContent(); + + $rootScope.showHelpButton = config.showHelpButton(); + $rootScope.showLogOutButton = config.showLogOutButton(); + /** - * Initial entry after if logged in + * Log out function */ - if($location.path()!="/" && !$rootScope.showMenu && !$rootScope.showSideBar){//make sure we only fade in/run once - userService.useAPITokenHeader();//use token - $rootScope.$emit("reloadListView", {}); //send and event to tell the list view to reload - $rootScope.showMenu=true; - $rootScope.showSideBar=true; - - //options for humans - $rootScope.helpContent=config.getHelpContent(); - - $rootScope.showHelpButton = config.showHelpButton(); - $rootScope.showLogOutButton = config.showLogOutButton(); - - /** - * Log out function - */ - $rootScope.logOut = function(){ - sessionStorage.apiToken=null; - window.location.href='#/'; - $rootScope.showMenu=false; - $rootScope.showSideBar=false; - } - - //Check for updates - $http.get(config.getUpdateURL()).then( - function(response){//Successful - if(response.data.version!=config.getVersion()) - alertify.log(""+response.data.updateText+"", "", 0); - } - ); - } - } + $rootScope.logOut = function(){ + $rootScope.$emit("logOut"); + }; + + //Check for updates + $http.get(config.getUpdateURL()).then( + function(response){//Successful + if(response.data.version!=config.getVersion()) + alertify.log(""+response.data.updateText+"", "", 0); + }); }); + + /** + * Handle logOut event + */ + $rootScope.$on("logOut",function(){ + userService.destroyTokenHeader(); + window.location.href='#/'; + $rootScope.showMenu=false; + $rootScope.showSideBar=false; + }) }); \ No newline at end of file diff --git a/OpenNote/openNote/partials/folderPartial.html b/OpenNote/openNote/partials/folderPartial.html index bb7b7abc..0213e20d 100644 --- a/OpenNote/openNote/partials/folderPartial.html +++ b/OpenNote/openNote/partials/folderPartial.html @@ -7,7 +7,7 @@ -
+

{{folder.name}}

@@ -17,7 +17,7 @@

-
+

{{note.title}}

diff --git a/OpenNote/openNote/partials/listPartial.html b/OpenNote/openNote/partials/listPartial.html new file mode 100644 index 00000000..e4ff4528 --- /dev/null +++ b/OpenNote/openNote/partials/listPartial.html @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/OpenNote/openNote/partials/loginPartial.html b/OpenNote/openNote/partials/loginPartial.html index cd9688ee..0ae7951b 100644 --- a/OpenNote/openNote/partials/loginPartial.html +++ b/OpenNote/openNote/partials/loginPartial.html @@ -26,12 +26,12 @@

OpenNote

- + {{isAvailable}}

- +

diff --git a/OpenNote/openNote/partials/navBarPartial.html b/OpenNote/openNote/partials/navBarPartial.html new file mode 100644 index 00000000..fca30d65 --- /dev/null +++ b/OpenNote/openNote/partials/navBarPartial.html @@ -0,0 +1,23 @@ + + \ No newline at end of file diff --git a/OpenNote/openNote/partials/searchPartial.html b/OpenNote/openNote/partials/searchPartial.html index 350cc06f..a6012366 100644 --- a/OpenNote/openNote/partials/searchPartial.html +++ b/OpenNote/openNote/partials/searchPartial.html @@ -33,7 +33,7 @@
-
+

{{folder.name}}

@@ -43,7 +43,7 @@

-
+

{{note.title}}

diff --git a/OpenNote/openNote/partials/treePartial.html b/OpenNote/openNote/partials/treePartial.html index 44409af8..c2280774 100644 --- a/OpenNote/openNote/partials/treePartial.html +++ b/OpenNote/openNote/partials/treePartial.html @@ -3,5 +3,8 @@ {{folder.name}}
    -
  1. +
\ No newline at end of file diff --git a/OpenNote/openNote/services/userService.js b/OpenNote/openNote/services/userService.js index bf849437..0188cc44 100644 --- a/OpenNote/openNote/services/userService.js +++ b/OpenNote/openNote/services/userService.js @@ -16,7 +16,17 @@ openNote.service("userService", function ($http, $q, config) { this.useAPITokenHeader = function(){ $http.defaults.headers.common["token"] = this.getAPITokenString();//used by the resources implicitly - document.cookie="token="+this.getAPITokenString()+"; path=/"; //This is the download token, it is used for pulling files + document.cookie="token="+this.getAPITokenString()+"; path=/;"; //This is the download token, it is used for pulling files + } + + /** + * Stop using a token + */ + this.destroyTokenHeader = function(){ + $http.delete(config.servicePath() +"/token/");//have the server delete it + + delete sessionStorage.apiToken; + document.cookie = "token=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;"; } /** @@ -27,7 +37,7 @@ openNote.service("userService", function ($http, $q, config) { var tokenObject = this.getAPITokenObject(); if(tokenObject!=null){ var tokenTime = tokenObject.expires.replace(" ","T");//convert to ISO-8601 date and time - return new Date().getTime()< Date.parse(tokenTime); + return new Date().getTime()< Date.parse(tokenTime);//UTC time } return false; @@ -49,20 +59,20 @@ openNote.service("userService", function ($http, $q, config) { * @return - true if available, false if not */ this.isAvailable = function(userName){ - return $http.get(config.servicePath() +"/user/"+userName).then(function(responce){ - throw "Error"; // Weirdly if we get a 2xx value its a failure - },function(response){ - switch(response.status){ - case 302://we found it so its not available - return false; - - case 404://could not find it so its available - return true; - - default://there was a error - throw "Error"; - }; - }); + return $http.get(config.servicePath() +"/user/"+userName).then(function(response){ + throw "Error"; // Weirdly if we get a 2xx value its a failure + },function(response){ + switch(response.status){ + case 302://we found it so its not available + return false; + + case 404://could not find it so its available + return true; + + default://there was a error + throw "Error"; + }; + }); }; /** @@ -78,7 +88,7 @@ openNote.service("userService", function ($http, $q, config) { if(response.status==200){ if(response.data.token==null) - throw "Invalid responce from server"; + throw "Invalid response from server"; sessionStorage.apiToken=angular.toJson(response.data); self.useAPITokenHeader();//used by the resources implicitly @@ -103,7 +113,7 @@ openNote.service("userService", function ($http, $q, config) { if(response.status==200){ if(response.data.token==null) - throw "Invalid responce from server"; + throw "Invalid response from server"; sessionStorage.apiToken=angular.toJson(response.data); self.useAPITokenHeader();//used by the resources implicitly diff --git a/OpenNote/openNote/style/animations.css b/OpenNote/openNote/style/animations.css index 39345d5c..3d3c522e 100644 --- a/OpenNote/openNote/style/animations.css +++ b/OpenNote/openNote/style/animations.css @@ -3,8 +3,8 @@ .fadeIn.ng-hide-remove, .fadeIn.ng-enter, .fadeIn.ng-leave{ - transition:all linear 2s; - display: block !important; + transition:all 2s; + display: block; } .fadeIn.ng-hide-add.ng-hide-add-active, diff --git a/OpenNote/openNote/style/invert/alertify.less b/OpenNote/openNote/style/invert/alertify.less index 24215ec1..1ceeeec7 100644 --- a/OpenNote/openNote/style/invert/alertify.less +++ b/OpenNote/openNote/style/invert/alertify.less @@ -99,3 +99,20 @@ .alertify-log-success { color: negation(#CCC, @offset); } + +.alertify-cover { + transition: opacity 1s ease-out, width 0s; + background-color: negation(#555, @offset); + height: 100%; + position: fixed; + width: 100%; + top: 0; + opacity: 0.8; + right:0; +} + +.alertify-cover.alertify-cover-hidden{/*For animation*/ + display: block; + opacity: 0; + width:0; +} diff --git a/README.md b/README.md index 0e4ce475..9bedfecc 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Features - PDO Connector/(MySql and SQLite Database Support) - Move Folders(Drag into another folder in the list view.) - Rename/Delete Folders(Click on folder title to get menu.) +- Responsive Upcoming Features -----------------