mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 22:17:03 +03:00
PreRelease 1.8.3
This commit is contained in:
parent
39566292af
commit
0ea982671b
40 changed files with 712 additions and 370 deletions
|
|
@ -20,58 +20,90 @@
|
|||
{
|
||||
var self = this;
|
||||
|
||||
this.obj = this.createNewObject();
|
||||
this.objForNotification = this.createNewObject();
|
||||
// this.userMedia = window.navigator.getUserMedia || window.navigator.webkitGetUserMedia ||
|
||||
// window.navigator.mozGetUserMedia || window.navigator.msGetUserMedia;
|
||||
//
|
||||
// this.audioContext = window.AudioContext || window.webkitAudioContext;
|
||||
// if (!this.audioContext || !window.Float32Array)
|
||||
// {
|
||||
// this.audioContext = null;
|
||||
// this.userMedia = null;
|
||||
// }
|
||||
|
||||
this.supported = !Globals.bMobileDevice && !Globals.bSafari &&
|
||||
this.obj && '' !== this.obj.canPlayType('audio/mpeg');
|
||||
this.player = this.createNewObject();
|
||||
|
||||
if (this.obj && this.supported)
|
||||
this.supported = !Globals.bMobileDevice && !Globals.bSafari && !!this.player && !!this.player.play;
|
||||
if (this.supported && this.player.canPlayType)
|
||||
{
|
||||
this.objForNotification.src = Links.sound('new-mail.mp3');
|
||||
this.supportedMp3 = '' !== this.player.canPlayType('audio/mpeg;').replace(/no/, '');
|
||||
this.supportedWav = '' !== this.player.canPlayType('audio/wav; codecs="1"').replace(/no/, '');
|
||||
this.supportedOgg = '' !== this.player.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/, '');
|
||||
this.supportedNotification = this.supported && this.supportedMp3;
|
||||
}
|
||||
|
||||
$(this.obj).on('ended error', function () {
|
||||
if (!this.player || (!this.supportedMp3 && !this.supportedOgg && !this.supportedWav))
|
||||
{
|
||||
this.supported = false;
|
||||
this.supportedMp3 = false;
|
||||
this.supportedOgg = false;
|
||||
this.supportedWav = false;
|
||||
this.supportedNotification = false;
|
||||
}
|
||||
|
||||
if (this.supported)
|
||||
{
|
||||
$(this.player).on('ended error', function () {
|
||||
self.stop();
|
||||
});
|
||||
|
||||
Events.sub('audio.api.stop', function () {
|
||||
self.stop();
|
||||
});
|
||||
|
||||
Events.sub('audio.api.play', function (sUrl, sName) {
|
||||
self.playMp3(sUrl, sName);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Audio.prototype.obj = null;
|
||||
Audio.prototype.objForNotification = null;
|
||||
Audio.prototype.player = null;
|
||||
Audio.prototype.notificator = null;
|
||||
|
||||
Audio.prototype.supported = false;
|
||||
Audio.prototype.supportedMp3 = false;
|
||||
Audio.prototype.supportedOgg = false;
|
||||
Audio.prototype.supportedWav = false;
|
||||
Audio.prototype.supportedNotification = false;
|
||||
|
||||
// Audio.prototype.record = function ()
|
||||
// {
|
||||
// this.getUserMedia({audio:true}, function () {
|
||||
// window.console.log(arguments);
|
||||
// }, function(oError) {
|
||||
// window.console.log(arguments);
|
||||
// });
|
||||
// };
|
||||
|
||||
Audio.prototype.createNewObject = function ()
|
||||
{
|
||||
var obj = window.Audio ? new window.Audio() : null;
|
||||
if (obj && obj.canPlayType)
|
||||
var player = window.Audio ? new window.Audio() : null;
|
||||
if (player && player.canPlayType && player.pause && player.play)
|
||||
{
|
||||
obj.preload = 'none';
|
||||
obj.loop = false;
|
||||
obj.autoplay = false;
|
||||
obj.muted = false;
|
||||
player.preload = 'none';
|
||||
player.loop = false;
|
||||
player.autoplay = false;
|
||||
player.muted = false;
|
||||
}
|
||||
|
||||
return obj;
|
||||
return player;
|
||||
};
|
||||
|
||||
Audio.prototype.paused = function ()
|
||||
{
|
||||
return this.supported ? !!this.obj.paused : true;
|
||||
return this.supported ? !!this.player.paused : true;
|
||||
};
|
||||
|
||||
Audio.prototype.stop = function ()
|
||||
{
|
||||
if (this.supported && this.obj.pause)
|
||||
if (this.supported && this.player.pause)
|
||||
{
|
||||
this.obj.pause();
|
||||
this.player.pause();
|
||||
}
|
||||
|
||||
Events.pub('audio.stop');
|
||||
|
|
@ -79,33 +111,73 @@
|
|||
|
||||
Audio.prototype.pause = Audio.prototype.stop;
|
||||
|
||||
Audio.prototype.clearName = function (sName, sExt)
|
||||
{
|
||||
sExt = sExt || '';
|
||||
sName = Utils.isUnd(sName) ? '' : Utils.trim(sName);
|
||||
if (sExt && '.' + sExt === sName.toLowerCase().substr((sExt.length + 1) * -1))
|
||||
{
|
||||
sName = Utils.trim(sName.substr(0, sName.length - 4));
|
||||
}
|
||||
|
||||
if ('' === sName)
|
||||
{
|
||||
sName = 'audio';
|
||||
}
|
||||
|
||||
return sName;
|
||||
};
|
||||
|
||||
Audio.prototype.playMp3 = function (sUrl, sName)
|
||||
{
|
||||
if (this.supported && this.obj.play)
|
||||
if (this.supported && this.supportedMp3)
|
||||
{
|
||||
this.obj.src = sUrl;
|
||||
this.obj.play();
|
||||
this.player.src = sUrl;
|
||||
this.player.play();
|
||||
|
||||
sName = Utils.isUnd(sName) ? '' : Utils.trim(sName);
|
||||
if ('.mp3' === sName.toLowerCase().substr(-4))
|
||||
{
|
||||
sName = Utils.trim(sName.substr(0, sName.length - 4));
|
||||
}
|
||||
Events.pub('audio.start', [this.clearName(sName, 'mp3'), 'mp3']);
|
||||
}
|
||||
};
|
||||
|
||||
if ('' === sName)
|
||||
{
|
||||
sName = 'audio';
|
||||
}
|
||||
Audio.prototype.playOgg = function (sUrl, sName)
|
||||
{
|
||||
if (this.supported && this.supportedOgg)
|
||||
{
|
||||
this.player.src = sUrl;
|
||||
this.player.play();
|
||||
|
||||
Events.pub('audio.start', [sName]);
|
||||
sName = this.clearName(sName, 'oga');
|
||||
sName = this.clearName(sName, 'ogg');
|
||||
|
||||
Events.pub('audio.start', [sName, 'ogg']);
|
||||
}
|
||||
};
|
||||
|
||||
Audio.prototype.playWav = function (sUrl, sName)
|
||||
{
|
||||
if (this.supported && this.supportedWav)
|
||||
{
|
||||
this.player.src = sUrl;
|
||||
this.player.play();
|
||||
|
||||
Events.pub('audio.start', [this.clearName(sName, 'wav'), 'wav']);
|
||||
}
|
||||
};
|
||||
|
||||
Audio.prototype.playNotification = function ()
|
||||
{
|
||||
if (this.supported && this.objForNotification.play)
|
||||
if (this.supported && this.supportedMp3)
|
||||
{
|
||||
this.objForNotification.play();
|
||||
if (!this.notificator)
|
||||
{
|
||||
this.notificator = this.createNewObject();
|
||||
this.notificator.src = Links.sound('new-mail.mp3');
|
||||
}
|
||||
|
||||
if (this.notificator && this.notificator.play)
|
||||
{
|
||||
this.notificator.play();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,26 @@
|
|||
|
||||
var Enums = {};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.FileType = {
|
||||
'Unknown': 'unknown',
|
||||
'Text': 'text',
|
||||
'Html': 'html',
|
||||
'Code': 'code',
|
||||
'Eml': 'eml',
|
||||
'WordText': 'word-text',
|
||||
'Pdf': 'pdf',
|
||||
'Image': 'image',
|
||||
'Audio': 'audio',
|
||||
'Video': 'video',
|
||||
'Sheet': 'sheet',
|
||||
'Presentation': 'presentation',
|
||||
'Certificate': 'certificate',
|
||||
'Archive': 'archive'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
Globals.$win = $(window);
|
||||
Globals.$doc = $(window.document);
|
||||
Globals.$html = $('html');
|
||||
Globals.$body = $('body');
|
||||
Globals.$div = $('<div></div>');
|
||||
|
||||
Globals.$win.__sizes = [0, 0];
|
||||
|
|
@ -268,7 +269,7 @@
|
|||
});
|
||||
|
||||
Globals.keyScopeReal.subscribe(function (sValue) {
|
||||
// window.console.log('keyScope=' + sValue); // TODO
|
||||
// window.console.log('keyScope=' + sValue); // DEBUG
|
||||
key.setScope(sValue);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@
|
|||
|
||||
this.resize = _.throttle(_.bind(this.resize, this), 100);
|
||||
|
||||
this.__inited = false;
|
||||
this.__initedData = null;
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
|
|
@ -190,7 +193,7 @@
|
|||
|
||||
HtmlEditor.prototype.setHtml = function (sHtml, bFocus)
|
||||
{
|
||||
if (this.editor)
|
||||
if (this.editor && this.__inited)
|
||||
{
|
||||
this.modeToggle(true);
|
||||
|
||||
|
|
@ -203,11 +206,15 @@
|
|||
this.focus();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.__initedData = [true, sHtml, bFocus];
|
||||
}
|
||||
};
|
||||
|
||||
HtmlEditor.prototype.setPlain = function (sPlain, bFocus)
|
||||
{
|
||||
if (this.editor)
|
||||
if (this.editor && this.__inited)
|
||||
{
|
||||
this.modeToggle(false);
|
||||
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain)
|
||||
|
|
@ -226,6 +233,10 @@
|
|||
this.focus();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.__initedData = [false, sPlain, bFocus];
|
||||
}
|
||||
};
|
||||
|
||||
HtmlEditor.prototype.init = function ()
|
||||
|
|
@ -322,7 +333,20 @@
|
|||
|
||||
self.fOnReady();
|
||||
self.__resizable = true;
|
||||
self.__inited = true;
|
||||
self.resize();
|
||||
|
||||
if (self.__initedData)
|
||||
{
|
||||
if (self.__initedData[0])
|
||||
{
|
||||
self.setHtml(self.__initedData[1], self.__initedData[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.setPlain(self.__initedData[1], self.__initedData[2]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -435,7 +435,7 @@
|
|||
};
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
* @return {boolean}
|
||||
*/
|
||||
Selector.prototype.autoSelect = function ()
|
||||
{
|
||||
|
|
@ -452,7 +452,7 @@
|
|||
|
||||
/**
|
||||
* @param {Object} oItem
|
||||
* @returns {string}
|
||||
* @return {string}
|
||||
*/
|
||||
Selector.prototype.getItemUid = function (oItem)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@
|
|||
/**
|
||||
* @param {string} sMailToUrl
|
||||
* @param {Function} PopupComposeVoreModel
|
||||
* @returns {boolean}
|
||||
* @return {boolean}
|
||||
*/
|
||||
Utils.mailToHelper = function (sMailToUrl, PopupComposeVoreModel)
|
||||
{
|
||||
|
|
@ -598,7 +598,7 @@
|
|||
* @param {string} sTheme
|
||||
* @return {string}
|
||||
*/
|
||||
Utils.convertThemeName = function (sTheme)
|
||||
Utils.convertThemeName = _.memoize(function (sTheme)
|
||||
{
|
||||
if ('@custom' === sTheme.substr(-7))
|
||||
{
|
||||
|
|
@ -606,7 +606,7 @@
|
|||
}
|
||||
|
||||
return Utils.trim(sTheme.replace(/[^a-zA-Z0-9]+/g, ' ').replace(/([A-Z])/g, ' $1').replace(/[\s]+/g, ' '));
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
|
|
@ -822,40 +822,6 @@
|
|||
|
||||
sText = '',
|
||||
|
||||
splitPlainText = function (sText)
|
||||
{
|
||||
var
|
||||
iLen = 100,
|
||||
sPrefix = '',
|
||||
sSubText = '',
|
||||
sResult = sText,
|
||||
iSpacePos = 0,
|
||||
iNewLinePos = 0
|
||||
;
|
||||
|
||||
while (sResult.length > iLen)
|
||||
{
|
||||
sSubText = sResult.substring(0, iLen);
|
||||
iSpacePos = sSubText.lastIndexOf(' ');
|
||||
iNewLinePos = sSubText.lastIndexOf('\n');
|
||||
|
||||
if (-1 !== iNewLinePos)
|
||||
{
|
||||
iSpacePos = iNewLinePos;
|
||||
}
|
||||
|
||||
if (-1 === iSpacePos)
|
||||
{
|
||||
iSpacePos = iLen;
|
||||
}
|
||||
|
||||
sPrefix += sSubText.substring(0, iSpacePos) + '\n';
|
||||
sResult = sResult.substring(iSpacePos + 1);
|
||||
}
|
||||
|
||||
return sPrefix + sResult;
|
||||
},
|
||||
|
||||
convertBlockquote = function (sText) {
|
||||
sText = Utils.trim(sText);
|
||||
sText = '> ' + sText.replace(/\n/gm, '\n> ');
|
||||
|
|
@ -929,7 +895,7 @@
|
|||
.replace(/&/gi, '&')
|
||||
;
|
||||
|
||||
sText = splitPlainText(Utils.trim(sText));
|
||||
sText = Utils.splitPlainText(Utils.trim(sText));
|
||||
|
||||
iPos = 0;
|
||||
iLimit = 800;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue