forked from 0x2620/oxjs
add mouse events example
This commit is contained in:
parent
c8e25562db
commit
f324320f89
12 changed files with 84 additions and 222 deletions
26
examples/mouse_events/css/example.css
Normal file
26
examples/mouse_events/css/example.css
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#clear {
|
||||
position: absolute;
|
||||
left: 256px;
|
||||
right: 0px;
|
||||
height: 16px;
|
||||
padding-left: 2px;
|
||||
background: rgb(224, 224, 224);
|
||||
}
|
||||
#log {
|
||||
position: absolute;
|
||||
left: 256px;
|
||||
top: 16px;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgb(255, 255, 255);
|
||||
overflow-y: auto;
|
||||
}
|
||||
#target {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 256px;
|
||||
padding-left: 2px;
|
||||
background: rgb(192, 192, 192);
|
||||
}
|
||||
13
examples/mouse_events/index.html
Normal file
13
examples/mouse_events/index.html
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Mouse Events</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<link rel="shortcut icon" type="image/png" href="../../source/Ox.UI/png/icon16.png"/>
|
||||
<link rel="stylesheet" type="text/css" href="css/example.css"/>
|
||||
<script type="text/javascript" src="../../dev/Ox.js"></script>
|
||||
<script type="text/javascript" src="js/example.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
44
examples/mouse_events/js/example.js
Normal file
44
examples/mouse_events/js/example.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
Ox.load({UI: {theme: 'classic'}}, function() {
|
||||
|
||||
var $target = Ox.Element()
|
||||
.attr({id: 'target'})
|
||||
.html('click/hold/drag here')
|
||||
.appendTo(Ox.$body),
|
||||
$log = Ox.Element()
|
||||
.attr({id: 'log'})
|
||||
.appendTo(Ox.$body),
|
||||
$clear = Ox.Element()
|
||||
.attr({id: 'clear'})
|
||||
.html('clear log')
|
||||
.bind({click: function() {
|
||||
$log.empty();
|
||||
}})
|
||||
.appendTo(Ox.$body);
|
||||
[
|
||||
'anyclick', 'singleclick', 'doubleclick', 'mousedown', 'mouserepeat',
|
||||
'dragstart', 'drag', 'dragenter', 'dragleave', 'dragpause', 'dragend'
|
||||
].forEach(function(event) {
|
||||
$target.bindEvent(event, function(e) {
|
||||
var date = new Date();
|
||||
$('<div>')
|
||||
.html(
|
||||
Ox.formatDate(date, '%H:%M:%S')
|
||||
+ '.' + (Ox.pad(date % 1000, 3))
|
||||
+ ' <span style="font-weight: bold">' + event + '</span> '
|
||||
+ JSON.stringify(
|
||||
Ox.extend(e.clientX ? {
|
||||
clientX: e.clientX,
|
||||
clientY: e.clientY,
|
||||
} : {}, e.clientDX ? {
|
||||
clientDX: e.clientDX,
|
||||
clientDY: e.clientDY
|
||||
} : {})
|
||||
)
|
||||
.replace(/"/g, '')
|
||||
.replace(/,/g, ', ')
|
||||
.replace(/:/g, ': ')
|
||||
)
|
||||
.prependTo($log);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue