image upload from chat
This commit is contained in:
@@ -146,7 +146,7 @@ class fileUploader
|
|||||||
|
|
||||||
if($this->save($sFileName.'.'.$sExt))
|
if($this->save($sFileName.'.'.$sExt))
|
||||||
{
|
{
|
||||||
return array('success'=>true, 'file_name'=>$sFileName.'.'.$sExt);
|
return array('success'=>true, 'file_name'=>$sFileName.'.'.$sExt, 'file_path'=>$_GET['serv_name'].$this->sFolderPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
13
jquery/common.js
vendored
13
jquery/common.js
vendored
@@ -47,10 +47,12 @@ $.prototype.addButton = function(sType, sTitle, oClickLink, sId, sButtonClass, s
|
|||||||
asAttributes.href = oClickLink;
|
asAttributes.href = oClickLink;
|
||||||
asAttributes.target = '_blank';
|
asAttributes.target = '_blank';
|
||||||
}
|
}
|
||||||
var $Button = $('<a>', asAttributes)
|
var $Button = $('<a>', asAttributes).append($('<i>', {'class':'icon fa fa-c-'+sType}));
|
||||||
.append($('<i>', {'class':'icon fa fa-c-'+sType}))
|
|
||||||
.append($('<span>', {'class':'value'}).text(sTitle))
|
if(sButtonClass.indexOf('no_text') == -1) $Button.append($('<span>', {'class':'value'}).text(sTitle));
|
||||||
.appendTo($This);
|
else $Button.attr('title', sTitle);
|
||||||
|
|
||||||
|
$Button.appendTo($This);
|
||||||
|
|
||||||
//Function
|
//Function
|
||||||
if(!bLink) $Button.click(function(e){e.preventDefault(); oClickLink($(this));});
|
if(!bLink) $Button.click(function(e){e.preventDefault(); oClickLink($(this));});
|
||||||
@@ -475,8 +477,7 @@ function debug(text, bQuery)
|
|||||||
function getLoginToken(sPass)
|
function getLoginToken(sPass)
|
||||||
{
|
{
|
||||||
if(!window.location.origin) window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
|
if(!window.location.origin) window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
|
||||||
//return md5(sPass+window.location.origin+window.location.pathname);
|
return md5(sPass+window.location.origin+window.location.pathname);
|
||||||
return md5(sPass+'http://databap.lutran.fr/');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function md5(str)
|
function md5(str)
|
||||||
|
|||||||
10
jquery/databap.js
vendored
10
jquery/databap.js
vendored
@@ -710,14 +710,20 @@ function Databap()
|
|||||||
$msg.hide().insertBefore(elem).slideDown('fast', function(){databap.updateScrollBar('bottom');}).delay(5000).slideUp('fast', function(){$(this).remove();databap.updateScrollBar();});
|
$msg.hide().insertBefore(elem).slideDown('fast', function(){databap.updateScrollBar('bottom');}).delay(5000).slideUp('fast', function(){$(this).remove();databap.updateScrollBar();});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.feedback = function(sClass, sMsg)
|
this.feedback = function(sClass, sMsg, bClean)
|
||||||
{
|
{
|
||||||
|
bClean = bClean || false;
|
||||||
if(sClass=='error' && sMsg=='') sMsg = 'Aïe ! Une erreur inconnue est suvenue';
|
if(sClass=='error' && sMsg=='') sMsg = 'Aïe ! Une erreur inconnue est suvenue';
|
||||||
else if(sClass=='error' && $.inArray(sMsg, self.consts.errors.system)!=-1) sMsg = 'Une erreur interne est survenue. Merci de contacter l\'admin';
|
else if(sClass=='error' && $.inArray(sMsg, self.consts.errors.system)!=-1) sMsg = 'Une erreur interne est survenue. Merci de contacter l\'admin';
|
||||||
|
|
||||||
|
//clean box
|
||||||
|
$Box = $('#title_feedback');
|
||||||
|
if(bClean) $Box.empty();
|
||||||
|
|
||||||
$('<span>', {'class':'feedback '+sClass})
|
$('<span>', {'class':'feedback '+sClass})
|
||||||
.append($('<i>', {'class':'fa fa-inline fa-c-'+sClass}))
|
.append($('<i>', {'class':'fa fa-inline fa-c-'+sClass}))
|
||||||
.append(self.addPunctuation(sMsg))
|
.append(self.addPunctuation(sMsg))
|
||||||
.appendTo('#title_feedback')
|
.appendTo($Box)
|
||||||
.slideDown('fast')
|
.slideDown('fast')
|
||||||
.delay(5000)
|
.delay(5000)
|
||||||
.slideUp('fast', function(){$(this).remove();});
|
.slideUp('fast', function(){$(this).remove();});
|
||||||
|
|||||||
19
jquery/fileuploader.js
vendored
19
jquery/fileuploader.js
vendored
@@ -486,13 +486,7 @@ qq.FileUploader = function(o){
|
|||||||
// call parent constructor
|
// call parent constructor
|
||||||
qq.FileUploaderBasic.apply(this, arguments);
|
qq.FileUploaderBasic.apply(this, arguments);
|
||||||
|
|
||||||
// additional options
|
var sDefTemplate = '<div class="uploader_box">' +
|
||||||
qq.extend(this._options, {
|
|
||||||
element: null,
|
|
||||||
// if set, will be used instead of uploader_list in template
|
|
||||||
listElement: null,
|
|
||||||
|
|
||||||
template:'<div class="uploader_box">' +
|
|
||||||
'<div class="uploader_droparea round">' +
|
'<div class="uploader_droparea round">' +
|
||||||
'<span>' +
|
'<span>' +
|
||||||
((typeof o.addSlideText !== 'undefined')?o.addSlideText:'Glisser les images ici') +
|
((typeof o.addSlideText !== 'undefined')?o.addSlideText:'Glisser les images ici') +
|
||||||
@@ -503,7 +497,16 @@ qq.FileUploader = function(o){
|
|||||||
'</a>' +
|
'</a>' +
|
||||||
'<div class="uploader_buffer"></div>' +
|
'<div class="uploader_buffer"></div>' +
|
||||||
'<ul id="uploader_list" class="uploader_list"></ul>' +
|
'<ul id="uploader_list" class="uploader_list"></ul>' +
|
||||||
'</div>',
|
'</div>';
|
||||||
|
var sTemplate = (typeof o.template !== 'undefined')?o.template:sDefTemplate;
|
||||||
|
|
||||||
|
// additional options
|
||||||
|
qq.extend(this._options, {
|
||||||
|
element: null,
|
||||||
|
// if set, will be used instead of uploader_list in template
|
||||||
|
listElement: null,
|
||||||
|
|
||||||
|
template:sTemplate,
|
||||||
|
|
||||||
// template for one item in file list
|
// template for one item in file list
|
||||||
fileTemplate:'<li id="uploader_item">' +
|
fileTemplate:'<li id="uploader_item">' +
|
||||||
|
|||||||
@@ -24,12 +24,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="chat_input" class="round">
|
<div id="chat_input" class="round">
|
||||||
<form id="chat_form" name="chat_form">
|
<form id="chat_form" name="chat_form">
|
||||||
<i id="message_img" class="fa fa-fw fa-20 fa-c-comment"></i><input type="text" id="message" name="message" value="" maxlength="500" autofocus />
|
|
||||||
<input type="hidden" id="chan" name="chan" value="" maxlength="50" />
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="template" class="hide">
|
<div id="template" class="hide">
|
||||||
|
<div id="message_input">
|
||||||
|
<i id="message_img" class="fa fa-fw fa-20 fa-c-comment"></i>
|
||||||
|
<input type="text" id="message" name="message" value="" maxlength="500" autofocus />
|
||||||
|
<input type="hidden" id="chan" name="chan" value="" maxlength="50" />
|
||||||
|
<i id="upload_img" class="fa fa-fw fa-20 fa-c-image"></i>
|
||||||
|
</div>
|
||||||
<div id="help" class="help tiny_round">
|
<div id="help" class="help tiny_round">
|
||||||
<p class="title">Manuel d'utilisation</p>
|
<p class="title">Manuel d'utilisation</p>
|
||||||
<p class="title righty"> <span id="close_help" class="clickable"><i class="fa fa-30 fa-c-close"></i></span></p>
|
<p class="title righty"> <span id="close_help" class="clickable"><i class="fa fa-30 fa-c-close"></i></span></p>
|
||||||
@@ -93,7 +98,7 @@ databap.pageInit = function()
|
|||||||
//Bind message box key events
|
//Bind message box key events
|
||||||
databap.getMainElem('#chat_form').submit(function(e){e.preventDefault();});
|
databap.getMainElem('#chat_form').submit(function(e){e.preventDefault();});
|
||||||
$MsgInput.bind('keydown', function(e){if(e.which == 9)e.preventDefault();});
|
$MsgInput.bind('keydown', function(e){if(e.which == 9)e.preventDefault();});
|
||||||
$MsgInput.keyup(function(event){add_message(event);});
|
$MsgInput.keyup(function(e){keyController(e);});
|
||||||
|
|
||||||
//Loading the chat
|
//Loading the chat
|
||||||
self.initScrollBar('#chat_container', '#chat_messages_box', '#chat_messages');
|
self.initScrollBar('#chat_container', '#chat_messages_box', '#chat_messages');
|
||||||
@@ -114,6 +119,9 @@ databap.pageInit = function()
|
|||||||
//Init sidebar events
|
//Init sidebar events
|
||||||
initSideBar();
|
initSideBar();
|
||||||
|
|
||||||
|
//Setup Image upload
|
||||||
|
initImageUpload();
|
||||||
|
|
||||||
//Init's end
|
//Init's end
|
||||||
databap.setInitEnd(true);
|
databap.setInitEnd(true);
|
||||||
};
|
};
|
||||||
@@ -124,7 +132,7 @@ databap.onResize = function()
|
|||||||
self.setScrollBarSize('maximize');
|
self.setScrollBarSize('maximize');
|
||||||
|
|
||||||
//Message Input
|
//Message Input
|
||||||
$('#message').width($('#chat_input').width() - $('#message_img').outerWidth(true)- 1);
|
//$('#message').width($('#chat_input').width() - $('#message_img').outerWidth(true)- 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
//Disconnect from the chat
|
//Disconnect from the chat
|
||||||
@@ -143,6 +151,49 @@ databap.onKeyDown = function(e)
|
|||||||
else databap.tmp('refresh', false);
|
else databap.tmp('refresh', false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function initImageUpload()
|
||||||
|
{
|
||||||
|
//load Uploader
|
||||||
|
self.tmp('uploader', new qq.FileUploader
|
||||||
|
(
|
||||||
|
{
|
||||||
|
element: document.getElementById('chat_form'),
|
||||||
|
action: databap.getActionLink('upload_image'),
|
||||||
|
allowedExtensions: databap.consts.authorized_img_exts,
|
||||||
|
sizeLimit: parseInt(databap.consts.max_size)*100,
|
||||||
|
template: '<div class="uploader_box">' +
|
||||||
|
'<div class="uploader_droparea round">' +
|
||||||
|
'<span>Glisser les images ici</span>' +
|
||||||
|
'</div>' +
|
||||||
|
'<a class="uploader_button hide"></a>' +
|
||||||
|
'<div class="uploader_buffer hide"></div>' +
|
||||||
|
'<ul id="uploader_list" class="uploader_list hide"></ul>' +
|
||||||
|
'</div>',
|
||||||
|
onComplete:function(id, fileName, result)
|
||||||
|
{
|
||||||
|
if(result.success==true)
|
||||||
|
{
|
||||||
|
postMessage('/img '+result.file_path+result.file_name);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onProgress:function(id, fileName, loaded, total)
|
||||||
|
{
|
||||||
|
databap.feedback('success', 'Télécharge: '+(loaded/total*100)+'%', true);
|
||||||
|
},
|
||||||
|
showMessage:function(sMsg)
|
||||||
|
{
|
||||||
|
databap.feedback('error', sMsg);
|
||||||
|
},
|
||||||
|
debug: false,
|
||||||
|
stepId: 1
|
||||||
|
}
|
||||||
|
));
|
||||||
|
$('.uploader_box').append($('#message_input').children());
|
||||||
|
|
||||||
|
//prompt file explorer
|
||||||
|
$('#upload_img').click(function(){$('#c1_file').click();});
|
||||||
|
}
|
||||||
|
|
||||||
function initSideBar()
|
function initSideBar()
|
||||||
{
|
{
|
||||||
//Sidebar Events
|
//Sidebar Events
|
||||||
@@ -503,21 +554,10 @@ function quitChan(sChanKeyName)
|
|||||||
else databap.addFailIcon('Ceci est le dernier chan');
|
else databap.addFailIcon('Ceci est le dernier chan');
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_message(e)
|
function postMessage(sMsg)
|
||||||
{
|
{
|
||||||
if(e.keyCode != 9) databap.tmp('tab_info', {}); //See case 9, tab
|
sMsg = sMsg || '';
|
||||||
switch(e.keyCode)
|
|
||||||
{
|
|
||||||
case 13 : //enter
|
|
||||||
$this = databap.getMainElem('#message');
|
|
||||||
var chat_message = $this.val();
|
|
||||||
var bSuccess = true;
|
var bSuccess = true;
|
||||||
if(chat_message.substr(0, 7) == '/join #') joinChan(chat_message.substr(7));
|
|
||||||
else if(chat_message.substr(0, 7) == '/quit #') quitChan(getChanKeyName(chat_message.substr(7)));
|
|
||||||
else if(chat_message == '/help') displayHelp();
|
|
||||||
else if(chat_message.substr(0, 8) == '/invite ') invite($.trim(chat_message.substr(8)), currentChan());
|
|
||||||
else if(chat_message != '' && databap.tmp('sending_msg') == false) //send
|
|
||||||
{
|
|
||||||
if(databap.tmp('sending_msg') == true)
|
if(databap.tmp('sending_msg') == true)
|
||||||
{
|
{
|
||||||
databap.feedback('warning', 'Pas si pressé ! J\'ai pas encore envoyé le dernier message');
|
databap.feedback('warning', 'Pas si pressé ! J\'ai pas encore envoyé le dernier message');
|
||||||
@@ -525,6 +565,11 @@ function add_message(e)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(sMsg!='')
|
||||||
|
{
|
||||||
|
databap.tmp('msg_buffer', $('#message').val());
|
||||||
|
$('#message').val(sMsg);
|
||||||
|
}
|
||||||
databap.tmp('sending_msg', true);
|
databap.tmp('sending_msg', true);
|
||||||
databap.saveForm
|
databap.saveForm
|
||||||
(
|
(
|
||||||
@@ -539,8 +584,25 @@ function add_message(e)
|
|||||||
true,
|
true,
|
||||||
'json'
|
'json'
|
||||||
);
|
);
|
||||||
|
if(sMsg!='') $('#message').val(databap.tmp('msg_buffer'));
|
||||||
}
|
}
|
||||||
}
|
return bSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
function keyController(e)
|
||||||
|
{
|
||||||
|
if(e.keyCode != 9) databap.tmp('tab_info', {}); //See case 9, tab
|
||||||
|
switch(e.keyCode)
|
||||||
|
{
|
||||||
|
case 13 : //enter
|
||||||
|
$this = databap.getMainElem('#message');
|
||||||
|
var chat_message = $this.val();
|
||||||
|
var bSuccess = true;
|
||||||
|
if(chat_message.substr(0, 7) == '/join #') joinChan(chat_message.substr(7));
|
||||||
|
else if(chat_message.substr(0, 7) == '/quit #') quitChan(getChanKeyName(chat_message.substr(7)));
|
||||||
|
else if(chat_message == '/help') displayHelp();
|
||||||
|
else if(chat_message.substr(0, 8) == '/invite ') invite($.trim(chat_message.substr(8)), currentChan());
|
||||||
|
else if(chat_message != '') bSuccess = postMessage();
|
||||||
|
|
||||||
if(bSuccess)
|
if(bSuccess)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -307,3 +307,7 @@ vertical-align 0% -5% -10% -15% -20% -25% -30%
|
|||||||
.fa-c-file-png:before, .fa-c-file-gif:before, .fa-c-file-jpg:before, .fa-c-file-jpeg:before {
|
.fa-c-file-png:before, .fa-c-file-gif:before, .fa-c-file-jpg:before, .fa-c-file-jpeg:before {
|
||||||
content: "\f1c5";
|
content: "\f1c5";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fa-c-image:before {
|
||||||
|
content: "\f03e";
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -663,6 +663,7 @@
|
|||||||
background:$col_none;
|
background:$col_none;
|
||||||
height:100%;
|
height:100%;
|
||||||
padding:5px;
|
padding:5px;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.g_white_transparent {
|
.g_white_transparent {
|
||||||
@@ -814,30 +815,70 @@
|
|||||||
margin-right:5px;
|
margin-right:5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#chat #chat_input {
|
/* Chat - Input */
|
||||||
|
|
||||||
|
#chat {
|
||||||
|
|
||||||
|
#chat_input {
|
||||||
background:$col_main_3;
|
background:$col_main_3;
|
||||||
color:#94BDF9;
|
color:#94BDF9;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
#chat #chat_input .fa {
|
#c1_file {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uploader_box {
|
||||||
|
position:inherit;
|
||||||
|
width:auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#upload_img {
|
||||||
|
cursor:pointer;
|
||||||
|
margin-top:2px;
|
||||||
|
}
|
||||||
|
i.fa#upload_img:hover {
|
||||||
|
color:#EFAB00;
|
||||||
|
}
|
||||||
|
|
||||||
|
#chat_form .uploader_box > * {
|
||||||
|
float:left;
|
||||||
|
padding: 7px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uploader_droparea {
|
||||||
|
background:#D9E5F2;
|
||||||
|
height:100%;
|
||||||
|
top:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uploader_droparea-active {
|
||||||
|
background:#EFAB00;
|
||||||
|
color:white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#chat_input .fa {
|
||||||
color:$col_main_1;
|
color:$col_main_1;
|
||||||
margin-right:3px;
|
margin-right:5px;
|
||||||
margin-left:3px;
|
margin-left:5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#chat #chat_input input#message {
|
#chat_input input#message {
|
||||||
background:$col_main_3;
|
background:$col_main_3;
|
||||||
margin:0;
|
margin:0;
|
||||||
padding:7px 0;
|
|
||||||
border:none;
|
border:none;
|
||||||
min-width:200px;
|
min-width:200px;
|
||||||
|
width:calc(100% - 72px); /* 32 icons width * 2 */
|
||||||
font-size:$size_vbig;
|
font-size:$size_vbig;
|
||||||
|
}
|
||||||
|
|
||||||
|
#chat_input input#message:hover, #chat #chat_input input#message:focus {
|
||||||
|
background-color:transparent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#chat #chat_input input#message:hover, #chat #chat_input input#message:focus {
|
/* Chat - Sidebar */
|
||||||
background-color:transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
#chat #sidebar {
|
#chat #sidebar {
|
||||||
position:absolute;
|
position:absolute;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user