active_administration 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/README.md +2 -1
  4. data/active_administration.gemspec +2 -1
  5. data/app/assets/javascripts/active_administration/README.md +0 -0
  6. data/app/assets/javascripts/active_administration/metro-accordion.js +70 -0
  7. data/app/assets/javascripts/active_administration/metro-button-set.js +88 -0
  8. data/app/assets/javascripts/active_administration/metro-calendar.js +437 -0
  9. data/app/assets/javascripts/active_administration/metro-carousel.js +304 -0
  10. data/app/assets/javascripts/active_administration/metro-core.js +39 -0
  11. data/app/assets/javascripts/active_administration/metro-countdown.js +200 -0
  12. data/app/assets/javascripts/active_administration/metro-date-format.js +137 -0
  13. data/app/assets/javascripts/active_administration/metro-datepicker.js +138 -0
  14. data/app/assets/javascripts/active_administration/metro-dialog.js +221 -0
  15. data/app/assets/javascripts/active_administration/metro-drag-tile.js +46 -0
  16. data/app/assets/javascripts/active_administration/metro-dropdown.js +112 -0
  17. data/app/assets/javascripts/active_administration/metro-fluentmenu.js +57 -0
  18. data/app/assets/javascripts/active_administration/metro-global.js +4 -0
  19. data/app/assets/javascripts/active_administration/metro-hint.js +104 -0
  20. data/app/assets/javascripts/active_administration/metro-initiator.js +271 -0
  21. data/app/assets/javascripts/active_administration/metro-input-control.js +318 -0
  22. data/app/assets/javascripts/active_administration/metro-listview.js +53 -0
  23. data/app/assets/javascripts/active_administration/metro-live-tile.js +162 -0
  24. data/app/assets/javascripts/active_administration/metro-loader.js +46 -0
  25. data/app/assets/javascripts/active_administration/metro-locale.js +132 -0
  26. data/app/assets/javascripts/active_administration/metro-notify.js +120 -0
  27. data/app/assets/javascripts/active_administration/metro-panel.js +41 -0
  28. data/app/assets/javascripts/active_administration/metro-plugin-template.js +21 -0
  29. data/app/assets/javascripts/active_administration/metro-progressbar.js +97 -0
  30. data/app/assets/javascripts/active_administration/metro-pull.js +38 -0
  31. data/app/assets/javascripts/active_administration/metro-rating.js +99 -0
  32. data/app/assets/javascripts/active_administration/metro-scroll.js +756 -0
  33. data/app/assets/javascripts/active_administration/metro-slider.js +304 -0
  34. data/app/assets/javascripts/active_administration/metro-stepper.js +105 -0
  35. data/app/assets/javascripts/active_administration/metro-streamer.js +214 -0
  36. data/app/assets/javascripts/active_administration/metro-tab-control.js +96 -0
  37. data/app/assets/javascripts/active_administration/metro-table.js +74 -0
  38. data/app/assets/javascripts/active_administration/metro-tile-transform.js +65 -0
  39. data/app/assets/javascripts/active_administration/metro-times.js +190 -0
  40. data/app/assets/javascripts/active_administration/metro-touch-handler.js +65 -0
  41. data/app/assets/javascripts/active_administration/metro-treeview.js +64 -0
  42. data/app/assets/javascripts/active_administration/metro-wizard.js +148 -0
  43. data/app/assets/stylesheets/active_administration/accordion.less +64 -0
  44. data/app/assets/stylesheets/active_administration/balloon.less +88 -0
  45. data/app/assets/stylesheets/active_administration/breadcrumbs.less +118 -0
  46. data/app/assets/stylesheets/active_administration/buttons.less +383 -0
  47. data/app/assets/stylesheets/active_administration/calendar.less +123 -0
  48. data/app/assets/stylesheets/active_administration/carousel.less +118 -0
  49. data/app/assets/stylesheets/active_administration/colors.less +589 -0
  50. data/app/assets/stylesheets/active_administration/countdown.less +57 -0
  51. data/app/assets/stylesheets/active_administration/dataTables.less +134 -0
  52. data/app/assets/stylesheets/active_administration/fluent-menu.less +231 -0
  53. data/app/assets/stylesheets/active_administration/forms.less +414 -0
  54. data/app/assets/stylesheets/active_administration/funcs.less +178 -0
  55. data/app/assets/stylesheets/active_administration/grid.less +91 -0
  56. data/app/assets/stylesheets/active_administration/hint.less +120 -0
  57. data/app/assets/stylesheets/active_administration/iconFont-content.less +1353 -0
  58. data/app/assets/stylesheets/active_administration/iconFont.less +47 -0
  59. data/app/assets/stylesheets/active_administration/icons.less +10 -0
  60. data/app/assets/stylesheets/active_administration/images.less +75 -0
  61. data/app/assets/stylesheets/active_administration/layout.less +137 -0
  62. data/app/assets/stylesheets/active_administration/lists.less +258 -0
  63. data/app/assets/stylesheets/active_administration/menus.less +469 -0
  64. data/app/assets/stylesheets/active_administration/metro-bootstrap-responsive.less +300 -0
  65. data/app/assets/stylesheets/active_administration/metro-bootstrap.less +68 -0
  66. data/app/assets/stylesheets/active_administration/misc.less +72 -0
  67. data/app/assets/stylesheets/active_administration/navigation-bar.less +317 -0
  68. data/app/assets/stylesheets/active_administration/notice.less +52 -0
  69. data/app/assets/stylesheets/active_administration/notify.less +43 -0
  70. data/app/assets/stylesheets/active_administration/pagination.less +83 -0
  71. data/app/assets/stylesheets/active_administration/panels.less +38 -0
  72. data/app/assets/stylesheets/active_administration/progress-bar.less +25 -0
  73. data/app/assets/stylesheets/active_administration/rating.less +103 -0
  74. data/app/assets/stylesheets/active_administration/reset.less +219 -0
  75. data/app/assets/stylesheets/active_administration/scroll.less +141 -0
  76. data/app/assets/stylesheets/active_administration/sidebar.less +158 -0
  77. data/app/assets/stylesheets/active_administration/slider.less +106 -0
  78. data/app/assets/stylesheets/active_administration/stepper.less +80 -0
  79. data/app/assets/stylesheets/active_administration/streamer.less +250 -0
  80. data/app/assets/stylesheets/active_administration/tab-control.less +79 -0
  81. data/app/assets/stylesheets/active_administration/tables.less +170 -0
  82. data/app/assets/stylesheets/active_administration/tiles.less +599 -0
  83. data/app/assets/stylesheets/active_administration/transform.less +23 -0
  84. data/app/assets/stylesheets/active_administration/treeview.less +96 -0
  85. data/app/assets/stylesheets/active_administration/typography.less +382 -0
  86. data/app/assets/stylesheets/active_administration/utils.less +180 -0
  87. data/app/assets/stylesheets/active_administration/variables.less +250 -0
  88. data/app/assets/stylesheets/active_administration/window.less +225 -0
  89. data/app/assets/stylesheets/active_administration/wizard.less +53 -0
  90. data/lib/active_admin/version.rb +1 -1
  91. metadata +103 -10
@@ -0,0 +1,38 @@
1
+ (function( $ ) {
2
+ $.widget("metro.pullmenu", {
3
+
4
+ version: "1.0.0",
5
+
6
+ options: {
7
+ },
8
+
9
+ _create: function(){
10
+ var that = this,
11
+ element = this.element;
12
+
13
+ var menu = (element.data("relation") != undefined) ? element.data("relation") : element.parent().children(".element-menu, .horizontal-menu");
14
+
15
+ addTouchEvents(element[0]);
16
+
17
+ element.on("click", function(e){
18
+ menu.slideToggle();
19
+ e.preventDefault();
20
+ e.stopPropagation();
21
+ });
22
+
23
+ },
24
+
25
+ _destroy: function(){
26
+
27
+ },
28
+
29
+ _setOption: function(key, value){
30
+ this._super('_setOption', key, value);
31
+ }
32
+ })
33
+ })( jQuery );
34
+
35
+ $(window).resize(function(){
36
+ var device_width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
37
+ if (device_width > 800) {$(".element-menu").show();} else {$(".element-menu").hide();}
38
+ });
@@ -0,0 +1,99 @@
1
+ (function( $ ) {
2
+ $.widget("metro.rating", {
3
+
4
+ version: "1.0.0",
5
+
6
+ options: {
7
+ score: 0,
8
+ half: false,
9
+ stars: 5,
10
+ static: true,
11
+ hints: ['bad', 'poor', 'regular', 'good', 'gorgeous'],
12
+ showHint: false,
13
+ showScore: false,
14
+ scoreHint: "Current score: ",
15
+ click: function(value, rating){}
16
+ },
17
+
18
+ _create: function(){
19
+ var that = this,
20
+ element = this.element;
21
+
22
+ if (element.data('score') != undefined) {
23
+ this.options.score = element.data('score');
24
+ }
25
+ if (element.data('half') != undefined) {
26
+ this.options.half = element.data('half');
27
+ }
28
+ if (element.data('stars') != undefined) {
29
+ this.options.stars = element.data('stars');
30
+ }
31
+ if (element.data('showHint') != undefined) {
32
+ this.options.showHint = element.data('showHint');
33
+ }
34
+ if (element.data('static') != undefined) {
35
+ this.options.static = element.data('static');
36
+ }
37
+ if (element.data('showScore') != undefined) {
38
+ this.options.showScore = element.data('showScore');
39
+ }
40
+ if (element.data('scoreHint') != undefined) {
41
+ this.options.scoreHint = element.data('scoreHint');
42
+ }
43
+
44
+ this._showRating();
45
+ },
46
+
47
+ rate: function(value){
48
+ this.options.score = value;
49
+ this._showRating();
50
+ },
51
+
52
+ _showRating: function(){
53
+ var that = this,
54
+ element = this.element,
55
+ options = this.options,
56
+ ul, li;
57
+
58
+ element.addClass("rating");
59
+ element.html('');
60
+ ul = $("<ul/>");
61
+
62
+ if (!options.static){
63
+ element.addClass("active");
64
+ }
65
+
66
+ for(var i=0; i<options.stars;i++){
67
+ li = $("<li/>"); li.data('value', i+1);
68
+
69
+ if (options.showHint) li.attr('title', options.hints[i]);
70
+
71
+ if (i <= options.score - 1) {
72
+ li.addClass("rated");
73
+ }
74
+ li.on("click", function(){
75
+ options.click($(this).data('value'), that);
76
+ });
77
+ li.appendTo(ul);
78
+ }
79
+
80
+ ul.appendTo(element);
81
+
82
+ if (options.showScore) {
83
+ $("<span/>").addClass('score-hint').html(options.scoreHint+options.score).appendTo(element);
84
+ element.css('height', 'auto');
85
+ } else {
86
+ element.find('ul').css('margin-bottom', 0);
87
+ }
88
+ },
89
+
90
+ _destroy: function(){
91
+
92
+ },
93
+
94
+ _setOption: function(key, value){
95
+ this._super('_setOption', key, value);
96
+ }
97
+ })
98
+ })( jQuery );
99
+
@@ -0,0 +1,756 @@
1
+ (function( $ ) {
2
+ $.widget("metro.scrollbar", {
3
+
4
+ version: "1.0.0",
5
+
6
+ options: {
7
+ height: '100%', /* '100%'|int */
8
+ width: '100%', /* '100%'|int */
9
+ axis: ['x','y'], /* x|y|[x,y] */
10
+ wheel: 55 /* step in px */
11
+ //size: 'auto' /* 'auto'|int */
12
+ },
13
+ startSize: {
14
+ width: null,
15
+ height: null
16
+ },
17
+ elemPadding: false,
18
+ bothScroll: false,
19
+ scrollbar: null,
20
+ contentHeight: 0,
21
+ contentWidth: 0,
22
+ contentMinHeight: 0,
23
+ contentMinWidth: 0,
24
+ dragElem: null,
25
+ dragStart: false,
26
+ startCoords: {
27
+ x:0,
28
+ y:0
29
+ },
30
+ currCoords: {
31
+ x:0,
32
+ y:0
33
+ },
34
+ handlers: false,
35
+
36
+ _create: function() {
37
+ var elem = this.element;
38
+ var that = this;
39
+ if(elem.data('scroll') != undefined) {
40
+ var dataScroll = elem.data('scroll');
41
+ if(dataScroll == 'vertical') {
42
+ this.options.axis = 'y';
43
+ }
44
+ if(dataScroll == 'horizontal') {
45
+ this.options.axis = 'x';
46
+ }
47
+ if(dataScroll == 'both') {
48
+ this.options.axis = ['x','y'];
49
+ }
50
+ }
51
+ if(elem.data('height') != undefined) {
52
+ this.options.height = elem.data('height');
53
+ }
54
+ if(elem.data('width') != undefined) {
55
+ this.options.width = elem.data('width');
56
+ }
57
+ if(elem.data('wheel') != undefined) {
58
+ this.options.wheel = elem.data('wheel');
59
+ }
60
+
61
+ elem.css({
62
+ position: 'relative'
63
+ });
64
+
65
+ var width = elem.outerWidth();
66
+ var height = elem.outerHeight();
67
+
68
+ this.contentMinWidth = width;
69
+ this.contentMinHeight = height;
70
+
71
+ this.startSize.width = this.options.width;
72
+ this.startSize.height = this.options.height;
73
+
74
+ var sw = (this.startSize.width == parseInt(this.startSize.width)) ? this.startSize.width+'px' : this.startSize.width;
75
+ var sh = (this.startSize.height == parseInt(this.startSize.height)) ? this.startSize.height+'px' : this.startSize.height;
76
+
77
+ elem.wrap('<div class="scrollbar" style="width: '+sw+'; height: '+sh+';"></div>');
78
+ this.scrollbar = elem.parents('.scrollbar').first();
79
+
80
+ this.scrollbar.parents().first().css({
81
+ overflow: 'hidden'
82
+ });
83
+
84
+ this._build(width,height);
85
+
86
+ $(window).resize(function () {
87
+ that._resize();
88
+ });
89
+ },
90
+
91
+ _resize: function () {
92
+ var elem = this.element;
93
+
94
+ if( (!isNaN(parseInt(this.element.css('left'))) && parseInt(this.element.css('left')) != 0) || (!isNaN(parseInt(this.element.css('top'))) && parseInt(this.element.css('top'))) ) {
95
+ var l = Math.abs(parseInt(this.element.css('left')));
96
+ var t = Math.abs(parseInt(this.element.css('top')));
97
+
98
+ var w = this.scrollbar.width();
99
+ var h = this.scrollbar.height();
100
+
101
+ if(this.contentWidth - l < w) {
102
+ l = l - (w-(this.contentWidth - l));
103
+ if(l<0) {
104
+ l = 0;
105
+ }
106
+ this.element.css('left',l*(-1));
107
+ }
108
+ this.element.css('left',l*(-1));
109
+ if(this.contentHeight - t < h) {
110
+ t = t - (h-(this.contentHeight - t));
111
+ if(t<0) {
112
+ t = 0;
113
+ }
114
+ this.element.css('top',t*(-1));
115
+ }
116
+ }
117
+
118
+ this.options.width = this.startSize.width;
119
+ this.options.height = this.startSize.height;
120
+
121
+ this.scrollbar.css({
122
+ padding: 0
123
+ });
124
+ if(this.elemPadding) {
125
+ this.element.css({
126
+ paddingRight: '-=5',
127
+ paddingBottom: '-=5'
128
+ });
129
+ this.elemPadding = false;
130
+ }
131
+
132
+ if(this.scrollbar.find('.scrollbar-v').length>0) {
133
+ this.scrollbar.find('.scrollbar-v').remove();
134
+ }
135
+ if(this.scrollbar.find('.scrollbar-h').length>0) {
136
+ this.scrollbar.find('.scrollbar-h').remove();
137
+ }
138
+ if(this.scrollbar.find('.scrollbar-both').length>0) {
139
+ this.scrollbar.find('.scrollbar-both').remove();
140
+ }
141
+
142
+ var width = elem.outerWidth();
143
+ var height = elem.outerHeight();
144
+
145
+ this.contentWidth = width;
146
+ this.contentHeight = height;
147
+ this._removeHandlers();
148
+ this._build(width,height);
149
+ },
150
+ _build: function (width,height) {
151
+ var elem = this.element;
152
+
153
+ this.options.width = (this.options.width == '100%') ? this.scrollbar.outerWidth() : this.options.width;
154
+ this.options.height = (this.options.height == '100%') ? this.scrollbar.outerHeight() : this.options.height;
155
+
156
+ this.scrollbar.css({
157
+ width: this.startSize.width,
158
+ height: this.startSize.height
159
+ });
160
+
161
+ this.contentWidth = width;
162
+ this.contentHeight = height;
163
+
164
+ if(this.options.axis == 'y') {
165
+ /* vertical */
166
+ if(this.contentHeight>this.options.height) {
167
+ this.scrollbar.css({
168
+ paddingRight: 20,
169
+ paddingBottom: 0
170
+ });
171
+ var width = elem.outerWidth();
172
+ var height = elem.outerHeight();
173
+ this.contentWidth = width;
174
+ this.contentHeight = height;
175
+
176
+ this._verticalScrollbar();
177
+ this._startHandlers();
178
+ }
179
+ else {
180
+ if(this.scrollbar.find('.scrollbar-v').length>0) {
181
+ this.scrollbar.find('.scrollbar-v').hide();
182
+ }
183
+ this.scrollbar.css({
184
+ paddingRight: 0,
185
+ paddingBottom: 0
186
+ });
187
+ }
188
+
189
+ }
190
+ else if(this.options.axis == 'x') {
191
+ /* horizontal */
192
+ if(this.contentWidth>this.options.width) {
193
+ if(this.startSize.height == '100%') {
194
+ this.scrollbar.css({
195
+ paddingBottom: 20,
196
+ paddingRight: 0
197
+ });
198
+ var width = elem.outerWidth();
199
+ var height = elem.outerHeight();
200
+ this.contentWidth = width;
201
+ this.contentHeight = height;
202
+ }
203
+
204
+ this._horizontalScrollbar();
205
+ this._startHandlers();
206
+ }
207
+ else {
208
+ if(this.scrollbar.find('.scrollbar-h').length>0) {
209
+ this.scrollbar.find('.scrollbar-h').hide();
210
+ }
211
+ this.scrollbar.css({
212
+ paddingBottom: 0,
213
+ paddingRight: 0
214
+ });
215
+ }
216
+ }
217
+ else {
218
+ /* both */
219
+ if(this.contentHeight>this.options.height && this.contentWidth>this.options.width) {
220
+
221
+ this.bothScroll = true;
222
+ if(this.scrollbar.find('.scrollbar-both').length>0) {
223
+ this.scrollbar.find('.scrollbar-both').show();
224
+ }
225
+ else {
226
+ this.scrollbar.append('<div class="scrollbar-both"></div>');
227
+ }
228
+
229
+ if(!this.elemPadding) {
230
+ this.element.css({
231
+ paddingRight: '+=5',
232
+ paddingBottom: '+=5'
233
+ });
234
+ this.elemPadding = true;
235
+ }
236
+
237
+
238
+ var width = elem.outerWidth();
239
+ var height = elem.outerHeight();
240
+ this.contentWidth = width;
241
+ this.contentHeight = height;
242
+
243
+ this._verticalScrollbar();
244
+ this._horizontalScrollbar();
245
+ this._startHandlers();
246
+ }
247
+ else {
248
+ this.bothScroll = false;
249
+ if(this.scrollbar.find('.scrollbar-both').length>0) {
250
+ this.scrollbar.find('.scrollbar-both').hide();
251
+ }
252
+ if(this.elemPadding) {
253
+ this.element.css({
254
+ paddingRight: '-=5',
255
+ paddingBottom: '-=5'
256
+ });
257
+ this.elemPadding = false;
258
+ }
259
+ if(this.contentWidth>this.options.width) {
260
+ if(this.startSize.height == '100%') {
261
+ this.scrollbar.css({
262
+ paddingBottom: 20,
263
+ paddingRight: 0
264
+ });
265
+ var width = elem.outerWidth();
266
+ var height = elem.outerHeight();
267
+ this.contentWidth = width;
268
+ this.contentHeight = height;
269
+ }
270
+
271
+ this._horizontalScrollbar();
272
+ this._startHandlers();
273
+ }
274
+ else {
275
+ if(this.scrollbar.find('.scrollbar-h').length>0) {
276
+ this.scrollbar.find('.scrollbar-h').hide();
277
+ }
278
+ this.scrollbar.css({
279
+ paddingBottom: 0,
280
+ paddingRight: 0
281
+ });
282
+ }
283
+ if(this.contentHeight>this.options.height) {
284
+ this.scrollbar.css({
285
+ paddingRight: 20,
286
+ paddingBottom: 0
287
+ });
288
+ var width = elem.outerWidth();
289
+ var height = elem.outerHeight();
290
+ this.contentWidth = width;
291
+ this.contentHeight = height;
292
+
293
+ this._verticalScrollbar();
294
+ this._startHandlers();
295
+ }
296
+ else {
297
+ if(this.scrollbar.find('.scrollbar-v').length>0) {
298
+ this.scrollbar.find('.scrollbar-v').hide();
299
+ }
300
+ this.scrollbar.css({
301
+ paddingRight: 0,
302
+ paddingBottom: 0
303
+ });
304
+ }
305
+ }
306
+ }
307
+ },
308
+ _verticalScrollbar: function () {
309
+ if(this.scrollbar.find('.scrollbar-v').length<1) {
310
+ var str = [];
311
+ str[str.length] = '<div class="scrollbar-v">';
312
+ str[str.length] = '<div class="scrollbar-v-up"></div>';
313
+ str[str.length] = '<div class="scrollbar-v-down"></div>';
314
+ str[str.length] = '<div class="scrollbar-line-v">';
315
+ str[str.length] = '<div class="scrollbar-line-v-btn"></div>';
316
+ str[str.length] = '</div>';
317
+ str[str.length] = '</div>';
318
+ str = str.join('');
319
+
320
+ this.scrollbar.append(str);
321
+ }
322
+ else {
323
+ this.scrollbar.find('.scrollbar-v').show();
324
+ }
325
+
326
+ var line = this.scrollbar.find('.scrollbar-line-v');
327
+ var btn = this.scrollbar.find('.scrollbar-line-v-btn');
328
+ var scrollBar = this.scrollbar.find('.scrollbar-v');
329
+
330
+ if(this.bothScroll) {
331
+ scrollBar.height(this.options.height);
332
+ var h = scrollBar.height()-15;
333
+ this.options.height = h;
334
+ scrollBar.height(h);
335
+ }
336
+ else {
337
+ scrollBar.height(this.options.height);
338
+ }
339
+
340
+ var height = this.options.height-32;
341
+ var ratio = height/this.contentHeight;
342
+
343
+ line.height(height);
344
+
345
+ if(ratio>=(this.contentHeight-32)/this.contentHeight) {
346
+ btn.hide();
347
+ }
348
+ else {
349
+ var btnHeight = ratio*this.options.height;
350
+ btn.show().height(btnHeight);
351
+ }
352
+ },
353
+ _horizontalScrollbar: function () {
354
+ if(this.scrollbar.find('.scrollbar-h').length<1) {
355
+ var str = [];
356
+ str[str.length] = '<div class="scrollbar-h">';
357
+ str[str.length] = '<div class="scrollbar-h-up"></div>';
358
+ str[str.length] = '<div class="scrollbar-h-down"></div>';
359
+ str[str.length] = '<div class="scrollbar-line-h">';
360
+ str[str.length] = '<div class="scrollbar-line-h-btn"></div>';
361
+ str[str.length] = '</div>';
362
+ str[str.length] = '</div>';
363
+ str = str.join('');
364
+
365
+ this.scrollbar.append(str);
366
+ }
367
+ else {
368
+ this.scrollbar.find('.scrollbar-h').show();
369
+ }
370
+
371
+ var line = this.scrollbar.find('.scrollbar-line-h');
372
+ var btn = this.scrollbar.find('.scrollbar-line-h-btn');
373
+ var scrollBar = this.scrollbar.find('.scrollbar-h');
374
+
375
+ if(this.bothScroll) {
376
+ scrollBar.width(this.options.width);
377
+ var w = scrollBar.width()-15;
378
+ this.options.width = w;
379
+ scrollBar.width(w);
380
+ }
381
+ else {
382
+ scrollBar.width(this.options.width);
383
+ }
384
+
385
+ var width = this.options.width-32;
386
+ var ratio = width/this.contentWidth;
387
+ var btnWidth = ratio*this.options.width;
388
+ var l = (!isNaN(parseInt(this.element.css('left')))) ? parseInt(this.element.css('left')) : 0;
389
+ var left = Math.abs(l)*ratio;
390
+
391
+ line.width(width);
392
+ if(ratio>=(this.contentWidth-32)/this.contentWidth) {
393
+ btn.hide();
394
+ }
395
+ else {
396
+ btn.show().width(btnWidth).css({
397
+ left:left
398
+ });
399
+ }
400
+ },
401
+
402
+ _startHandlers: function () {
403
+ if(this.handlers) {
404
+ return false;
405
+ }
406
+ this.handlers = true;
407
+ var that = this;
408
+ $(document).mousemove(function(e){
409
+ that._drag(e);
410
+ });
411
+ $(document).mouseup(function(e){
412
+ that._dragEnd(e);
413
+ });
414
+ this.scrollbar.find('.scrollbar-line-v-btn,.scrollbar-line-h-btn').on('mousedown', function(e){
415
+ that._dragStart(e, $(this));
416
+ });
417
+ this.scrollbar.find('.scrollbar-line-v,.scrollbar-line-h').on('click', function(e){
418
+ that._clickPos(e, $(this));
419
+ });
420
+ this.scrollbar.find('.scrollbar-v-up,.scrollbar-h-up').on('click', function(e){
421
+ that._fixScroll(1,$(this));
422
+ });
423
+ this.scrollbar.find('.scrollbar-v-down,.scrollbar-h-down').on('click', function(e){
424
+ that._fixScroll(-1,$(this));
425
+ });
426
+ this.scrollbar.mousewheel(function(e, delta) {
427
+ that._fixScroll(delta);
428
+ return false;
429
+ });
430
+ },
431
+ _removeHandlers: function () {
432
+ if(!this.handlers) {
433
+ return false;
434
+ }
435
+ this.handlers = false;
436
+ var that = this;
437
+ $(document).mousemove(function(e){
438
+ return false;
439
+ });
440
+ $(document).mouseup(function(e){
441
+ return false;
442
+ });
443
+ this.scrollbar.find('.scrollbar-line-v-btn,.scrollbar-line-h-btn').off('mousedown');
444
+ this.scrollbar.find('.scrollbar-line-v,.scrollbar-line-h').off('click');
445
+ this.scrollbar.find('.scrollbar-v-up,.scrollbar-h-up').off('click');
446
+ this.scrollbar.find('.scrollbar-v-down,.scrollbar-h-down').off('click');
447
+ },
448
+
449
+ _clickPos: function (e,elem) {
450
+ if($(e.target).attr('class') == 'scrollbar-line-v' || $(e.target).attr('class') == 'scrollbar-line-h') {
451
+ var offset = elem.offset();
452
+ if($(e.target).attr('class') == 'scrollbar-line-v') {
453
+ var top = e.pageY - offset.top;
454
+
455
+ var btn = elem.find('.scrollbar-line-v-btn');
456
+
457
+ this.dragElem = {
458
+ elem: btn,
459
+ width: btn.width(),
460
+ height: btn.height(),
461
+ parent: elem,
462
+ parentWidth: elem.width(),
463
+ parentHeight: elem.height(),
464
+ parentOffset: offset
465
+ };
466
+
467
+ this._scrollTo(0,top,'y');
468
+
469
+ this.dragElem = null;
470
+ }
471
+ else {
472
+ var left = e.pageX - offset.left;
473
+
474
+ var btn = elem.find('.scrollbar-line-h-btn');
475
+
476
+ this.dragElem = {
477
+ elem: btn,
478
+ width: btn.width(),
479
+ height: btn.height(),
480
+ parent: elem,
481
+ parentWidth: elem.width(),
482
+ parentHeight: elem.height(),
483
+ parentOffset: offset
484
+ };
485
+
486
+ this._scrollTo(left,0,'x');
487
+
488
+ this.dragElem = null;
489
+ }
490
+ }
491
+ },
492
+ _fixScroll: function (delta,elem) {
493
+ var step = this.options.wheel;
494
+ if( (elem !== undefined && (elem.hasClass('scrollbar-h-up') || elem.hasClass('scrollbar-h-down'))) || this.options.axis == 'x' || (this.options.axis != 'x' && this.options.axis != 'y' && this.scrollbar.find('.scrollbar-v').length<1)) {
495
+ var percent = step/this.contentWidth*100;
496
+ var barStep = (this.options.width-32)/100*percent;
497
+ var leftCss = parseInt(this.element.css('left'));
498
+ var pos = (!isNaN(leftCss)) ? Math.abs(leftCss) : 0;
499
+
500
+ var btn = this.scrollbar.find('.scrollbar-line-h-btn');
501
+ var parent = this.scrollbar.find('.scrollbar-line-h');
502
+
503
+ var barLeftCss = parseFloat(btn.css('left'));
504
+ var barPos = (!isNaN(barLeftCss)) ? barLeftCss : 0;
505
+
506
+ if(delta>0) {
507
+ var left = pos-step;
508
+ var barLeft = barPos-barStep;
509
+ }
510
+ else {
511
+ var left = pos+step;
512
+ var barLeft = barPos+barStep;
513
+ }
514
+
515
+ if(left<0) {
516
+ left = 0;
517
+ }
518
+ if(left>this.contentWidth-this.options.width) {
519
+ left = this.contentWidth-this.options.width;
520
+ }
521
+
522
+ var parentsSize = {
523
+ width: parent.width(),
524
+ height: parent.height()
525
+ };
526
+ var dragElemSize = {
527
+ width: btn.width(),
528
+ height: btn.height()
529
+ };
530
+ if(barLeft<0) {
531
+ barLeft = 0;
532
+ }
533
+ if(barLeft+dragElemSize.width>parentsSize.width) {
534
+ barLeft = parentsSize.width-dragElemSize.width;
535
+ }
536
+
537
+ this.element.css({
538
+ left: left*(-1)
539
+ });
540
+ btn.css({
541
+ left: barLeft
542
+ });
543
+ }
544
+ else {
545
+ var percent = step/this.contentHeight*100;
546
+ var barStep = (this.options.height-32)/100*percent;
547
+ var topCss = parseInt(this.element.css('top'));
548
+ var pos = (!isNaN(topCss)) ? Math.abs(topCss) : 0;
549
+
550
+ var btn = this.scrollbar.find('.scrollbar-line-v-btn');
551
+ var parent = this.scrollbar.find('.scrollbar-line-v');
552
+
553
+ var barTopCss = parseFloat(btn.css('top'));
554
+ var barPos = (!isNaN(barTopCss)) ? barTopCss : 0;
555
+
556
+ if(delta>0) {
557
+ var top = pos-step;
558
+ var barTop = barPos-barStep;
559
+ }
560
+ else {
561
+ var top = pos+step;
562
+ var barTop = barPos+barStep;
563
+ }
564
+
565
+ if(top<0) {
566
+ top = 0;
567
+ }
568
+ if(top>this.contentHeight-this.options.height) {
569
+ top = this.contentHeight-this.options.height;
570
+ }
571
+
572
+ var parentsSize = {
573
+ width: parent.width(),
574
+ height: parent.height()
575
+ };
576
+ var dragElemSize = {
577
+ width: btn.width(),
578
+ height: btn.height()
579
+ };
580
+ if(barTop<0) {
581
+ barTop = 0;
582
+ }
583
+ if(barTop+dragElemSize.height>parentsSize.height) {
584
+ barTop = parentsSize.height-dragElemSize.height;
585
+ }
586
+
587
+ this.element.css({
588
+ top: top*(-1)
589
+ });
590
+ btn.css({
591
+ top: barTop
592
+ });
593
+ }
594
+ },
595
+ _scrollTo: function (left,top,xy) {
596
+ if(xy == 'x') {
597
+ var width = this.options.width-32;
598
+ var ratio = width/this.contentWidth;
599
+
600
+ var currLeft = left/ratio;
601
+
602
+ if(currLeft<0) {
603
+ currLeft = 0;
604
+ }
605
+ if(currLeft>this.contentWidth-this.options.width) {
606
+ currLeft = this.contentWidth-this.options.width;
607
+ }
608
+ if(left<0) {
609
+ left = 0;
610
+ }
611
+ if(left>this.dragElem.parentWidth-this.dragElem.width) {
612
+ left = this.dragElem.parentWidth-this.dragElem.width;
613
+ }
614
+
615
+ this.dragElem.elem.css({
616
+ left:left
617
+ });
618
+ this.element.css({
619
+ left: currLeft*(-1)
620
+ });
621
+ }
622
+ else {
623
+ var height = this.options.height-32;
624
+ var ratio = height/this.contentHeight;
625
+
626
+ var currTop = top/ratio;
627
+ if(currTop<0) {
628
+ currTop = 0;
629
+ }
630
+ if(currTop>this.contentHeight-this.options.height) {
631
+ currTop = this.contentHeight-this.options.height;
632
+ }
633
+ if(top<0) {
634
+ top = 0;
635
+ }
636
+ if(top>this.dragElem.parentHeight-this.dragElem.height) {
637
+ top = this.dragElem.parentHeight-this.dragElem.height;
638
+ }
639
+
640
+ this.dragElem.elem.css({
641
+ top:top
642
+ });
643
+
644
+ this.element.css({
645
+ top: currTop*(-1)
646
+ });
647
+ }
648
+ },
649
+ _scroll: function () {
650
+ if(this.dragElem.elem.hasClass('scrollbar-line-h-btn')) {
651
+ var width = this.options.width-32;
652
+ var ratio = width/this.contentWidth;
653
+
654
+ var leftCss = parseInt(this.dragElem.elem.css('left'));
655
+ var leftCurr = (!isNaN(leftCss)) ? Math.abs(leftCss) : 0;
656
+ var left = leftCurr/ratio;
657
+
658
+ if(left<0) {
659
+ left = 0;
660
+ }
661
+ if(left>this.contentWidth-this.options.width) {
662
+ left = this.contentWidth-this.options.width;
663
+ }
664
+
665
+ this.element.css({
666
+ left: left*(-1)
667
+ });
668
+ }
669
+ else {
670
+ var height = this.options.height-32;
671
+ var ratio = height/this.contentHeight;
672
+
673
+ var topCss = parseInt(this.dragElem.elem.css('top'));
674
+ var topCurr = (!isNaN(topCss)) ? Math.abs(topCss) : 0;
675
+ var top = topCurr/ratio;
676
+ if(top<0) {
677
+ top = 0;
678
+ }
679
+ if(top>this.contentHeight-this.options.height) {
680
+ top = this.contentHeight-this.options.height;
681
+ }
682
+
683
+ this.element.css({
684
+ top: top*(-1)
685
+ });
686
+ }
687
+ },
688
+
689
+ _startCoordsDiff: function (e) {
690
+ var offset = this.dragElem.elem.offset();
691
+ this.startCoords.x = e.pageX - offset.left;
692
+ this.startCoords.y = e.pageY - offset.top;
693
+ },
694
+ _dragStart: function (e,elem) {
695
+ var parent = elem.parents().first();
696
+ this.dragElem = {
697
+ elem: elem,
698
+ width: elem.width(),
699
+ height: elem.height(),
700
+ parent: parent,
701
+ parentWidth: parent.width(),
702
+ parentHeight: parent.height(),
703
+ parentOffset: parent.offset()
704
+ };
705
+ this.dragStart = true;
706
+ this.currCoords.x = e.pageX;
707
+ this.currCoords.y = e.pageY;
708
+
709
+ this._startCoordsDiff(e);
710
+ },
711
+ _drag: function (e) {
712
+ if( this.dragStart ) {
713
+ this.currCoords.x = e.pageX;
714
+ this.currCoords.y = e.pageY;
715
+ var left = this.currCoords.x - this.startCoords.x - this.dragElem.parentOffset.left;
716
+ var top = this.currCoords.y - this.startCoords.y - this.dragElem.parentOffset.top;
717
+ if(left<0) {
718
+ left = 0;
719
+ }
720
+ if(left+this.dragElem.width>=this.dragElem.parentWidth) {
721
+ left = this.dragElem.parentWidth-this.dragElem.width;
722
+ }
723
+
724
+ if(top<0) {
725
+ top = 0;
726
+ }
727
+ if(top+this.dragElem.height>this.dragElem.parentHeight) {
728
+ top = this.dragElem.parentHeight-this.dragElem.height;
729
+ }
730
+ this.dragElem.elem.css({
731
+ left: left,
732
+ top: top
733
+ });
734
+ this._scroll();
735
+ }
736
+ },
737
+ _dragEnd: function (e) {
738
+ if(this.dragStart) {
739
+ this.dragElem = null;
740
+ this.dragStart = false;
741
+ this.startCoords.x = 0;
742
+ this.startCoords.y = 0;
743
+ this.currCoords.x = null;
744
+ this.currCoords.y = null;
745
+ }
746
+ },
747
+
748
+ _destroy: function() {
749
+
750
+ },
751
+ _setOption: function(key, value) {
752
+ this._super('_setOption', key, value);
753
+ }
754
+ })
755
+ })( jQuery );
756
+