diff --git a/pom.xml b/pom.xml index b0a506bdd..692c1ef98 100644 --- a/pom.xml +++ b/pom.xml @@ -109,10 +109,6 @@ celements-mailsender 7.0-SNAPSHOT - - com.xpn.xwiki.platform.plugins - xwiki-plugin-skinx - org.xwiki.platform xwiki-platform-tag-api @@ -205,19 +201,19 @@ celements-xwiki-core 7.0-SNAPSHOT - + com.celements celements-xwiki-velocity 7.0-SNAPSHOT com.celements - celements-xwiki-velocity + celements-xwiki-rendering-api 7.0-SNAPSHOT com.celements - celements-xwiki-rendering-api + celements-xwiki-xml 7.0-SNAPSHOT diff --git a/src/main/webapp/WEB-INF/xwiki.cfg b/src/main/webapp/WEB-INF/xwiki.cfg index 2530fd65a..bb040341d 100644 --- a/src/main/webapp/WEB-INF/xwiki.cfg +++ b/src/main/webapp/WEB-INF/xwiki.cfg @@ -476,11 +476,6 @@ xwiki.plugins=\ com.celements.calendar.plugin.CelementsCalendarPlugin,\ com.xpn.xwiki.plugin.applicationmanager.ApplicationManagerPlugin,\ com.xpn.xwiki.plugin.wikimanager.WikiManagerPlugin,\ - com.xpn.xwiki.plugin.skinx.JsSkinExtensionPlugin,\ - com.xpn.xwiki.plugin.skinx.JsSkinFileExtensionPlugin,\ - com.xpn.xwiki.plugin.skinx.CssSkinExtensionPlugin,\ - com.xpn.xwiki.plugin.skinx.CssSkinFileExtensionPlugin,\ - com.xpn.xwiki.plugin.skinx.LinkExtensionPlugin,\ com.xpn.xwiki.plugin.mail.MailPlugin,\ com.xpn.xwiki.plugin.packaging.PackagePlugin,\ com.xpn.xwiki.plugin.fileupload.FileUploadPlugin,\ diff --git a/src/main/webapp/docs/celements2web/Panels/ClassEditorWelcome.xml b/src/main/webapp/docs/celements2web/Panels/ClassEditorWelcome.xml index aabbaf08a..f9978efbc 100644 --- a/src/main/webapp/docs/celements2web/Panels/ClassEditorWelcome.xml +++ b/src/main/webapp/docs/celements2web/Panels/ClassEditorWelcome.xml @@ -105,7 +105,7 @@ #largepanelheader($msg.get("classEditorIntro")) -$xwiki.jsx.use('Panels.ClassSwitcher')## +##$xwiki.jsx.use('Panels.ClassSwitcher')## <p>$msg.get("xe.panels.classedit.youare") <strong>${doc.fullName}</strong>. $msg.get("xe.panels.classedit.chooseproperty")</p> <div> <form id="changeclass" method="post" action="$doc.getURL("redirect")"> diff --git a/src/main/webapp/docs/celements2web/Panels/ClassSwitcher.xml b/src/main/webapp/docs/celements2web/Panels/ClassSwitcher.xml index 9cec1dd9b..7ce7d06f8 100644 --- a/src/main/webapp/docs/celements2web/Panels/ClassSwitcher.xml +++ b/src/main/webapp/docs/celements2web/Panels/ClassSwitcher.xml @@ -105,7 +105,7 @@ #largepanelheader('Class Switcher') -$xwiki.jsx.use('Panels.ClassSwitcher')## +##$xwiki.jsx.use('Panels.ClassSwitcher')## <div> <form id="changeclass" method="post" action="$doc.getURL("redirect")"> <div> diff --git a/src/main/webapp/docs/celements2web/Panels/Navigation.xml b/src/main/webapp/docs/celements2web/Panels/Navigation.xml index 767ac8799..9b0e4b937 100644 --- a/src/main/webapp/docs/celements2web/Panels/Navigation.xml +++ b/src/main/webapp/docs/celements2web/Panels/Navigation.xml @@ -142,8 +142,11 @@ #end </div> </div> -$xwiki.jsfx.use('js/scriptaculous/scriptaculous.js') -$xwiki.jsfx.use('js/xwiki/accordion/accordion.js') +#set($jsService = $services.javascript) +#set($extJsParam = $jsService.createExtJSParam().setAction('file')) +#set($extJsParam = $extJsParam.setLazyLoad(true)) +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/scriptaculous/scriptaculous.js'))## +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/accordion/accordion.js'))## <script type="text/javascript"> var obj = {div:'xwikinav',no:$spacecount,height:250}; var acc = createAccordion(obj); diff --git a/src/main/webapp/docs/celements2web/Panels/PanelWizard.xml b/src/main/webapp/docs/celements2web/Panels/PanelWizard.xml index a59d21946..82e0e2655 100644 --- a/src/main/webapp/docs/celements2web/Panels/PanelWizard.xml +++ b/src/main/webapp/docs/celements2web/Panels/PanelWizard.xml @@ -352,11 +352,14 @@ dG8WUcuijwAAAABJRU5ErkJggg== #else #set($ajaxurl = $xwiki.getDocument("Panels.PanelLayoutUpdate").getURL("view", "xpage=plain&prefsdoc=${currentDoc}")) #end - $xwiki.jsfx.use("js/scriptaculous/scriptaculous.js") - $xwiki.jsfx.use("js/xwiki/accordion/accordion.js") - $xwiki.jsfx.use("js/xwiki/panelwizard/Drag.js") - $xwiki.jsfx.use("js/xwiki/panelwizard/ieemu.js") - $xwiki.jsfx.use("js/xwiki/panelwizard/toolTip.js") + #set($jsService = $services.javascript) + #set($extJsParam = $jsService.createExtJSParam().setAction('file')) + #set($extJsParam = $extJsParam.setLazyLoad(true)) + $!jsService.includeExtJsFile($extJsParam.setJsFile(':js/scriptaculous/scriptaculous.js'))## + $!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/accordion/accordion.js'))## + $!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/panelwizard/Drag.js'))## + $!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/panelwizard/ieemu.js'))## + $!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/panelwizard/toolTip.js'))## <script type="text/javascript"> //<![CDATA[ window.ajaxurl = "$ajaxurl"; diff --git a/src/main/webapp/docs/celements2web/Panels/RightsHelp.xml b/src/main/webapp/docs/celements2web/Panels/RightsHelp.xml index 573ce026f..989ffd69b 100644 --- a/src/main/webapp/docs/celements2web/Panels/RightsHelp.xml +++ b/src/main/webapp/docs/celements2web/Panels/RightsHelp.xml @@ -134,8 +134,11 @@ $msg.get("xe.panels.rights.allowdenyexplanation") </div> #panelfooter() </div> -$xwiki.jsfx.use("js/scriptaculous/scriptaculous.js") -$xwiki.jsfx.use("js/xwiki/accordion/accordion.js") +#set($jsService = $services.javascript) +#set($extJsParam = $jsService.createExtJSParam().setAction('file')) +#set($extJsParam = $extJsParam.setLazyLoad(true)) +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/scriptaculous/scriptaculous.js'))## +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/accordion/accordion.js'))## <script type="text/javascript"> var obj = {div:'xwikirightshelp',no:0,height:512}; var acc = createAccordion(obj); diff --git a/src/main/webapp/docs/celements2web/Panels/RightsTips.xml b/src/main/webapp/docs/celements2web/Panels/RightsTips.xml index 3eec7562b..0a4f2acf1 100644 --- a/src/main/webapp/docs/celements2web/Panels/RightsTips.xml +++ b/src/main/webapp/docs/celements2web/Panels/RightsTips.xml @@ -143,8 +143,11 @@ $msg.get("xe.panels.rights.bannedgroup") </div> #panelfooter() </div> -$xwiki.jsfx.use("js/scriptaculous/scriptaculous.js") -$xwiki.jsfx.use("js/xwiki/accordion/accordion.js") +#set($jsService = $services.javascript) +#set($extJsParam = $jsService.createExtJSParam().setAction('file')) +#set($extJsParam = $extJsParam.setLazyLoad(true)) +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/scriptaculous/scriptaculous.js'))## +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/accordion/accordion.js'))## <script type="text/javascript"> var obj = {div:'xwikirightstips',no:0,height:250}; var acc = createAccordion(obj); diff --git a/src/main/webapp/docs/xwiki/XWiki/AdminGroupsSheet.xml b/src/main/webapp/docs/xwiki/XWiki/AdminGroupsSheet.xml index 5873903d7..467291b42 100644 --- a/src/main/webapp/docs/xwiki/XWiki/AdminGroupsSheet.xml +++ b/src/main/webapp/docs/xwiki/XWiki/AdminGroupsSheet.xml @@ -29,11 +29,14 @@ ## ## Inject needed JS and CSS files ## -#set($ok = $xwiki.jsfx.use("js/xwiki/lightbox/lightbox.js", true)) -#set($ok = $xwiki.jsfx.use("js/xwiki/usersandgroups/usersandgroups.js", true)) -#set($ok = $xwiki.ssfx.use("js/xwiki/usersandgroups/usersandgroups.css", true)) -#set($ok = $xwiki.jsfx.use("js/xwiki/table/livetable.js", true)) -#set($ok = $xwiki.ssfx.use("js/xwiki/table/livetable.css", true)) +#set($jsService = $services.javascript) +#set($extJsParam = $jsService.createExtJSParam().setAction('file')) +#set($extJsParam = $extJsParam.setLazyLoad(true)) +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/lightbox/lightbox.js'))## +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/usersandgroups/usersandgroups.js'))## +$services.css.includeCSSPage(':js/xwiki/usersandgroups/usersandgroups.css')## +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/table/livetable.js'))## +$services.css.includeCSSPage(':js/xwiki/table/livetable.css')## ## ## url to get the groups for displaying them in the ajax-based table ## diff --git a/src/main/webapp/docs/xwiki/XWiki/AdminSheet.xml b/src/main/webapp/docs/xwiki/XWiki/AdminSheet.xml index 6eed66a76..00f36fed7 100644 --- a/src/main/webapp/docs/xwiki/XWiki/AdminSheet.xml +++ b/src/main/webapp/docs/xwiki/XWiki/AdminSheet.xml @@ -2782,9 +2782,12 @@ p.legend { ##------------------------------------- ## determine the displayed sections ##------------------------------------- - $xwiki.jsfx.use('js/scriptaculous/scriptaculous.js')## - $xwiki.jsx.use('XWiki.AdminSheet')## - $xwiki.ssx.use('XWiki.AdminSheet')## + #set($jsService = $services.javascript) + #set($extJsParam = $jsService.createExtJSParam().setAction('file')) + #set($extJsParam = $extJsParam.setLazyLoad(true)) + $!jsService.includeExtJsFile($extJsParam.setJsFile(':js/scriptaculous/scriptaculous.js'))## +## $xwiki.jsx.use('XWiki.AdminSheet')## +## $xwiki.ssx.use('XWiki.AdminSheet')## #if($editor == 'globaladmin') #set($currentDoc = 'XWiki.XWikiPreferences') #set($sections = ['General', 'Presentation', 'Registration', 'Programming', 'Rights', 'Users', 'Groups', 'Import', 'Export', 'Templates']) diff --git a/src/main/webapp/docs/xwiki/XWiki/AdminUsersSheet.xml b/src/main/webapp/docs/xwiki/XWiki/AdminUsersSheet.xml index c9eff59f1..63905dfd5 100644 --- a/src/main/webapp/docs/xwiki/XWiki/AdminUsersSheet.xml +++ b/src/main/webapp/docs/xwiki/XWiki/AdminUsersSheet.xml @@ -29,13 +29,16 @@ ## ## inject needed JS and CSS files ## -#set($ok = $xwiki.jsfx.use("js/xwiki/lightbox/lightbox.js", true)) -#set($ok = $xwiki.jsfx.use("js/xwiki/usersandgroups/usersandgroups.js", true)) -#set($ok = $xwiki.ssfx.use("js/xwiki/usersandgroups/usersandgroups.css", true)) -#set($ok = $xwiki.jsfx.use("js/xwiki/table/livetable.js", true)) -#set($ok = $xwiki.ssfx.use("js/xwiki/table/livetable.css", true)) -#set($ok = $xwiki.ssx.use("XWiki.XWikiUserSheet")) -#set($ok = $xwiki.jsx.use("XWiki.XWikiUserSheet")) +#set($jsService = $services.javascript) +#set($extJsParam = $jsService.createExtJSParam().setAction('file')) +#set($extJsParam = $extJsParam.setLazyLoad(true)) +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/lightbox/lightbox.js'))## +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/usersandgroups/usersandgroups.js'))## +$services.css.includeCSSPage(':js/xwiki/usersandgroups/usersandgroups.css')## +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/table/livetable.js'))## +$services.css.includeCSSPage(':js/xwiki/table/livetable.css')## +###set($ok = $xwiki.ssx.use("XWiki.XWikiUserSheet")) +###set($ok = $xwiki.jsx.use("XWiki.XWikiUserSheet")) ## ## url to get the users for displaying them in the ajax-based table ## diff --git a/src/main/webapp/docs/xwiki/XWiki/ConfigurableClass.xml b/src/main/webapp/docs/xwiki/XWiki/ConfigurableClass.xml index 6cc26e75b..c9d7dde36 100644 --- a/src/main/webapp/docs/xwiki/XWiki/ConfigurableClass.xml +++ b/src/main/webapp/docs/xwiki/XWiki/ConfigurableClass.xml @@ -374,7 +374,10 @@ iKAtTBe0AQfYWgXdAG9qCi1fA5wQWwLgSdydYgcsNRLABafWgzPNB4DsfrNE6VJz6VvXltr/A+kB #set($nameOfThisDocument = 'XWiki.ConfigurableClass') ## ## Form submission depends on this. -$xwiki.jsfx.use('js/xwiki/actionbuttons/actionButtons.js', true) +#set($jsService = $services.javascript) +#set($extJsParam = $jsService.createExtJSParam().setAction('file')) +#set($extJsParam = $extJsParam.setLazyLoad(true)) +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/actionbuttons/actionButtons.js'))## ## #if(!$section) #set($section = $request.getParameter('section')) @@ -574,7 +577,7 @@ $xwiki.jsfx.use('js/xwiki/actionbuttons/actionButtons.js', true) ## ## Merge save buttons, remove headings from subsections, and make information links into popups. ## This is not done if there is only a custom defined form. - $xwiki.jsx.use($nameOfThisDocument) +## $xwiki.jsx.use($nameOfThisDocument) ## ## We don't begin the form until we have content for it so that a configurable can specify a ## custom form in codeToExecute and if that configurable object is the first of it's kind in that diff --git a/src/main/webapp/docs/xwiki/XWiki/XWikiGroupSheet.xml b/src/main/webapp/docs/xwiki/XWiki/XWikiGroupSheet.xml index 7437e3922..de4e78be1 100644 --- a/src/main/webapp/docs/xwiki/XWiki/XWikiGroupSheet.xml +++ b/src/main/webapp/docs/xwiki/XWiki/XWikiGroupSheet.xml @@ -49,10 +49,13 @@ {{velocity output="false"}} #set($mainwk = $xcontext.isMainWiki()) -$xwiki.jsfx.use('js/xwiki/usersandgroups/usersandgroups.js', true) -$xwiki.ssfx.use('js/xwiki/usersandgroups/usersandgroups.css') -$xwiki.jsfx.use('js/xwiki/table/livetable.js', true) -$xwiki.ssfx.use('js/xwiki/table/livetable.css', true) +#set($jsService = $services.javascript) +#set($extJsParam = $jsService.createExtJSParam().setAction('file')) +#set($extJsParam = $extJsParam.setLazyLoad(true)) +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/usersandgroups/usersandgroups.js'))## +$services.css.includeCSSPage(':js/xwiki/usersandgroups/usersandgroups.css')## +$!jsService.includeExtJsFile($extJsParam.setJsFile(':js/xwiki/table/livetable.js'))## +$services.css.includeCSSPage(':js/xwiki/table/livetable.css')## #set($groupDoc = $doc) #if($doc.fullName == 'Main.UserDirectory') #set($groupDoc = $xwiki.getDocument('XWiki.XWikiAllGroup')) diff --git a/src/main/webapp/docs/xwiki/XWiki/XWikiUserPreferencesSheet.xml b/src/main/webapp/docs/xwiki/XWiki/XWikiUserPreferencesSheet.xml index fef663597..760585569 100644 --- a/src/main/webapp/docs/xwiki/XWiki/XWikiUserPreferencesSheet.xml +++ b/src/main/webapp/docs/xwiki/XWiki/XWikiUserPreferencesSheet.xml @@ -28,7 +28,7 @@ {{info}}$msg.get('xe.admin.users.applyonusers'){{/info}}## #else $doc.use($obj) -$xwiki.ssx.use('XWiki.XWikiUserSheet')## +##$xwiki.ssx.use('XWiki.XWikiUserSheet')## {{html wiki="true"}} <div class="#if($context.action == 'view')half #{else}full #{end}column"> <div class="userPreferences"> diff --git a/src/main/webapp/docs/xwiki/XWiki/XWikiUserProfileSheet.xml b/src/main/webapp/docs/xwiki/XWiki/XWikiUserProfileSheet.xml index 5b613ff50..a7dfbe565 100644 --- a/src/main/webapp/docs/xwiki/XWiki/XWikiUserProfileSheet.xml +++ b/src/main/webapp/docs/xwiki/XWiki/XWikiUserProfileSheet.xml @@ -42,7 +42,7 @@ $doc.use($obj) <div class="vcard"> <span class="fn hidden">$username</span> #end -$xwiki.ssx.use("XWiki.XWikiUserSheet")## +##$xwiki.ssx.use("XWiki.XWikiUserSheet")## <div class="#if($context.action == 'view')half #{else}full #{end}column"> <div class="userInfo"> #if($xcontext.action == 'view' && $hasEdit) diff --git a/src/main/webapp/docs/xwiki/XWiki/XWikiUserSheet.xml b/src/main/webapp/docs/xwiki/XWiki/XWikiUserSheet.xml index eb09f3b85..b0c66fd04 100644 --- a/src/main/webapp/docs/xwiki/XWiki/XWikiUserSheet.xml +++ b/src/main/webapp/docs/xwiki/XWiki/XWikiUserSheet.xml @@ -364,8 +364,8 @@ span#avatarUpload { ## ## Extensions and vars ## -$xwiki.ssx.use("XWiki.XWikiUserSheet")## -$xwiki.jsx.use("XWiki.XWikiUserSheet")## +##$xwiki.ssx.use("XWiki.XWikiUserSheet")## +##$xwiki.jsx.use("XWiki.XWikiUserSheet")## #set($obj = $doc.getObject("XWiki.XWikiUsers")) ## ## Categories diff --git a/src/main/webapp/resources/js/xwiki/compatibility.js b/src/main/webapp/resources/js/xwiki/compatibility.js index 6c0e276aa..3ed6efd25 100644 --- a/src/main/webapp/resources/js/xwiki/compatibility.js +++ b/src/main/webapp/resources/js/xwiki/compatibility.js @@ -4,188 +4,195 @@ * All usage of deprecated code should log warnings in the console to help developers * moving to new code. */ -(function(){ - -/** - * If possible, log a warning message to the console. - * If not, does nothing. - */ -function warn(message){ - if (typeof console != "undefined" && typeof console.warn == "function") { - console.warn(message); +(function (window, undefined) { + "use strict"; + + var XWiki = window.XWiki ?? {}; + var widgets = XWiki.widgets ?? {}; + + /** + * If possible, log a warning message to the console. + * If not, does nothing. + */ + function warn(message) { + if (typeof console != "undefined" && typeof console.warn == "function") { + console.warn(message); + } } -} -/** - * Deprecated since 2.6RC2 - */ -if (typeof XWiki.widgets == 'object' && typeof XWiki.widgets.FullScreen == 'function') { - XWiki.editors = XWiki.editors || {}; - XWiki.editors.FullScreenEditing = Class.create(XWiki.widgets.FullScreen, { - initialize: function($super){ - warn("XWiki.editors.FullScreenEditing is deprecated since XWiki 2.6RC2. Use XWiki.widgets.FullScreen instead."); - $super(); - } - }); -} + /** + * Deprecated since 2.6RC2 + */ + if (typeof XWiki.widgets == 'object' && typeof XWiki.widgets.FullScreen == 'function') { + XWiki.editors = XWiki.editors || {}; + XWiki.editors.FullScreenEditing = Class.create(XWiki.widgets.FullScreen, { + initialize: function ($super) { + warn("XWiki.editors.FullScreenEditing is deprecated since XWiki 2.6RC2. Use XWiki.widgets.FullScreen instead."); + $super(); + } + }); + } -/** - * _xwk is an old namespace for XWiki code that was optional - * Deprecated since 2.6RC1 - */ -if (window.useXWKns) { - warn("_xwk namespace is deprecated since XWiki 2.6RC1. Use the XWiki namespace instead."); - if (typeof _xwk == "undefined") { - _xwk = new Object(); + /** + * _xwk is an old namespace for XWiki code that was optional + * Deprecated since 2.6RC1 + */ + if (window.useXWKns) { + warn("_xwk namespace is deprecated since XWiki 2.6RC1. Use the XWiki namespace instead."); + if (typeof _xwk == "undefined") { + _xwk = new Object(); + } + } else { + _xwk = window; } -} else { - _xwk = window; -} -/** - * Deprecated since 2.6RC1 - */ -_xwk.ajaxSuggest = Class.create(XWiki.widgets.Suggest, { - initialize: function($super){ - warn("ajaxSuggest is deprecated since XWiki 2.6RC1. Use XWiki.widgets.Suggest instead."); - var args = $A(arguments) - args.shift(); - $super.apply( _xwk, args ); + /** + * Deprecated since 2.6RC1 + */ + if (typeof XWiki.widgets.Suggest !== 'undefined') { + _xwk.ajaxSuggest = Class.create(XWiki.widgets.Suggest, { + initialize: function ($super) { + warn("ajaxSuggest is deprecated since XWiki 2.6RC1. Use XWiki.widgets.Suggest instead."); + var args = $A(arguments) + args.shift(); + $super.apply(_xwk, args); + } + }); } -}); -/** - * Deprecated since 1.9M2 - */ -window.displayDocExtra = XWiki.displayDocExtra.wrap( - function(){ - warn("window.displayDocExtra is deprecated since XWiki 1.9M2. Use XWiki.displayDocExtra instead."); - var args = $A(arguments), proceed = args.shift(); - return proceed.apply(window, args); - } -); + /** + * Deprecated since 1.9M2 + */ + window.displayDocExtra = XWiki.displayDocExtra.wrap( + function () { + warn("window.displayDocExtra is deprecated since XWiki 1.9M2. Use XWiki.displayDocExtra instead."); + var args = $A(arguments), proceed = args.shift(); + return proceed.apply(window, args); + } + ); + + /** + * window.ASSTable + * Deprecated since 1.9M2 + */ + if (typeof XWiki.widgets == "object" && typeof XWiki.widgets.LiveTable == "function") { + window.ASSTable = Class.create(XWiki.widgets.LiveTable, { + initialize: function ($super, url, limit, domNode, scrollNode, filterNode, getHandler, hasFilters, action) { + // warn developers they are using deprecated code. + warn("window.ASSTable is deprecated since XWiki 1.9M2. Use XWiki.widgets.LiveTable instead."); + + if ($("showLimits")) { + // inject an element for pagination since the scroller has been removed. + if ($("showLimits").up("tr")) { + $("showLimits").up("tr").insert({ + 'after': + new Element("tr").update( + new Element("td").update( + new Element("div", { + 'id': domNode + "-pagination", + 'class': "xwiki-grid-pagination-content" + }) + ) + ) + }); + } + // replace the id of the limits element by the one expected by convention by the new LiveTable widget + $("showLimits").id = domNode + "-limits"; + } -/** - * window.ASSTable - * Deprecated since 1.9M2 - */ -if (typeof XWiki.widgets == "object" && typeof XWiki.widgets.LiveTable == "function") { - window.ASSTable = Class.create(XWiki.widgets.LiveTable, { - initialize: function($super, url, limit, domNode, scrollNode, filterNode, getHandler, hasFilters, action) { - // warn developers they are using deprecated code. - warn("window.ASSTable is deprecated since XWiki 1.9M2. Use XWiki.widgets.LiveTable instead."); - - if($("showLimits")) { - // inject an element for pagination since the scroller has been removed. - if($("showLimits").up("tr")) { - $("showLimits").up("tr").insert({'after': - new Element("tr").update( - new Element("td").update( - new Element("div", { - 'id': domNode + "-pagination", - 'class': "xwiki-grid-pagination-content" - }) - ) - ) - }); + if ($('scrollbar1') && $('scrollbar1').up("td")) { + // if it present, remove that annoying pseudo-scroll, the new widget support normal pagination. + if ($('scrollbar1').up("td").next()) { + $('scrollbar1').up("td").next().remove(); // remove the buff td + } + $('scrollbar1').up("td").remove(); // remove the td that holds the scrollbar } - // replace the id of the limits element by the one expected by convention by the new LiveTable widget - $("showLimits").id = domNode + "-limits"; - } - if ($('scrollbar1') && $('scrollbar1').up("td")) { - // if it present, remove that annoying pseudo-scroll, the new widget support normal pagination. - if($('scrollbar1').up("td").next()) { - $('scrollbar1').up("td").next().remove(); // remove the buff td - } - $('scrollbar1').up("td").remove(); // remove the td that holds the scrollbar - } - - if($('table-filters')) { - // replace the id of the filters container by the one expected by convention by the new LiveTable widget - $('table-filters').id = domNode + "-filters"; - } + if ($('table-filters')) { + // replace the id of the filters container by the one expected by convention by the new LiveTable widget + $('table-filters').id = domNode + "-filters"; + } - // Ouf, that should be all for compatibility code, now we call father initialize method of new widget. - // Some arguments are dropped since the new signature is different. - $super(url, domNode, getHandler, {"action" : action}); - } - }); -} + // Ouf, that should be all for compatibility code, now we call father initialize method of new widget. + // Some arguments are dropped since the new signature is different. + $super(url, domNode, getHandler, { "action": action }); + } + }); + } -/** - * Hide the fieldset inside the given form. - * - * @param form {element} The form element. - * - * Deprecated since 2.6 RC1 - */ -window.hideForm = function(form){ - warn("window.hideForm is deprecated since XWiki 2.6RC1. Use a CSS selector + Element#toggleClassName instead."); + /** + * Hide the fieldset inside the given form. + * + * @param form {element} The form element. + * + * Deprecated since 2.6 RC1 + */ + window.hideForm = function (form) { + warn("window.hideForm is deprecated since XWiki 2.6RC1. Use a CSS selector + Element#toggleClassName instead."); form.getElementsByTagName("fieldset").item(0).className = "collapsed"; -} + } -/** - * Hide the fieldset inside the given form if visible, show it if it's not. - * - * @param form {element} The form element. - * - * Deprecated since 2.6 RC1 - */ -window.toggleForm= function(form){ + /** + * Hide the fieldset inside the given form if visible, show it if it's not. + * + * @param form {element} The form element. + * + * Deprecated since 2.6 RC1 + */ + window.toggleForm = function (form) { warn("window.toggleForm is deprecated since XWiki 2.6RC1. Use a CSS selector + Element#toggleClassName instead."); var fieldset = form.getElementsByTagName("fieldset").item(0); - if(fieldset.className == "collapsed"){ - fieldset.className = "expanded"; + if (fieldset.className == "collapsed") { + fieldset.className = "expanded"; } - else{ - fieldset.className = "collapsed"; + else { + fieldset.className = "collapsed"; } -} - -/** - * Deprecated since 2.6RC1 - */ -window.createCookie = XWiki.cookies.create.wrap( - function(){ - warn("window.createCookie is deprecated since XWiki 2.6RC1. Use XWiki.cookies.create instead."); - var args = $A(arguments), proceed = args.shift(); - return proceed.apply(window, args); } -); -/** - * Deprecated since 2.6RC1 - */ -window.readCookie = XWiki.cookies.read.wrap( - function(){ - warn("window.readCookie is deprecated since XWiki 2.6RC1. Use XWiki.cookies.read instead."); - var args = $A(arguments), proceed = args.shift(); - return proceed.apply(window, args); - } -); - -/** - * Deprecated since 2.6RC1 - */ -window.eraseCookie = XWiki.cookies.erase.wrap( - function(){ - warn("window.eraseCookie is deprecated since XWiki 2.6RC1. Use XWiki.cookies.erase instead."); - var args = $A(arguments), proceed = args.shift(); - return proceed.apply(window, args); - } -); - -/** - * Deprecated since 2.6RC1 - */ -window.togglePanelVisibility = XWiki.togglePanelVisibility.wrap( - function(){ - warn("window.togglePanelVisibility is deprecated since XWiki 2.6RC1. Use XWiki.togglePanelVisibility instead."); - var args = $A(arguments), proceed = args.shift(); - return proceed.apply(window, args); - } -); + /** + * Deprecated since 2.6RC1 + */ + window.createCookie = XWiki.cookies.create.wrap( + function () { + warn("window.createCookie is deprecated since XWiki 2.6RC1. Use XWiki.cookies.create instead."); + var args = $A(arguments), proceed = args.shift(); + return proceed.apply(window, args); + } + ); + + /** + * Deprecated since 2.6RC1 + */ + window.readCookie = XWiki.cookies.read.wrap( + function () { + warn("window.readCookie is deprecated since XWiki 2.6RC1. Use XWiki.cookies.read instead."); + var args = $A(arguments), proceed = args.shift(); + return proceed.apply(window, args); + } + ); + + /** + * Deprecated since 2.6RC1 + */ + window.eraseCookie = XWiki.cookies.erase.wrap( + function () { + warn("window.eraseCookie is deprecated since XWiki 2.6RC1. Use XWiki.cookies.erase instead."); + var args = $A(arguments), proceed = args.shift(); + return proceed.apply(window, args); + } + ); + + /** + * Deprecated since 2.6RC1 + */ + window.togglePanelVisibility = XWiki.togglePanelVisibility.wrap( + function () { + warn("window.togglePanelVisibility is deprecated since XWiki 2.6RC1. Use XWiki.togglePanelVisibility instead."); + var args = $A(arguments), proceed = args.shift(); + return proceed.apply(window, args); + } + ); -})(); +})(window); diff --git a/src/main/webapp/resources/js/xwiki/importer/import.css b/src/main/webapp/resources/js/xwiki/importer/import.css index e4c5f40eb..2377866eb 100644 --- a/src/main/webapp/resources/js/xwiki/importer/import.css +++ b/src/main/webapp/resources/js/xwiki/importer/import.css @@ -1,25 +1,25 @@ #template('colorThemeInit.vm') - /* Overriding skins */ #import ul.xlist li.xitem div.xitemcontainer { - text-indent: 0; + text-indent: 0; } div.legend { - margin-bottom:10px; - font-size:1.33em; - border-bottom:0px solid #D6E1E7; - color:#005A83; - display:block; - font-weight:400; - line-height:1.2em; - margin:20px 0; - overflow:hidden; + margin-bottom: 10px; + font-size: 1.33em; + border-bottom: 0px solid #D6E1E7; + color: #005A83; + display: block; + font-weight: 400; + line-height: 1.2em; + margin: 20px 0; + overflow: hidden; } .clearfloats { - font-size: 0; /* toucan IE6 */ + font-size: 0; + /* toucan IE6 */ margin: -1px 50px 0; background-color: #fff; clear: both; @@ -39,7 +39,7 @@ ul.xlist li.xunderline { } div.loading { - min-height:200px; + min-height: 200px; } /* Package List styles */ @@ -48,13 +48,13 @@ div.loading { width: 51%; } -#packagelist fieldset { +#packagelist fieldset { background-color: $theme.backgroundSecondaryColor; padding: 5px; } .package-upload { - background: transparent url($xwiki.getSkinFile('icons/silk/package_add.gif', true)) no-repeat scroll 0 5px; + background: transparent url('/file/resources/icons/silk/package_add.gif') no-repeat scroll 0 5px; padding-left: 20px; min-height: 16px; } @@ -62,11 +62,11 @@ div.loading { #packagelist ul.xlist { margin: 0 !important; list-style: none; - padding: 0px; + padding: 0px; } #packagelist .xitemcontainer { - background: transparent url($xwiki.getSkinFile('icons/silk/package.gif', true)) no-repeat scroll 5px 0.5em; + background: transparent url('/file/resources/icons/silk/package.gif') no-repeat scroll 5px 0.5em; font-size: .85em; margin-bottom: .2em; padding: .3em 0 .3em 1em; @@ -86,14 +86,15 @@ div.loading { color: $theme.textSecondaryColor; } -#packagelistcontainer .xwikibuttonlinks{ +#packagelistcontainer .xwikibuttonlinks { float: right; padding-right: .2em; - *margin-top: -2em; /* IE7 */ + *margin-top: -2em; + /* IE7 */ } #packagelistcontainer .deletelink { - background: url($xwiki.getSkinFile('icons/silk/cross.gif', true)) no-repeat left 0.2em; + background: url('/file/resources/icons/silk/cross.gif') no-repeat left 0.2em; display: block; height: 1.4em; width: 16px; @@ -108,7 +109,7 @@ div.loading { #packageDescription { background-color: #FCFCFC; - border: 0px solid $theme.borderColor; + border: 0px solid $theme.borderColor; overflow: hidden; padding: 10px; margin-bottom: 1px; @@ -124,11 +125,11 @@ div.loading { display: table-row; } -#packagecontainer .packageinfos .filename { +#packagecontainer .packageinfos .filename { font-weight: 700; } -#packagecontainer .packageinfos span{ +#packagecontainer .packageinfos span { color: $theme.textSecondaryColor; margin: 0 5px 0; } @@ -153,7 +154,7 @@ div.loading { } div#package div.importOption { - margin-bottom:5px; + margin-bottom: 5px; } div#package ul.package { @@ -178,13 +179,8 @@ ul.package li.xitem div.xitemcontainer span.checkbox { width: auto; } -ul.package li.xitem div.xitemcontainer div.spacename, -ul.package li.xitem div.xitemcontainer img { - float: left; -} - ul.package li.xitem div.xitemcontainer div.spacename { - background: transparent url($xwiki.getSkinFile('icons/silk/folder.gif', true)) no-repeat scroll 0 .1em ; + background: transparent url('/file/resources/icons/silk/folder.gif') no-repeat scroll 0 .1em; cursor: pointer; font-weight: bold; padding-left: 30px; @@ -192,7 +188,7 @@ ul.package li.xitem div.xitemcontainer div.spacename { ul.package li.xitem div.xitemcontainer div.selection { color: $theme.textSecondaryColor; - float: right; + margin-left: auto; font-size: .8em; line-height: 1.7em; margin-right: .2em; @@ -213,10 +209,30 @@ ul.pages li.xitem { ul.pages li.xitem, ul.package li.xitem { list-style-type: none; + + >div.xitemcontainer { + display: flex; + flex-wrap: wrap; + align-items: center; + + >i { + width: 10px; + margin-left: 5px; + margin-right: 5px; + } + } + + div.pages { + width: 100%; + } + + div.clearfloats { + display: none; + } } -.documentName{ - background: transparent url($xwiki.getSkinFile('icons/silk/page_white_text.gif', true)) no-repeat scroll 0 0; +.documentName { + background: transparent url('/file/resources/icons/silk/page_white_text.gif') no-repeat scroll 0 0; padding-left: 20px; } @@ -237,4 +253,4 @@ ul.package ul.pages li.xitem div.xpagecontainer input { .generalOverlay .main.layoutsubsection { width: 1024px; -} \ No newline at end of file +} diff --git a/src/main/webapp/resources/js/xwiki/importer/import.js b/src/main/webapp/resources/js/xwiki/importer/import.js index d2a770e10..963dc62fe 100644 --- a/src/main/webapp/resources/js/xwiki/importer/import.js +++ b/src/main/webapp/resources/js/xwiki/importer/import.js @@ -1,27 +1,14 @@ -var XWiki = (function(XWiki){ +var XWiki = (function (XWiki) { var importer = XWiki.importer = XWiki.importer || {}; - var translations = { - "availableDocuments" : "$msg.get('core.importer.availableDocuments')", - "importHistoryLabel" : "$msg.get('core.importer.importHistory')", - "selectionEmpty" : "$msg.get('core.importer.selectionEmptyWarning')", - "import" : "$msg.get('core.importer.import')", - "package" : "$msg.get('core.importer.package')", - "description" : "$msg.get('core.importer.package.description')", - "version" : "$msg.get('core.importer.package.version')", - "licence" : "$msg.get('core.importer.package.licence')", - "author" : "$msg.get('core.importer.package.author')", - "documentSelected" : "$msg.get('core.importer.documentSelected')", - "whenDocumentAlreadyExists" : "$msg.get('core.importer.whenDocumentAlreadyExists')", - "addNewVersion" : "$msg.get('core.importer.addNewVersion')", - "replaceDocumentHistory" : "$msg.get('core.importer.replaceDocumentHistory')", - "resetHistory" : "$msg.get('core.importer.resetHistory')", - "importAsBackup" : "$msg.get('core.importer.importAsBackup')", - "select" : "$msg.get('core.importer.select')", - "all" : "$msg.get('core.importer.selectAll')", - "none" : "$msg.get('core.importer.selectNone')" - }; + let translations = {}; + if (window.celExecOnceAfterMessagesLoaded) { + window.celExecOnceAfterMessagesLoaded( + celMessages => translations = celMessages.celAdminImport); + } else { + console.warn('celExecOnceAfterMessagesLoaded not available!'); + } // FIXME: we should have those images outside SmartClient library to lessen the dependency towards the library var expandFolderImagePath = "$xwiki.getSkinFile('js/smartclient/skins/Enterprise/images/TreeGrid/opener_closed.png', true)"; @@ -35,91 +22,86 @@ var XWiki = (function(XWiki){ * FIXME: right now disabled for IE6 - until the rich UI is fully debugged for this browser */ if (!browser.isIE6x) { - $j(document).ready(function(){ - $$("#packagelistcontainer ul.xlist li.xitem a.package").invoke("observe", "click", function(event) { - var a = event.element(), file = a.href.substring(a.href.indexOf("&file=") + 6); + $j(document).ready(function () { + $$("#packagelistcontainer ul.xlist li.xitem a.package").invoke("observe", "click", function (event) { + var a = event.element(), file = a.href.substring(a.href.indexOf("&file=") + 6); - event.stop(); // prevent loading the link. + event.stop(); // prevent loading the link. - // Visually mark the selected package as active. - $$('div#packagelistcontainer div.active').invoke('removeClassName','active'); - event.element().up("div.package").addClassName("active"); + // Visually mark the selected package as active. + $$('div#packagelistcontainer div.active').invoke('removeClassName', 'active'); + event.element().up("div.package").addClassName("active"); - // Create a package explorer widget to let the user browse - // and select/unselect the documents he wants. - new importer.PackageExplorer( "packagecontainer", decodeURIComponent(file) ); + // Create a package explorer widget to let the user browse + // and select/unselect the documents he wants. + new importer.PackageExplorer("packagecontainer", decodeURIComponent(file)); + }); }); - }); } - + /** * Extend input elements with check and uncheck methods to be able to check/uncheck * a large collection of checkboxes at once using Enumerable#invoke */ Element.addMethods('input', { - uncheck:function(elem){ + uncheck: function (elem) { elem = $(elem); elem.checked = false; return elem; }, - check:function(elem){ + check: function (elem) { elem = $(elem); elem.checked = true; return elem; } }); - + /** * Helper class to request the server informations about a package via AJAX. */ importer.PackageInformationRequest = Class.create({ - + /** * Constructor of this class */ - initialize:function(name, options) - { - this.name = decodeURIComponent( name ); - - this.successCallback = options.onSuccess || function(){}; - this.failureCallback = options.onFailure || function(){}; - + initialize: function (name, options) { + this.name = decodeURIComponent(name); + + this.successCallback = options.onSuccess || function () { }; + this.failureCallback = options.onFailure || function () { }; + var url = ''; if (typeof window.getCelHost !== 'undefined') { - url += window.getCelHost(); + url += window.getCelHost(); } else { - url += window.docgeturl; + url += window.docgeturl; } url += "?xpage=packageinfo&package=" + name; - + new Ajax.Request(url, { onSuccess: this.onSuccess.bindAsEventListener(this), - on1223 : this.on1223.bindAsEventListener(this), - on0 : this.on0.bindAsEventListener(this), - onFailure : this.onFailure.bind(this) + on1223: this.on1223.bindAsEventListener(this), + on0: this.on0.bindAsEventListener(this), + onFailure: this.onFailure.bind(this) }); }, - + // IE converts 204 status code into 1223... - on1223 : function(response) - { - response.request.options.onSuccess(response); + on1223: function (response) { + response.request.options.onSuccess(response); }, // 0 is returned for network failures, except on IE where a strange large number (12031) is returned. - on0 : function(response) - { - response.request.options.onFailure(response); + on0: function (response) { + response.request.options.onFailure(response); }, - onSuccess : function(response) - { - this.successCallback(response); + onSuccess: function (response) { + this.successCallback(response); }, - - onFailure : function(response) - { - this.failureCallback(response); + + onFailure: function (response) { + this.failureCallback(response); } }); @@ -135,10 +117,9 @@ var XWiki = (function(XWiki){ * @param id the DOM id to use as parent of this package explorer widget * @param name the name of the XAR to display the explorer */ - initialize:function(id, name) - { + initialize: function (id, name) { this.node = $(id); - this.name = name; + this.name = name; // A object to store the documents the import should ignore. // Entries will be added to that object each time the user @@ -150,212 +131,208 @@ var XWiki = (function(XWiki){ // Request the server for information about the desired package, // and bind the response to the proper callbacks (success or failure). this.node.addClassName("loading"); - var ajx = new importer.PackageInformationRequest(name,{ - onSuccess: this.onPackageInfosAvailable.bind(this), - onFailure: this.onPackageInfosRequestFailed.bind(this) + var ajx = new importer.PackageInformationRequest(name, { + onSuccess: this.onPackageInfosAvailable.bind(this), + onFailure: this.onPackageInfosRequestFailed.bind(this) }); }, - + /** * Callback triggered when the package information has been successfully retrieved */ - onPackageInfosAvailable: function(transport) - { + onPackageInfosAvailable: function (transport) { // Remove loading indicator. this.node.removeClassName("loading"); - + // Clear the content in case a package already is present. - this.node.update(); - + this.node.update(); + if (this.node.empty()) { - this.node.insert( new Element("h4", {'class':'legend'}).update( translations["availableDocuments"] )); + this.node.insert(new Element("h4", { 'class': 'legend' }).update(translations["availableDocuments"])); } - + var pack = transport.responseText.evalJSON(); - + this.infos = pack.infos; - this.packageDocuments = pack.files; + this.packageDocuments = pack.files; - this.container = new Element("div", {'id':'packageDescription'}); + this.container = new Element("div", { 'id': 'packageDescription' }); this.node.insert(this.container); // Inject the package header. - this.container.insert( this.createPackageHeader(pack.infos) ); - + this.container.insert(this.createPackageHeader(pack.infos)); + // Inject the block with select all/none links - var noneLink = new Element("span").update( translations["none"] ); + var noneLink = new Element("span").update(translations["none"]); noneLink.observe("click", this.onIgnoreAllDocuments.bind(this)); - var allLink = new Element("span").update( translations["all"] ); + var allLink = new Element("span").update(translations["all"]); allLink.observe("click", this.onRestoreAllDocuments.bind(this)); - this.container.insert( new Element("div", {'class':'selectLinks'}) - .insert( translations["select"] ) - .insert( noneLink ) - .insert(", ") - .insert( allLink ) ); + this.container.insert(new Element("div", { 'class': 'selectLinks' }) + .insert(translations["select"]) + .insert(noneLink) + .insert(", ") + .insert(allLink)); // Create and inject in the DOM the parent UL HTML element // that will contain the list of space and documents present in the package. - this.list = new Element("ul", {'class':'xlist package'}); - this.container.insert( new Element("div", {'id':'package'}).update(this.list) ); - + this.list = new Element("ul", { 'class': 'xlist package' }); + this.container.insert(new Element("div", { 'id': 'package' }).update(this.list)); + // Create the list of spaces and their documents Object.keys(this.packageDocuments).sort().each(this.addSpaceToPackage.bind(this)); - + // Insert options and button to submit the form. - this.container.insert( this.createPackageFormSubmit( pack.infos) ); - + this.container.insert(this.createPackageFormSubmit(pack.infos)); + this.container.down("div.packagesubmit input[type=radio]").checked = true; // The line above should not be needed, but as it appears IE will not let one check a checkbox before it's inserted in the DOM }, - onIgnoreAllDocuments: function() - { + onIgnoreAllDocuments: function () { this.container.select("input[type=checkbox][class=space]").invoke("uncheck"); - this.container.select("input[type=checkbox][class=space]").invoke("fire","custom:click"); + this.container.select("input[type=checkbox][class=space]").invoke("fire", "custom:click"); }, - onRestoreAllDocuments : function() - { + onRestoreAllDocuments: function () { this.container.select("input[type=checkbox][class=space]").invoke("check"); - this.container.select("input[type=checkbox][class=space]").invoke("fire","custom:click"); + this.container.select("input[type=checkbox][class=space]").invoke("fire", "custom:click"); }, - onPackageInfosRequestFailed: function(transport) - { - this.node.update(); + onPackageInfosRequestFailed: function (transport) { + this.node.update(); var errorMessage = "Failed to retrieve package information. Reason: "; if (transport.statusText == '' /* No response */ || response.status == 12031 /* In IE */) { - errorMessage += "Server not responding"; + errorMessage += "Server not responding"; } else { - errorMessage += transport.statusText; + errorMessage += transport.statusText; } this.node.removeClassName("loading"); - this.node.update( new Element("div", {'class':'errormessage'}).update(errorMessage) ); + this.node.update(new Element("div", { 'class': 'errormessage' }).update(errorMessage)); }, /** * Builds the submit DOM fragment of the form, including history options */ - createPackageFormSubmit: function(infos) - { - var submitBlock = new Element("div", {'class':'packagesubmit'}); - - submitBlock.insert( new Element("em").update( translations["whenDocumentAlreadyExists"] )); - - var defaultChoiceRadioButton = new Element("input", { 'type':'radio','name':'historyStrategy', - 'checked':'checked', 'value': 'add' }); - - submitBlock.insert( new Element("div", {'class':'historyStrategyOption'}) - .insert( defaultChoiceRadioButton ) - .insert( translations["addNewVersion"] ) ); - - submitBlock.insert( new Element("div", {'class':'historyStrategyOption'}) - .insert( new Element("input", { 'type':'radio','name':'historyStrategy', 'value': 'replace' }) ) - .insert( translations["replaceDocumentHistory"] ) ); - - submitBlock.insert( new Element("div", {'class':'historyStrategyOption'}) - .insert( new Element("input", { 'type':'radio','name':'historyStrategy', 'value': 'reset' }) ) - .insert(translations["resetHistory"] ) ); - + createPackageFormSubmit: function (infos) { + var submitBlock = new Element("div", { 'class': 'packagesubmit' }); + + submitBlock.insert(new Element("em").update(translations["whenDocumentAlreadyExists"])); + + var defaultChoiceRadioButton = new Element("input", { + 'type': 'radio', 'name': 'historyStrategy', + 'checked': 'checked', 'value': 'add' + }); + + submitBlock.insert(new Element("div", { 'class': 'historyStrategyOption' }) + .insert(defaultChoiceRadioButton) + .insert(translations["addNewVersion"])); + + submitBlock.insert(new Element("div", { 'class': 'historyStrategyOption' }) + .insert(new Element("input", { 'type': 'radio', 'name': 'historyStrategy', 'value': 'replace' })) + .insert(translations["replaceDocumentHistory"])); + + submitBlock.insert(new Element("div", { 'class': 'historyStrategyOption' }) + .insert(new Element("input", { 'type': 'radio', 'name': 'historyStrategy', 'value': 'reset' })) + .insert(translations["resetHistory"])); + if (XWiki.hasBackupPackImportRights) { - var importAsBackupCheckbox = new Element("input", { 'type':'checkbox', 'name':'importAsBackup', 'value':'true' }); - if (infos.backup) { - importAsBackupCheckbox.checked = true; - } - submitBlock.insert( new Element("div", {'class':'importOption'}) - .insert(importAsBackupCheckbox) - .insert(translations["importAsBackup"]) ); + var importAsBackupCheckbox = new Element("input", { 'type': 'checkbox', 'name': 'importAsBackup', 'value': 'true' }); + if (infos.backup) { + importAsBackupCheckbox.checked = true; + } + submitBlock.insert(new Element("div", { 'class': 'importOption' }) + .insert(importAsBackupCheckbox) + .insert(translations["importAsBackup"])); } - - var submit = new Element("span", {'class':'buttonwrapper'}); - var button = new Element("input", {'type':'submit', 'value': translations["import"], 'class':'button'}); + + var submit = new Element("span", { 'class': 'buttonwrapper' }); + var button = new Element("input", { 'type': 'submit', 'value': translations["import"], 'class': 'button' }); button.observe("click", this.onPackageSubmit.bind(this)); submit.insert(button); - + submitBlock.insert(submit); - + return submitBlock; }, /** * Callback when package is submitted. */ - onPackageSubmit: function() - { + onPackageSubmit: function () { if (this.countSelectedDocuments() == 0) { - // Refuse to import since no document remains selected. - // Displays a warning and exit. - var warning = new Element("span", {'class':'warningmessage'}).update( translations["selectionEmpty"] ); - if (!$("packagecontainer").down("div.packagesubmit span.warningmessage")) { - // Display the warning only if not present yet in the DOM (in case the user clicks like a maniac). - $('packagecontainer').select('div.packagesubmit input').last().insert({'after' : warning}); - Element.remove.delay(5, warning); - } - - return; + // Refuse to import since no document remains selected. + // Displays a warning and exit. + var warning = new Element("span", { 'class': 'warningmessage' }).update(translations["selectionEmpty"]); + if (!$("packagecontainer").down("div.packagesubmit span.warningmessage")) { + // Display the warning only if not present yet in the DOM (in case the user clicks like a maniac). + $('packagecontainer').select('div.packagesubmit input').last().insert({ 'after': warning }); + Element.remove.delay(5, warning); + } + + return; } - + // Create form and submit ajax request. var parameters = {}; - + parameters["action"] = "import"; parameters["name"] = this.name; - parameters["historyStrategy"] = $('packageDescription').down("input[type=radio][value='add']").checked ? "add" : - ($('packageDescription').down("input[type=radio][value='replace']").checked ? "replace" : "reset"); + parameters["historyStrategy"] = $('packageDescription').down("input[type=radio][value='add']").checked ? "add" : + ($('packageDescription').down("input[type=radio][value='replace']").checked ? "replace" : "reset"); if (XWiki.hasBackupPackImportRights) { parameters["importAsBackup"] = $('packageDescription').down("input[type=checkbox][name='importAsBackup']").checked ? "true" : "false"; } parameters["ajax"] = "1"; - + var pages = []; - + var spaces = Object.keys(this.packageDocuments); - for (var i=0;i < spaces.length; i++) { + for (var i = 0; i < spaces.length; i++) { var space = this.packageDocuments[spaces[i]]; var documents = Object.keys(space); - for (var j=0;j