Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
949b245b
Commit
949b245b
authored
Jun 08, 2016
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
новый файл
parent
2c9c560b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
174 additions
and
0 deletions
+174
-0
common/text_input.js
common/text_input.js
+174
-0
No files found.
common/text_input.js
0 → 100644
View file @
949b245b
"
use strict
"
;
(
function
(
window
,
undefined
)
{
var
c_oCompositionState
=
{
start
:
0
,
process
:
1
,
end
:
2
};
function
CTextInput
(
api
)
{
this
.
Api
=
api
;
this
.
compositionValue
=
[];
// коды символов
this
.
compositionState
=
c_oCompositionState
.
end
;
this
.
TargetId
=
null
;
// id caret
this
.
HtmlDiv
=
null
;
// для незаметной реализации одной textarea недостаточно
this
.
HtmlArea
=
null
;
this
.
HtmlAreaOffset
=
60
;
this
.
Listener
=
null
;
this
.
KeyDownFlag
=
false
;
}
CTextInput
.
prototype
=
{
init
:
function
(
target_id
)
{
this
.
TargetId
=
target_id
;
var
oHtmlTarget
=
document
.
getElementById
(
this
.
TargetId
);
var
oHtmlParent
=
oHtmlTarget
.
parentNode
;
this
.
HtmlDiv
=
document
.
createElement
(
"
div
"
);
this
.
HtmlDiv
.
style
.
background
=
"
transparent
"
;
this
.
HtmlDiv
.
style
.
border
=
"
none
"
;
this
.
HtmlDiv
.
style
.
position
=
"
absolute
"
;
this
.
HtmlDiv
.
style
.
zIndex
=
0
;
this
.
HtmlDiv
.
style
.
width
=
"
20px
"
;
this
.
HtmlDiv
.
style
.
height
=
"
50px
"
;
this
.
HtmlDiv
.
style
.
overflow
=
"
hidden
"
;
this
.
HtmlArea
=
document
.
createElement
(
"
textarea
"
);
this
.
HtmlArea
.
id
=
"
area_id
"
;
this
.
HtmlArea
.
style
.
background
=
"
transparent
"
;
this
.
HtmlArea
.
style
.
border
=
"
none
"
;
this
.
HtmlArea
.
style
.
position
=
"
absolute
"
;
this
.
HtmlArea
.
style
[
"
text-shadow
"
]
=
"
0 0 0 #000
"
;
this
.
HtmlArea
.
style
.
outline
=
"
none
"
;
this
.
HtmlArea
.
style
.
color
=
"
transparent
"
;
this
.
HtmlArea
.
style
.
width
=
"
1000px
"
;
this
.
HtmlArea
.
style
.
height
=
"
50px
"
;
this
.
HtmlArea
.
style
.
overflow
=
"
hidden
"
;
this
.
HtmlArea
.
style
.
left
=
"
0px;
"
;
this
.
HtmlArea
.
style
.
top
=
(
-
this
.
HtmlAreaOffset
)
+
"
px
"
;
this
.
HtmlArea
.
setAttribute
(
"
spellcheck
"
,
false
);
this
.
HtmlDiv
.
appendChild
(
this
.
HtmlArea
);
oHtmlParent
.
appendChild
(
this
.
HtmlDiv
);
// events:
var
oThis
=
this
;
this
.
HtmlArea
[
"
onkeydown
"
]
=
function
(
e
)
{
return
oThis
.
onKeyDown
(
e
);
};
this
.
HtmlArea
[
"
onkeypress
"
]
=
function
(
e
)
{
return
oThis
.
onKeyPress
(
e
);
};
this
.
HtmlArea
[
"
oninput
"
]
=
function
(
e
)
{
return
oThis
.
onInput
(
e
);
};
//this.HtmlArea["oncompositionstart"] = function(e) { return oThis.onCompositionStart(e); };
//this.HtmlArea["oncompositionupdate"] = function(e) { return oThis.onCompositionUpdate(e); };
//this.HtmlArea["oncompositionend"] = function(e) { return oThis.onCompositionEnd(e); };
this
.
HtmlArea
.
addEventListener
(
"
compositionstart
"
,
function
(
e
)
{
return
oThis
.
onCompositionStart
(
e
);
},
false
);
this
.
HtmlArea
.
addEventListener
(
"
compositionupdate
"
,
function
(
e
)
{
return
oThis
.
onCompositionUpdate
(
e
);
},
false
);
this
.
HtmlArea
.
addEventListener
(
"
compositionend
"
,
function
(
e
)
{
return
oThis
.
onCompositionEnd
(
e
);
},
false
);
this
.
Listener
=
this
.
Api
.
WordControl
.
m_oLogicDocument
;
// TODO:
setInterval
(
function
(){
oThis
.
HtmlArea
.
focus
();
},
10
);
},
move
:
function
()
{
var
oTarget
=
document
.
getElementById
(
this
.
TargetId
);
var
xPos
=
parseInt
(
oTarget
.
style
.
left
);
var
yPos
=
parseInt
(
oTarget
.
style
.
top
)
+
parseInt
(
oTarget
.
style
.
height
);
this
.
HtmlDiv
.
style
.
left
=
xPos
+
"
px
"
;
this
.
HtmlDiv
.
style
.
top
=
yPos
+
this
.
HtmlAreaOffset
+
"
px
"
;
// еще бы сдвинуться на высоту строки
},
clear
:
function
()
{
this
.
compositionValue
=
""
;
this
.
compositionState
=
c_oCompositionState
.
end
;
this
.
HtmlArea
.
value
=
""
;
},
onInput
:
function
(
e
)
{
// none
},
onKeyDown
:
function
(
e
)
{
return
this
.
Api
.
WordControl
.
onKeyDown
(
e
);
},
onKeyPress
:
function
(
e
)
{
if
(
c_oCompositionState
.
end
!=
this
.
compositionState
)
return
;
return
this
.
Api
.
WordControl
.
onKeyPress
(
e
);
},
onCompositionStart
:
function
(
e
)
{
if
(
!
this
.
Listener
)
this
.
Listener
=
this
.
Api
.
WordControl
.
m_oLogicDocument
;
this
.
compositionState
=
c_oCompositionState
.
start
;
this
.
Listener
.
Begin_CompositeInput
();
},
onCompositionUpdate
:
function
(
e
)
{
this
.
checkCompositionData
(
e
.
data
);
this
.
Listener
.
Replace_CompositeText
(
this
.
compositionValue
);
this
.
compositionState
=
c_oCompositionState
.
process
;
},
onCompositionEnd
:
function
(
e
)
{
this
.
clear
();
this
.
Listener
.
End_CompositeInput
();
},
checkCompositionData
:
function
(
data
)
{
this
.
compositionValue
=
[];
var
_length
=
data
.
length
;
for
(
var
i
=
0
;
i
<
_length
;
i
++
)
{
var
_code
=
data
.
charCodeAt
(
i
);
if
((
_code
<
0xD800
||
_code
>=
0xDC00
)
||
i
>=
(
_length
-
1
))
this
.
compositionValue
.
push
(
_code
);
else
{
i
++
;
var
_code2
=
data
.
charCodeAt
(
i
);
if
(
_code2
<
0xDC00
||
_code2
>=
0xDFFF
)
{
this
.
compositionValue
.
push
(
_code
);
this
.
compositionValue
.
push
(
_code2
);
}
else
{
this
.
compositionValue
.
push
(((
_code
&
0x3FF
)
<<
10
)
|
(
_code2
&
0x3FF
));
}
}
}
}
};
window
[
'
AscCommon
'
]
=
window
[
'
AscCommon
'
]
||
{};
window
[
'
AscCommon
'
].
CTextInput
=
CTextInput
;
})(
window
);
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