mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
add 'enter to save clipboard'
This commit is contained in:
@@ -17,26 +17,27 @@
|
|||||||
<!-- Dev!!-->
|
<!-- Dev!!-->
|
||||||
<button style="position:fixed;bottom:0;right:0;padding:5px;z-index:1000;" type="button" name="button" ng-click="toggleDev()">DEV!</button>
|
<button style="position:fixed;bottom:0;right:0;padding:5px;z-index:1000;" type="button" name="button" ng-click="toggleDev()">DEV!</button>
|
||||||
|
|
||||||
<div class="search-block">
|
<div ng-click="focusSearchInput()" class="search-block">
|
||||||
<input ng-change="filterList(searchNeedle)" search-input id="search-input" type="text" class="form-control" ng-model="searchNeedle" ng-change="refreshResult">
|
<input ng-change="filterList(searchNeedle)" search-input id="search-input" type="text" class="form-control" ng-model="searchNeedle" ng-change="refreshResult">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="result-block row-fluid">
|
<div class="result-block row-fluid">
|
||||||
<ul ng-click="focusList()" class="result-list" ng-class="{focused:isFocusing == 2}">
|
<ul ng-click="focusList()" class="result-list left-pane" ng-class="{focused:isFocusing == 2}">
|
||||||
<li ng-click="selectItem($index)" ng-repeat="snippet in filteredSnippets"><a ng-class="{selected:$index == selectIndex}" href="#">{{snippet.description}}</a></li>
|
<li ng-click="selectItem($index)" ng-repeat="snippet in filteredSnippets"><a ng-class="{selected:$index == selectIndex}" href="#">{{snippet.description}}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="result-detail" ng-class="{focused:isFocusing == 3}">
|
<div class="right-pane">
|
||||||
<div class="result-detail-control">
|
<div ng-click="focusControl()" class="result-detail-control">
|
||||||
<button type="button" name="button" class="btn btn-default"><i class="fa fa-clipboard"></i></button>
|
<button ng-class="{focus: controlIndex == 1}" id="btnClipboard" type="button" name="button" class="btn btn-default"><i class="fa fa-clipboard"></i></button>
|
||||||
<button type="button" name="button" class="btn btn-default"><i class="fa fa-edit"></i></button>
|
<button ng-class="{focus: controlIndex == 2}" id="btnEdit" type="button" name="button" class="btn btn-default"><i class="fa fa-edit"></i></button>
|
||||||
<button type="button" name="button" class="btn btn-default"><i class="fa fa-share"></i></button>
|
<button ng-class="{focus: controlIndex == 3}" id="btnShare" type="button" name="button" class="btn btn-default"><i class="fa fa-share"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="result-detail-cotent"
|
<div ng-click="focusContent()" id="aceView" class="result-detail-content"
|
||||||
ui-ace="{
|
ui-ace="{
|
||||||
showGutter: false,
|
showGutter: false,
|
||||||
useWrapMode: true,
|
useWrapMode: true,
|
||||||
mode:selectedItem.mode.toLowerCase()
|
mode:selectedItem.mode.toLowerCase(),
|
||||||
|
onLoad : aceLoaded
|
||||||
}"
|
}"
|
||||||
|
|
||||||
readonly
|
readonly
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
// document.getElementById('search-input').focus()
|
/* global angular */
|
||||||
|
|
||||||
var remote = require('remote')
|
var remote = require('remote')
|
||||||
var ipc = require('ipc')
|
var ipc = require('ipc')
|
||||||
|
var clipboard = require('clipboard')
|
||||||
|
|
||||||
var SEARCH_INPUT = 1
|
var SEARCH_INPUT = 1
|
||||||
var RESULT_LIST = 2
|
var RESULT_LIST = 2
|
||||||
var RESULT_DETAIL = 3
|
var RESULT_CONTROL = 3
|
||||||
|
var RESULT_CONTENT = 4
|
||||||
|
var btnClipboard = document.getElementById('btnClipboard')
|
||||||
|
var btnEdit = document.getElementById('btnEdit')
|
||||||
|
var btnShare = document.getElementById('btnShare')
|
||||||
|
var aceView = document.getElementById('aceView')
|
||||||
|
|
||||||
angular.module('codexen.popup', [
|
angular.module('codexen.popup', [
|
||||||
'ui.ace',
|
'ui.ace',
|
||||||
@@ -26,35 +32,99 @@ angular.module('codexen.popup', [
|
|||||||
|
|
||||||
hotkeys.bindTo($scope)
|
hotkeys.bindTo($scope)
|
||||||
.add('down', function (e) {
|
.add('down', function (e) {
|
||||||
if ($scope.isFocusing === RESULT_LIST) selectNextItem()
|
switch ($scope.isFocusing) {
|
||||||
|
case RESULT_LIST:
|
||||||
|
selectNextItem()
|
||||||
|
break
|
||||||
|
case RESULT_CONTROL:
|
||||||
|
focusContent()
|
||||||
|
break
|
||||||
|
}
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
.add('up', function (e) {
|
.add('up', function (e) {
|
||||||
if ($scope.isFocusing === RESULT_LIST) selectPriorItem()
|
switch ($scope.isFocusing) {
|
||||||
|
case RESULT_LIST:
|
||||||
|
selectPriorItem()
|
||||||
|
break
|
||||||
|
case RESULT_CONTENT:
|
||||||
|
focusControl()
|
||||||
|
break
|
||||||
|
}
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
.add('right', function (e) {
|
.add('right', function (e) {
|
||||||
if ($scope.isFocusing === RESULT_LIST) focusDetail()
|
if ($scope.isFocusing === RESULT_LIST) {
|
||||||
|
focusControl()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ($scope.isFocusing === RESULT_CONTROL) {
|
||||||
|
nextControl()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.add('left', function (e) {
|
.add('left', function (e) {
|
||||||
if ($scope.isFocusing === RESULT_DETAIL) focusList()
|
if ($scope.isFocusing === RESULT_CONTROL) {
|
||||||
|
priorControl()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.add('esc', function (e) {
|
.add('esc', function (e) {
|
||||||
switch ($scope.isFocusing) {
|
switch ($scope.isFocusing) {
|
||||||
case RESULT_LIST:
|
case RESULT_LIST:
|
||||||
focusSearchInput()
|
focusSearchInput()
|
||||||
break
|
break
|
||||||
case RESULT_DETAIL:
|
case RESULT_CONTROL:
|
||||||
focusList()
|
focusList()
|
||||||
break
|
break
|
||||||
|
case RESULT_CONTENT:
|
||||||
|
console.log('esc fr content')
|
||||||
|
focusControl()
|
||||||
|
break
|
||||||
case SEARCH_INPUT:
|
case SEARCH_INPUT:
|
||||||
hidePopUp()
|
hidePopUp()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.add('tab', function (e) {
|
.add('shift+tab', function (e) {
|
||||||
if ($scope.isFocusing === RESULT_LIST) focusDetail()
|
e.preventDefault()
|
||||||
|
if ($scope.isFocusing === RESULT_CONTROL) {
|
||||||
|
priorControl()
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
.add('tab', function (e) {
|
||||||
|
e.preventDefault()
|
||||||
|
if ($scope.isFocusing === RESULT_LIST) {
|
||||||
|
focusControl()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ($scope.isFocusing === RESULT_CONTROL) {
|
||||||
|
nextControl()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.add('enter', function (e) {
|
||||||
|
switch ($scope.isFocusing) {
|
||||||
|
case RESULT_LIST:
|
||||||
|
console.log($scope.selectedItem.content)
|
||||||
|
clipboard.writeText($scope.selectedItem.content)
|
||||||
|
hidePopUp()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
e.preventDefault()
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
$scope.aceLoaded = function (editor) {
|
||||||
|
editor.commands.addCommand({
|
||||||
|
name: 'escape',
|
||||||
|
bindKey: {win: 'esc', mac: 'esc'},
|
||||||
|
exec: function (editor) {
|
||||||
|
editor.blur()
|
||||||
|
focusControl()
|
||||||
|
$scope.$apply()
|
||||||
|
},
|
||||||
|
readOnly: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Init Data
|
// Init Data
|
||||||
$scope.snippets = []
|
$scope.snippets = []
|
||||||
@@ -63,62 +133,98 @@ angular.module('codexen.popup', [
|
|||||||
Snippet.findByUser(userId)
|
Snippet.findByUser(userId)
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
$scope.snippets = data.snippets
|
$scope.snippets = data.snippets
|
||||||
$scope.selectedItem = $scope.snippets[0]
|
|
||||||
filterList()
|
filterList()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
|
||||||
|
// Search Filter
|
||||||
function filterList (needle) {
|
function filterList (needle) {
|
||||||
$scope.filteredSnippets = $filter('filter')($scope.snippets, needle)
|
$scope.filteredSnippets = $filter('filter')($scope.snippets, needle)
|
||||||
|
$scope.selectIndex = 0
|
||||||
|
selectItem($scope.selectIndex)
|
||||||
}
|
}
|
||||||
$scope.filterList = filterList
|
$scope.filterList = filterList
|
||||||
|
|
||||||
$scope.isFocusing = 0
|
function hidePopUp () {
|
||||||
|
ipc.send('hidePopUp')
|
||||||
|
}
|
||||||
|
|
||||||
|
// Result Item control
|
||||||
$scope.selectIndex = 0
|
$scope.selectIndex = 0
|
||||||
|
|
||||||
$scope.selectItem = selectItem
|
$scope.selectItem = selectItem
|
||||||
function selectItem (index) {
|
function selectItem (index) {
|
||||||
$scope.selectIndex = index
|
$scope.selectIndex = index
|
||||||
$scope.selectedItem = $scope.filteredSnippets[index]
|
$scope.selectedItem = $scope.filteredSnippets[index]
|
||||||
|
|
||||||
|
$scope.controlIndex = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectNextItem () {
|
function selectNextItem () {
|
||||||
if ($scope.selectIndex >= ($scope.filteredSnippets.length -1)) {
|
if ($scope.selectIndex >= ($scope.filteredSnippets.length - 1)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
selectItem(++$scope.selectIndex)
|
selectItem(++$scope.selectIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectPriorItem () {
|
function selectPriorItem () {
|
||||||
if ($scope.selectIndex == 0) {
|
if ($scope.selectIndex === 0) {
|
||||||
focusSearchInput()
|
focusSearchInput()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
selectItem(--$scope.selectIndex)
|
selectItem(--$scope.selectIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Focusing control
|
||||||
|
$scope.isFocusing = 0
|
||||||
|
|
||||||
function focusSearchInput () {
|
function focusSearchInput () {
|
||||||
$scope.isFocusing = SEARCH_INPUT
|
$scope.isFocusing = SEARCH_INPUT
|
||||||
document.getElementById('search-input').focus()
|
document.getElementById('search-input').focus()
|
||||||
|
|
||||||
|
$scope.controlIndex = 0
|
||||||
}
|
}
|
||||||
|
$scope.focusSearchInput = focusSearchInput
|
||||||
|
|
||||||
function focusList () {
|
function focusList () {
|
||||||
$scope.isFocusing = RESULT_LIST
|
$scope.isFocusing = RESULT_LIST
|
||||||
document.getElementById('search-input').blur()
|
document.getElementById('search-input').blur()
|
||||||
|
|
||||||
|
$scope.controlIndex = 0
|
||||||
}
|
}
|
||||||
$scope.focusList = focusList
|
$scope.focusList = focusList
|
||||||
|
|
||||||
function focusDetail () {
|
function focusControl () {
|
||||||
$scope.isFocusing = RESULT_DETAIL
|
if ($scope.controlIndex === 0) {
|
||||||
}
|
$scope.controlIndex = 1
|
||||||
|
|
||||||
function hidePopUp () {
|
|
||||||
remote.getCurrentWindow().hide()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.directive('resultItem', function () {
|
|
||||||
return {
|
|
||||||
link: function (scope, el, attr) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$scope.isFocusing = RESULT_CONTROL
|
||||||
|
}
|
||||||
|
$scope.focusControl = focusControl
|
||||||
|
|
||||||
|
function focusContent () {
|
||||||
|
angular.element(aceView).scope().focus()
|
||||||
|
$scope.isFocusing = RESULT_CONTENT
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.controlIndex = 0
|
||||||
|
|
||||||
|
function nextControl () {
|
||||||
|
if ($scope.controlIndex === 3) {
|
||||||
|
$scope.controlIndex = 0
|
||||||
|
focusContent()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$scope.controlIndex ++
|
||||||
|
}
|
||||||
|
|
||||||
|
function priorControl () {
|
||||||
|
if ($scope.controlIndex === 1) {
|
||||||
|
focusList()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$scope.controlIndex --
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.directive('searchInput', function () {
|
.directive('searchInput', function () {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ $focused-shadow-color: $brand-primary;
|
|||||||
bottom: 0;
|
bottom: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
.result-list{
|
.left-pane{
|
||||||
margin: 0;
|
margin: 0;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -30,6 +30,9 @@ $focused-shadow-color: $brand-primary;
|
|||||||
width: 40%;
|
width: 40%;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
|
||||||
|
}
|
||||||
|
.result-list{
|
||||||
list-style:none;
|
list-style:none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
&.focused{
|
&.focused{
|
||||||
@@ -52,10 +55,7 @@ $focused-shadow-color: $brand-primary;
|
|||||||
}
|
}
|
||||||
border-right: 1px solid $border-color;
|
border-right: 1px solid $border-color;
|
||||||
}
|
}
|
||||||
.result-detail{
|
.right-pane{
|
||||||
&.focused{
|
|
||||||
border: solid 1px $brand-primary;
|
|
||||||
}
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 40%;
|
left: 40%;
|
||||||
top: 0;
|
top: 0;
|
||||||
@@ -63,12 +63,20 @@ $focused-shadow-color: $brand-primary;
|
|||||||
width: 60%;
|
width: 60%;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
.result-detail-cotent{
|
|
||||||
position: absolute;
|
}
|
||||||
top: 34px;
|
|
||||||
bottom: 0;
|
.result-detail-control{
|
||||||
width: 100%;
|
position: absolute;
|
||||||
}
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 34px;
|
||||||
|
}
|
||||||
|
.result-detail-content{
|
||||||
|
position: absolute;
|
||||||
|
top: 34px;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
5
main.js
5
main.js
@@ -12,7 +12,12 @@ app.on('window-all-closed', function () {
|
|||||||
if (process.platform !== 'darwin') app.quit()
|
if (process.platform !== 'darwin') app.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var Tray = require('tray')
|
||||||
|
var appIcon = null
|
||||||
|
|
||||||
app.on('ready', function () {
|
app.on('ready', function () {
|
||||||
|
appIcon = new Tray('./icon.png')
|
||||||
|
appIcon.setToolTip('This is my application.')
|
||||||
|
|
||||||
mainWindow = new BrowserWindow({width: 800, height: 600})
|
mainWindow = new BrowserWindow({width: 800, height: 600})
|
||||||
|
|
||||||
|
|||||||
@@ -332,6 +332,12 @@ angular.module('ui.ace', [])
|
|||||||
|
|
||||||
scope.Infinity = -1
|
scope.Infinity = -1
|
||||||
|
|
||||||
|
scope.focus = function () {
|
||||||
|
acee.focus()
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.addCommand = acee.commands.addCommand
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
Reference in New Issue
Block a user