mechanize-store 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +15 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +58 -0
  4. data/Rakefile +32 -0
  5. data/app/assets/javascripts/mechanize_store/application.js +22 -0
  6. data/app/assets/javascripts/mechanize_store/sb-admin/bootstrap.js +1951 -0
  7. data/app/assets/javascripts/mechanize_store/sb-admin/custom.js +58 -0
  8. data/app/assets/javascripts/mechanize_store/sb-admin/flot/excanvas.min.js +1 -0
  9. data/app/assets/javascripts/mechanize_store/sb-admin/flot/jquery.flot.js +3137 -0
  10. data/app/assets/javascripts/mechanize_store/sb-admin/flot/jquery.flot.pie.js +817 -0
  11. data/app/assets/javascripts/mechanize_store/sb-admin/flot/main.js +20 -0
  12. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-ui.js +2256 -0
  13. data/app/assets/javascripts/mechanize_store/sb-admin/jquery.activity-indicator-1.0.0.min.js +223 -0
  14. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/dataTables/dataTables.bootstrap.js +245 -0
  15. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/dataTables/jquery.dataTables.js +14013 -0
  16. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/flot/excanvas.min.js +1 -0
  17. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/flot/jquery.flot.js +2599 -0
  18. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/flot/jquery.flot.pie.js +750 -0
  19. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/flot/jquery.flot.resize.js +60 -0
  20. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/flot/jquery.flot.tooltip.min.js +12 -0
  21. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/metisMenu/jquery.metisMenu.js +45 -0
  22. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/morris/morris.js +1888 -0
  23. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/morris/raphael-2.1.0.min.js +10 -0
  24. data/app/assets/javascripts/mechanize_store/sb-admin/sb-admin.js +18 -0
  25. data/app/assets/stylesheets/mechanize_store/application.css +199 -0
  26. data/app/assets/stylesheets/mechanize_store/sb-admin/bootstrap.css +5831 -0
  27. data/app/assets/stylesheets/mechanize_store/sb-admin/plugins/dataTables/dataTables.bootstrap.css +233 -0
  28. data/app/assets/stylesheets/mechanize_store/sb-admin/plugins/morris/morris-0.4.3.min.css +2 -0
  29. data/app/assets/stylesheets/mechanize_store/sb-admin/plugins/social-buttons/social-buttons.css +68 -0
  30. data/app/assets/stylesheets/mechanize_store/sb-admin/plugins/timeline/timeline.css +144 -0
  31. data/app/assets/stylesheets/mechanize_store/sb-admin/sb-admin.css +307 -0
  32. data/app/controllers/mechanize_store/application_controller.rb +4 -0
  33. data/app/controllers/mechanize_store/flags_controller.rb +77 -0
  34. data/app/controllers/mechanize_store/order_statuses_controller.rb +77 -0
  35. data/app/controllers/mechanize_store/orders_controller.rb +28 -0
  36. data/app/controllers/mechanize_store/payment_statuses_controller.rb +77 -0
  37. data/app/controllers/mechanize_store/payment_types_controller.rb +77 -0
  38. data/app/controllers/mechanize_store/product_categories_controller.rb +77 -0
  39. data/app/controllers/mechanize_store/products_controller.rb +77 -0
  40. data/app/helpers/mechanize_store/application_helper.rb +7 -0
  41. data/app/models/mechanize_store/flag.rb +4 -0
  42. data/app/models/mechanize_store/freight.rb +5 -0
  43. data/app/models/mechanize_store/order.rb +8 -0
  44. data/app/models/mechanize_store/order_status.rb +5 -0
  45. data/app/models/mechanize_store/payment.rb +6 -0
  46. data/app/models/mechanize_store/payment_status.rb +4 -0
  47. data/app/models/mechanize_store/payment_type.rb +4 -0
  48. data/app/models/mechanize_store/product.rb +5 -0
  49. data/app/models/mechanize_store/product_category.rb +5 -0
  50. data/app/models/mechanize_store/product_photo.rb +5 -0
  51. data/app/models/mechanize_store/store.rb +5 -0
  52. data/app/views/layouts/store/application.html.erb +93 -0
  53. data/app/views/mechanize_store/flags/_form.html.erb +11 -0
  54. data/app/views/mechanize_store/flags/edit.html.erb +12 -0
  55. data/app/views/mechanize_store/flags/index.html.erb +46 -0
  56. data/app/views/mechanize_store/flags/new.html.erb +9 -0
  57. data/app/views/mechanize_store/flags/show.html.erb +15 -0
  58. data/app/views/mechanize_store/order_statuses/_form.html.erb +11 -0
  59. data/app/views/mechanize_store/order_statuses/edit.html.erb +12 -0
  60. data/app/views/mechanize_store/order_statuses/index.html.erb +46 -0
  61. data/app/views/mechanize_store/order_statuses/new.html.erb +9 -0
  62. data/app/views/mechanize_store/order_statuses/show.html.erb +15 -0
  63. data/app/views/mechanize_store/orders/index.html.erb +84 -0
  64. data/app/views/mechanize_store/orders/show.html.erb +0 -0
  65. data/app/views/mechanize_store/payment_statuses/_form.html.erb +11 -0
  66. data/app/views/mechanize_store/payment_statuses/edit.html.erb +12 -0
  67. data/app/views/mechanize_store/payment_statuses/index.html.erb +46 -0
  68. data/app/views/mechanize_store/payment_statuses/new.html.erb +9 -0
  69. data/app/views/mechanize_store/payment_statuses/show.html.erb +15 -0
  70. data/app/views/mechanize_store/payment_types/_form.html.erb +11 -0
  71. data/app/views/mechanize_store/payment_types/edit.html.erb +12 -0
  72. data/app/views/mechanize_store/payment_types/index.html.erb +46 -0
  73. data/app/views/mechanize_store/payment_types/new.html.erb +9 -0
  74. data/app/views/mechanize_store/payment_types/show.html.erb +15 -0
  75. data/app/views/mechanize_store/product_categories/_form.html.erb +12 -0
  76. data/app/views/mechanize_store/product_categories/edit.html.erb +12 -0
  77. data/app/views/mechanize_store/product_categories/index.html.erb +48 -0
  78. data/app/views/mechanize_store/product_categories/new.html.erb +9 -0
  79. data/app/views/mechanize_store/product_categories/show.html.erb +19 -0
  80. data/app/views/mechanize_store/products/_form.html.erb +18 -0
  81. data/app/views/mechanize_store/products/edit.html.erb +12 -0
  82. data/app/views/mechanize_store/products/index.html.erb +50 -0
  83. data/app/views/mechanize_store/products/new.html.erb +9 -0
  84. data/app/views/mechanize_store/products/show.html.erb +43 -0
  85. data/app/views/shared/_flashes.html.erb +8 -0
  86. data/config/locales/store.pt-BR.yml +22 -0
  87. data/config/routes.rb +10 -0
  88. data/db/migrate/20140401203200_create_mechanize_store_freights.rb +12 -0
  89. data/db/migrate/20140401203246_create_mechanize_store_order_statuses.rb +9 -0
  90. data/db/migrate/20140402140318_create_mechanize_store_payment_statuses.rb +9 -0
  91. data/db/migrate/20140402140325_create_mechanize_store_payment_types.rb +9 -0
  92. data/db/migrate/20140402140539_create_mechanize_store_payments.rb +16 -0
  93. data/db/migrate/20140402140549_create_mechanize_store_flags.rb +9 -0
  94. data/db/migrate/20140402140832_create_mechanize_store_products.rb +16 -0
  95. data/db/migrate/20140402140942_create_mechanize_store_product_photos.rb +10 -0
  96. data/db/migrate/20140402141340_create_mechanize_store_stores.rb +12 -0
  97. data/db/migrate/20140402153139_create_mechanize_store_orders.rb +11 -0
  98. data/db/migrate/20140402192058_create_mechanize_store_product_categories.rb +10 -0
  99. data/lib/mechanize_store.rb +4 -0
  100. data/lib/mechanize_store/engine.rb +16 -0
  101. data/lib/mechanize_store/version.rb +3 -0
  102. data/lib/tasks/store_tasks.rake +4 -0
  103. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  104. data/lib/templates/erb/scaffold/edit.html.erb +12 -0
  105. data/lib/templates/erb/scaffold/index.html.erb +50 -0
  106. data/lib/templates/erb/scaffold/new.html.erb +9 -0
  107. data/lib/templates/erb/scaffold/show.html.erb +17 -0
  108. data/lib/templates/rails/scaffold_controller/controller.rb +79 -0
  109. metadata +265 -0
@@ -0,0 +1,223 @@
1
+ /*!
2
+ * NETEYE Activity Indicator jQuery Plugin
3
+ *
4
+ * Copyright (c) 2010 NETEYE GmbH
5
+ * Licensed under the MIT license
6
+ *
7
+ * Author: Felix Gnass [fgnass at neteye dot de]
8
+ * Version: 1.0.0
9
+ */
10
+
11
+ /**
12
+ * Plugin that renders a customisable activity indicator (spinner) using SVG or VML.
13
+ */
14
+ (function($) {
15
+
16
+ $.fn.activity = function(opts) {
17
+ this.each(function() {
18
+ var $this = $(this);
19
+ var el = $this.data('activity');
20
+ if (el) {
21
+ clearInterval(el.data('interval'));
22
+ el.remove();
23
+ $this.removeData('activity');
24
+ }
25
+ if (opts !== false) {
26
+ opts = $.extend({color: $this.css('color')}, $.fn.activity.defaults, opts);
27
+
28
+ el = render($this, opts).css('position', 'absolute').prependTo(opts.outside ? 'body' : $this);
29
+ var h = $this.outerHeight() - el.height();
30
+ var w = $this.outerWidth() - el.width();
31
+ var margin = {
32
+ top: opts.valign == 'top' ? opts.padding : opts.valign == 'bottom' ? h - opts.padding : Math.floor(h / 2),
33
+ left: opts.align == 'left' ? opts.padding : opts.align == 'right' ? w - opts.padding : Math.floor(w / 2)
34
+ };
35
+ var offset = $this.offset();
36
+ if (opts.outside) {
37
+ el.css({top: offset.top + 'px', left: offset.left + 'px'});
38
+ }
39
+ else {
40
+ margin.top -= el.offset().top - offset.top;
41
+ margin.left -= el.offset().left - offset.left;
42
+ }
43
+ el.css({marginTop: margin.top + 'px', marginLeft: margin.left + 'px'});
44
+ animate(el, opts.segments, Math.round(10 / opts.speed) / 10);
45
+ $this.data('activity', el);
46
+ }
47
+ });
48
+ return this;
49
+ };
50
+
51
+ $.fn.activity.defaults = {
52
+ segments: 12,
53
+ space: 3,
54
+ length: 7,
55
+ width: 4,
56
+ speed: 1.2,
57
+ align: 'center',
58
+ valign: 'center',
59
+ padding: 4,
60
+ zIndex: 1000
61
+ };
62
+
63
+ $.fn.activity.getOpacity = function(opts, i) {
64
+ var steps = opts.steps || opts.segments-1;
65
+ var end = opts.opacity !== undefined ? opts.opacity : 1/steps;
66
+ return 1 - Math.min(i, steps) * (1 - end) / steps;
67
+ };
68
+
69
+ /**
70
+ * Default rendering strategy. If neither SVG nor VML is available, a div with class-name 'busy'
71
+ * is inserted, that can be styled with CSS to display an animated gif as fallback.
72
+ */
73
+ var render = function() {
74
+ return $('<div>').addClass('busy');
75
+ };
76
+
77
+ /**
78
+ * The default animation strategy does nothing as we expect an animated gif as fallback.
79
+ */
80
+ var animate = function() {
81
+ };
82
+
83
+ /**
84
+ * Utility function to create elements in the SVG namespace.
85
+ */
86
+ function svg(tag, attr) {
87
+ var el = document.createElementNS("http://www.w3.org/2000/svg", tag || 'svg');
88
+ if (attr) {
89
+ $.each(attr, function(k, v) {
90
+ el.setAttributeNS(null, k, v);
91
+ });
92
+ }
93
+ return $(el);
94
+ }
95
+
96
+ if (document.createElementNS && document.createElementNS( "http://www.w3.org/2000/svg", "svg").createSVGRect) {
97
+
98
+ // =======================================================================================
99
+ // SVG Rendering
100
+ // =======================================================================================
101
+
102
+ /**
103
+ * Rendering strategy that creates a SVG tree.
104
+ */
105
+ render = function(target, d) {
106
+ var innerRadius = d.width*2 + d.space;
107
+ var r = (innerRadius + d.length + Math.ceil(d.width / 2) + 1);
108
+
109
+ var el = svg().width(r*2).height(r*2);
110
+
111
+ var g = svg('g', {
112
+ 'stroke-width': d.width,
113
+ 'stroke-linecap': 'round',
114
+ stroke: d.color
115
+ }).appendTo(svg('g', {transform: 'translate('+ r +','+ r +')'}).appendTo(el));
116
+
117
+ for (var i = 0; i < d.segments; i++) {
118
+ g.append(svg('line', {
119
+ x1: 0,
120
+ y1: innerRadius,
121
+ x2: 0,
122
+ y2: innerRadius + d.length,
123
+ transform: 'rotate(' + (360 / d.segments * i) + ', 0, 0)',
124
+ opacity: $.fn.activity.getOpacity(d, i)
125
+ }));
126
+ }
127
+ return $('<div>').append(el).width(2*r).height(2*r);
128
+ };
129
+
130
+ // Check if Webkit CSS animations are available, as they work much better on the iPad
131
+ // than setTimeout() based animations.
132
+
133
+ if (document.createElement('div').style.WebkitAnimationName !== undefined) {
134
+
135
+ var animations = {};
136
+
137
+ /**
138
+ * Animation strategy that uses dynamically created CSS animation rules.
139
+ */
140
+ animate = function(el, steps, duration) {
141
+ if (!animations[steps]) {
142
+ var name = 'spin' + steps;
143
+ var rule = '@-webkit-keyframes '+ name +' {';
144
+ for (var i=0; i < steps; i++) {
145
+ var p1 = Math.round(100000 / steps * i) / 1000;
146
+ var p2 = Math.round(100000 / steps * (i+1) - 1) / 1000;
147
+ var value = '% { -webkit-transform:rotate(' + Math.round(360 / steps * i) + 'deg); }\n';
148
+ rule += p1 + value + p2 + value;
149
+ }
150
+ rule += '100% { -webkit-transform:rotate(100deg); }\n}';
151
+ document.styleSheets[0].insertRule(rule);
152
+ animations[steps] = name;
153
+ }
154
+ el.css('-webkit-animation', animations[steps] + ' ' + duration +'s linear infinite');
155
+ };
156
+ }
157
+ else {
158
+
159
+ /**
160
+ * Animation strategy that transforms a SVG element using setInterval().
161
+ */
162
+ animate = function(el, steps, duration) {
163
+ var rotation = 0;
164
+ var g = el.find('g g').get(0);
165
+ el.data('interval', setInterval(function() {
166
+ g.setAttributeNS(null, 'transform', 'rotate(' + (++rotation % steps * (360 / steps)) + ')');
167
+ }, duration * 1000 / steps));
168
+ };
169
+ }
170
+
171
+ }
172
+ else {
173
+
174
+ // =======================================================================================
175
+ // VML Rendering
176
+ // =======================================================================================
177
+
178
+ var s = $('<shape>').css('behavior', 'url(#default#VML)').appendTo('body');
179
+
180
+ if (s.get(0).adj) {
181
+
182
+ // VML support detected. Insert CSS rules for group, shape and stroke.
183
+ var sheet = document.createStyleSheet();
184
+ $.each(['group', 'shape', 'stroke'], function() {
185
+ sheet.addRule(this, "behavior:url(#default#VML);");
186
+ });
187
+
188
+ /**
189
+ * Rendering strategy that creates a VML tree.
190
+ */
191
+ render = function(target, d) {
192
+
193
+ var innerRadius = d.width*2 + d.space;
194
+ var r = (innerRadius + d.length + Math.ceil(d.width / 2) + 1);
195
+ var s = r*2;
196
+ var o = -Math.ceil(s/2);
197
+
198
+ var el = $('<group>', {coordsize: s + ' ' + s, coordorigin: o + ' ' + o}).css({top: o, left: o, width: s, height: s});
199
+ for (var i = 0; i < d.segments; i++) {
200
+ el.append($('<shape>', {path: 'm ' + innerRadius + ',0 l ' + (innerRadius + d.length) + ',0'}).css({
201
+ width: s,
202
+ height: s,
203
+ rotation: (360 / d.segments * i) + 'deg'
204
+ }).append($('<stroke>', {color: d.color, weight: d.width + 'px', endcap: 'round', opacity: $.fn.activity.getOpacity(d, i)})));
205
+ }
206
+ return $('<group>', {coordsize: s + ' ' + s}).css({width: s, height: s, overflow: 'hidden'}).append(el);
207
+ };
208
+
209
+ /**
210
+ * Animation strategy that modifies the VML rotation property using setInterval().
211
+ */
212
+ animate = function(el, steps, duration) {
213
+ var rotation = 0;
214
+ var g = el.get(0);
215
+ el.data('interval', setInterval(function() {
216
+ g.style.rotation = ++rotation % steps * (360 / steps);
217
+ }, duration * 1000 / steps));
218
+ };
219
+ }
220
+ $(s).remove();
221
+ }
222
+
223
+ })(jQuery);
@@ -0,0 +1,245 @@
1
+ /* Set the defaults for DataTables initialisation */
2
+ $.extend(true, $.fn.dataTable.defaults, {
3
+ "sDom": "<'row'<'col-sm-6'l><'col-sm-6'f>r>" + "t" + "<'row'<'col-sm-6'i><'col-sm-6'p>>",
4
+ "oLanguage": {
5
+ "sLengthMenu": "_MENU_ records per page"
6
+ }
7
+ });
8
+
9
+
10
+ /* Default class modification */
11
+ $.extend($.fn.dataTableExt.oStdClasses, {
12
+ "sWrapper": "dataTables_wrapper form-inline",
13
+ "sFilterInput": "form-control input-sm",
14
+ "sLengthSelect": "form-control input-sm"
15
+ });
16
+
17
+ // In 1.10 we use the pagination renderers to draw the Bootstrap paging,
18
+ // rather than custom plug-in
19
+ if ($.fn.dataTable.Api) {
20
+ $.fn.dataTable.defaults.renderer = 'bootstrap';
21
+ $.fn.dataTable.ext.renderer.pageButton.bootstrap = function(settings, host, idx, buttons, page, pages) {
22
+ var api = new $.fn.dataTable.Api(settings);
23
+ var classes = settings.oClasses;
24
+ var lang = settings.oLanguage.oPaginate;
25
+ var btnDisplay, btnClass;
26
+
27
+ var attach = function(container, buttons) {
28
+ var i, ien, node, button;
29
+ var clickHandler = function(e) {
30
+ e.preventDefault();
31
+ if (e.data.action !== 'ellipsis') {
32
+ api.page(e.data.action).draw(false);
33
+ }
34
+ };
35
+
36
+ for (i = 0, ien = buttons.length; i < ien; i++) {
37
+ button = buttons[i];
38
+
39
+ if ($.isArray(button)) {
40
+ attach(container, button);
41
+ } else {
42
+ btnDisplay = '';
43
+ btnClass = '';
44
+
45
+ switch (button) {
46
+ case 'ellipsis':
47
+ btnDisplay = '&hellip;';
48
+ btnClass = 'disabled';
49
+ break;
50
+
51
+ case 'first':
52
+ btnDisplay = lang.sFirst;
53
+ btnClass = button + (page > 0 ?
54
+ '' : ' disabled');
55
+ break;
56
+
57
+ case 'previous':
58
+ btnDisplay = lang.sPrevious;
59
+ btnClass = button + (page > 0 ?
60
+ '' : ' disabled');
61
+ break;
62
+
63
+ case 'next':
64
+ btnDisplay = lang.sNext;
65
+ btnClass = button + (page < pages - 1 ?
66
+ '' : ' disabled');
67
+ break;
68
+
69
+ case 'last':
70
+ btnDisplay = lang.sLast;
71
+ btnClass = button + (page < pages - 1 ?
72
+ '' : ' disabled');
73
+ break;
74
+
75
+ default:
76
+ btnDisplay = button + 1;
77
+ btnClass = page === button ?
78
+ 'active' : '';
79
+ break;
80
+ }
81
+
82
+ if (btnDisplay) {
83
+ node = $('<li>', {
84
+ 'class': classes.sPageButton + ' ' + btnClass,
85
+ 'aria-controls': settings.sTableId,
86
+ 'tabindex': settings.iTabIndex,
87
+ 'id': idx === 0 && typeof button === 'string' ? settings.sTableId + '_' + button : null
88
+ })
89
+ .append($('<a>', {
90
+ 'href': '#'
91
+ })
92
+ .html(btnDisplay)
93
+ )
94
+ .appendTo(container);
95
+
96
+ settings.oApi._fnBindAction(
97
+ node, {
98
+ action: button
99
+ }, clickHandler
100
+ );
101
+ }
102
+ }
103
+ }
104
+ };
105
+
106
+ attach(
107
+ $(host).empty().html('<ul class="pagination"/>').children('ul'),
108
+ buttons
109
+ );
110
+ }
111
+ } else {
112
+ // Integration for 1.9-
113
+ $.fn.dataTable.defaults.sPaginationType = 'bootstrap';
114
+
115
+ /* API method to get paging information */
116
+ $.fn.dataTableExt.oApi.fnPagingInfo = function(oSettings) {
117
+ return {
118
+ "iStart": oSettings._iDisplayStart,
119
+ "iEnd": oSettings.fnDisplayEnd(),
120
+ "iLength": oSettings._iDisplayLength,
121
+ "iTotal": oSettings.fnRecordsTotal(),
122
+ "iFilteredTotal": oSettings.fnRecordsDisplay(),
123
+ "iPage": oSettings._iDisplayLength === -1 ? 0 : Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength),
124
+ "iTotalPages": oSettings._iDisplayLength === -1 ? 0 : Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength)
125
+ };
126
+ };
127
+
128
+ /* Bootstrap style pagination control */
129
+ $.extend($.fn.dataTableExt.oPagination, {
130
+ "bootstrap": {
131
+ "fnInit": function(oSettings, nPaging, fnDraw) {
132
+ var oLang = oSettings.oLanguage.oPaginate;
133
+ var fnClickHandler = function(e) {
134
+ e.preventDefault();
135
+ if (oSettings.oApi._fnPageChange(oSettings, e.data.action)) {
136
+ fnDraw(oSettings);
137
+ }
138
+ };
139
+
140
+ $(nPaging).append(
141
+ '<ul class="pagination">' +
142
+ '<li class="prev disabled"><a href="#">&larr; ' + oLang.sPrevious + '</a></li>' +
143
+ '<li class="next disabled"><a href="#">' + oLang.sNext + ' &rarr; </a></li>' +
144
+ '</ul>'
145
+ );
146
+ var els = $('a', nPaging);
147
+ $(els[0]).bind('click.DT', {
148
+ action: "previous"
149
+ }, fnClickHandler);
150
+ $(els[1]).bind('click.DT', {
151
+ action: "next"
152
+ }, fnClickHandler);
153
+ },
154
+
155
+ "fnUpdate": function(oSettings, fnDraw) {
156
+ var iListLength = 5;
157
+ var oPaging = oSettings.oInstance.fnPagingInfo();
158
+ var an = oSettings.aanFeatures.p;
159
+ var i, ien, j, sClass, iStart, iEnd, iHalf = Math.floor(iListLength / 2);
160
+
161
+ if (oPaging.iTotalPages < iListLength) {
162
+ iStart = 1;
163
+ iEnd = oPaging.iTotalPages;
164
+ } else if (oPaging.iPage <= iHalf) {
165
+ iStart = 1;
166
+ iEnd = iListLength;
167
+ } else if (oPaging.iPage >= (oPaging.iTotalPages - iHalf)) {
168
+ iStart = oPaging.iTotalPages - iListLength + 1;
169
+ iEnd = oPaging.iTotalPages;
170
+ } else {
171
+ iStart = oPaging.iPage - iHalf + 1;
172
+ iEnd = iStart + iListLength - 1;
173
+ }
174
+
175
+ for (i = 0, ien = an.length; i < ien; i++) {
176
+ // Remove the middle elements
177
+ $('li:gt(0)', an[i]).filter(':not(:last)').remove();
178
+
179
+ // Add the new list items and their event handlers
180
+ for (j = iStart; j <= iEnd; j++) {
181
+ sClass = (j == oPaging.iPage + 1) ? 'class="active"' : '';
182
+ $('<li ' + sClass + '><a href="#">' + j + '</a></li>')
183
+ .insertBefore($('li:last', an[i])[0])
184
+ .bind('click', function(e) {
185
+ e.preventDefault();
186
+ oSettings._iDisplayStart = (parseInt($('a', this).text(), 10) - 1) * oPaging.iLength;
187
+ fnDraw(oSettings);
188
+ });
189
+ }
190
+
191
+ // Add / remove disabled classes from the static elements
192
+ if (oPaging.iPage === 0) {
193
+ $('li:first', an[i]).addClass('disabled');
194
+ } else {
195
+ $('li:first', an[i]).removeClass('disabled');
196
+ }
197
+
198
+ if (oPaging.iPage === oPaging.iTotalPages - 1 || oPaging.iTotalPages === 0) {
199
+ $('li:last', an[i]).addClass('disabled');
200
+ } else {
201
+ $('li:last', an[i]).removeClass('disabled');
202
+ }
203
+ }
204
+ }
205
+ }
206
+ });
207
+ }
208
+
209
+
210
+ /*
211
+ * TableTools Bootstrap compatibility
212
+ * Required TableTools 2.1+
213
+ */
214
+ if ($.fn.DataTable.TableTools) {
215
+ // Set the classes that TableTools uses to something suitable for Bootstrap
216
+ $.extend(true, $.fn.DataTable.TableTools.classes, {
217
+ "container": "DTTT btn-group",
218
+ "buttons": {
219
+ "normal": "btn btn-default",
220
+ "disabled": "disabled"
221
+ },
222
+ "collection": {
223
+ "container": "DTTT_dropdown dropdown-menu",
224
+ "buttons": {
225
+ "normal": "",
226
+ "disabled": "disabled"
227
+ }
228
+ },
229
+ "print": {
230
+ "info": "DTTT_print_info modal"
231
+ },
232
+ "select": {
233
+ "row": "active"
234
+ }
235
+ });
236
+
237
+ // Have the collection use a bootstrap compatible dropdown
238
+ $.extend(true, $.fn.DataTable.TableTools.DEFAULTS.oTags, {
239
+ "collection": {
240
+ "container": "ul",
241
+ "button": "li",
242
+ "liner": "a"
243
+ }
244
+ });
245
+ }