Skip to content

Commit

Permalink
Editor area size adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
1602 committed Mar 26, 2010
1 parent 11538b7 commit 94e2529
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 24 deletions.
1 change: 1 addition & 0 deletions editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ a.bb-color {
a.bb-fullscreen {
background:url(images/bb-top.gif) no-repeat center -158px;
display:block;
height: 20px;
}

/* left buttons */
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
Quisque <b>lectus</b> augue, <i>egestas</i> eget <u>consequat</u> faucibus, pharetra eu leo. Quisque libero augue, volutpat gravida lobortis non, accumsan sit amet metus. Phasellus consectetur ante in dolor lobortis gravida.
</p>
<input type="button" onclick="wysiwyg.insert_quote('author', 'originalcontent'); return false" value="Quote" />
<div style="height:500px">
<div style="height:100px">
text
</div>
<div style="position: relative">
Expand Down
40 changes: 31 additions & 9 deletions wysiwyg.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ function Wysiwyg(textarea, options) {
var w = ip.w + dx;
if (options.min_width <= w && w <= options.max_width) {
editor.style.width = w + 'px';
self.iframe.style.width = ip.ew + dx + 'px';
self.tp.style.width = ip.tw + dx + 'px';
self.adjust_editor_area_size();
//self.iframe.style.width = ip.ew + dx + 'px';
//self.tp.style.width = ip.tw + dx + 'px';
//self.controls.style.width = ip.cw + e.clientX - ip.x + 'px';
}
if (options.min_height <= h && h <= options.max_height) {
editor.style.height = h + 'px';
self.iframe.style.height = ip.eh + dy + 'px';
self.tp.style.height = ip.th + dy + 'px';
self.adjust_editor_area_size();
//self.iframe.style.height = ip.eh + dy + 'px';
//self.tp.style.height = ip.th + dy + 'px';
}
}

Expand Down Expand Up @@ -89,7 +91,7 @@ function Wysiwyg(textarea, options) {

// stretch (resizer)
var editor_stretch = $.create_top('div', 'editor-stretch', editor);
editor_stretch.innerHTML = '<a title="растянуть" href="#"><img alt="растянуть" src="images/stretch.gif"/></a>';
editor_stretch.innerHTML = '<a title="растянуть" href="#"><img alt="растянуть" src="/js/editor/images/stretch.gif"/></a>';
resizer(editor_stretch);

// top controls (with logo and rounded corners)
Expand All @@ -102,7 +104,7 @@ function Wysiwyg(textarea, options) {
var hideandshow_div = $.create_top('div', 'hideandshow', editor);
var hideandshow_link = $.create_top('a', false, hideandshow_div);
hideandshow_link.href = "#";
hideandshow_link.innerHTML = '<img title="" alt="" src="/js/editor/images/hide.gif" style="display: none;" /><img title="" alt="" src="/js/editor/images/show.gif" />';
hideandshow_link.innerHTML = '<img title="" alt="show" src="/js/editor/images/hide.gif" style="display: none;" /><img title="" alt="hide" src="/js/editor/images/show.gif" />';
hideandshow_link.onclick = function () {
$.each([
self.controls.style,
Expand All @@ -111,7 +113,7 @@ function Wysiwyg(textarea, options) {
], function (i, s) {
s.display = s.display ? '' : 'none';
});
// todo: resize textarea/iframe
self.adjust_editor_area_size();
return false;
};

Expand Down Expand Up @@ -240,15 +242,16 @@ function Wysiwyg(textarea, options) {
this.options.min_width = new_min_width;
editor.style.width = this.options.min_width + 'px';
}

/*
if (!options.show_media_panel) {
delta += 107;
}
// fix editor width
this.tp.style.width = this.tp.offsetWidth + delta + 'px';
this.iframe.style.width = this.iframe.offsetWidth + delta - 20 + 'px';
this.source.style.width = this.source.offsetWidth + delta - 20 + 'px';
this.source.style.width = this.source.offsetWidth + delta - 20 + 'px'; */
this.adjust_editor_area_size();
this.source.style.display = 'none';
}

Expand Down Expand Up @@ -550,5 +553,24 @@ Wysiwyg.prototype = {
this.text_modified_timeout = setTimeout(function () {
self.update_textarea();
}, 500);
},
adjust_editor_area_size: function () {
var editor_width = this.workspace.firstChild.offsetWidth,
editor_height = this.workspace.firstChild.offsetHeight,
delta_x = this.options.show_media_panel ? 107 + 22 : 22,
// todo: make this working
delta_y = this.controls.style.display === 'none' ? 97: 97,
textplace_width = editor_width - delta_x,
textplace_height = editor_height - delta_y,
edit_area_width = textplace_width - 22,
edit_area_height = textplace_height - 22;

this.tp.style.width = textplace_width + 'px';
this.iframe.style.width = edit_area_width + 'px';
this.source.style.width = edit_area_width + 'px';

this.tp.style.height = textplace_height + 'px';
this.iframe.style.height = edit_area_height + 'px';
this.source.style.height = edit_area_height + 'px';
}
};
22 changes: 8 additions & 14 deletions wysiwyg.plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,9 @@ Wysiwyg.prototype.plugins.fullscreen = function (w) {
function restore_size() {
w.workspace.firstChild.style.width = dim.edw + 'px';
w.workspace.firstChild.style.height = dim.edh + 'px';
w.tp.style.width = dim.tpw + 2 + 'px';
w.tp.style.height = dim.tph + 'px';
w.iframe.style.width = dim.ifw - 18 + 'px';
w.iframe.style.height = dim.ifh + 2 + 'px';
w.adjust_editor_area_size();
}

function fullscreen() {
var bounds = w.$.calc_screen_bounds();
w.workspace.style.width = bounds.w - 60 + 'px';
Expand All @@ -531,12 +528,9 @@ Wysiwyg.prototype.plugins.fullscreen = function (w) {
var dh = w.workspace.offsetHeight - w.workspace.firstChild.offsetHeight - 22;
w.workspace.firstChild.style.width = w.workspace.firstChild.offsetWidth + dw + 'px';
w.workspace.firstChild.style.height = w.workspace.firstChild.offsetHeight + dh + 'px';
w.tp.style.width = w.tp.offsetWidth + dw + 2 + 'px';
w.tp.style.height = w.tp.offsetHeight + dh + 'px';
w.iframe.style.width = w.iframe.offsetWidth + dw - 18 + 'px';
w.iframe.style.height = w.iframe.offsetHeight + dh + 2 + 'px';
w.adjust_editor_area_size();
}

function adjust_size() {
if (!w.fullscreen) {
w.resizer.style.display = '';
Expand All @@ -554,11 +548,11 @@ Wysiwyg.prototype.plugins.fullscreen = function (w) {
fullscreen();
}
}

function scroll() {
window.scrollTo(0, 0);
}

function switch_mode() {
w.fullscreen = !w.fullscreen;
if (w.fullscreen) {
Expand All @@ -569,11 +563,11 @@ Wysiwyg.prototype.plugins.fullscreen = function (w) {
w.$.remove_event(window, 'scroll', scroll);
}
}

this.action = function () {
switch_mode();
adjust_size();
};

this.update = function(){return true};
};

0 comments on commit 94e2529

Please sign in to comment.