lolita-file-upload 0.6.2 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/VERSION +1 -1
  2. data/app/assets/images/lolita/{upload → file-upload}/back.png +0 -0
  3. data/app/assets/images/lolita/{upload → file-upload}/delete.png +0 -0
  4. data/app/assets/images/lolita/{upload → file-upload}/edit.png +0 -0
  5. data/app/assets/images/lolita/{upload → file-upload}/next.png +0 -0
  6. data/app/assets/images/lolita/{upload → file-upload}/prev.png +0 -0
  7. data/app/assets/images/lolita/{upload → file-upload}/save.png +0 -0
  8. data/app/assets/javascripts/lolita/file-upload/application.js +1 -0
  9. data/app/assets/javascripts/lolita/file-upload/gallery.js.coffee +129 -0
  10. data/app/assets/stylesheets/lolita/file-upload/application.css +4 -0
  11. data/app/assets/stylesheets/lolita/file-upload/gallery.css +26 -0
  12. data/{vendor/assets/stylesheets/lolita/upload/lolita_file_upload.css.scss → app/assets/stylesheets/lolita/file-upload/uploader.css.erb} +7 -7
  13. data/app/views/components/lolita/configuration/tab/files/_cells.html.erb +2 -2
  14. data/app/views/components/lolita/configuration/tab/files/_file.html.erb +1 -1
  15. data/app/views/components/lolita/configuration/tab/files/_fixed_gallery.html.haml +14 -32
  16. data/app/views/components/lolita/configuration/tab/files/_image.html.erb +3 -1
  17. data/app/views/components/lolita/configuration/tab/files/_row.html.erb +3 -1
  18. data/app/views/components/lolita/configuration/tab/files/_upload_script.html.erb +2 -2
  19. data/config/locales/en.yml +9 -0
  20. data/config/locales/lv.yml +7 -0
  21. data/lib/lolita-file-upload.rb +4 -11
  22. data/lib/lolita-file-upload/rails.rb +5 -5
  23. data/lolita-file-upload.gemspec +37 -29
  24. data/vendor/assets/images/lolita/file-upload/elastislide/nav.png +0 -0
  25. data/vendor/assets/images/lolita/file-upload/elastislide/pattern.png +0 -0
  26. data/vendor/assets/images/lolita/{upload → file-upload}/plupload/backgrounds.gif +0 -0
  27. data/vendor/assets/images/lolita/{upload → file-upload}/plupload/buttons-disabled.png +0 -0
  28. data/vendor/assets/images/lolita/{upload → file-upload}/plupload/buttons.png +0 -0
  29. data/vendor/assets/images/lolita/{upload → file-upload}/plupload/delete.gif +0 -0
  30. data/vendor/assets/images/lolita/{upload → file-upload}/plupload/done.gif +0 -0
  31. data/vendor/assets/images/lolita/{upload → file-upload}/plupload/error.gif +0 -0
  32. data/vendor/assets/images/lolita/{upload → file-upload}/plupload/plupload-bw.png +0 -0
  33. data/vendor/assets/images/lolita/{upload → file-upload}/plupload/plupload.png +0 -0
  34. data/vendor/assets/images/lolita/{upload → file-upload}/plupload/throbber.gif +0 -0
  35. data/vendor/assets/images/lolita/{upload → file-upload}/plupload/transp50.png +0 -0
  36. data/vendor/assets/javascripts/lolita/{upload → file-upload}/I18n/lv.js +0 -0
  37. data/vendor/assets/javascripts/lolita/{upload → file-upload}/I18n/ru.js +0 -0
  38. data/vendor/assets/javascripts/lolita/file-upload/application_vendor.js +13 -0
  39. data/vendor/assets/javascripts/lolita/file-upload/jquery.easing.1.3.js +205 -0
  40. data/vendor/assets/javascripts/lolita/file-upload/jquery.elastislide.js +358 -0
  41. data/vendor/assets/javascripts/lolita/{upload → file-upload}/jquery.ui.plupload.js +0 -0
  42. data/vendor/assets/javascripts/lolita/{upload → file-upload}/plupload.flash.swf +0 -0
  43. data/vendor/assets/javascripts/lolita/{upload → file-upload}/plupload.full.js +0 -0
  44. data/vendor/assets/stylesheets/lolita/file-upload/application_vendor.css +4 -0
  45. data/vendor/assets/stylesheets/lolita/file-upload/elastislide.css.erb +53 -0
  46. data/vendor/assets/stylesheets/lolita/{upload → file-upload}/jquery.ui.plupload.css.erb +2 -2
  47. data/vendor/assets/stylesheets/lolita/{upload → file-upload}/plupload.queue.css +10 -10
  48. metadata +38 -30
  49. data/app/views/components/lolita/configuration/field/string/text_gallery/_display.html.haml +0 -20
  50. data/vendor/assets/javascripts/lolita/upload/application_vendor.js +0 -11
  51. data/vendor/assets/stylesheets/lolita/upload/application_vendor.css +0 -5
@@ -0,0 +1,13 @@
1
+ //= require jquery-ui
2
+ //= require lolita/file-upload/plupload.full
3
+ //= require lolita/file-upload/jquery.ui.plupload
4
+ //= require lolita/file-upload/jquery.easing.1.3
5
+ //= require lolita/file-upload/jquery.elastislide
6
+
7
+ $(document).ready(function(){
8
+ $(document).on("click", ".file-editor a.save", function(event) {
9
+ $(this).closest("form").submit();
10
+ return false;
11
+ });
12
+ });
13
+
@@ -0,0 +1,205 @@
1
+ /*
2
+ * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
3
+ *
4
+ * Uses the built in easing capabilities added In jQuery 1.1
5
+ * to offer multiple easing options
6
+ *
7
+ * TERMS OF USE - jQuery Easing
8
+ *
9
+ * Open source under the BSD License.
10
+ *
11
+ * Copyright © 2008 George McGinley Smith
12
+ * All rights reserved.
13
+ *
14
+ * Redistribution and use in source and binary forms, with or without modification,
15
+ * are permitted provided that the following conditions are met:
16
+ *
17
+ * Redistributions of source code must retain the above copyright notice, this list of
18
+ * conditions and the following disclaimer.
19
+ * Redistributions in binary form must reproduce the above copyright notice, this list
20
+ * of conditions and the following disclaimer in the documentation and/or other materials
21
+ * provided with the distribution.
22
+ *
23
+ * Neither the name of the author nor the names of contributors may be used to endorse
24
+ * or promote products derived from this software without specific prior written permission.
25
+ *
26
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
27
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
31
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
32
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
34
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
35
+ *
36
+ */
37
+
38
+ // t: current time, b: begInnIng value, c: change In value, d: duration
39
+ jQuery.easing['jswing'] = jQuery.easing['swing'];
40
+
41
+ jQuery.extend( jQuery.easing,
42
+ {
43
+ def: 'easeOutQuad',
44
+ swing: function (x, t, b, c, d) {
45
+ //alert(jQuery.easing.default);
46
+ return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
47
+ },
48
+ easeInQuad: function (x, t, b, c, d) {
49
+ return c*(t/=d)*t + b;
50
+ },
51
+ easeOutQuad: function (x, t, b, c, d) {
52
+ return -c *(t/=d)*(t-2) + b;
53
+ },
54
+ easeInOutQuad: function (x, t, b, c, d) {
55
+ if ((t/=d/2) < 1) return c/2*t*t + b;
56
+ return -c/2 * ((--t)*(t-2) - 1) + b;
57
+ },
58
+ easeInCubic: function (x, t, b, c, d) {
59
+ return c*(t/=d)*t*t + b;
60
+ },
61
+ easeOutCubic: function (x, t, b, c, d) {
62
+ return c*((t=t/d-1)*t*t + 1) + b;
63
+ },
64
+ easeInOutCubic: function (x, t, b, c, d) {
65
+ if ((t/=d/2) < 1) return c/2*t*t*t + b;
66
+ return c/2*((t-=2)*t*t + 2) + b;
67
+ },
68
+ easeInQuart: function (x, t, b, c, d) {
69
+ return c*(t/=d)*t*t*t + b;
70
+ },
71
+ easeOutQuart: function (x, t, b, c, d) {
72
+ return -c * ((t=t/d-1)*t*t*t - 1) + b;
73
+ },
74
+ easeInOutQuart: function (x, t, b, c, d) {
75
+ if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
76
+ return -c/2 * ((t-=2)*t*t*t - 2) + b;
77
+ },
78
+ easeInQuint: function (x, t, b, c, d) {
79
+ return c*(t/=d)*t*t*t*t + b;
80
+ },
81
+ easeOutQuint: function (x, t, b, c, d) {
82
+ return c*((t=t/d-1)*t*t*t*t + 1) + b;
83
+ },
84
+ easeInOutQuint: function (x, t, b, c, d) {
85
+ if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
86
+ return c/2*((t-=2)*t*t*t*t + 2) + b;
87
+ },
88
+ easeInSine: function (x, t, b, c, d) {
89
+ return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
90
+ },
91
+ easeOutSine: function (x, t, b, c, d) {
92
+ return c * Math.sin(t/d * (Math.PI/2)) + b;
93
+ },
94
+ easeInOutSine: function (x, t, b, c, d) {
95
+ return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
96
+ },
97
+ easeInExpo: function (x, t, b, c, d) {
98
+ return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
99
+ },
100
+ easeOutExpo: function (x, t, b, c, d) {
101
+ return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
102
+ },
103
+ easeInOutExpo: function (x, t, b, c, d) {
104
+ if (t==0) return b;
105
+ if (t==d) return b+c;
106
+ if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
107
+ return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
108
+ },
109
+ easeInCirc: function (x, t, b, c, d) {
110
+ return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
111
+ },
112
+ easeOutCirc: function (x, t, b, c, d) {
113
+ return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
114
+ },
115
+ easeInOutCirc: function (x, t, b, c, d) {
116
+ if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
117
+ return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
118
+ },
119
+ easeInElastic: function (x, t, b, c, d) {
120
+ var s=1.70158;var p=0;var a=c;
121
+ if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
122
+ if (a < Math.abs(c)) { a=c; var s=p/4; }
123
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
124
+ return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
125
+ },
126
+ easeOutElastic: function (x, t, b, c, d) {
127
+ var s=1.70158;var p=0;var a=c;
128
+ if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
129
+ if (a < Math.abs(c)) { a=c; var s=p/4; }
130
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
131
+ return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
132
+ },
133
+ easeInOutElastic: function (x, t, b, c, d) {
134
+ var s=1.70158;var p=0;var a=c;
135
+ if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
136
+ if (a < Math.abs(c)) { a=c; var s=p/4; }
137
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
138
+ if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
139
+ return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
140
+ },
141
+ easeInBack: function (x, t, b, c, d, s) {
142
+ if (s == undefined) s = 1.70158;
143
+ return c*(t/=d)*t*((s+1)*t - s) + b;
144
+ },
145
+ easeOutBack: function (x, t, b, c, d, s) {
146
+ if (s == undefined) s = 1.70158;
147
+ return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
148
+ },
149
+ easeInOutBack: function (x, t, b, c, d, s) {
150
+ if (s == undefined) s = 1.70158;
151
+ if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
152
+ return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
153
+ },
154
+ easeInBounce: function (x, t, b, c, d) {
155
+ return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
156
+ },
157
+ easeOutBounce: function (x, t, b, c, d) {
158
+ if ((t/=d) < (1/2.75)) {
159
+ return c*(7.5625*t*t) + b;
160
+ } else if (t < (2/2.75)) {
161
+ return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
162
+ } else if (t < (2.5/2.75)) {
163
+ return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
164
+ } else {
165
+ return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
166
+ }
167
+ },
168
+ easeInOutBounce: function (x, t, b, c, d) {
169
+ if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
170
+ return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
171
+ }
172
+ });
173
+
174
+ /*
175
+ *
176
+ * TERMS OF USE - EASING EQUATIONS
177
+ *
178
+ * Open source under the BSD License.
179
+ *
180
+ * Copyright © 2001 Robert Penner
181
+ * All rights reserved.
182
+ *
183
+ * Redistribution and use in source and binary forms, with or without modification,
184
+ * are permitted provided that the following conditions are met:
185
+ *
186
+ * Redistributions of source code must retain the above copyright notice, this list of
187
+ * conditions and the following disclaimer.
188
+ * Redistributions in binary form must reproduce the above copyright notice, this list
189
+ * of conditions and the following disclaimer in the documentation and/or other materials
190
+ * provided with the distribution.
191
+ *
192
+ * Neither the name of the author nor the names of contributors may be used to endorse
193
+ * or promote products derived from this software without specific prior written permission.
194
+ *
195
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
196
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
197
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
198
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
199
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
200
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
201
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
202
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
203
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
204
+ *
205
+ */
@@ -0,0 +1,358 @@
1
+ (function( window, $, undefined ) {
2
+
3
+ $.elastislide = function( options, element ) {
4
+ this.$el = $( element );
5
+ this._init( options );
6
+ };
7
+
8
+ $.elastislide.defaults = {
9
+ speed : 450, // animation speed
10
+ easing : '', // animation easing effect
11
+ imageW : 190, // the images width
12
+ margin : 3, // image margin right
13
+ border : 2, // image border
14
+ minItems : 1, // the minimum number of items to show.
15
+ // when we resize the window, this will make sure minItems are always shown
16
+ // (unless of course minItems is higher than the total number of elements)
17
+ current : 0, // index of the current item
18
+ // when we resize the window, the carousel will make sure this item is visible
19
+ onClick : function() { return false; } // click item callback
20
+ };
21
+
22
+ $.elastislide.prototype = {
23
+ _init : function( options ) {
24
+
25
+ this.options = $.extend( true, {}, $.elastislide.defaults, options );
26
+
27
+ // <ul>
28
+ this.$slider = this.$el.find('ul');
29
+
30
+ // <li>
31
+ this.$items = this.$slider.children('li');
32
+
33
+ // total number of elements / images
34
+ this.itemsCount = this.$items.length;
35
+
36
+ // cache the <ul>'s parent, since we will eventually need to recalculate its width on window resize
37
+ this.$esCarousel = this.$slider.parent();
38
+
39
+ // validate options
40
+ this._validateOptions();
41
+
42
+ // set sizes and initialize some vars...
43
+ this._configure();
44
+
45
+ // add navigation buttons
46
+ this._addControls();
47
+
48
+ // initialize the events
49
+ this._initEvents();
50
+
51
+ // show the <ul>
52
+ this.$slider.show();
53
+
54
+ // slide to current's position
55
+ this._slideToCurrent( false );
56
+
57
+ },
58
+ _validateOptions : function() {
59
+
60
+ if( this.options.speed < 0 )
61
+ this.options.speed = 450;
62
+ if( this.options.margin < 0 )
63
+ this.options.margin = 4;
64
+ if( this.options.border < 0 )
65
+ this.options.border = 1;
66
+ if( this.options.minItems < 1 || this.options.minItems > this.itemsCount )
67
+ this.options.minItems = 1;
68
+ if( this.options.current > this.itemsCount - 1 )
69
+ this.options.current = 0;
70
+
71
+ },
72
+ _configure : function() {
73
+
74
+ // current item's index
75
+ this.current = this.options.current;
76
+
77
+ // the ul's parent's (div.es-carousel) width is the "visible" width
78
+ this.visibleWidth = this.$esCarousel.width();
79
+
80
+ // test to see if we need to initially resize the items
81
+ if( this.visibleWidth < this.options.minItems * ( this.options.imageW + 2 * this.options.border ) + ( this.options.minItems - 1 ) * this.options.margin ) {
82
+ this._setDim( ( this.visibleWidth - ( this.options.minItems - 1 ) * this.options.margin ) / this.options.minItems );
83
+ this._setCurrentValues();
84
+ // how many items fit with the current width
85
+ this.fitCount = this.options.minItems;
86
+ }
87
+ else {
88
+ this._setDim();
89
+ this._setCurrentValues();
90
+ }
91
+
92
+ // set the <ul> width
93
+ this.$slider.css({
94
+ width : this.sliderW
95
+ });
96
+
97
+ },
98
+ _setDim : function( elW ) {
99
+
100
+ // <li> style
101
+ this.$items.css({
102
+ marginRight : this.options.margin,
103
+ width : ( elW ) ? elW : this.options.imageW + 2 * this.options.border
104
+ }).children('a').css({ // <a> style
105
+ borderWidth : this.options.border
106
+ });
107
+
108
+ },
109
+ _setCurrentValues : function() {
110
+
111
+ // the total space occupied by one item
112
+ this.itemW = this.$items.outerWidth(true);
113
+
114
+ // total width of the slider / <ul>
115
+ // this will eventually change on window resize
116
+ this.sliderW = this.itemW * this.itemsCount;
117
+
118
+ // the ul parent's (div.es-carousel) width is the "visible" width
119
+ this.visibleWidth = this.$esCarousel.width();
120
+
121
+ // how many items fit with the current width
122
+ this.fitCount = Math.floor( this.visibleWidth / this.itemW );
123
+
124
+ },
125
+ _addControls : function() {
126
+
127
+ this.$navNext = $('<span class="es-nav-next">Next</span>');
128
+ this.$navPrev = $('<span class="es-nav-prev">Previous</span>');
129
+ $('<div class="es-nav"/>')
130
+ .append( this.$navPrev )
131
+ .append( this.$navNext )
132
+ .appendTo( this.$el );
133
+
134
+ //this._toggleControls();
135
+
136
+ },
137
+ _toggleControls : function( dir, status ) {
138
+
139
+ // show / hide navigation buttons
140
+ if( dir && status ) {
141
+ if( status === 1 )
142
+ ( dir === 'right' ) ? this.$navNext.show() : this.$navPrev.show();
143
+ else
144
+ ( dir === 'right' ) ? this.$navNext.hide() : this.$navPrev.hide();
145
+ }
146
+ else if( this.current === this.itemsCount - 1 || this.fitCount >= this.itemsCount )
147
+ this.$navNext.hide();
148
+
149
+ },
150
+ _initEvents : function() {
151
+
152
+ var instance = this;
153
+
154
+ // window resize
155
+ $(window).bind('resize.elastislide', function( event ) {
156
+
157
+ // set values again
158
+ instance._setCurrentValues();
159
+
160
+ // need to resize items
161
+ if( instance.visibleWidth < instance.options.minItems * ( instance.options.imageW + 2 * instance.options.border ) + ( instance.options.minItems - 1 ) * instance.options.margin ) {
162
+ instance._setDim( ( instance.visibleWidth - ( instance.options.minItems - 1 ) * instance.options.margin ) / instance.options.minItems );
163
+ instance._setCurrentValues();
164
+ instance.fitCount = instance.options.minItems;
165
+ }
166
+ else{
167
+ instance._setDim();
168
+ instance._setCurrentValues();
169
+ }
170
+
171
+ instance.$slider.css({
172
+ width : instance.sliderW + 10 // TODO: +10px seems to solve a firefox "bug" :S
173
+ });
174
+
175
+ // slide to the current element
176
+ clearTimeout( instance.resetTimeout );
177
+ instance.resetTimeout = setTimeout(function() {
178
+ instance._slideToCurrent();
179
+ }, 200);
180
+
181
+ });
182
+
183
+ // navigation buttons events
184
+ this.$navNext.bind('click.elastislide', function( event ) {
185
+ instance._slide('right');
186
+ });
187
+
188
+ this.$navPrev.bind('click.elastislide', function( event ) {
189
+ instance._slide('left');
190
+ });
191
+
192
+ // item click event
193
+ this.$items.bind('click.elastislide', function( event ) {
194
+ instance.options.onClick( $(this) );
195
+ return false;
196
+ });
197
+
198
+ },
199
+ _slide : function( dir, val, anim, callback ) {
200
+
201
+ // if animating return
202
+ if( this.$slider.is(':animated') )
203
+ return false;
204
+
205
+ // current margin left
206
+ var ml = parseFloat( this.$slider.css('margin-left') );
207
+
208
+ // val is just passed when we want an exact value for the margin left (used in the _slideToCurrent function)
209
+ if( val === undefined ) {
210
+
211
+ // how much to slide?
212
+ var amount = this.fitCount * this.itemW, val;
213
+
214
+ if( amount < 0 ) return false;
215
+
216
+ // make sure not to leave a space between the last item / first item and the end / beggining of the slider available width
217
+ if( dir === 'right' && this.sliderW - ( Math.abs( ml ) + amount ) < this.visibleWidth ) {
218
+ amount = this.sliderW - ( Math.abs( ml ) + this.visibleWidth ) - this.options.margin; // decrease the margin left
219
+ // show / hide navigation buttons
220
+ this._toggleControls( 'right', -1 );
221
+ this._toggleControls( 'left', 1 );
222
+ }
223
+ else if( dir === 'left' && Math.abs( ml ) - amount < 0 ) {
224
+ amount = Math.abs( ml );
225
+ // show / hide navigation buttons
226
+ this._toggleControls( 'left', -1 );
227
+ this._toggleControls( 'right', 1 );
228
+ }
229
+ else {
230
+ var fml; // future margin left
231
+ ( dir === 'right' )
232
+ ? fml = Math.abs( ml ) + this.options.margin + Math.abs( amount )
233
+ : fml = Math.abs( ml ) - this.options.margin - Math.abs( amount );
234
+
235
+ // show / hide navigation buttons
236
+ if( fml > 0 )
237
+ this._toggleControls( 'left', 1 );
238
+ else
239
+ this._toggleControls( 'left', -1 );
240
+
241
+ if( fml < this.sliderW - this.visibleWidth )
242
+ this._toggleControls( 'right', 1 );
243
+ else
244
+ this._toggleControls( 'right', -1 );
245
+
246
+ }
247
+
248
+ ( dir === 'right' ) ? val = '-=' + amount : val = '+=' + amount
249
+
250
+ }
251
+ else {
252
+ var fml = Math.abs( val ); // future margin left
253
+
254
+ if( Math.max( this.sliderW, this.visibleWidth ) - fml < this.visibleWidth ) {
255
+ val = - ( Math.max( this.sliderW, this.visibleWidth ) - this.visibleWidth );
256
+ if( val !== 0 )
257
+ val += this.options.margin; // decrease the margin left if not on the first position
258
+
259
+ // show / hide navigation buttons
260
+ this._toggleControls( 'right', -1 );
261
+ fml = Math.abs( val );
262
+ }
263
+
264
+ // show / hide navigation buttons
265
+ if( fml > 0 )
266
+ this._toggleControls( 'left', 1 );
267
+ else
268
+ this._toggleControls( 'left', -1 );
269
+
270
+ if( Math.max( this.sliderW, this.visibleWidth ) - this.visibleWidth > fml + this.options.margin )
271
+ this._toggleControls( 'right', 1 );
272
+ else
273
+ this._toggleControls( 'right', -1 );
274
+
275
+ }
276
+
277
+ $.fn.applyStyle = ( anim === undefined ) ? $.fn.animate : $.fn.css;
278
+
279
+ var sliderCSS = { marginLeft : val };
280
+
281
+ var instance = this;
282
+
283
+ this.$slider.applyStyle( sliderCSS, $.extend( true, [], { duration : this.options.speed, easing : this.options.easing, complete : function() {
284
+ if( callback ) callback.call();
285
+ } } ) );
286
+
287
+ },
288
+ _slideToCurrent : function( anim ) {
289
+
290
+ // how much to slide?
291
+ var amount = this.current * this.itemW;
292
+ this._slide('', -amount, anim );
293
+
294
+ },
295
+ add : function( $newelems, callback ) {
296
+
297
+ // adds new items to the carousel
298
+ this.$items = this.$items.add( $newelems );
299
+ this.itemsCount = this.$items.length;
300
+ this._setDim();
301
+ this._setCurrentValues();
302
+ this.$slider.css({
303
+ width : this.sliderW
304
+ });
305
+ this._slideToCurrent();
306
+
307
+ if ( callback ) callback.call( $newelems );
308
+
309
+ },
310
+ destroy : function( callback ) {
311
+ this._destroy( callback );
312
+ },
313
+ refresh :function(){
314
+ this._setCurrentValues();
315
+ },
316
+ _destroy : function( callback ) {
317
+ this.$el.unbind('.elastislide').removeData('elastislide');
318
+ $(window).unbind('.elastislide');
319
+ if ( callback ) callback.call();
320
+ }
321
+ };
322
+
323
+ var logError = function( message ) {
324
+ if ( this.console ) {
325
+ console.error( message );
326
+ }
327
+ };
328
+
329
+ $.fn.elastislide = function( options ) {
330
+ if ( typeof options === 'string' ) {
331
+ var args = Array.prototype.slice.call( arguments, 1 );
332
+
333
+ this.each(function() {
334
+ var instance = $.data( this, 'elastislide' );
335
+ if ( !instance ) {
336
+ logError( "cannot call methods on elastislide prior to initialization; " +
337
+ "attempted to call method '" + options + "'" );
338
+ return;
339
+ }
340
+ if ( !$.isFunction( instance[options] ) || options.charAt(0) === "_" ) {
341
+ logError( "no such method '" + options + "' for elastislide instance" );
342
+ return;
343
+ }
344
+ instance[ options ].apply( instance, args );
345
+ });
346
+ }
347
+ else {
348
+ this.each(function() {
349
+ var instance = $.data( this, 'elastislide' );
350
+ if ( !instance ) {
351
+ $.data( this, 'elastislide', new $.elastislide( options, this ) );
352
+ }
353
+ });
354
+ }
355
+ return this;
356
+ };
357
+
358
+ })( window, jQuery );