redactor
This commit is contained in:
parent
e15b671787
commit
7a3f493b0e
File diff suppressed because it is too large
Load Diff
@ -1,73 +1,74 @@
|
|||||||
if (!RedactorPlugins) var RedactorPlugins = {};
|
(function($)
|
||||||
|
|
||||||
RedactorPlugins.fontcolor = function()
|
|
||||||
{
|
{
|
||||||
return {
|
$.Redactor.prototype.fontcolor = function()
|
||||||
init: function()
|
{
|
||||||
{
|
return {
|
||||||
var colors = [
|
init: function()
|
||||||
'#ffffff', '#000000', '#eeece1', '#1f497d', '#4f81bd', '#c0504d', '#9bbb59', '#8064a2', '#4bacc6', '#f79646', '#ffff00',
|
|
||||||
'#f2f2f2', '#7f7f7f', '#ddd9c3', '#c6d9f0', '#dbe5f1', '#f2dcdb', '#ebf1dd', '#e5e0ec', '#dbeef3', '#fdeada', '#fff2ca',
|
|
||||||
'#d8d8d8', '#595959', '#c4bd97', '#8db3e2', '#b8cce4', '#e5b9b7', '#d7e3bc', '#ccc1d9', '#b7dde8', '#fbd5b5', '#ffe694',
|
|
||||||
'#bfbfbf', '#3f3f3f', '#938953', '#548dd4', '#95b3d7', '#d99694', '#c3d69b', '#b2a2c7', '#b7dde8', '#fac08f', '#f2c314',
|
|
||||||
'#a5a5a5', '#262626', '#494429', '#17365d', '#366092', '#953734', '#76923c', '#5f497a', '#92cddc', '#e36c09', '#c09100',
|
|
||||||
'#7f7f7f', '#0c0c0c', '#1d1b10', '#0f243e', '#244061', '#632423', '#4f6128', '#3f3151', '#31859b', '#974806', '#7f6000'
|
|
||||||
];
|
|
||||||
|
|
||||||
var buttons = ['fontcolor', 'backcolor'];
|
|
||||||
|
|
||||||
for (var i = 0; i < 2; i++)
|
|
||||||
{
|
{
|
||||||
var name = buttons[i];
|
var colors = [
|
||||||
|
'#ffffff', '#000000', '#eeece1', '#1f497d', '#4f81bd', '#c0504d', '#9bbb59', '#8064a2', '#4bacc6', '#f79646', '#ffff00',
|
||||||
|
'#f2f2f2', '#7f7f7f', '#ddd9c3', '#c6d9f0', '#dbe5f1', '#f2dcdb', '#ebf1dd', '#e5e0ec', '#dbeef3', '#fdeada', '#fff2ca',
|
||||||
|
'#d8d8d8', '#595959', '#c4bd97', '#8db3e2', '#b8cce4', '#e5b9b7', '#d7e3bc', '#ccc1d9', '#b7dde8', '#fbd5b5', '#ffe694',
|
||||||
|
'#bfbfbf', '#3f3f3f', '#938953', '#548dd4', '#95b3d7', '#d99694', '#c3d69b', '#b2a2c7', '#b7dde8', '#fac08f', '#f2c314',
|
||||||
|
'#a5a5a5', '#262626', '#494429', '#17365d', '#366092', '#953734', '#76923c', '#5f497a', '#92cddc', '#e36c09', '#c09100',
|
||||||
|
'#7f7f7f', '#0c0c0c', '#1d1b10', '#0f243e', '#244061', '#632423', '#4f6128', '#3f3151', '#31859b', '#974806', '#7f6000'
|
||||||
|
];
|
||||||
|
|
||||||
var button = this.button.add(name, this.lang.get(name));
|
var buttons = ['fontcolor', 'backcolor'];
|
||||||
var $dropdown = this.button.addDropdown(button);
|
|
||||||
|
|
||||||
$dropdown.width(242);
|
for (var i = 0; i < 2; i++)
|
||||||
this.fontcolor.buildPicker($dropdown, name, colors);
|
{
|
||||||
|
var name = buttons[i];
|
||||||
|
|
||||||
|
var button = this.button.add(name, this.lang.get(name));
|
||||||
|
var $dropdown = this.button.addDropdown(button);
|
||||||
|
|
||||||
|
$dropdown.width(242);
|
||||||
|
this.fontcolor.buildPicker($dropdown, name, colors);
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
buildPicker: function($dropdown, name, colors)
|
||||||
|
{
|
||||||
|
var rule = (name == 'backcolor') ? 'background-color' : 'color';
|
||||||
|
|
||||||
|
var len = colors.length;
|
||||||
|
var self = this;
|
||||||
|
var func = function(e)
|
||||||
|
{
|
||||||
|
e.preventDefault();
|
||||||
|
self.fontcolor.set($(this).data('rule'), $(this).attr('rel'));
|
||||||
|
};
|
||||||
|
|
||||||
|
for (var z = 0; z < len; z++)
|
||||||
|
{
|
||||||
|
var color = colors[z];
|
||||||
|
|
||||||
|
var $swatch = $('<a rel="' + color + '" data-rule="' + rule +'" href="#" style="float: left; font-size: 0; border: 2px solid #fff; padding: 0; margin: 0; width: 22px; height: 22px;"></a>');
|
||||||
|
$swatch.css('background-color', color);
|
||||||
|
$swatch.on('click', func);
|
||||||
|
|
||||||
|
$dropdown.append($swatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
var $elNone = $('<a href="#" style="display: block; clear: both; padding: 5px; font-size: 12px; line-height: 1;"></a>').html(this.lang.get('none'));
|
||||||
|
$elNone.on('click', $.proxy(function(e)
|
||||||
|
{
|
||||||
|
e.preventDefault();
|
||||||
|
this.fontcolor.remove(rule);
|
||||||
|
|
||||||
|
}, this));
|
||||||
|
|
||||||
|
$dropdown.append($elNone);
|
||||||
|
},
|
||||||
|
set: function(rule, type)
|
||||||
|
{
|
||||||
|
this.inline.format('span', 'style', rule + ': ' + type + ';');
|
||||||
|
},
|
||||||
|
remove: function(rule)
|
||||||
|
{
|
||||||
|
this.inline.removeStyleRule(rule);
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
buildPicker: function($dropdown, name, colors)
|
|
||||||
{
|
|
||||||
var rule = (name == 'backcolor') ? 'background-color' : 'color';
|
|
||||||
|
|
||||||
var len = colors.length;
|
|
||||||
var self = this;
|
|
||||||
var func = function(e)
|
|
||||||
{
|
|
||||||
e.preventDefault();
|
|
||||||
self.fontcolor.set($(this).data('rule'), $(this).attr('rel'));
|
|
||||||
};
|
|
||||||
|
|
||||||
for (var z = 0; z < len; z++)
|
|
||||||
{
|
|
||||||
var color = colors[z];
|
|
||||||
|
|
||||||
var $swatch = $('<a rel="' + color + '" data-rule="' + rule +'" href="#" style="float: left; font-size: 0; border: 2px solid #fff; padding: 0; margin: 0; width: 22px; height: 22px;"></a>');
|
|
||||||
$swatch.css('background-color', color);
|
|
||||||
$swatch.on('click', func);
|
|
||||||
|
|
||||||
$dropdown.append($swatch);
|
|
||||||
}
|
|
||||||
|
|
||||||
var $elNone = $('<a href="#" style="display: block; clear: both; padding: 5px; font-size: 12px; line-height: 1;"></a>').html(this.lang.get('none'));
|
|
||||||
$elNone.on('click', $.proxy(function(e)
|
|
||||||
{
|
|
||||||
e.preventDefault();
|
|
||||||
this.fontcolor.remove(rule);
|
|
||||||
|
|
||||||
}, this));
|
|
||||||
|
|
||||||
$dropdown.append($elNone);
|
|
||||||
},
|
|
||||||
set: function(rule, type)
|
|
||||||
{
|
|
||||||
this.inline.format('span', 'style', rule + ': ' + type + ';');
|
|
||||||
},
|
|
||||||
remove: function(rule)
|
|
||||||
{
|
|
||||||
this.inline.removeStyleRule(rule);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
};
|
})(jQuery);
|
@ -1,32 +1,33 @@
|
|||||||
if (!RedactorPlugins) var RedactorPlugins = {};
|
(function($)
|
||||||
|
|
||||||
RedactorPlugins.fontfamily = function()
|
|
||||||
{
|
{
|
||||||
return {
|
$.Redactor.prototype.fontfamily = function()
|
||||||
init: function ()
|
{
|
||||||
{
|
return {
|
||||||
var fonts = [ 'Lato', 'Stylograph','Arial', 'Helvetica', 'Georgia', 'Times New Roman', 'Monospace' ];
|
init: function ()
|
||||||
var that = this;
|
|
||||||
var dropdown = {};
|
|
||||||
|
|
||||||
$.each(fonts, function(i, s)
|
|
||||||
{
|
{
|
||||||
dropdown['s' + i] = { title: s, func: function() { that.fontfamily.set(s); }};
|
var fonts = [ 'Arial', 'Helvetica', 'Georgia', 'Times New Roman', 'Monospace' ];
|
||||||
});
|
var that = this;
|
||||||
|
var dropdown = {};
|
||||||
|
|
||||||
dropdown.remove = { title: 'Remove Font Family', func: that.fontfamily.reset };
|
$.each(fonts, function(i, s)
|
||||||
|
{
|
||||||
|
dropdown['s' + i] = { title: s, func: function() { that.fontfamily.set(s); }};
|
||||||
|
});
|
||||||
|
|
||||||
var button = this.button.add('fontfamily', 'Change Font Family');
|
dropdown.remove = { title: 'Remove Font Family', func: that.fontfamily.reset };
|
||||||
this.button.addDropdown(button, dropdown);
|
|
||||||
|
|
||||||
},
|
var button = this.button.add('fontfamily', 'Change Font Family');
|
||||||
set: function (value)
|
this.button.addDropdown(button, dropdown);
|
||||||
{
|
|
||||||
this.inline.format('span', 'style', 'font-family:' + value + ';');
|
},
|
||||||
},
|
set: function (value)
|
||||||
reset: function()
|
{
|
||||||
{
|
this.inline.format('span', 'style', 'font-family:' + value + ';');
|
||||||
this.inline.removeStyleRule('font-family');
|
},
|
||||||
}
|
reset: function()
|
||||||
|
{
|
||||||
|
this.inline.removeStyleRule('font-family');
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
})(jQuery);
|
@ -1,75 +1,32 @@
|
|||||||
if (!RedactorPlugins) var RedactorPlugins = {};
|
(function($)
|
||||||
|
|
||||||
RedactorPlugins.fontsize = function()
|
|
||||||
{
|
{
|
||||||
return {
|
$.Redactor.prototype.fontsize = function()
|
||||||
init: function()
|
{
|
||||||
{
|
return {
|
||||||
var fonts = [10, 11, 12, 14, 16, 18, 20, 24, 28, 30];
|
init: function()
|
||||||
var that = this;
|
|
||||||
var dropdown = {};
|
|
||||||
|
|
||||||
$.each(fonts, function(i, s)
|
|
||||||
{
|
{
|
||||||
dropdown['s' + i] = { title: s + 'px', func: function() { that.fontsize.set(s); } };
|
var fonts = [10, 11, 12, 14, 16, 18, 20, 24, 28, 30];
|
||||||
});
|
var that = this;
|
||||||
|
var dropdown = {};
|
||||||
|
|
||||||
dropdown.remove = { title: 'Remove Font Size', func: that.fontsize.reset };
|
$.each(fonts, function(i, s)
|
||||||
|
{
|
||||||
|
dropdown['s' + i] = { title: s + 'px', func: function() { that.fontsize.set(s); } };
|
||||||
|
});
|
||||||
|
|
||||||
var button = this.button.add('fontsize', 'Change Font Size');
|
dropdown.remove = { title: 'Remove Font Size', func: that.fontsize.reset };
|
||||||
this.button.addDropdown(button, dropdown);
|
|
||||||
},
|
var button = this.button.add('fontsize', 'Change Font Size');
|
||||||
set: function(size)
|
this.button.addDropdown(button, dropdown);
|
||||||
{
|
},
|
||||||
this.inline.format('span', 'style', 'font-size: ' + size + 'px;');
|
set: function(size)
|
||||||
},
|
{
|
||||||
reset: function()
|
this.inline.format('span', 'style', 'font-size: ' + size + 'px;');
|
||||||
{
|
},
|
||||||
this.inline.removeStyleRule('font-size');
|
reset: function()
|
||||||
}
|
{
|
||||||
|
this.inline.removeStyleRule('font-size');
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
})(jQuery);
|
||||||
|
|
||||||
if (!RedactorPlugins) var RedactorPlugins = {};
|
|
||||||
|
|
||||||
RedactorPlugins.scriptbuttons = function()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
init: function()
|
|
||||||
{
|
|
||||||
var sup = this.button.add('superscript', 'Superscript');
|
|
||||||
var sub = this.button.add('subscript', 'Subscript');
|
|
||||||
|
|
||||||
// make your added buttons as Font Awesome's icon
|
|
||||||
this.button.setAwesome('superscript', 'fa-superscript');
|
|
||||||
this.button.setAwesome('subscript', 'fa-subscript');
|
|
||||||
|
|
||||||
this.button.addCallback(sup, this.scriptbuttons.formatSup);
|
|
||||||
this.button.addCallback(sub, this.scriptbuttons.formatSub);
|
|
||||||
},
|
|
||||||
formatSup: function()
|
|
||||||
{
|
|
||||||
this.inline.format('sup');
|
|
||||||
},
|
|
||||||
formatSub: function()
|
|
||||||
{
|
|
||||||
this.inline.format('sub');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!RedactorPlugins) var RedactorPlugins = {};
|
|
||||||
|
|
||||||
RedactorPlugins.bufferbuttons = function()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
init: function()
|
|
||||||
{
|
|
||||||
var undo = this.button.addFirst('undo', 'Undo');
|
|
||||||
var redo = this.button.addAfter('undo', 'redo', 'Redo');
|
|
||||||
|
|
||||||
this.button.addCallback(undo, this.buffer.undo);
|
|
||||||
this.button.addCallback(redo, this.buffer.redo);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user