';
>>> var w = 300;var h = 200;
>>> var top = ($(window).height()-200)/2+$(document).scrollTop();
>>> var left = ($(window).width()-300)/2;
>>> if ($("#"+d.id+"_about").length === 0){
>>> $("body").append("
about
");
>>> $("#"+d.id+"_about").html(html);
--- }else{
--- $("#"+d.id+"_about").css("top",top);
--- $("#"+d.id+"_about").css("left",left);
}
>>> $("#"+d.id+"_about").focus();
>>> $("#"+d.id+"_about").fadeIn(1000);
>>> }else{
>>> var arg = (undefined===arg1)?null:arg1;
>>> d.idoc.execCommand(cmd, false, arg);
}
//Setting the changed text to textearea
>>> if($("#"+d.id).is(":visible")===false){
>>> $("#"+d.id).val(this.get_html());
// Register change
--- if(urm){urm.add(this.get_html());}
--- if(undefined!==d.change){d.change();}
}
};
//=====================================================================//
// METHOD: cmd //
//========================== END OF METHOD ============================//
//========================= START OF METHOD ===========================//
// METHOD: get_text //
//=====================================================================//
/**
* Returns the text without tags of the HtmlBox
* @since 1.2
* @return this
*/
>>> this.get_text = function(){
// Is textbox visible?
--- if($("#"+d.id).is(":visible")){ return $("#"+d.id).val(); }
// Iframe is visible
var text;
--- if($.browser.msie){
--- text = d.iframe.contentWindow.document.body.innerText;
--- }else{
--- var html = d.iframe.contentWindow.document.body.ownerDocument.createRange();
--- html.selectNodeContents(d.iframe.contentWindow.document.body);
--- text = html;
}
--- return text;
};
//=====================================================================//
// METHOD: get_text //
//========================== END OF METHOD ============================//
//========================= START OF METHOD ===========================//
// METHOD: set_text //
//=====================================================================//
/**
* Sets the text as a content of the HtmlBox
* @since 1.2
* @return this
*/
>>> this.set_text = function(txt){
--- var text = (undefined===txt)?"":txt;
--- if(text=="" && $.browser.safari){text = " ";}// Bug in Chrome and Safari
// Is textarea visible? Writing to it.
--- if($("#"+d.id).is(":visible")){
--- $("#"+d.id).val(text);
--- }else{
// Textarea not visible. write to iframe
--- if($.browser.mozilla||$.browser.safari){
//if($.trim(text)===""){text=" ";}
--- d.idoc.open('text/html', 'replace'); d.idoc.write(text); d.idoc.close();
--- }else{
--- d.idoc.body.innerHTML = "";
--- if(text!==""){d.idoc.write(text);}
}
--- style(); // Setting the CSS style for the iframe
--- d.idoc.body.contentEditable = true;
}
--- if(urm){urm.add(this.get_html());}
--- if(undefined!==d.change){d.change();}
--- return this;
};
//=====================================================================//
// METHOD: set_text //
//========================== END OF METHOD ============================//
//========================= START OF METHOD ===========================//
// METHOD: get_html //
//=====================================================================//
/**
* Returns the (X)HTML content of the HtmlBox
* @return this
*/
>>> this.get_html = function(){
var html;
>>> if($("#"+d.id).is(":visible")){
--- html = $("#"+d.id).val();
>>> }else{
>>> html = d.iframe.contentWindow.document.body.innerHTML;
}
--- if(typeof getXHTML === 'function'){ return getXHTML(html); }else{return html;}
};
//=====================================================================//
// METHOD: get_html //
//========================== END OF METHOD ============================//
//========================= START OF METHOD ===========================//
// METHOD: change //
//=====================================================================//
/**
* Specifies a function to be executed on text change in the HtmlBox
*/
>>> this.change=function(fn){d.change=fn;return this;};
//=====================================================================//
// METHOD: change //
//========================== END OF METHOD ============================//
//========================= START OF METHOD ===========================//
// METHOD: remove //
//=====================================================================//
/**
* Removes the HtmlBox instance from the DOM and the globalspace
*/
>>> this.remove = function(){
--- global_hb[d.id]=undefined;
--- $("#"+d.id+"_wrap").remove();
--- if ($("#"+d.id+"_about").length === 0){$("#"+d.id+"_about").remove();}
};
//=====================================================================//
// METHOD: remove //
//========================== END OF METHOD ============================//
//========================= START OF METHOD ===========================//
// METHOD: post //
//=====================================================================//
/**
* Posts the form data to the specified URL using Ajax
* @param String the URL to post to
* @param String the text to be posted, default the (X)HTML text
* @return this;
*/
>>> this.post=function(url,data){
--- if(undefined===data){data=this.get_html();} data=(d.id+"="+data);
--- $.ajax({type: "POST", data: data,url: url,dataType: "html",error:d.error,success:d.success});
};
//=====================================================================//
// METHOD: post //
//========================== END OF METHOD ============================//
//========================= START OF METHOD ===========================//
// METHOD: get //
//=====================================================================//
/**
* Gets the form data to the specified URL using Ajax
* @param String the URL to get to
* @param String the text to be posted, default the (X)HTML text
* @return this;
*/
>>> this.get=function(url,data){
--- if(undefined===data){data=this.get_html();} data=(d.id+"="+data);
--- $.ajax({type: "GET", data: data,url: url,dataType: "html",error:d.error,success:d.success});
};
//=====================================================================//
// METHOD: get //
//========================== END OF METHOD ============================//
//========================= START OF METHOD ===========================//
// METHOD: success //
//=====================================================================//
/**
* Specifies what is to be executed on successful Ajax POST or GET
*/
>>> this.success=function(fn){d.success=fn;return this;};
//=====================================================================//
// METHOD: success //
//========================== END OF METHOD ============================//
//========================= START OF METHOD ===========================//
// METHOD: error //
//=====================================================================//
/**
* Specifies what is to be executed on error Ajax POST or GET
* @return {HtmlBox} the instance of this HtmlBox
*/
>>> this.error=function(fn){d.error=fn;return this;};
//=====================================================================//
// METHOD: error //
//========================== END OF METHOD ============================//
// -------------- END: PUBLIC METHODS ------------------//
>>> this._init(false);
>>> return this;
};
})(jQuery);
//===========================================================================//
// CLASS: HtmlBox //
//============================== END OF CLASS ===============================//
=== Inline script in: http://localhost/subjectPrograms/ClientSideOnly/htmledit/demo_full.html ===
>>> $("#ha").css("height","100%").css("width","100%").htmlbox({
toolbars:[
[
// Cut, Copy, Paste
"separator","cut","copy","paste",
// Undo, Redo
"separator","undo","redo",
// Bold, Italic, Underline, Strikethrough, Sup, Sub
"separator","bold","italic","underline","strike","sup","sub",
// Left, Right, Center, Justify
"separator","justify","left","center","right",
// Ordered List, Unordered List, Indent, Outdent
"separator","ol","ul","indent","outdent",
// Hyperlink, Remove Hyperlink, Image
"separator","link","unlink","image"
],
[// Show code
"separator","code",
// Formats, Font size, Font family, Font color, Font, Background
"separator","formats","fontsize","fontfamily",
"separator","fontcolor","highlight",
],
[
//Strip tags
"separator","removeformat","striptags","hr","paragraph",
// Styles, Source code syntax buttons
"separator","quote","styles","syntax"
]
],
skin:"blue"
});
Total lines (including un-executable): 881
Total executable lines: 335
Covered lines: 200
Coverage: ~60%
Errors:0 errors/warningsh in the script