PluginProbe
Page & Post Notes / 1.2.0
Page & Post Notes v1.2.0
trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5
page-post-notes / include / script.php

script.php in Page & Post Notes 1.2.0, at include/script.php

126 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
2 <script>
3
4
5 jQuery(document).ready(function($){
6
7 // dealing with adding notes when clicking on the button
8 $(document).on('click', '.yydev-notes a.add-notes-button', function () {
9
10 if( !$(this).hasClass('yy-another-notes') ) {
11
12 $('.yydev-notes .add-notes-button').html('+ Add Another Note');
13 $('.yydev-notes .add-notes-button').addClass('yy-another-notes');
14 $('.yydev-notes .yydev-textarea-note').removeClass('not-active-notes');
15 $('.yydev-notes .table_notes').focus();
16
17 } // if( !$(this).hasClass('yy-another-notes') ) {
18
19 return false;
20
21 }); // $(document).on('click', 'a.move-keyword-up', function () {
22
23
24 // dealing with creating another notes box
25 $(document).on('click', '.yy-another-notes', function () {
26
27 var lastYYnotes = $('.yydev-textarea-note').last();
28 lastYYnotes.clone().insertAfter(lastYYnotes);
29 $(".yydev-textarea-note").last().find('.table_notes').val('');
30
31 return false;
32
33 }); // $(document).on('click', 'a.move-keyword-up', function () {
34
35
36 // delating with adding text separator notes
37 $(document).on('click', '.yydev-notes a.text-separator_btn', function () {
38
39 // function that helps add a line on the textarea
40 // **textareaClass**.yydevSeoAddSeparator('startCode', endCode)
41 jQuery.fn.extend({
42 yydevNotesAddSeparator: function(myValue, myValueE) {
43
44 return this.each(function(i) {
45
46 //For browsers like Firefox and Webkit based
47 var startPos = this.selectionStart;
48 var endPos = this.selectionEnd;
49 var scrollTop = this.scrollTop;
50 this.value = this.value.substring(0,startPos)+myValue+this.value.substring(startPos,endPos)+myValueE+this.value.substring(endPos,this.value.length);
51 this.focus();
52 this.selectionStart = startPos + myValue.length;
53 this.selectionEnd = ((startPos + myValue.length) + this.value.substring(startPos,endPos).length);
54 this.scrollTop = scrollTop;
55
56 })
57
58 } // return this.each(function(i) {
59 }); // jQuery.fn.extend({
60
61 var currentTextArea = $(this).parent().find(".table_notes");
62 currentTextArea.yydevNotesAddSeparator("\n" + "--------------------------" + "\n", '');
63
64 return false;
65
66 }); // $(document).on('click', '.yydev-notes a.retext-separator_btn', function () {
67
68
69 // delating with removing notees
70 $(document).on('click', '.yydev-notes a.remove-notes-btn', function () {
71
72 if ( confirm("Are you sure you want to permanently remove the page note?") ) {
73
74 if( $('.yydev-textarea-note').length > 1 ) {
75
76 // if there is more than one note remove it
77 $(this).parent().remove();
78
79 } else { // if( $('.yydev-textarea-note').length > 1 ) {
80
81 // if there is only one note hide it
82 $(this).parent().addClass('not-active-notes');
83 $(this).parent().find('.table_notes').val('');
84
85 $('.add-notes-button').removeClass('not-active-notes');
86 $('.yydev-notes .add-notes-button').html('+ Add Page Note');
87 $('.yydev-notes .add-notes-button').removeClass('yy-another-notes');
88
89 } // if( $('.yydev-textarea-note').length > 1 ) {
90
91 } // if ( confirm("Are you sure you want to remove the page note?") ) {
92
93 return false;
94
95 }); // $(document).on('click', 'a.move-keyword-up', function () {
96
97
98 // delating with text direction
99 $(document).on('click', '.yydev-notes a.text-direction_btn', function () {
100
101 var notesDirections = $(this).parent().find('.table_notes');
102
103 if( notesDirections.hasClass('direction-rtl') ) {
104
105 notesDirections.removeClass('direction-rtl');
106 notesDirections.addClass('direction-ltr');
107 $(this).parent().find('.yydev_direction_class').val('direction-ltr');
108 $(this).parent().find('.table_notes').focus();
109
110 } else { // if( notesDirections.hasClass('direction-rtl') ) {
111
112 notesDirections.removeClass('direction-ltr');
113 notesDirections.addClass('direction-rtl');
114 $(this).parent().find('.yydev_direction_class').val('direction-rtl');
115 $(this).parent().find('.table_notes').focus();
116
117 } // } else { // if( notesDirections.hasClass('direction-rtl') ) {
118
119 return false;
120
121 }); // $(document).on('click', '.yydev-notes a.text-direction_btn', function () {
122
123
124 }); // jQuery(document).ready(function($){
125
126 </script>