diff --git a/file/js/be.bastelstu.Chat.litcoffee b/file/js/be.bastelstu.Chat.litcoffee
index aaf448b..b4444e0 100644
--- a/file/js/be.bastelstu.Chat.litcoffee
+++ b/file/js/be.bastelstu.Chat.litcoffee
@@ -813,6 +813,34 @@ Remove the given callback from the given event.
events[event].remove callback
true
+
+ if WCF?.Attachment?.Upload?
+ Attachment = WCF.Attachment.Upload.extend
+ init: ->
+ @_super $('#timsChatUploadContainer'), $('
').appendTo('#content'), 'be.bastelstu.chat.message', 0, 0, 0, 1, null
+
+ _createButton: ->
+ if @_supportsAJAXUpload
+ @_fileUpload = $ """"""
+ @_fileUpload.change =>
+ do @_upload
+ button = $ """#{WCF.Language.get("wcf.global.button.upload")}"""
+ button.prepend @_fileUpload
+ else
+ button = $ """#{WCF.Language.get("wcf.global.button.upload")}"""
+ button.click =>
+ do @_showOverlay
+
+ @_insertButton button
+
+ _insertButton: (button) ->
+ @_super(button)
+ @_buttonSelector.removeClass 'invisible'
+
+ _upload: ->
+ @_tmpHash = do Math.random
+ @_objectID = be.bastelstu.Chat.currentRoomID
+ do @_super
And finally export the public methods and variables.
@@ -823,10 +851,12 @@ And finally export the public methods and variables.
insertText: insertText
freeTheFish: freeTheFish
join: join
+ currentRoomID: currentRoom.roomID
listener:
add: addListener
remove: removeListener
-
+ Chat.Attachment = Attachment if Attachment?
+
window.be ?= {}
be.bastelstu ?= {}
window.be.bastelstu.Chat = Chat
diff --git a/file/lib/page/ChatPage.class.php b/file/lib/page/ChatPage.class.php
index bbff697..e2ce651 100644
--- a/file/lib/page/ChatPage.class.php
+++ b/file/lib/page/ChatPage.class.php
@@ -73,6 +73,12 @@ class ChatPage extends \wcf\page\AbstractPage {
*/
public $smileyCategories = array();
+ /**
+ * attachment handler
+ * @see \wcf\system\attachment\AttachmentHandler
+ */
+ public $attachmentHandler = null;
+
/**
* @see wcf\page\AbstractPage::$enableTracking
*/
@@ -94,6 +100,7 @@ public function assignVariables() {
'messageTypes' => $reflection->getConstants(),
'defaultSmilies' => $this->defaultSmilies,
'smileyCategories' => $this->smileyCategories,
+ 'attachmentHandler' => $this->attachmentHandler,
'sidebarCollapsed' => \wcf\system\user\collapsible\content\UserCollapsibleContentHandler::getInstance()->isCollapsed('com.woltlab.wcf.collapsibleSidebar', 'be.bastelstu.chat.ChatPage'),
'sidebarName' => 'be.bastelstu.chat.ChatPage'
));
@@ -125,6 +132,10 @@ public function readData() {
$this->defaultSmilies = \wcf\data\smiley\SmileyCache::getInstance()->getCategorySmilies($firstCategory->categoryID ?: null);
}
}
+
+ if (MODULE_ATTACHMENT) {
+ $this->attachmentHandler = new \wcf\system\attachment\AttachmentHandler('be.bastelstu.chat.message', 0, '', 0);
+ }
}
/**
diff --git a/template/chat.tpl b/template/chat.tpl
index 0ff5b60..0b24bde 100644
--- a/template/chat.tpl
+++ b/template/chat.tpl
@@ -21,12 +21,22 @@
'chat.error.onMessageLoad': '{@"chat.error.onMessageLoad"|language|encodeJS}',
'chat.error.duplicateTab': '{lang}chat.error.duplicateTab{/lang}',
'chat.error.join': '{lang}chat.error.join{/lang}',
- 'chat.error.reload': '{lang}chat.error.reload{/lang}'
+ 'chat.error.reload': '{lang}chat.error.reload{/lang}',
+ 'wcf.attachment.upload.error.invalidExtension': '{lang}wcf.attachment.upload.error.invalidExtension{/lang}',
+ 'wcf.attachment.upload.error.tooLarge': '{lang}wcf.attachment.upload.error.tooLarge{/lang}',
+ 'wcf.attachment.upload.error.reachedLimit': '{lang}wcf.attachment.upload.error.reachedLimit{/lang}',
+ 'wcf.attachment.upload.error.reachedRemainingLimit': '{lang}wcf.attachment.upload.error.reachedRemainingLimit{/lang}',
+ 'wcf.attachment.upload.error.uploadFailed': '{lang}wcf.attachment.upload.error.uploadFailed{/lang}',
+ 'wcf.global.button.upload': '{lang}wcf.global.button.upload{/lang}',
+ 'wcf.attachment.insert': '{lang}wcf.attachment.insert{/lang}',
+ 'wcf.attachment.delete.sure': '{lang}wcf.attachment.delete.sure{/lang}'
});
// Boot the chat
{if MODULE_SMILEY}WCF.TabMenu.init();{/if}
+ {if MODULE_ATTACHMENT}new be.bastelstu.Chat.Attachment();{/if}
new WCF.Message.Smilies();
+
{capture assign='messageTemplate'}{include application='chat' file='message'}{/capture}
{capture assign='userTemplate'}{include application='chat' file='userListUser'}{/capture}
@@ -110,10 +120,17 @@
{lang}chat.general.controls{/lang}
diff --git a/template/javascriptInclude.tpl b/template/javascriptInclude.tpl
index 11cce77..249ddcf 100644
--- a/template/javascriptInclude.tpl
+++ b/template/javascriptInclude.tpl
@@ -1,3 +1,4 @@
+{if MODULE_ATTACHMENT}{/if}
-{event name='javascript'}
\ No newline at end of file
+{event name='javascript'}