author | veltr |
Fri, 11 Oct 2013 17:37:25 +0200 | |
changeset 107 | 6b346cb90c5a |
parent 30 | 81d408373dde |
permissions | -rw-r--r-- |
30
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
<!DOCTYPE html> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
<html lang="en"> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
<head> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
<meta charset="UTF-8" /> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
<title>jQuery UI Slider - Slider scrollbar</title> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
<script type="text/javascript" src="../../jquery-1.4.2.js"></script> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
<script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
<script type="text/javascript" src="../../ui/jquery.ui.slider.js"></script> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
<link type="text/css" href="../demos.css" rel="stylesheet" /> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
<style type="text/css"> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
#demo-frame > div.demo { padding: 10px !important; } |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
.scroll-pane { overflow: auto; width: 99%; float:left; } |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
.scroll-content { width: 2440px; float: left; } |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
.scroll-content-item { width: 100px; height: 100px; float: left; margin: 10px; font-size: 3em; line-height: 96px; text-align: center; } |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
* html .scroll-content-item { display: inline; } /* IE6 float double margin bug */ |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
.scroll-bar-wrap { clear: left; padding: 0 4px 0 2px; margin: 0 -1px -1px -1px; } |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
.scroll-bar-wrap .ui-slider { background: none; border:0; height: 2em; margin: 0 auto; } |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
.scroll-bar-wrap .ui-handle-helper-parent { position: relative; width: 100%; height: 100%; margin: 0 auto; } |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
.scroll-bar-wrap .ui-slider-handle { top:.2em; height: 1.5em; } |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
.scroll-bar-wrap .ui-slider-handle .ui-icon { margin: -8px auto 0; position: relative; top: 50%; } |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
</style> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
<script type="text/javascript"> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
$(function() { |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
//scrollpane parts |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
var scrollPane = $('.scroll-pane'); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
var scrollContent = $('.scroll-content'); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
//build slider |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
var scrollbar = $(".scroll-bar").slider({ |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
slide:function(e, ui){ |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
if( scrollContent.width() > scrollPane.width() ){ scrollContent.css('margin-left', Math.round( ui.value / 100 * ( scrollPane.width() - scrollContent.width() )) + 'px'); } |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
else { scrollContent.css('margin-left', 0); } |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
} |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
37 |
}); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
38 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
39 |
//append icon to handle |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
40 |
var handleHelper = scrollbar.find('.ui-slider-handle') |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
41 |
.mousedown(function(){ |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
42 |
scrollbar.width( handleHelper.width() ); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
43 |
}) |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
44 |
.mouseup(function(){ |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
45 |
scrollbar.width( '100%' ); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
46 |
}) |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
47 |
.append('<span class="ui-icon ui-icon-grip-dotted-vertical"></span>') |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
48 |
.wrap('<div class="ui-handle-helper-parent"></div>').parent(); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
49 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
50 |
//change overflow to hidden now that slider handles the scrolling |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
51 |
scrollPane.css('overflow','hidden'); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
52 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
53 |
//size scrollbar and handle proportionally to scroll distance |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
54 |
function sizeScrollbar(){ |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
55 |
var remainder = scrollContent.width() - scrollPane.width(); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
56 |
var proportion = remainder / scrollContent.width(); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
57 |
var handleSize = scrollPane.width() - (proportion * scrollPane.width()); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
58 |
scrollbar.find('.ui-slider-handle').css({ |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
59 |
width: handleSize, |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
60 |
'margin-left': -handleSize/2 |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
61 |
}); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
62 |
handleHelper.width('').width( scrollbar.width() - handleSize); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
63 |
} |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
64 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
65 |
//reset slider value based on scroll content position |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
66 |
function resetValue(){ |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
67 |
var remainder = scrollPane.width() - scrollContent.width(); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
68 |
var leftVal = scrollContent.css('margin-left') == 'auto' ? 0 : parseInt(scrollContent.css('margin-left')); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
69 |
var percentage = Math.round(leftVal / remainder * 100); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
70 |
scrollbar.slider("value", percentage); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
71 |
} |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
72 |
//if the slider is 100% and window gets larger, reveal content |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
73 |
function reflowContent(){ |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
74 |
var showing = scrollContent.width() + parseInt( scrollContent.css('margin-left') ); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
75 |
var gap = scrollPane.width() - showing; |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
76 |
if(gap > 0){ |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
77 |
scrollContent.css('margin-left', parseInt( scrollContent.css('margin-left') ) + gap); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
78 |
} |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
79 |
} |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
80 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
81 |
//change handle position on window resize |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
82 |
$(window) |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
83 |
.resize(function(){ |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
84 |
resetValue(); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
85 |
sizeScrollbar(); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
86 |
reflowContent(); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
87 |
}); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
88 |
//init scrollbar size |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
89 |
setTimeout(sizeScrollbar,10);//safari wants a timeout |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
90 |
}); |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
91 |
</script> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
92 |
</head> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
93 |
<body> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
94 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
95 |
<div class="demo"> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
96 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
97 |
<div class="scroll-pane ui-widget ui-widget-header ui-corner-all"> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
98 |
<div class="scroll-content"> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
99 |
<div class="scroll-content-item ui-widget-header">1</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
100 |
<div class="scroll-content-item ui-widget-header">2</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
101 |
<div class="scroll-content-item ui-widget-header">3</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
102 |
<div class="scroll-content-item ui-widget-header">4</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
103 |
<div class="scroll-content-item ui-widget-header">5</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
104 |
<div class="scroll-content-item ui-widget-header">6</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
105 |
<div class="scroll-content-item ui-widget-header">7</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
106 |
<div class="scroll-content-item ui-widget-header">8</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
107 |
<div class="scroll-content-item ui-widget-header">9</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
108 |
<div class="scroll-content-item ui-widget-header">10</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
109 |
<div class="scroll-content-item ui-widget-header">11</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
110 |
<div class="scroll-content-item ui-widget-header">12</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
111 |
<div class="scroll-content-item ui-widget-header">13</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
112 |
<div class="scroll-content-item ui-widget-header">14</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
113 |
<div class="scroll-content-item ui-widget-header">15</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
114 |
<div class="scroll-content-item ui-widget-header">16</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
115 |
<div class="scroll-content-item ui-widget-header">17</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
116 |
<div class="scroll-content-item ui-widget-header">18</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
117 |
<div class="scroll-content-item ui-widget-header">19</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
118 |
<div class="scroll-content-item ui-widget-header">20</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
119 |
</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
120 |
<div class="scroll-bar-wrap ui-widget-content ui-corner-bottom"> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
121 |
<div class="scroll-bar"></div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
122 |
</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
123 |
</div> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
124 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
125 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
126 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
127 |
</div><!-- End demo --> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
128 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
129 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
130 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
131 |
<div class="demo-description"> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
132 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
133 |
<p>Use a slider to manipulate the positioning of content on the page. In this case, it acts as a scrollbar with the potential to capture values if needed.</p> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
134 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
135 |
</div><!-- End demo-description --> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
136 |
|
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
137 |
</body> |
81d408373dde
itry to have the player in the preview page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
138 |
</html> |