-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #369 from divio/feature/cleanup-javascript
Introduce webpack for js bundling
- Loading branch information
Showing
23 changed files
with
2,003 additions
and
434 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
djangocms_admin_style/static/djangocms_admin_style/css/pie.css
This file was deleted.
Oops, something went wrong.
108 changes: 21 additions & 87 deletions
108
djangocms_admin_style/static/djangocms_admin_style/js/base-admin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
161 changes: 0 additions & 161 deletions
161
djangocms_admin_style/static/djangocms_admin_style/js/datetimefields.js
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
djangocms_admin_style/static/djangocms_admin_style/js/dist/bundle.adminstyle.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
djangocms_admin_style/static/djangocms_admin_style/js/libs/jquery.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.