From 5c31bf357b60df258f13649288f3bb88d9498b83 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 21 Sep 2016 13:07:03 +1200 Subject: [PATCH] Remove framework bundle include This is now handled through one combined bundle which is included through LeftAndMain.php (in framework module) Rename bundle-legacy.js to bundle.js: It'll contain more than legacy stuff eventually Remove leftover dist artefacts: These weren't part of the webpack build any more Building SilverStripeNavigator separately (and rename bundle) --- client/dist/js/CMSMain.AddForm.js | 193 ------------ client/dist/js/CMSMain.EditForm.js | 324 -------------------- client/dist/js/CMSMain.Tree.js | 163 ---------- client/dist/js/CMSMain.js | 104 ------- client/dist/js/CMSPageHistoryController.js | 134 -------- client/dist/js/RedirectorPage.js | 48 --- client/dist/js/SilverStripeNavigator.js | 52 +--- client/dist/js/SiteTreeURLSegmentField.js | 131 -------- client/dist/js/bundle-legacy.js | 2 - client/dist/js/bundle.js | 2 + client/src/bundles/{legacy.js => bundle.js} | 1 - code/Controllers/CMSMain.php | 14 +- code/Forms/SiteTreeURLSegmentField.php | 3 - webpack.config.js | 5 +- 14 files changed, 9 insertions(+), 1167 deletions(-) delete mode 100644 client/dist/js/CMSMain.AddForm.js delete mode 100644 client/dist/js/CMSMain.EditForm.js delete mode 100644 client/dist/js/CMSMain.Tree.js delete mode 100644 client/dist/js/CMSMain.js delete mode 100644 client/dist/js/CMSPageHistoryController.js delete mode 100644 client/dist/js/RedirectorPage.js delete mode 100644 client/dist/js/SiteTreeURLSegmentField.js delete mode 100644 client/dist/js/bundle-legacy.js create mode 100644 client/dist/js/bundle.js rename client/src/bundles/{legacy.js => bundle.js} (87%) diff --git a/client/dist/js/CMSMain.AddForm.js b/client/dist/js/CMSMain.AddForm.js deleted file mode 100644 index 780207e2..00000000 --- a/client/dist/js/CMSMain.AddForm.js +++ /dev/null @@ -1,193 +0,0 @@ -(function (global, factory) { - if (typeof define === "function" && define.amd) { - define('ss.CMSMain.AddForm', ['jQuery'], factory); - } else if (typeof exports !== "undefined") { - factory(require('jQuery')); - } else { - var mod = { - exports: {} - }; - factory(global.jQuery); - global.ssCMSMainAddForm = mod.exports; - } -})(this, function (_jQuery) { - 'use strict'; - - var _jQuery2 = _interopRequireDefault(_jQuery); - - function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { - default: obj - }; - } - - _jQuery2.default.entwine('ss', function ($) { - $(".cms-add-form .parent-mode :input").entwine({ - onclick: function onclick(e) { - if (this.val() == 'top') { - var parentField = this.closest('form').find('#Form_AddForm_ParentID_Holder .TreeDropdownField'); - parentField.setValue(''); - parentField.setTitle(''); - } - } - }); - - $(".cms-add-form").entwine({ - ParentID: 0, - ParentCache: {}, - onadd: function onadd() { - var self = this; - - this.find('#Form_AddForm_ParentID_Holder .TreeDropdownField').bind('change', function () { - self.updateTypeList(); - }); - this.find(".SelectionGroup.parent-mode").bind('change', function () { - self.updateTypeList(); - }); - this.updateTypeList(); - }, - loadCachedChildren: function loadCachedChildren(parentID) { - var cache = this.getParentCache(); - if (typeof cache[parentID] !== 'undefined') return cache[parentID];else return null; - }, - saveCachedChildren: function saveCachedChildren(parentID, children) { - var cache = this.getParentCache(); - cache[parentID] = children; - this.setParentCache(cache); - }, - - updateTypeList: function updateTypeList() { - var hints = this.data('hints'), - parentTree = this.find('#Form_AddForm_ParentID_Holder .TreeDropdownField'), - parentMode = this.find("input[name=ParentModeField]:checked").val(), - metadata = parentTree.data('metadata'), - id = metadata && parentMode === 'child' ? parentTree.getValue() || this.getParentID() : null, - newClassName = metadata ? metadata.ClassName : null, - hintKey = newClassName && parentMode === 'child' ? newClassName : 'Root', - hint = typeof hints[hintKey] !== 'undefined' ? hints[hintKey] : null, - self = this, - defaultChildClass = hint && typeof hint.defaultChild !== 'undefined' ? hint.defaultChild : null, - disallowedChildren = []; - - if (id) { - if (this.hasClass('loading')) return; - this.addClass('loading'); - - this.setParentID(id); - if (!parentTree.getValue()) parentTree.setValue(id); - - disallowedChildren = this.loadCachedChildren(id); - if (disallowedChildren !== null) { - this.updateSelectionFilter(disallowedChildren, defaultChildClass); - this.removeClass('loading'); - return; - } - $.ajax({ - url: self.data('childfilter'), - data: { 'ParentID': id }, - success: function success(data) { - self.saveCachedChildren(id, data); - self.updateSelectionFilter(data, defaultChildClass); - }, - complete: function complete() { - self.removeClass('loading'); - } - }); - - return false; - } else { - disallowedChildren = hint && typeof hint.disallowedChildren !== 'undefined' ? hint.disallowedChildren : []; - this.updateSelectionFilter(disallowedChildren, defaultChildClass); - } - }, - - updateSelectionFilter: function updateSelectionFilter(disallowedChildren, defaultChildClass) { - var allAllowed = null; - this.find('#Form_AddForm_PageType div.radio').each(function () { - var className = $(this).find('input').val(), - isAllowed = $.inArray(className, disallowedChildren) === -1; - - $(this).setEnabled(isAllowed); - if (!isAllowed) { - $(this).setSelected(false); - } - if (allAllowed === null) { - allAllowed = isAllowed; - } else { - allAllowed = allAllowed && isAllowed; - } - }); - - if (defaultChildClass) { - var selectedEl = this.find('#Form_AddForm_PageType div.radio input[value=' + defaultChildClass + ']').parents('li:first'); - } else { - var selectedEl = this.find('#Form_AddForm_PageType div.radio:not(.disabled):first'); - } - selectedEl.setSelected(true); - selectedEl.siblings().setSelected(false); - - var buttonState = this.find('#Form_AddForm_PageType div.radio:not(.disabled)').length ? 'enable' : 'disable'; - this.find('button[name=action_doAdd]').button(buttonState); - - this.find('.message-restricted')[allAllowed ? 'hide' : 'show'](); - } - }); - - $(".cms-add-form #Form_AddForm_PageType div.radio").entwine({ - onclick: function onclick(e) { - this.setSelected(true); - }, - setSelected: function setSelected(bool) { - var input = this.find('input'); - if (bool && !input.is(':disabled')) { - this.siblings().setSelected(false); - this.toggleClass('selected', true); - input.prop('checked', true); - } else { - this.toggleClass('selected', false); - input.prop('checked', false); - } - }, - setEnabled: function setEnabled(bool) { - $(this).toggleClass('disabled', !bool); - if (!bool) { - $(this).find('input').attr('disabled', 'disabled').removeAttr('checked'); - } else { - $(this).find('input').removeAttr('disabled'); - } - } - }); - - $(".cms-content-addpage-button").entwine({ - onclick: function onclick(e) { - var tree = $('.cms-tree'), - list = $('.cms-list'), - parentId = 0, - extraParams; - - if (tree.is(':visible')) { - var selected = tree.jstree('get_selected'); - parentId = selected ? $(selected[0]).data('id') : null; - } else { - var state = list.find('input[name="Page[GridState]"]').val(); - if (state) { - parentId = parseInt(JSON.parse(state).ParentID, 10); - } - } - - var data = { selector: this.data('targetPanel'), pjax: this.data('pjax') }, - url; - if (parentId) { - extraParams = this.data('extraParams') ? this.data('extraParams') : ''; - url = $.path.addSearchParams(i18n.sprintf(this.data('urlAddpage'), parentId), extraParams); - } else { - url = this.attr('href'); - } - $('.cms-container').loadPanel(url, null, data); - e.preventDefault(); - - this.blur(); - } - }); - }); -}); \ No newline at end of file diff --git a/client/dist/js/CMSMain.EditForm.js b/client/dist/js/CMSMain.EditForm.js deleted file mode 100644 index b58c79cd..00000000 --- a/client/dist/js/CMSMain.EditForm.js +++ /dev/null @@ -1,324 +0,0 @@ -(function (global, factory) { - if (typeof define === "function" && define.amd) { - define('ss.CMSMain.EditForm', ['jQuery', 'i18n'], factory); - } else if (typeof exports !== "undefined") { - factory(require('jQuery'), require('i18n')); - } else { - var mod = { - exports: {} - }; - factory(global.jQuery, global.i18n); - global.ssCMSMainEditForm = mod.exports; - } -})(this, function (_jQuery, _i18n) { - 'use strict'; - - var _jQuery2 = _interopRequireDefault(_jQuery); - - var _i18n2 = _interopRequireDefault(_i18n); - - function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { - default: obj - }; - } - - _jQuery2.default.entwine('ss', function ($) { - $('.cms-edit-form :input[name=ClassName]').entwine({ - onchange: function onchange() { - alert(_i18n2.default._t('CMSMAIN.ALERTCLASSNAME')); - } - }); - - $('.cms-edit-form input[name=Title]').entwine({ - onmatch: function onmatch() { - var self = this; - - self.data('OrigVal', self.val()); - - var form = self.closest('form'); - var urlSegmentInput = $('input:text[name=URLSegment]', form); - var liveLinkInput = $('input[name=LiveLink]', form); - - if (urlSegmentInput.length > 0) { - self._addActions(); - this.bind('change', function (e) { - var origTitle = self.data('OrigVal'); - var title = self.val(); - self.data('OrigVal', title); - - if (urlSegmentInput.val().indexOf(urlSegmentInput.data('defaultUrl')) === 0 && liveLinkInput.val() == '') { - self.updateURLSegment(title); - } else { - $('.update', self.parent()).show(); - } - - self.updateRelatedFields(title, origTitle); - self.updateBreadcrumbLabel(title); - }); - } - - this._super(); - }, - onunmatch: function onunmatch() { - this._super(); - }, - - updateRelatedFields: function updateRelatedFields(title, origTitle) { - this.parents('form').find('input[name=MetaTitle], input[name=MenuTitle]').each(function () { - var $this = $(this); - if ($this.val() == origTitle) { - $this.val(title); - - if ($this.updatedRelatedFields) $this.updatedRelatedFields(); - } - }); - }, - - updateURLSegment: function updateURLSegment(title) { - var urlSegmentInput = $('input:text[name=URLSegment]', this.closest('form')); - var urlSegmentField = urlSegmentInput.closest('.field.urlsegment'); - var updateURLFromTitle = $('.update', this.parent()); - urlSegmentField.update(title); - if (updateURLFromTitle.is(':visible')) { - updateURLFromTitle.hide(); - } - }, - - updateBreadcrumbLabel: function updateBreadcrumbLabel(title) { - var pageID = $('.cms-edit-form input[name=ID]').val(); - var panelCrumb = $('span.cms-panel-link.crumb'); - if (title && title != "") { - panelCrumb.text(title); - } - }, - - _addActions: function _addActions() { - var self = this; - var updateURLFromTitle; - - updateURLFromTitle = $('