gui 에디터 추가
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
(function ($) {
|
||||
'use strict';
|
||||
|
||||
$.extend(true, $.trumbowyg, {
|
||||
langs: {
|
||||
// jshint camelcase:false
|
||||
en: {
|
||||
lineheight: 'Line height',
|
||||
lineheights: {
|
||||
'0.9': 'Small',
|
||||
'normal': 'Regular',
|
||||
'1.5': 'Large',
|
||||
'2.0': 'Extra large'
|
||||
}
|
||||
},
|
||||
fr: {
|
||||
lineheight: 'Hauteur de ligne',
|
||||
lineheights: {
|
||||
'0.9': 'Petit',
|
||||
'normal': 'Regular',
|
||||
'1.5': 'Grand',
|
||||
'2.0': 'Très grand'
|
||||
}
|
||||
},
|
||||
nl: {
|
||||
lineheight: 'Regelhoogte',
|
||||
lineheights: {
|
||||
'0.9': 'Klein',
|
||||
'normal': 'Normaal',
|
||||
'1.5': 'Groot',
|
||||
'2.0': 'Extra groot'
|
||||
}
|
||||
},
|
||||
tr: {
|
||||
lineheight: 'Satır yüksekliği',
|
||||
lineheights: {
|
||||
'0.9': 'Küçük',
|
||||
'normal': 'Normal',
|
||||
'1.5': 'Büyük',
|
||||
'2.0': 'Çok Büyük'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// jshint camelcase:true
|
||||
|
||||
// Add dropdown with font sizes
|
||||
$.extend(true, $.trumbowyg, {
|
||||
plugins: {
|
||||
lineheight: {
|
||||
init: function (trumbowyg) {
|
||||
trumbowyg.addBtnDef('lineheight', {
|
||||
dropdown: buildDropdown(trumbowyg)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Build the dropdown
|
||||
function buildDropdown(trumbowyg) {
|
||||
var dropdown = [];
|
||||
var sizes = ['0.9', 'normal', '1.5', '2.0'];
|
||||
|
||||
$.each(sizes, function(index, size) {
|
||||
trumbowyg.addBtnDef('lineheight_' + size, {
|
||||
text: '<span style="line-height: ' + size + ';">' + trumbowyg.lang.lineheights[size] + '</span>',
|
||||
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);
|
||||
@@ -0,0 +1 @@
|
||||
!function(e){"use strict";function n(n){var i=[],l=["0.9","normal","1.5","2.0"];return e.each(l,function(l,r){n.addBtnDef("lineheight_"+r,{text:'<span style="line-height: '+r+';">'+n.lang.lineheights[r]+"</span>",hasIcon:!1,fn:function(){n.saveRange();var i=n.getRangeText();if(""!==i.replace(/\s/g,""))try{var l=t();e(l).css("lineHeight",r)}catch(a){}}}),i.push("lineheight_"+r)}),i}function t(){var e,n=null;return window.getSelection?(e=window.getSelection(),e.rangeCount&&(n=e.getRangeAt(0).commonAncestorContainer,1!==n.nodeType&&(n=n.parentNode))):(e=document.selection)&&"Control"!==e.type&&(n=e.createRange().parentElement()),n}e.extend(!0,e.trumbowyg,{langs:{en:{lineheight:"Line height",lineheights:{.9:"Small",normal:"Regular",1.5:"Large","2.0":"Extra large"}},fr:{lineheight:"Hauteur de ligne",lineheights:{.9:"Petit",normal:"Regular",1.5:"Grand","2.0":"Très grand"}},nl:{lineheight:"Regelhoogte",lineheights:{.9:"Klein",normal:"Normaal",1.5:"Groot","2.0":"Extra groot"}},tr:{lineheight:"Satır yüksekliği",lineheights:{.9:"Küçük",normal:"Normal",1.5:"Büyük","2.0":"Çok Büyük"}}}}),e.extend(!0,e.trumbowyg,{plugins:{lineheight:{init:function(e){e.addBtnDef("lineheight",{dropdown:n(e)})}}}})}(jQuery);
|
||||
Reference in New Issue
Block a user