| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?> |
| 2 |
<script> |
| 3 |
|
| 4 |
jQuery(document).ready(function($){ |
| 5 |
|
| 6 |
// dealing with adding notes when clicking on the button |
| 7 |
$(document).on('click', '.yydev-notes a.add-notes-button', function () { |
| 8 |
|
| 9 |
if( !$(this).hasClass('yy-another-notes') ) { |
| 10 |
|
| 11 |
$('.yydev-notes .add-notes-button').html('+ Add Another Note'); |
| 12 |
$('.yydev-notes .add-notes-button').addClass('yy-another-notes'); |
| 13 |
$('.yydev-notes .yydev-textarea-note').removeClass('not-active-notes'); |
| 14 |
$('.yydev-notes .table_notes').focus(); |
| 15 |
|
| 16 |
} // if( !$(this).hasClass('yy-another-notes') ) { |
| 17 |
|
| 18 |
return false; |
| 19 |
|
| 20 |
}); // $(document).on('click', 'a.move-keyword-up', function () { |
| 21 |
|
| 22 |
|
| 23 |
// dealing with creating another notes box |
| 24 |
$(document).on('click', '.yy-another-notes', function () { |
| 25 |
|
| 26 |
var lastYYnotes = $('.yydev-textarea-note').last(); |
| 27 |
lastYYnotes.clone().insertAfter(lastYYnotes); |
| 28 |
$(".yydev-textarea-note").last().find('.table_notes').val(''); |
| 29 |
|
| 30 |
return false; |
| 31 |
|
| 32 |
}); // $(document).on('click', 'a.move-keyword-up', function () { |
| 33 |
|
| 34 |
|
| 35 |
// delating with adding text separator notes |
| 36 |
$(document).on('click', '.yydev-notes a.text-separator_btn', function () { |
| 37 |
|
| 38 |
// function that helps add a line on the textarea |
| 39 |
// **textareaClass**.yydevSeoAddSeparator('startCode', endCode) |
| 40 |
jQuery.fn.extend({ |
| 41 |
yydevNotesAddSeparator: function(myValue, myValueE) { |
| 42 |
|
| 43 |
return this.each(function(i) { |
| 44 |
|
| 45 |
//For browsers like Firefox and Webkit based |
| 46 |
var startPos = this.selectionStart; |
| 47 |
var endPos = this.selectionEnd; |
| 48 |
var scrollTop = this.scrollTop; |
| 49 |
this.value = this.value.substring(0,startPos)+myValue+this.value.substring(startPos,endPos)+myValueE+this.value.substring(endPos,this.value.length); |
| 50 |
this.focus(); |
| 51 |
this.selectionStart = startPos + myValue.length; |
| 52 |
this.selectionEnd = ((startPos + myValue.length) + this.value.substring(startPos,endPos).length); |
| 53 |
this.scrollTop = scrollTop; |
| 54 |
|
| 55 |
}) |
| 56 |
|
| 57 |
} // return this.each(function(i) { |
| 58 |
}); // jQuery.fn.extend({ |
| 59 |
|
| 60 |
var currentTextArea = $(this).parent().find(".table_notes"); |
| 61 |
currentTextArea.yydevNotesAddSeparator("\n" + "--------------------------" + "\n", ''); |
| 62 |
|
| 63 |
return false; |
| 64 |
|
| 65 |
}); // $(document).on('click', '.yydev-notes a.retext-separator_btn', function () { |
| 66 |
|
| 67 |
|
| 68 |
// delating with removing notees |
| 69 |
$(document).on('click', '.yydev-notes a.remove-notes-btn', function () { |
| 70 |
|
| 71 |
if ( confirm("Are you sure you want to permanently remove the page note?") ) { |
| 72 |
|
| 73 |
if( $('.yydev-textarea-note').length > 1 ) { |
| 74 |
|
| 75 |
// if there is more than one note remove it |
| 76 |
$(this).parent().remove(); |
| 77 |
|
| 78 |
} else { // if( $('.yydev-textarea-note').length > 1 ) { |
| 79 |
|
| 80 |
// if there is only one note hide it |
| 81 |
$(this).parent().addClass('not-active-notes'); |
| 82 |
$(this).parent().find('.table_notes').val(''); |
| 83 |
|
| 84 |
$('.add-notes-button').removeClass('not-active-notes'); |
| 85 |
$('.yydev-notes .add-notes-button').html('+ Add Page Note'); |
| 86 |
$('.yydev-notes .add-notes-button').removeClass('yy-another-notes'); |
| 87 |
|
| 88 |
} // if( $('.yydev-textarea-note').length > 1 ) { |
| 89 |
|
| 90 |
} // if ( confirm("Are you sure you want to remove the page note?") ) { |
| 91 |
|
| 92 |
return false; |
| 93 |
|
| 94 |
}); // $(document).on('click', 'a.move-keyword-up', function () { |
| 95 |
|
| 96 |
|
| 97 |
// delating with text direction |
| 98 |
$(document).on('click', '.yydev-notes a.text-direction_btn', function () { |
| 99 |
|
| 100 |
var notesDirections = $(this).parent().find('.table_notes'); |
| 101 |
|
| 102 |
if( notesDirections.hasClass('direction-rtl') ) { |
| 103 |
|
| 104 |
notesDirections.removeClass('direction-rtl'); |
| 105 |
notesDirections.addClass('direction-ltr'); |
| 106 |
$(this).parent().find('.yydev_direction_class').val('direction-ltr'); |
| 107 |
$(this).parent().find('.table_notes').focus(); |
| 108 |
|
| 109 |
} else { // if( notesDirections.hasClass('direction-rtl') ) { |
| 110 |
|
| 111 |
notesDirections.removeClass('direction-ltr'); |
| 112 |
notesDirections.addClass('direction-rtl'); |
| 113 |
$(this).parent().find('.yydev_direction_class').val('direction-rtl'); |
| 114 |
$(this).parent().find('.table_notes').focus(); |
| 115 |
|
| 116 |
} // } else { // if( notesDirections.hasClass('direction-rtl') ) { |
| 117 |
|
| 118 |
return false; |
| 119 |
|
| 120 |
}); // $(document).on('click', '.yydev-notes a.text-direction_btn', function () { |
| 121 |
|
| 122 |
|
| 123 |
// ==================================================== |
| 124 |
// saving data with ajax when save notes on dashboard |
| 125 |
// ==================================================== |
| 126 |
|
| 127 |
$(document).on('click', '.yydev-notes a.dashbaord-save-button', function () { |
| 128 |
|
| 129 |
$('.yydev-notes .yydev-notes-ajax-data').html('').css('display', 'block'); |
| 130 |
|
| 131 |
var data = { |
| 132 |
'action': 'yydev_notes_save_dashboard_data', |
| 133 |
'yydev_direction_class': $(".yydev-notes [name='yydev_direction_class[]']").map(function(){return $(this).val();}).get(), |
| 134 |
'yydev_notes': $(".yydev-notes [name='yydev_notes[]']").map(function(){return $(this).val();}).get(), |
| 135 |
'yydev_notes_id': $(".yydev-notes [name='yydev_notes_id']").val(), |
| 136 |
'yydev_notes_nonce': $(".yydev-notes [name='yydev_notes_nonce']").val(), |
| 137 |
'yydev_notes_page_id': $(".yydev-notes [name='yydev_notes_page_id']").val() |
| 138 |
}; |
| 139 |
|
| 140 |
jQuery.ajax({ url: '<?php echo admin_url('admin-ajax.php'); ?>', type: 'POST', data: data, |
| 141 |
beforeSent: $('.yydev-notes a.dashbaord-save-button').addClass('dashbaord-save-button-ajax'), |
| 142 |
success: function (response) { |
| 143 |
$('.yydev-notes a.dashbaord-save-button').removeClass('dashbaord-save-button-ajax') |
| 144 |
$('.yydev-notes .yydev-notes-ajax-data').html(response).delay(1000).fadeOut(); |
| 145 |
} //success: function (response) { |
| 146 |
}); |
| 147 |
|
| 148 |
|
| 149 |
return false; |
| 150 |
|
| 151 |
}); // $(".yydev-notes a.dashbaord-save-button").live('click', function() { |
| 152 |
|
| 153 |
|
| 154 |
}); // jQuery(document).ready(function($){ |
| 155 |
|
| 156 |
</script> |