| 1 | <!doctype html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta charset="utf-8"> |
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | <title>jQuery UI Position - Default functionality</title> |
| 7 | <link rel="stylesheet" href="../../themes/base/all.css"> |
| 8 | <link rel="stylesheet" href="../demos.css"> |
| 9 | <style> |
| 10 | #parent { |
| 11 | width: 60%; |
| 12 | height: 40px; |
| 13 | margin: 10px auto; |
| 14 | padding: 5px; |
| 15 | border: 1px solid #777; |
| 16 | background-color: #fbca93; |
| 17 | text-align: center; |
| 18 | } |
| 19 | .positionable { |
| 20 | position: absolute; |
| 21 | display: block; |
| 22 | right: 0; |
| 23 | bottom: 0; |
| 24 | background-color: #bcd5e6; |
| 25 | text-align: center; |
| 26 | } |
| 27 | #positionable1 { |
| 28 | width: 75px; |
| 29 | height: 75px; |
| 30 | } |
| 31 | #positionable2 { |
| 32 | width: 120px; |
| 33 | height: 40px; |
| 34 | } |
| 35 | select, input { |
| 36 | margin-left: 15px; |
| 37 | } |
| 38 | </style> |
| 39 | <script src="../../external/requirejs/require.js"></script> |
| 40 | <script src="../bootstrap.js" data-modules="draggable"> |
| 41 | function position() { |
| 42 | $( ".positionable" ).position({ |
| 43 | of: $( "#parent" ), |
| 44 | my: $( "#my_horizontal" ).val() + " " + $( "#my_vertical" ).val(), |
| 45 | at: $( "#at_horizontal" ).val() + " " + $( "#at_vertical" ).val(), |
| 46 | collision: $( "#collision_horizontal" ).val() + " " + $( "#collision_vertical" ).val() |
| 47 | }); |
| 48 | } |
| 49 | |
| 50 | $( ".positionable" ).css( "opacity", 0.5 ); |
| 51 | |
| 52 | $( "select, input" ).on( "click keyup change", position ); |
| 53 | |
| 54 | $( "#parent" ).draggable({ |
| 55 | drag: position |
| 56 | }); |
| 57 | |
| 58 | position(); |
| 59 | </script> |
| 60 | </head> |
| 61 | <body> |
| 62 | |
| 63 | <div id="parent"> |
| 64 | <p> |
| 65 | This is the position parent element. |
| 66 | </p> |
| 67 | </div> |
| 68 | |
| 69 | <div class="positionable" id="positionable1"> |
| 70 | <p> |
| 71 | to position |
| 72 | </p> |
| 73 | </div> |
| 74 | |
| 75 | <div class="positionable" id="positionable2"> |
| 76 | <p> |
| 77 | to position 2 |
| 78 | </p> |
| 79 | </div> |
| 80 | |
| 81 | <div style="padding: 20px; margin-top: 75px;"> |
| 82 | position... |
| 83 | <div style="padding-bottom: 20px;"> |
| 84 | <b>my:</b> |
| 85 | <select id="my_horizontal"> |
| 86 | <option value="left">left</option> |
| 87 | <option value="center">center</option> |
| 88 | <option value="right">right</option> |
| 89 | </select> |
| 90 | <select id="my_vertical"> |
| 91 | <option value="top">top</option> |
| 92 | <option value="center">center</option> |
| 93 | <option value="bottom">bottom</option> |
| 94 | </select> |
| 95 | </div> |
| 96 | <div style="padding-bottom: 20px;"> |
| 97 | <b>at:</b> |
| 98 | <select id="at_horizontal"> |
| 99 | <option value="left">left</option> |
| 100 | <option value="center">center</option> |
| 101 | <option value="right">right</option> |
| 102 | </select> |
| 103 | <select id="at_vertical"> |
| 104 | <option value="top">top</option> |
| 105 | <option value="center">center</option> |
| 106 | <option value="bottom">bottom</option> |
| 107 | </select> |
| 108 | </div> |
| 109 | <div style="padding-bottom: 20px;"> |
| 110 | <b>collision:</b> |
| 111 | <select id="collision_horizontal"> |
| 112 | <option value="flip">flip</option> |
| 113 | <option value="fit">fit</option> |
| 114 | <option value="flipfit">flipfit</option> |
| 115 | <option value="none">none</option> |
| 116 | </select> |
| 117 | <select id="collision_vertical"> |
| 118 | <option value="flip">flip</option> |
| 119 | <option value="fit">fit</option> |
| 120 | <option value="flipfit">flipfit</option> |
| 121 | <option value="none">none</option> |
| 122 | </select> |
| 123 | </div> |
| 124 | </div> |
| 125 | |
| 126 | <div class="demo-description"> |
| 127 | <p>Use the form controls to configure the positioning, or drag the positioned element to modify its offset. |
| 128 | <br>Drag around the parent element to see collision detection in action.</p> |
| 129 | </div> |
| 130 | </body> |
| 131 | </html> |