mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Add first pieces of attachment upload
Currently the upload is working, but it's impossible to delete the attachment or generate a "attachment message"
This commit is contained in:
parent
b90d21a224
commit
0fa4bbc9b6
@ -814,6 +814,34 @@ Remove the given callback from the given event.
|
|||||||
|
|
||||||
true
|
true
|
||||||
|
|
||||||
|
if WCF?.Attachment?.Upload?
|
||||||
|
Attachment = WCF.Attachment.Upload.extend
|
||||||
|
init: ->
|
||||||
|
@_super $('#timsChatUploadContainer'), $('<ul>').appendTo('#content'), 'be.bastelstu.chat.message', 0, 0, 0, 1, null
|
||||||
|
|
||||||
|
_createButton: ->
|
||||||
|
if @_supportsAJAXUpload
|
||||||
|
@_fileUpload = $ """<input type="file" name="#{@_name}" />"""
|
||||||
|
@_fileUpload.change =>
|
||||||
|
do @_upload
|
||||||
|
button = $ """<a id="timsChatUpload" class="button uploadButton jsTooltip" title="#{WCF.Language.get("wcf.global.button.upload")}"><span class="icon icon16 icon-upload-alt"></span><span class="invisible">#{WCF.Language.get("wcf.global.button.upload")}</span></a>"""
|
||||||
|
button.prepend @_fileUpload
|
||||||
|
else
|
||||||
|
button = $ """<a id="timsChatUpload" class="button uploadFallbackButton jsTooltip" title="#{WCF.Language.get("wcf.global.button.upload")}"><span class="icon icon16 icon-upload-alt"></span><span class="invisible">#{WCF.Language.get("wcf.global.button.upload")}</span></a>"""
|
||||||
|
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.
|
And finally export the public methods and variables.
|
||||||
|
|
||||||
Chat =
|
Chat =
|
||||||
@ -823,9 +851,11 @@ And finally export the public methods and variables.
|
|||||||
insertText: insertText
|
insertText: insertText
|
||||||
freeTheFish: freeTheFish
|
freeTheFish: freeTheFish
|
||||||
join: join
|
join: join
|
||||||
|
currentRoomID: currentRoom.roomID
|
||||||
listener:
|
listener:
|
||||||
add: addListener
|
add: addListener
|
||||||
remove: removeListener
|
remove: removeListener
|
||||||
|
Chat.Attachment = Attachment if Attachment?
|
||||||
|
|
||||||
window.be ?= {}
|
window.be ?= {}
|
||||||
be.bastelstu ?= {}
|
be.bastelstu ?= {}
|
||||||
|
@ -73,6 +73,12 @@ class ChatPage extends \wcf\page\AbstractPage {
|
|||||||
*/
|
*/
|
||||||
public $smileyCategories = array();
|
public $smileyCategories = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* attachment handler
|
||||||
|
* @see \wcf\system\attachment\AttachmentHandler
|
||||||
|
*/
|
||||||
|
public $attachmentHandler = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see wcf\page\AbstractPage::$enableTracking
|
* @see wcf\page\AbstractPage::$enableTracking
|
||||||
*/
|
*/
|
||||||
@ -94,6 +100,7 @@ public function assignVariables() {
|
|||||||
'messageTypes' => $reflection->getConstants(),
|
'messageTypes' => $reflection->getConstants(),
|
||||||
'defaultSmilies' => $this->defaultSmilies,
|
'defaultSmilies' => $this->defaultSmilies,
|
||||||
'smileyCategories' => $this->smileyCategories,
|
'smileyCategories' => $this->smileyCategories,
|
||||||
|
'attachmentHandler' => $this->attachmentHandler,
|
||||||
'sidebarCollapsed' => \wcf\system\user\collapsible\content\UserCollapsibleContentHandler::getInstance()->isCollapsed('com.woltlab.wcf.collapsibleSidebar', 'be.bastelstu.chat.ChatPage'),
|
'sidebarCollapsed' => \wcf\system\user\collapsible\content\UserCollapsibleContentHandler::getInstance()->isCollapsed('com.woltlab.wcf.collapsibleSidebar', 'be.bastelstu.chat.ChatPage'),
|
||||||
'sidebarName' => '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);
|
$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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,12 +21,22 @@
|
|||||||
'chat.error.onMessageLoad': '{@"chat.error.onMessageLoad"|language|encodeJS}',
|
'chat.error.onMessageLoad': '{@"chat.error.onMessageLoad"|language|encodeJS}',
|
||||||
'chat.error.duplicateTab': '{lang}chat.error.duplicateTab{/lang}',
|
'chat.error.duplicateTab': '{lang}chat.error.duplicateTab{/lang}',
|
||||||
'chat.error.join': '{lang}chat.error.join{/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
|
// Boot the chat
|
||||||
{if MODULE_SMILEY}WCF.TabMenu.init();{/if}
|
{if MODULE_SMILEY}WCF.TabMenu.init();{/if}
|
||||||
|
{if MODULE_ATTACHMENT}new be.bastelstu.Chat.Attachment();{/if}
|
||||||
new WCF.Message.Smilies();
|
new WCF.Message.Smilies();
|
||||||
|
|
||||||
{capture assign='messageTemplate'}{include application='chat' file='message'}{/capture}
|
{capture assign='messageTemplate'}{include application='chat' file='message'}{/capture}
|
||||||
{capture assign='userTemplate'}{include application='chat' file='userListUser'}{/capture}
|
{capture assign='userTemplate'}{include application='chat' file='userListUser'}{/capture}
|
||||||
|
|
||||||
@ -110,10 +120,17 @@
|
|||||||
<span class="invisible">{lang}chat.general.controls{/lang}</span>
|
<span class="invisible">{lang}chat.general.controls{/lang}</span>
|
||||||
<ul class="smallButtons buttonGroup">
|
<ul class="smallButtons buttonGroup">
|
||||||
<li><a id="timsChatAutoscroll" accesskey="d" class="button active timsChatToggle jsTooltip" title="{lang}chat.general.scroll{/lang}" data-status="1"><span class="icon icon16 icon-arrow-down"></span><span class="invisible">{lang}chat.general.scroll{/lang}</span></a></li>{*
|
<li><a id="timsChatAutoscroll" accesskey="d" class="button active timsChatToggle jsTooltip" title="{lang}chat.general.scroll{/lang}" data-status="1"><span class="icon icon16 icon-arrow-down"></span><span class="invisible">{lang}chat.general.scroll{/lang}</span></a></li>{*
|
||||||
|
|
||||||
*}<li><a id="timsChatFullscreen" accesskey="f" class="button timsChatToggle jsTooltip" title="{lang}chat.general.fullscreen{/lang}" data-status="0"><span class="icon icon16 icon-fullscreen"></span><span class="invisible">{lang}chat.general.fullscreen{/lang}</span></a></li>{*
|
*}<li><a id="timsChatFullscreen" accesskey="f" class="button timsChatToggle jsTooltip" title="{lang}chat.general.fullscreen{/lang}" data-status="0"><span class="icon icon16 icon-fullscreen"></span><span class="invisible">{lang}chat.general.fullscreen{/lang}</span></a></li>{*
|
||||||
|
|
||||||
*}<li><a id="timsChatNotify" accesskey="n" class="button timsChatToggle jsTooltip" title="{lang}chat.general.notify{/lang}" data-status="0"><span class="icon icon16 icon-bell-alt"></span><span class="invisible">{lang}chat.general.notify{/lang}</span></a></li>{*
|
*}<li><a id="timsChatNotify" accesskey="n" class="button timsChatToggle jsTooltip" title="{lang}chat.general.notify{/lang}" data-status="0"><span class="icon icon16 icon-bell-alt"></span><span class="invisible">{lang}chat.general.notify{/lang}</span></a></li>{*
|
||||||
|
|
||||||
*}<li{if !MODULE_SMILEY || !$smileyCategories|count} style="display: none;"{/if}><a id="timsChatSmilies" accesskey="e" class="button{if ENABLE_SMILIES_DEFAULT_VALUE} active{/if} timsChatToggle jsTooltip" title="{lang}chat.general.smilies{/lang}" data-status="{@ENABLE_SMILIES_DEFAULT_VALUE}"><span class="icon icon16 icon-smile"></span><span class="invisible">{lang}chat.general.smilies{/lang}</span></a></li>{*
|
*}<li{if !MODULE_SMILEY || !$smileyCategories|count} style="display: none;"{/if}><a id="timsChatSmilies" accesskey="e" class="button{if ENABLE_SMILIES_DEFAULT_VALUE} active{/if} timsChatToggle jsTooltip" title="{lang}chat.general.smilies{/lang}" data-status="{@ENABLE_SMILIES_DEFAULT_VALUE}"><span class="icon icon16 icon-smile"></span><span class="invisible">{lang}chat.general.smilies{/lang}</span></a></li>{*
|
||||||
|
|
||||||
|
*}<li id="timsChatUploadContainer" class="invisible" data-max-size="{$attachmentHandler->getMaxSize()}"></li>{*
|
||||||
|
|
||||||
*}<li><a id="timsChatClear" class="button jsTooltip" title="{lang}chat.general.clear{/lang}"><span class="icon icon16 icon-remove"></span><span class="invisible">{lang}chat.general.clear{/lang}</span></a></li>{*
|
*}<li><a id="timsChatClear" class="button jsTooltip" title="{lang}chat.general.clear{/lang}"><span class="icon icon16 icon-remove"></span><span class="invisible">{lang}chat.general.clear{/lang}</span></a></li>{*
|
||||||
|
|
||||||
*}<li><a id="timsChatMark" class="button timsChatToggle jsTooltip" title="{lang}chat.general.mark{/lang}" data-status="0"><span class="icon icon16 icon-check"></span><span class="invisible">{lang}chat.general.mark{/lang}</span></a></li>
|
*}<li><a id="timsChatMark" class="button timsChatToggle jsTooltip" title="{lang}chat.general.mark{/lang}" data-status="0"><span class="icon icon16 icon-check"></span><span class="invisible">{lang}chat.general.mark{/lang}</span></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
{if MODULE_ATTACHMENT}<script data-relocate="true" src="{@$__wcf->getPath()}js/WCF.Attachment{if !ENABLE_DEBUG_MODE}.min{/if}.js?v={@$__wcfVersion}"></script>{/if}
|
||||||
<script data-relocate="true" src="{$__wcf->getPath('chat')}js/be.bastelstu.Chat{if !ENABLE_DEBUG_MODE}.min{/if}.js?version={PACKAGE_VERSION|rawurlencode}"></script>
|
<script data-relocate="true" src="{$__wcf->getPath('chat')}js/be.bastelstu.Chat{if !ENABLE_DEBUG_MODE}.min{/if}.js?version={PACKAGE_VERSION|rawurlencode}"></script>
|
||||||
<!--script src="{$__wcf->getPath('chat')}js/be.bastelstu.Chat.Log{if !ENABLE_DEBUG_MODE}.min{/if}.js?version={PACKAGE_VERSION|rawurlencode}"></script-->
|
<!--script src="{$__wcf->getPath('chat')}js/be.bastelstu.Chat.Log{if !ENABLE_DEBUG_MODE}.min{/if}.js?version={PACKAGE_VERSION|rawurlencode}"></script-->
|
||||||
{event name='javascript'}
|
{event name='javascript'}
|
Loading…
Reference in New Issue
Block a user