diff --git a/package.json b/package.json index 0b2a4bb..10b03fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@a2nt/ss-bootstrap-ui-webpack-boilerplate", - "version": "1.1.0", + "version": "1.1.1", "author": "Tony Air ", "license": "MIT", "description": "This UI Kit allows you to build Bootstrap 4 webapp with some extra UI features. It's easy to extend and easy to convert HTML templates to CMS templates.", @@ -124,8 +124,7 @@ "block-no-empty": null, "color-no-invalid-hex": true, "comment-empty-line-before": [ - "always", - { + "always", { "ignore": [ "stylelint-commands", "after-comment" @@ -134,8 +133,7 @@ ], "declaration-colon-space-after": "always", "indentation": [ - 4, - { + 4, { "except": [ "value" ] @@ -143,8 +141,7 @@ ], "max-empty-lines": 2, "rule-empty-line-before": [ - "always", - { + "always", { "except": [ "first-nested" ], diff --git a/src/js/_components/_ui.form.jqte.js b/src/js/_components/_ui.form.jqte.js index 1bbb4ba..2bc65bf 100755 --- a/src/js/_components/_ui.form.jqte.js +++ b/src/js/_components/_ui.form.jqte.js @@ -6,7 +6,10 @@ import Events from '../_events'; import Spinner from '../_components/_ui.spinner'; import FormValidateField from "./_ui.form.validate.field"; -import '../../thirdparty/jquery-te/jquery-te.js'; + +import '../../thirdparty/jQuery-TE_v.1.4.0/jquery-te-1.4.0.css'; +import '../../thirdparty/jQuery-TE_v.1.4.0/uncompressed/jquery-te-1.4.0.js'; + const JqteUI = (($) => { diff --git a/src/thirdparty/jQuery-TE_v.1.4.0/demo/demo.css b/src/thirdparty/jQuery-TE_v.1.4.0/demo/demo.css new file mode 100644 index 0000000..5462453 --- /dev/null +++ b/src/thirdparty/jQuery-TE_v.1.4.0/demo/demo.css @@ -0,0 +1,94 @@ +/* general styles */ +html, body { + padding:30px 100px; + background:#E5E5E5 +} +* { + font-family:Verdana, Arial, sans-serif; + color:#000 +} +h1 { + font-size:33px; + color:#99CC00; + margin:15px 0 +} +.navigation { + margin:10px 0 20px; +} +.navigation, .navigation a { + color:#608000; + font-size:12px; +} +.navigation a { + margin-right:4px; +} +h2 { + margin:15px 0 25px; + color:#608000; + font-size:14px; + font-weight:bold +} +a:link, a:visited { + text-decoration:underline +} +.testbutton { + margin-bottom:30px; + background:#3399FF; + padding:6px 25px; + border:#003F81 1px solid; + color:#FFF; + font-size:22px; + border-radius:5px; -webkit-border-radius:5px; -moz-border-radius:5px; + box-shadow:inset 0 5px 5px #67B3FF; -webkit-box-shadow:inset 0 5px 5px #67B3FF; -moz-box-shadow:inset 0 5px 5px #67B3FF +} +.testbutton:hover { + background:#198CFF; + cursor:pointer +} +.footer, .footer * { + color:#802D00; + font-size:15px +} + +.jqte-test { + display:block; + margin:0 0 10px; + padding:6px; + width:95%; + background:#FFF; + border:#AAA 1px solid; + font-size:13px; +} +textarea.jqte-test, div.jqte-test, span.jqte-test { + min-height:100px; +} +button { + display:block; + margin:20px 0; + padding:6px 0 4px; + width:154px; + background:#658700; + border:#526E00 1px solid; + color:#F3FFCF !important; + text-align:center; + font-size:13px; + font-weight:bold; + border-radius:3px; -webkit-border-radius:3px; -moz-border-radius:3px; + box-shadow:0 0 2px #000, inset 0 1px 1px #99CC00; -webkit-box-shadow:0 0 2px #000, inset 0 1px 1px #99CC00; -moz-box-shadow:0 0 2px #000, inset 0 1px 1px #99CC00; + cursor:pointer; +} +button:hover { + background:#78A000; + border-color:#658700; + text-decoration:none !important; + cursor:pointer +} + +button:active { + background:#3F5500; + border-color:#2C3C00; + color:#9CCD00 !important; + box-shadow:0 0 3px #000,inset 0 -2px 2px #333; + -webkit-box-shadow:0 0 3px #000, inset 0 -2px 2px #333; + -moz-box-shadow:0 0 3px #000, inset 0 -2px 2px #333; +} \ No newline at end of file diff --git a/src/thirdparty/jQuery-TE_v.1.4.0/demo/demo.html b/src/thirdparty/jQuery-TE_v.1.4.0/demo/demo.html new file mode 100644 index 0000000..ee799c7 --- /dev/null +++ b/src/thirdparty/jQuery-TE_v.1.4.0/demo/demo.html @@ -0,0 +1,64 @@ + + + + + +jQuery TE | Downloaded Demo | v.1.4.0 + + + + + + + + + +

jQuery TE

+ + + +

Demo | v.1.4.0

+ + + + + + + + + + +My contents are from SPAN + + + + + + +
+ + + +

Thanks for using!

+ + + \ No newline at end of file diff --git a/src/thirdparty/jQuery-TE_v.1.4.0/jquery-te-1.4.0.css b/src/thirdparty/jQuery-TE_v.1.4.0/jquery-te-1.4.0.css new file mode 100644 index 0000000..ed615f7 --- /dev/null +++ b/src/thirdparty/jQuery-TE_v.1.4.0/jquery-te-1.4.0.css @@ -0,0 +1,457 @@ +/*! + * + * jQuery TE 1.4.0 , http://jqueryte.com/ + * Copyright (C) 2013, Fatih Koca (fattih@fattih.com), (http://jqueryte.com/about) + + * jQuery TE is provided under the MIT LICENSE. + * +*/ + +/* editor's general field */ +.jqte { + margin:30px 0; + border:#000 1px solid; + border-radius:5px; -webkit-border-radius:5px; -moz-border-radius:5px; + box-shadow:0 0 3px #999; -webkit-box-shadow:0 0 3px #999; -moz-box-shadow:0 0 3px #999; + overflow:hidden; + transition:box-shadow 0.4s, border 0.4s; -webkit-transition:-webkit-box-shadow 0.4s, border 0.4s; -moz-transition:-moz-box-shadow 0.4s, border 0.4s; -o-transition:-o-box-shadow 0.4s, border 0.4s; +} +.jqte * { + color:#333; + font-family:Arial, Helvetica, sans-serif; + font-size:14px; +} +.jqte_focused { + border-color:#00AAE7; + box-shadow:0 0 10px #00BDFF; -webkit-box-shadow:0 0 10px #00BDFF; -moz-box-shadow:0 0 10px #00BDFF; +} +/* toolbar */ +.jqte_toolbar { + overflow:auto; + padding:3px 4px; + background:#EEE; + border-bottom:#BBB 1px solid; +} +.jqte_tool { + float:left; + margin:0; + padding:0; + cursor:pointer; +} +.jqte_tool, .jqte_tool_icon, .jqte_tool_label { + border:#EEE 1px solid; + border-radius:3px; -webkit-border-radius:3px; -moz-border-radius:3px +} +.jqte_hiddenField { + display:none +} +.jqte_tool_icon { + display:block; + width:22px; + height:22px; + background:url(jquery-te.png) no-repeat +} +.jqte_tool.jqte_tool_1 .jqte_tool_label { + position:relative; + display:block; + padding:3px; + width:70px; + height:16px; + overflow:hidden; +} +.jqte_tool.jqte_tool_1 .jqte_tool_text { + font:bold 13px Arial,sans-serif; + color:#222; +} +.jqte_tool.jqte_tool_1 .jqte_tool_icon { + position:absolute; + top:10px; + right:2px; + width:6px; + height:4px; + background-position:-19px -23px; + border:none; + border-radius:none; -webkit-border-radius:none; -moz-border-radius:none +} +.jqte_tool.jqte_tool_2 .jqte_tool_icon { + background-position:0 0 +} +.jqte_tool.jqte_tool_3 .jqte_tool_icon { + background-position:-22px 0 +} +.jqte_tool.jqte_tool_4 .jqte_tool_icon { + background-position:-44px 0 +} +.jqte_tool.jqte_tool_5 .jqte_tool_icon { + background-position:-66px 0 +} +.jqte_tool.jqte_tool_6 .jqte_tool_icon { + background-position:-88px 0 +} +.jqte_tool.jqte_tool_7 .jqte_tool_icon { + background-position:-110px 0 +} +.jqte_tool.jqte_tool_8 .jqte_tool_icon { + background-position:-132px 0 +} +.jqte_tool.jqte_tool_9 .jqte_tool_icon { + background-position:-154px 0 +} +.jqte_tool.jqte_tool_10 .jqte_tool_icon { + background-position:-176px 0 +} +.jqte_tool.jqte_tool_11 .jqte_tool_icon { + background-position:-198px 0 +} +.jqte_tool.jqte_tool_12 .jqte_tool_icon { + background-position:-220px 0 +} +.jqte_tool.jqte_tool_13 .jqte_tool_icon { + background-position:-242px 0 +} +.jqte_tool.jqte_tool_14 .jqte_tool_icon { + background-position:-264px 0 +} +.jqte_tool.jqte_tool_15 .jqte_tool_icon { + background-position:-286px 0 +} +.jqte_tool.jqte_tool_16 .jqte_tool_icon { + background-position:-308px 0 +} +.jqte_tool.jqte_tool_17 .jqte_tool_icon { + background-position:-330px 0 +} +.jqte_tool.jqte_tool_18 .jqte_tool_icon { + background-position:-352px 0 +} +.jqte_tool.jqte_tool_19 .jqte_tool_icon { + background-position:-374px 0 +} +.jqte_tool.jqte_tool_20 .jqte_tool_icon { + background-position:-396px 0 +} +.jqte_tool.jqte_tool_21 .jqte_tool_icon { + background-position:-418px 0 +} +.jqte_tool:hover { + background-color:#FFF; + border-color:#FFF +} +.jqte_tool:hover .jqte_tool_icon, .jqte_tool:hover .jqte_tool_label { + border:#AAA 1px solid +} +.jqte_tool:active .jqte_tool_icon, .jqte_tool:active .jqte_tool_label { + border:#777 1px solid +} +.jqte_tool.jqte_tool_1:hover .jqte_tool_icon, .jqte_tool.jqte_tool_1:active .jqte_tool_icon { + border:none +} +.jqte_tool_depressed { + background-color:#DDD; + border-color:#CCC +} +.jqte_tool_depressed .jqte_tool_icon { + border-color:#AAA +} +.jqte_tool_depressed:hover { + background-color:#EEE +} +/* link form area */ +.jqte_linkform { + padding:5px 10px; + background:#DDD; + border-bottom:#BBB 1px solid; +} +.jqte_linktypeselect { + position:relative; + float:left; + width:130px; + background:#EEE; + cursor:pointer +} +.jqte_linktypeselect:Active { + background:#FFF +} +.jqte_linktypeview { + padding:3px 5px; + border:#333 1px solid; + color:#777; + border-radius:3px; -webkit-border-radius:3px; -moz-border-radius:3px; + outline:none +} +.jqte_linktypetext { + font-size:12px; +} +.jqte_linktypearrow { + position:absolute; + bottom:8px; right:6px; + width:7px; + height:6px; + margin:0 auto; + background:url(jquery-te.png) -7px -23px no-repeat; +} +.jqte_linktypes { + display:none; + position:absolute; + top:22px; left:1px; + width:125px; + background:#FFF; + border:#333 1px solid; + box-shadow:0 1px 4px #AAA; -webkit-box-shadow:0 1px 4px #AAA; -moz-box-shadow:0 1px 4px #AAA +} +.jqte_linktypes a { + display:block; + padding:4px 5px; + font-size:12px; +} +.jqte_linktypes a:hover { + background:#DDD +} +.jqte_linkinput { + float:left; + margin:0 5px; + padding:3px 5px; + width:300px; + background:#EEE; + border:#333 1px solid; + color:#777; + font-size:12px; + border-radius:3px; -webkit-border-radius:3px; -moz-border-radius:3px; + outline:none; +} +.jqte_linkinput:focus, .jqte_linkinput:hover { + background:#FFF; + border-color:#000; +} +.jqte_linkbutton { + float:left; + padding:3px 12px; + background:#AAA; + border:#333 1px solid; + color:#FFF; + font-size:12px; + font-weight:bold; + cursor:pointer; + border-radius:3px; -webkit-border-radius:3px; -moz-border-radius:3px; + box-shadow:inset 0 1px #EEE; -webkit-box-shadow:inset 0 1px #EEE; -moz-box-shadow:inset 0 1px #EEE; +} +.jqte_linkbutton:hover { + background:#A1A1A1 +} +.jqte_linkbutton:active { + box-shadow:inset 0 1px #CCC; -webkit-box-shadow:inset 0 1px #CCC; -moz-box-shadow:inset 0 1px #CCC; + background:#888; +} + +/* text format menu */ +.jqte_formats { + display:none; + position:absolute; + width:180px; + oveflow-x:hidden; + overflow-y:auto; + background:#FFF; + border:#AAA 1px solid; + box-shadow:0 0 5px #AAA; -webkit-box-shadow:0 0 5px #AAA; -moz-box-shadow:0 0 5px #AAA; + z-index:100; +} +.jqte_format { + display:block; + padding:4px 7px; + font-size:13px +} +.jqte_format:hover { + background:#DDD +} +.jqte_format_1, .jqte_format_2, .jqte_format_3, .jqte_format_4, .jqte_format_5, .jqte_format_6 { + font-weight:bold +} +.jqte_format_1 { + font-size:22px +} +.jqte_format_2 { + font-size:20px +} +.jqte_format_3 { + font-size:18px +} +.jqte_format_4 { + font-size:16px +} +.jqte_format_5 { + font-size:14px +} +.jqte_format_6 { + font-size:12px +} +.jqte_format_7 { + font-family:"Courier New", Courier, monospace +} + +/* font size menu */ +.jqte_fontsizes { + display:none; + position:absolute; + width:180px; + height:198px; + oveflow-x:hidden; + overflow-y:auto; + background:#FFF; + border:#AAA 1px solid; + box-shadow:0 0 5px #AAA; -webkit-box-shadow:0 0 5px #AAA; -moz-box-shadow:0 0 5px #AAA +} +.jqte_fontsize { + display:block; + padding:3px 7px; +} +.jqte_fontsize:hover { + background:#DDD +} + +/* color pallette */ +.jqte_cpalette { + display:none; + position:absolute; + padding:6px; + width:144px; + background:#FFF; + border:#AAA 1px solid; + box-shadow:0 0 5px #AAA; -webkit-box-shadow:0 0 5px #AAA; -moz-box-shadow:0 0 5px #AAA +} +.jqte_color { + display:block; + float:left; + width:16px; + height:16px; + border:#FFF 1px solid; +} +.jqte_color:hover { + border-color:#000 +} +.jqte_colorSeperator { + float:none; + clear:both; + height:7px; +} + +/* editor area */ +.jqte_editor, .jqte_source { + padding:10px; + background:#FFF; + min-height:100px; + max-height:900px; + overflow:auto; + outline:none; + word-wrap:break-word; -ms-word-wrap:break-word; + resize:vertical +} +.jqte_editor div, .jqte_editor p { + margin:0 0 7px +} +.jqte_editor a:link, .jqte_editor a:link * { + color:#0066FF !important; + text-decoration:underline; +} +.jqte_editor blockquote { + margin-top:0; + margin-bottom:7px +} +.jqte_editor img { + float:left; + margin:0 10px 5px 0 +} +.jqte_editor a[jqte-setlink], .jqte_editor a[jqte-setlink] * { + background:#3297FD !important; + color:#FFF !important +} +.jqte_editor h1, .jqte_editor h2, .jqte_editor h3, .jqte_editor h4, .jqte_editor h5, .jqte_editor h6, .jqte_editor pre { + display:block; + margin:0 0 3px; +} +.jqte_editor h1, .jqte_editor h1 * { + font-size:26px +} +.jqte_editor h2, .jqte_editor h2 * { + font-size:24px +} +.jqte_editor h3, .jqte_editor h3 * { + font-size:22px +} +.jqte_editor h4, .jqte_editor h4 * { + font-size:20px +} +.jqte_editor h5, .jqte_editor h5 * { + font-size:18px +} +.jqte_editor h6, .jqte_editor h6 * { + font-size:15px +} +.jqte_editor pre, .jqte_editor pre * { + font-family:"Courier New", Courier, monospace +} + +/* source area */ +.jqte_source, .jqte_source textarea { + background:#FFF1E8 +} +.jqte_source textarea { + margin:0 !important; + padding:0 !important; + display:block !important; + width:100% !important; + min-height:100px; + font-family:Courier, Arial, sans-serif !important; + font-weight:normal; + font-size:15px; + overflow:hidden !important; + outline:none; + resize:none; +} +.jqte_source textarea, .jqte_source textarea:focus { + css_shadow:none !important; + background:none !important; + border:none !important; +} + +/* title box */ +.jqte_title { + display:none; + position:absolute; + z-index:9999; +} +.jqte_titleArrow { + position:relative; +} +.jqte_titleArrowIcon { + width:7px; + height:6px; + margin:0 auto; + background:url(jquery-te.png) 0 -23px no-repeat; +} +.jqte_titleText { + padding:5px 7px; + margin-top:0; + min-width:5px; + min-height:1px; + max-width:400px; + background:#000; + border-radius:3px; -webkit-border-radius:3px; -moz-border-radius:3px; + word-wrap:break-word; -ms-word-wrap:break-word +} +.jqte_titleText, .jqte_titleText * { + color:#FFF; + font-size:11px +} + +/* placeholder */ +.jqte_placeholder { + position:relative; + display:none; +} +.jqte_placeholder_text { + position:absolute; + top:43px; + left:10px; + font-size:14px; + color:#CCC; +} \ No newline at end of file diff --git a/src/thirdparty/jQuery-TE_v.1.4.0/jquery-te-1.4.0.min.js b/src/thirdparty/jQuery-TE_v.1.4.0/jquery-te-1.4.0.min.js new file mode 100644 index 0000000..6e9f58d --- /dev/null +++ b/src/thirdparty/jQuery-TE_v.1.4.0/jquery-te-1.4.0.min.js @@ -0,0 +1,9 @@ +/*! + * + * jQuery TE 1.4.0 , http://jqueryte.com/ + * Copyright (C) 2013, Fatih Koca (fattih@fattih.com), (http://jqueryte.com/about) + + * jQuery TE is provided under the MIT LICENSE. + * +*/ +(function(e){e.fn.jqte=function(t){function l(e,t,n,r,i){var s=f.length+1;return f.push({name:e,cls:s,command:t,key:n,tag:r,emphasis:i})}var n=[{title:"Text Format"},{title:"Font Size"},{title:"Color"},{title:"Bold",hotkey:"B"},{title:"Italic",hotkey:"I"},{title:"Underline",hotkey:"U"},{title:"Ordered List",hotkey:"."},{title:"Unordered List",hotkey:","},{title:"Subscript",hotkey:"down arrow"},{title:"Superscript",hotkey:"up arrow"},{title:"Outdent",hotkey:"left arrow"},{title:"Indent",hotkey:"right arrow"},{title:"Justify Left"},{title:"Justify Center"},{title:"Justify Right"},{title:"Strike Through",hotkey:"K"},{title:"Add Link",hotkey:"L"},{title:"Remove Link"},{title:"Cleaner Style",hotkey:"Delete"},{title:"Horizontal Rule",hotkey:"H"},{title:"Source"}];var r=[["p","Normal"],["h1","Header 1"],["h2","Header 2"],["h3","Header 3"],["h4","Header 4"],["h5","Header 5"],["h6","Header 6"],["pre","Preformatted"]];var i=["10","12","16","18","20","24","28"];var s=["0,0,0","68,68,68","102,102,102","153,153,153","204,204,204","238,238,238","243,243,243","255,255,255",null,"255,0,0","255,153,0","255,255,0","0,255,0","0,255,255","0,0,255","153,0,255","255,0,255",null,"244,204,204","252,229,205","255,242,204","217,234,211","208,224,227","207,226,243","217,210,233","234,209,220","234,153,153","249,203,156","255,229,153","182,215,168","162,196,201","159,197,232","180,167,214","213,166,189","224,102,102","246,178,107","255,217,102","147,196,125","118,165,175","111,168,220","142,124,195","194,123,160","204,0,0","230,145,56","241,194,50","106,168,79","69,129,142","61,133,198","103,78,167","166,77,121","153,0,0","180,95,6","191,144,0","56,118,29","19,79,92","11,83,148","53,28,117","116,27,71","102,0,0","120,63,4","127,96,0","39,78,19","12,52,61","7,55,99","32,18,77","76,17,48"];var o=["Web Address","E-mail Address","Picture URL"];var u=e.extend({status:true,css:"jqte",title:true,titletext:n,button:"OK",format:true,formats:r,fsize:true,fsizes:i,funit:"px",color:true,linktypes:o,b:true,i:true,u:true,ol:true,ul:true,sub:true,sup:true,outdent:true,indent:true,left:true,center:true,right:true,strike:true,link:true,unlink:true,remove:true,rule:true,source:true,placeholder:false,br:true,p:true,change:"",focus:"",blur:""},t);e.fn.jqteVal=function(t){e(this).closest("."+u.css).find("."+u.css+"_editor").html(t)};var a=navigator.userAgent.toLowerCase();if(/msie [1-7]./.test(a))u.title=false;var f=[];l("format","formats","","",false);l("fsize","fSize","","",false);l("color","colors","","",false);l("b","Bold","B",["b","strong"],true);l("i","Italic","I",["i","em"],true);l("u","Underline","U",["u"],true);l("ol","insertorderedlist","¾",["ol"],true);l("ul","insertunorderedlist","¼",["ul"],true);l("sub","subscript","(",["sub"],true);l("sup","superscript","&",["sup"],true);l("outdent","outdent","%",["blockquote"],false);l("indent","indent","'",["blockquote"],true);l("left","justifyLeft","","",false);l("center","justifyCenter","","",false);l("right","justifyRight","","",false);l("strike","strikeThrough","K",["strike"],true);l("link","linkcreator","L",["a"],true);l("unlink","unlink","",["a"],false);l("remove","removeformat",".","",false);l("rule","inserthorizontalrule","H",["hr"],false);l("source","displaysource","","",false);return this.each(function(){function B(){if(window.getSelection)return window.getSelection();else if(document.selection&&document.selection.createRange&&document.selection.type!="None")return document.selection.createRange()}function j(e,t){var n,r=B();if(window.getSelection){if(r.anchorNode&&r.getRangeAt)n=r.getRangeAt(0);if(n){r.removeAllRanges();r.addRange(n)}if(!a.match(/msie/))document.execCommand("StyleWithCSS",false,false);document.execCommand(e,false,t)}else if(document.selection&&document.selection.createRange&&document.selection.type!="None"){n=document.selection.createRange();n.execCommand(e,false,t)}q(false,false)}function F(t,n,r){if(v.not(":focus"))v.focus();if(window.getSelection){var i=B(),s,o,u;if(i.anchorNode&&i.getRangeAt){s=i.getRangeAt(0);o=document.createElement(t);e(o).attr(n,r);u=s.extractContents();o.appendChild(u);s.insertNode(o);i.removeAllRanges();if(n=="style")q(e(o),r);else q(e(o),false)}}else if(document.selection&&document.selection.createRange&&document.selection.type!="None"){var a=document.selection.createRange();var f=a.htmlText;var l="<"+t+" "+n+'="'+r+'">'+f+"";document.selection.createRange().pasteHTML(l)}}function q(e,t){var n=I();n=n?n:e;if(n&&t==false){if(n.parent().is("[style]"))n.attr("style",n.parent().attr("style"));if(n.is("[style]"))n.find("*").attr("style",n.attr("style"))}else if(e&&t&&e.is("[style]")){var r=t.split(";");r=r[0].split(":");if(e.is("[style*="+r[0]+"]"))e.find("*").css(r[0],r[1]);R(e)}}function R(t){if(t){var t=t[0];if(document.body.createTextRange){var n=document.body.createTextRange();n.moveToElementText(t);n.select()}else if(window.getSelection){var r=window.getSelection();var n=document.createRange();if(t!="undefined"&&t!=null){n.selectNodeContents(t);r.removeAllRanges();r.addRange(n);if(e(t).is(":empty")){e(t).append(" ");R(e(t))}}}}}function U(){if(!p.data("sourceOpened")){var t=I();var n="http://";W(true);if(t){var r=t.prop("tagName").toLowerCase();if(r=="a"&&t.is("[href]")){n=t.attr("href");t.attr(S,"")}else F("a",S,"")}else y.val(n).focus();g.click(function(t){if(e(t.target).hasClass(u.css+"_linktypetext")||e(t.target).hasClass(u.css+"_linktypearrow"))X(true)});w.find("a").click(function(){var t=e(this).attr(u.css+"-linktype");w.data("linktype",t);E.find("."+u.css+"_linktypetext").html(w.find("a:eq("+w.data("linktype")+")").text());V(n);X()});V(n);y.focus().val(n).bind("keypress keyup",function(e){if(e.keyCode==13){z(h.find("["+S+"]"));return false}});b.click(function(){z(h.find("["+S+"]"))})}else W(false)}function z(t){y.focus();R(t);t.removeAttr(S);if(w.data("linktype")!="2")j("createlink",y.val());else{j("insertImage",y.val());v.find("img").each(function(){var t=e(this).prev("a");var n=e(this).next("a");if(t.length>0&&t.html()=="")t.remove();else if(n.length>0&&n.html()=="")n.remove()})}W();v.trigger("change")}function W(e){Q("["+S+"]:not([href])");h.find("["+S+"][href]").removeAttr(S);if(e){p.data("linkOpened",true);d.show()}else{p.data("linkOpened",false);d.hide()}X()}function X(e){if(e)w.show();else w.hide()}function V(e){var t=w.data("linktype");if(t=="1"&&(y.val()=="http://"||y.is("[value^=http://]")||!y.is("[value^=mailto]")))y.val("mailto:");else if(t!="1"&&!y.is("[value^=http://]"))y.val("http://");else y.val(e)}function J(t){if(!p.data("sourceOpened")){if(t=="fSize")styleField=P;else if(t=="colors")styleField=H;K(styleField,true);styleField.find("a").unbind("click").click(function(){var n=e(this).attr(u.css+"-styleval");if(t=="fSize"){styleType="font-size";n=n+u.funit}else if(t=="colors"){styleType="color";n="rgb("+n+")"}var r=G(styleType);F("span","style",styleType+":"+n+";"+r);K("",false);e("."+u.css+"_title").remove();v.trigger("change")})}else K(styleField,false);W(false)}function K(e,t){var n="",r=[{d:"fsizeOpened",f:P},{d:"cpallOpened",f:H}];if(e!=""){for(var i=0;i");Z(false)})}function Z(e){var t=e?true:false;t=e&&D.data("status")?true:false;if(t||!e)D.data("status",false).slideUp(200);else D.data("status",true).slideDown(200)}function et(e){var t=D.closest("."+u.css+"_tool").find("."+u.css+"_tool_label").find("."+u.css+"_tool_text");if(e.length>10)e=e.substr(0,7)+"...";t.html(e)}function tt(e){var t,n,r;t=e.replace(/\n/gim,"").replace(/\r/gim,"").replace(/\t/gim,"").replace(/ /gim," ");n=[/\(.*?)<\/span><\/span>/gim,/<(\w*[^p])\s*[^\/>]*>\s*<\/\1>/gim,/\(.*?)\<\/div>/gim,/\(.*?)\<\/strong>/gim,/\(.*?)\<\/em>/gim];r=["$3","","$2

","$2","$2"];for(A=0;A<5;A++){for(var i=0;i(.*?)\<\/p>/ig,"
$2");if(!u.br){n=[/\
(.*?)/ig,/\(.*?)/ig];r=["

$1

","

$1

"];for(var i=0;i(.*?)\<\/p>/ig,"
$1
");return t}function nt(){var e=v.text()==""&&v.html().length<12?"":v.html();l.val(tt(e))}function rt(){v.html(tt(l.val()))}function it(t){var n=false,r=I(),i;if(r){e.each(t,function(t,s){i=r.prop("tagName").toLowerCase();if(i==s)n=true;else{r.parents().each(function(){i=e(this).prop("tagName").toLowerCase();if(i==s)n=true})}});return n}else return false}function st(t){for(var n=0;n0&&it(s)){et(u.formats[i][1]);r=true;break}}if(!r)et(u.formats[0][1])}K("",false);Z(false)}if(!e(this).data("jqte")||e(this).data("jqte")==null||e(this).data("jqte")=="undefined")e(this).data("jqte",true);else e(this).data("jqte",false);if(!u.status||!e(this).data("jqte")){if(e(this).closest("."+u.css).length>0){var t=e(this).closest("."+u.css).find("."+u.css+"_editor").html();var n="";e(e(this)[0].attributes).each(function(){if(this.nodeName!="style")n=n+" "+this.nodeName+'="'+this.nodeValue+'"'});var r=e(this).is("[data-origin]")&&e(this).attr("data-origin")!=""?e(this).attr("data-origin"):"textarea";var i=">"+t;if(r=="input"||r=="option"){t=t.replace(/"/g,""").replace(/'/g,"'").replace(//g,">");i='value="'+t+'">'}var o=e(this).clone();e(this).data("jqte",false).closest("."+u.css).before(o).remove();o.replaceWith("<"+r+n+i+"")}return}var l=e(this);var r=e(this).prop("tagName").toLowerCase();e(this).attr("data-origin",r);var c=e(this).is("[value]")||r=="textarea"?e(this).val():e(this).html();c=c.replace(/"/g,'"').replace(/'/g,"'").replace(//g,">").replace(/&/g,"&");e(this).after('
');var h=e(this).next("."+u.css);h.html('
');var p=h.find("."+u.css+"_toolbar");var d=h.find("."+u.css+"_linkform");var v=h.find("."+u.css+"_editor");var m=u.css+"_tool_depressed";d.append('
'+u.button+'
');var g=d.find("."+u.css+"_linktypeselect");var y=d.find("."+u.css+"_linkinput");var b=d.find("."+u.css+"_linkbutton");g.append('
');var w=g.find("."+u.css+"_linktypes");var E=g.find("."+u.css+"_linktypeview");var S=u.css+"-setlink";v.after('
');var x=h.find("."+u.css+"_source");l.appendTo(x);if(r!="textarea"){var n="";e(l[0].attributes).each(function(){if(this.nodeName!="type"&&this.nodeName!="value")n=n+" "+this.nodeName+'="'+this.nodeValue+'"'});l.replaceWith("");l=x.find("textarea")}v.attr("contenteditable","true").html(c);for(var T=0;T0?u.titletext[T].hotkey!=null&&u.titletext[T].hotkey!="undefined"&&u.titletext[T].hotkey!=""?" (Ctrl+"+u.titletext[T].hotkey+")":"":"";var C=u.titletext[T].title!=null&&u.titletext[T].title!="undefined"&&u.titletext[T].title!=""?u.titletext[T].title+N:"";p.append('
');p.find("."+u.css+"_tool[data-tool="+T+"]").data({tag:f[T].tag,command:f[T].command,emphasis:f[T].emphasis,title:C});if(f[T].name=="format"&&e.isArray(u.formats)){var k=u.formats[0][1].length>0&&u.formats[0][1]!="undefined"?u.formats[0][1]:"";p.find("."+u.css+"_tool_"+f[T].cls).find("."+u.css+"_tool_icon").replaceWith(''+k+'');p.find("."+u.css+"_tool_"+f[T].cls).append('
');for(var L=0;L'+u.formats[L][1]+"")}p.find("."+u.css+"_formats").data("status",false)}else if(f[T].name=="fsize"&&e.isArray(u.fsizes)){p.find("."+u.css+"_tool_"+f[T].cls).append('
');for(var L=0;LAbcdefgh...')}}else if(f[T].name=="color"&&e.isArray(s)){p.find("."+u.css+"_tool_"+f[T].cls).append('
');for(var A=0;A');else p.find("."+u.css+"_cpalette").append('
')}}}}w.data("linktype","0");for(var T=0;T<3;T++){w.append("'+u.linktypes[T]+"");E.html('
'+w.find("a:eq("+w.data("linktype")+")").text()+"
")}var O="";if(/msie/.test(a))O="-ms-";else if(/chrome/.test(a)||/safari/.test(a)||/yandex/.test(a))O="-webkit-";else if(/mozilla/.test(a))O="-moz-";else if(/opera/.test(a))O="-o-";else if(/konqueror/.test(a))O="-khtml-";else O="";if(u.placeholder&&u.placeholder!=""){h.prepend('
'+u.placeholder+"
");var M=h.find("."+u.css+"_placeholder");M.click(function(){v.focus()})}h.find("[unselectable]").css(O+"user-select","none").addClass("unselectable").attr("unselectable","on").on("selectstart mousedown",false);var _=p.find("."+u.css+"_tool");var D=p.find("."+u.css+"_formats");var P=p.find("."+u.css+"_fontsizes");var H=p.find("."+u.css+"_cpalette");var I=function(){var t,n;if(window.getSelection){n=getSelection();t=n.anchorNode}if(!t&&document.selection&&document.selection.createRange&&document.selection.type!="None"){n=document.selection;var r=n.getRangeAt?n.getRangeAt(0):n.createRange();t=r.commonAncestorContainer?r.commonAncestorContainer:r.parentElement?r.parentElement():r.item(0)}if(t){return t.nodeName=="#text"?e(t.parentNode):e(t)}else return false};_.unbind("click").click(function(t){if(e(this).data("command")=="displaysource"&&!p.data("sourceOpened")){p.find("."+u.css+"_tool").addClass(u.css+"_hiddenField");e(this).removeClass(u.css+"_hiddenField");p.data("sourceOpened",true);l.css("height",v.outerHeight());x.removeClass(u.css+"_hiddenField");v.addClass(u.css+"_hiddenField");l.focus();W(false);K("",false);Z();if(u.placeholder&&u.placeholder!="")M.hide()}else{if(!p.data("sourceOpened")){if(e(this).data("command")=="linkcreator"){if(!p.data("linkOpened"))U();else{W(false);Z(false)}}else if(e(this).data("command")=="formats"){if(e(this).data("command")=="formats"&&!e(t.target).hasClass(u.css+"_format"))Y();K("",false);if(v.not(":focus"))v.focus()}else if(e(this).data("command")=="fSize"||e(this).data("command")=="colors"){if(e(this).data("command")=="fSize"&&!e(t.target).hasClass(u.css+"_fontsize")||e(this).data("command")=="colors"&&!e(t.target).hasClass(u.css+"_color"))J(e(this).data("command"));Z(false);if(v.not(":focus"))v.focus()}else{if(v.not(":focus"))v.focus();j(e(this).data("command"),null);K("",false);Z(false);X();e(this).data("emphasis")==true&&!e(this).hasClass(m)?e(this).addClass(m):e(this).removeClass(m);x.addClass(u.css+"_hiddenField");v.removeClass(u.css+"_hiddenField")}}else{p.data("sourceOpened",false);p.find("."+u.css+"_tool").removeClass(u.css+"_hiddenField");x.addClass(u.css+"_hiddenField");v.removeClass(u.css+"_hiddenField")}if(u.placeholder&&u.placeholder!="")v.html()!=""?M.hide():M.show()}v.trigger("change")}).hover(function(t){if(u.title&&e(this).data("title")!=""&&(e(t.target).hasClass(u.css+"_tool")||e(t.target).hasClass(u.css+"_tool_icon"))){e("."+u.css+"_title").remove();h.append('
'+e(this).data("title")+"
");var n=e("."+u.css+"_title:first");var r=n.find("."+u.css+"_titleArrowIcon");var i=e(this).position();var s=i.left+e(this).outerWidth()-n.outerWidth()/2-e(this).outerWidth()/2;var o=i.top+e(this).outerHeight()+5;n.delay(400).css({top:o,left:s}).fadeIn(200)}},function(){e("."+u.css+"_title").remove()});var ot=null;v.bind("keypress keyup keydown drop cut copy paste DOMCharacterDataModified DOMSubtreeModified",function(){if(!p.data("sourceOpened"))e(this).trigger("change");X();if(e.isFunction(u.change))u.change();if(u.placeholder&&u.placeholder!="")e(this).text()!=""?M.hide():M.show()}).bind("change",function(){if(!p.data("sourceOpened")){clearTimeout(ot);ot=setTimeout(nt,10)}}).keydown(function(e){if(e.ctrlKey){for(var t=0;t no hotkey + addParams('fsize','fSize','','',false); // font size button --> no hotkey + addParams('color','colors','','',false); // text color button --> no hotkey + addParams('b','Bold','B',["b","strong"],true); // bold --> ctrl + b + addParams('i','Italic','I',["i","em"],true); // italic --> ctrl + i + addParams('u','Underline','U',["u"],true); // underline --> ctrl + u + addParams('ol','insertorderedlist','¾',["ol"],true); // ordered list --> ctrl + .(dot) + addParams('ul','insertunorderedlist','¼',["ul"],true); // unordered list --> ctrl + ,(comma) + addParams('sub','subscript','(',["sub"],true); // sub script --> ctrl + down arrow + addParams('sup','superscript','&',["sup"],true); // super script --> ctrl + up arrow + addParams('outdent','outdent','%',["blockquote"],false); // outdent --> ctrl + left arrow + addParams('indent','indent','\'',["blockquote"],true); // indent --> ctrl + right arrow + addParams('left','justifyLeft','','',false); // justify Left --> no hotkey + addParams('center','justifyCenter','','',false); // justify center --> no hotkey + addParams('right','justifyRight','','',false); // justify right --> no hotkey + addParams('strike','strikeThrough','K',["strike"],true); // strike through --> ctrl + K + addParams('link','linkcreator','L',["a"],true); // insertion link --> ctrl + L + addParams('unlink','unlink','',["a"],false); // remove link --> ctrl + N + addParams('remove','removeformat','.','',false); // remove all styles --> ctrl + delete + addParams('rule','inserthorizontalrule','H',["hr"],false); // insertion horizontal rule --> ctrl + H + addParams('source','displaysource','','',false); // feature of displaying source + + return this.each(function(){ + if(!$(this).data("jqte") || $(this).data("jqte")==null || $(this).data("jqte")=="undefined") + $(this).data("jqte",true); + else + $(this).data("jqte",false); + + // is the status false of the editor + if(!vars.status || !$(this).data("jqte")) + { + // if wanting the false status later + if($(this).closest("."+vars.css).length>0) + { + var editorValue = $(this).closest("."+vars.css).find("."+vars.css+"_editor").html(); + + // add all attributes of element + var thisElementAttrs = ""; + + $($(this)[0].attributes).each(function() + { + if(this.nodeName!="style") + thisElementAttrs = thisElementAttrs+" "+this.nodeName+'="'+this.nodeValue+'"'; + }); + + var thisElementTag = $(this).is("[data-origin]") && $(this).attr("data-origin")!="" ? $(this).attr("data-origin") : "textarea"; + + // the contents of this element + var createValue = '>'+editorValue; + + // if this element is input or option + if(thisElementTag=="input" || thisElementTag=="option") + { + // encode special html characters + editorValue = editorValue.replace(/"/g,'"').replace(/'/g,''').replace(//g,'>'); + + // the value of this element + createValue = 'value="'+editorValue+'">'; + } + + var thisClone = $(this).clone(); + + $(this).data("jqte",false).closest("."+vars.css).before(thisClone).remove(); + thisClone.replaceWith('<'+ thisElementTag + thisElementAttrs + createValue + ''); + } + return; + } + + // element will converted to the jqte editor + var thisElement = $(this); + + // tag name of the element + var thisElementTag = $(this).prop('tagName').toLowerCase(); + + // tag name of origin + $(this).attr("data-origin",thisElementTag); + + // contents of the element + var thisElementVal = $(this).is("[value]") || thisElementTag == "textarea" ? $(this).val() : $(this).html(); + + // decode special html characters + thisElementVal = thisElementVal.replace(/"/g,'"').replace(/'/g,"'").replace(/</g,'<').replace(/>/g,'>').replace(/&/g,'&'); + + // start jqte editor to after the element + $(this).after('
'); + + // jqte + var jQTE = $(this).next('.'+vars.css); + + // insert toolbar in jqte editor + jQTE.html('
'); + + var toolbar = jQTE.find('.'+vars.css+"_toolbar"); // the toolbar variable + var linkform = jQTE.find('.'+vars.css+"_linkform"); // the link-form-area in the toolbar variable + var editor = jQTE.find('.'+vars.css+"_editor"); // the text-field of jqte editor + var emphasize = vars.css+"_tool_depressed"; // highlight style of the toolbar buttons + + // add to some tools in link form area + linkform.append('
'+vars.button+'
'); + + var linktypeselect = linkform.find("."+vars.css+"_linktypeselect"); // the tool of link-type-selector + var linkinput = linkform.find("."+vars.css+"_linkinput"); // the input of insertion link + var linkbutton = linkform.find("."+vars.css+"_linkbutton"); // the button of insertion link + + // add to the link-type-selector sub tool parts + linktypeselect.append('
'); + + var linktypes = linktypeselect.find("."+vars.css+"_linktypes"); // the select box of link types + var linktypeview = linktypeselect.find("."+vars.css+"_linktypeview"); // the link type preview + var setdatalink = vars.css+"-setlink"; // the selected text add to mark as "link will be added" + + // create to the source-area + editor.after('
'); + + var sourceField = jQTE.find("."+vars.css+"_source"); // the source-area variable + + // move the element to the source-area + thisElement.appendTo(sourceField); + + // if the element isn't a textarea, convert this to textarea + if(thisElementTag!="textarea") + { + // add all attributes of element to new textarea (type and value except) + var thisElementAttrs = ""; + + $(thisElement[0].attributes).each(function(){ + if(this.nodeName!="type" && this.nodeName!="value") + thisElementAttrs = thisElementAttrs+" "+this.nodeName+'="'+this.nodeValue+'"'; + }); + + // convert the element to textarea + thisElement.replaceWith(''); + + // update to variable of thisElement + thisElement = sourceField.find("textarea"); + } + + // add feature editable to the text-field ve copy from the element's value to text-field + editor.attr("contenteditable","true").html(thisElementVal); + + // insertion the toolbar button + for(var n = 0; n < buttons.length; n++) + { + // if setting of this button is activated (is it true?) + if(vars[buttons[n].name]) + { + // if it have a title, add to this button + var buttonHotkey = buttons[n].key.length>0 ? vars.titletext[n].hotkey!=null && vars.titletext[n].hotkey!="undefined" && vars.titletext[n].hotkey!="" ? ' (Ctrl+'+vars.titletext[n].hotkey+')' : '' : ''; + var buttonTitle = vars.titletext[n].title!=null && vars.titletext[n].title!="undefined" && vars.titletext[n].title!="" ? vars.titletext[n].title+buttonHotkey : ''; + + // add this button to the toolbar + toolbar.append('
'); + + // add the parameters to this button + toolbar.find('.'+vars.css+'_tool[data-tool='+n+']').data({tag : buttons[n].tag, command : buttons[n].command, emphasis : buttons[n].emphasis, title : buttonTitle}); + + // format-selector field + if(buttons[n].name=="format" && $.isArray(vars.formats)) + { + // selected text format + var toolLabel = vars.formats[0][1].length>0 && vars.formats[0][1]!="undefined" ? vars.formats[0][1] : ""; + + toolbar.find("."+vars.css+'_tool_'+buttons[n].cls).find("."+vars.css+"_tool_icon").replaceWith(''+toolLabel+''); + + toolbar.find("."+vars.css+'_tool_'+buttons[n].cls) + .append('
'); + + // add font-sizes to font-size-selector + for(var f = 0; f < vars.formats.length; f++) + { + toolbar.find("."+vars.css+"_formats").append(''+ vars.formats[f][1] +''); + } + + toolbar.find("."+vars.css+"_formats").data("status",false); + } + + // font-size-selector field + else if(buttons[n].name=="fsize" && $.isArray(vars.fsizes)) + { + toolbar.find("."+vars.css+'_tool_'+buttons[n].cls) + .append('
'); + + // add font-sizes to font-size-selector + for(var f = 0; f < vars.fsizes.length; f++) + { + toolbar.find("."+vars.css+"_fontsizes").append('Abcdefgh...'); + } + } + + // color-selector field + else if(buttons[n].name=="color" && $.isArray(colors)) + { + toolbar.find("."+vars.css+'_tool_'+buttons[n].cls) + .append('
'); + + // create color palette to color-selector field + for(var c = 0; c < colors.length; c++) + { + if(colors[c]!=null) + toolbar.find("."+vars.css+"_cpalette").append(''); + else + toolbar.find("."+vars.css+"_cpalette").append('
'); + } + } + } + } + + // the default value of the link-type + linktypes.data("linktype","0"); + + // add link types to link-type-selector + for(var n = 0; n < 3; n++) + { + linktypes.append(''+vars.linktypes[n]+''); + + linktypeview.html('
'+linktypes.find('a:eq('+linktypes.data("linktype")+')').text()+'
'); + } + + // add the prefix of css according to browser + var prefixCss = ""; + + if(/msie/.test(thisBrowser)) // ie + prefixCss = '-ms-'; + else if(/chrome/.test(thisBrowser) || /safari/.test(thisBrowser) || /yandex/.test(thisBrowser)) // webkit group (safari, chrome, yandex) + prefixCss = '-webkit-'; + else if(/mozilla/.test(thisBrowser)) // firefox + prefixCss = '-moz-'; + else if(/opera/.test(thisBrowser)) // opera + prefixCss = '-o-'; + else if(/konqueror/.test(thisBrowser)) // konqueror + prefixCss = '-khtml-'; + else + prefixCss = ''; + + // the feature of placeholder + if(vars.placeholder && vars.placeholder!="") + { + jQTE.prepend('
'+vars.placeholder+'
'); + + var placeHolder = jQTE.find("."+vars.css+"_placeholder"); + + placeHolder.click(function(){ + editor.focus(); + }); + } + + // make unselectable to unselectable attribute ones + jQTE.find("[unselectable]") + .css(prefixCss+"user-select","none") + .addClass("unselectable") + .attr("unselectable","on") + .on("selectstart mousedown",false); + + // each button of the toolbar + var toolbutton = toolbar.find("."+vars.css+"_tool"); + + // format menu + var formatbar = toolbar.find("."+vars.css+"_formats"); + + // font-size filed + var fsizebar = toolbar.find("."+vars.css+"_fontsizes"); + + // color palette + var cpalette = toolbar.find("."+vars.css+"_cpalette"); + + // get the selected text as plain format + function selectionGet() + { + // for webkit, mozilla, opera + if (window.getSelection) + return window.getSelection(); + // for ie + else if (document.selection && document.selection.createRange && document.selection.type != "None") + return document.selection.createRange(); + } + + // the function of changing to the selected text with "execCommand" method + function selectionSet(addCommand,thirdParam) + { + var range, + sel = selectionGet(); + + // for webkit, mozilla, opera + if (window.getSelection) + { + if (sel.anchorNode && sel.getRangeAt) + range = sel.getRangeAt(0); + + if(range) + { + sel.removeAllRanges(); + sel.addRange(range); + } + + if(!thisBrowser.match(/msie/)) + document.execCommand('StyleWithCSS', false, false); + + document.execCommand(addCommand, false, thirdParam); + } + + // for ie + else if (document.selection && document.selection.createRange && document.selection.type != "None") + { + range = document.selection.createRange(); + range.execCommand(addCommand, false, thirdParam); + } + + // change styles to around tags + affectStyleAround(false,false); + } + + // the function of changing to the selected text with tags and tags's attributes + function replaceSelection(tTag,tAttr,tVal) { + + // first, prevent to conflict of different jqte editors + if(editor.not(":focus")) + editor.focus(); + + // for webkit, mozilla, opera + if (window.getSelection) + { + var selObj = selectionGet(), selRange, newElement, documentFragment; + + if (selObj.anchorNode && selObj.getRangeAt) + { + selRange = selObj.getRangeAt(0); + + // create to new element + newElement = document.createElement(tTag); + + // add the attribute to the new element + $(newElement).attr(tAttr,tVal); + + // extract to the selected text + documentFragment = selRange.extractContents(); + + // add the contents to the new element + newElement.appendChild(documentFragment); + + selRange.insertNode(newElement); + selObj.removeAllRanges(); + + // if the attribute is "style", change styles to around tags + if(tAttr=="style") + affectStyleAround($(newElement),tVal); + // for other attributes + else + affectStyleAround($(newElement),false); + } + } + // for ie + else if (document.selection && document.selection.createRange && document.selection.type != "None") + { + var range = document.selection.createRange(); + var selectedText = range.htmlText; + + var newText = '<'+tTag+' '+tAttr+'="'+tVal+'">'+selectedText+''; + + document.selection.createRange().pasteHTML(newText); + } + } + + // the function of getting to the parent tag + var getSelectedNode = function() { + var node,selection; + if(window.getSelection) { + selection = getSelection(); + node = selection.anchorNode; + } + if(!node && document.selection && document.selection.createRange && document.selection.type != "None") + { + selection = document.selection; + var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange(); + node = range.commonAncestorContainer ? range.commonAncestorContainer : + range.parentElement ? range.parentElement() : range.item(0); + } + if(node) { + return (node.nodeName == "#text" ? $(node.parentNode) : $(node)); + } + else + return false; + }; + + // the function of replacement styles to the around tags (parent and child) + function affectStyleAround(element,style) + { + var selectedTag = getSelectedNode(); // the selected node + + selectedTag = selectedTag ? selectedTag : element; + + // (for replacement with execCommand) affect to child tags with parent tag's styles + if(selectedTag && style==false) + { + // apply to the selected node with parent tag's styles + if(selectedTag.parent().is("[style]")) + selectedTag.attr("style",selectedTag.parent().attr("style")); + + // apply to child tags with parent tag's styles + if(selectedTag.is("[style]")) + selectedTag.find("*").attr("style",selectedTag.attr("style")); + } + // (for replacement with html changing method) + else if(element && style && element.is("[style]")) + { + var styleKey = style.split(";"); // split the styles + + styleKey = styleKey[0].split(":") // get the key of first style feature + + // apply to child tags with parent tag's styles + if(element.is("[style*="+styleKey[0]+"]")) + element.find("*").css(styleKey[0],styleKey[1]); + + // select to the selected node again + selectText(element); + } + } + + // the function of making selected to a element + function selectText(element) + { + if(element) + { + var element = element[0]; + + if (document.body.createTextRange) + { + var range = document.body.createTextRange(); + range.moveToElementText(element); + range.select(); + } + else if (window.getSelection) + { + var selection = window.getSelection(); + var range = document.createRange(); + + if(element != "undefined" && element != null) + { + range.selectNodeContents(element); + + selection.removeAllRanges(); + selection.addRange(range); + + if($(element).is(":empty")) + { + $(element).append(" "); + selectText($(element)); + } + } + } + } + } + + // the function of converting text to link + function selected2link() + { + if(!toolbar.data("sourceOpened")) + { + var selectedTag = getSelectedNode(); // the selected node + var thisHrefLink = "http://"; // default the input value of the link-form-field + + // display the link-form-field + linkAreaSwitch(true); + + if(selectedTag) + { + + var thisTagName = selectedTag.prop('tagName').toLowerCase(); + + // if tag name of the selected node is "a" and the selected node have "href" attribute + if(thisTagName == "a" && selectedTag.is('[href]')) + { + thisHrefLink = selectedTag.attr('href'); + + selectedTag.attr(setdatalink,""); + } + // if it don't have "a" tag name + else + replaceSelection("a",setdatalink,""); + + } + else + linkinput.val(thisHrefLink).focus(); + + // the method of displaying-hiding to link-types + linktypeselect.click(function(e) + { + if($(e.target).hasClass(vars.css+"_linktypetext") || $(e.target).hasClass(vars.css+"_linktypearrow")) + linktypeSwitch(true); + }); + + // the method of selecting to link-types + linktypes.find("a").click(function() + { + var thisLinkType = $(this).attr(vars.css+"-linktype"); + + linktypes.data("linktype",thisLinkType) + + linktypeview.find("."+vars.css+"_linktypetext").html(linktypes.find('a:eq('+linktypes.data("linktype")+')').text()); + + linkInputSet(thisHrefLink); + + linktypeSwitch(); + }); + + linkInputSet(thisHrefLink); + + // the method of link-input + linkinput + // auto focus + .focus() + // update to value + .val(thisHrefLink) + // the event of key to enter in link-input + .bind("keypress keyup",function(e) + { + if(e.keyCode==13) + { + linkRecord(jQTE.find("["+setdatalink+"]")); + return false; + } + }); + + // the event of click link-button + linkbutton.click(function() + { + linkRecord(jQTE.find("["+setdatalink+"]")); + }); + } + else + // hide the link-form-field + linkAreaSwitch(false); + } + + function linkRecord(thisSelection) + { + // focus to link-input + linkinput.focus(); + + // select to the selected node + selectText(thisSelection); + + // remove pre-link attribute (mark as "link will be added") of the selected node + thisSelection.removeAttr(setdatalink); + + // if not selected to link-type of picture + if(linktypes.data("linktype")!="2") + selectionSet("createlink",linkinput.val()); // insert link url of link-input to the selected node + // if selected to link-type of picture + else + { + selectionSet("insertImage",linkinput.val()); // insert image url of link-input to the selected node + + // the method of all pictures in the editor + editor.find("img").each(function(){ + var emptyPrevLinks = $(this).prev("a"); + var emptyNextLinks = $(this).next("a"); + + // if "a" tags of the front and rear of the picture is empty, remove + if(emptyPrevLinks.length>0 && emptyPrevLinks.html()=="") + emptyPrevLinks.remove(); + else if(emptyNextLinks.length>0 && emptyNextLinks.html()=="") + emptyNextLinks.remove(); + }); + } + + // hide the link-form-field + linkAreaSwitch(); + + // export contents of the text to the sources + editor.trigger("change"); + } + + // the function of switching link-form-field + function linkAreaSwitch(status) + { + // remove all pre-link attribute (mark as "link will be added") + clearSetElement("["+setdatalink+"]:not([href])"); + jQTE.find("["+setdatalink+"][href]").removeAttr(setdatalink); + + if(status) + { + toolbar.data("linkOpened",true); + linkform.show(); + } + else + { + toolbar.data("linkOpened",false); + linkform.hide(); + } + + linktypeSwitch(); + } + + // the function of switching link-type-selector + function linktypeSwitch(status) + { + if(status) + linktypes.show(); + else + linktypes.hide(); + } + + // the function of updating the link-input according to the link-type + function linkInputSet(thisHrefLink) + { + var currentType = linktypes.data("linktype"); + + // if selected type of e-mail + if(currentType=="1" && (linkinput.val()=="http://" || linkinput.is("[value^=http://]") || !linkinput.is("[value^=mailto]"))) + linkinput.val("mailto:"); + else if(currentType!="1" && !linkinput.is("[value^=http://]")) + linkinput.val("http://"); + else + linkinput.val(thisHrefLink); + } + + // the function of adding style to selected text + function selected2style(styleCommand) + { + if(!toolbar.data("sourceOpened")) + { + + // if selected to changing the font-size value + if(styleCommand=="fSize") + styleField = fsizebar; + + // if selected to changing the text-color value + else if(styleCommand=="colors") + styleField = cpalette; + + // display the style-field + styleFieldSwitch(styleField,true); + + // the event of click to style button + styleField.find("a").unbind("click").click(function() + { + var styleValue = $(this).attr(vars.css + "-styleval"); // the property of style value to be added + + // if selected to changing the font-size value + if(styleCommand=="fSize") + { + styleType = "font-size"; + styleValue = styleValue + vars.funit; // combine the value with size unit + } + // if selected to changing the text-color value + else if(styleCommand=="colors") + { + styleType = "color"; + styleValue = "rgb("+styleValue + ")"; // combine color value with rgb + } + + var prevStyles = refuseStyle(styleType); // affect styles to child tags (and extract to the new style attributes) + + // change to selected text + replaceSelection("span","style",styleType+":"+styleValue+";"+prevStyles); + + // hide all style-fields + styleFieldSwitch("",false); + + // remove title bubbles + $('.'+vars.css+'_title').remove(); + + // export contents of the text to the sources + editor.trigger("change"); + }); + + } + else + // hide the style-field + styleFieldSwitch(styleField,false); + + // hide the link-form-field + linkAreaSwitch(false); + } + + // the function of switching the style-field + function styleFieldSwitch(styleField,status) + { + var mainData="", // the style data of the actual wanted + allData = [{"d":"fsizeOpened","f":fsizebar},{"d":"cpallOpened","f":cpalette}]; // all style datas + + // if the style data of the actual wanted isn't empty + if(styleField!="") + { + // return to all datas and find the main data + for(var si=0; si < allData.length; si++) + { + if(styleField==allData[si]["f"]) + mainData = allData[si]; + } + } + // display the style-field + if(status) + { + toolbar.data(mainData["d"],true); // stil seçme alanının açıldığını belirten parametre yaz + mainData["f"].slideDown(100); // stil seçme alanını aç + + // return to all datas and close the fields of external datas + for(var si=0; si < allData.length; si++) + { + if(mainData["d"]!=allData[si]["d"]) + { + toolbar.data(allData[si]["d"],false); + allData[si]["f"].slideUp(100); + } + } + } + // hide all style-fields + else + { + // return to all datas and close all style fields + for(var si=0; si < allData.length; si++) + { + toolbar.data(allData[si]["d"],false); + allData[si]["f"].slideUp(100); + } + } + } + + // the function of removing all pre-link attribute (mark as "link will be added") + function clearSetElement(elem) + { + jQTE.find(elem).each(function(){ + $(this).before($(this).html()).remove(); + }); + } + + // the function of refusing some styles + function refuseStyle(refStyle) + { + var selectedTag = getSelectedNode(); // the selected node + + // if the selected node have attribute of "style" and it have unwanted style + if(selectedTag && selectedTag.is("[style]") && selectedTag.css(refStyle)!="") + { + var refValue = selectedTag.css(refStyle); // first get key of unwanted style + + selectedTag.css(refStyle,""); // clear unwanted style + + var cleanStyle = selectedTag.attr("style"); // cleaned style + + selectedTag.css(refStyle,refValue); // add unwanted style to the selected node again + + return cleanStyle; // print cleaned style + } + else + return ""; + } + + // the function of adding style to selected text + function selected2format() + { + formatFieldSwitch(true); + + formatbar.find("a").click(function() + { + $("*",this).click(function(e) + { + e.preventDefault(); + return false; + }); + + formatLabelView($(this).text()); + + var formatValue = $(this).attr(vars.css + "-formatval"); // the type of format value + + // convert to selected format + selectionSet("formatBlock",'<'+formatValue+'>'); + + formatFieldSwitch(false); + }); + } + + // the function of switching the style-field + function formatFieldSwitch(status) + { + var thisStatus = status ? true : false; + + thisStatus = status && formatbar.data("status") ? true : false; + + if(thisStatus || !status) + formatbar.data("status",false).slideUp(200); + else + formatbar.data("status",true).slideDown(200); + } + + // change format label + function formatLabelView(str) + { + var formatLabel = formatbar.closest("."+vars.css+"_tool").find("."+vars.css+"_tool_label").find("."+vars.css+"_tool_text"); + + if(str.length > 10) + str = str.substr(0,7) + "..."; + + // change format label of button + formatLabel.html(str); + } + + // the function of insertion a specific form to texts + function extractToText(strings) + { + var $htmlContent, $htmlPattern, $htmlReplace; + + // first remove to unnecessary gaps + $htmlContent = strings.replace(/\n/gim,'').replace(/\r/gim,'').replace(/\t/gim,'').replace(/ /gim,' '); + + $htmlPattern = [ + /\(.*?)<\/span><\/span>/gim, // trim nested spans + /<(\w*[^p])\s*[^\/>]*>\s*<\/\1>/gim, // remove empty or white-spaces tags (ignore paragraphs (

) and breaks (
)) + /\(.*?)\<\/div>/gim, // convert div to p + /\(.*?)\<\/strong>/gim, // convert strong to b + /\(.*?)\<\/em>/gim // convert em to i + ]; + + $htmlReplace = [ + '$3', + '', + '$2

', + '$2', + '$2' + ]; + + // repeat the cleaning process 5 times + for(c=0; c<5; c++) + { + // create loop as the number of pattern + for(var i = 0; i < $htmlPattern.length; i++) + { + $htmlContent = $htmlContent.replace($htmlPattern[i], $htmlReplace[i]); + } + } + + // if paragraph is false (

), convert

to
+ if(!vars.p) + $htmlContent = $htmlContent.replace(/\(.*?)\<\/p>/ig, '
$2'); + + // if break is false (
), convert
to

+ if(!vars.br) + { + $htmlPattern = [ + /\
(.*?)/ig, + /\(.*?)/ig + ]; + + $htmlReplace = [ + '

$1

', + '

$1

' + ]; + + // create loop as the number of pattern (for breaks) + for (var i = 0; i < $htmlPattern.length; i++) { + $htmlContent = $htmlContent.replace($htmlPattern[i], $htmlReplace[i]); + } + } + + // if paragraph and break is false (

&&
), convert

to

+ if(!vars.p && !vars.br) + $htmlContent = $htmlContent.replace(/\

(.*?)\<\/p>/ig, '

$1
'); + + return $htmlContent; + } + + // the function of exporting contents of the text field to the source field (to be the standard in all browsers) + function postToSource() + { + // clear unnecessary tags when editor view empty + var sourceStrings = editor.text()=="" && editor.html().length<12 ? "" : editor.html(); + + thisElement.val(extractToText(sourceStrings)); + } + + // the function of exporting contents of the source field to the text field (to be the standard in all browsers) + function postToEditor() + { + editor.html(extractToText(thisElement.val())); + } + + // the function of getting parent (or super parent) tag name of the selected node + function detectElement(tags){ + + var resultdetect=false, $node = getSelectedNode(), parentsTag; + + if($node) + { + $.each(tags, function(i, val){ + parentsTag = $node.prop('tagName').toLowerCase(); + + if (parentsTag == val) + resultdetect = true; + else + { + $node.parents().each(function(){ + parentsTag = $(this).prop('tagName').toLowerCase(); + if (parentsTag == val) + resultdetect = true; + }); + } + }); + + return resultdetect; + } + else + return false; + }; + + // the function of highlighting the toolbar buttons according to the cursor position in jqte editor + function buttonEmphasize(e) + { + for(var n = 0; n < buttons.length; n++) + { + if(vars[buttons[n].name] && buttons[n].emphasis && buttons[n].tag!='') + detectElement(buttons[n].tag) ? toolbar.find('.'+vars.css+'_tool_'+buttons[n].cls).addClass(emphasize) : $('.'+vars.css+'_tool_'+buttons[n].cls).removeClass(emphasize); + } + // showing text format + if(vars.format && $.isArray(vars.formats)) + { + var isFoundFormat = false; + + for(var f = 0; f < vars.formats.length; f++) + { + var thisFormat = []; + thisFormat[0] = vars.formats[f][0]; + + if(vars.formats[f][0].length>0 && detectElement(thisFormat)) + { + formatLabelView(vars.formats[f][1]); + + isFoundFormat = true; + break; + } + } + + if(!isFoundFormat) + formatLabelView(vars.formats[0][1]); + } + + // hide all style-fields + styleFieldSwitch("",false); + formatFieldSwitch(false); + } + + // the event of click to the toolbar buttons + toolbutton + .unbind("click") + .click(function(e){ + // if source button is clicked + if($(this).data('command')=='displaysource' && !toolbar.data("sourceOpened")) + { + // hide all the toolbar buttons (except the source button) + toolbar.find("."+vars.css+"_tool").addClass(vars.css+"_hiddenField"); + $(this).removeClass(vars.css+"_hiddenField"); + + // update to data of source displaying + toolbar.data("sourceOpened",true); + + // equalize height of the text field with height of the source field + thisElement.css("height",editor.outerHeight()); + + sourceField.removeClass(vars.css+"_hiddenField"); + editor.addClass(vars.css+"_hiddenField"); + thisElement.focus(); + + // hide the link-form-field + linkAreaSwitch(false); + + // hide all style-fields + styleFieldSwitch("",false); + + // hide format field + formatFieldSwitch(); + + // hide placeholder + if(vars.placeholder && vars.placeholder!="") + placeHolder.hide(); + } + // if other buttons is clicked + else + { + // if source field is closed + if(!toolbar.data("sourceOpened")) + { + // if insert-link-button is clicked + if($(this).data('command')=='linkcreator') + { + if(!toolbar.data("linkOpened")) + selected2link(); + else + { + // hide the link-form-field + linkAreaSwitch(false); + + // hide format field + formatFieldSwitch(false); + } + } + + // if the format button is clicked + else if($(this).data('command')=='formats') + { + if($(this).data('command')=='formats' && !$(e.target).hasClass(vars.css+"_format")) + selected2format(); + + // hide all style-fields + styleFieldSwitch("",false); + + if(editor.not(":focus")) + editor.focus(); + } + + // if the style buttons are clicked + else if($(this).data('command')=='fSize' || $(this).data('command')=='colors') + { + if( + ($(this).data('command')=='fSize' && !$(e.target).hasClass(vars.css+"_fontsize")) || // the font-size button + ($(this).data('command')=='colors' && !$(e.target).hasClass(vars.css+"_color")) // the color button + ) + selected2style($(this).data('command')); + + // hide format field + formatFieldSwitch(false); + + if(editor.not(":focus")) + editor.focus(); + } + + // if other buttons is clicked + else + { + // first, prevent to conflict of different jqte editors + if(editor.not(":focus")) + editor.focus(); + + // apply command of clicked button to the selected text + selectionSet($(this).data('command'),null); + + // hide all menu-fields + styleFieldSwitch("",false); + formatFieldSwitch(false); + linktypeSwitch(); + + // to highlight the toolbar buttons according to the cursor position in jqte editor + $(this).data('emphasis')==true && !$(this).hasClass(emphasize) ? $(this).addClass(emphasize) : $(this).removeClass(emphasize); + + sourceField.addClass(vars.css+"_hiddenField"); + editor.removeClass(vars.css+"_hiddenField"); + } + + } + // hide the source field and display the text field + else + { + // update to data of source hiding + toolbar.data("sourceOpened",false); + + // display all the toolbar buttons + toolbar.find("."+vars.css+"_tool").removeClass(vars.css+"_hiddenField"); + + sourceField.addClass(vars.css+"_hiddenField"); + editor.removeClass(vars.css+"_hiddenField"); + } + + if(vars.placeholder && vars.placeholder!="") + editor.html()!="" ? placeHolder.hide() : placeHolder.show(); + } + + // export contents of the text to the sources + editor.trigger("change"); + }) + // the event of showing to the title bubble when mouse over of the toolbar buttons + .hover(function(e){ + if(vars.title && $(this).data("title")!="" && ( $(e.target).hasClass(vars.css+"_tool") || $(e.target).hasClass(vars.css+"_tool_icon") )) + { + $('.'+vars.css+'_title').remove(); + + // create the title bubble + jQTE.append('
'+$(this).data("title")+'
'); + + var thisTitle = $('.'+vars.css+'_title:first'); + var thisArrow = thisTitle.find('.'+vars.css+'_titleArrowIcon'); + var thisPosition = $(this).position(); + var thisAlignX = thisPosition.left + $(this).outerWidth() - (thisTitle.outerWidth()/2) - ($(this).outerWidth()/2); + var thisAlignY = (thisPosition.top + $(this).outerHeight() + 5); + + // show the title bubble and set to its position + thisTitle.delay(400).css({'top':thisAlignY, 'left':thisAlignX}).fadeIn(200); + } + },function(){ + $('.'+vars.css+'_title').remove(); + }); + + // prevent multiple calling postToSource() + var editorChangeTimer = null; + + // the methods of the text fields + editor + + // trigger change method of the text field when the text field modified + .bind("keypress keyup keydown drop cut copy paste DOMCharacterDataModified DOMSubtreeModified",function() + { + // export contents of the text to the sources + if(!toolbar.data("sourceOpened")) + $(this).trigger("change"); + + // hide the link-type-field + linktypeSwitch(); + + // if the change method is added run the change method + if($.isFunction(vars.change)) + vars.change(); + + // the feature of placeholder + if(vars.placeholder && vars.placeholder!="") + $(this).text()!="" ? placeHolder.hide() : placeHolder.show(); + }) + .bind("change",function() + { + if(!toolbar.data("sourceOpened")) + { + clearTimeout(editorChangeTimer); + editorChangeTimer = setTimeout(postToSource,10); + } + }) + + // run to keyboard shortcuts + .keydown(function(e) + { + // if ctrl key is clicked + if(e.ctrlKey) + { + // check all toolbar buttons + for(var n = 0; n < buttons.length; n++) + { + // if this settings of this button is activated (is it true) + // if the keyed button with ctrl is same of hotkey of this button + if(vars[buttons[n].name] && e.keyCode == buttons[n].key.charCodeAt(0)) + { + if(buttons[n].command!='' && buttons[n].command!='linkcreator') + selectionSet(buttons[n].command,null); + + else if(buttons[n].command=='linkcreator') + selected2link(); + + return false; + } + } + } + }) + + // method of triggering to the highlight button + .bind("mouseup keyup",buttonEmphasize) + + // the event of focus to the text field + .focus(function() + { + // if the focus method is added run the focus method + if($.isFunction(vars.focus)) + vars.focus(); + + // add onfocus class + jQTE.addClass(vars.css+"_focused"); + + // prevent focus problem on opera + if(/opera/.test(thisBrowser)) + { + var range = document.createRange(); + range.selectNodeContents(editor[0]); + range.collapse(false); + var selection = window.getSelection(); + selection.removeAllRanges(); + selection.addRange(range); + } + }) + + // the event of focus out from the text field + .focusout(function() + { + // remove to highlights of all toolbar buttons + toolbutton.removeClass(emphasize); + + // hide all menu-fields + styleFieldSwitch("",false); + formatFieldSwitch(false); + linktypeSwitch(); + + // if the blur method is added run the blur method + if($.isFunction(vars.blur)) + vars.blur(); + + // remove onfocus class + jQTE.removeClass(vars.css+"_focused"); + + // show default text format + if($.isArray(vars.formats)) + formatLabelView(vars.formats[0][1]); + }); + + // the event of key in the source field + thisElement + .bind("keydown keyup",function() + { + // export contents of the source to the text field + setTimeout(postToEditor,0); + + // auto extension for the source field + $(this).height($(this)[0].scrollHeight); + + // if the source field is empty, shorten to the source field + if($(this).val()=="") + $(this).height(0); + }) + .focus(function() + { + // add onfocus class + jQTE.addClass(vars.css+"_focused"); + }) + .focusout(function() + { + // remove onfocus class + jQTE.removeClass(vars.css+"_focused"); + }); + }); + }; +})(jQuery); \ No newline at end of file