Changes for page Message Sender Macro
Last modified by Ludovic Dubost on 2024/07/22 15:51
From version 13.1
edited by Ludovic Dubost
on 2022/04/20 17:59
on 2022/04/20 17:59
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-messagestream-ui/14.0]
To version 9.1
edited by Ludovic Dubost
on 2019/08/02 10:59
on 2019/08/02 10:59
Change comment:
Migrated property [contentJavaType] from class [XWiki.WikiMacroClass]
Summary
-
Objects (2 modified, 0 added, 0 removed)
Details
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -1,10 +1,9 @@ 1 1 var XWiki = (function (XWiki) { 2 2 // Start XWiki augmentation. 3 3 XWiki.MessageStream = Class.create({ 4 - initialize : function(container) { 5 - container = container || $(document.body); 6 - this.prepareForms(container); 7 - this.enhanceSelect(container); 4 + initialize : function() { 5 + this.prepareForms(); 6 + this.enhanceSelect(); 8 8 }, 9 9 prepareTargetInput : function(event, element) { 10 10 var targetType = element.options[element.selectedIndex].value; ... ... @@ -31,14 +31,14 @@ 31 31 } 32 32 }); 33 33 }, 34 - enhanceSelect: function ( container) {35 - container.select('.messagestream select[name="visibilityLevel"]').each(function(element) {33 + enhanceSelect: function () { 34 + $$('.messagestream select[name="visibilityLevel"]').each(function(element) { 36 36 element.observe('change', this.prepareTargetInput.bindAsEventListener(this, element)); 37 37 this.prepareTargetInput(null, element); 38 38 }.bind(this)); 39 39 }, 40 - prepareForms: function( container) {41 - container.select('.messagestream form').each(function(msForm) {39 + prepareForms: function() { 40 + $$('.messagestream form').each(function(msForm) { 42 42 msForm.action = msForm.action.replace(/xredirect=.*$/, 'xpage=plain') 43 43 msForm.observe('submit', function(event) { 44 44 event.stop(); ... ... @@ -64,7 +64,12 @@ 64 64 document.fire('xwiki:activity:newActivity', msForm); 65 65 }, 66 66 onFailure: function(response) { 67 - var failureReason = response.statusText || 'Server not responding'; 66 + var failureReason = ''; 67 + if (response.statusText == '' /* No response */ || response.status == 12031 /* In IE */) { 68 + failureReason = 'Server not responding'; 69 + } else { 70 + failureReason = response.statusText; 71 + } 68 68 if (msForm) { 69 69 msForm._disabled = false 70 70 if (msForm._notification) { ... ... @@ -73,6 +73,9 @@ 73 73 msForm._notification = new XWiki.widgets.Notification("$services.localization.render('xe.activity.messages.submit.failed'): " + failureReason, 'error'); 74 74 } 75 75 }, 80 + on1223 : function(response) { /*SUCCESS*/ 81 + response.request.options.onSuccess(response); 82 + }, 76 76 on0 : function(response) { /*FAILURE*/ 77 77 response.request.options.onFailure(response); 78 78 }, ... ... @@ -86,21 +86,11 @@ 86 86 } 87 87 }); 88 88 89 -var init = function (event) { 90 - var elements = (event && event.memo.elements) || [$(document.body)]; 91 - elements.forEach(function(container) { 92 - new XWiki.MessageStream(container); 93 - }); 94 - return true; 96 +var init = function() { 97 + return new XWiki.MessageStream(); 95 95 }; 99 +(XWiki.domIsLoaded && init()) || document.observe('xwiki:dom:loaded', init); 96 96 97 -// Initialize the message sender macro when the page is loaded. 98 -(XWiki.domIsLoaded && init()) 99 -|| document.observe('xwiki:dom:loaded', init); 100 - 101 -// Initialize the message sender macro when it is added after the page is loaded. 102 -document.observe('xwiki:dom:updated', init); 103 - 104 104 // End XWiki augmentation. 105 105 return XWiki; 106 106 }(XWiki || {}));
- XWiki.WikiMacroParameterClass[2]
-
- Parameter description
-
... ... @@ -1,3 +1,3 @@ 1 1 Comma separated list of visibility options that the macro should allow the user to choose from. 2 2 3 -This list should be a sublist of the def ault ones: 'everyone', 'followers', 'group', 'user'.3 +This list should be a sublist of the defualt ones: 'everyone', 'followers', 'group', 'user'.