1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
Drupal.Sweaver = Drupal.Sweaver || {};
|
8
|
|
9
|
$(document).ready(function() {
|
10
|
Drupal.Sweaver.themeSwitch_init();
|
11
|
$('#tab-sweaver_plugin_themeswitch a').click(function() {
|
12
|
Drupal.Sweaver.themeSwitch_init();
|
13
|
});
|
14
|
});
|
15
|
|
16
|
|
17
|
Drupal.Sweaver.themeSwitch_init = function() {
|
18
|
|
19
|
var width = 0;
|
20
|
$('#themeswitch-content .selected-image').each(function () {
|
21
|
width += $(this).outerWidth(true);
|
22
|
});
|
23
|
$('#themeswitch-content').css('width', width +'px');
|
24
|
|
25
|
|
26
|
var scrollPane = $('#themeswitch-pane');
|
27
|
var scrollContent = $('#themeswitch-content');
|
28
|
|
29
|
|
30
|
var scrollbar = $("#sweaver .scroll-bar").slider({
|
31
|
slide:function(e, ui){
|
32
|
if (scrollContent.width() > scrollPane.width()) {
|
33
|
|
34
|
scrollContent.css('cssText', 'margin-left: ' + Math.round( ui.value / 100 * ( scrollPane.width() - scrollContent.width() )) + 'px !important; width: ' + width + 'px');
|
35
|
}
|
36
|
else {
|
37
|
|
38
|
scrollContent.css('cssText', 'margin-left: 0px !important; width: ' + width + 'px');
|
39
|
}
|
40
|
}
|
41
|
});
|
42
|
|
43
|
|
44
|
var handleHelper = scrollbar.find('.ui-slider-handle')
|
45
|
.mousedown(function(){
|
46
|
scrollbar.width( handleHelper.width() );
|
47
|
})
|
48
|
.mouseup(function(){
|
49
|
scrollbar.width( '100%' );
|
50
|
})
|
51
|
.append('<span class="ui-icon ui-icon-grip-dotted-vertical"></span>')
|
52
|
.wrap('<div class="ui-handle-helper-parent"></div>').parent();
|
53
|
|
54
|
|
55
|
scrollPane.css('overflow','hidden');
|
56
|
|
57
|
|
58
|
function sizeScrollbar(){
|
59
|
if (scrollContent.width() > scrollPane.width()) {
|
60
|
handleHelper.parents('.ui-slider').show();
|
61
|
var remainder = scrollContent.width() - scrollPane.width();
|
62
|
var proportion = remainder / scrollContent.width();
|
63
|
var handleSize = scrollPane.width() - (proportion * scrollPane.width());
|
64
|
scrollbar.find('.ui-slider-handle').css({
|
65
|
width: handleSize
|
66
|
});
|
67
|
handleHelper.width(scrollbar.width());
|
68
|
}
|
69
|
else {
|
70
|
handleHelper.parents('.ui-slider').hide();
|
71
|
}
|
72
|
}
|
73
|
|
74
|
|
75
|
function resetValue(){
|
76
|
var remainder = scrollPane.width() - scrollContent.width();
|
77
|
var leftVal = scrollContent.css('margin-left') == 'auto' ? 0 : parseInt(scrollContent.css('margin-left'));
|
78
|
var percentage = Math.round(leftVal / remainder * 100);
|
79
|
scrollbar.slider("value", percentage);
|
80
|
}
|
81
|
|
82
|
|
83
|
$(window)
|
84
|
.resize(function(){
|
85
|
if (scrollPane.parent().is(':visible')) {
|
86
|
resetValue();
|
87
|
sizeScrollbar();
|
88
|
}
|
89
|
});
|
90
|
|
91
|
|
92
|
setTimeout(sizeScrollbar,10);
|
93
|
};
|