19 include_once($ROOT_PATH.
'wysiwyg_plugin.inc');
46 $this->
_add_button(
'outdent',
'Outdent',
'Decrease Indent',
'false',
'28');
47 $this->
_add_button(
'indent',
'Indent',
'Increase Indent',
'false',
'29');
62 <script type=
"text/javascript">
64 HTMLArea.prototype._changeIndent =
function(direction) {
69 var blockElts =
"|applet|div|embed|fieldset|form|h1|h2|h3|h4|h5|h6|iframe|ilayer|img|object|p|pre|quote|table|textarea|ul|ol|";
70 var sel = this._getSelection();
71 var range = this._createRange(sel);
74 if (direction ==
'right') {
77 this._execCommand(
'indent',
false,
'');
80 var sel = this._getSelection();
81 var range = this._createRange(sel);
83 var parent = range.parentElement();
84 if (parent.tagName.toLowerCase() ==
'p') {
85 parent = parent.parentNode;
87 if (parent.tagName ==
'BLOCKQUOTE') {
88 var subElt = parent.firstChild;
89 while (subElt != null) {
90 newElt = subElt.nextSibling;
92 if (blockElts.indexOf(
'|'+subElt.tagName.toLowerCase()+
'|') != -1) {
93 this._setLeftMargin(direction, subElt);
95 parent.removeChild(subElt);
96 parent.parentNode.insertBefore(subElt, parent);
100 parent.parentNode.removeChild(parent);
105 var tRange = this._doc.selection.createRange()
106 if (tRange.parentElement().tagName.toLowerCase() ==
'p') {
107 tRange.moveToElementText(tRange.parentElement());
109 tRange.moveStart(
'character', -1);
110 tRange.moveEnd(
'character', 1);
111 var parent = this.getParentElement();
112 if (parent.tagName.toLowerCase() ==
'p') {
113 parent = parent.parentNode;
115 var subElt = parent.firstChild;
117 var foundFirst =
false;
118 while (subElt != null) {
119 var nextElt = subElt.nextSibling;
120 if (subElt.tagName) {
121 var nodeRange = tRange.duplicate();
122 nodeRange.moveToElementText(subElt);
124 if (tRange.inRange(nodeRange)) {
125 if (blockElts.indexOf(
'|'+subElt.tagName.toLowerCase()+
'|') != -1) {
126 success = this._setLeftMargin(direction, subElt) || success;
135 this._doc.execCommand(
'outdent',
false,
'');
142 this._doc.execCommand((direction ==
'left') ?
'outdent' :
'indent',
false,
'');
148 HTMLArea.prototype._setLeftMargin =
function(direction, el) {
149 if (el.style.marginLeft ==
"" || el.style.marginLeft ==
"0pt"|| el.style.marginLeft ==
"0px") {
150 if (direction ==
"right") {
151 el.style.marginLeft =
"40px";
157 var result = el.style.marginLeft.match(/(\d)+px/g);
158 var current_indent = parseInt(result[0]);
159 if (direction ==
"right") {
160 new_px = current_indent + 40;
161 }
else if (direction ==
"left") {
162 if (current_indent > 40) {
163 new_px = current_indent - 40;
164 }
else if (current_indent == 40) {
170 el.style.marginLeft = new_px.toString();
190 this._changeIndent(
"left");
193 this._changeIndent(
"right");