Skip to content

Commit

Permalink
Upgrade jQuery to 2.2.4.
Browse files Browse the repository at this point in the history
Include some tests for the drawer opening.
  • Loading branch information
dracos committed May 21, 2021
1 parent 5eddff3 commit d269fcf
Show file tree
Hide file tree
Showing 19 changed files with 126 additions and 104 deletions.
31 changes: 31 additions & 0 deletions .cypress/cypress/integration/simple_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,34 @@ describe('Clicking the "big green banner" on a map page', function() {
cy.get('.js-reporting-page--next').should('be.visible');
});
});

describe.only('Clicking on drawers', function() {
it('works on a direct report page', function() {
cy.visit('/report/15');
cy.contains('Get updates').click();
cy.contains('Receive email when updates are left').should('be.visible');
cy.contains('Get updates').click();
cy.contains('Receive email when updates are left').should('not.be.visible');
});

it('works on a pulled-in report page', function() {
cy.server();
cy.route('/report/*').as('show-report');
cy.visit('/around?lon=-2.295894&lat=51.526877&zoom=0');
// force to hopefully work around apparent Cypress SVG issue
cy.get('image[title="Lights out in tunnel"]:last').click({force: true});
cy.wait('@show-report');
cy.get('#side-report').contains('Get updates').click();
cy.contains('Receive email when updates are left').should('be.visible');
cy.get('#side-report').contains('Get updates').click();
cy.contains('Receive email when updates are left').should('not.be.visible');
});

it('works on an around page', function() {
cy.visit('/around?lon=-2.295894&lat=51.526877&zoom=0');
cy.contains('Get updates').click();
cy.contains('Which problems do you want alerts about?').should('be.visible');
cy.contains('Get updates').click();
cy.contains('Which problems do you want alerts about?').should('not.be.visible');
});
});
1 change: 0 additions & 1 deletion .jshintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
**/vendor/
web/jslib/
**/*.auto.min.js
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- Include failure count in send report error output, #3316
- Sort output in export script. #3323
- Show relevant updates in alert-update email preview. #3417
- Upgrade jQuery. #3017
- Open311 improvements:
- Consistent protected field ordering.
- Security:
Expand Down
6 changes: 0 additions & 6 deletions conf/apache-vhost.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,4 @@
AllowOverride None
</Directory>

Alias /jslib/ /home/yourname/fixmystreet/commonlib/jslib/
<Location /jslib>
AddOutputFilter DEFLATE js
Header append Cache-Control "no-transform"
</Location>

</VirtualHost>
3 changes: 0 additions & 3 deletions conf/httpd.conf-example
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ ExpiresByType application/javascript "access plus 10 years"
Header append Cache-Control "no-transform"
</Location>

# Don't want jslib being passed to Catalyst
RewriteRule ^/jslib(.*) /jslib$1 [L,PT]

# trap anything that reaches us here and send it to the Catalyst app
RewriteRule ^(.*)$ /fixmystreet_app_fastcgi.cgi$1 [L]

1 change: 0 additions & 1 deletion notes/no-update-server
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ apache_config() {
</Location>
Alias /admin/ $basedir/fixmystreet/web-admin/
Alias /jslib/ $basedir/fixmystreet/commonlib/jslib/
</VirtualHost>
EOF

Expand Down
2 changes: 1 addition & 1 deletion templates/web/base/common_header_tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
[% IF bodyclass.match('frontpage') %]
<link rel="prefetch" href="[% version('/js/validation_rules.js') %]">
[%~ IF NOT c.user_exists OR NOT (c.user.from_body OR c.user.is_superuser) %]
<link rel="prefetch" href="[% version('/jslib/jquery-1.7.2.min.js') %]">
<link rel="prefetch" href="[% version('/vendor/jquery-2.2.4.min.js') %]">
[%~ END %]
<link rel="prefetch" href="[% version('/vendor/jquery.multi-select.min.js') %]">
<link rel="prefetch" href="[% version('/vendor/jquery.validate.min.js') %]">
Expand Down
4 changes: 2 additions & 2 deletions templates/web/base/common_scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
ELSE;
scripts.push(
version('/js/validation_rules.js'),
version('/jslib/jquery-1.7.2.min.js'),
version('/vendor/jquery-2.2.4.min.js'),
version('/vendor/jquery.multi-select.min.js'),
version('/vendor/jquery.validate.min.js'),
version('/cobrands/fixmystreet/fixmystreet.js'),
Expand All @@ -37,7 +37,7 @@
IF c.user_exists AND (c.user.from_body OR c.user.is_superuser);
scripts.push(
version('/js/geolocation.js'),
version('/jslib/jquery-1.7.2.min.js'),
version('/vendor/jquery-2.2.4.min.js'),
version('/cobrands/fixmystreet/staff.js')
);
IF bodyclass.match('mappage') AND c.cobrand.suggest_duplicates AND NOT login_success AND NOT oauth_need_email;
Expand Down
2 changes: 1 addition & 1 deletion templates/web/base/report/_item_expandable.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Since the photo set includes `<a>` elements of its own, we drop the usual
"wrapper" `<a>` and the associated `.item-list--reports__item` class, to
avoid anchor nesting.
%]
~%]

[% truncated_detail = BLOCK %][% problem.detail | truncate(75, '…') | html_para %][% END ~%]
[% full_detail = BLOCK %][% problem.detail | add_links | html_para %][% END ~%]
Expand Down
2 changes: 1 addition & 1 deletion templates/web/bromley/footer_extra_js.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[% scripts.push(
version('/jslib/jquery-1.7.2.min.js'),
version('/vendor/jquery-2.2.4.min.js'),
version('/cobrands/bromley/a-z-nav.js'),
) %]
[% PROCESS 'footer_extra_js_base.html' cobrand_js=1 validation=1 tfl=1 roadworks=1 %]
2 changes: 1 addition & 1 deletion templates/web/tfl/footer_extra_js.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[% scripts.push(
version('/jslib/jquery-1.7.2.min.js'),
version('/vendor/jquery-2.2.4.min.js'),
) %]
[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 %]
[%~
Expand Down
2 changes: 1 addition & 1 deletion templates/web/zurich/footer_extra_js.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[% scripts.push(
version('/jslib/jquery-1.7.2.min.js'),
version('/vendor/jquery-2.2.4.min.js'),
version('/cobrands/zurich/validation_rules.js'),
'//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js',
version('/cobrands/zurich/js.js'),
Expand Down
137 changes: 72 additions & 65 deletions web/cobrands/fixmystreet/fixmystreet.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,26 @@ function isR2L() {
// that doesn't change the main content at all.
small_drawer: function(id) {
var $this = $(this), d = $('#' + id);
this.toggle(function() {
if (opened) {
opened.click();
}
if (!$this.addClass('hover').data('setup')) {
d.hide().removeClass('hidden-js').css({
padding: '1em',
background: '#fff'
});
$this.data('setup', true);
this.click(function(e) {
e.preventDefault();
if (!$this.hasClass('hover')) {
if (opened) {
opened.click();
}
if (!$this.addClass('hover').data('setup')) {
d.hide().removeClass('hidden-js').css({
padding: '1em',
background: '#fff'
});
$this.data('setup', true);
}
d.slideDown();
opened = $this;
} else {
$this.removeClass('hover');
d.slideUp();
opened = null;
}
d.slideDown();
opened = $this;
}, function(e) {
$this.removeClass('hover');
d.slideUp();
opened = null;
});
},

Expand All @@ -56,58 +59,62 @@ function isR2L() {
var $drawer = $('#' + id);

this.off('click');
this.toggle(function() {
// Find the specified drawer, or create it if it doesn't exist
if ($drawer.length === 0) {
$drawer = $('<div id="' + id + '">');
$drawer.appendTo($swparent);
}

if (!$this.addClass('hover').data('setup')) {
// Optionally fill $drawer with HTML from an AJAX data source
if (ajax) {
var href = $this.attr('href') + ';ajax=1';
var margin = isR2L() ? 'margin-left' : 'margin-right';
var $ajax_result = $('<div>').appendTo($drawer);
$ajax_result.html('<p style="text-align:center">Loading</p>');
$ajax_result.load(href);
this.click(function(e) {
e.preventDefault();
var drawer_top;
if (!$this.hasClass('hover')) {
// Find the specified drawer, or create it if it doesn't exist
if ($drawer.length === 0) {
$drawer = $('<div id="' + id + '">');
$drawer.appendTo($swparent);
}

// Style up the $drawer
var drawer_top = $(window).height() - $sw.height();
var drawer_css = {
position: 'fixed',
zIndex: 10,
top: drawer_top,
bottom: 0,
width: $sidebar.css('width'),
paddingLeft: $sidebar.css('padding-left'),
paddingRight: $sidebar.css('padding-right'),
overflow: 'auto',
background: '#fff'
};
drawer_css[isR2L() ? 'right' : 'left'] = 0;
$drawer.css(drawer_css).removeClass('hidden-js').find('h2').css({ marginTop: 0 });
$this.data('setup', true);
}
if (!$this.addClass('hover').data('setup')) {
// Optionally fill $drawer with HTML from an AJAX data source
if (ajax) {
var href = $this.attr('href') + ';ajax=1';
var margin = isR2L() ? 'margin-left' : 'margin-right';
var $ajax_result = $('<div>').appendTo($drawer);
$ajax_result.html('<p style="text-align:center">Loading</p>');
$ajax_result.load(href);
}

// Insert the .shadow-wrap controls into the top of the drawer.
$sw.addClass('static').prependTo($drawer);
// Style up the $drawer
drawer_top = $(window).height() - $sw.height();
var drawer_css = {
position: 'fixed',
zIndex: 10,
top: drawer_top,
bottom: 0,
width: $sidebar.css('width'),
paddingLeft: $sidebar.css('padding-left'),
paddingRight: $sidebar.css('padding-right'),
overflow: 'auto',
background: '#fff'
};
drawer_css[isR2L() ? 'right' : 'left'] = 0;
$drawer.css(drawer_css).removeClass('hidden-js').find('h2').css({ marginTop: 0 });
$this.data('setup', true);
}

// Animate the drawer into place, enitrely covering the sidebar.
var sidebar_top_px = $sidebar.position().top;
$drawer.show().animate({ top: sidebar_top_px }, 1000);
// Insert the .shadow-wrap controls into the top of the drawer.
$sw.addClass('static').prependTo($drawer);

}, function(e) {
// Slide the drawer down, move the .shadow-wrap back to its
// original parent, and hide the drawer for potential re-use later.
$this.removeClass('hover');
var drawer_top = $(window).height() - $sw.height();
// Animate the drawer into place, enitrely covering the sidebar.
var sidebar_top_px = $sidebar.position().top;
$drawer.show().animate({ top: sidebar_top_px }, 1000);

$drawer.animate({ top: drawer_top }, 1000, function() {
$sw.removeClass('static').appendTo($swparent);
$drawer.hide();
});
} else {
// Slide the drawer down, move the .shadow-wrap back to its
// original parent, and hide the drawer for potential re-use later.
$this.removeClass('hover');
drawer_top = $(window).height() - $sw.height();

$drawer.animate({ top: drawer_top }, 1000, function() {
$sw.removeClass('static').appendTo($swparent);
$drawer.hide();
});
}
});
},

Expand Down Expand Up @@ -374,7 +381,7 @@ $.extend(fixmystreet.set_up, {
$('#pc').focus();

// In case we've come here by clicking back to a form that disabled a submit button
$('form.validate input[type=submit]').removeAttr('disabled');
$('form.validate input[type=submit]').prop('disabled', false);

$('[data-confirm]').on('click', function() {
return confirm(this.getAttribute('data-confirm'));
Expand Down Expand Up @@ -624,7 +631,7 @@ $.extend(fixmystreet.set_up, {
};

// Delegation is necessary because category/subcategory may be replaced during the lifetime of the page
$("#problem_form").on("change.category", "[name^=category.]", function() {
$("#problem_form").on("change.category", '[name^="category."]', function() {
category_changed($(this).val());
});
$("#problem_form").on("change.category", "[name=category]", function(e, no_event){
Expand Down Expand Up @@ -779,7 +786,7 @@ $.extend(fixmystreet.set_up, {
$('input[type=submit]', $context).prop("disabled", true).removeClass('green-btn');
});
this.on("queuecomplete", function() {
$('input[type=submit]', $context).removeAttr('disabled').addClass('green-btn');
$('input[type=submit]', $context).prop('disabled', false).addClass('green-btn');
});
this.on("success", function(file, xhrResponse) {
var ids = $('input[name=upload_fileid]', $context).val().split(','),
Expand Down
7 changes: 1 addition & 6 deletions web/js/map-OpenLayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -996,12 +996,7 @@ $.extend(fixmystreet.utils, {
click.activate();
}

// Vector layers must be added onload as IE sucks
if ($.browser.msie) {
$(window).load(onload);
} else {
onload();
}
onload();

// Allow external scripts to react to pans/zooms on the map,
// by subscribing to $(fixmystreet).on('maps:update_view')
Expand Down
6 changes: 1 addition & 5 deletions web/js/map-wmts-zurich.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ fixmystreet.maps.matrix_ids = [

/* Admin dragging of pin */
if (fixmystreet.page == 'admin') {
if ($.browser.msie) {
$(window).load(function() { fixmystreet.maps.admin_drag(pin_dragged, true); });
} else {
fixmystreet.maps.admin_drag(pin_dragged, true);
}
fixmystreet.maps.admin_drag(pin_dragged, true);
}
});

Expand Down
1 change: 0 additions & 1 deletion web/jslib

This file was deleted.

10 changes: 5 additions & 5 deletions web/vendor/fancybox/jquery.fancybox-1.3.4.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
loading.hide();

if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
$.event.trigger('fancybox-cancel');
$('.fancybox-inline-tmp').trigger('fancybox-cancel');

busy = false;
return;
Expand Down Expand Up @@ -379,7 +379,7 @@
content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish);
};

$.event.trigger('fancybox-change');
$('.fancybox-inline-tmp').trigger('fancybox-change');

content
.empty()
Expand Down Expand Up @@ -597,7 +597,7 @@
}

if (currentOpts.type == 'iframe') {
$('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
$('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
}

wrap.show();
Expand Down Expand Up @@ -897,7 +897,7 @@

busy = true;

$.event.trigger('fancybox-cancel');
$('.fancybox-inline-tmp').trigger('fancybox-cancel');

_abort();

Expand Down Expand Up @@ -942,7 +942,7 @@
title.empty().hide();
wrap.hide();

$.event.trigger('fancybox-cleanup');
$('.fancybox-inline-tmp').trigger('fancybox-cleanup');

content.empty();

Expand Down
Loading

0 comments on commit d269fcf

Please sign in to comment.