admin.js
1601 lines
| 1 | /** |
| 2 | * plugin admin area javascript |
| 3 | */ |
| 4 | (function($){$(function () { |
| 5 | |
| 6 | if ( ! $('body.wpallexport-plugin').length) return; // do not execute any code if we are not on plugin page |
| 7 | |
| 8 | // fix layout position |
| 9 | setTimeout(function () { |
| 10 | $('table.wpallexport-layout').length && $('table.wpallexport-layout td.left h2:first-child').css('margin-top', $('.wrap').offset().top - $('table.wpallexport-layout').offset().top); |
| 11 | }, 10); |
| 12 | |
| 13 | // help icons |
| 14 | $('a.wpallexport-help').tipsy({ |
| 15 | gravity: function() { |
| 16 | var ver = 'n'; |
| 17 | if ($(document).scrollTop() < $(this).offset().top - $('.tipsy').height() - 2) { |
| 18 | ver = 's'; |
| 19 | } |
| 20 | var hor = ''; |
| 21 | if ($(this).offset().left + $('.tipsy').width() < $(window).width() + $(document).scrollLeft()) { |
| 22 | hor = 'w'; |
| 23 | } else if ($(this).offset().left - $('.tipsy').width() > $(document).scrollLeft()) { |
| 24 | hor = 'e'; |
| 25 | } |
| 26 | return ver + hor; |
| 27 | }, |
| 28 | live: true, |
| 29 | html: true, |
| 30 | opacity: 1 |
| 31 | }).live('click', function () { |
| 32 | return false; |
| 33 | }).each(function () { // fix tipsy title for IE |
| 34 | $(this).attr('original-title', $(this).attr('title')); |
| 35 | $(this).removeAttr('title'); |
| 36 | }); |
| 37 | |
| 38 | if ($('#wp_all_export_code').length){ |
| 39 | var editor = CodeMirror.fromTextArea(document.getElementById("wp_all_export_code"), { |
| 40 | lineNumbers: true, |
| 41 | matchBrackets: true, |
| 42 | mode: "application/x-httpd-php", |
| 43 | indentUnit: 4, |
| 44 | indentWithTabs: true, |
| 45 | lineWrapping: true |
| 46 | }); |
| 47 | editor.setCursor(1); |
| 48 | $('.CodeMirror').resizable({ |
| 49 | resize: function() { |
| 50 | editor.setSize("100%", $(this).height()); |
| 51 | } |
| 52 | }); |
| 53 | } |
| 54 | |
| 55 | // swither show/hide logic |
| 56 | $('input.switcher').live('change', function (e) { |
| 57 | |
| 58 | if ($(this).is(':radio:checked')) { |
| 59 | $(this).parents('form').find('input.switcher:radio[name="' + $(this).attr('name') + '"]').not(this).change(); |
| 60 | } |
| 61 | var $switcherID = $(this).attr('id'); |
| 62 | var $targets = $('.switcher-target-' + $switcherID); |
| 63 | |
| 64 | var is_show = $(this).is(':checked'); if ($(this).is('.switcher-reversed')) is_show = ! is_show; |
| 65 | if (is_show) { |
| 66 | $targets.fadeIn('fast', function(){ |
| 67 | if ($switcherID == 'coperate_php'){ |
| 68 | editor.setCursor(1); |
| 69 | } |
| 70 | }); |
| 71 | } else { |
| 72 | $targets.hide().find('.clear-on-switch').add($targets.filter('.clear-on-switch')).val(''); |
| 73 | } |
| 74 | }).change(); |
| 75 | |
| 76 | // swither show/hide logic |
| 77 | $('input.switcher-horizontal').live('change', function (e) { |
| 78 | |
| 79 | if ($(this).is(':checked')) { |
| 80 | $(this).parents('form').find('input.switcher-horizontal[name="' + $(this).attr('name') + '"]').not(this).change(); |
| 81 | } |
| 82 | var $targets = $('.switcher-target-' + $(this).attr('id')); |
| 83 | |
| 84 | var is_show = $(this).is(':checked'); if ($(this).is('.switcher-reversed')) is_show = ! is_show; |
| 85 | |
| 86 | if (is_show) { |
| 87 | $targets.animate({width:'205px'}, 350); |
| 88 | } else { |
| 89 | $targets.animate({width:'0px'}, 1000).find('.clear-on-switch').add($targets.filter('.clear-on-switch')).val(''); |
| 90 | } |
| 91 | }).change(); |
| 92 | |
| 93 | // autoselect input content on click |
| 94 | $('input.selectable').live('click', function () { |
| 95 | $(this).select(); |
| 96 | }); |
| 97 | |
| 98 | $('.pmxe_choosen').each(function(){ |
| 99 | $(this).find(".choosen_input").select2({tags: $(this).find('.choosen_values').html().split(',')}); |
| 100 | }); |
| 101 | |
| 102 | // choose file form: option selection dynamic |
| 103 | // options form: highlight options of selected post type |
| 104 | $('form.choose-post-type input[name="type"]').click(function() { |
| 105 | var $container = $(this).parents('.file-type-container'); |
| 106 | $('.file-type-container').not($container).removeClass('selected').find('.file-type-options').hide(); |
| 107 | $container.addClass('selected').find('.file-type-options').show(); |
| 108 | }).filter(':checked').click(); |
| 109 | |
| 110 | $('.wpallexport-collapsed').each(function(){ |
| 111 | |
| 112 | if ( ! $(this).hasClass('closed')) $(this).find('.wpallexport-collapsed-content:first').slideDown(); |
| 113 | |
| 114 | }); |
| 115 | |
| 116 | $('.wpallexport-collapsed').find('.wpallexport-collapsed-header').live('click', function(){ |
| 117 | var $parent = $(this).parents('.wpallexport-collapsed:first'); |
| 118 | if ($parent.hasClass('closed')){ |
| 119 | $parent.removeClass('closed'); |
| 120 | $parent.find('.wpallexport-collapsed-content:first').slideDown(); |
| 121 | } |
| 122 | else{ |
| 123 | $parent.addClass('closed'); |
| 124 | $parent.find('.wpallexport-collapsed-content:first').slideUp(); |
| 125 | } |
| 126 | }); |
| 127 | |
| 128 | // [ Helper functions ] |
| 129 | |
| 130 | var get_valid_ajaxurl = function() |
| 131 | { |
| 132 | var $URL = ajaxurl; |
| 133 | if (typeof export_id != "undefined") |
| 134 | { |
| 135 | if ($URL.indexOf("?") == -1) |
| 136 | { |
| 137 | $URL += '?id=' + export_id; |
| 138 | } |
| 139 | else |
| 140 | { |
| 141 | $URL += '&id=' + export_id; |
| 142 | } |
| 143 | } |
| 144 | return $URL; |
| 145 | } |
| 146 | |
| 147 | // generate warning on a fly when required fields deleting from the export template |
| 148 | var trigger_warnings = function() |
| 149 | { |
| 150 | |
| 151 | var missing_fields = ['id']; |
| 152 | |
| 153 | if ( $('#is_product_export').length ) missing_fields = missing_fields.concat(['_sku', 'product_type']); |
| 154 | if ( $('#is_wp_query').length ) missing_fields.push('post_type'); |
| 155 | |
| 156 | $('#columns').find('li:not(.placeholder)').each(function(i, e){ |
| 157 | $(this).find('div.custom_column:first').attr('rel', i + 1); |
| 158 | if ($(this).find('input[name^=cc_type]').val() == 'id'){ |
| 159 | var index = missing_fields.indexOf('id'); |
| 160 | if (index > -1) { |
| 161 | missing_fields.splice(index, 1); |
| 162 | } |
| 163 | } |
| 164 | if ($(this).find('input[name^=cc_label]').val() == '_sku'){ |
| 165 | var index = missing_fields.indexOf('_sku'); |
| 166 | if (index > -1) { |
| 167 | missing_fields.splice(index, 1); |
| 168 | } |
| 169 | |
| 170 | } |
| 171 | if ($(this).find('input[name^=cc_label]').val() == 'product_type'){ |
| 172 | var index = missing_fields.indexOf('product_type'); |
| 173 | if (index > -1) { |
| 174 | missing_fields.splice(index, 1); |
| 175 | } |
| 176 | } |
| 177 | if ($(this).find('input[name^=cc_label]').val() == 'post_type'){ |
| 178 | var index = missing_fields.indexOf('post_type'); |
| 179 | if (index > -1) { |
| 180 | missing_fields.splice(index, 1); |
| 181 | } |
| 182 | } |
| 183 | }); |
| 184 | |
| 185 | if ( missing_fields.length ) |
| 186 | { |
| 187 | var fields = ''; |
| 188 | switch (missing_fields.length) |
| 189 | { |
| 190 | case 1: |
| 191 | fields = missing_fields.shift(); |
| 192 | break; |
| 193 | case 2: |
| 194 | fields = missing_fields.join(" and "); |
| 195 | break; |
| 196 | default: |
| 197 | var latest_field = missing_fields.pop(); |
| 198 | fields = missing_fields.join(", ") + ", and " + latest_field; |
| 199 | break; |
| 200 | } |
| 201 | |
| 202 | var warning_template = $('#warning_template').length ? $('#warning_template').val().replace("%s", fields) : ''; |
| 203 | |
| 204 | $('.wp-all-export-warning').find('p').html(warning_template); |
| 205 | $('.wp-all-export-warning').show(); |
| 206 | } |
| 207 | else |
| 208 | { |
| 209 | $('.wp-all-export-warning').hide(); |
| 210 | } |
| 211 | |
| 212 | } |
| 213 | |
| 214 | // Get a valid filtering rules for selected field type |
| 215 | var init_filtering_fields = function(){ |
| 216 | |
| 217 | var wp_all_export_rules_config = { |
| 218 | '#wp_all_export_xml_element' : {width:"98%"}, |
| 219 | '#wp_all_export_rule' : {width:"98%"}, |
| 220 | } |
| 221 | |
| 222 | for (var selector in wp_all_export_rules_config) { |
| 223 | |
| 224 | $(selector).chosen(wp_all_export_rules_config[selector]); |
| 225 | |
| 226 | if (selector == '#wp_all_export_xml_element'){ |
| 227 | |
| 228 | $(selector).on('change', function(evt, params) { |
| 229 | |
| 230 | $('#wp_all_export_available_rules').html('<div class="wp_all_export_preloader" style="display:block;"></div>'); |
| 231 | |
| 232 | var date_fields = ['post_date', 'comment_date', 'user_registered']; |
| 233 | |
| 234 | if ( date_fields.indexOf(params.selected) > -1 ) |
| 235 | { |
| 236 | $('#date_field_notice').show(); |
| 237 | } |
| 238 | else |
| 239 | { |
| 240 | $('#date_field_notice').hide(); |
| 241 | } |
| 242 | |
| 243 | var request = { |
| 244 | action: 'wpae_available_rules', |
| 245 | data: {'selected' : params.selected}, |
| 246 | security: wp_all_export_security |
| 247 | }; |
| 248 | $.ajax({ |
| 249 | type: 'POST', |
| 250 | url: ajaxurl, |
| 251 | data: request, |
| 252 | success: function(response) { |
| 253 | $('#wp_all_export_available_rules').html(response.html); |
| 254 | $('#wp_all_export_rule').chosen({width:"98%"}); |
| 255 | $('#wp_all_export_rule').on('change', function(evt, params) { |
| 256 | if (params.selected == 'is_empty' || params.selected == 'is_not_empty') |
| 257 | $('#wp_all_export_value').hide(); |
| 258 | else |
| 259 | $('#wp_all_export_value').show(); |
| 260 | }); |
| 261 | }, |
| 262 | dataType: "json" |
| 263 | }); |
| 264 | }); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | $('.wp_all_export_filtering_rules').pmxe_nestedSortable({ |
| 269 | handle: 'div', |
| 270 | items: 'li.dragging', |
| 271 | toleranceElement: '> div', |
| 272 | update: function () { |
| 273 | $('.wp_all_export_filtering_rules').find('.condition').removeClass('last_condition').show(); |
| 274 | $('.wp_all_export_filtering_rules').find('.condition:last').addClass('last_condition'); |
| 275 | liveFiltering(); |
| 276 | } |
| 277 | }); |
| 278 | |
| 279 | } |
| 280 | |
| 281 | var is_first_load = true; |
| 282 | |
| 283 | var filtering = function(postType){ |
| 284 | |
| 285 | var is_preload = $('.wpallexport-preload-post-data').val(); |
| 286 | var filter_rules_hierarhy = parseInt(is_preload) ? $('input[name=filter_rules_hierarhy]').val() : ''; |
| 287 | |
| 288 | $('.wpallexport-preload-post-data').val(0); |
| 289 | |
| 290 | var request = { |
| 291 | action: 'wpae_filtering', |
| 292 | data: {'cpt' : postType, 'export_type' : 'specific', 'filter_rules_hierarhy' : filter_rules_hierarhy, 'product_matching_mode' : 'strict'}, |
| 293 | security: wp_all_export_security |
| 294 | }; |
| 295 | |
| 296 | if (is_first_load == false || postType != '') $('.wp_all_export_preloader').show(); |
| 297 | |
| 298 | $.ajax({ |
| 299 | type: 'POST', |
| 300 | url: ajaxurl, |
| 301 | data: request, |
| 302 | success: function(response) { |
| 303 | |
| 304 | $('.wp_all_export_preloader').hide(); |
| 305 | |
| 306 | var export_type = $('input[name=export_type]').val(); |
| 307 | |
| 308 | if (export_type == 'advanced') |
| 309 | { |
| 310 | $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideUp(); |
| 311 | $('.wpallexport-choose-file').find('.wp_all_export_continue_step_two').html(response.btns); |
| 312 | $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').show(); |
| 313 | } |
| 314 | else |
| 315 | { |
| 316 | if (postType != '') |
| 317 | { |
| 318 | |
| 319 | $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').html(response.html); |
| 320 | $('.wpallexport-choose-file').find('.wp_all_export_continue_step_two').html(response.btns); |
| 321 | |
| 322 | init_filtering_fields(); |
| 323 | liveFiltering(is_first_load); |
| 324 | } |
| 325 | else |
| 326 | { |
| 327 | $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideUp(); |
| 328 | $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide(); |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | is_first_load = false; |
| 333 | |
| 334 | }, |
| 335 | error: function( jqXHR, textStatus ) { |
| 336 | |
| 337 | $('.wp_all_export_preloader').hide(); |
| 338 | |
| 339 | }, |
| 340 | dataType: "json" |
| 341 | }); |
| 342 | |
| 343 | } |
| 344 | |
| 345 | var liveFiltering = function(first_load, after_filtering){ |
| 346 | |
| 347 | // serialize filters |
| 348 | $('.hierarhy-output').each(function(){ |
| 349 | var sortable = $('.wp_all_export_filtering_rules.ui-sortable'); |
| 350 | if (sortable.length){ |
| 351 | $(this).val(window.JSON.stringify(sortable.pmxe_nestedSortable('toArray', {startDepthCount: 0}))); |
| 352 | } |
| 353 | }); |
| 354 | |
| 355 | var postType = $('input[name=cpt]').length ? $('input[name=cpt]').val() : $('input[name=selected_post_type]').val(); |
| 356 | |
| 357 | // prepare data for ajax request to get post count after filtering |
| 358 | var request = { |
| 359 | action: 'wpae_filtering_count', |
| 360 | data: { |
| 361 | 'cpt' : postType, |
| 362 | 'filter_rules_hierarhy' : $('input[name=filter_rules_hierarhy]').val(), |
| 363 | 'product_matching_mode' : $('select[name=product_matching_mode]').length ? $('select[name=product_matching_mode]').val() : '', |
| 364 | 'is_confirm_screen' : $('.wpallexport-step-4').length, |
| 365 | 'is_template_screen' : $('.wpallexport-step-3').length, |
| 366 | 'export_only_new_stuff' : $('#export_only_new_stuff').is(':checked') ? 1 : 0, |
| 367 | 'export_type' : $('input[name=export_type]').val() |
| 368 | }, |
| 369 | security: wp_all_export_security |
| 370 | }; |
| 371 | |
| 372 | $('.wp_all_export_preloader').show(); |
| 373 | $('.wp_all_export_filter_preloader').show(); |
| 374 | |
| 375 | $.ajax({ |
| 376 | type: 'POST', |
| 377 | url: get_valid_ajaxurl(), |
| 378 | data: request, |
| 379 | success: function(response) { |
| 380 | |
| 381 | $('.wp_all_export_filter_preloader').hide(); |
| 382 | |
| 383 | $('#filtering_result').html(response.html); |
| 384 | |
| 385 | $('.wpallexport-choose-file').find('.wpallexport-filtering-wrapper').slideDown(400, function(){ |
| 386 | if (typeof first_load != 'undefined') |
| 387 | { |
| 388 | $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideDown(); |
| 389 | $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').addClass('closed'); |
| 390 | $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').show(); |
| 391 | } |
| 392 | }); |
| 393 | |
| 394 | $('.wp_all_export_preloader').hide(); |
| 395 | |
| 396 | if (typeof after_filtering != 'undefined') |
| 397 | { |
| 398 | after_filtering(response); |
| 399 | } |
| 400 | |
| 401 | if ( $('.wpallexport-step-4').length && typeof wp_all_export_L10n != 'undefined'){ |
| 402 | |
| 403 | if (response.found_records) |
| 404 | { |
| 405 | $('.wp_all_export_confirm_and_run').show(); |
| 406 | $('.confirm_and_run_bottom').val(wp_all_export_L10n.confirm_and_run); |
| 407 | $('#filtering_result').removeClass('nothing_to_export'); |
| 408 | } |
| 409 | else |
| 410 | { |
| 411 | $('.wp_all_export_confirm_and_run').hide(); |
| 412 | $('.confirm_and_run_bottom').val(wp_all_export_L10n.save_configuration); |
| 413 | $('#filtering_result').addClass('nothing_to_export'); |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | if ( $('.wpallexport-step-3').length ){ |
| 418 | |
| 419 | $('.founded_records').html(response.html); |
| 420 | |
| 421 | if (response.found_records) |
| 422 | { |
| 423 | $('.founded_records').removeClass('nothing_to_export'); |
| 424 | } |
| 425 | else |
| 426 | { |
| 427 | $('.founded_records').addClass('nothing_to_export'); |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | if ( $('.wpallexport-step-1').length) |
| 432 | { |
| 433 | if (response.found_records) |
| 434 | { |
| 435 | $('.founded_records').removeClass('nothing_to_export'); |
| 436 | } |
| 437 | else |
| 438 | { |
| 439 | $('.founded_records').addClass('nothing_to_export'); |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | }, |
| 444 | error: function( jqXHR, textStatus ) { |
| 445 | |
| 446 | $('.wp_all_export_filter_preloader').hide(); |
| 447 | $('.wp_all_export_preloader').hide(); |
| 448 | |
| 449 | }, |
| 450 | dataType: "json" |
| 451 | }).fail(function(xhr, textStatus, error) { |
| 452 | $('.wpallexport-header').next('.clear').after("<div class='error inline'><p>" + textStatus + " " + error + "</p></div>"); |
| 453 | }); |
| 454 | |
| 455 | } |
| 456 | // [ \Helper functions ] |
| 457 | |
| 458 | |
| 459 | // [ Step 1 ( chose & filter export data ) ] |
| 460 | $('.wpallexport-step-1').each(function(){ |
| 461 | |
| 462 | var $wrap = $('.wrap'); |
| 463 | |
| 464 | var formHeight = $wrap.height(); |
| 465 | |
| 466 | $('.wpallexport-import-from').click(function(){ |
| 467 | |
| 468 | var showImportType = false; |
| 469 | |
| 470 | var postType = $('input[name=cpt]').val(); |
| 471 | |
| 472 | switch ($(this).attr('rel')){ |
| 473 | case 'specific_type': |
| 474 | |
| 475 | $('.wpallexport-user-export-notice').hide(); |
| 476 | $('.wpallexport-shop_customer-export-notice').hide(); |
| 477 | $('.wpallexport-comments-export-notice').hide(); |
| 478 | |
| 479 | if (postType != '') |
| 480 | { |
| 481 | if (postType == 'users'){ |
| 482 | $('.wpallexport-user-export-notice').show(); |
| 483 | showImportType = false; |
| 484 | $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideDown(); |
| 485 | } |
| 486 | else if (postType == 'comments') |
| 487 | { |
| 488 | $('.wpallexport-comments-export-notice').show(); |
| 489 | showImportType = false; |
| 490 | $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideDown(); |
| 491 | } |
| 492 | else if (postType == 'shop_customer') |
| 493 | { |
| 494 | $('.wpallexport-customer-export-notice').show(); |
| 495 | showImportType = false; |
| 496 | $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideDown(); |
| 497 | } |
| 498 | else |
| 499 | { |
| 500 | showImportType = true; |
| 501 | $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideDown(); |
| 502 | } |
| 503 | |
| 504 | $('.wpallexport-filtering-wrapper').show(); |
| 505 | } |
| 506 | break; |
| 507 | case 'advanced_type': |
| 508 | |
| 509 | $('.wpallexport-user-export-notice').hide(); |
| 510 | $('.wpallexport-comments-export-notice').hide(); |
| 511 | $('.wpallexport-shop_customer-export-notice').hide(); |
| 512 | |
| 513 | if ($('input[name=wp_query_selector]').val() == 'wp_user_query') |
| 514 | { |
| 515 | $('.wpallexport-user-export-notice').show(); |
| 516 | $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideUp(); |
| 517 | showImportType = false; |
| 518 | } |
| 519 | else if ($('input[name=wp_query_selector]').val() == 'wp_comment_query') |
| 520 | { |
| 521 | $('.wpallexport-comments-export-notice').show(); |
| 522 | $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideUp(); |
| 523 | showImportType = false; |
| 524 | } |
| 525 | else |
| 526 | { |
| 527 | $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideUp(); |
| 528 | showImportType = true; |
| 529 | } |
| 530 | $('.wpallexport-filtering-wrapper').hide(); |
| 531 | filtering(); |
| 532 | break; |
| 533 | } |
| 534 | |
| 535 | $('.wpallexport-import-from').removeClass('selected').addClass('bind'); |
| 536 | $(this).addClass('selected').removeClass('bind'); |
| 537 | $('.wpallexport-choose-file').find('.wpallexport-upload-type-container').hide(); |
| 538 | $('.wpallexport-choose-file').find('.wpallexport-upload-type-container[rel=' + $(this).attr('rel') + ']').show(); |
| 539 | $('.wpallexport-choose-file').find('input[name=export_type]').val( $(this).attr('rel').replace('_type', '') ); |
| 540 | |
| 541 | if ( ! showImportType) |
| 542 | { |
| 543 | $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide(); |
| 544 | } |
| 545 | else{ |
| 546 | $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').show(); |
| 547 | } |
| 548 | |
| 549 | }); |
| 550 | |
| 551 | $('.wpallexport-import-from.selected').click(); |
| 552 | |
| 553 | $('#file_selector').ddslick({ |
| 554 | width: 600, |
| 555 | onSelected: function(selectedData){ |
| 556 | |
| 557 | $('.wpallexport-user-export-notice').hide(); |
| 558 | $('.wpallexport-comments-export-notice').hide(); |
| 559 | $('.wpallexport-shop_customer-export-notice').hide(); |
| 560 | |
| 561 | if (selectedData.selectedData.value != ""){ |
| 562 | |
| 563 | $('#file_selector').find('.dd-selected').css({'color':'#555'}); |
| 564 | |
| 565 | var i = 0; |
| 566 | var postType = selectedData.selectedData.value; |
| 567 | $('#file_selector').find('.dd-option-value').each(function(){ |
| 568 | if (postType == $(this).val()) return false; |
| 569 | i++; |
| 570 | }); |
| 571 | |
| 572 | $('.wpallexport-choose-file').find('input[name=cpt]').val(postType); |
| 573 | |
| 574 | if (postType == 'users') |
| 575 | { |
| 576 | $('.wpallexport-user-export-notice').show(); |
| 577 | $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide(); |
| 578 | } |
| 579 | else if (postType == 'comments') |
| 580 | { |
| 581 | $('.wpallexport-comments-export-notice').show(); |
| 582 | $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide(); |
| 583 | } |
| 584 | else if (postType == 'shop_customer') |
| 585 | { |
| 586 | $('.wpallexport-shop_customer-export-notice').show(); |
| 587 | $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide(); |
| 588 | } |
| 589 | else |
| 590 | { |
| 591 | $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').show(); |
| 592 | } |
| 593 | |
| 594 | filtering(postType); |
| 595 | |
| 596 | } |
| 597 | else |
| 598 | { |
| 599 | $('.wpallexport-choose-file').find('input[name=cpt]').val(''); |
| 600 | $('#file_selector').find('.dd-selected').css({'color':'#cfceca'}); |
| 601 | $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideUp(); |
| 602 | $('.wpallexport-choose-file').find('.wpallexport-filtering-wrapper').slideUp(); |
| 603 | |
| 604 | switch ($('.wpallexport-import-from.selected').attr('rel')){ |
| 605 | case 'specific_type': |
| 606 | filtering($('input[name=cpt]').val()); |
| 607 | break; |
| 608 | case 'advanced_type': |
| 609 | |
| 610 | break; |
| 611 | } |
| 612 | } |
| 613 | } |
| 614 | }); |
| 615 | |
| 616 | $('a.auto-generate-template').live('click', function(){ |
| 617 | $('input[name^=auto_generate]').val('1'); |
| 618 | |
| 619 | $('.hierarhy-output').each(function(){ |
| 620 | var sortable = $('.wp_all_export_filtering_rules.ui-sortable'); |
| 621 | if (sortable.length){ |
| 622 | $(this).val(window.JSON.stringify(sortable.pmxe_nestedSortable('toArray', {startDepthCount: 0}))); |
| 623 | } |
| 624 | }); |
| 625 | |
| 626 | $(this).parents('form:first').submit(); |
| 627 | }); |
| 628 | |
| 629 | $('form.wpallexport-choose-file').find('input[type=submit]').click(function(e){ |
| 630 | e.preventDefault(); |
| 631 | |
| 632 | $('.hierarhy-output').each(function(){ |
| 633 | var sortable = $('.wp_all_export_filtering_rules.ui-sortable'); |
| 634 | if (sortable.length){ |
| 635 | $(this).val(window.JSON.stringify(sortable.pmxe_nestedSortable('toArray', {startDepthCount: 0}))); |
| 636 | } |
| 637 | }); |
| 638 | |
| 639 | $(this).parents('form:first').submit(); |
| 640 | }); |
| 641 | |
| 642 | $('#wp_query_selector').ddslick({ |
| 643 | width: 600, |
| 644 | onSelected: function(selectedData){ |
| 645 | |
| 646 | $('.wpallexport-user-export-notice').hide(); |
| 647 | $('.wpallexport-comments-export-notice').hide(); |
| 648 | $('.wpallexport-shop_customer-export-notice').hide(); |
| 649 | |
| 650 | $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide(); |
| 651 | |
| 652 | if (selectedData.selectedData.value != ""){ |
| 653 | |
| 654 | $('#wp_query_selector').find('.dd-selected').css({'color':'#555'}); |
| 655 | var queryType = selectedData.selectedData.value; |
| 656 | if (queryType == 'wp_query'){ |
| 657 | $('textarea[name=wp_query]').attr("placeholder", "'post_type' => 'post', 'post_status' => array( 'pending', 'draft', 'future' )"); |
| 658 | $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').show(); |
| 659 | } |
| 660 | if(queryType == 'wp_user_query') |
| 661 | { |
| 662 | $('.wpallexport-user-export-notice').show(); |
| 663 | $('textarea[name=wp_query]').attr("placeholder", "'role' => 'Administrator'"); |
| 664 | $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide(); |
| 665 | } |
| 666 | else if(queryType == 'wp_comment_query') |
| 667 | { |
| 668 | $('.wpallexport-comments-export-notice').show(); |
| 669 | $('textarea[name=wp_query]').attr("placeholder", "'meta_key' => 'featured', 'meta_value' => '1'"); |
| 670 | $('.wpallexport-choose-file').find('.wpallexport-submit-buttons').hide(); |
| 671 | } |
| 672 | $('input[name=wp_query_selector]').val(queryType); |
| 673 | } |
| 674 | else{ |
| 675 | |
| 676 | $('#wp_query_selector').find('.dd-selected').css({'color':'#cfceca'}); |
| 677 | $('.wpallexport-choose-file').find('.wpallexport-upload-resource-step-two').slideUp(); |
| 678 | |
| 679 | } |
| 680 | } |
| 681 | }); |
| 682 | |
| 683 | }); |
| 684 | // [ \Step 1 ( chose & filter export data ) ] |
| 685 | |
| 686 | |
| 687 | // [ Step 2 ( export template ) ] |
| 688 | $('.wpallexport-export-template').each(function(){ |
| 689 | |
| 690 | trigger_warnings(); |
| 691 | |
| 692 | var $sortable = $( "#columns" ); |
| 693 | |
| 694 | $( "#available_data li:not(.available_sub_section, .wpallexport_disabled)" ).draggable({ |
| 695 | appendTo: "body", |
| 696 | helper: "clone" |
| 697 | }); |
| 698 | |
| 699 | var outsideContainer = 0; |
| 700 | |
| 701 | // this one control if the draggable is outside the droppable area |
| 702 | $('#columns_to_export').droppable({ |
| 703 | accept : '.ui-sortable-helper' |
| 704 | }); |
| 705 | |
| 706 | $( "#columns_to_export" ).on( "dropout", function( event, ui ) { |
| 707 | outsideContainer = 1; |
| 708 | ui.draggable.find('.custom_column').css('background', 'white'); |
| 709 | } ); |
| 710 | |
| 711 | $( "#columns_to_export" ).on( "dropover", function( event, ui ) { |
| 712 | outsideContainer = 0; |
| 713 | ui.draggable.find('.custom_column').css('background', 'white'); |
| 714 | } ); |
| 715 | |
| 716 | // this one control if the draggable is dropped |
| 717 | $('body, form.wpallexport-template').droppable({ |
| 718 | accept : '.ui-sortable-helper', |
| 719 | drop : function(event, ui){ |
| 720 | if(outsideContainer == 1){ |
| 721 | ui.draggable.remove(); |
| 722 | trigger_warnings(); |
| 723 | |
| 724 | if ( $('#columns').find('li:not(.placeholder)').length === 1) |
| 725 | { |
| 726 | $('#columns').find( ".placeholder" ).show(); |
| 727 | } |
| 728 | }else{ |
| 729 | ui.draggable.find('.custom_column').css('background', 'none'); |
| 730 | } |
| 731 | } |
| 732 | }); |
| 733 | |
| 734 | $( "#columns_to_export ol" ).droppable({ |
| 735 | activeClass: "pmxe-state-default", |
| 736 | hoverClass: "pmxe-state-hover", |
| 737 | accept: ":not(.ui-sortable-helper)", |
| 738 | drop: function( event, ui ) { |
| 739 | $( this ).find( ".placeholder" ).hide(); |
| 740 | |
| 741 | if (ui.draggable.find('input[name^=rules]').length){ |
| 742 | $('li.' + ui.draggable.find('input[name^=rules]').val()).each(function(){ |
| 743 | var $value = $(this).find('input[name^=cc_value]').val(); |
| 744 | var $is_media_field = false; |
| 745 | if ( $(this).find('input[name^=cc_type]').val().indexOf('image_') !== -1 || $(this).find('input[name^=cc_type]').val().indexOf('attachment_') !== -1 ) |
| 746 | { |
| 747 | $value = $(this).find('input[name^=cc_type]').val(); |
| 748 | $is_media_field = true; |
| 749 | } |
| 750 | var $add_field = true; |
| 751 | $('#columns').find('li').each(function(){ |
| 752 | if ( $is_media_field ) |
| 753 | { |
| 754 | if ($(this).find('input[name^=cc_type]').val() == $value){ |
| 755 | $add_field = false; |
| 756 | } |
| 757 | } |
| 758 | else |
| 759 | { |
| 760 | if ($(this).find('input[name^=cc_value]').val() == $value){ |
| 761 | $add_field = false; |
| 762 | } |
| 763 | } |
| 764 | }); |
| 765 | if ($add_field) |
| 766 | { |
| 767 | $( "<li></li>" ).html( $(this).html() ).appendTo( $( "#columns_to_export ol" ) ); |
| 768 | var $just_added = $('#columns').find('li:last').find('div:first'); |
| 769 | $just_added.attr('rel', $('#columns').find('li:not(.placeholder)').length); |
| 770 | if ( $just_added.find('input[name^=cc_type]').val().indexOf('image_') !== -1 ) |
| 771 | { |
| 772 | $just_added.find('.wpallexport-xml-element').html('Image ' + $just_added.find('input[name^=cc_name]').val()); |
| 773 | $just_added.find('input[name^=cc_name]').val('Image ' + $just_added.find('input[name^=cc_name]').val()); |
| 774 | } |
| 775 | if ( $just_added.find('input[name^=cc_type]').val().indexOf('attachment_') !== -1 ) |
| 776 | { |
| 777 | $just_added.find('.wpallexport-xml-element').html('Attachment ' + $just_added.find('input[name^=cc_name]').val()); |
| 778 | $just_added.find('input[name^=cc_name]').val('Attachment ' + $just_added.find('input[name^=cc_name]').val()); |
| 779 | } |
| 780 | } |
| 781 | }); |
| 782 | } |
| 783 | else{ |
| 784 | $( "<li></li>" ).html( ui.draggable.html() ).appendTo( this ); |
| 785 | var $just_added = $('#columns').find('li:last').find('div:first'); |
| 786 | $just_added.attr('rel', $('#columns').find('li:not(.placeholder)').length); |
| 787 | if ( $just_added.find('input[name^=cc_type]').val().indexOf('image_') !== -1 ) |
| 788 | { |
| 789 | $just_added.find('.wpallexport-xml-element').html('Image ' + $just_added.find('input[name^=cc_name]').val()); |
| 790 | $just_added.find('input[name^=cc_name]').val('Image ' + $just_added.find('input[name^=cc_name]').val()); |
| 791 | } |
| 792 | if ( $just_added.find('input[name^=cc_type]').val().indexOf('attachment_') !== -1 ) |
| 793 | { |
| 794 | $just_added.find('.wpallexport-xml-element').html('Attachment ' + $just_added.find('input[name^=cc_name]').val()); |
| 795 | $just_added.find('input[name^=cc_name]').val('Attachment ' + $just_added.find('input[name^=cc_name]').val()); |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | trigger_warnings(); |
| 800 | |
| 801 | } |
| 802 | }).sortable({ |
| 803 | items: "li:not(.placeholder)", |
| 804 | sort: function() { |
| 805 | // gets added unintentionally by droppable interacting with sortable |
| 806 | // using connectWithSortable fixes this, but doesn't allow you to customize active/hoverClass options |
| 807 | $( this ).removeClass( "ui-state-default" ); |
| 808 | } |
| 809 | }); |
| 810 | |
| 811 | var $this = $(this); |
| 812 | var $addAnother = $this.find('input.add_column'); |
| 813 | var $addAnotherForm = $('fieldset.wp-all-export-edit-column'); |
| 814 | var $template = $(this).find('.custom_column.template'); |
| 815 | |
| 816 | if (typeof wpPointerL10n != "undefined") wpPointerL10n.dismiss = 'Close'; |
| 817 | |
| 818 | // Add Another btn click |
| 819 | $addAnother.click(function(){ |
| 820 | |
| 821 | $addAnotherForm.find('form')[0].reset(); |
| 822 | $addAnotherForm.find('input[type=checkbox]').removeAttr('checked'); |
| 823 | |
| 824 | $addAnotherForm.removeAttr('rel'); |
| 825 | $addAnotherForm.removeClass('dc').addClass('cc'); |
| 826 | $addAnotherForm.find('.cc_field').hide(); |
| 827 | |
| 828 | $addAnotherForm.find('.wpallexport-edit-row-title').hide(); |
| 829 | $addAnotherForm.find('.wpallexport-add-row-title').show(); |
| 830 | $addAnotherForm.find('div[class^=switcher-target]').hide(); |
| 831 | $addAnotherForm.find('#coperate_php').removeAttr('checked'); |
| 832 | $addAnotherForm.find('input.column_name').parents('div.input:first').show(); |
| 833 | |
| 834 | $('.custom_column').removeClass('active'); |
| 835 | |
| 836 | $addAnotherForm.find('select[name=column_value_type]').find('option').each(function(){ |
| 837 | if ($(this).val() == 'id') |
| 838 | $(this).attr({'selected':'selected'}).click(); |
| 839 | else |
| 840 | $(this).removeAttr('selected'); |
| 841 | }); |
| 842 | |
| 843 | $('.wp-all-export-chosen-select').trigger('chosen:updated'); |
| 844 | $('.wp_all_export_saving_status').html(''); |
| 845 | |
| 846 | $('.wpallexport-overlay').show(); |
| 847 | $addAnotherForm.find('input.switcher').change(); |
| 848 | $addAnotherForm.show(); |
| 849 | |
| 850 | }); |
| 851 | |
| 852 | // Delete custom column action |
| 853 | $addAnotherForm.find('.delete_action').click(function(){ |
| 854 | |
| 855 | $('.custom_column').removeClass('active'); |
| 856 | |
| 857 | $('.custom_column[rel='+ $addAnotherForm.attr('rel') +']').parents('li:first').fadeOut().remove(); |
| 858 | |
| 859 | if ( ! $('#columns').find('li:visible').length ){ |
| 860 | $('#columns').find( ".placeholder" ).show(); |
| 861 | } |
| 862 | |
| 863 | trigger_warnings(); |
| 864 | |
| 865 | $addAnotherForm.fadeOut(); |
| 866 | $('.wpallexport-overlay').hide(); |
| 867 | }); |
| 868 | |
| 869 | // Add/Edit custom column action |
| 870 | $addAnotherForm.find('.save_action').click(function(){ |
| 871 | |
| 872 | var $save = true; |
| 873 | |
| 874 | // element name in exported file |
| 875 | var $elementName = $addAnotherForm.find('input.column_name'); |
| 876 | |
| 877 | // element name validation |
| 878 | if ($elementName.val() == '') |
| 879 | { |
| 880 | $save = false; |
| 881 | $elementName.addClass('error'); |
| 882 | return false; |
| 883 | } |
| 884 | |
| 885 | // get PHP function name |
| 886 | var $phpFunction = $addAnotherForm.find('.php_code:visible'); |
| 887 | |
| 888 | // validation passed, prepare field data |
| 889 | var $elementIndex = $addAnotherForm.attr('rel'); |
| 890 | // element type |
| 891 | var $elementType = $addAnotherForm.find('select[name=column_value_type]'); |
| 892 | // element label, options and other stuff |
| 893 | var $elementDetails = $elementType.find('option:selected'); |
| 894 | |
| 895 | var $clone = ( $elementIndex ) ? $('#columns').find('.custom_column[rel='+ $elementIndex +']') : $template.clone(true); |
| 896 | |
| 897 | // if new field adding |
| 898 | if ( ! parseInt( $elementIndex ) ) |
| 899 | { |
| 900 | // new column added, increase element Index |
| 901 | $clone.attr('rel', $('#columns').find('.custom_column').length + 1); |
| 902 | } |
| 903 | |
| 904 | // add element label |
| 905 | $clone.find('label.wpallexport-xml-element').html( $elementName.val() ); |
| 906 | // wrap field value into PHP function |
| 907 | $clone.find('input[name^=cc_php]').val( $addAnotherForm.find('#coperate_php').is(':checked') ? '1' : '0' ); |
| 908 | // save PHP function name |
| 909 | $clone.find('input[name^=cc_code]').val( $phpFunction.val() ); |
| 910 | // save SQL code |
| 911 | $clone.find('input[name^=cc_sql]').val( $addAnotherForm.find('textarea.column_value').val() ); |
| 912 | // save element name |
| 913 | $clone.find('input[name^=cc_name]').val( $elementName.val() == "ID" ? "id" : $elementName.val() ); |
| 914 | // save element type |
| 915 | $clone.find('input[name^=cc_type]').val( $elementType.val() ); |
| 916 | // save element value |
| 917 | $clone.find('input[name^=cc_value]').val( $elementDetails.attr('label') ); |
| 918 | // save element label |
| 919 | $clone.find('input[name^=cc_label]').val( $elementDetails.attr('label') ); |
| 920 | // save element options |
| 921 | $clone.find('input[name^=cc_options]').val( $elementDetails.attr('options') ); |
| 922 | |
| 923 | // if new field adding append element to the export template |
| 924 | if ( ! parseInt( $elementIndex ) ) |
| 925 | { |
| 926 | $( "#columns" ).find( ".placeholder" ).hide(); |
| 927 | $sortable.append('<li></li>'); |
| 928 | $sortable.find('li:last').append($clone.removeClass('template').fadeIn()); |
| 929 | } |
| 930 | |
| 931 | // set up additional element settings by element type |
| 932 | switch ( $elementType.val() ) |
| 933 | { |
| 934 | // save post date field format |
| 935 | case 'date': |
| 936 | var $dateType = $addAnotherForm.find('select.date_field_export_data').val(); |
| 937 | if ($dateType == 'unix') |
| 938 | $clone.find('input[name^=cc_settings]').val('unix'); |
| 939 | else |
| 940 | $clone.find('input[name^=cc_settings]').val($('.pmxe_date_format').val()); |
| 941 | break; |
| 942 | // set up additional settings for repeater field |
| 943 | case 'acf': |
| 944 | // determine is repeater field selected in dropdown |
| 945 | if ( $clone.find('input[name^=cc_options]').val().indexOf('s:4:"type";s:8:"repeater"') !== -1 ) |
| 946 | { |
| 947 | var obj = {}; |
| 948 | obj['repeater_field_item_per_line'] = $addAnotherForm.find('#repeater_field_item_per_line').is(':checked'); |
| 949 | obj['repeater_field_fill_empty_columns'] = $addAnotherForm.find('#repeater_field_fill_empty_columns').is(':checked'); |
| 950 | $clone.find('input[name^=cc_settings]').val(window.JSON.stringify(obj)); |
| 951 | } |
| 952 | break; |
| 953 | case 'woo': |
| 954 | switch ( $clone.find('input[name^=cc_value]').val() ) |
| 955 | { |
| 956 | case '_upsell_ids': |
| 957 | case '_crosssell_ids': |
| 958 | case 'item_data___upsell_ids': |
| 959 | case 'item_data___crosssell_ids': |
| 960 | $clone.find('input[name^=cc_settings]').val($addAnotherForm.find('select.linked_field_export_data').val()); |
| 961 | break; |
| 962 | } |
| 963 | break; |
| 964 | default: |
| 965 | // save option for media images field types |
| 966 | if ( $clone.find('input[name^=cc_type]').val().indexOf('image_') !== -1 ) |
| 967 | { |
| 968 | var obj = {}; |
| 969 | obj['is_export_featured'] = $addAnotherForm.find('#is_image_export_featured').is(':checked'); |
| 970 | obj['is_export_attached'] = $addAnotherForm.find('#is_image_export_attached_images').is(':checked'); |
| 971 | obj['image_separator'] = $addAnotherForm.find('input[name=image_field_separator]').val(); |
| 972 | $clone.find('input[name^=cc_options]').val(window.JSON.stringify(obj)); |
| 973 | } |
| 974 | |
| 975 | break; |
| 976 | } |
| 977 | |
| 978 | trigger_warnings(); |
| 979 | |
| 980 | $addAnotherForm.hide(); |
| 981 | |
| 982 | $('.wpallexport-overlay').hide(); |
| 983 | |
| 984 | $('.custom_column').removeClass('active'); |
| 985 | |
| 986 | }); |
| 987 | |
| 988 | // Clicking on column for edit |
| 989 | $('#columns').find('.custom_column').live('click', function(){ |
| 990 | |
| 991 | $addAnotherForm.find('form')[0].reset(); |
| 992 | $addAnotherForm.find('input[type=checkbox]').removeAttr('checked'); |
| 993 | |
| 994 | $addAnotherForm.removeClass('dc').addClass('cc'); |
| 995 | $addAnotherForm.attr('rel', $(this).attr('rel')); |
| 996 | |
| 997 | $addAnotherForm.find('.wpallexport-add-row-title').hide(); |
| 998 | $addAnotherForm.find('.wpallexport-edit-row-title').show(); |
| 999 | |
| 1000 | $addAnotherForm.find('input.column_name').parents('div.input:first').show(); |
| 1001 | |
| 1002 | $addAnotherForm.find('.cc_field').hide(); |
| 1003 | $('.custom_column').removeClass('active'); |
| 1004 | $(this).addClass('active'); |
| 1005 | |
| 1006 | var $elementType = $(this).find('input[name^=cc_type]'); |
| 1007 | var $elementLabel = $(this).find('input[name^=cc_label]'); |
| 1008 | |
| 1009 | |
| 1010 | $('.wp_all_export_saving_status').html(''); |
| 1011 | |
| 1012 | $addAnotherForm.find('select[name=column_value_type]').find('option').each(function(){ |
| 1013 | if ($(this).attr('label') == $elementLabel.val() && $(this).val() == $elementType.val()) |
| 1014 | $(this).attr({'selected':'selected'}).click(); |
| 1015 | else |
| 1016 | $(this).removeAttr('selected'); |
| 1017 | }); |
| 1018 | |
| 1019 | $('.wp-all-export-chosen-select').trigger('chosen:updated'); |
| 1020 | |
| 1021 | // set php snipped |
| 1022 | var $php_code = $(this).find('input[name^=cc_code]'); |
| 1023 | var $is_php = parseInt($(this).find('input[name^=cc_php]').val()); |
| 1024 | |
| 1025 | if ($is_php){ |
| 1026 | $addAnotherForm.find('#coperate_php').attr({'checked':'checked'}); |
| 1027 | $addAnotherForm.find('#coperate_php').parents('div.input:first').find('div[class^=switcher-target]').show(); |
| 1028 | } |
| 1029 | else{ |
| 1030 | $addAnotherForm.find('#coperate_php').removeAttr('checked'); |
| 1031 | $addAnotherForm.find('#coperate_php').parents('div.input:first').find('div[class^=switcher-target]').hide(); |
| 1032 | } |
| 1033 | |
| 1034 | $addAnotherForm.find('#coperate_php').parents('div.input:first').find('.php_code').val($php_code.val()); |
| 1035 | |
| 1036 | var $options = $(this).find('input[name^=cc_options]').val(); |
| 1037 | var $settings = $(this).find('input[name^=cc_settings]').val(); |
| 1038 | |
| 1039 | switch ( $elementType.val() ){ |
| 1040 | case 'sql': |
| 1041 | $addAnotherForm.find('textarea.column_value').val($(this).find('input[name^=cc_sql]').val()); |
| 1042 | $addAnotherForm.find('.sql_field_type').show(); |
| 1043 | break; |
| 1044 | case 'acf': |
| 1045 | if ($options.indexOf('s:4:"type";s:8:"repeater"') !== -1) |
| 1046 | { |
| 1047 | $addAnotherForm.find('.repeater_field_type').show(); |
| 1048 | if ($settings != "") |
| 1049 | { |
| 1050 | var $field_options = window.JSON.parse($settings); |
| 1051 | if ($field_options.repeater_field_item_per_line) $addAnotherForm.find('#repeater_field_item_per_line').attr('checked','checked'); |
| 1052 | if ($field_options.repeater_field_fill_empty_columns) $addAnotherForm.find('#repeater_field_fill_empty_columns').attr('checked','checked'); |
| 1053 | } |
| 1054 | } |
| 1055 | break; |
| 1056 | case 'woo': |
| 1057 | $woo_type = $(this).find('input[name^=cc_value]'); |
| 1058 | switch ($woo_type.val()) |
| 1059 | { |
| 1060 | case '_upsell_ids': |
| 1061 | case '_crosssell_ids': |
| 1062 | case 'item_data___upsell_ids': |
| 1063 | case 'item_data___crosssell_ids': |
| 1064 | |
| 1065 | $addAnotherForm.find('select.linked_field_export_data').find('option').each(function(){ |
| 1066 | if ($(this).val() == $settings) |
| 1067 | $(this).attr({'selected':'selected'}).click(); |
| 1068 | else |
| 1069 | $(this).removeAttr('selected'); |
| 1070 | }); |
| 1071 | $addAnotherForm.find('.linked_field_type').show(); |
| 1072 | break; |
| 1073 | } |
| 1074 | break; |
| 1075 | case 'date': |
| 1076 | $addAnotherForm.find('select.date_field_export_data').find('option').each(function(){ |
| 1077 | if ($(this).val() == $settings || $settings != 'unix' && $(this).val() == 'php') |
| 1078 | $(this).attr({'selected':'selected'}).click(); |
| 1079 | else |
| 1080 | $(this).removeAttr('selected'); |
| 1081 | }); |
| 1082 | |
| 1083 | if ($settings != 'php' && $settings != 'unix'){ |
| 1084 | $('.pmxe_date_format').val($settings); |
| 1085 | $('.pmxe_date_format_wrapper').show(); |
| 1086 | } |
| 1087 | else |
| 1088 | $('.pmxe_date_format').val(''); |
| 1089 | $addAnotherForm.find('.date_field_type').show(); |
| 1090 | break; |
| 1091 | default: |
| 1092 | |
| 1093 | if ( $elementType.val().indexOf('image_') !== -1 ) |
| 1094 | { |
| 1095 | $addAnotherForm.find('.image_field_type').show(); |
| 1096 | |
| 1097 | if ($options != "") |
| 1098 | { |
| 1099 | var $field_options = window.JSON.parse($options); |
| 1100 | |
| 1101 | if ($field_options.is_export_featured) $addAnotherForm.find('#is_image_export_featured').attr('checked','checked'); |
| 1102 | if ($field_options.is_export_attached) $addAnotherForm.find('#is_image_export_attached_images').attr('checked','checked'); |
| 1103 | |
| 1104 | $addAnotherForm.find('input[name=image_field_separator]').val($field_options.image_separator); |
| 1105 | } |
| 1106 | } |
| 1107 | |
| 1108 | break; |
| 1109 | } |
| 1110 | |
| 1111 | $addAnotherForm.find('input.switcher').change(); |
| 1112 | |
| 1113 | var $column_name = $(this).find('input[name^=cc_name]').val(); |
| 1114 | if ($column_name == "ID") $column_name = "id"; |
| 1115 | |
| 1116 | $addAnotherForm.find('input.column_name').val($column_name); |
| 1117 | $addAnotherForm.show(); |
| 1118 | $('.wpallexport-overlay').show(); |
| 1119 | |
| 1120 | }); |
| 1121 | |
| 1122 | // Preview export file |
| 1123 | var doPreview = function( ths, tagno ){ |
| 1124 | |
| 1125 | $('.wpallexport-overlay').show(); |
| 1126 | |
| 1127 | ths.pointer({ |
| 1128 | content: '<div class="wpallexport-preview-preload wpallexport-pointer-preview"></div>', |
| 1129 | position: { |
| 1130 | edge: 'right', |
| 1131 | align: 'center' |
| 1132 | }, |
| 1133 | pointerWidth: 715, |
| 1134 | close: function() { |
| 1135 | $.post( ajaxurl, { |
| 1136 | pointer: 'pksn1', |
| 1137 | action: 'dismiss-wp-pointer' |
| 1138 | }); |
| 1139 | $('.wpallexport-overlay').hide(); |
| 1140 | } |
| 1141 | }).pointer('open'); |
| 1142 | |
| 1143 | var $pointer = $('.wpallexport-pointer-preview').parents('.wp-pointer').first(); |
| 1144 | |
| 1145 | var $leftOffset = ($(window).width() - 715)/2; |
| 1146 | |
| 1147 | $pointer.css({'position':'fixed', 'top' : '15%', 'left' : $leftOffset + 'px'}); |
| 1148 | |
| 1149 | var request = { |
| 1150 | action: 'wpae_preview', |
| 1151 | data: $('form.wpallexport-step-3').serialize(), |
| 1152 | tagno: tagno, |
| 1153 | security: wp_all_export_security |
| 1154 | }; |
| 1155 | |
| 1156 | $.ajax({ |
| 1157 | type: 'POST', |
| 1158 | url: get_valid_ajaxurl(), |
| 1159 | data: request, |
| 1160 | success: function(response) { |
| 1161 | |
| 1162 | ths.pointer({'content' : response.html}); |
| 1163 | |
| 1164 | $pointer.css({'position':'fixed', 'top' : '15%', 'left' : $leftOffset + 'px'}); |
| 1165 | |
| 1166 | var $preview = $('.wpallexport-preview'); |
| 1167 | |
| 1168 | $preview.parent('.wp-pointer-content').removeClass('wp-pointer-content').addClass('wpallexport-pointer-content'); |
| 1169 | |
| 1170 | $preview.find('.navigation a').unbind('click').die('click').live('click', function () { |
| 1171 | |
| 1172 | tagno += '#prev' == $(this).attr('href') ? -1 : 1; |
| 1173 | |
| 1174 | doPreview(ths, tagno); |
| 1175 | |
| 1176 | }); |
| 1177 | |
| 1178 | }, |
| 1179 | error: function( jqXHR, textStatus ) { |
| 1180 | |
| 1181 | ths.pointer({'content' : jqXHR.responseText}); |
| 1182 | |
| 1183 | }, |
| 1184 | dataType: "json" |
| 1185 | }); |
| 1186 | |
| 1187 | }; |
| 1188 | |
| 1189 | $(this).find('.preview_a_row').click( function(){ |
| 1190 | doPreview($(this), 1); |
| 1191 | }); |
| 1192 | |
| 1193 | $('.wpae-available-fields-group').click(function(){ |
| 1194 | var $mode = $(this).find('.wpae-expander').text(); |
| 1195 | $(this).next('div').slideToggle(); |
| 1196 | if ($mode == '+') $(this).find('.wpae-expander').text('-'); else $(this).find('.wpae-expander').text('+'); |
| 1197 | }); |
| 1198 | |
| 1199 | $('.pmxe_remove_column').live('click', function(){ |
| 1200 | $(this).parents('li:first').remove(); |
| 1201 | }); |
| 1202 | |
| 1203 | $('.close_action').click(function(){ |
| 1204 | $(this).parents('fieldset:first').hide(); |
| 1205 | $('.wpallexport-overlay').hide(); |
| 1206 | $('#columns').find('div.active').removeClass('active'); |
| 1207 | }); |
| 1208 | |
| 1209 | $('.date_field_export_data').change(function(){ |
| 1210 | if ($(this).val() == "unix") |
| 1211 | $('.pmxe_date_format_wrapper').hide(); |
| 1212 | else |
| 1213 | $('.pmxe_date_format_wrapper').show(); |
| 1214 | }); |
| 1215 | |
| 1216 | $('.xml-expander').live('click', function () { |
| 1217 | var method; |
| 1218 | if ('-' == $(this).text()) { |
| 1219 | $(this).text('+'); |
| 1220 | method = 'addClass'; |
| 1221 | } else { |
| 1222 | $(this).text('-'); |
| 1223 | method = 'removeClass'; |
| 1224 | } |
| 1225 | // for nested representation based on div |
| 1226 | $(this).parent().find('> .xml-content')[method]('collapsed'); |
| 1227 | // for nested representation based on tr |
| 1228 | var $tr = $(this).parent().parent().filter('tr.xml-element').next()[method]('collapsed'); |
| 1229 | }); |
| 1230 | |
| 1231 | $('.wp-all-export-edit-column').css('left', ($( document ).width()/2) - 355 ); |
| 1232 | |
| 1233 | var wp_all_export_config = { |
| 1234 | '.wp-all-export-chosen-select' : {width:"50%"} |
| 1235 | } |
| 1236 | |
| 1237 | for (var selector in wp_all_export_config) { |
| 1238 | $(selector).chosen(wp_all_export_config[selector]); |
| 1239 | $(selector).on('change', function(evt, params) { |
| 1240 | $('.cc_field').hide(); |
| 1241 | var selected_value = $(selector).find('option:selected').attr('label'); |
| 1242 | var ftype = $(selector).val(); |
| 1243 | |
| 1244 | switch (ftype){ |
| 1245 | case 'date': |
| 1246 | $('.date_field_type').show(); |
| 1247 | break; |
| 1248 | case 'sql': |
| 1249 | $('.sql_field_type').show(); |
| 1250 | break; |
| 1251 | case 'woo': |
| 1252 | switch (selected_value){ |
| 1253 | case 'item_data___upsell_ids': |
| 1254 | case 'item_data___crosssell_ids': |
| 1255 | case '_upsell_ids': |
| 1256 | case '_crosssell_ids': |
| 1257 | $addAnotherForm.find('.linked_field_type').show(); |
| 1258 | break; |
| 1259 | } |
| 1260 | break; |
| 1261 | default: |
| 1262 | if ( $(selector).val().indexOf('image_') !== -1) |
| 1263 | { |
| 1264 | $('.image_field_type').show(); |
| 1265 | } |
| 1266 | break; |
| 1267 | } |
| 1268 | }); |
| 1269 | } |
| 1270 | |
| 1271 | $('.wp-all-export-advanced-field-options').click(function(){ |
| 1272 | if ($(this).find('span').html() == '+'){ |
| 1273 | $(this).find('span').html('-'); |
| 1274 | $('.wp-all-export-advanced-field-options-content').fadeIn('fast', function(){ |
| 1275 | if ($('#coperate_php').is(':checked')) editor.setCursor(1); |
| 1276 | }); |
| 1277 | } |
| 1278 | else{ |
| 1279 | $(this).find('span').html('+'); |
| 1280 | $('.wp-all-export-advanced-field-options-content').hide(); |
| 1281 | } |
| 1282 | }); |
| 1283 | |
| 1284 | // Auto generate available data |
| 1285 | $('.wp_all_export_auto_generate_data').click(function(){ |
| 1286 | |
| 1287 | $('ol#columns').find('li:not(.placeholder)').fadeOut().remove(); |
| 1288 | $('ol#columns').find('li.placeholder').fadeOut(); |
| 1289 | |
| 1290 | if ($('#available_data').find('li.wp_all_export_auto_generate').length) |
| 1291 | { |
| 1292 | $('#available_data').find('li.wp_all_export_auto_generate, li.pmxe_cats').each(function(i, e){ |
| 1293 | var $clone = $(this).clone(); |
| 1294 | $clone.attr('rel', i); |
| 1295 | $( "<li></li>" ).html( $clone.html() ).appendTo( $( "#columns_to_export ol" ) ); |
| 1296 | }); |
| 1297 | } |
| 1298 | else |
| 1299 | { |
| 1300 | $('#available_data').find('div.custom_column').each(function(i, e){ |
| 1301 | var $parent = $(this).parent('li'); |
| 1302 | var $clone = $parent.clone(); |
| 1303 | $clone.attr('rel', i); |
| 1304 | |
| 1305 | if ( $clone.find('input[name^=cc_type]').val().indexOf('image_') !== -1 ) |
| 1306 | { |
| 1307 | $clone.find('.wpallexport-xml-element').html('Image ' + $clone.find('input[name^=cc_name]').val()); |
| 1308 | $clone.find('input[name^=cc_name]').val('Image ' + $clone.find('input[name^=cc_name]').val()); |
| 1309 | } |
| 1310 | |
| 1311 | if ( $clone.find('input[name^=cc_type]').val().indexOf('attachment_') !== -1 ) |
| 1312 | { |
| 1313 | $clone.find('.wpallexport-xml-element').html('Attachment ' + $clone.find('input[name^=cc_name]').val()); |
| 1314 | $clone.find('input[name^=cc_name]').val('Attachment ' + $clone.find('input[name^=cc_name]').val()); |
| 1315 | } |
| 1316 | |
| 1317 | $( "<li></li>" ).html( $clone.html() ).appendTo( $( "#columns_to_export ol" ) ); |
| 1318 | }); |
| 1319 | } |
| 1320 | |
| 1321 | trigger_warnings(); |
| 1322 | |
| 1323 | }); |
| 1324 | |
| 1325 | $('.wp_all_export_clear_all_data').live('click', function(){ |
| 1326 | $('ol#columns').find('li:not(.placeholder)').remove(); |
| 1327 | $('ol#columns').find('li.placeholder').fadeIn(); |
| 1328 | }); |
| 1329 | |
| 1330 | if ($('input[name^=selected_post_type]').length){ |
| 1331 | |
| 1332 | var postType = $('input[name^=selected_post_type]').val(); |
| 1333 | |
| 1334 | init_filtering_fields(); |
| 1335 | |
| 1336 | // if ($('form.edit').length){ |
| 1337 | |
| 1338 | liveFiltering(); |
| 1339 | |
| 1340 | // } |
| 1341 | |
| 1342 | $('form.wpallexport-template').find('input[type=submit]').click(function(e){ |
| 1343 | e.preventDefault(); |
| 1344 | |
| 1345 | $('.hierarhy-output').each(function(){ |
| 1346 | var sortable = $('.wp_all_export_filtering_rules.ui-sortable'); |
| 1347 | if (sortable.length){ |
| 1348 | $(this).val(window.JSON.stringify(sortable.pmxe_nestedSortable('toArray', {startDepthCount: 0}))); |
| 1349 | } |
| 1350 | }); |
| 1351 | |
| 1352 | $(this).parents('form:first').submit(); |
| 1353 | }); |
| 1354 | } |
| 1355 | |
| 1356 | $('.wpallexport-import-to-format').click(function(){ |
| 1357 | |
| 1358 | $('.wpallexport-import-to-format').removeClass('selected'); |
| 1359 | $(this).addClass('selected'); |
| 1360 | |
| 1361 | if ($(this).hasClass('wpallexport-csv-type')) |
| 1362 | { |
| 1363 | $('.wpallexport-csv-options').show(); |
| 1364 | $('.wpallexport-xml-options').hide(); |
| 1365 | $('input[name=export_to]').val('csv'); |
| 1366 | } |
| 1367 | else |
| 1368 | { |
| 1369 | $('.wpallexport-csv-options').hide(); |
| 1370 | $('.wpallexport-xml-options').show(); |
| 1371 | $('input[name=export_to]').val('xml'); |
| 1372 | } |
| 1373 | }); |
| 1374 | |
| 1375 | // template form: auto submit when `load template` list value is picked |
| 1376 | $(this).find('select[name="load_template"]').live('change', function () { |
| 1377 | $(this).parents('form').submit(); |
| 1378 | }); |
| 1379 | |
| 1380 | var height = $(window).height(); |
| 1381 | $('#available_data').find('.wpallexport-xml').css({'max-height': height - 125}); |
| 1382 | |
| 1383 | }); |
| 1384 | // [ \Step 2 ( export template ) ] |
| 1385 | |
| 1386 | |
| 1387 | // [ Step 3 ( export options ) ] |
| 1388 | if ( $('.wpallexport-export-options').length ){ |
| 1389 | |
| 1390 | if ($('input[name^=selected_post_type]').length){ |
| 1391 | |
| 1392 | var postType = $('input[name^=selected_post_type]').val(); |
| 1393 | |
| 1394 | init_filtering_fields(); |
| 1395 | |
| 1396 | // if ($('form.edit').length){ |
| 1397 | |
| 1398 | liveFiltering(); |
| 1399 | |
| 1400 | // } |
| 1401 | |
| 1402 | $('form.choose-export-options').find('input[type=submit]').click(function(e){ |
| 1403 | e.preventDefault(); |
| 1404 | |
| 1405 | $('.hierarhy-output').each(function(){ |
| 1406 | var sortable = $('.wp_all_export_filtering_rules.ui-sortable'); |
| 1407 | if (sortable.length){ |
| 1408 | $(this).val(window.JSON.stringify(sortable.pmxe_nestedSortable('toArray', {startDepthCount: 0}))); |
| 1409 | } |
| 1410 | }); |
| 1411 | |
| 1412 | $(this).parents('form:first').submit(); |
| 1413 | }); |
| 1414 | } |
| 1415 | |
| 1416 | $('.wp_all_export_confirm_and_run').click(function(e){ |
| 1417 | e.preventDefault(); |
| 1418 | $('form.choose-export-options').submit(); |
| 1419 | }); |
| 1420 | |
| 1421 | } |
| 1422 | // if we are on re-run export screen |
| 1423 | if ($('.wpallexport-re-run-export').length) |
| 1424 | { |
| 1425 | $('#export_only_new_stuff').click(function(){ |
| 1426 | $(this).attr('disabled','disabled'); |
| 1427 | $('label[for=export_only_new_stuff]').addClass('loading'); |
| 1428 | liveFiltering(null, function(){ |
| 1429 | $('label[for=export_only_new_stuff]').removeClass('loading'); |
| 1430 | $('#export_only_new_stuff').removeAttr('disabled'); |
| 1431 | }); |
| 1432 | }); |
| 1433 | } |
| 1434 | // [ \Step 3 ( export options ) ] |
| 1435 | |
| 1436 | |
| 1437 | // [ Step 4 ( export completed ) ] |
| 1438 | $('.download_data').click(function(){ |
| 1439 | window.location.href = $(this).attr('rel'); |
| 1440 | }); |
| 1441 | // [ \Step 4 ( export completed ) ] |
| 1442 | |
| 1443 | |
| 1444 | // [ Additional functionality ] |
| 1445 | |
| 1446 | // Add new filtering rule |
| 1447 | $('#wp_all_export_add_rule').live('click', function(){ |
| 1448 | |
| 1449 | var $el = $('#wp_all_export_xml_element'); |
| 1450 | var $rule = $('#wp_all_export_rule'); |
| 1451 | var $val = $('#wp_all_export_value'); |
| 1452 | |
| 1453 | if ($el.val() == "" || $rule.val() == "") return; |
| 1454 | |
| 1455 | var relunumber = $('.wp_all_export_filtering_rules').find('li').length + 1; |
| 1456 | |
| 1457 | var html = '<li id="item_'+ relunumber +'" class="dragging"><div class="drag-element">'; |
| 1458 | html += '<input type="hidden" value="'+ $el.val() +'" class="wp_all_export_xml_element" name="wp_all_export_xml_element['+relunumber+']"/>'; |
| 1459 | html += '<input type="hidden" value="'+ $el.find('option:selected').html() +'" class="wp_all_export_xml_element_title" name="wp_all_export_xml_element_title['+relunumber+']"/>'; |
| 1460 | html += '<input type="hidden" value="'+ $rule.val() +'" class="wp_all_export_rule" name="wp_all_export_rule['+relunumber+']"/>'; |
| 1461 | html += '<input type="hidden" value="'+ $val.val() +'" class="wp_all_export_value" name="wp_all_export_value['+relunumber+']"/>'; |
| 1462 | html += '<span class="rule_element">' + $el.find('option:selected').html() + '</span> <span class="rule_as_is">' + $rule.find('option:selected').html() + '</span> <span class="rule_condition_value">"' + $val.val() +'"</span>'; |
| 1463 | html += '<span class="condition"> <label for="rule_and_'+relunumber+'">AND</label><input id="rule_and_'+relunumber+'" type="radio" value="and" name="rule['+relunumber+']" checked="checked" class="rule_condition"/><label for="rule_or_'+relunumber+'">OR</label><input id="rule_or_'+relunumber+'" type="radio" value="or" name="rule['+relunumber+']" class="rule_condition"/> </span>'; |
| 1464 | html += '</div><a href="javascript:void(0);" class="icon-item remove-ico"></a></li>'; |
| 1465 | |
| 1466 | $('#wpallexport-filters, #wp_all_export_apply_filters').show(); |
| 1467 | $('#no_options_notice').hide(); |
| 1468 | |
| 1469 | $('.wp_all_export_filtering_rules').append(html); |
| 1470 | |
| 1471 | $('.wp_all_export_filtering_rules').find('.condition:hidden').each(function(){ |
| 1472 | $(this).show(); |
| 1473 | $(this).find('.rule_condition:first').attr('checked', 'checked'); |
| 1474 | }); |
| 1475 | $('.wp_all_export_filtering_rules').find('.condition').removeClass('last_condition'); |
| 1476 | $('.wp_all_export_filtering_rules').find('.condition:last').addClass('last_condition'); |
| 1477 | |
| 1478 | $('.wp_all_export_product_matching_mode').show(); |
| 1479 | |
| 1480 | $el.prop('selectedIndex',0).trigger('chosen:updated');; |
| 1481 | $rule.prop('selectedIndex',0).trigger('chosen:updated');; |
| 1482 | |
| 1483 | $val.val(''); |
| 1484 | $('#wp_all_export_value').show(); |
| 1485 | |
| 1486 | $('#date_field_notice').hide(); |
| 1487 | |
| 1488 | liveFiltering(); |
| 1489 | |
| 1490 | }); |
| 1491 | |
| 1492 | // Re-count posts when clicking "OR" | "AND" clauses |
| 1493 | $('input[name^=rule]').live('click', function(){ |
| 1494 | liveFiltering(); |
| 1495 | }); |
| 1496 | // Re-count posts when changing product matching mode in filtering section |
| 1497 | $('select[name^=product_matching_mode]').live('change', function(){ |
| 1498 | liveFiltering(); |
| 1499 | }); |
| 1500 | // Re-count posts when deleting a filtering rule |
| 1501 | $('.wp_all_export_filtering_rules').find('.remove-ico').live('click', function(){ |
| 1502 | $(this).parents('li:first').remove(); |
| 1503 | if ( ! $('.wp_all_export_filtering_rules').find('li').length) |
| 1504 | { |
| 1505 | $('#wp_all_export_apply_filters').hide(); |
| 1506 | $('#no_options_notice').show(); |
| 1507 | $('.wp_all_export_product_matching_mode').hide(); |
| 1508 | } |
| 1509 | else |
| 1510 | { |
| 1511 | $('.wp_all_export_filtering_rules').find('li:last').find('.condition').addClass('last_condition'); |
| 1512 | } |
| 1513 | |
| 1514 | liveFiltering(); |
| 1515 | }); |
| 1516 | // hide "value" input when "Is Empty" or "Is Not Empty" rule is selected |
| 1517 | $('#wp_all_export_rule').change(function(){ |
| 1518 | if ($(this).val() == 'is_empty' || $(this).val() == 'is_not_empty') |
| 1519 | $('#wp_all_export_value').hide(); |
| 1520 | else |
| 1521 | $('#wp_all_export_value').show(); |
| 1522 | }); |
| 1523 | // saving & validating function editor |
| 1524 | $('.wp_all_export_save_functions').click(function(){ |
| 1525 | var request = { |
| 1526 | action: 'save_functions', |
| 1527 | data: editor.getValue(), |
| 1528 | security: wp_all_export_security |
| 1529 | }; |
| 1530 | $('.wp_all_export_functions_preloader').show(); |
| 1531 | $('.wp_all_export_saving_status').html(''); |
| 1532 | |
| 1533 | $.ajax({ |
| 1534 | type: 'POST', |
| 1535 | url: get_valid_ajaxurl(), |
| 1536 | data: request, |
| 1537 | success: function(response) { |
| 1538 | $('.wp_all_export_functions_preloader').hide(); |
| 1539 | |
| 1540 | if (response.result) |
| 1541 | { |
| 1542 | $('.wp_all_export_saving_status').css({'color':'green'}); |
| 1543 | setTimeout(function() { |
| 1544 | $('.wp_all_export_saving_status').html('').fadeOut(); |
| 1545 | }, 3000); |
| 1546 | } |
| 1547 | else |
| 1548 | { |
| 1549 | $('.wp_all_export_saving_status').css({'color':'red'}); |
| 1550 | } |
| 1551 | |
| 1552 | $('.wp_all_export_saving_status').html(response.msg).show(); |
| 1553 | |
| 1554 | }, |
| 1555 | error: function( jqXHR, textStatus ) { |
| 1556 | $('.wp_all_export_functions_preloader').hide(); |
| 1557 | }, |
| 1558 | dataType: "json" |
| 1559 | }); |
| 1560 | }); |
| 1561 | // auot-generate zapier API key |
| 1562 | $('input[name=pmxe_generate_zapier_api_key]').click(function(e){ |
| 1563 | |
| 1564 | e.preventDefault(); |
| 1565 | |
| 1566 | var request = { |
| 1567 | action: 'generate_zapier_api_key', |
| 1568 | security: wp_all_export_security |
| 1569 | }; |
| 1570 | |
| 1571 | $.ajax({ |
| 1572 | type: 'POST', |
| 1573 | url: get_valid_ajaxurl(), |
| 1574 | data: request, |
| 1575 | success: function(response) { |
| 1576 | $('input[name=zapier_api_key]').val(response.api_key); |
| 1577 | }, |
| 1578 | error: function( jqXHR, textStatus ) { |
| 1579 | |
| 1580 | }, |
| 1581 | dataType: "json" |
| 1582 | }); |
| 1583 | }); |
| 1584 | |
| 1585 | $('.wpallexport-overlay').click(function(){ |
| 1586 | $('.wp-pointer').hide(); |
| 1587 | $('#columns').find('div.active').removeClass('active'); |
| 1588 | $('fieldset.wp-all-export-edit-column').hide(); |
| 1589 | $(this).hide(); |
| 1590 | }); |
| 1591 | |
| 1592 | if ( $('.wpallexport-template').length ) |
| 1593 | { |
| 1594 | setTimeout(function(){ |
| 1595 | $('.wpallexport-template').slideDown(); |
| 1596 | }, 1000); |
| 1597 | } |
| 1598 | // [ \Additional functionality ] |
| 1599 | |
| 1600 | });})(jQuery); |
| 1601 |