Skip to content

Commit

Permalink
2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-D committed Aug 30, 2016
1 parent d6c6444 commit 919c577
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 73 deletions.
4 changes: 3 additions & 1 deletion dist/langs/ar.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
* ===========================================================
* Author : Abo Mokh ahmed (abomokhahmed)
* Github : https://github.com/abomokhahmed
* Reviewed by : Abdellah Chadidi (chadidi)
* Github : https://github.com/chadidi
*/
jQuery.trumbowyg.langs.ar={_dir:"rtl",viewHTML:"إعرض-HTML",formatting:"تصميم",p:"فقرة",blockquote:"اقتباس",code:"كود",header:"رئيسي",bold:"عريض",italic:"مائل",strikethrough:"مشطوب",underline:"خطّ سفلي",strong:"بارز",em:"تغميق",del:"حذف",unorderedList:"قائمة غير مرتّبة",orderedList:"قائمة مرتّبة",insertImage:"إدخال صورة",insertVideo:"إدخال فيديو",link:"رابط",createLink:"انشاء رابط",unlink:"حذف رابط",justifyLeft:"تصحيح للشمال",justifyCenter:"تصحيح للمركز",justifyRight:"تصحيح لليمين",justifyFull:"تصحيح لكلا الإتّجاهين",horizontalRule:"إدخال خطّ أفقي",fullscreen:"شاشة واسعة",close:"إغلاق",submit:"أرسل",reset:"تهيئة من حديد",required:"إلزامي",description:"وصف",title:"عنوان",text:"نصّ"};
jQuery.trumbowyg.langs.ar={_dir:"rtl",viewHTML:"إعرض-HTML",undo:"تراجع",redo:"إعادة",formatting:"تنسيق",p:"فقرة",blockquote:"اقتباس",code:"كود",header:"رأس",bold:"عريض",italic:"مائل",strikethrough:"مشطوب",underline:"خطّ سفلي",strong:"بارز",em:"تغميق",del:"حذف",superscript:"الأس",subscript:"أس سفلي",unorderedList:"قائمة غير مرتّبة",orderedList:"قائمة مرتّبة",insertImage:"إدراج صورة",insertVideo:"إدراج فيديو",link:"رابط",createLink:"انشاء رابط",unlink:"حذف رابط",justifyLeft:"تصحيح للشمال",justifyCenter:"توسيط",justifyRight:"تصحيح لليمين",justifyFull:"تصحيح لكلا الإتّجاهين",horizontalRule:"إدراج خطّ أفقي",fullscreen:"ملء الشاشة",close:"إغلاق",submit:"إرسال",reset:"إعادة تعيين",required:"إلزامي",description:"وصف",title:"عنوان",text:"نصّ",target:"الهدف"};
35 changes: 27 additions & 8 deletions dist/plugins/base64/trumbowyg.base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@
return typeof FileReader !== 'undefined';
};

var isValidImage = function (type) {
return /^data:image\/[a-z]?/i.test(type);
};

$.extend(true, $.trumbowyg, {
langs: {
// jshint camelcase:false
en: {
base64: 'Image as base64',
file: 'File',
errFileReaderNotSupported: 'FileReader is not supported by your browser.'
errFileReaderNotSupported: 'FileReader is not supported by your browser.',
errInvalidImage: 'Invalid image file.'
},
fr: {
base64: 'Image en base64',
Expand All @@ -32,6 +37,10 @@
zh_cn: {
base64: '图片(Base64编码)',
file: '文件'
},
nl: {
errFileReaderNotSupported: 'Uw browser ondersteunt deze functionaliteit niet.',
errInvalidImage: 'De gekozen afbeelding is ongeldig.'
}
},
// jshint camelcase:true
Expand All @@ -44,17 +53,20 @@
isSupported: isSupported,
fn: function () {
trumbowyg.saveRange();

var file;
trumbowyg.openModalInsert(
var $modal = trumbowyg.openModalInsert(
// Title
trumbowyg.lang.base64,

// Fields
{
file: {
type: 'file',
required: true
required: true,
attributes: {
accept: 'image/*'
}
},
alt: {
label: 'description',
Expand All @@ -66,10 +78,17 @@
function (values) {
var fReader = new FileReader();

fReader.onloadend = function () {
trumbowyg.execCmd('insertImage', fReader.result);
$(['img[src="', fReader.result, '"]:not([alt])'].join(''), trumbowyg.$box).attr('alt', values.alt);
trumbowyg.closeModal();
fReader.onloadend = function (e) {
if (isValidImage(e.target.result)) {
trumbowyg.execCmd('insertImage', fReader.result);
$(['img[src="', fReader.result, '"]:not([alt])'].join(''), trumbowyg.$box).attr('alt', values.alt);
trumbowyg.closeModal();
} else {
trumbowyg.addErrorOnModalField(
$('input[type=file]', $modal),
trumbowyg.lang.errInvalidImage
);
}
};

fReader.readAsDataURL(file);
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/base64/trumbowyg.base64.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/colors/ui/sass/trumbowyg.colors.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Trumbowyg v2.2.0 - A lightweight WYSIWYG editor
* Trumbowyg v2.3.0 - A lightweight WYSIWYG editor
* Colors plugin stylesheet for Trumbowyg editor
* ------------------------
* @link http://alex-d.github.io/Trumbowyg
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/colors/ui/trumbowyg.colors.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Trumbowyg v2.2.0 - A lightweight WYSIWYG editor
* Trumbowyg v2.3.0 - A lightweight WYSIWYG editor
* Colors plugin stylesheet for Trumbowyg editor
* ------------------------
* @link http://alex-d.github.io/Trumbowyg
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/colors/ui/trumbowyg.colors.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 32 additions & 16 deletions dist/plugins/upload/trumbowyg.upload.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/* ===========================================================
* trumbowyg.upload.js v1.1
* trumbowyg.upload.js v1.2
* Upload plugin for Trumbowyg
* http://alex-d.github.com/Trumbowyg
* ===========================================================
* Author : Alexandre Demode (Alex-D)
* Twitter : @AlexandreDemode
* Website : alex-d.fr
* Mod by : Aleksandr-ru
* Twitter : @Aleksandr_ru
* Website : aleksandr.ru
*/

(function ($) {
Expand Down Expand Up @@ -68,6 +71,11 @@
upload: '上传',
file: '文件',
uploadError: '错误'
},
ru: {
upload: 'Загрузка',
file: 'Файл',
uploadError: 'Ошибка'
}
},
// jshint camelcase:true
Expand All @@ -91,7 +99,10 @@
{
file: {
type: 'file',
required: true
required: true,
attributes: {
accept: 'image/*'
}
},
alt: {
label: 'description',
Expand Down Expand Up @@ -138,23 +149,28 @@
}, 200);
},

success: trumbowyg.o.plugins.upload.success || function (data) {
if (!!getDeep(data, trumbowyg.o.plugins.upload.statusPropertyName.split('.'))) {
var url = getDeep(data, trumbowyg.o.plugins.upload.urlPropertyName.split('.'));
trumbowyg.execCmd('insertImage', url);
$('img[src="' + url + '"]:not([alt])', trumbowyg.$box).attr('alt', values.alt);
setTimeout(function () {
trumbowyg.closeModal();
}, 250);
trumbowyg.$c.trigger('tbwuploadsuccess', [trumbowyg, data, url]);
success: function (data) {
if (trumbowyg.o.plugins.upload.success) {
trumbowyg.o.plugins.upload.success(data, trumbowyg, $modal, values);
} else {
trumbowyg.addErrorOnModalField(
$('input[type=file]', $modal),
trumbowyg.lang[data.message]
);
trumbowyg.$c.trigger('tbwuploaderror', [trumbowyg, data]);
if (!!getDeep(data, trumbowyg.o.plugins.upload.statusPropertyName.split('.'))) {
var url = getDeep(data, trumbowyg.o.plugins.upload.urlPropertyName.split('.'));
trumbowyg.execCmd('insertImage', url);
$('img[src="' + url + '"]:not([alt])', trumbowyg.$box).attr('alt', values.alt);
setTimeout(function () {
trumbowyg.closeModal();
}, 250);
trumbowyg.$c.trigger('tbwuploadsuccess', [trumbowyg, data, url]);
} else {
trumbowyg.addErrorOnModalField(
$('input[type=file]', $modal),
trumbowyg.lang[data.message]
);
trumbowyg.$c.trigger('tbwuploaderror', [trumbowyg, data]);
}
}
},

error: trumbowyg.o.plugins.upload.error || function () {
trumbowyg.addErrorOnModalField(
$('input[type=file]', $modal),
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/upload/trumbowyg.upload.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 919c577

Please sign in to comment.