Skip to content

Commit

Permalink
mobile terminal features
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed May 31, 2015
1 parent bec69a6 commit 379d88f
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 11 deletions.
3 changes: 2 additions & 1 deletion plugins/core/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"fastclick": "~1.0.3",
"angular-sortable-view": "0.0.13",
"AngularJS-Toaster": "~0.4.9",
"angular-base64": "~2.0.4"
"angular-base64": "~2.0.4",
"mobile-detect": "*"
},
"resolutions": {
"angular": "~1.4.0"
Expand Down
3 changes: 2 additions & 1 deletion plugins/core/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: core
author: Ajenti project
email: e@ajenti.org
url: http://ajenti.org
version: '0.36'
version: '0.37'
title: Core
icon: link
dependencies: []
Expand All @@ -25,6 +25,7 @@ resources:
- 'resources/vendor/ngstorage/ngStorage.min.js'
- 'resources/vendor/fastclick/lib/fastclick.js'
- 'resources/vendor/angular-base64/angular-base64.js'
- 'resources/vendor/mobile-detect/mobile-detect.min.js'
- 'resources/css/bootstrap/bootstrap.less'
- 'resources/css/overrides.less'
- 'resources/css/animations.less'
Expand Down
Binary file modified plugins/core/resources/images/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ angular.module('core').service 'hotkeys', ($timeout, $window, $rootScope) ->
@ENTER = 13

handler = (e, mode) ->
isTextField = false
if not e.metaKey and not e.ctrlKey
if $('input:focus').length > 0 or $('textarea:focus').length > 0
return
isTextField = true
if e.which < 32
char = e.which
else
char = String.fromCharCode(e.which)
#console.log(char, e)
$rootScope.$broadcast mode, char, e
if not isTextField
$rootScope.$broadcast mode, char, e
$rootScope.$broadcast "#{mode}:global", char, e
$rootScope.$apply()
return
return

$timeout () ->
$(document).keydown (e) -> handler(e, 'keydown')
Expand Down
2 changes: 1 addition & 1 deletion plugins/filemanager/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: filemanager
author: Ajenti project
email: e@ajenti.org
url: http://ajenti.org
version: '0.13'
version: '0.14'
title: 'File Manager'
icon: folder-o
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion plugins/filemanager/resources/partial/properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
</div>
</div>

<dialog ng:show="permissionsDialogVisible">
<dialog ng:show="permissionsDialogVisible" ng:cloak>
<div class="modal-header">
<h4>Permission bits</h4>
</div>
Expand Down
2 changes: 1 addition & 1 deletion plugins/terminal/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: terminal
author: Ajenti project
email: e@ajenti.org
url: http://ajenti.org
version: '0.17'
version: '0.18'
title: 'Terminal'
icon: terminal
dependencies:
Expand Down
31 changes: 31 additions & 0 deletions plugins/terminal/resources/css/terminal.less
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,36 @@ terminal {
cursor: text;
}
}

.mobile-input-area {
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 100%;
display: block;
opacity: 0;
z-index: 5;
-webkit-user-modify: read-write-plaintext-only;
}

.extra-keyboard-toggle {
position: absolute;
bottom: 15px;
right: 15px;
z-index: 15;
}

.extra-keyboard {
position: absolute;
bottom: 15px;
left: 15px;
width: 100%;
z-index: 10;

.btn.active {
color: blue;
}
}
}

46 changes: 43 additions & 3 deletions plugins/terminal/resources/js/directives/terminal.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,45 @@ angular.module('ajenti.terminal').directive 'terminal', ($timeout, $log, $q, soc
ng:blur="pasteAreaFocused = false"
></textarea>
</div>
<textarea
class="mobile-input-area"
ng:if="isMobile"
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
></textarea>
<a class="extra-keyboard-toggle btn btn-default" ng:click="extraKeyboardVisible=!extraKeyboardVisible" ng:show="isMobile">
<i class="fa fa-keyboard-o"></i>
</a>
<div class="extra-keyboard" ng:show="extraKeyboardVisible">
<a class="btn btn-default" ng:click="extraKeyboardCtrl = true" ng:class="{active: extraKeyboardCtrl}">
Ctrl
</a>
<a class="btn btn-default" ng:click="fakeKeyEvent(38)">
<i class="fa fa-arrow-up"></i>
</a>
<a class="btn btn-default" ng:click="fakeKeyEvent(40)">
<i class="fa fa-arrow-down"></i>
</a>
<a class="btn btn-default" ng:click="fakeKeyEvent(37)">
<i class="fa fa-arrow-left"></i>
</a>
<a class="btn btn-default" ng:click="fakeKeyEvent(39)">
<i class="fa fa-arrow-right"></i>
</a>
</div>
</div>
'''
link: ($scope, element, attrs) ->
element.addClass('block-element')

$scope.isMobile = new MobileDetect(window.navigator.userAgent).mobile()
$scope.extraKeyboardVisible = false

$scope.charWidth = 7
$scope.charHeight = 14
$scope.canvas = element.find('canvas')[0]
Expand Down Expand Up @@ -233,7 +267,7 @@ angular.module('ajenti.terminal').directive 'terminal', ($timeout, $log, $q, soc

#$log.log event

if event_name == 'keypress' and event.charCode
if event_name == 'keypress' and (event.charCode or event.which)
ch = String.fromCharCode(event.which)
if ch == '\r'
ch = '\n'
Expand Down Expand Up @@ -300,6 +334,9 @@ angular.module('ajenti.terminal').directive 'terminal', ($timeout, $log, $q, soc
handler = (key, event, mode) ->
if $scope.pasteAreaFocused or $scope.disabled
return
if $scope.extraKeyboardCtrl
event.ctrlKey = true
$scope.extraKeyboardCtrl = false
ch = $scope.parseKey(event, mode)
if not ch
return false
Expand All @@ -308,11 +345,14 @@ angular.module('ajenti.terminal').directive 'terminal', ($timeout, $log, $q, soc

hotkeys.on $scope, (k, e) ->
return handler(k, e, 'keypress')
, 'keypress'
, 'keypress:global'

hotkeys.on $scope, (k, e) ->
return handler(k, e, 'keydown')
, 'keydown'
, 'keydown:global'

$scope.fakeKeyEvent = (code) ->
handler(null, {keyCode: code}, 'keydown')

$scope.$watch 'pasteData', () ->
if $scope.pasteData
Expand Down

0 comments on commit 379d88f

Please sign in to comment.