8000 Fixes/use svg icons by jrief · Pull Request #6457 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

Fixes/use svg icons #6457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed a bug where structureboard tried to preload markup with legacy …
…renderer
  • Loading branch information
vxsx committed May 28, 2018
commit f04a878ea4c8acdd3610b36d8f24cb7e635c45e7
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
regardless of the toolbar status (draft / live). This only affected custom
urls from an apphook.
* Removed extra quotation mark from the sideframe button template
* Fixed a bug where structureboard tried to preload markup when using legacy
renderer


=== 3.5.2 (2018-04-11) ===
Expand Down
2 changes: 1 addition & 1 deletion cms/static/cms/js/dist/3.5.2/bundle.toolbar.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions cms/static/cms/js/modules/cms.structureboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ class StructureBoard {
}

_preloadOppositeMode() {
if (CMS.config.settings.legacy_mode) {
return;
}
const WAIT_BEFORE_PRELOADING = 2000;

$(Helpers._getWindow()).one('load', () => {
Expand Down
1 change: 1 addition & 0 deletions cms/static/cms/js/modules/preload-images.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// istanbul ignore next
/**
* preload
*
Expand Down
37 changes: 37 additions & 0 deletions cms/tests/frontend/unit/cms.structureboard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ describe('CMS.StructureBoard', function() {

expect(board.ui.toolbarModeSwitcher.find('.cms-btn')).toHaveClass('cms-btn-disabled');
});

it('sets loaded content and structure flags if it is a legacy renderer', () => {
CMS.config.settings.legacy_mode = true;
board = new CMS.Struct 10000 ureBoard();
expect(board._loadedStructure).toEqual(true);
expect(board._loadedContent).toEqual(true);
});
});

describe('.show()', function() {
Expand Down Expand Up @@ -2539,6 +2546,36 @@ describe('CMS.StructureBoard', function() {
StructureBoard.__ResetDependency__('Helpers');
});
});

it('does not preload the opposite mode (legacy renderer)', () => {
const div = document.createElement('div');
const _getWindow = jasmine.createSpy().and.returnValue(div);

StructureBoard.__Rewire__('Helpers', {
_getWindow
});

const board = new StructureBoard();

spyOn(board, '_requestMode');

jasmine.clock().install();

CMS.config.settings.legacy_mode = true;
board._loadedContent = true;
board._loadedStructure = true;

board._preloadOppositeMode();
expect(board._requestMode).not.toHaveBeenCalled();
$(div).trigger('load');
expect(board._requestMode).not.toHaveBeenCalled();
jasmine.clock().tick(2001);
expect(board._requestMode).not.toHaveBeenCalled();

jasmine.clock().uninstall();

StructureBoard.__ResetDependency__('Helpers');
});
});

describe('actualizePluginCollapseStatus', () => {
Expand Down
1 change: 1 addition & 0 deletions cms/tests/frontend/unit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ if (files[0] === '*') {
require('./cms.modal.test');
require('./shortcuts.test');
require('./keyboard.test');
require('./preload-images.test');
// FIXME this has to be last because it messes with the url
require('./cms.structureboard.test'); // missing some tests
} else {
Expand Down
61 changes: 61 additions & 0 deletions cms/tests/frontend/unit/preload-images.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
'use strict';
const preloadImagesFromMarkup = require('../../../static/cms/js/modules/preload-images').default;

describe('preloadImagesFromMarkup', () => {
let preload;

beforeEach(() => {
preload = jasmine.createSpy();
preloadImagesFromMarkup.__Rewire__('preload', preload);
});

afterEach(() => {
preloadImagesFromMarkup.__ResetDependency__('preload');
});

const tests = [
{
input: 'no img',
expected: []
},
{
input: '<img src="whatever">',
expected: ['whatever']
},
{
input: "<img src='whatever'>",
expected: ['whatever']
},
{
input: `<img
src="whatever"
class="x" other attributes />`,
expected: ['whatever']
},
{
input: `
<img src="/static/img1.png">
<img src="/static/img2.png">
`,
expected: [
'/static/img1.png',
'/static/img2.png'
]
},
{
input: '<IMG CLASS="WUT" src="/static/img1.jpg?2" />',
expected: [
'/static/img1.jpg?2'
]
}
];

tests.forEach((test, i) => {
it(`preloads images from markup ${i}`, () => {
preloadImagesFromMarkup(test.input);

expect(preload).toHaveBeenCalledTimes(test.expected.length);
test.expected.forEach(ex => expect(preload).toHaveBeenCalledWith(ex));
});
});
});
0