Skip to content

Commit

Permalink
Merge pull request #369 from divio/feature/cleanup-javascript
Browse files Browse the repository at this point in the history
Introduce webpack for js bundling
  • Loading branch information
vxsx authored Aug 26, 2016
2 parents d57212d + eee8c95 commit c194435
Show file tree
Hide file tree
Showing 23 changed files with 2,003 additions and 434 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.pyc
dist
!djangocms_admin_style/static/djangocms_admin_style/js/dist
*egg-info*
bin/
include/
Expand All @@ -10,7 +11,6 @@ database.db
.idea
.sass-cache
build
dist
.eggs
screenshots/results
screenshots/failures
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CHANGELOG
* Fixed an issue with sortable tables
* Fixed an issue with datetime fields
* Fixed an issue with long names and smaller screens in change list
* Added single js bundle vs many small javascript files

1.2.3 (2016-06-22)
------------------
Expand Down
4 changes: 0 additions & 4 deletions djangocms_admin_style/sass/ie.scss

This file was deleted.

96 changes: 0 additions & 96 deletions djangocms_admin_style/static/cms/PIE.htc

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions djangocms_admin_style/static/djangocms_admin_style/css/pie.css

This file was deleted.

108 changes: 21 additions & 87 deletions djangocms_admin_style/static/djangocms_admin_style/js/base-admin.js
Original file line number Diff line number Diff line change
@@ -1,87 +1,21 @@
(function () {
/**
* @function toggleClass
* @param {Element} element
* @param {String} className
* @returns {Boolean|void}
*/
function toggleClass(element, className) {
var classString = element.className;
var nameIndex = classString.indexOf(className);

if (!element || !className) {
return false;
}

if (nameIndex === -1) {
classString += ' ' + className;
} else {
classString = classString.substr(0, nameIndex) + classString.substr(nameIndex + className.length);
}

element.className = classString;
}

var submenu = document.getElementsByClassName('submenu')[0];
var menuItem = document.getElementsByClassName('menu-item')[0];
var html = document.getElementsByTagName('html')[0];


menuItem.addEventListener('click', function (event) {
var evt = event || window.event;

evt.preventDefault();

toggleClass(submenu, 'submenu-open');
toggleClass(menuItem, 'menu-item-open');
});


html.addEventListener('click', function (event) {
if (event.target !== menuItem) {
var submenuOpen = document.getElementsByClassName('submenu-open')[0];
var menuItemOpen = document.getElementsByClassName('menu-item-open')[0];

if (submenuOpen && menuItemOpen) {
submenuOpen.className = submenuOpen.className.replace('submenu-open', '');
menuItemOpen.className = menuItemOpen.className.replace('menu-item-open', '');
}
}
});

// Back to link
try {
var cmsFrameData = JSON.parse(window.name);
var headerLink = document.getElementsByClassName('js-header-link')[0];

if (cmsFrameData.name && cmsFrameData.name === 'cms_frame') {
headerLink.setAttribute('href', cmsFrameData.url);
}
} catch (error) {

}

if (window.jQuery || (window.django && window.django.jQuery)) {
// scopes the jQuery
(function ($) {
// waits for the document.ready
$(function () {
var toplinks = $('.toplinks');

// calls touch support function
if ($.fn.touchSupport && $('.drag-handler').length) {
$(window).touchSupport();
}
// this has to be done by javascript because we don't change html markup
// floats toolbar if actions are visible #275, #285
if ($('#changelist-form').find('.actions').length) {
$('#toolbar').addClass('actions-visible');
}
// adds class to toplinks if list is empty to remove unnecessary space
if (toplinks.children().length === 0 && toplinks.parent().hasClass('xfull')) {
toplinks.parent().addClass('hidden');
}
});
})(window.jQuery || window.django.jQuery);
}
})();
var $ = require('jquery');
var initDateTimeFields = require('./modules/datetimefields');
var initDragAndDropSupportForTreeBeard = require('./modules/drag-touch-support');
var initUIFixes = require('./modules/ui-fixes');
var initRelatedWidgetWrappers = require('./modules/related-widget-wrapper');
var initToolbarDropdown = require('./modules/toolbar-dropdown');

// this attaches to global jQuery because
// we need to touch punch the things like sortedm2m
// which use django jquery
//
// also, it's a custom script, so be careful with updating
require('./modules/jquery.ui.touch-punch.min');

$(function () {
initDateTimeFields();
initDragAndDropSupportForTreeBeard();
initUIFixes();
initRelatedWidgetWrappers();
initToolbarDropdown();
});

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit c194435

Please sign in to comment.