Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old 2.1 (abandoned, see packages branch instead) #160

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
204113b
Resiable panels
moughxyz Oct 26, 2017
201429b
Functioning resizable panels
moughxyz Oct 26, 2017
c94d3ef
Fix panel overflow issue
moughxyz Oct 26, 2017
bd962a9
Default widths
moughxyz Oct 26, 2017
d0c2156
Remote user preferences, save panel widths
moughxyz Oct 27, 2017
dcc88f1
Singleton models
moughxyz Oct 27, 2017
2c99752
Editor panel wip
moughxyz Oct 27, 2017
5267759
Resizable editor
moughxyz Oct 28, 2017
addfd0d
Remove full screen option in favor of resizable panels
moughxyz Oct 28, 2017
9a6789a
Note panel display options
moughxyz Oct 28, 2017
854566b
Flex display on note column
moughxyz Oct 28, 2017
498614a
Search results count
moughxyz Oct 28, 2017
4e2c928
Monospace font option
moughxyz Oct 28, 2017
bfc606e
Panels collapsable flag
moughxyz Oct 28, 2017
26e1ff4
authManager -> userManager
moughxyz Oct 28, 2017
2a42275
Resize editor after switching
moughxyz Oct 28, 2017
74df48a
Editor singleton
moughxyz Oct 28, 2017
fcbf6e6
Extension save decrypted status, fix remote load issue
moughxyz Oct 29, 2017
ce6f82f
Ability to rename extensions
moughxyz Oct 29, 2017
594c666
Right to left language support
moughxyz Oct 29, 2017
e7cecd9
Incipient keyboard shortcuts
moughxyz Oct 29, 2017
8a2ae7f
Functioning keyboard shortcuts
moughxyz Oct 29, 2017
5f56942
Keyboard shortcuts from mapping json
moughxyz Oct 30, 2017
764135f
Typo
moughxyz Oct 30, 2017
0f3ece7
Editor panels recognize max width
moughxyz Oct 30, 2017
b9229f6
Prevent extension response from changing item name
moughxyz Oct 30, 2017
3585d40
Monospace font for Mac application
moughxyz Oct 30, 2017
b6493bd
Extension default value
moughxyz Oct 31, 2017
a3025c4
Reload font on system editor set
moughxyz Oct 31, 2017
45bba89
Extension style updates
moughxyz Oct 31, 2017
05daec7
Set proper items storage mode
moughxyz Nov 1, 2017
20ff6c5
Fix lock icon placement when offline
moughxyz Nov 1, 2017
c73cc80
Sync manager filter then slice, fix editor tags on blur, fix deleting…
moughxyz Nov 2, 2017
ce2a768
Fix issue with race condition when alternating UUIDs, removing locall…
moughxyz Nov 3, 2017
ea2553a
Comment regarding alternate uuids during sign in
moughxyz Nov 3, 2017
bd5c1ee
Skip data that might be corrupted
moughxyz Nov 4, 2017
06faa11
More explicit variable names and comments for synced items
moughxyz Nov 4, 2017
8a14ede
Resolve relationships for duplicate items, rename contentObject to co…
moughxyz Nov 4, 2017
f008c22
Rename removeAllRelationships -> removeAndDirtyAllRelationships to be…
moughxyz Nov 5, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gruntfile.js
Expand Up @@ -84,7 +84,8 @@ module.exports = function(grunt) {
src: [
'vendor/assets/bower_components/angular/angular.js',
'vendor/assets/javascripts/lodash/lodash.custom.min.js',
'vendor/assets/javascripts/crypto/*.js'
'vendor/assets/javascripts/crypto/*.js',
'vendor/assets/javascripts/mousetrap/mousetrap.min.js',
],
dest: 'vendor/assets/javascripts/lib.js',
},
Expand Down
4 changes: 4 additions & 0 deletions app/assets/javascripts/app/app.frontend.js
Expand Up @@ -36,3 +36,7 @@ function parametersFromURL(url) {
function isDesktopApplication() {
return window && window.process && window.process.type && window.process.versions["electron"];
}

function isMacApplication() {
return window && window.process && window.process.type && window.process.platform == "darwin";
}
155 changes: 135 additions & 20 deletions app/assets/javascripts/app/frontend/controllers/editor.js
Expand Up @@ -37,7 +37,100 @@ angular.module('app.frontend')
}
}
})
.controller('EditorCtrl', function ($sce, $timeout, authManager, $rootScope, extensionManager, syncManager, modelManager, editorManager, themeManager, componentManager, storageManager) {
.controller('EditorCtrl', function ($sce, $timeout, userManager, $rootScope, extensionManager, syncManager,
modelManager, editorManager, themeManager, componentManager, storageManager, keyboardManager) {

this.keyboardManager = keyboardManager;

keyboardManager.registerAction("delete-current-note", () => {
this.deleteNote();
})

keyboardManager.registerAction("toggle-note-archived", () => {
this.toggleArchiveNote();
})

keyboardManager.registerAction("toggle-note-pinned", () => {
this.togglePin();
})

keyboardManager.registerContextHandler("editor", (source, type) => {
if(type == 'begin') {
if(source == 'keyboard') {
// Focus note title
let titleInput = document.getElementById("note-title-editor");
if(titleInput) {
titleInput.focus();
}
}
}
})

this.resizeControl = {};

this.onPanelResizeFinish = function(width, left, isMaxWidth) {
if(isMaxWidth) {
userManager.userPreferences.setAppDataItem("editorWidth", null);
} else {
if(width !== undefined && width !== null) {
userManager.userPreferences.setAppDataItem("editorWidth", width);
}
}

if(left !== undefined && left !== null) {
userManager.userPreferences.setAppDataItem("editorLeft", left);
}
userManager.syncUserPreferences();
}

$rootScope.$on("user-preferences-changed", () => {
this.loadPreferences();
});

this.loadPreferences = function() {
this.monospaceFont = userManager.getUserPref("monospaceFont", "monospace");

if(!document.getElementById("editor-content")) {
// Elements have not yet loaded due to ng-if around wrapper
return;
}

this.reloadFont();

let width = userManager.getUserPref("editorWidth", null);
if(width !== null) {
this.resizeControl.setWidth(width);
}

let left = userManager.getUserPref("editorLeft", null);
if(left !== null) {
this.resizeControl.setLeft(left);
}
}

this.reloadFont = function() {
var editable = document.getElementById("note-text-editor");

if(!editable) {
return;
}
if(this.monospaceFont) {
if(isMacApplication()) {
editable.style.fontFamily = "Menlo, Consolas, 'DejaVu Sans Mono', monospace";
} else {
editable.style.fontFamily = "monospace";
}
} else {
editable.style.fontFamily = "inherit";
}
}

this.toggleKey = function(key) {
this[key] = !this[key];
userManager.userPreferences.setAppDataItem(key, this[key]);
userManager.syncUserPreferences();
this.reloadFont();
}

this.componentManager = componentManager;
this.componentStack = [];
Expand Down Expand Up @@ -165,10 +258,17 @@ angular.module('app.frontend')
this.showMenu = false;
this.loadTagsString();

let onReady = () => {
this.noteReady = true;
$timeout(() => {
this.loadPreferences();
})
}

var setEditor = function(editor) {
this.editor = editor;
this.postNoteToExternalEditor();
this.noteReady = true;
onReady();
}.bind(this)

var editor = this.editorForNote(note);
Expand All @@ -188,11 +288,10 @@ angular.module('app.frontend')
setEditor(editor);
}
} else {
this.editor = null;
this.noteReady = true;
this.editor = editorManager.systemEditor;
onReady();
}


if(note.safeText().length == 0 && note.dummy) {
this.focusTitle(100);
}
Expand All @@ -209,7 +308,7 @@ angular.module('app.frontend')
this.selectedEditor = function(editor) {
this.showEditorMenu = false;

if(this.editor && editor !== this.editor) {
if(this.editor && editor !== this.editor && !this.editor.systemEditor) {
this.editor.removeItemAsRelationship(this.note);
this.editor.setDirty(true);
}
Expand All @@ -220,6 +319,12 @@ angular.module('app.frontend')
syncManager.sync();

this.editor = editor;

if(editor.systemEditor) {
$timeout(() => {
this.reloadFont();
})
}
}.bind(this)

this.editorForNote = function(note) {
Expand Down Expand Up @@ -250,7 +355,7 @@ angular.module('app.frontend')
}

this.postNoteToExternalEditor = function() {
if(!this.editor) {
if(!this.editor || this.editor.systemEditor) {
return;
}

Expand Down Expand Up @@ -296,7 +401,7 @@ angular.module('app.frontend')
if(statusTimeout) $timeout.cancel(statusTimeout);
statusTimeout = $timeout(function(){
var status = "All changes saved";
if(authManager.offline()) {
if(userManager.offline()) {
status += " (offline)";
}
this.saveError = false;
Expand Down Expand Up @@ -344,29 +449,41 @@ angular.module('app.frontend')

this.onNameFocus = function() {
this.editingName = true;
keyboardManager.lockKeyboardContext();
}

this.onContentFocus = function() {
$rootScope.$broadcast("editorFocused");
this.onNameBlur = function() {
this.editingName = false;
keyboardManager.unlockKeyboardContext();
}

this.onNameBlur = function() {
this.onTagsFocus = function() {
this.editingName = true;
keyboardManager.lockKeyboardContext();
}

this.onTagsBlur = function() {
this.editingName = false;
keyboardManager.unlockKeyboardContext();
this.updateTagsFromTagsString()
}

this.toggleFullScreen = function() {
this.fullscreen = !this.fullscreen;
if(this.fullscreen) {
this.focusEditor(0);
}
this.onContentFocus = function() {
$rootScope.$broadcast("editorFocused");
keyboardManager.lockKeyboardContext();
}

this.onContentBlur = function() {
keyboardManager.unlockKeyboardContext();
}

this.selectedMenuItem = function($event) {
this.showMenu = false;
}

this.deleteNote = function() {
if(confirm("Are you sure you want to delete this note?")) {
let title = this.note.safeTitle().length ? `'${this.note.title}'` : "this note";
if(confirm(`Are you sure you want to delete ${title}?`)) {
this.remove()(this.note);
this.showMenu = false;
}
Expand Down Expand Up @@ -430,9 +547,7 @@ angular.module('app.frontend')
this.loadTagsString();
}

this.updateTagsFromTagsString = function($event) {
$event.target.blur();

this.updateTagsFromTagsString = function() {
var tags = this.tagsString.split("#");
tags = _.filter(tags, function(tag){
return tag.length > 0;
Expand Down
8 changes: 4 additions & 4 deletions app/assets/javascripts/app/frontend/controllers/footer.js
@@ -1,5 +1,5 @@
angular.module('app.frontend')
.directive("footer", function(authManager){
.directive("footer", function(userManager){
return {
restrict: 'E',
scope: {},
Expand All @@ -22,12 +22,12 @@ angular.module('app.frontend')
}
}
})
.controller('FooterCtrl', function ($rootScope, authManager, modelManager, $timeout, dbManager, syncManager, storageManager, passcodeManager) {
.controller('FooterCtrl', function ($rootScope, userManager, modelManager, $timeout, dbManager, syncManager, storageManager, passcodeManager) {

this.user = authManager.user;
this.user = userManager.user;

this.updateOfflineStatus = function() {
this.offline = authManager.offline();
this.offline = userManager.offline();
}
this.updateOfflineStatus();

Expand Down
19 changes: 11 additions & 8 deletions app/assets/javascripts/app/frontend/controllers/home.js
@@ -1,8 +1,12 @@
angular.module('app.frontend')
.controller('HomeCtrl', function ($scope, $location, $rootScope, $timeout, modelManager,
dbManager, syncManager, authManager, themeManager, passcodeManager, storageManager) {
dbManager, syncManager, userManager, themeManager, passcodeManager, storageManager) {

storageManager.initialize(passcodeManager.hasPasscode(), authManager.isEphemeralSession());
storageManager.initialize(passcodeManager.hasPasscode(), userManager.isEphemeralSession());

$rootScope.sync = function() {
syncManager.sync();
}

$scope.onUpdateAvailable = function(version) {
$rootScope.$broadcast('new-update-available', version);
Expand Down Expand Up @@ -49,13 +53,12 @@ angular.module('app.frontend')
}

function initiateSync() {
authManager.loadInitialData();
userManager.loadInitialData();
syncManager.loadLocalItems(function(items) {
$scope.allTag.didLoad = true;
themeManager.activateInitialTheme();
$scope.$apply();


syncManager.sync(null);
// refresh every 30s
setInterval(function () {
Expand Down Expand Up @@ -226,7 +229,7 @@ angular.module('app.frontend')
}

syncManager.sync(function(){
if(authManager.offline()) {
if(userManager.offline()) {
// when deleting items while ofline, we need to explictly tell angular to refresh UI
setTimeout(function () {
$scope.notifyDelete();
Expand All @@ -251,9 +254,9 @@ angular.module('app.frontend')
var email = urlParam("email");
var pw = urlParam("pw");

if(!authManager.offline()) {
if(!userManager.offline()) {
// check if current account
if(syncManager.serverURL === server && authManager.user.email === email) {
if(syncManager.serverURL === server && userManager.user.email === email) {
// already signed in, return
return;
} else {
Expand All @@ -263,7 +266,7 @@ angular.module('app.frontend')
})
}
} else {
authManager.login(server, email, pw, false, function(response){
userManager.login(server, email, pw, false, function(response){
window.location.reload();
})
}
Expand Down