|
3 | 3 |
|
4 | 4 | function cbxchangelog_copyStringToClipboard(str) {
|
5 | 5 | // Create new element
|
6 |
| - var el = document.createElement('textarea'); |
| 6 | + var el = document.createElement('textarea'); |
7 | 7 | // Set value (string to be copied)
|
8 | 8 | el.value = str;
|
9 | 9 | // Set non-editable to avoid focus and move outside of view
|
|
21 | 21 | $(document.body).ready(function ($) {
|
22 | 22 | var awn_options = {
|
23 | 23 | labels: {
|
24 |
| - tip : cbxchangelog_edit.awn_options.tip, |
25 |
| - info : cbxchangelog_edit.awn_options.info, |
26 |
| - success : cbxchangelog_edit.awn_options.success, |
27 |
| - warning : cbxchangelog_edit.awn_options.warning, |
28 |
| - alert : cbxchangelog_edit.awn_options.alert, |
29 |
| - async : cbxchangelog_edit.awn_options.async, |
30 |
| - confirm : cbxchangelog_edit.awn_options.confirm, |
31 |
| - confirmOk : cbxchangelog_edit.awn_options.confirmOk, |
| 24 | + tip: cbxchangelog_edit.awn_options.tip, |
| 25 | + info: cbxchangelog_edit.awn_options.info, |
| 26 | + success: cbxchangelog_edit.awn_options.success, |
| 27 | + warning: cbxchangelog_edit.awn_options.warning, |
| 28 | + alert: cbxchangelog_edit.awn_options.alert, |
| 29 | + async: cbxchangelog_edit.awn_options.async, |
| 30 | + confirm: cbxchangelog_edit.awn_options.confirm, |
| 31 | + confirmOk: cbxchangelog_edit.awn_options.confirmOk, |
32 | 32 | confirmCancel: cbxchangelog_edit.awn_options.confirmCancel
|
33 | 33 | }
|
34 | 34 | };
|
|
83 | 83 |
|
84 | 84 | //sort sponsor item
|
85 | 85 | $element.sortable({
|
86 |
| - group : 'feature_wrap_' + index, |
87 |
| - nested : false, |
88 |
| - vertical : true, |
89 |
| - horizontal : false, |
90 |
| - pullPlaceholder : true, |
91 |
| - handle : '.move-feature', |
92 |
| - placeholder : 'feature_placeholder', |
93 |
| - itemSelector : 'p.feature', |
| 86 | + group: 'feature_wrap_' + index, |
| 87 | + nested: false, |
| 88 | + vertical: true, |
| 89 | + horizontal: false, |
| 90 | + pullPlaceholder: true, |
| 91 | + handle: '.move-feature', |
| 92 | + placeholder: 'feature_placeholder', |
| 93 | + itemSelector: 'p.feature', |
94 | 94 | containerSelector: $element,
|
95 | 95 | });
|
96 | 96 |
|
|
101 | 101 | $('#cbxchangelog_metabox').on('click', 'a.cbxchangelog_add_release', function (e) {
|
102 | 102 | e.preventDefault();
|
103 | 103 |
|
104 |
| - var $this = $(this); |
105 |
| - var $position = $this.data('position'); |
| 104 | + var $this = $(this); |
| 105 | + var $position = $this.data('position'); |
106 | 106 |
|
107 | 107 | //var $counter = Number($this.attr('data-counter'));
|
108 |
| - var $counter = Number($changelog_wrapper.data('counter')); |
| 108 | + var $counter = Number($changelog_wrapper.data('counter')); |
109 | 109 |
|
110 | 110 | //var rendered = Mustache.render($release_template, {increment: $counter, incrementplus: ($counter + 1)});
|
111 | 111 | var rendered = Mustache.render($release_template, {increment: ($counter - 1), incrementplus: ($counter)});
|
|
125 | 125 |
|
126 | 126 | //sort sponsor item
|
127 | 127 | $element.sortable({
|
128 |
| - group : 'feature_wrap_' + index, |
129 |
| - nested : false, |
130 |
| - vertical : true, |
131 |
| - horizontal : false, |
132 |
| - pullPlaceholder : true, |
133 |
| - handle : '.move-feature', |
134 |
| - placeholder : 'feature_placeholder', |
135 |
| - itemSelector : 'p.feature', |
| 128 | + group: 'feature_wrap_' + index, |
| 129 | + nested: false, |
| 130 | + vertical: true, |
| 131 | + horizontal: false, |
| 132 | + pullPlaceholder: true, |
| 133 | + handle: '.move-feature', |
| 134 | + placeholder: 'feature_placeholder', |
| 135 | + itemSelector: 'p.feature', |
136 | 136 | containerSelector: $element,
|
137 | 137 | });
|
138 | 138 | });
|
|
142 | 142 | $changelog_wrapper.on('click', '.trash-release', function (e) {
|
143 | 143 | e.preventDefault();
|
144 | 144 |
|
145 |
| - var $this = $(this); |
146 |
| - var $post_id = Number($this.data('post-id')); |
| 145 | + var $this = $(this); |
| 146 | + var $post_id = Number($this.data('post-id')); |
147 | 147 | var $relesae_id = Number($this.data('id'));
|
148 | 148 |
|
149 | 149 | var notifier = new AWN(awn_options);
|
|
159 | 159 | });
|
160 | 160 | } else {
|
161 | 161 | $.ajax({
|
162 |
| - type : 'post', |
| 162 | + type: 'post', |
163 | 163 | dataType: 'json',
|
164 |
| - url : cbxchangelog_edit.ajaxurl, |
165 |
| - data : { |
166 |
| - action : 'cbxchangelog_release_delete', |
167 |
| - security : cbxchangelog_edit.nonce, |
168 |
| - post_id : $post_id, |
| 164 | + url: cbxchangelog_edit.ajaxurl, |
| 165 | + data: { |
| 166 | + action: 'cbxchangelog_release_delete', |
| 167 | + security: cbxchangelog_edit.nonce, |
| 168 | + post_id: $post_id, |
169 | 169 | release_id: $relesae_id
|
170 | 170 | },
|
171 |
| - success : function (data, textStatus, XMLHttpRequest) { |
| 171 | + success: function (data, textStatus, XMLHttpRequest) { |
172 | 172 |
|
173 | 173 | if (data.success) {
|
174 | 174 | $this.closest('.cbxchangelog_release').fadeOut('slow', function () {
|
|
201 | 201 | $changelog_wrapper.on('click', '.add-feature', function (e) {
|
202 | 202 | e.preventDefault();
|
203 | 203 |
|
204 |
| - var $this = $(this); |
205 |
| - var $parent = $this.parents('.release-feature-wrap'); |
| 204 | + var $this = $(this); |
| 205 | + var $parent = $this.parents('.release-feature-wrap'); |
206 | 206 | var $counter = $parent.data('boxincrement');
|
207 | 207 |
|
208 | 208 | var rendered = Mustache.render($feature_template, {increment: $counter});
|
|
253 | 253 |
|
254 | 254 | });
|
255 | 255 |
|
| 256 | + //resync release no/id with index (top to bottom or bottom to top) |
| 257 | + $('#cbxchangelog_toolbar_extras').on('click', 'a.cbxchangelog_resync_releases', function (e) { |
| 258 | + e.preventDefault(); |
| 259 | + |
| 260 | + var $this = $(this); |
| 261 | + var $post_id = Number($this.data('post-id')); |
| 262 | + var $dir = Number($this.data('dir')); |
| 263 | + var $confirm_desc = ($dir) ? cbxchangelog_edit.resync.confirm_desc : cbxchangelog_edit.resync.confirm_desc_alt; |
| 264 | + |
| 265 | + var notifier = new AWN(awn_options); |
| 266 | + |
| 267 | + var onCancel = () => { |
| 268 | + }; |
| 269 | + |
| 270 | + var onOk = () => { |
| 271 | + $this.prop('disabled', true); |
| 272 | + $this.addClass('running'); |
| 273 | + |
| 274 | + $.ajax({ |
| 275 | + type: 'post', |
| 276 | + dataType: 'json', |
| 277 | + url: cbxchangelog_edit.ajaxurl, |
| 278 | + data: { |
| 279 | + action: 'cbxchangelog_release_resync', |
| 280 | + security: cbxchangelog_edit.nonce, |
| 281 | + post_id: $post_id, |
| 282 | + dir: $dir |
| 283 | + }, |
| 284 | + success: function (data, textStatus, XMLHttpRequest) { |
| 285 | + if (data.success) { |
| 286 | + new AWN(awn_options).success(data.message); |
| 287 | + |
| 288 | + location.reload(); |
| 289 | + } else { |
| 290 | + new AWN(awn_options).alert(data.message); |
| 291 | + } |
| 292 | + }//end of success |
| 293 | + });//end of ajax |
| 294 | + }; |
| 295 | + |
| 296 | + notifier.confirm( |
| 297 | + $confirm_desc, |
| 298 | + onOk, |
| 299 | + onCancel, |
| 300 | + { |
| 301 | + labels: { |
| 302 | + confirm: cbxchangelog_edit.resync.confirm |
| 303 | + } |
| 304 | + } |
| 305 | + ); |
| 306 | + }); |
| 307 | + |
| 308 | + //delete all releases |
| 309 | + $('#cbxchangelog_toolbar_extras').on('click', 'a.cbxchangelog_delete_releases', function (e) { |
| 310 | + e.preventDefault(); |
| 311 | + |
| 312 | + var $this = $(this); |
| 313 | + var $post_id = Number($this.data('post-id')); |
| 314 | + |
| 315 | + var notifier = new AWN(awn_options); |
| 316 | + |
| 317 | + var onCancel = () => { |
| 318 | + }; |
| 319 | + |
| 320 | + var onOk = () => { |
| 321 | + $this.prop('disabled', true); |
| 322 | + $this.addClass('running'); |
| 323 | + |
| 324 | + $.ajax({ |
| 325 | + type: 'post', |
| 326 | + dataType: 'json', |
| 327 | + url: cbxchangelog_edit.ajaxurl, |
| 328 | + data: { |
| 329 | + action: 'cbxchangelog_delete_releases', |
| 330 | + security: cbxchangelog_edit.nonce, |
| 331 | + post_id: $post_id |
| 332 | + }, |
| 333 | + success: function (data, textStatus, XMLHttpRequest) { |
| 334 | + if (data.success) { |
| 335 | + new AWN(awn_options).success(data.message); |
| 336 | + |
| 337 | + location.reload(); |
| 338 | + } else { |
| 339 | + new AWN(awn_options).alert(data.message); |
| 340 | + } |
| 341 | + }//end of success |
| 342 | + });//end of ajax |
| 343 | + }; |
| 344 | + |
| 345 | + notifier.confirm( |
| 346 | + cbxchangelog_edit.deleteconfirm_all_releases, |
| 347 | + onOk, |
| 348 | + onCancel, |
| 349 | + { |
| 350 | + labels: { |
| 351 | + confirm: cbxchangelog_edit.deleteconfirm |
| 352 | + } |
| 353 | + } |
| 354 | + ); |
| 355 | + }); |
| 356 | + |
256 | 357 | //sorting releases
|
257 | 358 | $changelog_wrapper.sortable({
|
258 |
| - group : 'cbxchangelog_releases', |
259 |
| - nested : false, |
260 |
| - vertical : true, |
261 |
| - horizontal : false, |
262 |
| - pullPlaceholder : true, |
263 |
| - handle : '.move-release', |
264 |
| - placeholder : 'cbxchangelog_release_placeholder', |
265 |
| - itemSelector : 'div.cbxchangelog_release', |
| 359 | + group: 'cbxchangelog_releases', |
| 360 | + nested: false, |
| 361 | + vertical: true, |
| 362 | + horizontal: false, |
| 363 | + pullPlaceholder: true, |
| 364 | + handle: '.move-release', |
| 365 | + placeholder: 'cbxchangelog_release_placeholder', |
| 366 | + itemSelector: 'div.cbxchangelog_release', |
266 | 367 | containerSelector: 'div#cbxchangelog_wrapper'
|
267 | 368 | });
|
268 | 369 |
|
|
0 commit comments