diff --git a/client/dist/js/AssetAdmin.js b/client/dist/js/AssetAdmin.js index ab05186d..9238c02a 100644 --- a/client/dist/js/AssetAdmin.js +++ b/client/dist/js/AssetAdmin.js @@ -42,7 +42,7 @@ } }); - $('.AssetAdmin.cms-edit-form .ss-gridfield .col-buttons .action.gridfield-button-delete, .AssetAdmin.cms-edit-form .Actions button.action.action-delete').entwine({ + $('.AssetAdmin.cms-edit-form .ss-gridfield .col-buttons .action.gridfield-button-delete, .AssetAdmin.cms-edit-form .btn-toolbar button.action.action-delete').entwine({ onclick: function onclick(e) { var msg; if (this.closest('.ss-gridfield-item').data('class') == 'Folder') { @@ -103,11 +103,5 @@ $('.AssetAdmin.cms-edit-form .ss-gridfield').reload(); } }); - - $('.AssetAdmin .grid-levelup').entwine({ - onmatch: function onmatch() { - this.closest('.ui-tabs-panel').find('.cms-actions-row').prepend(this); - } - }); }); }); \ No newline at end of file diff --git a/client/dist/js/CMSMain.AddForm.js b/client/dist/js/CMSMain.AddForm.js index a0098c61..780207e2 100644 --- a/client/dist/js/CMSMain.AddForm.js +++ b/client/dist/js/CMSMain.AddForm.js @@ -1,179 +1,193 @@ (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; - } + 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'; + 'use strict'; - var _jQuery2 = _interopRequireDefault(_jQuery); + var _jQuery2 = _interopRequireDefault(_jQuery); - function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { - default: obj - }; - } + 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(''); - } - } - }); + _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); - }, + $(".cms-add-form").entwine({ + ParentID: 0, + ParentCache: {}, + onadd: function onadd() { + var self = this; - 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 = []; + 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); + }, - if (id) { - if (this.hasClass('loading')) return; - this.addClass('loading'); + 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 = []; - this.setParentID(id); - if (!parentTree.getValue()) parentTree.setValue(id); + if (id) { + if (this.hasClass('loading')) return; + this.addClass('loading'); - 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'); - } - }); + this.setParentID(id); + if (!parentTree.getValue()) parentTree.setValue(id); - return false; - } else { - disallowedChildren = hint && typeof hint.disallowedChildren !== 'undefined' ? hint.disallowedChildren : [], this.updateSelectionFilter(disallowedChildren, defaultChildClass); - } - }, + 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'); + } + }); - updateSelectionFilter: function updateSelectionFilter(disallowedChildren, defaultChildClass) { - var allAllowed = null; - this.find('#Form_AddForm_PageType li').each(function () { - var className = $(this).find('input').val(), - isAllowed = $.inArray(className, disallowedChildren) === -1; + return false; + } else { + disallowedChildren = hint && typeof hint.disallowedChildren !== 'undefined' ? hint.disallowedChildren : []; + this.updateSelectionFilter(disallowedChildren, defaultChildClass); + } + }, - $(this).setEnabled(isAllowed); - if (!isAllowed) $(this).setSelected(false); - if (allAllowed === null) allAllowed = isAllowed;else allAllowed = allAllowed && isAllowed; - }); + 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; - if (defaultChildClass) { - var selectedEl = this.find('#Form_AddForm_PageType li input[value=' + defaultChildClass + ']').parents('li:first'); - } else { - var selectedEl = this.find('#Form_AddForm_PageType li:not(.disabled):first'); - } - selectedEl.setSelected(true); - selectedEl.siblings().setSelected(false); + $(this).setEnabled(isAllowed); + if (!isAllowed) { + $(this).setSelected(false); + } + if (allAllowed === null) { + allAllowed = isAllowed; + } else { + allAllowed = allAllowed && isAllowed; + } + }); - var buttonState = this.find('#Form_AddForm_PageType li:not(.disabled)').length ? 'enable' : 'disable'; - this.find('button[name=action_doAdd]').button(buttonState); + 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); - this.find('.message-restricted')[allAllowed ? 'hide' : 'show'](); - } - }); + var buttonState = this.find('#Form_AddForm_PageType div.radio:not(.disabled)').length ? 'enable' : 'disable'; + this.find('button[name=action_doAdd]').button(buttonState); - $(".cms-add-form #Form_AddForm_PageType li").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'); - } - }); + this.find('.message-restricted')[allAllowed ? 'hide' : 'show'](); + } + }); - $(".cms-page-add-button").entwine({ - onclick: function onclick(e) { - var tree = $('.cms-tree'), - list = $('.cms-list'), - parentId = 0; + $(".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'); + } + } + }); - 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); - } + $(".cms-content-addpage-button").entwine({ + onclick: function onclick(e) { + var tree = $('.cms-tree'), + list = $('.cms-list'), + parentId = 0, + extraParams; - 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'); - } + 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); + } + } - $('.cms-container').loadPanel(url, null, data); - e.preventDefault(); + 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(); - } - }); - }); + this.blur(); + } + }); + }); }); \ No newline at end of file diff --git a/client/dist/js/CMSMain.EditForm.js b/client/dist/js/CMSMain.EditForm.js index 3d0b7df6..b58c79cd 100644 --- a/client/dist/js/CMSMain.EditForm.js +++ b/client/dist/js/CMSMain.EditForm.js @@ -179,7 +179,7 @@ } }); - $('.cms-edit-form .Actions #Form_EditForm_action_print').entwine({ + $('.cms-edit-form .btn-toolbar #Form_EditForm_action_print').entwine({ onclick: function onclick(e) { var printURL = $(this[0].form).attr('action').replace(/\?.*$/, '') + '/printable/' + $(':input[name=ID]', this[0].form).val(); if (printURL.substr(0, 7) != 'http://') printURL = $('base').attr('href') + printURL; @@ -190,7 +190,7 @@ } }); - $('.cms-edit-form .Actions #Form_EditForm_action_rollback').entwine({ + $('.cms-edit-form .btn-toolbar #Form_EditForm_action_rollback').entwine({ onclick: function onclick(e) { var form = this.parents('form:first'), version = form.find(':input[name=Version]').val(), @@ -208,7 +208,7 @@ } }); - $('.cms-edit-form .Actions #Form_EditForm_action_archive').entwine({ + $('.cms-edit-form .btn-toolbar #Form_EditForm_action_archive').entwine({ onclick: function onclick(e) { var form = this.parents('form:first'), version = form.find(':input[name=Version]').val(), @@ -222,7 +222,7 @@ } }); - $('.cms-edit-form .Actions #Form_EditForm_action_restore').entwine({ + $('.cms-edit-form .btn-toolbar #Form_EditForm_action_restore').entwine({ onclick: function onclick(e) { var form = this.parents('form:first'), version = form.find(':input[name=Version]').val(), @@ -237,7 +237,7 @@ } }); - $('.cms-edit-form .Actions #Form_EditForm_action_delete').entwine({ + $('.cms-edit-form .btn-toolbar #Form_EditForm_action_delete').entwine({ onclick: function onclick(e) { var form = this.parents('form:first'), version = form.find(':input[name=Version]').val(), @@ -251,7 +251,7 @@ } }); - $('.cms-edit-form .Actions #Form_EditForm_action_unpublish').entwine({ + $('.cms-edit-form .btn-toolbar #Form_EditForm_action_unpublish').entwine({ onclick: function onclick(e) { var form = this.parents('form:first'), version = form.find(':input[name=Version]').val(), @@ -280,7 +280,7 @@ } }); - $('.cms-edit-form .Actions button[name=action_publish]').entwine({ + $('.cms-edit-form .btn-toolbar button[name=action_publish]').entwine({ onbuttonafterrefreshalternate: function onbuttonafterrefreshalternate() { if (this.button('option', 'showingAlternate')) { this.addClass('ss-ui-action-constructive'); @@ -290,7 +290,7 @@ } }); - $('.cms-edit-form .Actions button[name=action_save]').entwine({ + $('.cms-edit-form .btn-toolbar button[name=action_save]').entwine({ onbuttonafterrefreshalternate: function onbuttonafterrefreshalternate() { if (this.button('option', 'showingAlternate')) { this.addClass('ss-ui-action-constructive'); diff --git a/client/src/legacy/AssetAdmin.js b/client/src/legacy/AssetAdmin.js index e2b79363..6f75b5c6 100644 --- a/client/src/legacy/AssetAdmin.js +++ b/client/src/legacy/AssetAdmin.js @@ -133,10 +133,4 @@ $.entwine('ss', function($){ $('.AssetAdmin.cms-edit-form .ss-gridfield').reload(); } }); - - $('.AssetAdmin .grid-levelup').entwine({ - onmatch: function () { - this.closest('.ui-tabs-panel').find('.cms-actions-row').prepend(this); - } - }) }); diff --git a/code/controllers/AssetAdmin.php b/code/controllers/AssetAdmin.php index 353cd832..adee40ff 100644 --- a/code/controllers/AssetAdmin.php +++ b/code/controllers/AssetAdmin.php @@ -166,7 +166,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{ new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm(), - GridFieldLevelup::create($folder->ID)->setLinkSpec('admin/assets/show/%d') + GridFieldLevelup::create($folder->ID)->setLinkSpec($this->Link('show') . '/%d') ); $gridField = GridField::create('File', $title, $this->getList(), $gridFieldConfig); diff --git a/gulpfile.js b/gulpfile.js index f84d513f..44fa281d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -101,12 +101,15 @@ gulp.task('bundle-legacy', function bundleLeftAndMain() { }); gulp.task('umd-cms', () => { // eslint-disable-line - return transformToUmd(glob.sync(`${PATHS.CMS_JS_SRC}/*.js`), PATHS.CMS_JS_DIST); + return transformToUmd(glob.sync( + `${PATHS.CMS_JS_SRC}/**/*.js`, + { ignore: `${PATHS.CMS_JS_SRC}/bundles/*` } + ), PATHS.CMS_JS_DIST); }); gulp.task('umd-watch', () => { // eslint-disable-line if (isDev) { - gulp.watch(`${PATHS.CMS_JS_SRC}/*.js`, ['umd-cms']); + gulp.watch(`${PATHS.CMS_JS_SRC}/**/*.js`, ['umd-cms']); } });