Changeset 548
- Timestamp:
- 08/07/06 13:23:07 (7 years ago)
- Location:
- branches/mokhet
- Files:
-
- 2 modified
-
examples/on_demand.php (modified) (3 diffs)
-
htmlarea.js (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/mokhet/examples/on_demand.php
r545 r548 1 1 <?php 2 $content1 = array_key_exists('ta1', $_POST) ? $_POST['ta1']: '<p>Content ONE here</p>';3 $content2 = array_key_exists('ta2', $_POST) ? $_POST['ta2']: '<p>Content TWO here</p>';2 $content1 = array_key_exists('ta1', $_POST) ? stripslashes($_POST['ta1']) : '<p>Content ONE here</p>'; 3 $content2 = array_key_exists('ta2', $_POST) ? stripslashes($_POST['ta2']) : '<p>Content TWO here</p>'; 4 4 // Entitize contents 5 5 // Please referer to http://xinha.python-hosting.com/wiki/Entize … … 143 143 padding:2px; 144 144 } 145 #resultcontent 145 #resultcontent, .fromPOST 146 146 { 147 147 border:1px solid black; … … 212 212 213 213 </form> 214 <div id="resultcontent"></div> 214 <div id="resultcontent"> 215 <?php 216 if ( array_key_exists('ta1', $_POST) ) 217 { 218 echo '<div class="fromPOST">'.stripslashes($_POST['ta1']).'</div>'; 219 } 220 if ( array_key_exists('ta2', $_POST) ) 221 { 222 echo '<div class="fromPOST">'.stripslashes($_POST['ta2']).'</div>'; 223 } 224 ?> 225 </div> 215 226 </body> 216 227 </html> -
branches/mokhet/htmlarea.js
r546 r548 169 169 this.toFree = []; 170 170 this._notifyListeners = {}; 171 this.freeLater(this, '_notifyListeners');172 171 173 172 // Panels … … 205 204 panels[i].div = panels[i].container; // legacy 206 205 panels[i].container.className = 'panels ' + i; 207 this.freeLater(panels[i], 'container'); 208 this.freeLater(panels[i], 'div'); 206 this.freeLater(panels[i], ['container', 'div']); 209 207 } 210 208 // finally store the variable 211 209 this._panels = panels; 212 210 213 this.freeLater(this, '_textArea');211 this.freeLater(this, ['_textArea', '_notifyListeners']); 214 212 } 215 213 } … … 881 879 toolbar.unselectable = "1"; 882 880 883 this.freeLater(this, '_toolBar'); 884 this.freeLater(this, '_toolbar'); 881 this.freeLater(this, ['_toolBar', '_toolbar']); 885 882 886 883 var tb_row = null; … … 1065 1062 }; 1066 1063 1067 editor.freeLater(obj); 1064 // editor.freeLater(obj); 1065 editor.freeLater(obj, ['element', 'state']); 1068 1066 1069 1067 tb_objects[txt] = obj; … … 1126 1124 }; 1127 1125 1128 editor.freeLater(obj); 1126 // editor.freeLater(obj); 1127 editor.freeLater(obj, ['element', 'state']); 1129 1128 1130 1129 tb_objects[txt] = obj; … … 1137 1136 el = document.createElement("a"); 1138 1137 el.style.display = 'block'; 1139 el.href = ' javascript:void(0)';1138 el.href = '#'; 1140 1139 el.style.textDecoration = 'none'; 1141 1140 el.title = btn[0]; … … 1155 1154 context : btn[4] || null // enabled in a certain context? 1156 1155 }; 1157 editor.freeLater(el); 1158 editor.freeLater(obj); 1156 // editor.freeLater(el); 1157 // editor.freeLater(obj); 1158 editor.freeLater(obj, ['element', 'cmd', 'state', 'imgel', 'swapImage']); 1159 1159 1160 1160 tb_objects[txt] = obj; … … 1162 1162 // prevent drag&drop of the icon to content area 1163 1163 el.ondrag = function() { return false; }; 1164 editor.freeLater(el, 'ondrag'); 1164 1165 1165 1166 // handlers to emulate nice flat toolbar buttons … … 1182 1183 HTMLArea._addClass(el, "buttonActive"); 1183 1184 HTMLArea._removeClass(el, "buttonPressed"); 1184 HTMLArea.Events.stop(ev);1185 }1185 } 1186 HTMLArea.Events.stop(ev); 1186 1187 } 1187 1188 // when clicked, do the following: … … 1197 1198 } 1198 1199 obj.cmd(editor, obj.name, obj); 1199 HTMLArea.Events.stop(ev);1200 }1200 } 1201 HTMLArea.Events.stop(ev); 1201 1202 } 1202 1203 HTMLArea.Events.add(el, 'mouseout', el_onmout); … … 1387 1388 statusbar.className = "statusBar"; 1388 1389 this._statusBar = statusbar; 1389 this.freeLater(this, '_statusBar');1390 1390 1391 1391 // statusbar.appendChild(document.createTextNode(HTMLArea._lc("Path") + ": ")); … … 1395 1395 div.innerHTML = HTMLArea._lc("Path") + ": "; 1396 1396 this._statusBarTree = div; 1397 this.freeLater(this, '_statusBarTree');1398 1397 this._statusBar.appendChild(div); 1399 1398 … … 1402 1401 div.style.display = "none"; 1403 1402 this._statusBarTextMode = div; 1404 this.freeLater(this, '_statusBarTextMode');1403 this.freeLater(this, ['_statusBar', '_statusBarTree', '_statusBarTextMode']); 1405 1404 this._statusBar.appendChild(div); 1406 1405 … … 1567 1566 var htmlarea = this._framework.table; 1568 1567 this._htmlArea = htmlarea; 1569 this.freeLater(this, '_htmlArea');1570 1568 htmlarea.className = "htmlarea"; 1571 1569 … … 1579 1577 this._iframe = iframe; 1580 1578 this._iframe.className = 'xinha_iframe'; 1581 this.freeLater(this, '_iframe');1579 this.freeLater(this, ['_htmlArea', '_iframe']); 1582 1580 1583 1581 // creates & appends the status bar … … 1601 1599 function form_onsubmit() 1602 1600 { 1603 editor._textArea.value = editor.outwardHtml(editor.getHTML()); 1601 if ( !editor.isSubmited ) 1602 { 1603 // flag to prevent the editor to update original content onDispose if the submit is already done 1604 editor.isSubmited = true; 1605 editor._textArea.value = editor.outwardHtml(editor.getHTML()); 1606 } 1604 1607 return true; 1605 1608 } 1606 1609 HTMLArea.Events.add(textarea.form, 'submit', form_onsubmit, 'prepend'); 1607 1610 1611 // onDispose get the HTMLArea content and update original textarea. 1612 editor.notifyOn('dispose', form_onsubmit); 1613 1614 // update the original form.submit() function. See ticket #823 1615 if ( !textarea.form.$XINHA_submit ) 1616 { 1617 textarea.form.$XINHA_submit = textarea.form.submit; 1618 textarea.form.submit = function() 1619 { 1620 for ( var i = this.elements.length; i--; ) 1621 { 1622 var element = this.elements[i]; 1623 if ( element.type == 'textarea' ) 1624 { 1625 for ( var a = __htmlareas.length; a--; ) 1626 { 1627 var editor = __htmlareas[a]; 1628 if ( editor && editor._textArea == element ) 1629 { 1630 // element.value = editor.outwardHtml(editor.getHTML()); 1631 editor.notifyOf('dispose', editor.config.onDisposeRemoveUI); 1632 } 1633 } 1634 } 1635 } 1636 this.$XINHA_submit(); 1637 }; 1638 } 1639 1608 1640 // this variable should already be saved when the editor was generating 1609 1641 var initialTAContent = textarea.value; … … 1756 1788 if ( rPanel.on && rPanel.panels.length && HTMLArea.hasDisplayedChildren(rPanel.div) ) 1757 1789 { 1758 this._htmlArea.style.width = this._htmlArea.offsetWidth + parseInt(this.config.panel_dimensions.right, 10);1790 this._htmlArea.style.width = (this._htmlArea.offsetWidth + parseInt(this.config.panel_dimensions.right, 10)) + 'px'; 1759 1791 } 1760 1792 … … 1762 1794 if ( lPanel.on && lPanel.panels.length && HTMLArea.hasDisplayedChildren(lPanel.div) ) 1763 1795 { 1764 this._htmlArea.style.width = this._htmlArea.offsetWidth + parseInt(this.config.panel_dimensions.left, 10);1796 this._htmlArea.style.width = (this._htmlArea.offsetWidth + parseInt(this.config.panel_dimensions.left, 10)) + 'px'; 1765 1797 } 1766 1798 } … … 2382 2414 2383 2415 // on window resize, resize the editor 2384 HTMLArea.Events.add(window, 'resize', editor.sizeEditor, false, editor); 2416 function win_onresize() { editor.sizeEditor(); } 2417 HTMLArea.Events.add(window, 'resize', win_onresize, false, editor); 2385 2418 2386 2419 editor.notifyOn('dispose', … … 2389 2422 HTMLArea.Events.remove(doc, 'mousedown', editor.activateEditor, editor); 2390 2423 HTMLArea.Events.remove(doc, ["keydown", "keypress", "mousedown", "mouseup", "drag"], listener); 2391 HTMLArea.Events.remove(window, 'resize', editor.sizeEditor, editor);2424 HTMLArea.Events.remove(window, 'resize', win_onresize, editor); 2392 2425 } 2393 2426 ); … … 6468 6501 } 6469 6502 6503 /* 6504 --------------------------------------------------------------------------- 6505 POSITION 6506 --------------------------------------------------------------------------- 6507 */ 6508 6470 6509 // find X position of an element 6471 6510 HTMLArea.findPosX = function(obj) … … 6506 6545 }; 6507 6546 6547 /* 6548 --------------------------------------------------------------------------- 6549 LOADING MESSAGES 6550 --------------------------------------------------------------------------- 6551 */ 6552 6508 6553 HTMLArea.prototype.setLoadingMessage = function(string, context, replace) 6509 6554 { 6510 if ( !this.config.showLoading || !document.getElementById("loading_sub_" + this._textArea.name) )6511 {6512 return;6513 }6514 6555 var elt = document.getElementById("loading_sub_" + this._textArea.name); 6515 elt.innerHTML = HTMLArea._lc(string, context, replace); 6556 if ( this.config.showLoading && elt ) 6557 { 6558 elt.innerHTML = HTMLArea._lc(string, context, replace); 6559 } 6516 6560 }; 6517 6561 6518 6562 HTMLArea.prototype.removeLoadingMessage = function() 6519 6563 { 6520 if ( !this.config.showLoading || !document.getElementById("loading_" + this._textArea.name) ) 6521 { 6522 return ; 6523 } 6524 document.body.removeChild(document.getElementById("loading_" + this._textArea.name)); 6525 }; 6526 6564 var elt = document.getElementById("loading_sub_" + this._textArea.name); 6565 if ( this.config.showLoading && elt ) 6566 { 6567 document.body.removeChild(elt); 6568 } 6569 }; 6570 6571 /* 6572 --------------------------------------------------------------------------- 6573 FREE MEMORY 6574 --------------------------------------------------------------------------- 6575 */ 6576 6577 /** 6578 * Cache a reference obj.prop to be later released from memory 6579 * @param {object} obj The object to free 6580 * @param {string|array} prop The property to release or an array of properties (optional) 6581 * @public 6582 */ 6527 6583 HTMLArea.prototype.freeLater = function(obj,prop) 6528 6584 { 6529 this.toFree.push({o:obj,p:prop}); 6585 // manage multiple properties with an array 6586 if ( prop && typeof prop !== 'string' && prop.length && prop.length > 0 ) 6587 { 6588 for ( var i = prop.length; i--; ) 6589 { 6590 this.toFree.push({o:obj,p:prop[i]}); 6591 } 6592 } 6593 else 6594 { 6595 this.toFree.push({o:obj,p:prop}); 6596 } 6530 6597 }; 6531 6598
