2018-06-24 16:07:22 +03:00
|
|
|
|
(function ($) {
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
$.extend(true, $.trumbowyg, {
|
|
|
|
|
langs: {
|
|
|
|
|
// jshint camelcase:false
|
|
|
|
|
en: {
|
|
|
|
|
lineheight: 'Line height',
|
|
|
|
|
lineheights: {
|
2020-05-12 21:47:37 +03:00
|
|
|
|
'0.9': 'Small',
|
2018-06-24 16:07:22 +03:00
|
|
|
|
'normal': 'Regular',
|
2020-05-12 21:47:37 +03:00
|
|
|
|
'1.5': 'Large',
|
|
|
|
|
'2.0': 'Extra large'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
da: {
|
|
|
|
|
lineheight: 'Linjehøjde',
|
|
|
|
|
lineheights: {
|
|
|
|
|
'0.9': 'Lille',
|
|
|
|
|
'normal': 'Normal',
|
|
|
|
|
'1.5': 'Stor',
|
|
|
|
|
'2.0': 'Ekstra stor'
|
2018-06-24 16:07:22 +03:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fr: {
|
|
|
|
|
lineheight: 'Hauteur de ligne',
|
|
|
|
|
lineheights: {
|
2020-05-12 21:47:37 +03:00
|
|
|
|
'0.9': 'Petite',
|
|
|
|
|
'normal': 'Normale',
|
|
|
|
|
'1.5': 'Grande',
|
|
|
|
|
'2.0': 'Très grande'
|
2018-06-24 16:07:22 +03:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
nl: {
|
|
|
|
|
lineheight: 'Regelhoogte',
|
|
|
|
|
lineheights: {
|
2020-05-12 21:47:37 +03:00
|
|
|
|
'0.9': 'Klein',
|
2018-06-24 16:07:22 +03:00
|
|
|
|
'normal': 'Normaal',
|
2020-05-12 21:47:37 +03:00
|
|
|
|
'1.5': 'Groot',
|
|
|
|
|
'2.0': 'Extra groot'
|
2018-06-24 16:07:22 +03:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
tr: {
|
|
|
|
|
lineheight: 'Satır yüksekliği',
|
|
|
|
|
lineheights: {
|
2020-05-12 21:47:37 +03:00
|
|
|
|
'0.9': 'Küçük',
|
2018-06-24 16:07:22 +03:00
|
|
|
|
'normal': 'Normal',
|
2020-05-12 21:47:37 +03:00
|
|
|
|
'1.5': 'Büyük',
|
|
|
|
|
'2.0': 'Çok Büyük'
|
2018-06-24 16:07:22 +03:00
|
|
|
|
}
|
2020-05-12 21:47:37 +03:00
|
|
|
|
},
|
|
|
|
|
zh_tw: {
|
|
|
|
|
lineheight: '文字間距',
|
|
|
|
|
lineheights: {
|
|
|
|
|
'0.9': '小',
|
|
|
|
|
'normal': '正常',
|
|
|
|
|
'1.5': '大',
|
|
|
|
|
'2.0': '特大'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
pt_br: {
|
|
|
|
|
lineheight: 'Altura de linha',
|
|
|
|
|
lineheights: {
|
|
|
|
|
'0.9': 'Pequena',
|
|
|
|
|
'normal': 'Regular',
|
|
|
|
|
'1.5': 'Grande',
|
|
|
|
|
'2.0': 'Extra grande'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
it: {
|
|
|
|
|
lineheight: 'Altezza linea',
|
|
|
|
|
lineheights: {
|
|
|
|
|
'0.9': 'Bassa',
|
|
|
|
|
'normal': 'Normale',
|
|
|
|
|
'1.5': 'Alta',
|
|
|
|
|
'2.0': 'Molto alta'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
ko: {
|
|
|
|
|
lineheight: '줄 간격',
|
|
|
|
|
lineheights: {
|
|
|
|
|
'0.9': '좁게',
|
|
|
|
|
'normal': '보통',
|
|
|
|
|
'1.5': '넓게',
|
|
|
|
|
'2.0': '아주 넓게'
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-06-24 16:07:22 +03:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// jshint camelcase:true
|
|
|
|
|
|
2020-05-12 21:47:37 +03:00
|
|
|
|
var defaultOptions = {
|
|
|
|
|
sizeList: [
|
|
|
|
|
'0.9',
|
|
|
|
|
'normal',
|
|
|
|
|
'1.5',
|
|
|
|
|
'2.0'
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-24 16:07:22 +03:00
|
|
|
|
// Add dropdown with font sizes
|
|
|
|
|
$.extend(true, $.trumbowyg, {
|
|
|
|
|
plugins: {
|
|
|
|
|
lineheight: {
|
|
|
|
|
init: function (trumbowyg) {
|
2020-05-12 21:47:37 +03:00
|
|
|
|
trumbowyg.o.plugins.lineheight = $.extend({},
|
|
|
|
|
defaultOptions,
|
|
|
|
|
trumbowyg.o.plugins.lineheight || {}
|
|
|
|
|
);
|
|
|
|
|
|
2018-06-24 16:07:22 +03:00
|
|
|
|
trumbowyg.addBtnDef('lineheight', {
|
|
|
|
|
dropdown: buildDropdown(trumbowyg)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Build the dropdown
|
|
|
|
|
function buildDropdown(trumbowyg) {
|
|
|
|
|
var dropdown = [];
|
|
|
|
|
|
2020-05-12 21:47:37 +03:00
|
|
|
|
$.each(trumbowyg.o.plugins.lineheight.sizeList, function(index, size) {
|
2018-06-24 16:07:22 +03:00
|
|
|
|
trumbowyg.addBtnDef('lineheight_' + size, {
|
2020-05-12 21:47:37 +03:00
|
|
|
|
text: trumbowyg.lang.lineheights[size] || size,
|
2018-06-24 16:07:22 +03:00
|
|
|
|
hasIcon: false,
|
|
|
|
|
fn: function(){
|
|
|
|
|
trumbowyg.saveRange();
|
|
|
|
|
var text = trumbowyg.getRangeText();
|
|
|
|
|
if (text.replace(/\s/g, '') !== '') {
|
|
|
|
|
try {
|
|
|
|
|
var parent = getSelectionParentElement();
|
|
|
|
|
$(parent).css('lineHeight', size);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
dropdown.push('lineheight_' + size);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return dropdown;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get the selection's parent
|
|
|
|
|
function getSelectionParentElement() {
|
|
|
|
|
var parentEl = null,
|
|
|
|
|
selection;
|
|
|
|
|
if (window.getSelection) {
|
|
|
|
|
selection = window.getSelection();
|
|
|
|
|
if (selection.rangeCount) {
|
|
|
|
|
parentEl = selection.getRangeAt(0).commonAncestorContainer;
|
|
|
|
|
if (parentEl.nodeType !== 1) {
|
|
|
|
|
parentEl = parentEl.parentNode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if ((selection = document.selection) && selection.type !== 'Control') {
|
|
|
|
|
parentEl = selection.createRange().parentElement();
|
|
|
|
|
}
|
|
|
|
|
return parentEl;
|
|
|
|
|
}
|
|
|
|
|
})(jQuery);
|