Skip to content

Commit

Permalink
updated WysiHat Engine to 0.1.10.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Kreeftmeijer committed Jan 11, 2010
1 parent 0669baa commit 03ec52e
Show file tree
Hide file tree
Showing 68 changed files with 117 additions and 110 deletions.
Binary file added public/images/icons/cancel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icons/text_heading_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icons/text_heading_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icons/text_heading_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icons/text_heading_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icons/text_heading_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icons/text_heading_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/javascripts/wysihat_engine_pack.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions public/stylesheets/wysihat.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ div.editor_toolbar span {
background-image: url('../images/icons/image.png'); }
.editor_toolbar .html {
background-image: url('../images/icons/page_code.png'); }
.editor_toolbar .h1 {
background-image: url('../images/icons/text_heading_1.png'); }
.editor_toolbar .h2 {
background-image: url('../images/icons/text_heading_2.png'); }
.editor_toolbar .h3 {
background-image: url('../images/icons/text_heading_3.png'); }
.editor_toolbar .h4 {
background-image: url('../images/icons/text_heading_4.png'); }
.editor_toolbar .h5 {
background-image: url('../images/icons/text_heading_5.png'); }
.editor_toolbar .h6 {
background-image: url('../images/icons/text_heading_6.png'); }
.editor_toolbar .p {
background-image: url('../images/icons/cancel.png'); }

iframe.editor {
border: 1px solid #999;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
--- !ruby/object:Gem::Specification
name: wysihat-engine
version: !ruby/object:Gem::Version
version: 0.1.9
version: 0.1.10
platform: ruby
authors:
- Jeff Kreeftmeijer
autorequire:
bindir: bin
cert_chain: []

date: 2009-12-22 00:00:00 +01:00
date: 2010-01-11 00:00:00 +01:00
default_executable:
dependencies:
- !ruby/object:Gem::Dependency
Expand Down Expand Up @@ -67,6 +67,7 @@ files:
- generators/wysihat/templates/images/facebox/tr.png
- generators/wysihat/templates/images/icons/arrow_redo.png
- generators/wysihat/templates/images/icons/arrow_undo.png
- generators/wysihat/templates/images/icons/cancel.png
- generators/wysihat/templates/images/icons/exclamation.png
- generators/wysihat/templates/images/icons/image.png
- generators/wysihat/templates/images/icons/link.png
Expand All @@ -75,6 +76,12 @@ files:
- generators/wysihat/templates/images/icons/text_align_left.png
- generators/wysihat/templates/images/icons/text_align_right.png
- generators/wysihat/templates/images/icons/text_bold.png
- generators/wysihat/templates/images/icons/text_heading_1.png
- generators/wysihat/templates/images/icons/text_heading_2.png
- generators/wysihat/templates/images/icons/text_heading_3.png
- generators/wysihat/templates/images/icons/text_heading_4.png
- generators/wysihat/templates/images/icons/text_heading_5.png
- generators/wysihat/templates/images/icons/text_heading_6.png
- generators/wysihat/templates/images/icons/text_italic.png
- generators/wysihat/templates/images/icons/text_list_bullets.png
- generators/wysihat/templates/images/icons/text_list_numbers.png
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions vendor/gems/wysihat-engine-0.1.10/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.10
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ div.editor_toolbar span {
background-image: url('../images/icons/image.png'); }
.editor_toolbar .html {
background-image: url('../images/icons/page_code.png'); }
.editor_toolbar .h1 {
background-image: url('../images/icons/text_heading_1.png'); }
.editor_toolbar .h2 {
background-image: url('../images/icons/text_heading_2.png'); }
.editor_toolbar .h3 {
background-image: url('../images/icons/text_heading_3.png'); }
.editor_toolbar .h4 {
background-image: url('../images/icons/text_heading_4.png'); }
.editor_toolbar .h5 {
background-image: url('../images/icons/text_heading_5.png'); }
.editor_toolbar .h6 {
background-image: url('../images/icons/text_heading_6.png'); }
.editor_toolbar .p {
background-image: url('../images/icons/cancel.png'); }

iframe.editor {
border: 1px solid #999;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -88,29 +88,14 @@ WysiHat.Commands = (function() {
this.execCommand('fontname', false, font);
}

function fontSelected() {
var node = this.selection.getNode();
return Element.getStyle(node, 'fontFamily');
}

function fontSizeSelection(fontSize) {
this.execCommand('fontsize', false, fontSize);
}

function fontSizeSelected() {
var node = this.selection.getNode();
return standardizeFontSize(Element.getStyle(node, 'fontSize'));
}

function colorSelection(color) {
this.execCommand('forecolor', false, color);
}

function colorSelected() {
var node = this.selection.getNode();
return standardizeColor(Element.getStyle(node, 'color'));
}

function backgroundColorSelection(color) {
if(Prototype.Browser.Gecko) {
this.execCommand('hilitecolor', false, color);
Expand All @@ -119,11 +104,6 @@ WysiHat.Commands = (function() {
}
}

function backgroundColorSelected() {
var node = this.selection.getNode();
return standardizeColor(Element.getStyle(node, 'backgroundColor'));
}

function alignSelection(alignment) {
this.execCommand('justify' + alignment);
}
Expand All @@ -150,6 +130,10 @@ WysiHat.Commands = (function() {
return node ? node.tagName.toUpperCase() == 'A' : false;
}

function formatblockSelection(element){
this.execCommand('formatblock', false, element);
}

function insertOrderedList() {
this.execCommand('insertorderedlist', false, null);
}
Expand Down Expand Up @@ -178,7 +162,7 @@ WysiHat.Commands = (function() {

if (Prototype.Browser.IE) this.selection.restore();

var handler = this.commands.get(command)
var handler = this.commands.get(command);
if (handler)
handler.bind(this)(value);
else
Expand All @@ -188,77 +172,22 @@ WysiHat.Commands = (function() {
function queryCommandState(state) {
var document = this.getDocument();

var handler = this.queryCommands.get(state)
var handler = this.queryCommands.get(state);
if (handler)
return handler.bind(this)();
else
return document.queryCommandState(state);
}
var fontSizeNames = $w('xxx-small xx-small x-small small medium large x-large xx-large');
var fontSizePixels = $w('9px 10px 13px 16px 18px 24px 32px 48px');

if (Prototype.Browser.WebKit) {
fontSizeNames.shift();
fontSizeNames.push('-webkit-xxx-large');
}

function standardizeFontSize(fontSize) {
var newSize = fontSizeNames.indexOf(fontSize);
if (newSize >= 0) return newSize;

newSize = fontSizePixels.indexOf(fontSize);
if (newSize >= 0) return newSize;
return parseInt(fontSize);
}

function standardizeColor(color) {
if (!color || color.match(/[0-9a-f]{6}/i)) return color;
var m = color.toLowerCase().match(/^(rgba?|hsla?)\(([\s\.\-,%0-9]+)\)/);
if(m){
var c = m[2].split(/\s*,\s*/), l = c.length, t = m[1];
if((t == "rgb" && l == 3) || (t == "rgba" && l == 4)){
var r = c[0];
if(r.charAt(r.length - 1) == "%"){
var a = c.map(function(x){
return parseFloat(x) * 2.56;
});
if(l == 4){ a[3] = c[3]; }
return _colorFromArray(a);
}
return _colorFromArray(c);
}
if((t == "hsl" && l == 3) || (t == "hsla" && l == 4)){
var H = ((parseFloat(c[0]) % 360) + 360) % 360 / 360,
S = parseFloat(c[1]) / 100,
L = parseFloat(c[2]) / 100,
m2 = L <= 0.5 ? L * (S + 1) : L + S - L * S,
m1 = 2 * L - m2,
a = [_hue2rgb(m1, m2, H + 1 / 3) * 256,
_hue2rgb(m1, m2, H) * 256, _hue2rgb(m1, m2, H - 1 / 3) * 256, 1];
if(l == 4){ a[3] = c[3]; }
return _colorFromArray(a);
}
}
return null; // dojo.Color
}

function _colorFromArray(a) {
var arr = a.slice(0, 3).map(function(x){
var s = parseInt(x).toString(16);
return s.length < 2 ? "0" + s : s;
});
return "#" + arr.join(""); // String
}

function _hue2rgb(m1, m2, h){
if(h < 0){ ++h; }
if(h > 1){ --h; }
var h6 = 6 * h;
if(h6 < 1){ return m1 + (m2 - m1) * h6; }
if(2 * h < 1){ return m2; }
if(3 * h < 2){ return m1 + (m2 - m1) * (2 / 3 - h) * 6; }
return m1;
}
function getSelectedStyles() {
var styles = $H({});
var editor = this;
editor.styleSelectors.each(function(style){
var node = editor.selection.getNode();
styles.set(style.first(), Element.getStyle(node, style.last()));
});
return styles;
}

return {
boldSelection: boldSelection,
Expand All @@ -270,29 +199,35 @@ WysiHat.Commands = (function() {
strikethroughSelection: strikethroughSelection,
blockquoteSelection: blockquoteSelection,
fontSelection: fontSelection,
fontSelected: fontSelected,
fontSizeSelection: fontSizeSelection,
fontSizeSelected: fontSizeSelected,
colorSelection: colorSelection,
colorSelected: colorSelected,
backgroundColorSelection: backgroundColorSelection,
backgroundColorSelected: backgroundColorSelected,
alignSelection: alignSelection,
alignSelected: alignSelected,
linkSelection: linkSelection,
unlinkSelection: unlinkSelection,
linkSelected: linkSelected,
formatblockSelection: formatblockSelection,
insertOrderedList: insertOrderedList,
insertUnorderedList: insertUnorderedList,
insertImage: insertImage,
insertHTML: insertHTML,
execCommand: execCommand,
queryCommandState: queryCommandState,
getSelectedStyles: getSelectedStyles,

commands: $H({}),

queryCommands: $H({
link: linkSelected
}),

styleSelectors: $H({
fontname: 'fontFamily',
fontsize: 'fontSize',
forecolor: 'color',
hilitecolor: 'backgroundColor',
backcolor: 'backgroundColor'
})
};
})();
Expand Down Expand Up @@ -864,7 +799,7 @@ if (typeof Range == 'undefined') {
this.START_TO_END = 1;
this.END_TO_END = 2;
this.END_TO_START = 3;
}
};

Range.CLONE_CONTENTS = 0;
Range.DELETE_CONTENTS = 1;
Expand Down Expand Up @@ -1519,7 +1454,7 @@ if (!window.getSelection) {
this.isCollapsed = true;
this.rangeCount = 0;
this.ranges = [];
}
};

Object.extend(SelectionImpl.prototype, (function() {
function addRange(r) {
Expand Down Expand Up @@ -1988,7 +1923,7 @@ WysiHat.Toolbar = Class.create((function() {
this.observeButtonClick(button, handler);

var handler = this.buttonStateHandler(name, options);
this.observeStateChanges(button, name, handler)
this.observeStateChanges(button, name, handler);
}

function createButtonElement(toolbar, options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ function wysiHatify(tag_id, buttons){
break;
case 'paste':
toolbar.addButton({label : button.gsub('_','-').camelize().capitalize(), handler: function(editor) { return editor.faceboxPaste(editor); }});
case 'h1': case 'h2': case 'h3': case 'h4': case 'h5': case 'h6': case 'p':
toolbar.addButton({label : button.gsub('_','-').camelize().capitalize(), handler: function(editor) { return editor.formatblockSelection(button.toLowerCase()); }});
break;
default:
toolbar.addButton({label : button.gsub('_','-').camelize().capitalize()});
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,29 @@ div.editor_toolbar

.html
background-image: url('../images/icons/page_code.png')



.h1
background-image: url('../images/icons/text_heading_1.png')

.h2
background-image: url('../images/icons/text_heading_2.png')

.h3
background-image: url('../images/icons/text_heading_3.png')

.h4
background-image: url('../images/icons/text_heading_4.png')

.h5
background-image: url('../images/icons/text_heading_5.png')

.h6
background-image: url('../images/icons/text_heading_6.png')

.p
background-image: url('../images/icons/cancel.png')


iframe.editor
border: 1px solid #999
height: 400px
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def manifest
m.file 'images/icons/text_list_numbers.png', 'public/images/icons/text_list_numbers.png'
m.file 'images/icons/text_strikethrough.png', 'public/images/icons/text_strikethrough.png'
m.file 'images/icons/text_underline.png', 'public/images/icons/text_underline.png'
m.file 'images/icons/text_heading_1.png', 'public/images/icons/text_heading_1.png'
m.file 'images/icons/text_heading_2.png', 'public/images/icons/text_heading_2.png'
m.file 'images/icons/text_heading_3.png', 'public/images/icons/text_heading_3.png'
m.file 'images/icons/text_heading_4.png', 'public/images/icons/text_heading_4.png'
m.file 'images/icons/text_heading_5.png', 'public/images/icons/text_heading_5.png'
m.file 'images/icons/text_heading_6.png', 'public/images/icons/text_heading_6.png'
m.file 'images/icons/cancel.png', 'public/images/icons/cancel.png'
end

m.migration_template 'migrations/create_wysihat_files.rb',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@ def wysihat_editor(object_name, method, options = {})
InstanceTag.new(object_name, method, self, options.delete(:object)).to_wysihat_editor_tag(options)
end
end

class InstanceTag #:nodoc:
def to_wysihat_editor_tag(options = {})
options = DEFAULT_TEXT_AREA_OPTIONS.merge(options.stringify_keys)
add_default_name_and_id(options)

size = options.delete("size")
options["cols"], options["rows"] = size.split("x") if size && size.respond_to?(:split)
options["cols"], options["rows"] = size.split("x") if size && size.respond_to?(:split)

if options['buttons'] == nil || options['buttons'] == :all
buttons = [:bold, :italic, :underline, :strikethrough, :justify_left, :justify_center, :justify_right, :insert_ordered_list, :insert_unordered_list, :undo, :redo, :link, :html, :image]
buttons = [:bold, :italic, :underline, :h1, :h2, :h3, :p, :strikethrough, :justify_left, :justify_center, :justify_right, :insert_ordered_list, :insert_unordered_list, :undo, :redo, :link, :html, :image]
else
buttons = options['buttons']
end

javascript = "Event.observe(window, 'load', function() {" <<
"wysiHatify('#{tag_id}', ['#{buttons.join('\', \'')}']);" <<
"});"

content_tag(:script, javascript, :type => 'text/javascript') <<
content_tag(:textarea, html_escape(options.delete('value') || value_before_type_cast(object)), options.merge(:class => 'wysihat_editor'))
end
end

class FormBuilder #:nodoc:
def wysihat_editor(method, options = {})
@template.wysihat_editor(@object_name, method, options)
Expand Down
Loading

0 comments on commit 03ec52e

Please sign in to comment.