让wordpress留言评论框,增加实用工具及自订简码
点击数: 2016
文章目录
完成后,是这样子的
步骤一、在主题的comments.php
适当的位置贴入以下语法,至于详细位置,现在很难说了。
早期主题比较简单,现在主题比较复杂。
像我的主题的comments.php里面是没有东西,是在另外一个档案。
-
"editor_tools">
-
"editor">
- class="btn-base small-btn-base round-btn btn-hot-pink" href="javascript:SIMPALED.Editor.strong()">粗体
- class="btn-base small-btn-base round-btn btn-pink" href="javascript:SIMPALED.Editor.em()">私密
- class="btn-base small-btn-base round-btn btn-blue-1" href="javascript:;" id="font-color">颜色
- class="btn-base small-btn-base round-btn btn-blue-2" href="javascript:SIMPALED.Editor.del()">删除线
"padding-top: 10px;">
"fontcolor">
步骤二、在主题里面新增js语法
- //评论的js
- jQuery(function(){
- jQuery("#fontcolor").hide(500);
- jQuery("#font-color").click(function(){
- jQuery("#fontcolor").toggle(500);
- });
- });
- jQuery(function(){
- jQuery("#fontcolor").hide();
- jQuery("#comment").click(function(){
- });
- });
- jQuery(function() {
- function addEditor(a, b, c) {
- if (document.selection) {
- a.focus();
- sel = document.selection.createRange();
- c ? sel.text = b + sel.text + c: sel.text = b;
- a.focus()
- } else if (a.selectionStart || a.selectionStart == '0') {
- var d = a.selectionStart;
- var e = a.selectionEnd;
- var f = e;
- c ? a.value = a.value.substring(0, d) + b + a.value.substring(d, e) + c + a.value.substring(e, a.value.length) : a.value = a.value.substring(0, d) + b + a.value.substring(e, a.value.length);
- c ? f += b.length + c.length: f += b.length - e + d;
- if (d == e && c) f -= c.length;
- a.focus();
- a.selectionStart = f;
- a.selectionEnd = f
- } else {
- a.value += b + c;
- a.focus()
- }
- }
- var myDate = new Date();
- var mytime=myDate.toLocaleTimeString()
- var g = document.getElementById('comment') || 0;
- var h = {
- strong: function() {
- addEditor(g, '', '')
- },
- em: function() {
- addEditor(g, '[p]', '[/p]')
- },
- del: function() {
- addEditor(g, '
', '') - },
- sign: function() {
- addEditor(g, '今天签到啦!时间:' + mytime, '')
- },
- red: function() {
- addEditor(g, '"color: red">', '')
- },
- fuchsia: function() {
- addEditor(g, '"color: fuchsia">', '')
- },
- purple: function() {
- addEditor(g, '"color: purple">', '')
- },
- orange: function() {
- addEditor(g, '"color: orange">', '')
- },
- yellow: function() {
- addEditor(g, '"color: yellow">', '')
- },
- olive: function() {
- addEditor(g, '"color: olive">', '')
- },
- lime: function() {
- addEditor(g, '"color: lime">', '')
- },
- maroon: function() {
- addEditor(g, '"color: maroon">', '')
- },
- aqua: function() {
- addEditor(g, '"color: aqua">', '')
- },
- teal: function() {
- addEditor(g, '"color: teal">', '')
- },
- green: function() {
- addEditor(g, '"color: green">', '')
- },
- blue: function() {
- addEditor(g, '"color: blue">', '')
- },
- navy: function() {
- addEditor(g, '"color: navy">', '')
- },
- gray: function() {
- addEditor(g, '"color: gray">', '')
- },
- deepskyblue: function() {
- addEditor(g, '"color: deepskyblue">', '')
- },
- gold: function() {
- addEditor(g, '"color: gold">', '')
- }, silver: function() {
- addEditor(g, '"color: silver">', '')
- },
- black: function() {
- addEditor(g, '"color: black">', '')
- }
- };
- window['SIMPALED'] = {};
- window['SIMPALED']['Editor'] = h
- });
步骤三、增加css的语法
- /*
- ===========================
- 按钮
- ===========================
- */
- .btn-base
- {
- width: 140px !important;
- height: 49px;
- line-height: 49px;
- display: inline-block !important;
- cursor: pointer;
- border-radius: 5px;
- text-align: center;
- margin: 4px 4px 4px 0;
- color: #fff !important;
- font-size: 14px;
- padding: 0 !important;
- }
- button:hover, button, .sidebar-nav *, .btn-base, .btn-base:hover, .small-btn-base:hover, a.btn-primary:hover, button:hover, .form-actions a.btn {
- transition: all 200ms linear 0s !important;
- }
- .btn-base:hover, .small-btn-base:hover {
- background: none repeat scroll 0 0 #262626 !important;
- color: #FFFFFF !important;
- }
- .btn-hot-pink {
- background-color: #EE2465;
- }
- .btn-pink {
- background-color: #ec6681;
- }
- .btn-purple-low {
- background-color: #5e5668;
- }
- .btn-gray {
- background-color: #9d9ea6;
- }
- .btn-blue-1 {
- background-color: #278aab;
- }
- .btn-blue-2 {
- background-color: #199dac;
- }
- .btn-green {
- background-color: #4c8624;
- }
- .btn-blue-3 {
- background-color: #7fcdcd;
- }
- .btn-orange {
- background-color: #e15d44;
- }
- .btn-red-orange {
- background-color: #dc4123;
- }
- .btn-yellow {
- background-color: #f9c62d;
- }
- .btn-blue-4 {
- background-color: #09c0be;
- }
- div .small-btn-base{
- width: 92px !important;
- text-align: center;
- height: 29px;
- line-height: 29px;
- display: inline-block !important;
- cursor: pointer;
- border-radius: 5px;
- margin: 4px 4px 4px 0;
- color: #fff !important;
- }
- .round-btn {
- border-radius: 25px !important;
- width: 137px !important;
- height: 40px;
- line-height: 37px;
- }
- a.btn-primary:hover, button:hover, .form-actions a.btn:hover {
- background: none repeat scroll 0 0 #262626 !important;
- color: #FFFFFF !important;
- }
- button:hover, button, .sidebar-nav *, .btn-base, .btn-base:hover, .small-btn-base:hover, a.btn-primary:hover, button:hover, .form-actions a.btn {
- transition: all 200ms linear 0s !important;
- }
- /** 评论工具 **/
- #smiley{
- padding-bottom: 10px;
- }
- #editor_tools{
- height: 35px;
- line-height: 32px;
- }
- #editor_tools a{
- color: #777;
- display: inline-block;
- padding: 0 8px;
- height: 30px;
- border-right: 1px solid #ddd;
- }
- #editor_tools a:hover{
- color: #333;
- text-decoration: none;
- }
- #fontcolor{
- width: 377px;
- height: 16px;
- line-height: 20px;
- border: 2px #e0e0e0 solid;
- z-index: 99999;
- padding: 2px 0px 2px 2px;
- }
- #fontcolor a{
- display: inline-block;
- height: 16px;
- width: 16px;
- }