blazer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of blazer might be problematic. Click here for more details.

Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +144 -0
  6. data/Rakefile +2 -0
  7. data/app/assets/javascripts/blazer/ace/ace.js +11 -0
  8. data/app/assets/javascripts/blazer/ace/ext-language_tools.js +5 -0
  9. data/app/assets/javascripts/blazer/ace/mode-sql.js +1 -0
  10. data/app/assets/javascripts/blazer/ace/snippets/sql.js +1 -0
  11. data/app/assets/javascripts/blazer/ace/snippets/text.js +1 -0
  12. data/app/assets/javascripts/blazer/ace/theme-twilight.js +1 -0
  13. data/app/assets/javascripts/blazer/application.js +15 -0
  14. data/app/assets/javascripts/blazer/daterangepicker.js +1026 -0
  15. data/app/assets/javascripts/blazer/highlight.pack.js +1 -0
  16. data/app/assets/javascripts/blazer/jquery.js +10308 -0
  17. data/app/assets/javascripts/blazer/jquery.stickytableheaders.js +263 -0
  18. data/app/assets/javascripts/blazer/jquery_ujs.js +469 -0
  19. data/app/assets/javascripts/blazer/list.js +1474 -0
  20. data/app/assets/javascripts/blazer/moment.js +2400 -0
  21. data/app/assets/javascripts/blazer/selectize.js +3477 -0
  22. data/app/assets/javascripts/blazer/stupidtable.js +114 -0
  23. data/app/assets/stylesheets/blazer/application.css +66 -0
  24. data/app/assets/stylesheets/blazer/bootstrap.css +6203 -0
  25. data/app/assets/stylesheets/blazer/bootstrap.css.map +1 -0
  26. data/app/assets/stylesheets/blazer/daterangepicker-bs3.css +267 -0
  27. data/app/assets/stylesheets/blazer/github.css +126 -0
  28. data/app/assets/stylesheets/blazer/selectize.default.css +386 -0
  29. data/app/controllers/blazer/queries_controller.rb +216 -0
  30. data/app/helpers/blazer/queries_helper.rb +21 -0
  31. data/app/models/blazer/audit.rb +5 -0
  32. data/app/models/blazer/connection.rb +5 -0
  33. data/app/models/blazer/query.rb +13 -0
  34. data/app/views/blazer/queries/_form.html.erb +84 -0
  35. data/app/views/blazer/queries/edit.html.erb +1 -0
  36. data/app/views/blazer/queries/index.html.erb +47 -0
  37. data/app/views/blazer/queries/new.html.erb +1 -0
  38. data/app/views/blazer/queries/run.html.erb +50 -0
  39. data/app/views/blazer/queries/show.html.erb +138 -0
  40. data/app/views/layouts/blazer/application.html.erb +17 -0
  41. data/blazer.gemspec +25 -0
  42. data/config/routes.rb +6 -0
  43. data/lib/blazer/engine.rb +11 -0
  44. data/lib/blazer/version.rb +3 -0
  45. data/lib/blazer.rb +16 -0
  46. data/lib/generators/blazer/install_generator.rb +33 -0
  47. data/lib/generators/blazer/templates/config.yml +8 -0
  48. data/lib/generators/blazer/templates/install.rb +17 -0
  49. metadata +134 -0
@@ -0,0 +1,263 @@
1
+ /*! Copyright (c) 2011 by Jonas Mosbech - https://github.com/jmosbech/StickyTableHeaders
2
+ MIT license info: https://github.com/jmosbech/StickyTableHeaders/blob/master/license.txt */
3
+
4
+ ;(function ($, window, undefined) {
5
+ 'use strict';
6
+
7
+ var name = 'stickyTableHeaders',
8
+ id = 0,
9
+ defaults = {
10
+ fixedOffset: 0,
11
+ leftOffset: 0,
12
+ scrollableArea: window
13
+ };
14
+
15
+ function Plugin (el, options) {
16
+ // To avoid scope issues, use 'base' instead of 'this'
17
+ // to reference this class from internal events and functions.
18
+ var base = this;
19
+
20
+ // Access to jQuery and DOM versions of element
21
+ base.$el = $(el);
22
+ base.el = el;
23
+ base.id = id++;
24
+
25
+ // Listen for destroyed, call teardown
26
+ base.$el.bind('destroyed',
27
+ $.proxy(base.teardown, base));
28
+
29
+ // Cache DOM refs for performance reasons
30
+ base.$clonedHeader = null;
31
+ base.$originalHeader = null;
32
+
33
+ // Keep track of state
34
+ base.isSticky = false;
35
+ base.hasBeenSticky = false;
36
+ base.leftOffset = null;
37
+ base.topOffset = null;
38
+
39
+ base.init = function () {
40
+ base.options = $.extend({}, defaults, options);
41
+
42
+ base.$el.each(function () {
43
+ var $this = $(this);
44
+
45
+ // remove padding on <table> to fix issue #7
46
+ $this.css('padding', 0);
47
+
48
+ base.$scrollableArea = $(base.options.scrollableArea);
49
+
50
+ base.$originalHeader = $('thead:first', this);
51
+ base.$clonedHeader = base.$originalHeader.clone();
52
+ $this.trigger('clonedHeader.' + name, [base.$clonedHeader]);
53
+
54
+ base.$clonedHeader.addClass('tableFloatingHeader');
55
+ base.$clonedHeader.css('display', 'none');
56
+
57
+ base.$originalHeader.addClass('tableFloatingHeaderOriginal');
58
+
59
+ base.$originalHeader.after(base.$clonedHeader);
60
+
61
+ base.$printStyle = $('<style type="text/css" media="print">' +
62
+ '.tableFloatingHeader{display:none !important;}' +
63
+ '.tableFloatingHeaderOriginal{position:static !important;}' +
64
+ '</style>');
65
+ $('head').append(base.$printStyle);
66
+ });
67
+
68
+ base.updateWidth();
69
+ base.toggleHeaders();
70
+
71
+ base.bind();
72
+ };
73
+
74
+ base.destroy = function (){
75
+ base.$el.unbind('destroyed', base.teardown);
76
+ base.teardown();
77
+ };
78
+
79
+ base.teardown = function(){
80
+ if (base.isSticky) {
81
+ base.$originalHeader.css('position', 'static');
82
+ }
83
+ $.removeData(base.el, 'plugin_' + name);
84
+ base.unbind();
85
+
86
+ base.$clonedHeader.remove();
87
+ base.$originalHeader.removeClass('tableFloatingHeaderOriginal');
88
+ base.$originalHeader.css('visibility', 'visible');
89
+ base.$printStyle.remove();
90
+
91
+ base.el = null;
92
+ base.$el = null;
93
+ };
94
+
95
+ base.bind = function(){
96
+ base.$scrollableArea.on('scroll.' + name, base.toggleHeaders);
97
+ if (!base.isWindowScrolling()) {
98
+ $(window).on('scroll.' + name + base.id, base.setPositionValues);
99
+ $(window).on('resize.' + name + base.id, base.toggleHeaders);
100
+ }
101
+ base.$scrollableArea.on('resize.' + name, base.toggleHeaders);
102
+ base.$scrollableArea.on('resize.' + name, base.updateWidth);
103
+ };
104
+
105
+ base.unbind = function(){
106
+ // unbind window events by specifying handle so we don't remove too much
107
+ base.$scrollableArea.off('.' + name, base.toggleHeaders);
108
+ if (!base.isWindowScrolling()) {
109
+ $(window).off('.' + name + base.id, base.setPositionValues);
110
+ $(window).off('.' + name + base.id, base.toggleHeaders);
111
+ }
112
+ base.$scrollableArea.off('.' + name, base.updateWidth);
113
+ base.$el.off('.' + name);
114
+ base.$el.find('*').off('.' + name);
115
+ };
116
+
117
+ base.toggleHeaders = function () {
118
+ if (base.$el) {
119
+ base.$el.each(function () {
120
+ var $this = $(this),
121
+ newLeft,
122
+ newTopOffset = base.isWindowScrolling() ? (
123
+ isNaN(base.options.fixedOffset) ?
124
+ base.options.fixedOffset.outerHeight() :
125
+ base.options.fixedOffset
126
+ ) :
127
+ base.$scrollableArea.offset().top + (!isNaN(base.options.fixedOffset) ? base.options.fixedOffset : 0),
128
+ offset = $this.offset(),
129
+
130
+ scrollTop = base.$scrollableArea.scrollTop() + newTopOffset,
131
+ scrollLeft = base.$scrollableArea.scrollLeft(),
132
+
133
+ scrolledPastTop = base.isWindowScrolling() ?
134
+ scrollTop > offset.top :
135
+ newTopOffset > offset.top,
136
+ notScrolledPastBottom = (base.isWindowScrolling() ? scrollTop : 0) <
137
+ (offset.top + $this.height() - base.$clonedHeader.height() - (base.isWindowScrolling() ? 0 : newTopOffset));
138
+
139
+ if (scrolledPastTop && notScrolledPastBottom) {
140
+ newLeft = offset.left - scrollLeft + base.options.leftOffset;
141
+ base.$originalHeader.css({
142
+ 'position': 'fixed',
143
+ 'margin-top': 0,
144
+ 'left': newLeft,
145
+ 'z-index': 1 // #18: opacity bug
146
+ });
147
+ base.isSticky = true;
148
+ base.leftOffset = newLeft;
149
+ base.topOffset = newTopOffset;
150
+ base.$clonedHeader.css('display', '');
151
+ base.setPositionValues();
152
+ // make sure the width is correct: the user might have resized the browser while in static mode
153
+ base.updateWidth();
154
+ } else if (base.isSticky) {
155
+ base.$originalHeader.css('position', 'static');
156
+ base.$clonedHeader.css('display', 'none');
157
+ base.isSticky = false;
158
+ base.resetWidth($("td,th", base.$clonedHeader), $("td,th", base.$originalHeader));
159
+ }
160
+ });
161
+ }
162
+ };
163
+
164
+ base.isWindowScrolling = function() {
165
+ return base.$scrollableArea[0] === window;
166
+ };
167
+
168
+ base.setPositionValues = function () {
169
+ var winScrollTop = $(window).scrollTop(),
170
+ winScrollLeft = $(window).scrollLeft();
171
+ if (!base.isSticky ||
172
+ winScrollTop < 0 || winScrollTop + $(window).height() > $(document).height() ||
173
+ winScrollLeft < 0 || winScrollLeft + $(window).width() > $(document).width()) {
174
+ return;
175
+ }
176
+ base.$originalHeader.css({
177
+ 'top': base.topOffset - (base.isWindowScrolling() ? 0 : winScrollTop),
178
+ 'left': base.leftOffset - (base.isWindowScrolling() ? 0 : winScrollLeft)
179
+ });
180
+ };
181
+
182
+ base.updateWidth = function () {
183
+ if (!base.isSticky) {
184
+ return;
185
+ }
186
+ // Copy cell widths from clone
187
+ if (!base.$originalHeaderCells) {
188
+ base.$originalHeaderCells = $('th,td', base.$originalHeader);
189
+ }
190
+ if (!base.$clonedHeaderCells) {
191
+ base.$clonedHeaderCells = $('th,td', base.$clonedHeader);
192
+ }
193
+ var cellWidths = base.getWidth(base.$clonedHeaderCells);
194
+ base.setWidth(cellWidths, base.$clonedHeaderCells, base.$originalHeaderCells);
195
+
196
+ // Copy row width from whole table
197
+ base.$originalHeader.css('width', base.$clonedHeader.width());
198
+ };
199
+
200
+ base.getWidth = function ($clonedHeaders) {
201
+ var widths = [];
202
+ $clonedHeaders.each(function (index) {
203
+ var width, $this = $(this);
204
+
205
+ if ($this.css('box-sizing') === 'border-box') {
206
+ width = $this.outerWidth(); // #39: border-box bug
207
+ } else {
208
+ width = $this.width();
209
+ }
210
+
211
+ widths[index] = width;
212
+ });
213
+ return widths;
214
+ };
215
+
216
+ base.setWidth = function (widths, $clonedHeaders, $origHeaders) {
217
+ $clonedHeaders.each(function (index) {
218
+ var width = widths[index];
219
+ $origHeaders.eq(index).css({
220
+ 'min-width': width,
221
+ 'max-width': width
222
+ });
223
+ });
224
+ };
225
+
226
+ base.resetWidth = function ($clonedHeaders, $origHeaders) {
227
+ $clonedHeaders.each(function (index) {
228
+ var $this = $(this);
229
+ $origHeaders.eq(index).css({
230
+ 'min-width': $this.css("min-width"),
231
+ 'max-width': $this.css("max-width")
232
+ });
233
+ });
234
+ };
235
+
236
+ base.updateOptions = function(options) {
237
+ base.options = $.extend({}, defaults, options);
238
+ base.updateWidth();
239
+ base.toggleHeaders();
240
+ };
241
+
242
+ // Run initializer
243
+ base.init();
244
+ }
245
+
246
+ // A plugin wrapper around the constructor,
247
+ // preventing against multiple instantiations
248
+ $.fn[name] = function ( options ) {
249
+ return this.each(function () {
250
+ var instance = $.data(this, 'plugin_' + name);
251
+ if (instance) {
252
+ if (typeof options === "string") {
253
+ instance[options].apply(instance);
254
+ } else {
255
+ instance.updateOptions(options);
256
+ }
257
+ } else if(options !== 'destroy') {
258
+ $.data(this, 'plugin_' + name, new Plugin( this, options ));
259
+ }
260
+ });
261
+ };
262
+
263
+ })(jQuery, window);