summaryrefslogtreecommitdiff
path: root/static/website
diff options
context:
space:
mode:
Diffstat (limited to 'static/website')
-rw-r--r--static/website/css/main.css73
-rwxr-xr-x[-rw-r--r--]static/website/js/nicEdit.js1717
-rwxr-xr-x[-rw-r--r--]static/website/js/nicEditorIcons.gifbin3351 -> 3716 bytes
-rw-r--r--static/website/js/thread-user.js147
-rw-r--r--static/website/templates/ajax-keyword-search.html4
-rw-r--r--static/website/templates/ajax-time-search.html4
-rw-r--r--static/website/templates/base.html9
-rw-r--r--static/website/templates/filter.html4
-rw-r--r--static/website/templates/get-question.html278
-rw-r--r--static/website/templates/index.html6
-rw-r--r--static/website/templates/notify.html4
-rw-r--r--static/website/templates/recent_questions.html5
-rw-r--r--static/website/templates/user-answers.html (renamed from static/website/templates/user-replies.html)12
13 files changed, 2084 insertions, 179 deletions
diff --git a/static/website/css/main.css b/static/website/css/main.css
index 4f1f495..ac93f8f 100644
--- a/static/website/css/main.css
+++ b/static/website/css/main.css
@@ -1,5 +1,8 @@
@import url(http://fonts.googleapis.com/css?family=Varela+Round);
/* override bootstrap */
+hr {
+ border-top: 1px solid #424242;
+}
.container>.navbar-header {
height: 45px;
}
@@ -33,7 +36,6 @@ body {
background: #ffffff;
}
#header-inner {
-
}
#logo {
width: 25px;
@@ -51,6 +53,31 @@ body {
}
#content{
}
+.question-critic, .answer-critic {
+ padding-left: 0;
+ padding-top: 15px;
+ text-align: center;
+}
+.question-critic {
+ font-size: 1.3em;
+}
+.answer-critic {
+ font-size: 1em;
+}
+.vote {
+ text-decoration: none;
+ color: #cccccc;
+}
+.vote:hover {
+ text-decoration: none;
+ cursor: pointer;
+}
+.voted {
+ color: orange;
+}
+.question-wrapper {
+ padding-left: 0;
+}
#content .question {
position: relative;
padding: 15px 0 15px 0;
@@ -170,22 +197,56 @@ table .title a {
.saved {
background: lightgreen;
}
-#content .reply {
+.answer-wrapper {
+ padding-left: 0px;
+}
+#content .answer {
position: relative;
border-bottom: 1px solid #f5f5f5;
padding-top: 20px;
padding-bottom: 20px;
margin: 10px 0px;
}
-#content .reply .body {
+#content .answer .body {
}
-#content .reply .user {
+#content .answer .user {
position: absolute;
right: 0px;
bottom: 0px;
padding: 2px 7px;
background: #f5f5f5;
}
+.comments {
+ border-left: 1px solid #cccccc;
+}
+.comments .comment {
+ position: relative;
+ padding: 5px 5px;
+ border-bottom: 1px dotted #cccccc;
+}
+.comments .new-comment {
+ display: none;
+}
+.comments .add-comment {
+ margin: 2px;
+ padding: 1px 2px;
+ color: #000000;
+ background: #f5f5f5;
+}
+.comments .cancel-comment {
+ display: none;
+ margin: 2px;
+ padding: 1px 2px;
+ color: #ffffff;
+ background: #d34836;
+}
+.comments .post-comment {
+ display: none;
+ margin: 2px;
+ padding: 1px 2px;
+ color: #ffffff;
+ background: #42B449;
+}
#footer-wrapper {
max-width: 970px;
margin:0 auto;
@@ -215,7 +276,7 @@ table .title a {
top: 15px;
}
.my-question,
-.my-reply {
+.my-answer {
position: relative;
margin: 10px auto;
padding: 15px;
@@ -223,7 +284,7 @@ table .title a {
background: #f7f7f7;
}
.my-question .date,
-.my-reply .date {
+.my-answer .date {
position: absolute;
right: 5px;
bottom: 5px;
diff --git a/static/website/js/nicEdit.js b/static/website/js/nicEdit.js
index c890433..f915847 100644..100755
--- a/static/website/js/nicEdit.js
+++ b/static/website/js/nicEdit.js
@@ -4,10 +4,250 @@
* NicEdit is distributed under the terms of the MIT license
* For more information visit http://nicedit.com/
* Do not remove this copyright message
- */
-var bkExtend=function(){var A=arguments;if(A.length==1){A=[this,A[0]]}for(var B in A[1]){A[0][B]=A[1][B]}return A[0]};function bkClass(){}bkClass.prototype.construct=function(){};bkClass.extend=function(C){var A=function(){if(arguments[0]!==bkClass){return this.construct.apply(this,arguments)}};var B=new this(bkClass);bkExtend(B,C);A.prototype=B;A.extend=this.extend;return A};var bkElement=bkClass.extend({construct:function(B,A){if(typeof (B)=="string"){B=(A||document).createElement(B)}B=$BK(B);return B},appendTo:function(A){A.appendChild(this);return this},appendBefore:function(A){A.parentNode.insertBefore(this,A);return this},addEvent:function(B,A){bkLib.addEvent(this,B,A);return this},setContent:function(A){this.innerHTML=A;return this},pos:function(){var C=curtop=0;var B=obj=this;if(obj.offsetParent){do{C+=obj.offsetLeft;curtop+=obj.offsetTop}while(obj=obj.offsetParent)}var A=(!window.opera)?parseInt(this.getStyle("border-width")||this.style.border)||0:0;return[C+A,curtop+A+this.offsetHeight]},noSelect:function(){bkLib.noSelect(this);return this},parentTag:function(A){var B=this;do{if(B&&B.nodeName&&B.nodeName.toUpperCase()==A){return B}B=B.parentNode}while(B);return false},hasClass:function(A){return this.className.match(new RegExp("(\\s|^)nicEdit-"+A+"(\\s|$)"))},addClass:function(A){if(!this.hasClass(A)){this.className+=" nicEdit-"+A}return this},removeClass:function(A){if(this.hasClass(A)){this.className=this.className.replace(new RegExp("(\\s|^)nicEdit-"+A+"(\\s|$)")," ")}return this},setStyle:function(A){var B=this.style;for(var C in A){switch(C){case"float":B.cssFloat=B.styleFloat=A[C];break;case"opacity":B.opacity=A[C];B.filter="alpha(opacity="+Math.round(A[C]*100)+")";break;case"className":this.className=A[C];break;default:B[C]=A[C]}}return this},getStyle:function(A,C){var B=(!C)?document.defaultView:C;if(this.nodeType==1){return(B&&B.getComputedStyle)?B.getComputedStyle(this,null).getPropertyValue(A):this.currentStyle[bkLib.camelize(A)]}},remove:function(){this.parentNode.removeChild(this);return this},setAttributes:function(A){for(var B in A){this[B]=A[B]}return this}});var bkLib={isMSIE:(navigator.appVersion.indexOf("MSIE")!=-1),addEvent:function(C,B,A){(C.addEventListener)?C.addEventListener(B,A,false):C.attachEvent("on"+B,A)},toArray:function(C){var B=C.length,A=new Array(B);while(B--){A[B]=C[B]}return A},noSelect:function(B){if(B.setAttribute&&B.nodeName.toLowerCase()!="input"&&B.nodeName.toLowerCase()!="textarea"){B.setAttribute("unselectable","on")}for(var A=0;A<B.childNodes.length;A++){bkLib.noSelect(B.childNodes[A])}},camelize:function(A){return A.replace(/\-(.)/g,function(B,C){return C.toUpperCase()})},inArray:function(A,B){return(bkLib.search(A,B)!=null)},search:function(A,C){for(var B=0;B<A.length;B++){if(A[B]==C){return B}}return null},cancelEvent:function(A){A=A||window.event;if(A.preventDefault&&A.stopPropagation){A.preventDefault();A.stopPropagation()}return false},domLoad:[],domLoaded:function(){if(arguments.callee.done){return }arguments.callee.done=true;for(i=0;i<bkLib.domLoad.length;i++){bkLib.domLoad[i]()}},onDomLoaded:function(A){this.domLoad.push(A);if(document.addEventListener){document.addEventListener("DOMContentLoaded",bkLib.domLoaded,null)}else{if(bkLib.isMSIE){document.write("<style>.nicEdit-main p { margin: 0; }</style><script id=__ie_onload defer "+((location.protocol=="https:")?"src='javascript:void(0)'":"src=//0")+"><\/script>");$BK("__ie_onload").onreadystatechange=function(){if(this.readyState=="complete"){bkLib.domLoaded()}}}}window.onload=bkLib.domLoaded}};function $BK(A){if(typeof (A)=="string"){A=document.getElementById(A)}return(A&&!A.appendTo)?bkExtend(A,bkElement.prototype):A}var bkEvent={addEvent:function(A,B){if(B){this.eventList=this.eventList||{};this.eventList[A]=this.eventList[A]||[];this.eventList[A].push(B)}return this},fireEvent:function(){var A=bkLib.toArray(arguments),C=A.shift();if(this.eventList&&this.eventList[C]){for(var B=0;B<this.eventList[C].length;B++){this.eventList[C][B].apply(this,A)}}}};function __(A){return A}Function.prototype.closure=function(){var A=this,B=bkLib.toArray(arguments),C=B.shift();return function(){if(typeof (bkLib)!="undefined"){return A.apply(C,B.concat(bkLib.toArray(arguments)))}}};Function.prototype.closureListener=function(){var A=this,C=bkLib.toArray(arguments),B=C.shift();return function(E){E=E||window.event;if(E.target){var D=E.target}else{var D=E.srcElement}return A.apply(B,[E,D].concat(C))}};
+ */
+var bkExtend = function(){
+ var args = arguments;
+ if (args.length == 1) args = [this, args[0]];
+ for (var prop in args[1]) args[0][prop] = args[1][prop];
+ return args[0];
+};
+function bkClass() { }
+bkClass.prototype.construct = function() {};
+bkClass.extend = function(def) {
+ var classDef = function() {
+ if (arguments[0] !== bkClass) { return this.construct.apply(this, arguments); }
+ };
+ var proto = new this(bkClass);
+ bkExtend(proto,def);
+ classDef.prototype = proto;
+ classDef.extend = this.extend;
+ return classDef;
+};
+
+var bkElement = bkClass.extend({
+ construct : function(elm,d) {
+ if(typeof(elm) == "string") {
+ elm = (d || document).createElement(elm);
+ }
+ elm = $BK(elm);
+ return elm;
+ },
+ appendTo : function(elm) {
+ elm.appendChild(this);
+ return this;
+ },
+
+ appendBefore : function(elm) {
+ elm.parentNode.insertBefore(this,elm);
+ return this;
+ },
+ addEvent : function(type, fn) {
+ bkLib.addEvent(this,type,fn);
+ return this;
+ },
+
+ setContent : function(c) {
+ this.innerHTML = c;
+ return this;
+ },
+
+ pos : function() {
+ var curleft = curtop = 0;
+ var o = obj = this;
+ if (obj.offsetParent) {
+ do {
+ curleft += obj.offsetLeft;
+ curtop += obj.offsetTop;
+ } while (obj = obj.offsetParent);
+ }
+ var b = (!window.opera) ? parseInt(this.getStyle('border-width') || this.style.border) || 0 : 0;
+ return [curleft+b,curtop+b+this.offsetHeight];
+ },
+
+ noSelect : function() {
+ bkLib.noSelect(this);
+ return this;
+ },
+
+ parentTag : function(t) {
+ var elm = this;
+ do {
+ if(elm && elm.nodeName && elm.nodeName.toUpperCase() == t) {
+ return elm;
+ }
+ elm = elm.parentNode;
+ } while(elm);
+ return false;
+ },
+
+ hasClass : function(cls) {
+ return this.className.match(new RegExp('(\\s|^)nicEdit-'+cls+'(\\s|$)'));
+ },
+
+ addClass : function(cls) {
+ if (!this.hasClass(cls)) { this.className += " nicEdit-"+cls };
+ return this;
+ },
+
+ removeClass : function(cls) {
+ if (this.hasClass(cls)) {
+ this.className = this.className.replace(new RegExp('(\\s|^)nicEdit-'+cls+'(\\s|$)'),' ');
+ }
+ return this;
+ },
+
+ setStyle : function(st) {
+ var elmStyle = this.style;
+ for(var itm in st) {
+ switch(itm) {
+ case 'float':
+ elmStyle['cssFloat'] = elmStyle['styleFloat'] = st[itm];
+ break;
+ case 'opacity':
+ elmStyle.opacity = st[itm];
+ elmStyle.filter = "alpha(opacity=" + Math.round(st[itm]*100) + ")";
+ break;
+ case 'className':
+ this.className = st[itm];
+ break;
+ default:
+ //if(document.compatMode || itm != "cursor") { // Nasty Workaround for IE 5.5
+ elmStyle[itm] = st[itm];
+ //}
+ }
+ }
+ return this;
+ },
+
+ getStyle : function( cssRule, d ) {
+ var doc = (!d) ? document.defaultView : d;
+ if(this.nodeType == 1)
+ return (doc && doc.getComputedStyle) ? doc.getComputedStyle( this, null ).getPropertyValue(cssRule) : this.currentStyle[ bkLib.camelize(cssRule) ];
+ },
+
+ remove : function() {
+ this.parentNode.removeChild(this);
+ return this;
+ },
+
+ setAttributes : function(at) {
+ for(var itm in at) {
+ this[itm] = at[itm];
+ }
+ return this;
+ }
+});
+
+var bkLib = {
+ isMSIE : (navigator.appVersion.indexOf("MSIE") != -1),
+
+ addEvent : function(obj, type, fn) {
+ (obj.addEventListener) ? obj.addEventListener( type, fn, false ) : obj.attachEvent("on"+type, fn);
+ },
+
+ toArray : function(iterable) {
+ var length = iterable.length, results = new Array(length);
+ while (length--) { results[length] = iterable[length] };
+ return results;
+ },
+
+ noSelect : function(element) {
+ if(element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
+ element.setAttribute('unselectable','on');
+ }
+ for(var i=0;i<element.childNodes.length;i++) {
+ bkLib.noSelect(element.childNodes[i]);
+ }
+ },
+ camelize : function(s) {
+ return s.replace(/\-(.)/g, function(m, l){return l.toUpperCase()});
+ },
+ inArray : function(arr,item) {
+ return (bkLib.search(arr,item) != null);
+ },
+ search : function(arr,itm) {
+ for(var i=0; i < arr.length; i++) {
+ if(arr[i] == itm)
+ return i;
+ }
+ return null;
+ },
+ cancelEvent : function(e) {
+ e = e || window.event;
+ if(e.preventDefault && e.stopPropagation) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ return false;
+ },
+ domLoad : [],
+ domLoaded : function() {
+ if (arguments.callee.done) return;
+ arguments.callee.done = true;
+ for (i = 0;i < bkLib.domLoad.length;i++) bkLib.domLoad[i]();
+ },
+ onDomLoaded : function(fireThis) {
+ this.domLoad.push(fireThis);
+ if (document.addEventListener) {
+ document.addEventListener("DOMContentLoaded", bkLib.domLoaded, null);
+ } else if(bkLib.isMSIE) {
+ document.write("<style>.nicEdit-main p { margin: 0; }</style><scr"+"ipt id=__ie_onload defer " + ((location.protocol == "https:") ? "src='javascript:void(0)'" : "src=//0") + "><\/scr"+"ipt>");
+ $BK("__ie_onload").onreadystatechange = function() {
+ if (this.readyState == "complete"){bkLib.domLoaded();}
+ };
+ }
+ window.onload = bkLib.domLoaded;
+ }
+};
+
+function $BK(elm) {
+ if(typeof(elm) == "string") {
+ elm = document.getElementById(elm);
+ }
+ return (elm && !elm.appendTo) ? bkExtend(elm,bkElement.prototype) : elm;
+}
+
+var bkEvent = {
+ addEvent : function(evType, evFunc) {
+ if(evFunc) {
+ this.eventList = this.eventList || {};
+ this.eventList[evType] = this.eventList[evType] || [];
+ this.eventList[evType].push(evFunc);
+ }
+ return this;
+ },
+ fireEvent : function() {
+ var args = bkLib.toArray(arguments), evType = args.shift();
+ if(this.eventList && this.eventList[evType]) {
+ for(var i=0;i<this.eventList[evType].length;i++) {
+ this.eventList[evType][i].apply(this,args);
+ }
+ }
+ }
+};
+
+function __(s) {
+ return s;
+}
+
+Function.prototype.closure = function() {
+ var __method = this, args = bkLib.toArray(arguments), obj = args.shift();
+ return function() { if(typeof(bkLib) != 'undefined') { return __method.apply(obj,args.concat(bkLib.toArray(arguments))); } };
+}
+
+Function.prototype.closureListener = function() {
+ var __method = this, args = bkLib.toArray(arguments), object = args.shift();
+ return function(e) {
+ e = e || window.event;
+ if(e.target) { var target = e.target; } else { var target = e.srcElement };
+ return __method.apply(object, [e,target].concat(args) );
+ };
+}
+
+
+/* START CONFIG */
var nicEditorConfig = bkClass.extend({
buttons : {
@@ -30,27 +270,784 @@ var nicEditorConfig = bkClass.extend({
},
iconsPath : '../nicEditorIcons.gif',
buttonList : ['save','bold','italic','underline','left','center','right','justify','ol','ul','fontSize','fontFamily','fontFormat','indent','outdent','image','upload','link','unlink','forecolor','bgcolor'],
- iconList : {"bgcolor":1,"forecolor":2,"bold":3,"center":4,"hr":5,"indent":6,"italic":7,"justify":8,"left":9,"ol":10,"outdent":11,"removeformat":12,"right":13,"save":24,"strikethrough":15,"subscript":16,"superscript":17,"ul":18,"underline":19,"image":20,"link":21,"unlink":22,"close":23,"arrow":25}
-
-});
-;
-var nicEditors={nicPlugins:[],editors:[],registerPlugin:function(B,A){this.nicPlugins.push({p:B,o:A})},allTextAreas:function(C){var A=document.getElementsByTagName("textarea");for(var B=0;B<A.length;B++){nicEditors.editors.push(new nicEditor(C).panelInstance(A[B]))}return nicEditors.editors},findEditor:function(C){var B=nicEditors.editors;for(var A=0;A<B.length;A++){if(B[A].instanceById(C)){return B[A].instanceById(C)}}}};var nicEditor=bkClass.extend({construct:function(C){this.options=new nicEditorConfig();bkExtend(this.options,C);this.nicInstances=new Array();this.loadedPlugins=new Array();var A=nicEditors.nicPlugins;for(var B=0;B<A.length;B++){this.loadedPlugins.push(new A[B].p(this,A[B].o))}nicEditors.editors.push(this);bkLib.addEvent(document.body,"mousedown",this.selectCheck.closureListener(this))},panelInstance:function(B,C){B=this.checkReplace($BK(B));var A=new bkElement("DIV").setStyle({width:(parseInt(B.getStyle("width"))||B.clientWidth)+"px"}).appendBefore(B);this.setPanel(A);return this.addInstance(B,C)},checkReplace:function(B){var A=nicEditors.findEditor(B);if(A){A.removeInstance(B);A.removePanel()}return B},addInstance:function(B,C){B=this.checkReplace($BK(B));if(B.contentEditable||!!window.opera){var A=new nicEditorInstance(B,C,this)}else{var A=new nicEditorIFrameInstance(B,C,this)}this.nicInstances.push(A);return this},removeInstance:function(C){C=$BK(C);var B=this.nicInstances;for(var A=0;A<B.length;A++){if(B[A].e==C){B[A].remove();this.nicInstances.splice(A,1)}}},removePanel:function(A){if(this.nicPanel){this.nicPanel.remove();this.nicPanel=null}},instanceById:function(C){C=$BK(C);var B=this.nicInstances;for(var A=0;A<B.length;A++){if(B[A].e==C){return B[A]}}},setPanel:function(A){this.nicPanel=new nicEditorPanel($BK(A),this.options,this);this.fireEvent("panel",this.nicPanel);return this},nicCommand:function(B,A){if(this.selectedInstance){this.selectedInstance.nicCommand(B,A)}},getIcon:function(D,A){var C=this.options.iconList[D];var B=(A.iconFiles)?A.iconFiles[D]:"";return{backgroundImage:"url('"+((C)?this.options.iconsPath:B)+"')",backgroundPosition:((C)?((C-1)*-18):0)+"px 0px"}},selectCheck:function(C,A){var B=false;do{if(A.className&&A.className.indexOf("nicEdit")!=-1){return false}}while(A=A.parentNode);this.fireEvent("blur",this.selectedInstance,A);this.lastSelectedInstance=this.selectedInstance;this.selectedInstance=null;return false}});nicEditor=nicEditor.extend(bkEvent);
-var nicEditorInstance=bkClass.extend({isSelected:false,construct:function(G,D,C){this.ne=C;this.elm=this.e=G;this.options=D||{};newX=parseInt(G.getStyle("width"))||G.clientWidth;newY=parseInt(G.getStyle("height"))||G.clientHeight;this.initialHeight=newY-8;var H=(G.nodeName.toLowerCase()=="textarea");if(H||this.options.hasPanel){var B=(bkLib.isMSIE&&!((typeof document.body.style.maxHeight!="undefined")&&document.compatMode=="CSS1Compat"));var E={width:newX+"px",border:"1px solid #ccc",borderTop:0,overflowY:"auto",overflowX:"hidden"};E[(B)?"height":"maxHeight"]=(this.ne.options.maxHeight)?this.ne.options.maxHeight+"px":null;this.editorContain=new bkElement("DIV").setStyle(E).appendBefore(G);var A=new bkElement("DIV").setStyle({width:(newX-8)+"px",margin:"4px",minHeight:newY+"px"}).addClass("main").appendTo(this.editorContain);G.setStyle({display:"none"});A.innerHTML=G.innerHTML;if(H){A.setContent(G.value);this.copyElm=G;var F=G.parentTag("FORM");if(F){bkLib.addEvent(F,"submit",this.saveContent.closure(this))}}A.setStyle((B)?{height:newY+"px"}:{overflow:"hidden"});this.elm=A}this.ne.addEvent("blur",this.blur.closure(this));this.init();this.blur()},init:function(){this.elm.setAttribute("contentEditable","true");if(this.getContent()==""){this.setContent("<br />")}this.instanceDoc=document.defaultView;this.elm.addEvent("mousedown",this.selected.closureListener(this)).addEvent("keypress",this.keyDown.closureListener(this)).addEvent("focus",this.selected.closure(this)).addEvent("blur",this.blur.closure(this)).addEvent("keyup",this.selected.closure(this));this.ne.fireEvent("add",this)},remove:function(){this.saveContent();if(this.copyElm||this.options.hasPanel){this.editorContain.remove();this.e.setStyle({display:"block"});this.ne.removePanel()}this.disable();this.ne.fireEvent("remove",this)},disable:function(){this.elm.setAttribute("contentEditable","false")},getSel:function(){return(window.getSelection)?window.getSelection():document.selection},getRng:function(){var A=this.getSel();if(!A||A.rangeCount===0){return }return(A.rangeCount>0)?A.getRangeAt(0):A.createRange()},selRng:function(A,B){if(window.getSelection){B.removeAllRanges();B.addRange(A)}else{A.select()}},selElm:function(){var C=this.getRng();if(!C){return }if(C.startContainer){var D=C.startContainer;if(C.cloneContents().childNodes.length==1){for(var B=0;B<D.childNodes.length;B++){var A=D.childNodes[B].ownerDocument.createRange();A.selectNode(D.childNodes[B]);if(C.compareBoundaryPoints(Range.START_TO_START,A)!=1&&C.compareBoundaryPoints(Range.END_TO_END,A)!=-1){return $BK(D.childNodes[B])}}}return $BK(D)}else{return $BK((this.getSel().type=="Control")?C.item(0):C.parentElement())}},saveRng:function(){this.savedRange=this.getRng();this.savedSel=this.getSel()},restoreRng:function(){if(this.savedRange){this.selRng(this.savedRange,this.savedSel)}},keyDown:function(B,A){if(B.ctrlKey){this.ne.fireEvent("key",this,B)}},selected:function(C,A){if(!A&&!(A=this.selElm)){A=this.selElm()}if(!C.ctrlKey){var B=this.ne.selectedInstance;if(B!=this){if(B){this.ne.fireEvent("blur",B,A)}this.ne.selectedInstance=this;this.ne.fireEvent("focus",B,A)}this.ne.fireEvent("selected",B,A);this.isFocused=true;this.elm.addClass("selected")}return false},blur:function(){this.isFocused=false;this.elm.removeClass("selected")},saveContent:function(){if(this.copyElm||this.options.hasPanel){this.ne.fireEvent("save",this);(this.copyElm)?this.copyElm.value=this.getContent():this.e.innerHTML=this.getContent()}},getElm:function(){return this.elm},getContent:function(){this.content=this.getElm().innerHTML;this.ne.fireEvent("get",this);return this.content},setContent:function(A){this.content=A;this.ne.fireEvent("set",this);this.elm.innerHTML=this.content},nicCommand:function(B,A){document.execCommand(B,false,A)}});
-var nicEditorIFrameInstance=nicEditorInstance.extend({savedStyles:[],init:function(){var B=this.elm.innerHTML.replace(/^\s+|\s+$/g,"");this.elm.innerHTML="";(!B)?B="<br />":B;this.initialContent=B;this.elmFrame=new bkElement("iframe").setAttributes({src:"javascript:;",frameBorder:0,allowTransparency:"true",scrolling:"no"}).setStyle({height:"100px",width:"100%"}).addClass("frame").appendTo(this.elm);if(this.copyElm){this.elmFrame.setStyle({width:(this.elm.offsetWidth-4)+"px"})}var A=["font-size","font-family","font-weight","color"];for(itm in A){this.savedStyles[bkLib.camelize(itm)]=this.elm.getStyle(itm)}setTimeout(this.initFrame.closure(this),50)},disable:function(){this.elm.innerHTML=this.getContent()},initFrame:function(){var B=$BK(this.elmFrame.contentWindow.document);B.designMode="on";B.open();var A=this.ne.options.externalCSS;B.write("<html><head>"+((A)?'<link href="'+A+'" rel="stylesheet" type="text/css" />':"")+'</head><body id="nicEditContent" style="margin: 0 !important; background-color: transparent !important;">'+this.initialContent+"</body></html>");B.close();this.frameDoc=B;this.frameWin=$BK(this.elmFrame.contentWindow);this.frameContent=$BK(this.frameWin.document.body).setStyle(this.savedStyles);this.instanceDoc=this.frameWin.document.defaultView;this.heightUpdate();this.frameDoc.addEvent("mousedown",this.selected.closureListener(this)).addEvent("keyup",this.heightUpdate.closureListener(this)).addEvent("keydown",this.keyDown.closureListener(this)).addEvent("keyup",this.selected.closure(this));this.ne.fireEvent("add",this)},getElm:function(){return this.frameContent},setContent:function(A){this.content=A;this.ne.fireEvent("set",this);this.frameContent.innerHTML=this.content;this.heightUpdate()},getSel:function(){return(this.frameWin)?this.frameWin.getSelection():this.frameDoc.selection},heightUpdate:function(){this.elmFrame.style.height=Math.max(this.frameContent.offsetHeight,this.initialHeight)+"px"},nicCommand:function(B,A){this.frameDoc.execCommand(B,false,A);setTimeout(this.heightUpdate.closure(this),100)}});
-var nicEditorPanel=bkClass.extend({construct:function(E,B,A){this.elm=E;this.options=B;this.ne=A;this.panelButtons=new Array();this.buttonList=bkExtend([],this.ne.options.buttonList);this.panelContain=new bkElement("DIV").setStyle({overflow:"hidden",width:"100%",border:"1px solid #cccccc",backgroundColor:"#efefef"}).addClass("panelContain");this.panelElm=new bkElement("DIV").setStyle({margin:"2px",marginTop:"0px",zoom:1,overflow:"hidden"}).addClass("panel").appendTo(this.panelContain);this.panelContain.appendTo(E);var C=this.ne.options;var D=C.buttons;for(button in D){this.addButton(button,C,true)}this.reorder();E.noSelect()},addButton:function(buttonName,options,noOrder){var button=options.buttons[buttonName];var type=(button.type)?eval("(typeof("+button.type+') == "undefined") ? null : '+button.type+";"):nicEditorButton;var hasButton=bkLib.inArray(this.buttonList,buttonName);if(type&&(hasButton||this.ne.options.fullPanel)){this.panelButtons.push(new type(this.panelElm,buttonName,options,this.ne));if(!hasButton){this.buttonList.push(buttonName)}}},findButton:function(B){for(var A=0;A<this.panelButtons.length;A++){if(this.panelButtons[A].name==B){return this.panelButtons[A]}}},reorder:function(){var C=this.buttonList;for(var B=0;B<C.length;B++){var A=this.findButton(C[B]);if(A){this.panelElm.appendChild(A.margin)}}},remove:function(){this.elm.remove()}});
-var nicEditorButton=bkClass.extend({construct:function(D,A,C,B){this.options=C.buttons[A];this.name=A;this.ne=B;this.elm=D;this.margin=new bkElement("DIV").setStyle({"float":"left",marginTop:"2px"}).appendTo(D);this.contain=new bkElement("DIV").setStyle({width:"20px",height:"20px"}).addClass("buttonContain").appendTo(this.margin);this.border=new bkElement("DIV").setStyle({backgroundColor:"#efefef",border:"1px solid #efefef"}).appendTo(this.contain);this.button=new bkElement("DIV").setStyle({width:"18px",height:"18px",overflow:"hidden",zoom:1,cursor:"pointer"}).addClass("button").setStyle(this.ne.getIcon(A,C)).appendTo(this.border);this.button.addEvent("mouseover",this.hoverOn.closure(this)).addEvent("mouseout",this.hoverOff.closure(this)).addEvent("mousedown",this.mouseClick.closure(this)).noSelect();if(!window.opera){this.button.onmousedown=this.button.onclick=bkLib.cancelEvent}B.addEvent("selected",this.enable.closure(this)).addEvent("blur",this.disable.closure(this)).addEvent("key",this.key.closure(this));this.disable();this.init()},init:function(){},hide:function(){this.contain.setStyle({display:"none"})},updateState:function(){if(this.isDisabled){this.setBg()}else{if(this.isHover){this.setBg("hover")}else{if(this.isActive){this.setBg("active")}else{this.setBg()}}}},setBg:function(A){switch(A){case"hover":var B={border:"1px solid #666",backgroundColor:"#ddd"};break;case"active":var B={border:"1px solid #666",backgroundColor:"#ccc"};break;default:var B={border:"1px solid #efefef",backgroundColor:"#efefef"}}this.border.setStyle(B).addClass("button-"+A)},checkNodes:function(A){var B=A;do{if(this.options.tags&&bkLib.inArray(this.options.tags,B.nodeName)){this.activate();return true}}while(B=B.parentNode&&B.className!="nicEdit");B=$BK(A);while(B.nodeType==3){B=$BK(B.parentNode)}if(this.options.css){for(itm in this.options.css){if(B.getStyle(itm,this.ne.selectedInstance.instanceDoc)==this.options.css[itm]){this.activate();return true}}}this.deactivate();return false},activate:function(){if(!this.isDisabled){this.isActive=true;this.updateState();this.ne.fireEvent("buttonActivate",this)}},deactivate:function(){this.isActive=false;this.updateState();if(!this.isDisabled){this.ne.fireEvent("buttonDeactivate",this)}},enable:function(A,B){this.isDisabled=false;this.contain.setStyle({opacity:1}).addClass("buttonEnabled");this.updateState();this.checkNodes(B)},disable:function(A,B){this.isDisabled=true;this.contain.setStyle({opacity:0.6}).removeClass("buttonEnabled");this.updateState()},toggleActive:function(){(this.isActive)?this.deactivate():this.activate()},hoverOn:function(){if(!this.isDisabled){this.isHover=true;this.updateState();this.ne.fireEvent("buttonOver",this)}},hoverOff:function(){this.isHover=false;this.updateState();this.ne.fireEvent("buttonOut",this)},mouseClick:function(){if(this.options.command){this.ne.nicCommand(this.options.command,this.options.commandArgs);if(!this.options.noActive){this.toggleActive()}}this.ne.fireEvent("buttonClick",this)},key:function(A,B){if(this.options.key&&B.ctrlKey&&String.fromCharCode(B.keyCode||B.charCode).toLowerCase()==this.options.key){this.mouseClick();if(B.preventDefault){B.preventDefault()}}}});
-var nicPlugin=bkClass.extend({construct:function(B,A){this.options=A;this.ne=B;this.ne.addEvent("panel",this.loadPanel.closure(this));this.init()},loadPanel:function(C){var B=this.options.buttons;for(var A in B){C.addButton(A,this.options)}C.reorder()},init:function(){}});
-
+ iconList : {"xhtml":1,"bgcolor":2,"forecolor":3,"bold":4,"center":5,"hr":6,"indent":7,"italic":8,"justify":9,"left":10,"ol":11,"outdent":12,"removeformat":13,"right":14,"save":25,"strikethrough":16,"subscript":17,"superscript":18,"ul":19,"underline":20,"image":21,"link":22,"unlink":23,"close":24,"arrow":26,"upload":27},
+ initWithLineBreak: true
+});
+/* END CONFIG */
+
+
+var nicEditors = {
+ nicPlugins : [],
+ editors : [],
+
+ registerPlugin : function(plugin,options) {
+ this.nicPlugins.push({p : plugin, o : options});
+ },
+
+ allTextAreas : function(nicOptions) {
+ var textareas = document.getElementsByTagName("textarea");
+ for(var i=0;i<textareas.length;i++) {
+ nicEditors.editors.push(new nicEditor(nicOptions).panelInstance(textareas[i]));
+ }
+ return nicEditors.editors;
+ },
+
+ findEditor : function(e) {
+ var editors = nicEditors.editors;
+ for(var i=0;i<editors.length;i++) {
+ if(editors[i].instanceById(e)) {
+ return editors[i]; // r is an instance of nicEditorInstance therefore it does not have removeInstance or removePanel methods
+ }
+ }
+ }
+};
+
+
+var nicEditor = bkClass.extend({
+ construct : function(o) {
+ this.options = new nicEditorConfig();
+ bkExtend(this.options,o);
+ this.nicInstances = new Array();
+ this.loadedPlugins = new Array();
+
+ var plugins = nicEditors.nicPlugins;
+ for(var i=0;i<plugins.length;i++) {
+ this.loadedPlugins.push(new plugins[i].p(this,plugins[i].o));
+ }
+ nicEditors.editors.push(this);
+ bkLib.addEvent(document.body,'mousedown', this.selectCheck.closureListener(this) );
+ },
+
+ panelInstance : function(e,o) {
+ e = this.checkReplace($BK(e));
+ var panelElm = new bkElement('DIV').setStyle({width : (parseInt(e.getStyle('width')) || e.clientWidth)+'px'}).appendBefore(e);
+ this.setPanel(panelElm);
+ return this.addInstance(e,o);
+ },
+
+ checkReplace : function(e) {
+ var r = nicEditors.findEditor(e);
+ if(r) {
+ r.removeInstance(e);
+ r.removePanel();
+ }
+ return e;
+ },
+
+ addInstance : function(e,o) {
+ e = this.checkReplace($BK(e));
+ if( e.contentEditable || !!window.opera ) {
+ var newInstance = new nicEditorInstance(e,o,this);
+ } else {
+ var newInstance = new nicEditorIFrameInstance(e,o,this);
+ }
+ this.nicInstances.push(newInstance);
+ return this;
+ },
+
+ removeInstance : function(e) {
+ e = $BK(e);
+ var instances = this.nicInstances;
+ for(var i=0;i<instances.length;i++) {
+ if(instances[i].e == e) {
+ instances[i].remove();
+ this.nicInstances.splice(i,1);
+ }
+ }
+ },
+
+ removePanel : function(e) {
+ if(this.nicPanel) {
+ this.nicPanel.remove();
+ this.nicPanel = null;
+ }
+ },
+
+ instanceById : function(e) {
+ e = $BK(e);
+ var instances = this.nicInstances;
+ for(var i=0;i<instances.length;i++) {
+ if(instances[i].e == e) {
+ return instances[i];
+ }
+ }
+ },
+
+ setPanel : function(e) {
+ this.nicPanel = new nicEditorPanel($BK(e),this.options,this);
+ this.fireEvent('panel',this.nicPanel);
+ return this;
+ },
+
+ nicCommand : function(cmd,args) {
+ if(this.selectedInstance) {
+ this.selectedInstance.nicCommand(cmd,args);
+ }
+ },
+
+ getIcon : function(iconName,options) {
+ var icon = this.options.iconList[iconName];
+ var file = (options.iconFiles) ? options.iconFiles[iconName] : '';
+ return {backgroundImage : "url('"+((icon) ? this.options.iconsPath : file)+"')", backgroundPosition : ((icon) ? ((icon-1)*-18) : 0)+'px 0px'};
+ },
+
+ selectCheck : function(e,t) {
+ var found = false;
+ do{
+ if(t.className && t.className.indexOf('nicEdit') != -1) {
+ return false;
+ }
+ } while(t = t.parentNode);
+ this.fireEvent('blur',this.selectedInstance,t);
+ this.lastSelectedInstance = this.selectedInstance;
+ this.selectedInstance = null;
+ return false;
+ }
+
+});
+nicEditor = nicEditor.extend(bkEvent);
+
+
+var nicEditorInstance = bkClass.extend({
+ isSelected : false,
+
+ construct : function(e,options,nicEditor) {
+ this.ne = nicEditor;
+ this.elm = this.e = e;
+ this.options = options || {};
+
+ newX = parseInt(e.getStyle('width')) || e.clientWidth;
+ newY = parseInt(e.getStyle('height')) || e.clientHeight;
+ this.initialHeight = newY-8;
+
+ var isTextarea = (e.nodeName.toLowerCase() == "textarea");
+ if(isTextarea || this.options.hasPanel) {
+ var ie7s = (bkLib.isMSIE && !((typeof document.body.style.maxHeight != "undefined") && document.compatMode == "CSS1Compat"))
+ var s = {width: newX+'px', border : '1px solid #ccc', borderTop : 0, overflowY : 'auto', overflowX: 'hidden' };
+ s[(ie7s) ? 'height' : 'maxHeight'] = (this.ne.options.maxHeight) ? this.ne.options.maxHeight+'px' : null;
+ this.editorContain = new bkElement('DIV').setStyle(s).appendBefore(e);
+ var editorElm = new bkElement('DIV').setStyle({width : (newX-8)+'px', margin: '4px', minHeight : newY+'px'}).addClass('main').appendTo(this.editorContain);
+
+ e.setStyle({display : 'none'});
+
+ editorElm.innerHTML = e.innerHTML;
+ if(isTextarea) {
+ editorElm.setContent(e.value);
+ this.copyElm = e;
+ var f = e.parentTag('FORM');
+ if(f) { bkLib.addEvent( f, 'submit', this.saveContent.closure(this)); }
+ }
+ editorElm.setStyle((ie7s) ? {height : newY+'px'} : {overflow: 'hidden'});
+ this.elm = editorElm;
+ }
+ this.ne.addEvent('blur',this.blur.closure(this));
+
+ this.init();
+ this.blur();
+ },
+
+ init : function() {
+ this.elm.setAttribute('contentEditable','true');
+ if(this.getContent() == "" && this.options.initWithLineBreak) {
+ this.setContent('<br />');
+ }
+ this.instanceDoc = document.defaultView;
+ this.elm.addEvent('mousedown',this.selected.closureListener(this)).addEvent('keypress',this.keyDown.closureListener(this)).addEvent('focus',this.selected.closure(this)).addEvent('blur',this.blur.closure(this)).addEvent('keyup',this.selected.closure(this));
+ this.ne.fireEvent('add',this);
+ },
+
+ remove : function() {
+ this.saveContent();
+ if(this.copyElm || this.options.hasPanel) {
+ this.editorContain.remove();
+ this.e.setStyle({'display' : 'block'});
+ this.ne.removePanel();
+ }
+ this.disable();
+ this.ne.fireEvent('remove',this);
+ },
+
+ disable : function() {
+ this.elm.setAttribute('contentEditable','false');
+ },
+
+ getSel : function() {
+ return (window.getSelection) ? window.getSelection() : document.selection;
+ },
+
+ getRng : function() {
+ var s = this.getSel();
+ if(!s) { return null; }
+ return (s.rangeCount > 0) ? s.getRangeAt(0) :
+ s.createRange && s.createRange() || document.createRange();
+ },
+
+ selRng : function(rng,s) {
+ if(window.getSelection) {
+ s.removeAllRanges();
+ s.addRange(rng);
+ } else {
+ rng.select();
+ }
+ },
+
+ selElm : function() {
+ var r = this.getRng();
+ if(r.startContainer) {
+ var contain = r.startContainer;
+ if(r.cloneContents().childNodes.length == 1) {
+ for(var i=0;i<contain.childNodes.length;i++) {
+ var rng = contain.childNodes[i].ownerDocument.createRange();
+ rng.selectNode(contain.childNodes[i]);
+ if(r.compareBoundaryPoints(Range.START_TO_START,rng) != 1 &&
+ r.compareBoundaryPoints(Range.END_TO_END,rng) != -1) {
+ return $BK(contain.childNodes[i]);
+ }
+ }
+ }
+ return $BK(contain);
+ } else {
+ return $BK((this.getSel().type == "Control") ? r.item(0) : r.parentElement());
+ }
+ },
+
+ saveRng : function() {
+ this.savedRange = this.getRng();
+ this.savedSel = this.getSel();
+ },
+
+ restoreRng : function() {
+ if(this.savedRange) {
+ this.selRng(this.savedRange,this.savedSel);
+ }
+ },
+
+ keyDown : function(e,t) {
+ this.ne.fireEvent('keyDown',this,e);
+
+ if(e.ctrlKey) {
+ this.ne.fireEvent('key',this,e);
+ }
+ },
+
+ selected : function(e,t) {
+ if(!t) {t = this.selElm()}
+ if(!e.ctrlKey) {
+ var selInstance = this.ne.selectedInstance;
+ if(selInstance != this) {
+ if(selInstance) {
+ this.ne.fireEvent('blur',selInstance,t);
+ }
+ this.ne.selectedInstance = this;
+ this.ne.fireEvent('focus',selInstance,t);
+ }
+ this.ne.fireEvent('selected',selInstance,t);
+ this.isFocused = true;
+ this.elm.addClass('selected');
+ }
+ return false;
+ },
+
+ blur : function() {
+ this.isFocused = false;
+ this.elm.removeClass('selected');
+ },
+
+ saveContent : function() {
+ if(this.copyElm || this.options.hasPanel) {
+ this.ne.fireEvent('save',this);
+ (this.copyElm) ? this.copyElm.value = this.getContent() : this.e.innerHTML = this.getContent();
+ }
+ },
+
+ getElm : function() {
+ return this.elm;
+ },
+
+ getContent : function() {
+ this.content = this.getElm().innerHTML;
+ this.ne.fireEvent('get',this);
+ return this.content;
+ },
+
+ setContent : function(e) {
+ this.content = e;
+ this.ne.fireEvent('set',this);
+ this.elm.innerHTML = this.content;
+ },
+
+ nicCommand : function(cmd,args) {
+ document.execCommand(cmd,false,args);
+ }
+});
+
+var nicEditorIFrameInstance = nicEditorInstance.extend({
+ savedStyles : [],
+
+ init : function() {
+ var c = this.elm.innerHTML.replace(/^\s+|\s+$/g, '');
+ this.elm.innerHTML = '';
+ (!c) ? c = "<br />" : c;
+ this.initialContent = c;
+
+ this.elmFrame = new bkElement('iframe').setAttributes({'src' : 'javascript:;', 'frameBorder' : 0, 'allowTransparency' : 'true', 'scrolling' : 'no'}).setStyle({height: '100px', width: '100%'}).addClass('frame').appendTo(this.elm);
+
+ if(this.copyElm) { this.elmFrame.setStyle({width : (this.elm.offsetWidth-4)+'px'}); }
+
+ var styleList = ['font-size','font-family','font-weight','color'];
+ for(itm in styleList) {
+ this.savedStyles[bkLib.camelize(itm)] = this.elm.getStyle(itm);
+ }
+
+ setTimeout(this.initFrame.closure(this),50);
+ },
+
+ disable : function() {
+ this.elm.innerHTML = this.getContent();
+ },
+
+ initFrame : function() {
+ var fd = $BK(this.elmFrame.contentWindow.document);
+ fd.designMode = "on";
+ fd.open();
+ var css = this.ne.options.externalCSS;
+ fd.write('<html><head>'+((css) ? '<link href="'+css+'" rel="stylesheet" type="text/css" />' : '')+'</head><body id="nicEditContent" style="margin: 0 !important; background-color: transparent !important;">'+this.initialContent+'</body></html>');
+ fd.close();
+ this.frameDoc = fd;
+
+ this.frameWin = $BK(this.elmFrame.contentWindow);
+ this.frameContent = $BK(this.frameWin.document.body).setStyle(this.savedStyles);
+ this.instanceDoc = this.frameWin.document.defaultView;
+
+ this.heightUpdate();
+ this.frameDoc.addEvent('mousedown', this.selected.closureListener(this)).addEvent('keyup',this.heightUpdate.closureListener(this)).addEvent('keydown',this.keyDown.closureListener(this)).addEvent('keyup',this.selected.closure(this));
+ this.ne.fireEvent('add',this);
+ },
+
+ getElm : function() {
+ return this.frameContent;
+ },
+
+ setContent : function(c) {
+ this.content = c;
+ this.ne.fireEvent('set',this);
+ this.frameContent.innerHTML = this.content;
+ this.heightUpdate();
+ },
+
+ getSel : function() {
+ return (this.frameWin) ? this.frameWin.getSelection() : this.frameDoc.selection;
+ },
+
+ heightUpdate : function() {
+ this.elmFrame.style.height = Math.max(this.frameContent.offsetHeight,this.initialHeight)+'px';
+ },
+
+ nicCommand : function(cmd,args) {
+ this.frameDoc.execCommand(cmd,false,args);
+ setTimeout(this.heightUpdate.closure(this),100);
+ }
+
+
+});
+var nicEditorPanel = bkClass.extend({
+ construct : function(e,options,nicEditor) {
+ this.elm = e;
+ this.options = options;
+ this.ne = nicEditor;
+ this.panelButtons = new Array();
+ this.buttonList = bkExtend([],this.ne.options.buttonList);
+
+ this.panelContain = new bkElement('DIV').setStyle({overflow : 'hidden', width : '100%', border : '1px solid #cccccc', backgroundColor : '#efefef'}).addClass('panelContain');
+ this.panelElm = new bkElement('DIV').setStyle({margin : '2px', marginTop : '0px', zoom : 1, overflow : 'hidden'}).addClass('panel').appendTo(this.panelContain);
+ this.panelContain.appendTo(e);
+
+ var opt = this.ne.options;
+ var buttons = opt.buttons;
+ for(button in buttons) {
+ this.addButton(button,opt,true);
+ }
+ this.reorder();
+ e.noSelect();
+ },
+
+ addButton : function(buttonName,options,noOrder) {
+ var button = options.buttons[buttonName];
+ var type = (button['type']) ? eval('(typeof('+button['type']+') == "undefined") ? null : '+button['type']+';') : nicEditorButton;
+ var hasButton = bkLib.inArray(this.buttonList,buttonName);
+ if(type && (hasButton || this.ne.options.fullPanel)) {
+ this.panelButtons.push(new type(this.panelElm,buttonName,options,this.ne));
+ if(!hasButton) {
+ this.buttonList.push(buttonName);
+ }
+ }
+ },
+
+ findButton : function(itm) {
+ for(var i=0;i<this.panelButtons.length;i++) {
+ if(this.panelButtons[i].name == itm)
+ return this.panelButtons[i];
+ }
+ },
+
+ reorder : function() {
+ var bl = this.buttonList;
+ for(var i=0;i<bl.length;i++) {
+ var button = this.findButton(bl[i]);
+ if(button) {
+ this.panelElm.appendChild(button.margin);
+ }
+ }
+ },
+
+ remove : function() {
+ this.elm.remove();
+ }
+});
+var nicEditorButton = bkClass.extend({
+
+ construct : function(e,buttonName,options,nicEditor) {
+ this.options = options.buttons[buttonName];
+ this.name = buttonName;
+ this.ne = nicEditor;
+ this.elm = e;
+
+ this.margin = new bkElement('DIV').setStyle({'float' : 'left', marginTop : '2px'}).appendTo(e);
+ this.contain = new bkElement('DIV').setStyle({width : '20px', height : '20px'}).addClass('buttonContain').appendTo(this.margin);
+ this.border = new bkElement('DIV').setStyle({backgroundColor : '#efefef', border : '1px solid #efefef'}).appendTo(this.contain);
+ this.button = new bkElement('DIV').setStyle({width : '18px', height : '18px', overflow : 'hidden', zoom : 1, cursor : 'pointer'}).addClass('button').setStyle(this.ne.getIcon(buttonName,options)).appendTo(this.border);
+ this.button.addEvent('mouseover', this.hoverOn.closure(this)).addEvent('mouseout',this.hoverOff.closure(this)).addEvent('mousedown',this.mouseClick.closure(this)).noSelect();
+
+ if(!window.opera) {
+ this.button.onmousedown = this.button.onclick = bkLib.cancelEvent;
+ }
+
+ nicEditor.addEvent('selected', this.enable.closure(this)).addEvent('blur', this.disable.closure(this)).addEvent('key',this.key.closure(this));
+
+ this.disable();
+ this.init();
+ },
+
+ init : function() { },
+
+ hide : function() {
+ this.contain.setStyle({display : 'none'});
+ },
+
+ updateState : function() {
+ if(this.isDisabled) { this.setBg(); }
+ else if(this.isHover) { this.setBg('hover'); }
+ else if(this.isActive) { this.setBg('active'); }
+ else { this.setBg(); }
+ },
+
+ setBg : function(state) {
+ switch(state) {
+ case 'hover':
+ var stateStyle = {border : '1px solid #666', backgroundColor : '#ddd'};
+ break;
+ case 'active':
+ var stateStyle = {border : '1px solid #666', backgroundColor : '#ccc'};
+ break;
+ default:
+ var stateStyle = {border : '1px solid #efefef', backgroundColor : '#efefef'};
+ }
+ this.border.setStyle(stateStyle).addClass('button-'+state);
+ },
+
+ checkNodes : function(e) {
+ var elm = e;
+ do {
+ if(this.options.tags && bkLib.inArray(this.options.tags,elm.nodeName)) {
+ this.activate();
+ return true;
+ }
+ } while((elm = elm.parentNode) && elm.className != "nicEdit");
+ elm = $BK(e);
+ while(elm.nodeType == 3) {
+ elm = $BK(elm.parentNode);
+ }
+ if(this.options.css) {
+ for(itm in this.options.css) {
+ if(elm.getStyle(itm,this.ne.selectedInstance.instanceDoc) == this.options.css[itm]) {
+ this.activate();
+ return true;
+ }
+ }
+ }
+ this.deactivate();
+ return false;
+ },
+
+ activate : function() {
+ if(!this.isDisabled) {
+ this.isActive = true;
+ this.updateState();
+ this.ne.fireEvent('buttonActivate',this);
+ }
+ },
+
+ deactivate : function() {
+ this.isActive = false;
+ this.updateState();
+ if(!this.isDisabled) {
+ this.ne.fireEvent('buttonDeactivate',this);
+ }
+ },
+
+ enable : function(ins,t) {
+ this.isDisabled = false;
+ this.contain.setStyle({'opacity' : 1}).addClass('buttonEnabled');
+ this.updateState();
+ if (t !== document) {
+ this.checkNodes(t);
+ }
+ },
+
+ disable : function(ins,t) {
+ this.isDisabled = true;
+ this.contain.setStyle({'opacity' : 0.6}).removeClass('buttonEnabled');
+ this.updateState();
+ },
+
+ toggleActive : function() {
+ (this.isActive) ? this.deactivate() : this.activate();
+ },
+ hoverOn : function() {
+ if(!this.isDisabled) {
+ this.isHover = true;
+ this.updateState();
+ this.ne.fireEvent("buttonOver",this);
+ }
+ },
+
+ hoverOff : function() {
+ this.isHover = false;
+ this.updateState();
+ this.ne.fireEvent("buttonOut",this);
+ },
+
+ mouseClick : function() {
+ if(this.options.command) {
+ this.ne.nicCommand(this.options.command,this.options.commandArgs);
+ if(!this.options.noActive) {
+ this.toggleActive();
+ }
+ }
+ this.ne.fireEvent("buttonClick",this);
+ },
+
+ key : function(nicInstance,e) {
+ if(this.options.key && e.ctrlKey && String.fromCharCode(e.keyCode || e.charCode).toLowerCase() == this.options.key) {
+ this.mouseClick();
+ if(e.preventDefault) e.preventDefault();
+ }
+ }
+
+});
+
+
+var nicPlugin = bkClass.extend({
+
+ construct : function(nicEditor,options) {
+ this.options = options;
+ this.ne = nicEditor;
+ this.ne.addEvent('panel',this.loadPanel.closure(this));
+
+ this.init();
+ },
+
+ loadPanel : function(np) {
+ var buttons = this.options.buttons;
+ for(var button in buttons) {
+ np.addButton(button,this.options);
+ }
+ np.reorder();
+ },
+
+ init : function() { }
+});
+
+
+
+
+ /* START CONFIG */
var nicPaneOptions = { };
+/* END CONFIG */
+
+var nicEditorPane = bkClass.extend({
+ construct : function(elm,nicEditor,options,openButton) {
+ this.ne = nicEditor;
+ this.elm = elm;
+ this.pos = elm.pos();
+
+ this.contain = new bkElement('div').setStyle({zIndex : '99999', overflow : 'hidden', position : 'absolute', left : this.pos[0]+'px', top : this.pos[1]+'px'})
+ this.pane = new bkElement('div').setStyle({fontSize : '12px', border : '1px solid #ccc', 'overflow': 'hidden', padding : '4px', textAlign: 'left', backgroundColor : '#ffffc9'}).addClass('pane').setStyle(options).appendTo(this.contain);
+
+ if(openButton && !openButton.options.noClose) {
+ this.close = new bkElement('div').setStyle({'float' : 'right', height: '16px', width : '16px', cursor : 'pointer'}).setStyle(this.ne.getIcon('close',nicPaneOptions)).addEvent('mousedown',openButton.removePane.closure(this)).appendTo(this.pane);
+ }
+
+ this.contain.noSelect().appendTo(document.body);
+
+ this.position();
+ this.init();
+ },
-var nicEditorPane=bkClass.extend({construct:function(D,C,B,A){this.ne=C;this.elm=D;this.pos=D.pos();this.contain=new bkElement("div").setStyle({zIndex:"99999",overflow:"hidden",position:"absolute",left:this.pos[0]+"px",top:this.pos[1]+"px"});this.pane=new bkElement("div").setStyle({fontSize:"12px",border:"1px solid #ccc",overflow:"hidden",padding:"4px",textAlign:"left",backgroundColor:"#ffffc9"}).addClass("pane").setStyle(B).appendTo(this.contain);if(A&&!A.options.noClose){this.close=new bkElement("div").setStyle({"float":"right",height:"16px",width:"16px",cursor:"pointer"}).setStyle(this.ne.getIcon("close",nicPaneOptions)).addEvent("mousedown",A.removePane.closure(this)).appendTo(this.pane)}this.contain.noSelect().appendTo(document.body);this.position();this.init()},init:function(){},position:function(){if(this.ne.nicPanel){var B=this.ne.nicPanel.elm;var A=B.pos();var C=A[0]+parseInt(B.getStyle("width"))-(parseInt(this.pane.getStyle("width"))+8);if(C<this.pos[0]){this.contain.setStyle({left:C+"px"})}}},toggle:function(){this.isVisible=!this.isVisible;this.contain.setStyle({display:((this.isVisible)?"block":"none")})},remove:function(){if(this.contain){this.contain.remove();this.contain=null}},append:function(A){A.appendTo(this.pane)},setContent:function(A){this.pane.setContent(A)}});
-
-var nicEditorAdvancedButton=nicEditorButton.extend({init:function(){this.ne.addEvent("selected",this.removePane.closure(this)).addEvent("blur",this.removePane.closure(this))},mouseClick:function(){if(!this.isDisabled){if(this.pane&&this.pane.pane){this.removePane()}else{this.pane=new nicEditorPane(this.contain,this.ne,{width:(this.width||"270px"),backgroundColor:"#fff"},this);this.addPane();this.ne.selectedInstance.saveRng()}}},addForm:function(C,G){this.form=new bkElement("form").addEvent("submit",this.submit.closureListener(this));this.pane.append(this.form);this.inputs={};for(itm in C){var D=C[itm];var F="";if(G){F=G.getAttribute(itm)}if(!F){F=D.value||""}var A=C[itm].type;if(A=="title"){new bkElement("div").setContent(D.txt).setStyle({fontSize:"14px",fontWeight:"bold",padding:"0px",margin:"2px 0"}).appendTo(this.form)}else{var B=new bkElement("div").setStyle({overflow:"hidden",clear:"both"}).appendTo(this.form);if(D.txt){new bkElement("label").setAttributes({"for":itm}).setContent(D.txt).setStyle({margin:"2px 4px",fontSize:"13px",width:"50px",lineHeight:"20px",textAlign:"right","float":"left"}).appendTo(B)}switch(A){case"text":this.inputs[itm]=new bkElement("input").setAttributes({id:itm,value:F,type:"text"}).setStyle({margin:"2px 0",fontSize:"13px","float":"left",height:"20px",border:"1px solid #ccc",overflow:"hidden"}).setStyle(D.style).appendTo(B);break;case"select":this.inputs[itm]=new bkElement("select").setAttributes({id:itm}).setStyle({border:"1px solid #ccc","float":"left",margin:"2px 0"}).appendTo(B);for(opt in D.options){var E=new bkElement("option").setAttributes({value:opt,selected:(opt==F)?"selected":""}).setContent(D.options[opt]).appendTo(this.inputs[itm])}break;case"content":this.inputs[itm]=new bkElement("textarea").setAttributes({id:itm}).setStyle({border:"1px solid #ccc","float":"left"}).setStyle(D.style).appendTo(B);this.inputs[itm].value=F}}}new bkElement("input").setAttributes({type:"submit"}).setStyle({backgroundColor:"#efefef",border:"1px solid #ccc",margin:"3px 0","float":"left",clear:"both"}).appendTo(this.form);this.form.onsubmit=bkLib.cancelEvent},submit:function(){},findElm:function(B,A,E){var D=this.ne.selectedInstance.getElm().getElementsByTagName(B);for(var C=0;C<D.length;C++){if(D[C].getAttribute(A)==E){return $BK(D[C])}}},removePane:function(){if(this.pane){this.pane.remove();this.pane=null;this.ne.selectedInstance.restoreRng()}}});
-
-var nicButtonTips=bkClass.extend({construct:function(A){this.ne=A;A.addEvent("buttonOver",this.show.closure(this)).addEvent("buttonOut",this.hide.closure(this))},show:function(A){this.timer=setTimeout(this.create.closure(this,A),400)},create:function(A){this.timer=null;if(!this.pane){this.pane=new nicEditorPane(A.button,this.ne,{fontSize:"12px",marginTop:"5px"});this.pane.setContent(A.options.name)}},hide:function(A){if(this.timer){clearTimeout(this.timer)}if(this.pane){this.pane=this.pane.remove()}}});nicEditors.registerPlugin(nicButtonTips);
-
+ init : function() { },
+ position : function() {
+ if(this.ne.nicPanel) {
+ var panelElm = this.ne.nicPanel.elm;
+ var panelPos = panelElm.pos();
+ var newLeft = panelPos[0]+parseInt(panelElm.getStyle('width'))-(parseInt(this.pane.getStyle('width'))+8);
+ if(newLeft < this.pos[0]) {
+ this.contain.setStyle({left : newLeft+'px'});
+ }
+ }
+ },
+
+ toggle : function() {
+ this.isVisible = !this.isVisible;
+ this.contain.setStyle({display : ((this.isVisible) ? 'block' : 'none')});
+ },
+
+ remove : function() {
+ if(this.contain) {
+ this.contain.remove();
+ this.contain = null;
+ }
+ },
+
+ append : function(c) {
+ c.appendTo(this.pane);
+ },
+
+ setContent : function(c) {
+ this.pane.setContent(c);
+ }
+
+});
+
+
+
+var nicEditorAdvancedButton = nicEditorButton.extend({
+
+ init : function() {
+ this.ne.addEvent('selected',this.removePane.closure(this)).addEvent('blur',this.removePane.closure(this));
+ },
+
+ mouseClick : function() {
+ if(!this.isDisabled) {
+ if(this.pane && this.pane.pane) {
+ this.removePane();
+ } else {
+ this.pane = new nicEditorPane(this.contain,this.ne,{width : (this.width || '270px'), backgroundColor : '#fff'},this);
+ this.addPane();
+ this.ne.selectedInstance.saveRng();
+ }
+ }
+ },
+
+ addForm : function(f,elm) {
+ this.form = new bkElement('form').addEvent('submit',this.submit.closureListener(this));
+ this.pane.append(this.form);
+ this.inputs = {};
+
+ for(itm in f) {
+ var field = f[itm];
+ var val = '';
+ if(elm) {
+ val = elm.getAttribute(itm);
+ }
+ if(!val) {
+ val = field['value'] || '';
+ }
+ var type = f[itm].type;
+
+ if(type == 'title') {
+ new bkElement('div').setContent(field.txt).setStyle({fontSize : '14px', fontWeight: 'bold', padding : '0px', margin : '2px 0'}).appendTo(this.form);
+ } else {
+ var contain = new bkElement('div').setStyle({overflow : 'hidden', clear : 'both'}).appendTo(this.form);
+ if(field.txt) {
+ new bkElement('label').setAttributes({'for' : itm}).setContent(field.txt).setStyle({margin : '2px 4px', fontSize : '13px', width: '50px', lineHeight : '20px', textAlign : 'right', 'float' : 'left'}).appendTo(contain);
+ }
+
+ switch(type) {
+ case 'text':
+ this.inputs[itm] = new bkElement('input').setAttributes({id : itm, 'value' : val, 'type' : 'text'}).setStyle({margin : '2px 0', fontSize : '13px', 'float' : 'left', height : '20px', border : '1px solid #ccc', overflow : 'hidden'}).setStyle(field.style).appendTo(contain);
+ break;
+ case 'select':
+ this.inputs[itm] = new bkElement('select').setAttributes({id : itm}).setStyle({border : '1px solid #ccc', 'float' : 'left', margin : '2px 0'}).appendTo(contain);
+ for(opt in field.options) {
+ var o = new bkElement('option').setAttributes({value : opt, selected : (opt == val) ? 'selected' : ''}).setContent(field.options[opt]).appendTo(this.inputs[itm]);
+ }
+ break;
+ case 'content':
+ this.inputs[itm] = new bkElement('textarea').setAttributes({id : itm}).setStyle({border : '1px solid #ccc', 'float' : 'left'}).setStyle(field.style).appendTo(contain);
+ this.inputs[itm].value = val;
+ }
+ }
+ }
+ new bkElement('input').setAttributes({'type' : 'submit'}).setStyle({backgroundColor : '#efefef',border : '1px solid #ccc', margin : '3px 0', 'float' : 'left', 'clear' : 'both'}).appendTo(this.form);
+ this.form.onsubmit = bkLib.cancelEvent;
+ },
+
+ submit : function() { },
+
+ findElm : function(tag,attr,val) {
+ var list = this.ne.selectedInstance.getElm().getElementsByTagName(tag);
+ for(var i=0;i<list.length;i++) {
+ if(list[i].getAttribute(attr) == val) {
+ return $BK(list[i]);
+ }
+ }
+ },
+
+ removePane : function() {
+ if(this.pane) {
+ this.pane.remove();
+ this.pane = null;
+ this.ne.selectedInstance.restoreRng();
+ }
+ }
+});
+
+
+var nicButtonTips = bkClass.extend({
+ construct : function(nicEditor) {
+ this.ne = nicEditor;
+ nicEditor.addEvent('buttonOver',this.show.closure(this)).addEvent('buttonOut',this.hide.closure(this));
+
+ },
+
+ show : function(button) {
+ this.timer = setTimeout(this.create.closure(this,button),400);
+ },
+
+ create : function(button) {
+ this.timer = null;
+ if(!this.pane) {
+ this.pane = new nicEditorPane(button.button,this.ne,{fontSize : '12px', marginTop : '5px'});
+ this.pane.setContent(button.options.name);
+ }
+ },
+
+ hide : function(button) {
+ if(this.timer) {
+ clearTimeout(this.timer);
+ }
+ if(this.pane) {
+ this.pane = this.pane.remove();
+ }
+ }
+});
+nicEditors.registerPlugin(nicButtonTips);
+
+
+
+ /* START CONFIG */
var nicSelectOptions = {
buttons : {
'fontSize' : {name : __('Select Font Size'), type : 'nicEditorFontSizeSelect', command : 'fontsize'},
@@ -58,45 +1055,705 @@ var nicSelectOptions = {
'fontFormat' : {name : __('Select Font Format'), type : 'nicEditorFontFormatSelect', command : 'formatBlock'}
}
};
+/* END CONFIG */
+var nicEditorSelect = bkClass.extend({
+
+ construct : function(e,buttonName,options,nicEditor) {
+ this.options = options.buttons[buttonName];
+ this.elm = e;
+ this.ne = nicEditor;
+ this.name = buttonName;
+ this.selOptions = new Array();
+
+ this.margin = new bkElement('div').setStyle({'float' : 'left', margin : '2px 1px 0 1px'}).appendTo(this.elm);
+ this.contain = new bkElement('div').setStyle({width: '90px', height : '20px', cursor : 'pointer', overflow: 'hidden'}).addClass('selectContain').addEvent('click',this.toggle.closure(this)).appendTo(this.margin);
+ this.items = new bkElement('div').setStyle({overflow : 'hidden', zoom : 1, border: '1px solid #ccc', paddingLeft : '3px', backgroundColor : '#fff'}).appendTo(this.contain);
+ this.control = new bkElement('div').setStyle({overflow : 'hidden', 'float' : 'right', height: '18px', width : '16px'}).addClass('selectControl').setStyle(this.ne.getIcon('arrow',options)).appendTo(this.items);
+ this.txt = new bkElement('div').setStyle({overflow : 'hidden', 'float' : 'left', width : '66px', height : '14px', marginTop : '1px', fontFamily : 'sans-serif', textAlign : 'center', fontSize : '12px'}).addClass('selectTxt').appendTo(this.items);
+
+ if(!window.opera) {
+ this.contain.onmousedown = this.control.onmousedown = this.txt.onmousedown = bkLib.cancelEvent;
+ }
+
+ this.margin.noSelect();
+
+ this.ne.addEvent('selected', this.enable.closure(this)).addEvent('blur', this.disable.closure(this));
+
+ this.disable();
+ this.init();
+ },
+
+ disable : function() {
+ this.isDisabled = true;
+ this.close();
+ this.contain.setStyle({opacity : 0.6});
+ },
+
+ enable : function(t) {
+ this.isDisabled = false;
+ this.close();
+ this.contain.setStyle({opacity : 1});
+ },
+
+ setDisplay : function(txt) {
+ this.txt.setContent(txt);
+ },
+
+ toggle : function() {
+ if(!this.isDisabled) {
+ (this.pane) ? this.close() : this.open();
+ }
+ },
+
+ open : function() {
+ this.pane = new nicEditorPane(this.items,this.ne,{width : '88px', padding: '0px', borderTop : 0, borderLeft : '1px solid #ccc', borderRight : '1px solid #ccc', borderBottom : '0px', backgroundColor : '#fff'});
+
+ for(var i=0;i<this.selOptions.length;i++) {
+ var opt = this.selOptions[i];
+ var itmContain = new bkElement('div').setStyle({overflow : 'hidden', borderBottom : '1px solid #ccc', width: '88px', textAlign : 'left', overflow : 'hidden', cursor : 'pointer'});
+ var itm = new bkElement('div').setStyle({padding : '0px 4px'}).setContent(opt[1]).appendTo(itmContain).noSelect();
+ itm.addEvent('click',this.update.closure(this,opt[0])).addEvent('mouseover',this.over.closure(this,itm)).addEvent('mouseout',this.out.closure(this,itm)).setAttributes('id',opt[0]);
+ this.pane.append(itmContain);
+ if(!window.opera) {
+ itm.onmousedown = bkLib.cancelEvent;
+ }
+ }
+ },
+
+ close : function() {
+ if(this.pane) {
+ this.pane = this.pane.remove();
+ }
+ },
+
+ over : function(opt) {
+ opt.setStyle({backgroundColor : '#ccc'});
+ },
+
+ out : function(opt) {
+ opt.setStyle({backgroundColor : '#fff'});
+ },
+
+
+ add : function(k,v) {
+ this.selOptions.push(new Array(k,v));
+ },
+
+ update : function(elm) {
+ this.ne.nicCommand(this.options.command,elm);
+ this.close();
+ }
+});
+
+var nicEditorFontSizeSelect = nicEditorSelect.extend({
+ sel : {1 : '1&nbsp;(8pt)', 2 : '2&nbsp;(10pt)', 3 : '3&nbsp;(12pt)', 4 : '4&nbsp;(14pt)', 5 : '5&nbsp;(18pt)', 6 : '6&nbsp;(24pt)'},
+ init : function() {
+ this.setDisplay('Font&nbsp;Size...');
+ for(itm in this.sel) {
+ this.add(itm,'<font size="'+itm+'">'+this.sel[itm]+'</font>');
+ }
+ }
+});
+
+var nicEditorFontFamilySelect = nicEditorSelect.extend({
+ sel : {'arial' : 'Arial','comic sans ms' : 'Comic Sans','courier new' : 'Courier New','georgia' : 'Georgia', 'helvetica' : 'Helvetica', 'impact' : 'Impact', 'times new roman' : 'Times', 'trebuchet ms' : 'Trebuchet', 'verdana' : 'Verdana'},
+
+ init : function() {
+ this.setDisplay('Font&nbsp;Family...');
+ for(itm in this.sel) {
+ this.add(itm,'<font face="'+itm+'">'+this.sel[itm]+'</font>');
+ }
+ }
+});
+
+var nicEditorFontFormatSelect = nicEditorSelect.extend({
+ sel : {'p' : 'Paragraph', 'pre' : 'Pre', 'h6' : 'Heading&nbsp;6', 'h5' : 'Heading&nbsp;5', 'h4' : 'Heading&nbsp;4', 'h3' : 'Heading&nbsp;3', 'h2' : 'Heading&nbsp;2', 'h1' : 'Heading&nbsp;1'},
+
+ init : function() {
+ this.setDisplay('Font&nbsp;Format...');
+ for(itm in this.sel) {
+ var tag = itm.toUpperCase();
+ this.add('<'+tag+'>','<'+itm+' style="padding: 0px; margin: 0px;">'+this.sel[itm]+'</'+tag+'>');
+ }
+ }
+});
+
+nicEditors.registerPlugin(nicPlugin,nicSelectOptions);
+
-var nicEditorSelect=bkClass.extend({construct:function(D,A,C,B){this.options=C.buttons[A];this.elm=D;this.ne=B;this.name=A;this.selOptions=new Array();this.margin=new bkElement("div").setStyle({"float":"left",margin:"2px 1px 0 1px"}).appendTo(this.elm);this.contain=new bkElement("div").setStyle({width:"90px",height:"20px",cursor:"pointer",overflow:"hidden"}).addClass("selectContain").addEvent("click",this.toggle.closure(this)).appendTo(this.margin);this.items=new bkElement("div").setStyle({overflow:"hidden",zoom:1,border:"1px solid #ccc",paddingLeft:"3px",backgroundColor:"#fff"}).appendTo(this.contain);this.control=new bkElement("div").setStyle({overflow:"hidden","float":"right",height:"18px",width:"16px"}).addClass("selectControl").setStyle(this.ne.getIcon("arrow",C)).appendTo(this.items);this.txt=new bkElement("div").setStyle({overflow:"hidden","float":"left",width:"66px",height:"14px",marginTop:"1px",fontFamily:"sans-serif",textAlign:"center",fontSize:"12px"}).addClass("selectTxt").appendTo(this.items);if(!window.opera){this.contain.onmousedown=this.control.onmousedown=this.txt.onmousedown=bkLib.cancelEvent}this.margin.noSelect();this.ne.addEvent("selected",this.enable.closure(this)).addEvent("blur",this.disable.closure(this));this.disable();this.init()},disable:function(){this.isDisabled=true;this.close();this.contain.setStyle({opacity:0.6})},enable:function(A){this.isDisabled=false;this.close();this.contain.setStyle({opacity:1})},setDisplay:function(A){this.txt.setContent(A)},toggle:function(){if(!this.isDisabled){(this.pane)?this.close():this.open()}},open:function(){this.pane=new nicEditorPane(this.items,this.ne,{width:"88px",padding:"0px",borderTop:0,borderLeft:"1px solid #ccc",borderRight:"1px solid #ccc",borderBottom:"0px",backgroundColor:"#fff"});for(var C=0;C<this.selOptions.length;C++){var B=this.selOptions[C];var A=new bkElement("div").setStyle({overflow:"hidden",borderBottom:"1px solid #ccc",width:"88px",textAlign:"left",overflow:"hidden",cursor:"pointer"});var D=new bkElement("div").setStyle({padding:"0px 4px"}).setContent(B[1]).appendTo(A).noSelect();D.addEvent("click",this.update.closure(this,B[0])).addEvent("mouseover",this.over.closure(this,D)).addEvent("mouseout",this.out.closure(this,D)).setAttributes("id",B[0]);this.pane.append(A);if(!window.opera){D.onmousedown=bkLib.cancelEvent}}},close:function(){if(this.pane){this.pane=this.pane.remove()}},over:function(A){A.setStyle({backgroundColor:"#ccc"})},out:function(A){A.setStyle({backgroundColor:"#fff"})},add:function(B,A){this.selOptions.push(new Array(B,A))},update:function(A){this.ne.nicCommand(this.options.command,A);this.close()}});var nicEditorFontSizeSelect=nicEditorSelect.extend({sel:{1:"1&nbsp;(8pt)",2:"2&nbsp;(10pt)",3:"3&nbsp;(12pt)",4:"4&nbsp;(14pt)",5:"5&nbsp;(18pt)",6:"6&nbsp;(24pt)"},init:function(){this.setDisplay("Font&nbsp;Size...");for(itm in this.sel){this.add(itm,'<font size="'+itm+'">'+this.sel[itm]+"</font>")}}});var nicEditorFontFamilySelect=nicEditorSelect.extend({sel:{arial:"Arial","comic sans ms":"Comic Sans","courier new":"Courier New",georgia:"Georgia",helvetica:"Helvetica",impact:"Impact","times new roman":"Times","trebuchet ms":"Trebuchet",verdana:"Verdana"},init:function(){this.setDisplay("Font&nbsp;Family...");for(itm in this.sel){this.add(itm,'<font face="'+itm+'">'+this.sel[itm]+"</font>")}}});var nicEditorFontFormatSelect=nicEditorSelect.extend({sel:{p:"Paragraph",pre:"Pre",h6:"Heading&nbsp;6",h5:"Heading&nbsp;5",h4:"Heading&nbsp;4",h3:"Heading&nbsp;3",h2:"Heading&nbsp;2",h1:"Heading&nbsp;1"},init:function(){this.setDisplay("Font&nbsp;Format...");for(itm in this.sel){var A=itm.toUpperCase();this.add("<"+A+">","<"+itm+' style="padding: 0px; margin: 0px;">'+this.sel[itm]+"</"+A+">")}}});nicEditors.registerPlugin(nicPlugin,nicSelectOptions);
-
+/* START CONFIG */
var nicLinkOptions = {
buttons : {
'link' : {name : 'Add Link', type : 'nicLinkButton', tags : ['A']},
'unlink' : {name : 'Remove Link', command : 'unlink', noActive : true}
}
};
+/* END CONFIG */
+
+var nicLinkButton = nicEditorAdvancedButton.extend({
+ addPane : function() {
+ this.ln = this.ne.selectedInstance.selElm().parentTag('A');
+ this.addForm({
+ '' : {type : 'title', txt : 'Add/Edit Link'},
+ 'href' : {type : 'text', txt : 'URL', value : 'http://', style : {width: '150px'}},
+ 'title' : {type : 'text', txt : 'Title'},
+ 'target' : {type : 'select', txt : 'Open In', options : {'' : 'Current Window', '_blank' : 'New Window'},style : {width : '100px'}}
+ },this.ln);
+ },
+
+ submit : function(e) {
+ var url = this.inputs['href'].value;
+ if(url == "http://" || url == "") {
+ alert("You must enter a URL to Create a Link");
+ return false;
+ }
+ this.removePane();
+
+ if(!this.ln) {
+ var tmp = 'javascript:nicTemp();';
+ this.ne.nicCommand("createlink",tmp);
+ this.ln = this.findElm('A','href',tmp);
+ // set the link text to the title or the url if there is no text selected
+ if (this.ln.innerHTML == tmp) {
+ this.ln.innerHTML = this.inputs['title'].value || url;
+ };
+ }
+ if(this.ln) {
+ var oldTitle = this.ln.title;
+ this.ln.setAttributes({
+ href : this.inputs['href'].value,
+ title : this.inputs['title'].value,
+ target : this.inputs['target'].options[this.inputs['target'].selectedIndex].value
+ });
+ // set the link text to the title or the url if the old text was the old title
+ if (this.ln.innerHTML == oldTitle) {
+ this.ln.innerHTML = this.inputs['title'].value || this.inputs['href'].value;
+ };
+ }
+ }
+});
+
+nicEditors.registerPlugin(nicPlugin,nicLinkOptions);
-var nicLinkButton=nicEditorAdvancedButton.extend({addPane:function(){this.ln=this.ne.selectedInstance.selElm().parentTag("A");this.addForm({"":{type:"title",txt:"Add/Edit Link"},href:{type:"text",txt:"URL",value:"http://",style:{width:"150px"}},title:{type:"text",txt:"Title"},target:{type:"select",txt:"Open In",options:{"":"Current Window",_blank:"New Window"},style:{width:"100px"}}},this.ln)},submit:function(C){var A=this.inputs.href.value;if(A=="http://"||A==""){alert("You must enter a URL to Create a Link");return false}this.removePane();if(!this.ln){var B="javascript:nicTemp();";this.ne.nicCommand("createlink",B);this.ln=this.findElm("A","href",B)}if(this.ln){this.ln.setAttributes({href:this.inputs.href.value,title:this.inputs.title.value,target:this.inputs.target.options[this.inputs.target.selectedIndex].value})}}});nicEditors.registerPlugin(nicPlugin,nicLinkOptions);
-
+
+/* START CONFIG */
var nicColorOptions = {
buttons : {
'forecolor' : {name : __('Change Text Color'), type : 'nicEditorColorButton', noClose : true},
'bgcolor' : {name : __('Change Background Color'), type : 'nicEditorBgColorButton', noClose : true}
}
};
+/* END CONFIG */
+
+var nicEditorColorButton = nicEditorAdvancedButton.extend({
+ addPane : function() {
+ var colorList = {0 : '00',1 : '33',2 : '66',3 :'99',4 : 'CC',5 : 'FF'};
+ var colorItems = new bkElement('DIV').setStyle({width: '270px'});
+
+ for(var r in colorList) {
+ for(var b in colorList) {
+ for(var g in colorList) {
+ var colorCode = '#'+colorList[r]+colorList[g]+colorList[b];
+
+ var colorSquare = new bkElement('DIV').setStyle({'cursor' : 'pointer', 'height' : '15px', 'float' : 'left'}).appendTo(colorItems);
+ var colorBorder = new bkElement('DIV').setStyle({border: '2px solid '+colorCode}).appendTo(colorSquare);
+ var colorInner = new bkElement('DIV').setStyle({backgroundColor : colorCode, overflow : 'hidden', width : '11px', height : '11px'}).addEvent('click',this.colorSelect.closure(this,colorCode)).addEvent('mouseover',this.on.closure(this,colorBorder)).addEvent('mouseout',this.off.closure(this,colorBorder,colorCode)).appendTo(colorBorder);
+
+ if(!window.opera) {
+ colorSquare.onmousedown = colorInner.onmousedown = bkLib.cancelEvent;
+ }
+
+ }
+ }
+ }
+ this.pane.append(colorItems.noSelect());
+ },
+
+ colorSelect : function(c) {
+ this.ne.nicCommand('foreColor',c);
+ this.removePane();
+ },
+
+ on : function(colorBorder) {
+ colorBorder.setStyle({border : '2px solid #000'});
+ },
+
+ off : function(colorBorder,colorCode) {
+ colorBorder.setStyle({border : '2px solid '+colorCode});
+ }
+});
+
+var nicEditorBgColorButton = nicEditorColorButton.extend({
+ colorSelect : function(c) {
+ this.ne.nicCommand('hiliteColor',c);
+ this.removePane();
+ }
+});
+
+nicEditors.registerPlugin(nicPlugin,nicColorOptions);
-var nicEditorColorButton=nicEditorAdvancedButton.extend({addPane:function(){var D={0:"00",1:"33",2:"66",3:"99",4:"CC",5:"FF"};var H=new bkElement("DIV").setStyle({width:"270px"});for(var A in D){for(var F in D){for(var E in D){var I="#"+D[A]+D[E]+D[F];var C=new bkElement("DIV").setStyle({cursor:"pointer",height:"15px","float":"left"}).appendTo(H);var G=new bkElement("DIV").setStyle({border:"2px solid "+I}).appendTo(C);var B=new bkElement("DIV").setStyle({backgroundColor:I,overflow:"hidden",width:"11px",height:"11px"}).addEvent("click",this.colorSelect.closure(this,I)).addEvent("mouseover",this.on.closure(this,G)).addEvent("mouseout",this.off.closure(this,G,I)).appendTo(G);if(!window.opera){C.onmousedown=B.onmousedown=bkLib.cancelEvent}}}}this.pane.append(H.noSelect())},colorSelect:function(A){this.ne.nicCommand("foreColor",A);this.removePane()},on:function(A){A.setStyle({border:"2px solid #000"})},off:function(A,B){A.setStyle({border:"2px solid "+B})}});var nicEditorBgColorButton=nicEditorColorButton.extend({colorSelect:function(A){this.ne.nicCommand("hiliteColor",A);this.removePane()}});nicEditors.registerPlugin(nicPlugin,nicColorOptions);
-
+
+/* START CONFIG */
var nicImageOptions = {
buttons : {
'image' : {name : 'Add Image', type : 'nicImageButton', tags : ['IMG']}
}
-
+
};
+/* END CONFIG */
-var nicImageButton=nicEditorAdvancedButton.extend({addPane:function(){this.im=this.ne.selectedInstance.selElm().parentTag("IMG");this.addForm({"":{type:"title",txt:"Add/Edit Image"},src:{type:"text",txt:"URL",value:"http://",style:{width:"150px"}},alt:{type:"text",txt:"Alt Text",style:{width:"100px"}},align:{type:"select",txt:"Align",options:{none:"Default",left:"Left",right:"Right"}}},this.im)},submit:function(B){var C=this.inputs.src.value;if(C==""||C=="http://"){alert("You must enter a Image URL to insert");return false}this.removePane();if(!this.im){var A="javascript:nicImTemp();";this.ne.nicCommand("insertImage",A);this.im=this.findElm("IMG","src",A)}if(this.im){this.im.setAttributes({src:this.inputs.src.value,alt:this.inputs.alt.value,align:this.inputs.align.value})}}});nicEditors.registerPlugin(nicPlugin,nicImageOptions);
-
+var nicImageButton = nicEditorAdvancedButton.extend({
+ addPane : function() {
+ this.im = this.ne.selectedInstance.selElm().parentTag('IMG');
+ this.addForm({
+ '' : {type : 'title', txt : 'Add/Edit Image'},
+ 'src' : {type : 'text', txt : 'URL', 'value' : 'http://', style : {width: '150px'}},
+ 'alt' : {type : 'text', txt : 'Alt Text', style : {width: '100px'}},
+ 'align' : {type : 'select', txt : 'Align', options : {none : 'Default','left' : 'Left', 'right' : 'Right'}}
+ },this.im);
+ },
+ submit : function(e) {
+ var src = this.inputs['src'].value;
+ if(src == "" || src == "http://") {
+ alert("You must enter a Image URL to insert");
+ return false;
+ }
+ this.removePane();
+
+ if(!this.im) {
+ var tmp = 'javascript:nicImTemp();';
+ this.ne.nicCommand("insertImage",tmp);
+ this.im = this.findElm('IMG','src',tmp);
+ }
+ if(this.im) {
+ this.im.setAttributes({
+ src : this.inputs['src'].value,
+ alt : this.inputs['alt'].value,
+ align : this.inputs['align'].value
+ });
+ }
+ }
+});
+
+nicEditors.registerPlugin(nicPlugin,nicImageOptions);
+
+
+
+
+/* START CONFIG */
var nicSaveOptions = {
buttons : {
'save' : {name : __('Save this content'), type : 'nicEditorSaveButton'}
}
};
+/* END CONFIG */
+
+var nicEditorSaveButton = nicEditorButton.extend({
+ init : function() {
+ if(!this.ne.options.onSave) {
+ this.margin.setStyle({'display' : 'none'});
+ }
+ },
+ mouseClick : function() {
+ var onSave = this.ne.options.onSave;
+ var selectedInstance = this.ne.selectedInstance;
+ onSave(selectedInstance.getContent(), selectedInstance.elm.id, selectedInstance);
+ }
+});
+
+nicEditors.registerPlugin(nicPlugin,nicSaveOptions);
+
+
+
+/* START CONFIG */
+var nicUploadOptions = {
+ buttons : {
+ 'upload' : {name : 'Upload Image', type : 'nicUploadButton'}
+ }
+
+};
+/* END CONFIG */
+
+var nicUploadButton = nicEditorAdvancedButton.extend({
+ nicURI : 'http://files.nicedit.com/',
+
+ addPane : function() {
+ this.im = this.ne.selectedInstance.selElm().parentTag('IMG');
+ this.myID = Math.round(Math.random()*Math.pow(10,15));
+ this.requestInterval = 1000;
+ this.uri = this.ne.options.uploadURI || this.nicURI;
+ nicUploadButton.lastPlugin = this;
+
+ this.myFrame = new bkElement('iframe').setAttributes({ width : '100%', height : '100px', frameBorder : 0, scrolling : 'no' }).setStyle({border : 0}).appendTo(this.pane.pane);
+ this.progressWrapper = new bkElement('div').setStyle({display: 'none', width: '100%', height: '20px', border : '1px solid #ccc'}).appendTo(this.pane.pane);
+ this.progress = new bkElement('div').setStyle({width: '0%', height: '20px', backgroundColor : '#ccc'}).setContent('&nbsp').appendTo(this.progressWrapper);
+
+ setTimeout(this.addForm.closure(this),50);
+ },
+
+ addForm : function() {
+ var myDoc = this.myDoc = this.myFrame.contentWindow.document;
+ myDoc.open();
+ myDoc.write("<html><body>");
+ myDoc.write('<form method="post" action="'+this.uri+'?id='+this.myID+'" enctype="multipart/form-data">');
+ myDoc.write('<input type="hidden" name="APC_UPLOAD_PROGRESS" value="'+this.myID+'" />');
+ if(this.uri == this.nicURI) {
+ myDoc.write('<div style="position: absolute; margin-left: 160px;"><img src="http://imageshack.us/img/imageshack.png" width="30" style="float: left;" /><div style="float: left; margin-left: 5px; font-size: 10px;">Hosted by<br /><a href="http://www.imageshack.us/" target="_blank">ImageShack</a></div></div>');
+ }
+ myDoc.write('<div style="font-size: 14px; font-weight: bold; padding-top: 5px;">Insert an Image</div>');
+ myDoc.write('<input name="nicImage" type="file" style="margin-top: 10px;" />');
+ myDoc.write('</form>');
+ myDoc.write("</body></html>");
+ myDoc.close();
+
+ this.myBody = myDoc.body;
+
+ this.myForm = $BK(this.myBody.getElementsByTagName('form')[0]);
+ this.myInput = $BK(this.myBody.getElementsByTagName('input')[1]).addEvent('change', this.startUpload.closure(this));
+ this.myStatus = new bkElement('div',this.myDoc).setStyle({textAlign : 'center', fontSize : '14px'}).appendTo(this.myBody);
+ },
+
+ startUpload : function() {
+ this.myForm.setStyle({display : 'none'});
+ this.myStatus.setContent('<img src="http://files.nicedit.com/ajax-loader.gif" style="float: right; margin-right: 40px;" /><strong>Uploading...</strong><br />Please wait');
+ this.myForm.submit();
+ setTimeout(this.makeRequest.closure(this),this.requestInterval);
+ },
+
+ makeRequest : function() {
+ if(this.pane && this.pane.pane) {
+ nicUploadButton.lastPlugin = this;
+ var s = new bkElement('script').setAttributes({ type : 'text/javascript', src : this.uri+'?check='+this.myID+'&rand='+Math.round(Math.random()*Math.pow(10,15))}).addEvent('load', function() {
+ s.parentNode.removeChild(s);
+ }).appendTo(document.getElementsByTagName('head')[0]);
+ if(this.requestInterval) {
+ setTimeout(this.makeRequest.closure(this), this.requestInterval);
+ }
+ }
+ },
+
+ setProgress : function(percent) {
+ this.progressWrapper.setStyle({display: 'block'});
+ this.progress.setStyle({width : percent+'%'});
+ },
+
+ update : function(o) {
+ if(o == false) {
+ this.progressWrapper.setStyle({display : 'none'});
+ } else if(o.url) {
+ this.setProgress(100);
+ this.requestInterval = false;
+
+ if(!this.im) {
+ this.ne.selectedInstance.restoreRng();
+ var tmp = 'javascript:nicImTemp();';
+ this.ne.nicCommand("insertImage",tmp);
+ this.im = this.findElm('IMG','src',tmp);
+ }
+ var w = parseInt(this.ne.selectedInstance.elm.getStyle('width'));
+ if(this.im) {
+ this.im.setAttributes({
+ src : o.url,
+ width : (w && o.width) ? Math.min(w,o.width) : ''
+ });
+ }
+
+ this.removePane();
+ } else if(o.error) {
+ this.requestInterval = false;
+ this.setProgress(100);
+ alert("There was an error uploading your image ("+o.error+").");
+ this.removePane();
+ } else if(o.noprogress) {
+ this.progressWrapper.setStyle({display : 'none'});
+ if(this.uri.indexOf('http:') == -1 || this.uri.indexOf(window.location.host) != -1) {
+ this.requestInterval = false;
+ }
+ } else {
+ this.setProgress( Math.round( (o.current/o.total) * 75) );
+ if(o.interval) {
+ this.requestInterval = o.interval;
+ }
+ }
+ }
+
+});
+
+nicUploadButton.statusCb = function(o) {
+ nicUploadButton.lastPlugin.update(o);
+}
+
+nicEditors.registerPlugin(nicPlugin,nicUploadOptions);
+
+
+
+var nicXHTML = bkClass.extend({
+ stripAttributes : ['_moz_dirty','_moz_resizing','_extended'],
+ noShort : ['style','title','script','textarea','a'],
+ cssReplace : {'font-weight:bold;' : 'strong', 'font-style:italic;' : 'em'},
+ sizes : {1 : 'xx-small', 2 : 'x-small', 3 : 'small', 4 : 'medium', 5 : 'large', 6 : 'x-large'},
+
+ construct : function(nicEditor) {
+ this.ne = nicEditor;
+ if(this.ne.options.xhtml) {
+ nicEditor.addEvent('get',this.cleanup.closure(this));
+ }
+ },
+
+ cleanup : function(ni) {
+ var node = ni.getElm();
+ var xhtml = this.toXHTML(node);
+ ni.content = xhtml;
+ },
+
+ toXHTML : function(n,r,d) {
+ var txt = '';
+ var attrTxt = '';
+ var cssTxt = '';
+ var nType = n.nodeType;
+ var nName = n.nodeName.toLowerCase();
+ var nChild = n.hasChildNodes && n.hasChildNodes();
+ var extraNodes = new Array();
+
+ switch(nType) {
+ case 1:
+ var nAttributes = n.attributes;
+
+ switch(nName) {
+ case 'b':
+ nName = 'strong';
+ break;
+ case 'i':
+ nName = 'em';
+ break;
+ case 'font':
+ nName = 'span';
+ break;
+ }
+
+ if(r) {
+ for(var i=0;i<nAttributes.length;i++) {
+ var attr = nAttributes[i];
+
+ var attributeName = attr.nodeName.toLowerCase();
+ var attributeValue = attr.nodeValue;
+
+ if(!attr.specified || !attributeValue || bkLib.inArray(this.stripAttributes,attributeName) || typeof(attributeValue) == "function") {
+ continue;
+ }
+
+ switch(attributeName) {
+ case 'style':
+ var css = attributeValue.replace(/ /g,"");
+ for(itm in this.cssReplace) {
+ if(css.indexOf(itm) != -1) {
+ extraNodes.push(this.cssReplace[itm]);
+ css = css.replace(itm,'');
+ }
+ }
+ cssTxt += css;
+ attributeValue = "";
+ break;
+ case 'class':
+ attributeValue = attributeValue.replace("Apple-style-span","");
+ break;
+ case 'size':
+ cssTxt += "font-size:"+this.sizes[attributeValue]+';';
+ attributeValue = "";
+ break;
+ }
+
+ if(attributeValue) {
+ attrTxt += ' '+attributeName+'="'+attributeValue+'"';
+ }
+ }
+
+ if(cssTxt) {
+ attrTxt += ' style="'+cssTxt+'"';
+ }
+
+ for(var i=0;i<extraNodes.length;i++) {
+ txt += '<'+extraNodes[i]+'>';
+ }
+
+ if(attrTxt == "" && nName == "span") {
+ r = false;
+ }
+ if(r) {
+ txt += '<'+nName;
+ if(nName != 'br') {
+ txt += attrTxt;
+ }
+ }
+ }
+
+
+
+ if(!nChild && !bkLib.inArray(this.noShort,attributeName)) {
+ if(r) {
+ txt += ' />';
+ }
+ } else {
+ if(r) {
+ txt += '>';
+ }
+
+ for(var i=0;i<n.childNodes.length;i++) {
+ var results = this.toXHTML(n.childNodes[i],true,true);
+ if(results) {
+ txt += results;
+ }
+ }
+ }
+
+ if(r && nChild) {
+ txt += '</'+nName+'>';
+ }
+
+ for(var i=0;i<extraNodes.length;i++) {
+ txt += '</'+extraNodes[i]+'>';
+ }
+
+ break;
+ case 3:
+ //if(n.nodeValue != '\n') {
+ txt += n.nodeValue;
+ //}
+ break;
+ }
+
+ return txt;
+ }
+});
+nicEditors.registerPlugin(nicXHTML);
+
+
+
+var nicBBCode = bkClass.extend({
+ construct : function(nicEditor) {
+ this.ne = nicEditor;
+ if(this.ne.options.bbCode) {
+ nicEditor.addEvent('get',this.bbGet.closure(this));
+ nicEditor.addEvent('set',this.bbSet.closure(this));
+
+ var loadedPlugins = this.ne.loadedPlugins;
+ for(itm in loadedPlugins) {
+ if(loadedPlugins[itm].toXHTML) {
+ this.xhtml = loadedPlugins[itm];
+ }
+ }
+ }
+ },
+
+ bbGet : function(ni) {
+ var xhtml = this.xhtml.toXHTML(ni.getElm());
+ ni.content = this.toBBCode(xhtml);
+ },
+
+ bbSet : function(ni) {
+ ni.content = this.fromBBCode(ni.content);
+ },
+
+ toBBCode : function(xhtml) {
+ function rp(r,m) {
+ xhtml = xhtml.replace(r,m);
+ }
+
+ rp(/\n/gi,"");
+ rp(/<strong>(.*?)<\/strong>/gi,"[b]$1[/b]");
+ rp(/<em>(.*?)<\/em>/gi,"[i]$1[/i]");
+ rp(/<span.*?style="text-decoration:underline;">(.*?)<\/span>/gi,"[u]$1[/u]");
+ rp(/<ul>(.*?)<\/ul>/gi,"[list]$1[/list]");
+ rp(/<li>(.*?)<\/li>/gi,"[*]$1[/*]");
+ rp(/<ol>(.*?)<\/ol>/gi,"[list=1]$1[/list]");
+ rp(/<img.*?src="(.*?)".*?>/gi,"[img]$1[/img]");
+ rp(/<a.*?href="(.*?)".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
+ rp(/<br.*?>/gi,"\n");
+ rp(/<.*?>.*?<\/.*?>/gi,"");
+
+ return xhtml;
+ },
+
+ fromBBCode : function(bbCode) {
+ function rp(r,m) {
+ bbCode = bbCode.replace(r,m);
+ }
+
+ rp(/\[b\](.*?)\[\/b\]/gi,"<strong>$1</strong>");
+ rp(/\[i\](.*?)\[\/i\]/gi,"<em>$1</em>");
+ rp(/\[u\](.*?)\[\/u\]/gi,"<span style=\"text-decoration:underline;\">$1</span>");
+ rp(/\[list\](.*?)\[\/list\]/gi,"<ul>$1</ul>");
+ rp(/\[list=1\](.*?)\[\/list\]/gi,"<ol>$1</ol>");
+ rp(/\[\*\](.*?)\[\/\*\]/gi,"<li>$1</li>");
+ rp(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
+ rp(/\[url=(.*?)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");
+ rp(/\n/gi,"<br />");
+ //rp(/\[.*?\](.*?)\[\/.*?\]/gi,"$1");
+
+ return bbCode;
+ }
+
+
+});
+nicEditors.registerPlugin(nicBBCode);
+
+
+
+nicEditor = nicEditor.extend({
+ floatingPanel : function() {
+ this.floating = new bkElement('DIV').setStyle({position: 'absolute', top : '-1000px'}).appendTo(document.body);
+ this.addEvent('focus', this.reposition.closure(this)).addEvent('blur', this.hide.closure(this));
+ this.setPanel(this.floating);
+ },
+
+ reposition : function() {
+ var e = this.selectedInstance.e;
+ this.floating.setStyle({ width : (parseInt(e.getStyle('width')) || e.clientWidth)+'px' });
+ var top = e.offsetTop-this.floating.offsetHeight;
+ if(top < 0) {
+ top = e.offsetTop+e.offsetHeight;
+ }
+
+ this.floating.setStyle({ top : top+'px', left : e.offsetLeft+'px', display : 'block' });
+ },
+
+ hide : function() {
+ this.floating.setStyle({ top : '-1000px'});
+ }
+});
+
+
+
+/* START CONFIG */
+var nicCodeOptions = {
+ buttons : {
+ 'xhtml' : {name : 'Edit HTML', type : 'nicCodeButton'}
+ }
+
+};
+/* END CONFIG */
+
+var nicCodeButton = nicEditorAdvancedButton.extend({
+ width : '350px',
+
+ addPane : function() {
+ this.addForm({
+ '' : {type : 'title', txt : 'Edit HTML'},
+ 'code' : {type : 'content', 'value' : this.ne.selectedInstance.getContent(), style : {width: '340px', height : '200px'}}
+ });
+ },
+
+ submit : function(e) {
+ var code = this.inputs['code'].value;
+ this.ne.selectedInstance.setContent(code);
+ this.removePane();
+ }
+});
+
+nicEditors.registerPlugin(nicPlugin,nicCodeOptions);
+
-var nicEditorSaveButton=nicEditorButton.extend({init:function(){if(!this.ne.options.onSave){this.margin.setStyle({display:"none"})}},mouseClick:function(){var B=this.ne.options.onSave;var A=this.ne.selectedInstance;B(A.getContent(),A.elm.id,A)}});nicEditors.registerPlugin(nicPlugin,nicSaveOptions);
-
diff --git a/static/website/js/nicEditorIcons.gif b/static/website/js/nicEditorIcons.gif
index 5cf1ebe..cd33a5d 100644..100755
--- a/static/website/js/nicEditorIcons.gif
+++ b/static/website/js/nicEditorIcons.gif
Binary files differ
diff --git a/static/website/js/thread-user.js b/static/website/js/thread-user.js
index e44448a..0e3ef02 100644
--- a/static/website/js/thread-user.js
+++ b/static/website/js/thread-user.js
@@ -80,7 +80,6 @@ $(document).ready(function() {
type: "POST",
dataType: "html",
success: function(data){
- console.log(data);
$saving.hide();
$saved.show();
$saved.fadeOut("slow");
@@ -147,58 +146,156 @@ $(document).ready(function() {
}
});
});
+
/*
- * reply edit section
+ * answer edit section
* set the dom variables
*/
- $reply_edit = $('.reply .edit');
- $reply_save = $(".reply .save");
- $replyPanelWrapper = $("#replyPanelWrapper");
+ $answer_edit = $('.answer .edit');
+ $answer_save = $(".answer .save");
+ $answerPanelWrapper = $("#answerPanelWrapper");
- var replyNicEditor = new nicEditor({
+ var answerNicEditor = new nicEditor({
buttonList : ['fontSize','bold','italic','underline','strikeThrough','subscript','superscript','html','image', 'link'],
iconsPath: "/static/website/js/nicEditorIcons.gif",
});
- replyNicEditor.panelInstance('replyNicPanel');
+ answerNicEditor.panelInstance('answerNicPanel');
- $reply_edit.click(function() {
+ $answer_edit.click(function(e) {
var target = $(this).data("target");
- console.log(target);
- replyNicEditor.addInstance(target);
- $(this).parents("div.reply").prepend($replyPanelWrapper);
- $replyPanelWrapper.show();
- $('#replyPanelWrapper .nicEdit-panelContain').parent().width('100%');
- $('#replyPanelWrapper .nicEdit-panelContain').parent().next().width('100%');
+ answerNicEditor.addInstance(target);
+ $(this).parents("div.answer").prepend($answerPanelWrapper);
+ $answerPanelWrapper.show();
+ $('#answerPanelWrapper .nicEdit-panelContain').parent().width('100%');
+ $('#answerPanelWrapper .nicEdit-panelContain').parent().next().width('100%');
$(this).hide();
$(this).next().show();
+ $("#"+target).focus();
+ e.preventDefault();
});
- $reply_save.click(function() {
+ $answer_save.click(function() {
$saving.show();
var target = $(this).data("target");
- replyNicEditor.removeInstance(target);
- $replyPanelWrapper.hide();
- $('#replyPanelWrapper .nicEdit-panelContain').parent().width('100%');
+ answerNicEditor.removeInstance(target);
+ $answerPanelWrapper.hide();
+ $('#answerPanelWrapper .nicEdit-panelContain').parent().width('100%');
$(this).hide();
$(this).prev().show();
- var reply_id = parseInt($(this).data("rid"));
- var reply_body = $("#"+target).html();
+ var answer_id = parseInt($(this).data("aid"));
+ var answer_body = $("#"+target).html();
$.ajax({
- url: "/ajax-reply-update/",
+ url: "/ajax-answer-update/",
type: "POST",
data: {
- reply_id: reply_id,
- reply_body: reply_body
+ answer_id: answer_id,
+ answer_body: answer_body
},
success: function(data) {
- console.log(data);
$saving.hide();
$saved.show();
$saved.fadeOut("slow");
}
});
});
-});
+ /*
+ * comment edit section
+ * set the dom variables
+ */
+ $comment_edit = $(".comment .edit");
+ $comment_save = $(".comment .save");
+ $commentPanelWrapper = $("#commentPanelWrapper");
+
+ var commentNicEditor = new nicEditor({
+ buttonList : ['fontSize','bold','italic','underline','strikeThrough','subscript','superscript','html','image', 'link'],
+ iconsPath: "/static/website/js/nicEditorIcons.gif",
+ });
+ commentNicEditor.panelInstance('commentNicPanel');
+
+ $comment_edit.click(function(e) {
+ var target = $(this).data("target");
+ commentNicEditor.addInstance(target);
+ $(this).parents("div.comment").prepend($commentPanelWrapper);
+ $commentPanelWrapper.show();
+ $('#commentPanelWrapper .nicEdit-panelContain').parent().width('100%');
+ $('#commentPanelWrapper .nicEdit-panelContain').parent().next().width('100%');
+ $(this).hide();
+ $(this).next().show();
+ $("#"+target).focus();
+ e.preventDefault();
+ });
+
+ $comment_save.click(function() {
+ $saving.show();
+ var target = $(this).data("target");
+ commentNicEditor.removeInstance(target);
+ $commentPanelWrapper.hide();
+ $('#commentPanelWrapper .nicEdit-panelContain').parent().width('100%');
+ $(this).hide();
+ $(this).prev().show();
+
+ var comment_id = parseInt($(this).data("cid"));
+ var comment_body = $("#"+target).html();
+ $.ajax({
+ url: "/ajax-answer-comment-update/",
+ type: "POST",
+ data: {
+ comment_id: comment_id,
+ comment_body: comment_body
+ },
+ success: function(data) {
+ $saving.hide();
+ $saved.show();
+ $saved.fadeOut("slow");
+ }
+ });
+ });
+
+ /*
+ * add a new comment
+ * set the dom variables
+ */
+ var nics = {};
+ $add_comment = $(".add-comment");
+ $cancel_commment = $(".cancel-comment");
+ $post_comment = $(".post-comment");
+
+ $add_comment.click(function(e) {
+ $(this).hide();
+ $(this).siblings(".cancel-comment").show();
+ $(this).siblings(".post-comment").show();
+
+ var target = $(this).data("target");
+ $("#"+target).show();
+ nics[target] = new nicEditor({
+ buttonList : ['fontSize','bold','italic','underline','strikeThrough','subscript','superscript','html','image', 'link'],
+ iconsPath: "/static/website/js/nicEditorIcons.gif",
+ }).panelInstance(target, {hasPanel : true});
+ e.preventDefault();
+ });
+
+ $cancel_commment.click(function(e) {
+ $(this).hide();
+ $(this).siblings(".post-comment").hide();
+ $(this).siblings(".add-comment").show();
+
+ var target = $(this).data("target");
+ nics[target].removeInstance(target);
+ nics[target] = null;
+ $("#"+target).hide();
+ e.preventDefault();
+ });
+
+ $post_comment.click(function(e) {
+ var target = $(this).data("target");
+ var answer_id = $(this).data("aid");
+ var form = $(this).data("form");
+ $form = $("#"+form);
+ nics[target].instanceById(target).saveContent();
+ $form.submit();
+ e.preventDefault;
+ });
+});
diff --git a/static/website/templates/ajax-keyword-search.html b/static/website/templates/ajax-keyword-search.html
index db9fbc7..b4295c7 100644
--- a/static/website/templates/ajax-keyword-search.html
+++ b/static/website/templates/ajax-keyword-search.html
@@ -8,7 +8,7 @@
<th> Question</th>
<th> Date</th>
<th> Views</th>
- <th> Replies</th>
+ <th> Answers</th>
<th> User</th>
{% for question in questions %}
<tr>
@@ -65,7 +65,7 @@
</td>
<td>
- {{ question.reply_set.count }}
+ {{ question.answer_set.count }}
</td>
<td>
diff --git a/static/website/templates/ajax-time-search.html b/static/website/templates/ajax-time-search.html
index 0b1673c..57be751 100644
--- a/static/website/templates/ajax-time-search.html
+++ b/static/website/templates/ajax-time-search.html
@@ -8,7 +8,7 @@
<th> Question</th>
<th> Date</th>
<th> Views</th>
- <th> Replies</th>
+ <th> Answers</th>
<th> User</th>
{% for question in questions %}
<tr>
@@ -65,7 +65,7 @@
</td>
<td>
- {{ question.reply_set.count }}
+ {{ question.answer_set.count }}
</td>
<td>
diff --git a/static/website/templates/base.html b/static/website/templates/base.html
index 49c5f18..286a2ec 100644
--- a/static/website/templates/base.html
+++ b/static/website/templates/base.html
@@ -1,9 +1,12 @@
+{% load compress %}
{% load static %}
<html>
<head>
<title>Spoken-Tutorial Forums</title>
+ {% compress css %}
<link rel="stylesheet" href="{% static 'website/css/bootstrap.min.css' %}" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="{% static 'website/css/main.css' %}" type="text/css" media="screen" charset="utf-8" />
+ {% endcompress %}
</head>
<body>
<div id="page-wrapper">
@@ -48,7 +51,7 @@
</a>
<ul class="dropdown-menu">
<li><a href="{% url 'website:user_questions' user.id %}">My Questions</a></li>
- <li><a href="{% url 'website:user_replies' user.id %}">My Replies</a></li>
+ <li><a href="{% url 'website:user_answers' user.id %}">My Answers</a></li>
<li>
<a href="{% url 'website:user_notifications' user.id %}">
Notifications
@@ -102,12 +105,14 @@
</div> <!-- /#footer-inner -->
</div> <!-- /#footer-wrapper -->
</div> <!-- /#page-wrapper -->
-
+
+ {% compress js %}
<script src="{% static 'website/js/jquery.min.js' %}"></script>
<script src="{% static 'website/js/bootstrap.min.js' %}"></script>
{% block javascript %}
<!-- overide with custom javascript -->
{% endblock %}
+ {% endcompress %}
</body>
</html>
diff --git a/static/website/templates/filter.html b/static/website/templates/filter.html
index 64eeb5c..dada403 100644
--- a/static/website/templates/filter.html
+++ b/static/website/templates/filter.html
@@ -80,7 +80,7 @@
<th> Question</th>
<th> Date</th>
<th> Views</th>
- <th> Replies</th>
+ <th> Answers</th>
<th> User</th>
{% for question in questions %}
<tr>
@@ -137,7 +137,7 @@
</td>
<td>
- {{ question.reply_set.count }}
+ {{ question.answer_set.count }}
</td>
<td>
diff --git a/static/website/templates/get-question.html b/static/website/templates/get-question.html
index c1ae565..2ef71b1 100644
--- a/static/website/templates/get-question.html
+++ b/static/website/templates/get-question.html
@@ -8,123 +8,189 @@
<span class="saving hideme">saving . . .</span>
<span class="saved hideme">saved</span>
-<div class="question {% if user|can_edit:question %}editable{% endif %}">
- <div class="title {% if user|can_edit:question %}title-editable{% endif %}">
- {{ question.title }}
- </div>
-
- <div id="title-edit" class="hideme">
- <h5>Title</h5>
- <input class="form-control" type="text">
- <h5>Question</h5>
- </div>
-
- <div id="questionNicPanel"></div>
- <div id="{% if user|can_edit:question %}questionInstance{% endif %}" class="body">
- {{ question.body|safe }}
- </div>
- <br>
-
- <span class="category">
- <small>
- <a href="{% url 'website:filter' question.category %}">
- {{ question.category }}
- </a>
- </small>
- </span>
-
- <span class="tutorial">
- <small>
- <a href="{% url 'website:filter' question.category question.tutorial %}">
- {{ question.tutorial}}
- </a>
- </small>
- </span>
-
- <span class="minute_range {% if question.minute_range == 'None' %}hideme{% endif %}">
- <small>
- <a href="{% url 'website:filter' question.category question.tutorial question.minute_range %}">
- {{ question.minute_range }} min
- </a>
- </small>
- </span>
-
- <span class="second_range {% if question.minute_range == 'None' %}hideme{% endif %}">
- <small>
- <a href="{% url 'website:filter' question.category question.tutorial question.minute_range question.second_range%}">
- {{ question.second_range }} sec
- </a>
- </small>
- </span>
-
- <a id="question-details-edit" data-toggle="modal" data-target="#detailsModal" href="#" class="hideme">
- <span class="glyphicon glyphicon-edit"></span>
- </a>
-
- <span class="modify">
- {% if user|can_edit:question %}
- <a class="edit btn btn-xs btn-info" href="#">Edit</a>
- <a class="save btn btn-xs btn-success" data-qid="{{ question.id }}" href="#">Save</a>
- {% endif %}
- </span>
-
- <span class="meta">
- <small>
- <i>
- {{ question.date_created|date:"y-d-m" }}, {{ question.date_created|time }}
- </i>
- </small>
+<div class="row">
+ <div class="question-critic col-lg-1 lead">
+ <span class="vote upvote" data-qid="{{ question.id }}" data-vote="1">
+ <span class="glyphicon glyphicon-circle-arrow-up"></span>
+ </span>
+ <div class="votes">34</div>
+ <span class="vote downvote" data-qid="{{ question.id }}" data-vote="-1">
+ <span class="glyphicon glyphicon-circle-arrow-down"></span>
+ </span>
+ </div>
- <span class="user">
- {{ question.user }}
+ <div class="col-lg-11 question-wrapper">
+ <div class="question {% if user|can_edit:question %}editable{% endif %}">
+ <div class="title {% if user|can_edit:question %}title-editable{% endif %}">
+ {{ question.title }}
+ </div>
+
+ <div id="title-edit" class="hideme">
+ <h5>Title</h5>
+ <input class="form-control" type="text">
+ <h5>Question</h5>
+ </div>
+
+ <div id="questionNicPanel"></div>
+ <div id="{% if user|can_edit:question %}questionInstance{% endif %}" class="body">
+ {{ question.body|safe }}
+ </div>
+ <br>
+
+ <span class="category">
+ <small>
+ <a href="{% url 'website:filter' question.category %}">
+ {{ question.category }}
+ </a>
+ </small>
+ </span>
+
+ <span class="tutorial">
+ <small>
+ <a href="{% url 'website:filter' question.category question.tutorial %}">
+ {{ question.tutorial}}
+ </a>
+ </small>
+ </span>
+
+ <span class="minute_range {% if question.minute_range == 'None' %}hideme{% endif %}">
+ <small>
+ <a href="{% url 'website:filter' question.category question.tutorial question.minute_range %}">
+ {{ question.minute_range }} min
+ </a>
+ </small>
+ </span>
+
+ <span class="second_range {% if question.minute_range == 'None' %}hideme{% endif %}">
+ <small>
+ <a href="{% url 'website:filter' question.category question.tutorial question.minute_range question.second_range%}">
+ {{ question.second_range }} sec
+ </a>
+ </small>
+ </span>
+
+ <a id="question-details-edit" data-toggle="modal" data-target="#detailsModal" href="#" class="hideme">
+ <span class="glyphicon glyphicon-edit"></span>
+ </a>
+
+ <span class="modify">
+ {% if user|can_edit:question %}
+ <a class="edit btn btn-xs btn-info" href="#">Edit</a>
+ <a class="save btn btn-xs btn-success" data-qid="{{ question.id }}" href="#">Save</a>
+ {% endif %}
+ </span>
+
+ <span class="meta">
+ <small>
+ <i>
+ {{ question.date_created|date:"y-d-m" }}, {{ question.date_created|time }}
+ </i>
+ </small>
+
+ <span class="user">
+ {{ question.user }}
+ </span>
</span>
- </span>
</div> <!-- /.question -->
+ </div>
+</div> <!-- /.row -->
<h4><u>Answers:</u></h4>
-
-<div id="replyPanelWrapper" style="display:none;">
- <div id="replyNicPanel" style="display:none;"></div>
+<div id="answerPanelWrapper" style="display:none;">
+ <div id="answerNicPanel" style="display:none;"></div>
</div>
-{% for reply in replies %}
- <div class="reply {% if user|can_edit:reply %}editable{% endif %}" id="reply{{reply.id}}">
-
- <div class="body" id="body{{ reply.id }}">
- {{ reply.body|safe }}
- </div>
+<div id="commentPanelWrapper" style="display:none;">
+ <div id="commentNicPanel" style="display:none;"></div>
+</div>
- <span class="user">
- {{ reply.user }}
+{% for answer in answers %}
+<div class="row">
+ <div class="answer-critic col-lg-1">
+ <span class="vote upvote" data-aid="{{ answer.id }}" data-vote="1">
+ <span class="glyphicon glyphicon-circle-arrow-up"></span>
</span>
-
- {% if user|can_edit:reply %}
- <span class="modify" style="display:block">
- <a class="edit btn btn-xs btn-info vs" href="#body{{ reply.id}}" data-target="body{{ reply.id }}">Edit</a>
- <a class="save btn btn-xs btn-success vs" data-target="body{{ reply.id }}" data-rid="{{ reply.id }}" href="#">Save</a>
+ <div class="votes">34</div>
+ <span class="vote downvote" href="#" data-aid="{{ answer.id }}" data-vote="-1">
+ <span class="glyphicon glyphicon-circle-arrow-down"></span>
</span>
- {% endif %}
- </div> <!-- /.reply -->
+ </div>
+
+ <div class="col-lg-11 answer-wrapper">
+ <div class="answer {% if user|can_edit:answer %}editable{% endif %}" id="answer{{answer.id}}">
+
+ <div class="body" id="body{{ answer.id }}">
+ {{ answer.body|safe }}
+ </div>
+
+ <span class="user">
+ {{ answer.user }}
+ </span>
+
+ {% if user|can_edit:answer %}
+ <span class="modify" style="display:block">
+ <a class="edit btn btn-xs btn-info vs" href="#body{{ answer.id}}" data-target="body{{ answer.id }}">Edit</a>
+ <a class="save btn btn-xs btn-success vs" data-target="body{{ answer.id }}" data-aid="{{ answer.id }}" href="#">Save</a>
+ </span>
+ {% endif %}
+ </div> <!-- /.answer -->
+
+ <div class="row">
+ <div class="comments col-lg-11 pull-right">
+ <!-- displaying comments -->
+ {% for comment in answer.answercomment_set.all %}
+ <div class="comment">
+ <div class="body" id="cbody{{ comment.id }}">
+ {{ comment.body|safe }}
+ </div>
+
+ <span class="modify" style="display:block">
+ <a class="edit btn btn-xs btn-info vs" href="#cbody{{ comment.id }}" data-target="cbody{{ comment.id }}">Edit</a>
+ <a class="save btn btn-xs btn-success vs" data-target="cbody{{ comment.id }}" data-cid="{{ comment.id }}" href="#">Save</a>
+ </span>
+ </div> <!-- /.comment -->
+ {% endfor %}
+
+
+ <!-- form to add comment -->
+ <form id="form{{ answer.id }}" method="post" action="/answer-comment/"> {% csrf_token %}
+ <input type="hidden" name="answer_id" value="{{answer.id}}">
+ <textarea name="body" class="new-comment form-control" id="comment{{ answer.id }}" rows="2"></textarea>
+ </form>
+ <a class="add-comment" href="#" data-target="comment{{ answer.id }}">
+ <small>add comment</small>
+ </a>
+ <a class="post-comment" href="#" data-target="comment{{ answer.id }}" data-aid="{{ answer.id }}" data-form="form{{ answer.id }}">
+ <small>post comment</small>
+ </a>
+ <a class="cancel-comment" href="#" data-target="comment{{ answer.id }}">
+ <small>cancel comment</small>
+ </a>
+ </div> <!-- comments -->
+ </div> <!-- /.row -->
+ <br> <hr>
+ </div> <!-- /.answer-wrapper -->
+</div> <!-- /.row -->
{% endfor %}
{% if user.is_authenticated %}
- <form action="{% url 'website:question_reply' %}" method="POST"> {% csrf_token %}
+ <form action="{% url 'website:question_answer' %}" method="POST"> {% csrf_token %}
{% with WIDGET_ERROR_CLASS='field_error' %}
<div class="row">
<div class="col-lg-12">
<div class="form-group">
{% render_field form.question value=question.id %}
- <label for="id_body">Reply</label>
+ <label for="id_body">Answer</label>
{% render_field form.body class+='form-control' %}
</div>
</div>
</div>
{% endwith %}
- <input class="btn btn-sm btn-info" type="submit" value="Submit Reply">
+ <input class="btn btn-sm btn-info" type="submit" value="Submit Answer">
</form>
{% else %}
<h4>
- <a class="btn btn-xs btn-success" href="{% url 'user_login'%}"><b>Log-in</b></a> to reply to this question.
+ <a class="btn btn-xs btn-success" href="{% url 'user_login'%}"><b>Log-in</b></a> to answer to this question.
</h4>
{% endif %}
@@ -137,7 +203,7 @@
<h4 class="modal-title" id="myModalLabel">Edit Question Details</h4>
</div>
<div class="modal-body">
-
+
<h5>The Current question is under:</h5>
{{ question.category }}
--&gt; {{ question.tutorial }}
@@ -147,7 +213,7 @@
{% if question.second_range != 'None' %}
--&gt; {{ question.second_range}}
{% endif %}
-
+
<h5>Move the question to:</h5>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
@@ -223,7 +289,6 @@
<a class="btn btn-sm btn-default" data-dismiss="modal" href="#">Close</a>
</div>
<div class="clearfix"></div>
-
</div> <!-- /.modal-body -->
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
@@ -243,4 +308,29 @@
{% block javascript %}
<script src="{% static 'website/js/thread-user.js' %}"></script>
<script src="{% static 'website/js/custom.js' %}"></script>
+ <script>
+ $(document).ready(function() {
+ $vote = $(".vote");
+
+ $vote.click(function() {
+ if($(this).hasClass("upvote")) {
+ /* handle upvote click event */
+ if($(this).hasClass("voted")) {
+ $(this).removeClass("voted");
+ } else {
+ $(this).addClass("voted");
+ $(this).siblings(".downvote").removeClass("voted");
+ }
+ } else {
+ /* handle downvote click event */
+ if($(this).hasClass("voted")) {
+ $(this).removeClass("voted");
+ } else {
+ $(this).addClass("voted");
+ $(this).siblings(".upvote").removeClass("voted");
+ }
+ }
+ });
+ });
+ </script>
{% endblock %}
diff --git a/static/website/templates/index.html b/static/website/templates/index.html
index 8cb69e4..af97707 100644
--- a/static/website/templates/index.html
+++ b/static/website/templates/index.html
@@ -10,7 +10,7 @@
<th> Question</th>
<th> Date</th>
<th> Views</th>
- <th> Replies</th>
+ <th> Answers</th>
<th> User</th>
{% for question in questions %}
<tr>
@@ -67,7 +67,7 @@
</td>
<td>
- {{ question.reply_set.count }}
+ {{ question.answer_set.count }}
</td>
<td>
@@ -79,7 +79,7 @@
{% endfor %}
</table>
- {% if total > 20 %}
+ {% if total > 25 %}
<ul class="pagination pull-right">
{% for i in total|get_range:"0,10" %}
<li>
diff --git a/static/website/templates/notify.html b/static/website/templates/notify.html
index 7251f1b..af93eb5 100644
--- a/static/website/templates/notify.html
+++ b/static/website/templates/notify.html
@@ -1,6 +1,6 @@
<div class="notification">
- <a href=""><strong>{{ reply.user }}</strong> replies to <strong>{{ question.title }}</strong></a> /
- {{ reply.body|safe }}
+ <a href=""><strong>{{ answer.user }}</strong> answers to <strong>{{ question.title }}</strong></a> /
+ {{ answer.body|safe }}
<a class="remove" data-nid="{{ notification.id }}" href="#">
<span class="glyphicon glyphicon-remove-circle"></span>
</a>
diff --git a/static/website/templates/recent_questions.html b/static/website/templates/recent_questions.html
deleted file mode 100644
index 1a4cc44..0000000
--- a/static/website/templates/recent_questions.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<ul>
-{% for question in recent_questions %}
- <li>{{question.title}}</li>
-{% endfor %}
-</ul>
diff --git a/static/website/templates/user-replies.html b/static/website/templates/user-answers.html
index 8be85fa..34a1c68 100644
--- a/static/website/templates/user-replies.html
+++ b/static/website/templates/user-answers.html
@@ -1,17 +1,17 @@
{% extends 'website/templates/base.html' %}
{% load count_tags %}
{% block content %}
- <h4>My Replies</h4>
- {% for reply in replies%}
- <div class="my-reply">
+ <h4>My Answers</h4>
+ {% for answer in answers%}
+ <div class="my-answer">
<span class="body">
- <a href="{% url 'website:get_question' reply.question.id %}#reply{{ reply.id }}">{{ reply.body|safe }}</a>
+ <a href="{% url 'website:get_question' answer.question.id %}#answer{{ answer.id }}">{{ answer.body|safe }}</a>
</span>
<br>
<span class="date">
<small>
Replied on:
- {{ reply.date_created }}
+ {{ answer.date_created }}
</small>
</span>
</div>
@@ -21,7 +21,7 @@
<ul class="pagination pull-right">
{% for i in total|get_range:"0,10" %}
<li>
- <a href="{% url 'website:user_replies' user.id %}?marker={{ i }}">
+ <a href="{% url 'website:user_answers' user.id %}?marker={{ i }}">
{% if i == marker %}
<strong>{{ i|div:"10"|inc }}</strong>
{% else %}