Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mui
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mui
Commits
b005dd4c
Commit
b005dd4c
authored
Jun 26, 2015
by
hbcui1984
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chat聊天模板新增录音时长过短提示功能
parent
b0089a43
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
38 deletions
+91
-38
examples/hello-mui/examples/im-chat.html
examples/hello-mui/examples/im-chat.html
+89
-35
examples/hello-mui/index.html
examples/hello-mui/index.html
+2
-3
No files found.
examples/hello-mui/examples/im-chat.html
View file @
b005dd4c
...
@@ -202,6 +202,7 @@
...
@@ -202,6 +202,7 @@
background-color
:
rgba
(
0
,
0
,
0
,
0.7
);
background-color
:
rgba
(
0
,
0
,
0
,
0.7
);
border-radius
:
5px
;
border-radius
:
5px
;
display
:
none
;
display
:
none
;
-webkit-transition
:
.15s
;
}
}
.rschedule
{
.rschedule
{
background-color
:
rgba
(
0
,
0
,
0
,
0
);
background-color
:
rgba
(
0
,
0
,
0
,
0
);
...
@@ -221,6 +222,32 @@
...
@@ -221,6 +222,32 @@
-webkit-animation
:
spin
1s
infinite
linear
;
-webkit-animation
:
spin
1s
infinite
linear
;
animation
:
spin
1s
infinite
linear
;
animation
:
spin
1s
infinite
linear
;
}
}
.r-sigh
{
display
:
none
;
border-radius
:
50px
;
box-shadow
:
0
0
15px
#2187e7
;
width
:
46px
;
height
:
46px
;
position
:
absolute
;
left
:
50%
;
top
:
50%
;
margin-left
:
-23px
;
margin-top
:
-23px
;
text-align
:
center
;
line-height
:
46px
;
font-size
:
40px
;
font-weight
:
bold
;
color
:
#2187e7
;
}
.rprogress-sigh
{
background-image
:
none
!important
;
}
.rprogress-sigh
.rschedule
{
display
:
none
!important
;
}
.rprogress-sigh
.r-sigh
{
display
:
block
!important
;
}
.rsalert
{
.rsalert
{
font-size
:
12px
;
font-size
:
12px
;
color
:
#bbb
;
color
:
#bbb
;
...
@@ -278,16 +305,15 @@
...
@@ -278,16 +305,15 @@
<script
id=
'msg-template'
type=
"text/template"
>
<script
id=
'msg-template'
type=
"text/template"
>
<%
for
(
var
i
in
record
){
var
item
=
record
[
i
];
%>
<%
for
(
var
i
in
record
){
var
item
=
record
[
i
];
%>
<
div
class
=
"
msg-item <%= (item.sender=='self'?' msg-item-self':'') %>
"
msg
-
type
=
'
<%=(item.type)%>
'
msg
-
content
=
'
<%=(item.content)%>
'
>
<
div
class
=
"
msg-item <%= (item.sender=='self'?' msg-item-self':'') %>
"
msg
-
type
=
'
<%=(item.type)%>
'
msg
-
content
=
'
<%=(item.content)%>
'
>
<%
if
(
item
.
sender
==
'
self
'
)
{
%>
<%
if
(
item
.
sender
==
'
self
'
)
{
%>
<
i
class
=
"
msg-user mui-icon mui-icon-person
"
><
/i
>
<
i
class
=
"
msg-user mui-icon mui-icon-person
"
><
/i
>
<%
}
else
{
%>
<%
}
else
{
%>
<
img
class
=
"
msg-user-img
"
src
=
"
../images/logo.png
"
alt
=
""
/>
<
img
class
=
"
msg-user-img
"
src
=
"
../images/logo.png
"
alt
=
""
/>
<%
}
%>
<%
}
%>
<
div
class
=
"
msg-content
"
>
<
div
class
=
"
msg-content
"
>
<
div
class
=
"
msg-content-inner
"
>
<
div
class
=
"
msg-content-inner
"
>
<%
if
(
item
.
type
==
'
text
'
)
{
%>
<%
if
(
item
.
type
==
'
text
'
)
{
%>
<%=
(
item
.
content
||
'
'
)
%>
<%=
(
item
.
content
||
'
'
)
%>
<%
}
else
if
(
item
.
type
==
'
image
'
)
{
%>
<%
}
else
if
(
item
.
type
==
'
image
'
)
{
%>
<
img
class
=
"
msg-content-image
"
src
=
"
<%=(item.content)%>
"
style
=
"
max-width: 100px;
"
/>
<
img
class
=
"
msg-content-image
"
src
=
"
<%=(item.content)%>
"
style
=
"
max-width: 100px;
"
/>
<%
}
else
if
(
item
.
type
==
'
sound
'
)
{
%>
<%
}
else
if
(
item
.
type
==
'
sound
'
)
{
%>
...
@@ -299,11 +325,10 @@
...
@@ -299,11 +325,10 @@
<
/div
>
<
/div
>
<
div
class
=
"
mui-item-clear
"
><
/div
>
<
div
class
=
"
mui-item-clear
"
><
/div
>
<
/div
>
<
/div
>
<%
}
%>
<%
}
%>
</script>
</script>
<div
class=
"mui-content"
>
<div
class=
"mui-content"
>
<div
id=
'msg-list'
>
<div
id=
'msg-list'
>
</div>
</div>
</div>
</div>
<footer>
<footer>
...
@@ -320,6 +345,7 @@
...
@@ -320,6 +345,7 @@
</footer>
</footer>
<div
id=
'sound-alert'
class=
"rprogress"
>
<div
id=
'sound-alert'
class=
"rprogress"
>
<div
class=
"rschedule"
></div>
<div
class=
"rschedule"
></div>
<div
class=
"r-sigh"
>
!
</div>
<div
id=
"audio_tips"
class=
"rsalert"
>
手指上滑,取消发送
</div>
<div
id=
"audio_tips"
class=
"rsalert"
>
手指上滑,取消发送
</div>
</div>
</div>
<script
src=
"../js/mui.min.js"
></script>
<script
src=
"../js/mui.min.js"
></script>
...
@@ -327,6 +353,7 @@
...
@@ -327,6 +353,7 @@
<script
src=
"../js/arttmpl.js"
></script>
<script
src=
"../js/arttmpl.js"
></script>
<script
type=
"text/javascript"
charset=
"utf-8"
>
<script
type=
"text/javascript"
charset=
"utf-8"
>
(
function
(
$
,
doc
)
{
(
function
(
$
,
doc
)
{
var
MIN_SOUND_TIME
=
800
;
$
.
init
({
$
.
init
({
gestureConfig
:
{
gestureConfig
:
{
tap
:
true
,
//默认为true
tap
:
true
,
//默认为true
...
@@ -338,7 +365,7 @@
...
@@ -338,7 +365,7 @@
release
:
true
//默认为false,不监听
release
:
true
//默认为false,不监听
}
}
});
});
template
.
config
(
'
escape
'
,
false
);
template
.
config
(
'
escape
'
,
false
);
//$.plusReady=function(fn){fn();};
//$.plusReady=function(fn){fn();};
$
.
plusReady
(
function
()
{
$
.
plusReady
(
function
()
{
plus
.
webview
.
currentWebview
().
setStyle
({
plus
.
webview
.
currentWebview
().
setStyle
({
...
@@ -357,7 +384,7 @@
...
@@ -357,7 +384,7 @@
var
imm
=
main
.
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
var
imm
=
main
.
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
imm
.
toggleSoftInput
(
0
,
InputMethodManager
.
SHOW_FORCED
);
imm
.
toggleSoftInput
(
0
,
InputMethodManager
.
SHOW_FORCED
);
//var view = ((ViewGroup)main.findViewById(android.R.id.content)).getChildAt(0);
//var view = ((ViewGroup)main.findViewById(android.R.id.content)).getChildAt(0);
imm
.
showSoftInput
(
main
.
getWindow
().
getDecorView
(),
InputMethodManager
.
SHOW_IMPLICIT
);
imm
.
showSoftInput
(
main
.
getWindow
().
getDecorView
(),
InputMethodManager
.
SHOW_IMPLICIT
);
//alert("ll");
//alert("ll");
}
}
};
};
...
@@ -444,16 +471,14 @@
...
@@ -444,16 +471,14 @@
bindMsgList
();
bindMsgList
();
});
});
};
};
function
msgTextFocus
()
{
function
msgTextFocus
()
{
ui
.
boxMsgText
.
focus
();
setTimeout
(
function
()
{
ui
.
boxMsgText
.
focus
();
ui
.
boxMsgText
.
focus
();
},
150
);
setTimeout
(
function
()
{
}
ui
.
boxMsgText
.
focus
();
},
150
);
}
//解决长按“发送”按钮,导致键盘关闭的问题;
//解决长按“发送”按钮,导致键盘关闭的问题;
ui
.
footerRight
.
addEventListener
(
'
touchstart
'
,
function
(
event
)
{
ui
.
footerRight
.
addEventListener
(
'
touchstart
'
,
function
(
event
)
{
if
(
ui
.
btnMsgType
.
classList
.
contains
(
'
mui-icon-paperplane
'
))
{
if
(
ui
.
btnMsgType
.
classList
.
contains
(
'
mui-icon-paperplane
'
))
{
msgTextFocus
();
msgTextFocus
();
...
@@ -467,19 +492,18 @@
...
@@ -467,19 +492,18 @@
event
.
preventDefault
();
event
.
preventDefault
();
}
}
});
});
// ui.footerRight.addEventListener('touchcancel', function(event) {
// ui.footerRight.addEventListener('touchcancel', function(event) {
// if (ui.btnMsgType.classList.contains('mui-icon-paperplane')) {
// if (ui.btnMsgType.classList.contains('mui-icon-paperplane')) {
// msgTextFocus();
// msgTextFocus();
// event.preventDefault();
// event.preventDefault();
// }
// }
// });
// });
// ui.footerRight.addEventListener('touchend', function(event) {
// ui.footerRight.addEventListener('touchend', function(event) {
// if (ui.btnMsgType.classList.contains('mui-icon-paperplane')) {
// if (ui.btnMsgType.classList.contains('mui-icon-paperplane')) {
// msgTextFocus();
// msgTextFocus();
// event.preventDefault();
// event.preventDefault();
// }
// }
// });
// });
ui
.
footerRight
.
addEventListener
(
'
release
'
,
function
(
event
)
{
ui
.
footerRight
.
addEventListener
(
'
release
'
,
function
(
event
)
{
if
(
ui
.
btnMsgType
.
classList
.
contains
(
'
mui-icon-paperplane
'
))
{
if
(
ui
.
btnMsgType
.
classList
.
contains
(
'
mui-icon-paperplane
'
))
{
//showKeyboard();
//showKeyboard();
...
@@ -487,11 +511,11 @@
...
@@ -487,11 +511,11 @@
setTimeout
(
function
()
{
setTimeout
(
function
()
{
ui
.
boxMsgText
.
focus
();
ui
.
boxMsgText
.
focus
();
},
150
);
},
150
);
// event.detail.gesture.preventDefault();
// event.detail.gesture.preventDefault();
send
({
send
({
sender
:
'
self
'
,
sender
:
'
self
'
,
type
:
'
text
'
,
type
:
'
text
'
,
content
:
ui
.
boxMsgText
.
value
.
replace
(
new
RegExp
(
'
\n
'
,
'
gm
'
),
'
<br/>
'
)
content
:
ui
.
boxMsgText
.
value
.
replace
(
new
RegExp
(
'
\n
'
,
'
gm
'
),
'
<br/>
'
)
});
});
ui
.
boxMsgText
.
value
=
''
;
ui
.
boxMsgText
.
value
=
''
;
$
.
trigger
(
ui
.
boxMsgText
,
'
input
'
,
null
);
$
.
trigger
(
ui
.
boxMsgText
,
'
input
'
,
null
);
...
@@ -551,18 +575,37 @@
...
@@ -551,18 +575,37 @@
break
;
break
;
}
}
});
});
},
false
);
},
false
);
var
setSoundAlertVisable
=
function
(
show
){
if
(
show
){
ui
.
boxSoundAlert
.
style
.
display
=
'
block
'
;
ui
.
boxSoundAlert
.
style
.
opacity
=
1
;
}
else
{
ui
.
boxSoundAlert
.
style
.
opacity
=
0
;
//fadeOut 完成再真正隐藏
setTimeout
(
function
(){
ui
.
boxSoundAlert
.
style
.
display
=
'
none
'
;
},
200
);
}
};
var
recordCancel
=
false
;
var
recordCancel
=
false
;
var
recorder
=
null
;
var
recorder
=
null
;
var
audio_tips
=
document
.
getElementById
(
"
audio_tips
"
);
var
audio_tips
=
document
.
getElementById
(
"
audio_tips
"
);
var
startTimestamp
=
null
;
var
stopTimestamp
=
null
;
var
stopTimer
=
null
;
ui
.
boxMsgSound
.
addEventListener
(
'
hold
'
,
function
(
event
)
{
ui
.
boxMsgSound
.
addEventListener
(
'
hold
'
,
function
(
event
)
{
recordCancel
=
false
;
recordCancel
=
false
;
ui
.
boxSoundAlert
.
style
.
display
=
'
block
'
;
if
(
stopTimer
)
clearTimeout
(
stopTimer
);
audio_tips
.
innerHTML
=
"
手指上划,取消发送
"
;
ui
.
boxSoundAlert
.
classList
.
remove
(
'
rprogress-sigh
'
);
setSoundAlertVisable
(
true
);
recorder
=
plus
.
audio
.
getRecorder
();
recorder
=
plus
.
audio
.
getRecorder
();
if
(
recorder
==
null
)
{
if
(
recorder
==
null
)
{
plus
.
nativeUI
.
toast
(
"
不能获取录音对象
"
);
plus
.
nativeUI
.
toast
(
"
不能获取录音对象
"
);
return
;
return
;
}
}
startTimestamp
=
(
new
Date
()).
getTime
();
recorder
.
record
({
recorder
.
record
({
filename
:
"
_doc/audio/
"
filename
:
"
_doc/audio/
"
},
function
(
path
)
{
},
function
(
path
)
{
...
@@ -602,7 +645,18 @@
...
@@ -602,7 +645,18 @@
audio_tips
.
classList
.
remove
(
"
cancel
"
);
audio_tips
.
classList
.
remove
(
"
cancel
"
);
audio_tips
.
innerHTML
=
"
手指上划,取消发送
"
;
audio_tips
.
innerHTML
=
"
手指上划,取消发送
"
;
}
}
ui
.
boxSoundAlert
.
style
.
display
=
'
none
'
;
//
stopTimestamp
=
(
new
Date
()).
getTime
();
if
(
stopTimestamp
-
startTimestamp
<
MIN_SOUND_TIME
)
{
audio_tips
.
innerHTML
=
"
录音时间太短
"
;
ui
.
boxSoundAlert
.
classList
.
add
(
'
rprogress-sigh
'
);
recordCancel
=
true
;
stopTimer
=
setTimeout
(
function
(){
setSoundAlertVisable
(
false
);
},
800
);
}
else
{
setSoundAlertVisable
(
false
);
}
recorder
.
stop
();
recorder
.
stop
();
},
false
);
},
false
);
ui
.
boxMsgSound
.
addEventListener
(
"
touchstart
"
,
function
(
e
)
{
ui
.
boxMsgSound
.
addEventListener
(
"
touchstart
"
,
function
(
e
)
{
...
@@ -612,7 +666,7 @@
...
@@ -612,7 +666,7 @@
ui
.
boxMsgText
.
addEventListener
(
'
input
'
,
function
(
event
)
{
ui
.
boxMsgText
.
addEventListener
(
'
input
'
,
function
(
event
)
{
ui
.
btnMsgType
.
classList
[
ui
.
boxMsgText
.
value
==
''
?
'
remove
'
:
'
add
'
](
'
mui-icon-paperplane
'
);
ui
.
btnMsgType
.
classList
[
ui
.
boxMsgText
.
value
==
''
?
'
remove
'
:
'
add
'
](
'
mui-icon-paperplane
'
);
ui
.
btnMsgType
.
setAttribute
(
"
for
"
,
ui
.
boxMsgText
.
value
==
''
?
''
:
'
msg-text
'
);
ui
.
btnMsgType
.
setAttribute
(
"
for
"
,
ui
.
boxMsgText
.
value
==
''
?
''
:
'
msg-text
'
);
ui
.
h
.
innerText
=
ui
.
boxMsgText
.
value
.
replace
(
new
RegExp
(
'
\n
'
,
'
gm
'
),
'
\n
-
'
)
||
'
-
'
;
ui
.
h
.
innerText
=
ui
.
boxMsgText
.
value
.
replace
(
new
RegExp
(
'
\n
'
,
'
gm
'
),
'
\n
-
'
)
||
'
-
'
;
ui
.
footer
.
style
.
height
=
(
ui
.
h
.
offsetHeight
+
footerPadding
)
+
'
px
'
;
ui
.
footer
.
style
.
height
=
(
ui
.
h
.
offsetHeight
+
footerPadding
)
+
'
px
'
;
ui
.
content
.
style
.
paddingBottom
=
ui
.
footer
.
style
.
height
;
ui
.
content
.
style
.
paddingBottom
=
ui
.
footer
.
style
.
height
;
});
});
...
...
examples/hello-mui/index.html
View file @
b005dd4c
...
@@ -40,9 +40,8 @@
...
@@ -40,9 +40,8 @@
}]
}]
});
});
mui
.
plusReady
(
function
()
{
mui
.
plusReady
(
function
()
{
if
(
mui
.
os
.
android
)
{
//仅支持竖屏显示
plus
.
screen
.
lockOrientation
(
"
portrait-primary
"
);
plus
.
screen
.
lockOrientation
(
"
portrait-primary
"
);
}
main
=
plus
.
webview
.
currentWebview
();
main
=
plus
.
webview
.
currentWebview
();
main
.
addEventListener
(
'
maskClick
'
,
closeMenu
);
main
.
addEventListener
(
'
maskClick
'
,
closeMenu
);
//处理侧滑导航,为了避免和子页面初始化等竞争资源,延迟加载侧滑页面;
//处理侧滑导航,为了避免和子页面初始化等竞争资源,延迟加载侧滑页面;
...
...
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