Ticket #13386: 13386.html

File 13386.html, 1.4 KB (added by Olek Nowodziński, 9 years ago)
Line 
1<!DOCTYPE html>
2<!--
3Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
4For licensing, see LICENSE.md or http://ckeditor.com/license
5-->
6<html>
7<head>
8        <meta charset="utf-8">
9        <title></title>
10        <link href="sample.css" rel="stylesheet">
11</head>
12<body>
13        <h1>Without timeout</h1>
14        <div contenteditable="true" style="outline: 1px dotted red; padding: 1em;">
15                <img id="img-raw" alt="Saturn V carrying Apollo 11" src="//cdn-source.ckeditor.com/4.5.1/standard/samples/img/logo.png"/>
16        </div>
17
18        <h1>With timeout</h1>
19        <div contenteditable="true" style="outline: 1px dotted green; padding: 1em;">
20                <img id="img-timeout" alt="Saturn V carrying Apollo 11" src="//cdn-source.ckeditor.com/4.5.1/standard/samples/img/logo.png"/>
21        </div>
22
23        <script>
24                var imgRaw = document.getElementById( 'img-raw' );
25
26                imgRaw.addEventListener( 'mousedown', function() {
27                        var r = document.createRange();
28                        r.setStartBefore( imgRaw );
29                        r.setEndAfter( imgRaw );
30
31                        var s = window.getSelection();
32                        s.removeAllRanges();
33                        s.addRange( r );
34                } );
35
36                var imgTimeout = document.getElementById( 'img-timeout' );
37
38                imgTimeout.addEventListener( 'mousedown', function() {
39                        var r = document.createRange();
40                        r.setStartBefore( imgTimeout );
41                        r.setEndAfter( imgTimeout );
42
43                        setTimeout( function() {
44                                var s = window.getSelection();
45                                s.removeAllRanges();
46                                s.addRange( r );
47                        }, 100 );
48                } );
49        </script>
50
51</body>
52</html>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy