This is an automated email from the ASF dual-hosted git repository. dklco pushed a commit to branch SLING-7900 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git
commit f74e7cb6e7e844335607cdfb0201edad92412d48 Merge: e0b2b83 e1374dd Author: Dan Klco <[email protected]> AuthorDate: Thu Oct 4 12:38:23 2018 -0400 Merging in master README.md | 6 +- core/pom.xml | 23 +- .../core/internal/filters/EditIncludeFilter.java | 15 +- .../internal/operations/BulkReplaceOperation.java | 253 +++++++++++---------- .../apache/sling/cms/core/models/ErrorHandler.java | 195 ++++++++++++---- .../apache/sling/cms/core/models/package-info.java | 2 - docs/admin-tools.md | 4 +- docs/administration.md | 3 +- docs/developers.md | 3 +- docs/img/add-config.png | Bin 35261 -> 18883 bytes docs/img/add-taxonomy.png | Bin 54030 -> 22675 bytes docs/img/add-template.png | Bin 82285 -> 19221 bytes docs/img/bulk-replace.png | Bin 55838 -> 36012 bytes docs/img/component-configurations.png | Bin 56299 -> 38301 bytes docs/img/component-editor.png | Bin 90386 -> 96528 bytes docs/img/configuration-fields.png | Bin 28453 -> 16335 bytes docs/img/configure-security-filter.png | Bin 77137 -> 48229 bytes docs/img/container-add.png | Bin 91196 -> 37214 bytes docs/img/content-packages.png | Bin 97449 -> 60455 bytes docs/img/create-site-configuration.png | Bin 64338 -> 23424 bytes docs/img/create-site-group.png | Bin 57275 -> 20512 bytes docs/img/create-site.png | Bin 58038 -> 25812 bytes docs/img/delete-dialog.png | Bin 72693 -> 53006 bytes docs/img/edit-file-config.png | Bin 74938 -> 57158 bytes docs/img/edit-site-configuration.png | Bin 112002 -> 56785 bytes docs/img/edit-template.png | Bin 71898 -> 53255 bytes docs/img/editor-topbar.png | Bin 135874 -> 113918 bytes docs/img/internationalization.png | Bin 55605 -> 33725 bytes docs/img/load-content.png | Bin 49462 -> 33793 bytes docs/img/manage-versions.png | Bin 79397 -> 38901 bytes docs/img/mappings.png | Bin 76531 -> 33685 bytes docs/img/move-copy.png | Bin 70051 -> 53038 bytes docs/img/node-browser.png | Bin 67381 -> 38589 bytes docs/img/osgi-console.png | Bin 147524 -> 93708 bytes docs/img/sample-console.png | Bin 67453 -> 29716 bytes docs/img/select-config-component-type.png | Bin 48785 -> 33449 bytes docs/img/select-field-type.png | Bin 47648 -> 28452 bytes docs/img/site-content.png | Bin 78605 -> 34216 bytes docs/img/ugc-approval.png | Bin 0 -> 61884 bytes docs/img/ugc-console.png | Bin 0 -> 49303 bytes docs/img/use-taxonomy.png | Bin 28360 -> 14997 bytes docs/img/users-groups.png | Bin 54151 -> 31634 bytes docs/intro.md | 17 +- docs/quickstart.md | 6 +- docs/releases.md | 54 +++++ docs/user-generated-content.md | 48 ++++ pom.xml | 25 +- ui/src/main/frontend/gulpfile.js | 7 +- ui/src/main/frontend/package.json | 7 +- ui/src/main/frontend/src/js/cms.js | 52 +++-- ui/src/main/frontend/src/js/editor.js | 202 ++++++++-------- ui/src/main/frontend/src/scss/cms.scss | 9 + .../components/cms/editconfig/editconfig.jsp | 4 +- .../components/cms/searchresults/searchresults.jsp | 86 +++---- .../components/cms/suffixswitch/suffixswitch.jsp | 2 +- .../components/editor/fields/path/path.jsp | 2 +- .../components/editor/scripts/finalize.jsp | 2 +- .../components/general/container/container.jsp | 2 +- .../libs/sling-cms/components/pages/base/nav.jsp | 36 ++- .../sling-cms/components/pages/editor/body.jsp | 2 +- .../pages/editor/{body.jsp => editor.jsp} | 8 +- .../libs/sling-cms/content/shared/search.json | 53 +++++ .../libs/sling/servlet/errorhandler/default.jsp | 3 +- 63 files changed, 734 insertions(+), 397 deletions(-) diff --cc core/pom.xml index 2b20be9,640e9f2..8362b93 --- a/core/pom.xml +++ b/core/pom.xml @@@ -186,13 -183,8 +183,17 @@@ <version>${project.version}</version> </dependency> <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.xss</artifactId> + <scope>provided</scope> + <version>2.0.0</version> + </dependency> ++ <dependency> + <groupId>org.apache.jackrabbit</groupId> + <artifactId>oak-core</artifactId> + </dependency> </dependencies> + <properties> + <sling.java.version>8</sling.java.version> + </properties> </project> diff --cc core/src/main/java/org/apache/sling/cms/core/models/package-info.java index da2cdc7,a8c656b..1118341 --- a/core/src/main/java/org/apache/sling/cms/core/models/package-info.java +++ b/core/src/main/java/org/apache/sling/cms/core/models/package-info.java @@@ -19,10 -19,8 +19,8 @@@ /** * Package with all of the core models used to support the Sling reference CMS - * - * @version 0.9.0 */ -@Version("2.0.0") +@Version("1.1.0") package org.apache.sling.cms.core.models; import org.osgi.annotation.versioning.Version; diff --cc ui/src/main/frontend/src/js/cms.js index 41cb831,3b2f306..730e823 --- a/ui/src/main/frontend/src/js/cms.js +++ b/ui/src/main/frontend/src/js/cms.js @@@ -19,554 -19,516 +19,566 @@@ var Sling = {}; Sling.CMS = { - ext: {}, - decorate: function($ctx){ - for (var key in Sling.CMS.ext) { - if(typeof Sling.CMS.ext[key].decorate == 'function'){ - console.log('Invoking decorate for '+key); - Sling.CMS.ext[key].decorate($ctx); + ext : {}, + decorate : function($ctx) { + for ( var key in Sling.CMS.ext) { + if (typeof Sling.CMS.ext[key].decorate == 'function') { + console.log('Invoking decorate for ' + key); + Sling.CMS.ext[key].decorate($ctx); + } + } + }, + init : function() { + for ( var key in Sling.CMS.ext) { + if (typeof Sling.CMS.ext[key].init == 'function') { + console.log('Invoking init for ' + key); + Sling.CMS.ext[key].init(); + } + } + Sling.CMS.decorate($(document)); + }, + ui : { + confirmMessage : function(title, message, complete) { + var $modal = $('<div class="modal"><div class="modal-background"></div><div class="modal-card is-draggable"><header class="modal-card-head"><p class="modal-card-title">' + + title + + '</p></header><section class="modal-card-body">' + + message + + '</section><footer class="modal-card-foot"><button type="button" class="close-modal button is-primary">OK</button></footer></div>'); + $('body').append($modal); + Sling.CMS.decorate($modal); + $modal.addClass('is-active'); + $modal.find('.delete,.close-modal').click(function() { + $modal.css('display', 'none').remove(); + complete(); + }); + return $modal; + }, + fetchModal : function(title, link, path, complete) { + var $modal = $('<div class="modal"><div class="modal-background"></div><div class="modal-card is-draggable"><header class="modal-card-head"><p class="modal-card-title">' + + title + + '</p></header><section class="modal-card-body"></section><footer class="modal-card-foot"><a class="close-modal is-danger button" aria-label="close">Cancel</a></footer></div>'); + $('body').append($modal); + $modal.find('.modal-card-body').load(link, function() { + var submitButton = $modal.find('button:submit'); + var closeButton = $modal.find('.close-modal'); + submitButton.insertBefore(closeButton); + submitButton.on("click", function() { + $modal.find('form').submit(); + }) + $modal.addClass('is-active'); + closeButton.click(function() { + $modal.css('display', 'none').remove(); + return false; + }); + Sling.CMS.decorate($modal); + complete(); + }); + return $modal; + } + }, + utils : { + form2Obj : function($form) { + var data = {}; + $.map($form.serializeArray(), function(n, i) { + data[n['name']] = n['value']; + }); + return data; + } + } +}; + +Sling.CMS.ext['ajaxform'] = { + decorate : function($ctx) { + $ctx + .find('.Form-Ajax') + .submit( + function() { + + var $form = $(this); + var jcrcontent = false; + $form.find('input,select,textarea').each(function(idx, inp) { + if (inp.name.indexOf('jcr:content') != -1) { + jcrcontent = true; } - } - }, - init: function(){ - for (var key in Sling.CMS.ext) { - if(typeof Sling.CMS.ext[key].init == 'function'){ - console.log('Invoking init for '+key); - Sling.CMS.ext[key].init(); + }); + if ($form.data('addDate') + && $form.find('input[name="jcr:content/jcr:lastModified"]').length == 0) { + if (jcrcontent) { + $form + .append('<input type="hidden" name="jcr:content/jcr:lastModified" />'); + $form + .append('<input type="hidden" name="jcr:content/jcr:lastModifiedBy" />'); + $form + .append('<input type="hidden" name="jcr:content/jcr:created" />'); + $form + .append('<input type="hidden" name="jcr:content/jcr:createdBy" />'); + } else { + $form + .append('<input type="hidden" name="jcr:lastModified" />'); + $form + .append('<input type="hidden" name="jcr:lastModifiedBy" />'); + $form.append('<input type="hidden" name="jcr:created" />'); + $form.append('<input type="hidden" name="jcr:createdBy" />'); } - } - Sling.CMS.decorate($(document)); - }, - ui: { - confirmMessage: function(title, message, complete){ - var $modal = $('<div class="modal"><div class="modal-background"></div><div class="modal-card is-draggable"><header class="modal-card-head"><p class="modal-card-title">'+title+'</p><button class="delete" aria-label="close"></button></header><section class="modal-card-body">'+message+'</section><footer class="modal-card-foot"><button type="button" class="close-modal button is-primary">OK</button></footer></div>'); - $('body').append($modal); - Sling.CMS.decorate($modal); - $modal.addClass('is-active'); - $modal.find('.delete,.close-modal').click(function(){ - $modal.css('display','none').remove(); - complete(); - }); - return $modal; - }, - fetchModal: function(title, link, path, complete){ - var $modal = $('<div class="modal"><div class="modal-background"></div><div class="modal-card is-draggable"><header class="modal-card-head"><p class="modal-card-title">'+title+'</p><button class="delete" aria-label="close"></button></header><section class="modal-card-body"></section><footer class="modal-card-foot"></footer></div>'); - $('body').append($modal); - $modal.find('.modal-card-body').load(link + " " +path,function(){ - $modal.addClass('is-active'); - $modal.find('.delete,.close-modal').click(function(){ - $modal.css('display','none').remove(); - return false; + } + var callback = $form.data('callback'); + var data = new FormData(this); + $form.find('.Form-Ajax__wrapper').attr('disabled', 'disabled'); + $.ajax({ + url : $form.attr('action'), + type : 'POST', + data : data, + processData : false, + contentType : false, + dataType : 'json', + success : function(res, msg) { + if (callback && Sling.CMS.ext[callback]) { + Sling.CMS.ext[callback](res, msg); + } else { + Sling.CMS.ext.reload(res, msg); + } + }, + error : function(xhr, msg, err) { + if (window.self !== window.top) { + window.top.Sling.CMS.ui.confirmMessage(msg, err, + function() { + $form.find('.Form-Ajax__wrapper').removeAttr( + 'disabled'); + }); + } else { + Sling.CMS.ui.confirmMessage(msg, err, function() { + $form.find('.Form-Ajax__wrapper').removeAttr('disabled'); }); - Sling.CMS.decorate($modal); - complete(); - }); - return $modal; - } - }, - utils: { - form2Obj: function ($form){ - var data = {}; - $.map($form.serializeArray(), function(n, i){ - data[n['name']] = n['value']; - }); - return data; - } - } - }; - - Sling.CMS.ext['ajaxform'] = { - decorate: function($ctx){ - $ctx.find('.Form-Ajax').submit(function(){ - - var $form = $(this); - var jcrcontent = false; - $form.find('input,select,textarea').each(function(idx,inp){ - if(inp.name.indexOf('jcr:content') != -1){ - jcrcontent = true; - } - }); - if($form.data('addDate') && $form.find('input[name="jcr:content/jcr:lastModified"]').length == 0){ - if(jcrcontent){ - $form.append('<input type="hidden" name="jcr:content/jcr:lastModified" />'); - $form.append('<input type="hidden" name="jcr:content/jcr:lastModifiedBy" />'); - $form.append('<input type="hidden" name="jcr:content/jcr:created" />'); - $form.append('<input type="hidden" name="jcr:content/jcr:createdBy" />'); - } else { - $form.append('<input type="hidden" name="jcr:lastModified" />'); - $form.append('<input type="hidden" name="jcr:lastModifiedBy" />'); - $form.append('<input type="hidden" name="jcr:created" />'); - $form.append('<input type="hidden" name="jcr:createdBy" />'); - } + } } - var callback = $form.data('callback'); - var data = new FormData(this); - $form.find('.Form-Ajax__wrapper').attr('disabled', 'disabled'); - $.ajax({ - url: $form.attr('action'), - type: 'POST', - data: data, - processData: false, - contentType: false, - dataType: 'json', - success: function(res,msg){ - if (callback && Sling.CMS.ext[callback]){ - Sling.CMS.ext[callback](res, msg); - } else { - Sling.CMS.ext.reload(res, msg); - } - }, - error: function(xhr, msg, err){ - if(window.self !== window.top){ - window.top.Sling.CMS.ui.confirmMessage(msg, err,function(){ - $form.find('.Form-Ajax__wrapper').removeAttr('disabled'); - }); - } else { - Sling.CMS.ui.confirmMessage(msg, err,function(){ - $form.find('.Form-Ajax__wrapper').removeAttr('disabled'); - }); - } - } - }); - return false; + }); + return false; }); - } - }; + } +}; - Sling.CMS.ext['draggable'] = { - decorate: function($ctx) { - var draggable = function(){ - var element = this; - var mouseX; - var mouseY; - var mouseDown = false; - var elementX = 0; - var elementY = 0; - - // mouse button down over the element - element.addEventListener('mousedown', function(evt){ - if(evt.target.matches('.modal-card-body *')){ - return; - } - mouseX = evt.clientX; - mouseY = evt.clientY; - mouseDown = true; - }); - - var moveComplete = function(){ - mouseDown = false; - elementX = parseInt(element.style.left) || 0; - elementY = parseInt(element.style.top) || 0; - return false; - } - - element.addEventListener('mouseup', moveComplete); - document.addEventListener('mouseout', moveComplete); - - document.addEventListener('mousemove', function(event) { - if (!mouseDown) { - return; - } - var deltaX = event.clientX - mouseX; - var deltaY = event.clientY - mouseY; - element.style.left = elementX + deltaX + 'px'; - element.style.top = elementY + deltaY + 'px'; - return false; - }); - - }; - if($ctx.is('.is-draggable')){ - $ctx.each(draggable) - } - $ctx.find('.is-draggable').each(draggable); - } - }; - - Sling.CMS.ext['load-versions'] = { - loaded: false, - decorate: function($ctx) { - if(!Sling.CMS.ext['load-versions'].loaded){ - $ctx.find('.load-versions').each(function(){ - var $ctr = $(this); - var $table = $ctr.closest('.table'); - $.getJSON($ctr.data('url'),function(res){ - $table.dataTable().api().destroy(); - var source = $('#'+$ctr.data('template')).html(); - var template = Handlebars.compile(source); - $ctr.append(template(res)); - Sling.CMS.ext['load-versions'].loaded = true; - Sling.CMS.decorate($ctr.closest('.version-container')); - }); - }); - } - } - }; +Sling.CMS.ext['draggable'] = { + decorate : function($ctx) { + var draggable = function() { + var element = this; + var mouseX; + var mouseY; + var mouseDown = false; + var elementX = 0; + var elementY = 0; - //support links which fetch HTML and display a modal - Sling.CMS.ext['fetch-modal'] = { - decorate : function($ctx){ - $ctx.find('a.Fetch-Modal').click(function(){ - var $link = $(this); - $link.attr('disabled', 'disabled'); - Sling.CMS.ui.fetchModal($link.attr('data-title'), encodeURI($link.attr('href')), $link.attr('data-path'), function(){ - $link.removeAttr('disabled'); - }); - return false; - }); + // mouse button down over the element + element.addEventListener('mousedown', function(evt) { - if (document.querySelector('.modal-card-body').contains(evt.target)) { ++ if (evt.target.matches('.modal-card-body *')) { + return; } - }; - - Sling.CMS.ext['file-upload'] = { - decorate: function($ctx) { - $ctx.find('.file').on('change', "input", function(){ - var node = $(this); - node.parent().find('.file-name').text(this.files[0].name); - }); - } - }; - - Sling.CMS.ext['getform'] = { - decorate: function($ctx){ - $ctx.find('.Get-Form').submit(function(){ - var $form = $(this); - var params = $form.serialize(); - $form.find('.Form-Ajax__wrapper').attr('disabled', 'disabled'); - - $($form.data('target')).load($form.attr('action') + '?' + params +' ' + $form.data('load'), function(){ - $form.find('.Form-Ajax__wrapper').removeAttr('disabled'); - Sling.CMS.decorate($($form.data('target'))); - }); - return false; - }); - } - }; + mouseX = evt.clientX; + mouseY = evt.clientY; + mouseDown = true; + }); - Sling.CMS.ext['includeconfig'] = { - decorate: function($ctx){ - $ctx.find('.sling-cms-include-config').each(function(){ - var $ctr = $(this); - var load = function(){ - var config = $($ctr.data('source')).find('option:selected').data('config'); - - if(config){ - $ctr.load(config + $ctr.parents('form').attr('action'), function(){ - Sling.CMS.decorate($ctr.children()); - }); - } - }; - $($ctr.data('source')).change(load); - load(); - }); - } - }; + var moveComplete = function() { + mouseDown = false; + elementX = parseInt(element.style.left) || 0; + elementY = parseInt(element.style.top) || 0; + return false; + } - Sling.CMS.ext['handledelete'] = function(res, msg){ - if(window.location.pathname.indexOf(res.path) !== -1){ - window.top.Sling.CMS.ui.confirmMessage(msg, res.title,function(){ - window.location = '/cms'; - }); - } else { - Sling.CMS.ext.reload(res, msg); - } - } + element.addEventListener('mouseup', moveComplete); + document.addEventListener('mouseout', moveComplete); - Sling.CMS.ext['handlemove'] = function(res, msg){ - var changes = res.changes[0]; - if(changes.type === 'moved' && window.location.pathname.indexOf(changes.argument[0]) !== -1){ - window.top.Sling.CMS.ui.confirmMessage(msg, res.title,function(){ - window.location = window.location.href.replace(changes.argument[0], changes.argument[1]); - }); - } else { - Sling.CMS.ext.reload(res, msg); + document.addEventListener('mousemove', function(event) { + if (!mouseDown) { + return; } + var deltaX = event.clientX - mouseX; + var deltaY = event.clientY - mouseY; + element.style.left = elementX + deltaX + 'px'; + element.style.top = elementY + deltaY + 'px'; + return false; + }); + + }; + if ($ctx.is('.is-draggable')) { + $ctx.each(draggable) } + $ctx.find('.is-draggable').each(draggable); + } +}; - Sling.CMS.ext['handleugc'] = function(res, msg){ - Sling.CMS.ui.confirmMessage(msg, res.title,function(){ - window.location = '/cms/usergenerated/content.html'+res.parentLocation; - }); +Sling.CMS.ext['load-versions'] = { + loaded : false, + decorate : function($ctx) { + if (!Sling.CMS.ext['load-versions'].loaded) { + $ctx.find('.load-versions').each(function() { + var $ctr = $(this); + var $table = $ctr.closest('.table'); + $.getJSON($ctr.data('url'), function(res) { + $table.dataTable().api().destroy(); + var source = $('#' + $ctr.data('template')).html(); + var template = Handlebars.compile(source); + $ctr.append(template(res)); + Sling.CMS.ext['load-versions'].loaded = true; + Sling.CMS.decorate($ctr.closest('.version-container')); + }); + }); } + } +}; + +// support links which fetch HTML and display a modal +Sling.CMS.ext['fetch-modal'] = { + decorate : function($ctx) { + $ctx.find('a.Fetch-Modal').click( + function() { + var $link = $(this); + $link.attr('disabled', 'disabled'); + Sling.CMS.ui.fetchModal($link.attr('data-title'), encodeURI($link + .attr('href')), $link.attr('data-path'), function() { + $link.removeAttr('disabled'); + }); + return false; + }); + } +}; + +Sling.CMS.ext['getform'] = { + decorate : function($ctx) { + $ctx.find('.Get-Form').submit( + function() { + var $form = $(this); + var params = $form.serialize(); + $form.find('.Form-Ajax__wrapper').attr('disabled', 'disabled'); + + $($form.data('target')).load( + $form.attr('action') + '?' + params + ' ' + $form.data('load'), + function() { + $form.find('.Form-Ajax__wrapper').removeAttr('disabled'); + Sling.CMS.decorate($($form.data('target'))); + }); + return false; + }); + } +}; + +Sling.CMS.ext['includeconfig'] = { + decorate : function($ctx) { + $ctx.find('.sling-cms-include-config').each( + function() { + var $ctr = $(this); + var load = function() { + var config = $($ctr.data('source')).find('option:selected').data( + 'config'); + + if (config) { + $ctr.load(config + $ctr.parents('form').attr('action'), + function() { + Sling.CMS.decorate($ctr.children()); + }); + } + }; + $($ctr.data('source')).change(load); + load(); + }); + } +}; + +Sling.CMS.ext['handledelete'] = function(res, msg) { + if (window.location.pathname.indexOf(res.path) !== -1) { + window.top.Sling.CMS.ui.confirmMessage(msg, res.title, function() { + window.location = '/cms'; + }); + } else { + Sling.CMS.ext.reload(res, msg); + } +} + +Sling.CMS.ext['handlemove'] = function(res, msg) { + var changes = res.changes[0]; + if (changes.type === 'moved' + && window.location.pathname.indexOf(changes.argument[0]) !== -1) { + window.top.Sling.CMS.ui.confirmMessage(msg, res.title, function() { + window.location = window.location.href.replace(changes.argument[0], + changes.argument[1]); + }); + } else { + Sling.CMS.ext.reload(res, msg); + } +} + +Sling.CMS.ext['handleugc'] = function(res, msg) { + Sling.CMS.ui.confirmMessage(msg, res.title, function() { + window.location = '/cms/usergenerated/content.html' + res.parentLocation; + }); +} + +Sling.CMS.ext['namehint'] = { + decorate : function($ctx) { + $ctx.find('.namehint').each( + function() { + var $nh = $(this); + $nh.parents('.Form-Ajax').find('select[name="sling:resourceType"]') + .change(function() { + var resourceType = $(this).val().split("\/"); + $nh.val(resourceType[resourceType.length - 1]); + }); + }); + } +}; - Sling.CMS.ext['namehint'] = { - decorate: function($ctx){ - $ctx.find('.namehint').each(function(){ - var $nh = $(this); - $nh.parents('.Form-Ajax').find('select[name="sling:resourceType"]').change(function(){ - var resourceType = $(this).val().split("\/"); - $nh.val(resourceType[resourceType.length - 1]); - }); - }); - } - }; + + Sling.CMS.ext['navbar'] = { + init: function() { + document.querySelectorAll('.navbar-burger').forEach(function(burger){ + burger.addEventListener('click', function(){ + var target = document.querySelector(burger.dataset.target); + target.classList.toggle('is-active'); + burger.classList.toggle('is-active'); + }); + }); + } + }; - - Sling.CMS.ext['pageproperties'] = { - decorate: function($ctx){ - $ctx.find('.Sling-CMS__page-properties').each(function(){ - var $ctr = $(this); - var $wrapper = $ctr.closest('.Form-Ajax__wrapper'); - $($ctr.data('source')).change(function(){ - var config = $(this).val(); - $ctr.load($ctr.data('path')+config, function(){ - var source = $('#content-template').html(); - var template = Handlebars.compile(source); - var updateContent = function(){ - if(!$wrapper.is(':disabled')){ - var data = Sling.CMS.utils.form2Obj($ctr.parents('form')); - $('input[name=":content"]').val(template(data)); - } - } - $ctr.find('input,textarea,select').change(updateContent); - $ctr.parents('form').submit(updateContent); - Sling.CMS.decorate($ctr.children()); - }); - }); - }); - } - }; + - Sling.CMS.ext['pathfield'] = { - suggest: function(field, type, base) { - var xhr; - new autoComplete({ - minChars: 1, - selector: field, - source: function(term, response){ - try { - xhr.abort(); - } catch(e){} - if(term === '/'){ - term = base; - } - xhr = $.getJSON('/bin/cms/paths', { path: term, type: type }, function(data){ - response(data); - }); - } - }); - }, - decorate: function($ctx){ - $ctx.find('input.pathfield').each(function(){ - var type = $(this).data('type'); - var base = $(this).data('base'); - Sling.CMS.ext.pathfield.suggest(this, type, base); - }); - } - }; +Sling.CMS.ext['pageproperties'] = { + decorate : function($ctx) { + $ctx.find('.Sling-CMS__page-properties').each(function() { + var $ctr = $(this); + var $wrapper = $ctr.closest('.Form-Ajax__wrapper'); + $($ctr.data('source')).change(function() { + var config = $(this).val(); + $ctr.load($ctr.data('path') + config, function() { + var source = $('#content-template').html(); + var template = Handlebars.compile(source); + var updateContent = function() { + if (!$wrapper.is(':disabled')) { + var data = Sling.CMS.utils.form2Obj($ctr.parents('form')); + $('input[name=":content"]').val(template(data)); + } + } + $ctr.find('input,textarea,select').change(updateContent); + $ctr.parents('form').submit(updateContent); + Sling.CMS.decorate($ctr.children()); + }); + }); + }); + } +}; - Sling.CMS.ext['reload'] = function(res, msg) { - if(window.self !== window.top){ - window.top.Sling.CMS.ui.confirmMessage(msg, res.title,function(){ - window.top.location.reload(); - }); - } else { - Sling.CMS.ui.confirmMessage(msg, res.title,function(){ - location.reload(); - }); +Sling.CMS.ext['pathfield'] = { + suggest : function(field, type, base) { + var xhr; + new autoComplete({ + minChars : 1, + selector : field, + source : function(term, response) { + try { + xhr.abort(); + } catch (e) { } - } - - Sling.CMS.ext['repeating'] = { - decorate: function($ctx){ - $ctx.find('.repeating').each(function(){ - var $rep = $(this); - $rep.find('.repeating__add').click(function(){ - var $div = $('<div/>').html($rep.find('.repeating__template').html()); - Sling.CMS.decorate($div); - $rep.find('.repeating__container').append($div); - return false; - }); - }); - $ctx.find('.repeating__remove').click(function(){ - var $rem = $(this); - $rem.parents('.repeating__item').remove(); - return false; - }); + if (term === '/') { + term = base; } - }; - - Sling.CMS.ext['richtext'] = { - decorate: function($ctx){ - $ctx.find('.richtext').summernote({ - toolbar: [ - ['style', ['bold', 'italic', 'clear','strikethrough', 'superscript', 'subscript']], - ['insert', ['picture', 'link', 'table', 'hr']], - ['para', ['style','ul', 'ol', 'paragraph']], - ['misc', ['codeview', 'undo','redo','help']] - ], - followingToolbar: false, - dialogsInBody: true, - height: 200, - onCreateLink: function (url) { - return url; - }, - callbacks: { - onDialogShown: function(){ - Sling.CMS.ext.pathfield.suggest($('.note-link-url')[0], 'content', '/content'); - Sling.CMS.ext.pathfield.suggest($('.note-image-url')[0], 'content', '/content'); - } - } - }); - } - }; - + xhr = $.getJSON('/bin/cms/paths', { + path : term, + type : type + }, function(data) { + response(data); + }); + } + }); + }, + decorate : function($ctx) { + $ctx.find('input.pathfield').each(function() { + var type = $(this).data('type'); + var base = $(this).data('base'); + Sling.CMS.ext.pathfield.suggest(this, type, base); + }); + } +}; + +Sling.CMS.ext['reload'] = function(res, msg) { + if (window.self !== window.top) { + window.top.Sling.CMS.ui.confirmMessage(msg, res.title, function() { + window.top.location.reload(); + }); + } else { + Sling.CMS.ui.confirmMessage(msg, res.title, function() { + location.reload(); + }); + } +} + +Sling.CMS.ext['repeating'] = { + decorate : function($ctx) { + $ctx.find('.repeating').each(function() { + var $rep = $(this); + $rep.find('.repeating__add').click(function() { + var $div = $('<div/>').html($rep.find('.repeating__template').html()); + Sling.CMS.decorate($div); + $rep.find('.repeating__container').append($div); + return false; + }); + }); + $ctx.find('.repeating__remove').click(function() { + var $rem = $(this); + $rem.parents('.repeating__item').remove(); + return false; + }); + } +}; + +Sling.CMS.ext['richtext'] = { + decorate : function($ctx) { + $ctx.find('.richtext').summernote( + { + toolbar : [ + [ + 'style', + [ 'bold', 'italic', 'clear', 'strikethrough', 'superscript', + 'subscript' ] ], + [ 'insert', [ 'picture', 'link', 'table', 'hr' ] ], + [ 'para', [ 'style', 'ul', 'ol', 'paragraph' ] ], + [ 'misc', [ 'codeview', 'undo', 'redo', 'help' ] ] ], + followingToolbar : false, + dialogsInBody : true, + height : 200, + onCreateLink : function(url) { + return url; + }, + callbacks : { + onDialogShown : function() { + Sling.CMS.ext.pathfield.suggest($('.note-link-url')[0], + 'content', '/content'); + Sling.CMS.ext.pathfield.suggest($('.note-image-url')[0], + 'content', '/content'); + } + } + }); + } +}; + - Sling.CMS.ext['searchselect'] = { - decorate : function($ctx) { - $ctx.find('.Search-Select-Button').click(function(evt) { - var $btn = $(evt.target); - var $active = Sling.CMS.ext['searchbutton'].active; - $active.val($btn.data('path')); - $btn.closest('.Modal').remove(); - }); - } - } + - Sling.CMS.ext['searchbutton'] = { - active : null, - decorate : function($ctx) { - $ctx.find('.Search-Button').click( - function(evt) { - Sling.CMS.ext['searchbutton'].active = $(evt.target).closest( - '.Field-Input').find('.Field-Path'); - }); - } + Sling.CMS.ext['searchselect'] = { + decorate: function($ctx) { + $ctx.find('.search-select-button').click(function(evt){ + var $btn = $(evt.target); + var $active = Sling.CMS.ext['searchbutton'].active; + $active.val($btn.data('path')); + $btn.closest('.modal').remove(); + }); + } - }; ++ } + + Sling.CMS.ext['searchbutton'] = { + active: null, + decorate: function($ctx) { + $ctx.find('.search-button').click(function(evt){ + Sling.CMS.ext['searchbutton'].active = $(evt.target).closest('.field').find('.pathfield'); + }); + } - }; +} - Sling.CMS.ext['suffix-form'] = { - init: function() { - $('.suffix-form').submit(function(){ - var suffix = $(this).find('input[name=suffix]').val(); - var path = $(this).attr('action'); - window.location = path + suffix; - return false; - }); - } - } - - Sling.CMS.ext['table'] = { - decorate: function($ctx) { - $ctx.find('table tbody tr').click(function(el){ - $('.actions-target > *').appendTo('tr.is-selected .cell-actions') - $('tr').removeClass('is-selected'); - $(this).addClass('is-selected'); - $(this).find('.cell-actions > *').appendTo('.actions-target') - }); +Sling.CMS.ext['suffix-form'] = { + init : function() { + $('.suffix-form').submit(function() { + var suffix = $(this).find('input[name=suffix]').val(); + var path = $(this).attr('action'); + window.location = path + suffix; + return false; + }); + } +} - $ctx.find('table').each(function(){ - var sort = $(this).data('sort') !== 'false'; - var paginate = $(this).data('paginate') !== 'false'; - $(this).DataTable({ - sort: sort, - paginate: paginate - }); - }); - } - }; +Sling.CMS.ext['table'] = { + decorate : function($ctx) { + $ctx.find('table tbody tr').click(function(el) { + $('.actions-target > *').appendTo('tr.is-selected .cell-actions') + $('tr').removeClass('is-selected'); + $(this).addClass('is-selected'); + $(this).find('.cell-actions > *').appendTo('.actions-target') + }); - Sling.CMS.ext['taxonomy'] = { - decorate: function($ctx){ - $ctx.find('.taxonomy').each(function(){ - var $rep = $(this); - $rep.find('.taxonomy__add').click(function(){ - var $span = $('<span/>').html($rep.find('.taxonomy__template').html()); - var val = $ctx.find('.taxonomy__field input').val(); - var found = false; - $rep.find('.taxonomy__item input').each(function(idx, el){ - if($(el).val() === val){ - found = true; - } - }); - if(found){ - return false; - } - $span.find('input').val(val); - var title = $ctx.find('option[value="'+val+'"]').text(); - - if(title !== ''){ - $span.find('.taxonomy__title').text(title); - Sling.CMS.decorate($span); - $('.taxonomy__container').append($span); - $ctx.find('.taxonomy__field input').val(''); - } - return false; - }); - }); - $ctx.find('.taxonomy__item').click(function(){ - $(this).remove(); - return false; - }); - } - }; - - Sling.CMS.ext['toggle-hidden'] = { - decorate: function($ctx){ - $ctx.find('.toggle-hidden').click(function(){ - $($(this).data('target')).toggleClass('is-hidden'); - }); + $ctx.find('table').each(function() { + var sort = $(this).data('sort') !== 'false'; + var paginate = $(this).data('paginate') !== 'false'; + $(this).DataTable({ + sort : sort, + paginate : paginate + }); + }); + } +}; + +Sling.CMS.ext['taxonomy'] = { + decorate : function($ctx) { + $ctx.find('.taxonomy').each(function() { + var $rep = $(this); + $rep.find('.taxonomy__add').click(function() { + var $span = $('<span/>').html($rep.find('.taxonomy__template').html()); + var val = $ctx.find('.taxonomy__field input').val(); + var found = false; + $rep.find('.taxonomy__item input').each(function(idx, el) { + if ($(el).val() === val) { + found = true; + } + }); + if (found) { + return false; } - }; - - Sling.CMS.ext['toggle-value'] = { - decorate: function($ctx) { - $ctx.find('.toggle-value').each(function(){ - var $tog = $(this); - $('input[name="'+$tog.data('toggle-source')+'"], select[name="'+$tog.data('toggle-source')+'"]').change(function(){ - if($(this).val() !== $tog.data('toggle-value')){ - $tog.addClass('is-hidden'); - } else { - $tog.removeClass('is-hidden'); - } - }); - }) + $span.find('input').val(val); + var title = $ctx.find('option[value="' + val + '"]').text(); + + if (title !== '') { + $span.find('.taxonomy__title').text(title); + Sling.CMS.decorate($span); + $('.taxonomy__container').append($span); + $ctx.find('.taxonomy__field input').val(''); } - }; + return false; + }); + }); + $ctx.find('.taxonomy__item').click(function() { + $(this).remove(); + return false; + }); + } +}; - $(document).ready(function() { - Sling.CMS.init(); +Sling.CMS.ext['toggle-hidden'] = { + decorate : function($ctx) { + $ctx.find('.toggle-hidden').click(function() { + $($(this).data('target')).toggleClass('is-hidden'); }); + } +}; + +Sling.CMS.ext['toggle-value'] = { + decorate : function($ctx) { + $ctx.find('.toggle-value').each( + function() { + var $tog = $(this); + $( + 'input[name="' + $tog.data('toggle-source') + '"], select[name="' + + $tog.data('toggle-source') + '"]').change(function() { + if ($(this).val() !== $tog.data('toggle-value')) { + $tog.addClass('is-hidden'); + } else { + $tog.removeClass('is-hidden'); + } + }); + }) + } +}; + +Sling.CMS.ext['file-upload'] = { + decorate : function($ctx) { + $ctx.find('.file').on('change', "input", function() { + var node = $(this); + node.parent().find('.file-name').text(this.files[0].name); + }); + } +}; + +$(document).ready(function() { + Sling.CMS.init(); +}); diff --cc ui/src/main/resources/jcr_root/libs/sling-cms/components/pages/base/nav.jsp index 2e6fd9e,da5e167..7dc39b8 --- a/ui/src/main/resources/jcr_root/libs/sling-cms/components/pages/base/nav.jsp +++ b/ui/src/main/resources/jcr_root/libs/sling-cms/components/pages/base/nav.jsp @@@ -17,23 -17,21 +17,21 @@@ * under the License. */ --%> <%@include file="/libs/sling-cms/global.jsp"%> -<nav class="navbar" role="navigation" aria-label="main mavigation"> +<nav class="navbar is-transparent" role="navigation" aria-label="main mavigation"> - <div class="navbar-brand"> - <a class="navbar-item" href="http://sling.apache.org" > - <img src="/static/clientlibs/sling-cms/img/sling-logo.svg" width="100" alt="Apache Sling"/> - </a> - <a href="/cms/start.html" class="navbar-item" title="CMS Home"><span class="icon"><i class="jam jam-home-f"></i></span></a> - <div class="navbar-item"> - </div> - <a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false"> - <span aria-hidden="true"></span> - <span aria-hidden="true"></span> - <span aria-hidden="true"></span> - </a> - </div> - <div class="navbar-menu"> - <div class="navbar-end"> - <a class="navbar-item " href="/system/sling/logout" title="Logout of Apache Sling CMS"><span>${resourceResolver.userID} </span><i class="jam jam-log-out"></i></a> - </div> - </div> - </nav> + <div class="navbar-brand"> + <a class="navbar-item" href="http://sling.apache.org" > + <img src="/static/clientlibs/sling-cms/img/sling-logo.svg" width="100" alt="Apache Sling"/> + </a> + <a href="/cms/start.html" class="navbar-item" title="CMS Home"><span class="icon"><i class="jam jam-home-f"></i></span></a> + <a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="#top-navbar-menu"> + <span aria-hidden="true"></span> + <span aria-hidden="true"></span> + <span aria-hidden="true"></span> + </a> + </div> + <div class="navbar-menu" id="top-navbar-menu"> + <div class="navbar-end"> + <a class="navbar-item " href="/system/sling/logout" title="Logout of Apache Sling CMS"><span>${resourceResolver.userID} </span><i class="jam jam-log-out"></i></a> + </div> + </div> -</nav> ++</nav>
