Commit 7993d1cd9f642f03e494c216d090f01bcf057b36

Authored by Cyril Mougel
1 parent fe93e0cf
Exists in master and in 1 other branch production

Fix issue with Jquery >= 1.9

See #500
Gemfile
... ... @@ -130,7 +130,9 @@ group :assets do
130 130 gem 'execjs'
131 131 gem 'therubyracer', :platform => :ruby # C Ruby (MRI) or Rubinius, but NOT Windows
132 132 gem 'uglifier', '>= 1.0.3'
133   - gem 'jquery-rails'
  133 + # We can't upgrade because not compatible to jquery >= 1.9.
  134 + # To do that, we need fix the rails.js
  135 + gem 'jquery-rails', '~> 2.1.4'
134 136 gem 'pjax_rails'
135 137 gem 'underscore-rails'
136 138 gem 'turbo-sprockets-rails3'
... ...
Gemfile.lock
... ... @@ -132,7 +132,7 @@ GEM
132 132 has_scope (0.5.1)
133 133 hashie (1.2.0)
134 134 highline (1.6.19)
135   - hike (1.2.2)
  135 + hike (1.2.3)
136 136 hipchat (0.9.0)
137 137 httparty
138 138 httparty
... ... @@ -152,7 +152,7 @@ GEM
152 152 has_scope (~> 0.5.0)
153 153 responders (~> 0.9)
154 154 journey (1.0.4)
155   - jquery-rails (3.0.0)
  155 + jquery-rails (2.1.4)
156 156 railties (>= 3.0, < 5.0)
157 157 thor (>= 0.14, < 2.0)
158 158 json (1.8.0)
... ... @@ -191,7 +191,7 @@ GEM
191 191 bundler (>= 1.0.0)
192 192 rails (>= 3.0.0)
193 193 railties (>= 3.0.0)
194   - multi_json (1.7.4)
  194 + multi_json (1.7.6)
195 195 multi_xml (0.5.3)
196 196 multipart-post (1.2.0)
197 197 net-scp (1.1.1)
... ... @@ -406,7 +406,7 @@ DEPENDENCIES
406 406 htmlentities
407 407 httparty
408 408 inherited_resources
409   - jquery-rails
  409 + jquery-rails (~> 2.1.4)
410 410 kaminari (>= 0.14.1)
411 411 launchy
412 412 lighthouse-api
... ...
app/assets/javascripts/application.js.erb
  1 +// We can't use jquery > 1.9
1 2 //= require jquery
2 3 //= require underscore
  4 +// This rails.js version is not like the original.
  5 +// We can't upgrade to the official version
3 6 //= require rails
4 7 //= require form
5 8 //= require jquery.pjax
... ...
app/assets/javascripts/errbit.js
... ... @@ -14,21 +14,12 @@ $(function() {
14 14  
15 15 bindRequiredPasswordMarks();
16 16  
17   - $('#watcher_name').live("click", function() {
18   - $(this).closest('form').find('.show').removeClass('show');
19   - $('#app_watchers_attributes_0_user_id').addClass('show');
20   - });
21   -
22   - $('#watcher_email').live("click", function() {
23   - $(this).closest('form').find('.show').removeClass('show');
24   - $('#app_watchers_attributes_0_email').addClass('show');
25   - });
26   -
27   - $('a.copy_config').live("click", function() {
  17 + // On page apps/:app_id/edit
  18 + $('a.copy_config').on("click", function() {
28 19 $('select.choose_other_app').show().focus();
29 20 });
30 21  
31   - $('select.choose_other_app').live("change", function() {
  22 + $('select.choose_other_app').on("change", function() {
32 23 var loc = window.location;
33 24 window.location.href = loc.protocol + "//" + loc.host + loc.pathname +
34 25 "?copy_attributes_from=" + $(this).val();
... ... @@ -82,7 +73,7 @@ $(function() {
82 73 function toggleProblemsCheckboxes() {
83 74 var checkboxToggler = $('#toggle_problems_checkboxes');
84 75  
85   - checkboxToggler.live("click", function() {
  76 + checkboxToggler.on("click", function() {
86 77 $('input[name^="problems"]').each(function() {
87 78 this.checked = checkboxToggler.get(0).checked;
88 79 });
... ... @@ -125,7 +116,7 @@ $(function() {
125 116 $('td.backtrace_separator').hide();
126 117 }
127 118 // Show external backtrace lines when clicking separator
128   - $('td.backtrace_separator span').live('click', show_external_backtrace);
  119 + $('td.backtrace_separator span').on('click', show_external_backtrace);
129 120 // Hide external backtrace on page load
130 121 hide_external_backtrace();
131 122  
... ...
app/assets/javascripts/form.js
... ... @@ -19,7 +19,8 @@ $(function(){
19 19 });
20 20  
21 21 function activateNestedForms() {
22   - $('.nested-wrapper').each(function(){
  22 + var wrapper = $('.nested-wrapper')
  23 + wrapper.each(function(){
23 24 var wrapper = $(this);
24 25  
25 26 makeNestedItemsDestroyable(wrapper);
... ... @@ -28,7 +29,7 @@ function activateNestedForms() {
28 29 addLink.click(appendNestedItem);
29 30 wrapper.append(addLink);
30 31 });
31   - $('.nested a.remove-nested').live('click',removeNestedItem);
  32 + wrapper.on('click','.nested a.remove-nested', removeNestedItem);
32 33 }
33 34  
34 35 function makeNestedItemsDestroyable(wrapper) {
... ... @@ -80,7 +81,7 @@ function activateTypeSelector(field_class, section_class) {
80 81 $('div.'+field_class+' > div.'+section_class).not('.chosen').find('input')
81 82 .attr('disabled','disabled').val('');
82 83  
83   - $('div.'+field_class+' input[name*=type]').live('click', function(){
  84 + $('div.'+field_class+' input[name*=type]').on('click', function(){
84 85 // Look for section in 'data-section', and fall back to 'value'
85 86 var chosen = $(this).data("section") || $(this).val();
86 87 var wrapper = $(this).closest('.nested');
... ...
app/assets/javascripts/jquery.alerts.js
... ... @@ -12,7 +12,7 @@
12 12 // $.jAlert( message, [title, callback] )
13 13 // $.jConfirm( message, [title, callback] )
14 14 // $.jPrompt( message, [value, title, callback] )
15   -//
  15 +//
16 16 // History:
17 17 //
18 18 // 1.00 - Released (29 December 2008)
... ... @@ -22,16 +22,16 @@
22 22 // 1.2 - global methods removed.
23 23 //
24 24 // License:
25   -//
  25 +//
26 26 // This plugin is dual-licensed under the GNU General Public License and the MIT License and
27   -// is copyright 2008 A Beautiful Site, LLC.
  27 +// is copyright 2008 A Beautiful Site, LLC.
28 28 //
29 29 (function($) {
30   -
  30 +
31 31 $.alerts = {
32   -
  32 +
33 33 // These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time
34   -
  34 +
35 35 verticalOffset: -75, // vertical offset of the dialog from center screen, in pixels
36 36 horizontalOffset: 0, // horizontal offset of the dialog from center screen, in pixels/
37 37 repositionOnResize: true, // re-centers the dialog on window resize
... ... @@ -46,37 +46,37 @@
46 46 confirm: 'Confirm',
47 47 prompt: 'Prompt'
48 48 },
49   -
  49 +
50 50 // Public methods
51   -
  51 +
52 52 alert: function(message, title, callback) {
53 53 if (! title) title = $.alerts.titles.alert;
54 54 $.alerts._show(title, message, null, 'alert', function(result) {
55 55 if (callback) callback(result);
56 56 });
57 57 },
58   -
  58 +
59 59 confirm: function(message, title, callback) {
60 60 if (! title) title = $.alerts.titles.confirm;
61 61 $.alerts._show(title, message, null, 'confirm', function(result) {
62 62 if (callback) callback(result);
63 63 });
64 64 },
65   -
  65 +
66 66 prompt: function(message, value, title, callback) {
67 67 if (! title) title = $.alerts.titles.prompt;
68 68 $.alerts._show(title, message, value, 'prompt', function(result) {
69 69 if(callback) callback(result);
70 70 });
71 71 },
72   -
  72 +
73 73 // Private methods
74   -
  74 +
75 75 _show: function(title, msg, value, type, callback) {
76   -
  76 +
77 77 $.alerts._hide();
78 78 $.alerts._overlay('show');
79   -
  79 +
80 80 $("BODY").append(
81 81 '<div id="popup_container">' +
82 82 '<h1 id="popup_title"></h1>' +
... ... @@ -84,32 +84,34 @@
84 84 '<div id="popup_message"></div>' +
85 85 '</div>' +
86 86 '</div>');
87   -
  87 +
88 88 if( $.alerts.dialogClass ) $("#popup_container").addClass($.alerts.dialogClass);
89   -
  89 +
90 90 // IE6 Fix
91   - var pos = ($.browser.msie && parseInt($.browser.version, 10) <= 6 ) ? 'absolute' : 'fixed';
92   -
  91 + // No more $.browser in Jquery > 1,9 and not support IE 6
  92 + // var pos = ($.browser.msie && parseInt($.browser.version, 10) <= 6 ) ? 'absolute' : 'fixed';
  93 + var pos = 'fixed';
  94 +
93 95 $("#popup_container").css({
94 96 position: pos,
95 97 zIndex: 99999,
96 98 padding: 0,
97 99 margin: 0
98 100 });
99   -
  101 +
100 102 $("#popup_title").text(title);
101 103 $("#popup_content").addClass(type);
102 104 $("#popup_message").text(msg);
103 105 $("#popup_message").html( $("#popup_message").text().replace(/\n/g, '<br />') );
104   -
  106 +
105 107 $("#popup_container").css({
106 108 minWidth: $("#popup_container").outerWidth(),
107 109 maxWidth: $("#popup_container").outerWidth()
108 110 });
109   -
  111 +
110 112 $.alerts._reposition();
111 113 $.alerts._maintainPosition(true);
112   -
  114 +
113 115 switch( type ) {
114 116 case 'alert':
115 117 $("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /></div>');
... ... @@ -158,20 +160,20 @@
158 160 break;
159 161 default: break;
160 162 }
161   -
  163 +
162 164 // Make draggable
163 165 if ($.alerts.draggable && $.fn.draggable) {
164 166 $("#popup_container").draggable({ handle: $("#popup_title") });
165 167 $("#popup_title").css({ cursor: 'move' });
166 168 }
167 169 },
168   -
  170 +
169 171 _hide: function() {
170 172 $("#popup_container").remove();
171 173 $.alerts._overlay('hide');
172 174 $.alerts._maintainPosition(false);
173 175 },
174   -
  176 +
175 177 _overlay: function(status) {
176 178 switch( status ) {
177 179 case 'show':
... ... @@ -194,23 +196,23 @@
194 196 default: break;
195 197 }
196 198 },
197   -
  199 +
198 200 _reposition: function() {
199 201 var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset;
200 202 var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset;
201 203 if( top < 0 ) top = 0;
202 204 if( left < 0 ) left = 0;
203   -
  205 +
204 206 // IE6 fix
205   - if( $.browser.msie && parseInt($.browser.version, 10) <= 6 ) top = top + $(window).scrollTop();
206   -
  207 + // if( $.browser.msie && parseInt($.browser.version, 10) <= 6 ) top = top + $(window).scrollTop();
  208 +
207 209 $("#popup_container").css({
208 210 top: top + 'px',
209 211 left: left + 'px'
210 212 });
211 213 $("#popup_overlay").height( $(document).height() );
212 214 },
213   -
  215 +
214 216 _maintainPosition: function(status) {
215 217 if( $.alerts.repositionOnResize ) {
216 218 switch(status) {
... ... @@ -224,7 +226,7 @@
224 226 }
225 227 }
226 228 }
227   -
  229 +
228 230 };
229   -
230   -})(jQuery);
231 231 \ No newline at end of file
  232 +
  233 +})(jQuery);
... ...
app/assets/javascripts/rails.js
1 1 /**
2 2 * Unobtrusive scripting adapter for jQuery
3 3 *
4   - * Requires jQuery 1.6.0 or later.
  4 + * Requires jQuery 1.6.0. Not compatible to jquery > 1.9
5 5 * https://github.com/rails/jquery-ujs
6 6  
7 7 * Uploading file using rails.js
... ... @@ -131,11 +131,11 @@
131 131 method = element.data('method');
132 132 url = element.data('url');
133 133 data = element.serialize();
134   - if (element.data('params')) data = data + "&" + element.data('params');
  134 + if (element.data('params')) data = data + "&" + element.data('params');
135 135 } else {
136 136 method = element.data('method');
137 137 url = element.attr('href');
138   - data = element.data('params') || null;
  138 + data = element.data('params') || null;
139 139 }
140 140  
141 141 options = {
... ...