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