Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
c8f7361e
Commit
c8f7361e
authored
Nov 01, 2017
by
Patrick O'Carroll
Committed by
Torkel Ödegaard
Nov 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
converted ng_model_on_blur.js to ts, deletedkeyboard_manager.js (#9676)
parent
624b75b5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
306 deletions
+20
-306
public/app/core/directives/ng_model_on_blur.ts
+20
-14
public/app/core/services/all.js
+0
-1
public/app/core/services/keyboard_manager.js
+0
-291
No files found.
public/app/core/directives/ng_model_on_blur.
j
s
→
public/app/core/directives/ng_model_on_blur.
t
s
View file @
c8f7361e
define
([
import
coreModule
from
'../core_module'
;
'../core_module'
,
import
rangeUtil
from
'app/core/utils/rangeutil'
;
'app/core/utils/rangeutil'
,
],
function
(
coreModule
,
rangeUtil
)
{
'use strict'
;
coreModule
.
default
.
directive
(
'ngModelOnblur'
,
function
()
{
export
class
NgModelOnBlur
{
constructor
()
{
return
{
return
{
restrict
:
'A'
,
restrict
:
'A'
,
priority
:
1
,
priority
:
1
,
...
@@ -23,22 +20,27 @@ function (coreModule, rangeUtil) {
...
@@ -23,22 +20,27 @@ function (coreModule, rangeUtil) {
});
});
}
}
};
};
});
}
}
coreModule
.
default
.
directive
(
'emptyToNull'
,
function
()
{
export
class
EmptyToNull
{
constructor
()
{
return
{
return
{
restrict
:
'A'
,
restrict
:
'A'
,
require
:
'ngModel'
,
require
:
'ngModel'
,
link
:
function
(
scope
,
elm
,
attrs
,
ctrl
)
{
link
:
function
(
scope
,
elm
,
attrs
,
ctrl
)
{
ctrl
.
$parsers
.
push
(
function
(
viewValue
)
{
ctrl
.
$parsers
.
push
(
function
(
viewValue
)
{
if
(
viewValue
===
""
)
{
return
null
;
}
if
(
viewValue
===
""
)
{
return
null
;
}
return
viewValue
;
return
viewValue
;
});
});
}
}
};
};
});
}
}
coreModule
.
default
.
directive
(
'validTimeSpan'
,
function
()
{
export
class
ValidTimeSpan
{
constructor
()
{
return
{
return
{
require
:
'ngModel'
,
require
:
'ngModel'
,
link
:
function
(
scope
,
elm
,
attrs
,
ctrl
)
{
link
:
function
(
scope
,
elm
,
attrs
,
ctrl
)
{
...
@@ -54,5 +56,9 @@ function (coreModule, rangeUtil) {
...
@@ -54,5 +56,9 @@ function (coreModule, rangeUtil) {
};
};
}
}
};
};
});
}
});
}
coreModule
.
directive
(
'ngModelOnblur'
,
NgModelOnBlur
);
coreModule
.
directive
(
'emptyToNull'
,
EmptyToNull
);
coreModule
.
directive
(
'validTimeSpan'
,
ValidTimeSpan
);
public/app/core/services/all.js
View file @
c8f7361e
...
@@ -3,7 +3,6 @@ define([
...
@@ -3,7 +3,6 @@ define([
'./util_srv'
,
'./util_srv'
,
'./context_srv'
,
'./context_srv'
,
'./timer'
,
'./timer'
,
'./keyboard_manager'
,
'./analytics'
,
'./analytics'
,
'./popover_srv'
,
'./popover_srv'
,
'./segment_srv'
,
'./segment_srv'
,
...
...
public/app/core/services/keyboard_manager.js
deleted
100644 → 0
View file @
624b75b5
define
([
'angular'
,
'lodash'
,
'../core_module'
,
],
function
(
angular
,
_
,
coreModule
)
{
'use strict'
;
// This service was based on OpenJS library available in BSD License
// http://www.openjs.com/scripts/events/keyboard_shortcuts/index.php
coreModule
.
default
.
factory
(
'keyboardManager'
,
[
'$window'
,
'$timeout'
,
function
(
$window
,
$timeout
)
{
var
keyboardManagerService
=
{};
var
defaultOpt
=
{
'type'
:
'keydown'
,
'propagate'
:
false
,
'inputDisabled'
:
false
,
'target'
:
$window
.
document
,
'keyCode'
:
false
};
// Store all keyboard combination shortcuts
keyboardManagerService
.
keyboardEvent
=
{};
// Add a new keyboard combination shortcut
keyboardManagerService
.
bind
=
function
(
label
,
callback
,
opt
)
{
var
fct
,
elt
,
code
,
k
;
// Initialize opt object
opt
=
angular
.
extend
({},
defaultOpt
,
opt
);
label
=
label
.
toLowerCase
();
elt
=
opt
.
target
;
if
(
typeof
opt
.
target
===
'string'
)
{
elt
=
document
.
getElementById
(
opt
.
target
);
}
fct
=
function
(
e
)
{
e
=
e
||
$window
.
event
;
// Disable event handler when focus input and textarea
if
(
opt
[
'inputDisabled'
])
{
var
elt
;
if
(
e
.
target
)
{
elt
=
e
.
target
;
}
else
if
(
e
.
srcElement
)
{
elt
=
e
.
srcElement
;
}
if
(
elt
.
nodeType
===
3
)
{
elt
=
elt
.
parentNode
;
}
if
(
elt
.
tagName
===
'INPUT'
||
elt
.
tagName
===
'TEXTAREA'
)
{
return
;
}
}
// Find out which key is pressed
if
(
e
.
keyCode
)
{
code
=
e
.
keyCode
;
}
else
if
(
e
.
which
)
{
code
=
e
.
which
;
}
var
character
=
String
.
fromCharCode
(
code
).
toLowerCase
();
if
(
code
===
188
)
{
character
=
","
;
// If the user presses , when the type is onkeydown
}
if
(
code
===
190
)
{
character
=
"."
;
// If the user presses , when the type is onkeydown
}
var
keys
=
label
.
split
(
"+"
);
// Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked
var
kp
=
0
;
// Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken
var
shift_nums
=
{
"`"
:
"~"
,
"1"
:
"!"
,
"2"
:
"@"
,
"3"
:
"#"
,
"4"
:
"$"
,
"5"
:
"%"
,
"6"
:
"^"
,
"7"
:
"&"
,
"8"
:
"*"
,
"9"
:
"("
,
"0"
:
")"
,
"-"
:
"_"
,
"="
:
"+"
,
";"
:
":"
,
"'"
:
"
\"
"
,
","
:
"<"
,
"."
:
">"
,
"/"
:
"?"
,
"»"
:
"?"
,
"«"
:
"?"
,
"¿"
:
"?"
,
"
\
\"
: "
|
"
};
// Special Keys - and their codes
var special_keys = {
'esc': 27,
'escape': 27,
'tab': 9,
'space': 32,
'return': 13,
'enter': 13,
'backspace': 8,
'scrolllock': 145,
'scroll_lock': 145,
'scroll': 145,
'capslock': 20,
'caps_lock': 20,
'caps': 20,
'numlock': 144,
'num_lock': 144,
'num': 144,
'pause': 19,
'break': 19,
'insert': 45,
'home': 36,
'delete': 46,
'end': 35,
'pageup': 33,
'page_up': 33,
'pu': 33,
'pagedown': 34,
'page_down': 34,
'pd': 34,
'left': 37,
'up': 38,
'right': 39,
'down': 40,
'f1': 112,
'f2': 113,
'f3': 114,
'f4': 115,
'f5': 116,
'f6': 117,
'f7': 118,
'f8': 119,
'f9': 120,
'f10': 121,
'f11': 122,
'f12': 123
};
// Some modifiers key
var modifiers = {
shift: {
wanted: false,
pressed: e.shiftKey ? true : false
},
ctrl : {
wanted: false,
pressed: e.ctrlKey ? true : false
},
alt : {
wanted: false,
pressed: e.altKey ? true : false
},
meta : { //Meta is Mac specific
wanted: false,
pressed: e.metaKey ? true : false
}
};
// Foreach keys in label (split on +)
for (var i = 0, l = keys.length; k = keys[i], i < l; i++) {
switch (k) {
case 'ctrl':
case 'control':
kp++;
modifiers.ctrl.wanted = true;
break;
case 'shift':
case 'alt':
case 'meta':
kp++;
modifiers[k].wanted = true;
break;
}
if (k.length > 1) { // If it is a special key
if (special_keys[k] === code) {
kp++;
}
} else if (opt['keyCode']) { // If a specific key is set into the config
if (opt['keyCode'] === code) {
kp++;
}
} else { // The special keys did not match
if (character === k) {
kp++;
}
else {
if (shift_nums[character] && e.shiftKey) { // Stupid Shift key bug created by using lowercase
character = shift_nums[character];
if (character === k) {
kp++;
}
}
}
}
}
if (kp === keys.length &&
modifiers.ctrl.pressed === modifiers.ctrl.wanted &&
modifiers.shift.pressed === modifiers.shift.wanted &&
modifiers.alt.pressed === modifiers.alt.wanted &&
modifiers.meta.pressed === modifiers.meta.wanted) {
$timeout(function() {
callback(e);
}, 1);
if (!opt['propagate']) { // Stop the event
// e.cancelBubble is supported by IE - this will kill the bubbling process.
e.cancelBubble = true;
e.returnValue = false;
// e.stopPropagation works in Firefox.
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
return false;
}
}
};
// Store shortcut
keyboardManagerService.keyboardEvent[label] = {
'callback': fct,
'target': elt,
'event': opt['type']
};
//Attach the function with the event
if (elt.addEventListener) {
elt.addEventListener(opt['type'], fct, false);
}
else if (elt.attachEvent) {
elt.attachEvent('on' + opt['type'], fct);
}
else {
elt['on' + opt['type']] = fct;
}
};
keyboardManagerService.unbindAll = function() {
_.each(keyboardManagerService.keyboardEvent, function(value, key) {
keyboardManagerService.unbind(key);
});
};
// Remove the shortcut - just specify the shortcut and I will remove the binding
keyboardManagerService.unbind = function (label) {
label = label.toLowerCase();
var binding = keyboardManagerService.keyboardEvent[label];
delete(keyboardManagerService.keyboardEvent[label]);
if (!binding) {
return;
}
var type = binding['event'],
elt = binding['target'],
callback = binding['callback'];
if (elt.detachEvent) {
elt.detachEvent('on' + type, callback);
}
else if (elt.removeEventListener) {
elt.removeEventListener(type, callback, false);
}
else {
elt['on' + type] = false;
}
};
//
return keyboardManagerService;
}]);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment