| 1 |
|
| 2 |
/** |
| 3 |
* |
| 4 |
* Delay |
| 5 |
* |
| 6 |
* Creates a way to delay events |
| 7 |
* Dependencies: jQuery |
| 8 |
* |
| 9 |
*/ |
| 10 |
|
| 11 |
/* |
| 12 |
Original Plugin Name: OptionTree |
| 13 |
Original Plugin URI: http://wp.envato.com |
| 14 |
Original Author: Derek Herman |
| 15 |
Original Author URI: http://valendesigns.com |
| 16 |
*/ |
| 17 |
|
| 18 |
(function ($) { |
| 19 |
$.fn.delay = function(time,func){ |
| 20 |
return this.each(function(){ |
| 21 |
setTimeout(func,time); |
| 22 |
}); |
| 23 |
}; |
| 24 |
})(jQuery); |
| 25 |
|
| 26 |
/** |
| 27 |
* |
| 28 |
* Center AJAX |
| 29 |
* |
| 30 |
* Creates a way to center the AJAX message |
| 31 |
* Dependencies: jQuery |
| 32 |
* |
| 33 |
*/ |
| 34 |
(function ($) { |
| 35 |
$.fn.ajaxMessage = function(html){ |
| 36 |
if (html) { |
| 37 |
return $(this).animate({"top":( $(window).height() - $(this).height() ) / 2 - 200 + $(window).scrollTop() + "px"},100).fadeIn('fast').html(html).delay(3000, function(){$('.ajax-message').fadeOut()}); |
| 38 |
} else { |
| 39 |
return $(this).animate({"top":( $(window).height() - $(this).height() ) / 2 - 200 + $(window).scrollTop() + "px"},100).fadeIn('fast').delay(3000, function(){$('.ajax-message').fadeOut()}); |
| 40 |
} |
| 41 |
}; |
| 42 |
})(jQuery); |
| 43 |
|
| 44 |
/** |
| 45 |
* |
| 46 |
* Style File |
| 47 |
* |
| 48 |
* Creates a way to cover file input with a better styled version |
| 49 |
* Dependencies: jQuery |
| 50 |
* |
| 51 |
*/ |
| 52 |
(function ($) { |
| 53 |
styleFile = { |
| 54 |
init: function () { |
| 55 |
$('input.file').each(function(){ |
| 56 |
var uploadbutton = '<input class="upload_file_button" type="button" value="Upload" />'; |
| 57 |
$(this).wrap('<div class="file_wrap" />'); |
| 58 |
$(this).addClass('file').css('opacity', 0); //set to invisible |
| 59 |
$(this).parent().append($('<div class="fake_file" />').append($('<input type="text" class="upload" />').attr('id',$(this).attr('id')+'_file')).append(uploadbutton)); |
| 60 |
|
| 61 |
$(this).bind('change', function() { |
| 62 |
$('#'+$(this).attr('id')+'_file').val($(this).val());; |
| 63 |
}); |
| 64 |
$(this).bind('mouseout', function() { |
| 65 |
$('#'+$(this).attr('id')+'_file').val($(this).val());; |
| 66 |
}); |
| 67 |
}); |
| 68 |
} |
| 69 |
}; |
| 70 |
$(document).ready(function () { |
| 71 |
styleFile.init() |
| 72 |
}) |
| 73 |
})(jQuery); |
| 74 |
|
| 75 |
/** |
| 76 |
* |
| 77 |
* Style Select |
| 78 |
* |
| 79 |
* Replace Select text |
| 80 |
* Dependencies: jQuery |
| 81 |
* |
| 82 |
*/ |
| 83 |
(function ($) { |
| 84 |
styleSelect = { |
| 85 |
init: function () { |
| 86 |
$('.select_wrapper').each(function () { |
| 87 |
$(this).prepend('<span>' + $(this).find('.select option:selected').text() + '</span>'); |
| 88 |
}); |
| 89 |
$('.select').live('change', function () { |
| 90 |
$(this).prev('span').replaceWith('<span>' + $(this).find('option:selected').text() + '</span>'); |
| 91 |
}); |
| 92 |
$('.select').bind($.browser.msie ? 'click' : 'change', function(event) { |
| 93 |
$(this).prev('span').replaceWith('<span>' + $(this).find('option:selected').text() + '</span>'); |
| 94 |
}); |
| 95 |
} |
| 96 |
}; |
| 97 |
$(document).ready(function () { |
| 98 |
styleSelect.init() |
| 99 |
}) |
| 100 |
})(jQuery); |
| 101 |
|
| 102 |
/** |
| 103 |
* |
| 104 |
* Activate Tabs |
| 105 |
* |
| 106 |
* Tab style UI toggle |
| 107 |
* Dependencies: jQuery, jQuery UI Core, jQuery UI Tabs |
| 108 |
* |
| 109 |
*/ |
| 110 |
(function ($) { |
| 111 |
activateTabs = { |
| 112 |
init: function () { |
| 113 |
// Activate |
| 114 |
$("#options_tabs").tabs(); |
| 115 |
// Append Toggle Button |
| 116 |
$('.top-info').append('<a href="" class="toggle_tabs">Tabs</a>'); |
| 117 |
// Toggle Tabs |
| 118 |
$('.toggle_tabs').toggle(function() { |
| 119 |
$("#options_tabs").tabs('destroy'); |
| 120 |
$(this).addClass('off'); |
| 121 |
}, function() { |
| 122 |
$("#options_tabs").tabs(); |
| 123 |
$(this).removeClass('off'); |
| 124 |
}); |
| 125 |
} |
| 126 |
}; |
| 127 |
$(document).ready(function () { |
| 128 |
activateTabs.init() |
| 129 |
}) |
| 130 |
})(jQuery); |
| 131 |
|
| 132 |
/** |
| 133 |
* |
| 134 |
* Upload Option |
| 135 |
* |
| 136 |
* Allows window.send_to_editor to function properly using a private post_id |
| 137 |
* Dependencies: jQuery, Media Upload, Thickbox |
| 138 |
* |
| 139 |
*/ |
| 140 |
(function ($) { |
| 141 |
uploadOption = { |
| 142 |
init: function () { |
| 143 |
var formfield, |
| 144 |
formID, |
| 145 |
btnContent = true; |
| 146 |
// On Click |
| 147 |
$('.upload_button').live("click", function () { |
| 148 |
formfield = $(this).prev('input').attr('name'); |
| 149 |
formID = $(this).attr('rel'); |
| 150 |
tb_show('', 'media-upload.php?post_id='+formID+'&type=image&TB_iframe=1'); |
| 151 |
return false; |
| 152 |
}); |
| 153 |
|
| 154 |
window.original_send_to_editor = window.send_to_editor; |
| 155 |
window.send_to_editor = function(html) { |
| 156 |
if (formfield) { |
| 157 |
itemurl = $(html).attr('href'); |
| 158 |
var image = /(^.*\.jpg|jpeg|png|gif|ico*)/gi; |
| 159 |
var document = /(^.*\.pdf|doc|docx|ppt|pptx|odt*)/gi; |
| 160 |
var audio = /(^.*\.mp3|m4a|ogg|wav*)/gi; |
| 161 |
var video = /(^.*\.mp4|m4v|mov|wmv|avi|mpg|ogv|3gp|3g2*)/gi; |
| 162 |
if (itemurl.match(image)) { |
| 163 |
btnContent = '<img src="'+itemurl+'" alt="" /><a href="" class="remove">Remove Image</a>'; |
| 164 |
} else { |
| 165 |
btnContent = '<div class="no_image">'+html+'<a href="" class="remove">Remove</a></div>'; |
| 166 |
} |
| 167 |
$('#' + formfield).val(itemurl); |
| 168 |
$('#' + formfield).next().next('div').slideDown().html(btnContent); |
| 169 |
tb_remove(); |
| 170 |
} else { |
| 171 |
window.original_send_to_editor(html); |
| 172 |
} |
| 173 |
} |
| 174 |
} |
| 175 |
}; |
| 176 |
$(document).ready(function () { |
| 177 |
uploadOption.init() |
| 178 |
}) |
| 179 |
})(jQuery); |
| 180 |
|
| 181 |
/** |
| 182 |
* |
| 183 |
* Inline Edit Options |
| 184 |
* |
| 185 |
* Creates & Updates Options via Ajax |
| 186 |
* Dependencies: jQuery |
| 187 |
* |
| 188 |
*/ |
| 189 |
(function ($) { |
| 190 |
inlineEditOption = { |
| 191 |
init: function () { |
| 192 |
var c = this, |
| 193 |
d = $("tr.inline-edit-option"); |
| 194 |
$('.save-options', '#the-theme-options').live("click", function () { |
| 195 |
inlineEditOption.save_options(this); |
| 196 |
return false; |
| 197 |
}); |
| 198 |
$("a.edit-inline").live("click", function (event) { |
| 199 |
if ($("a.edit-inline").hasClass('disable')) { |
| 200 |
event.preventDefault(); |
| 201 |
return false; |
| 202 |
} else { |
| 203 |
inlineEditOption.edit(this); |
| 204 |
return false; |
| 205 |
} |
| 206 |
}); |
| 207 |
$("a.save").live("click", function () { |
| 208 |
if ($("a.save").hasClass('add-save')) { |
| 209 |
inlineEditOption.addSave(this); |
| 210 |
return false; |
| 211 |
} else { |
| 212 |
inlineEditOption.editSave(this); |
| 213 |
return false; |
| 214 |
} |
| 215 |
}); |
| 216 |
$("a.cancel").live("click", function () { |
| 217 |
if ($("a.cancel").hasClass('undo-add')) { |
| 218 |
inlineEditOption.undoAdd(); |
| 219 |
return false; |
| 220 |
} else { |
| 221 |
inlineEditOption.revert(); |
| 222 |
return false; |
| 223 |
} |
| 224 |
}); |
| 225 |
$("a.add-option").live("click", function (event) { |
| 226 |
if ($(this).hasClass('disable')) { |
| 227 |
event.preventDefault(); |
| 228 |
return false; |
| 229 |
} else { |
| 230 |
$.post( |
| 231 |
ajaxurl, |
| 232 |
{ action:'profile_builder_next_id', _ajax_nonce: $("#_ajax_nonce").val() }, |
| 233 |
function (response) { |
| 234 |
c = parseInt(response) + 1; |
| 235 |
inlineEditOption.add(c); |
| 236 |
} |
| 237 |
); |
| 238 |
return false; |
| 239 |
} |
| 240 |
}); |
| 241 |
$('.delete-inline').live("click", function (event) { |
| 242 |
if ($("a.delete-inline").hasClass('disable')) { |
| 243 |
event.preventDefault(); |
| 244 |
return false; |
| 245 |
} else { |
| 246 |
var agree = confirm("Are you sure you want to delete this input?"); |
| 247 |
if (agree) { |
| 248 |
inlineEditOption.remove(this); |
| 249 |
return false; |
| 250 |
} else { |
| 251 |
return false; |
| 252 |
} |
| 253 |
} |
| 254 |
}); |
| 255 |
// Fade out message div |
| 256 |
if ($('.ajax-message').hasClass('show')) { |
| 257 |
$('.ajax-message').ajaxMessage(); |
| 258 |
} |
| 259 |
// Remove Uploaded Image |
| 260 |
$('.remove').live('click', function(event) { |
| 261 |
$(this).hide(); |
| 262 |
$(this).parents().prev().prev('.upload').attr('value', ''); |
| 263 |
$(this).parents('.screenshot').slideUp(); |
| 264 |
}); |
| 265 |
}, |
| 266 |
save_options: function (e) { |
| 267 |
var d = { |
| 268 |
action: "profile_builder_array_save" |
| 269 |
}; |
| 270 |
b = $(':input', '#the-theme-options').serialize(); |
| 271 |
d = b + "&" + $.param(d); |
| 272 |
$.post(ajaxurl, d, function (r) { |
| 273 |
if (r != -1) { |
| 274 |
$('.ajax-message').ajaxMessage('<div class="message"><span> </span>Theme Options were saved</div>'); |
| 275 |
$(".option-tree-slider-body").hide(); |
| 276 |
$('.option-tree-slider .edit').removeClass('down'); |
| 277 |
} else { |
| 278 |
$('.ajax-message').ajaxMessage('<div class="message warning"><span> </span>Theme Options could not be saved</div>'); |
| 279 |
} |
| 280 |
}); |
| 281 |
return false; |
| 282 |
}, |
| 283 |
remove: function (b) { |
| 284 |
var c = true; |
| 285 |
|
| 286 |
// Set ID |
| 287 |
c = $(b).parents("tr:first").attr('id'); |
| 288 |
c = c.substr(c.lastIndexOf("-") + 1); |
| 289 |
|
| 290 |
d = { |
| 291 |
action: "profile_builder_delete", |
| 292 |
id: c, |
| 293 |
_ajax_nonce: $("#_ajax_nonce").val() |
| 294 |
}; |
| 295 |
$.post(ajaxurl, d, function (r) { |
| 296 |
if (r) { |
| 297 |
if (r == 'removed') { |
| 298 |
$("#option-" + c).remove(); |
| 299 |
$('.ajax-message').ajaxMessage('<div class="message"><span> </span>Input deleted.</div>'); |
| 300 |
} else { |
| 301 |
$('.ajax-message').ajaxMessage('<div class="message warning"><span> </span>'+r+'</div>'); |
| 302 |
} |
| 303 |
} else { |
| 304 |
$('.ajax-message').ajaxMessage('<div class="message warning"><span> </span>'+r+'</div>'); |
| 305 |
} |
| 306 |
}); |
| 307 |
return false; |
| 308 |
}, |
| 309 |
add: function (c) { |
| 310 |
var e = this, |
| 311 |
addRow, editRow = true, temp_select; |
| 312 |
e.revert(); |
| 313 |
|
| 314 |
// Clone the blank main row |
| 315 |
addRow = $('#inline-add').clone(true); |
| 316 |
addRow = $(addRow).attr('id', 'option-'+c); |
| 317 |
|
| 318 |
// Clone the blank edit row |
| 319 |
editRow = $('#inline-edit').clone(true); |
| 320 |
|
| 321 |
$('a.cancel', editRow).addClass('undo-add'); |
| 322 |
$('a.save', editRow).addClass('add-save'); |
| 323 |
$('a.edit-inline').addClass('disable'); |
| 324 |
$('a.delete-inline').addClass('disable'); |
| 325 |
$('a.add-option').addClass('disable'); |
| 326 |
|
| 327 |
// Set Colspan to 5 |
| 328 |
$('td', editRow).attr('colspan', 5); |
| 329 |
|
| 330 |
// Add Row |
| 331 |
$("#framework-settings tr:last").after(addRow); |
| 332 |
|
| 333 |
// Add Row and hide |
| 334 |
$(addRow).hide().after(editRow); |
| 335 |
|
| 336 |
$('.item-data', addRow).attr('id', 'inline_'+c); |
| 337 |
|
| 338 |
// Show The Editor |
| 339 |
$(editRow).attr('id', 'edit-'+c).addClass('inline-editor').show(); |
| 340 |
|
| 341 |
$('.item_title', '#edit-'+c).focus(); |
| 342 |
|
| 343 |
$('.select').each(function () { |
| 344 |
temp_select = $(this).prev('span').text(); |
| 345 |
if (temp_select == 'Heading') { |
| 346 |
$('.option-desc', '#edit-'+c).hide(); |
| 347 |
$('.option-options', '#edit-'+c).hide(); |
| 348 |
} |
| 349 |
}); |
| 350 |
|
| 351 |
$('.select').live('change', function () { |
| 352 |
temp_select = $(this).prev('span').text(); |
| 353 |
if (temp_select == 'Heading') { |
| 354 |
$('.option-desc', '#edit-'+c).hide(); |
| 355 |
$('.option-options', '#edit-'+c).hide(); |
| 356 |
} else if ( |
| 357 |
temp_select == 'Checkbox' || |
| 358 |
temp_select == 'Radio' || |
| 359 |
temp_select == 'Select' |
| 360 |
) { |
| 361 |
$('.alternative').hide(); |
| 362 |
$('.regular').show(); |
| 363 |
$('.option-desc', '#edit-'+c).show(); |
| 364 |
$('.option-options', '#edit-'+c).show(); |
| 365 |
/* avatar */ |
| 366 |
}else if (temp_select == 'Avatar'){ |
| 367 |
$('.regular').hide(); |
| 368 |
$('.alternative').show().html('<strong>Avatar Size:</strong> Enter a numeric value (between 20 and 200) for the avatar size.'); |
| 369 |
$('.option-desc', editRow).show(); |
| 370 |
$('.option-options', editRow).show(); |
| 371 |
/* end avatar */ |
| 372 |
} else { |
| 373 |
if (temp_select == 'Textarea') { |
| 374 |
$('.regular').hide(); |
| 375 |
$('.alternative').show().html('<strong>Row Count:</strong> Enter a numeric value for the number of rows in your textarea.'); |
| 376 |
$('.option-desc', '#edit-'+c).show(); |
| 377 |
$('.option-options', '#edit-'+c).show(); |
| 378 |
} else if ( |
| 379 |
temp_select == 'Custom Post' || |
| 380 |
temp_select == 'Custom Posts' |
| 381 |
) { |
| 382 |
$('.regular').hide(); |
| 383 |
$('.alternative').show().html('<strong>Post Type:</strong> Enter your custom post_type.'); |
| 384 |
$('.option-desc', '#edit-'+c).show(); |
| 385 |
$('.option-options', '#edit-'+c).show(); |
| 386 |
} else { |
| 387 |
$('.option-desc', '#edit-'+c).show(); |
| 388 |
$('.option-options', '#edit-'+c).hide(); |
| 389 |
} |
| 390 |
} |
| 391 |
}); |
| 392 |
|
| 393 |
// Scroll |
| 394 |
$('html, body').animate({ scrollTop: 2000 }, 500); |
| 395 |
|
| 396 |
return false; |
| 397 |
}, |
| 398 |
undoAdd: function (b) { |
| 399 |
var e = this, |
| 400 |
c = true; |
| 401 |
e.revert(); |
| 402 |
c = $("#framework-settings tr:last").attr('id'); |
| 403 |
c = c.substr(c.lastIndexOf("-") + 1); |
| 404 |
|
| 405 |
$("a.edit-inline").removeClass('disable'); |
| 406 |
$("a.delete-inline").removeClass('disable'); |
| 407 |
$("a.add-option").removeClass('disable'); |
| 408 |
$("#option-" + c).remove(); |
| 409 |
|
| 410 |
return false; |
| 411 |
}, |
| 412 |
addSave: function (e) { |
| 413 |
var d, b, c, f, g, itemId; |
| 414 |
e = $("tr.inline-editor").attr("id"); |
| 415 |
e = e.substr(e.lastIndexOf("-") + 1); |
| 416 |
f = $("#edit-" + e); |
| 417 |
g = $("#inline_" + e); |
| 418 |
itemId = $.trim($("input.item_id", f).val().toLowerCase()).replace(/(\s+)/g,'_'); |
| 419 |
if (!itemId) { |
| 420 |
itemId = $.trim($("input.item_title", f).val().toLowerCase()).replace(/(\s+)/g,'_'); |
| 421 |
} |
| 422 |
d = { |
| 423 |
action: "profile_builder_add", |
| 424 |
id: e, |
| 425 |
item_id: itemId, |
| 426 |
item_title: $("input.item_title", f).val(), |
| 427 |
item_desc: $("textarea.item_desc", f).val(), |
| 428 |
item_type: $("select.item_type", f).val(), |
| 429 |
item_options: $("input.item_options", f).val() |
| 430 |
}; |
| 431 |
b = $("#edit-" + e + " :input").serialize(); |
| 432 |
d = b + "&" + $.param(d); |
| 433 |
$.post(ajaxurl, d, function (r) { |
| 434 |
if (r) { |
| 435 |
if (r == 'updated') { |
| 436 |
inlineEditOption.afterSave(e); |
| 437 |
$("#edit-" + e).remove(); |
| 438 |
$("#option-" + e).show(); |
| 439 |
$('.ajax-message').ajaxMessage('<div class="message"><span> </span>Input added.</div>'); |
| 440 |
$('#framework-settings').tableDnD({ |
| 441 |
onDragClass: "dragging", |
| 442 |
onDrop: function(table, row) { |
| 443 |
d = { |
| 444 |
action: "profile_builder_sort", |
| 445 |
id: $.tableDnD.serialize(), |
| 446 |
_ajax_nonce: $("#_ajax_nonce").val() |
| 447 |
}; |
| 448 |
$.post(ajaxurl, d, function (response) { |
| 449 |
|
| 450 |
}, "html"); |
| 451 |
} |
| 452 |
}); |
| 453 |
} else { |
| 454 |
$('.ajax-message').ajaxMessage('<div class="message warning"><span> </span>'+r+'</div>'); |
| 455 |
} |
| 456 |
} else { |
| 457 |
$('.ajax-message').ajaxMessage('<div class="message warning"><span> </span>'+r+'</div>'); |
| 458 |
} |
| 459 |
}); |
| 460 |
|
| 461 |
return false; |
| 462 |
}, |
| 463 |
edit: function (b) { |
| 464 |
var e = this, |
| 465 |
c, editRow, rowData, item_title, item_id, item_type, item_desc, item_options = true, temp_select; |
| 466 |
e.revert(); |
| 467 |
|
| 468 |
c = $(b).parents("tr:first").attr('id'); |
| 469 |
c = c.substr(c.lastIndexOf("-") + 1); |
| 470 |
|
| 471 |
// Clone the blank row |
| 472 |
editRow = $('#inline-edit').clone(true); |
| 473 |
$('td', editRow).attr('colspan', 5); |
| 474 |
$("#option-" + c).hide().after(editRow); |
| 475 |
|
| 476 |
// First Option Settings |
| 477 |
if ("#option-" + c == '#option-1') { |
| 478 |
$('.option').hide(); |
| 479 |
$('.option-title').show().css({"paddingBottom":"1px"}); |
| 480 |
$('.description', editRow).html('First item must be a heading.'); |
| 481 |
} |
| 482 |
|
| 483 |
// Populate the option data |
| 484 |
rowData = $('#inline_' + c); |
| 485 |
|
| 486 |
// Item Title |
| 487 |
item_title = $('.item_title', rowData).text(); |
| 488 |
$('.item_title', editRow).attr('value', item_title); |
| 489 |
|
| 490 |
// Item ID |
| 491 |
item_id = $('.item_id', rowData).text(); |
| 492 |
$('.item_id', editRow).attr('value', item_id); |
| 493 |
|
| 494 |
// Item Type |
| 495 |
item_type = $('.item_type', rowData).text(); |
| 496 |
$('select[name=item_type] option[value='+item_type+']', editRow).attr('selected', true); |
| 497 |
var temp_item_type = $('select[name=item_type] option[value='+item_type+']', editRow).text(); |
| 498 |
$('.select_wrapper span', editRow).text(temp_item_type); |
| 499 |
|
| 500 |
// Item Description |
| 501 |
item_desc = $('.item_desc', rowData).text(); |
| 502 |
$('.item_desc', editRow).attr('value', item_desc); |
| 503 |
|
| 504 |
// Avatar size |
| 505 |
item_avatar = $('.item_avatar', rowData).text(); |
| 506 |
$('.item_avatar', editRow).attr('value', item_avatar); |
| 507 |
|
| 508 |
// Item Options |
| 509 |
item_options = $('.item_options', rowData).text(); |
| 510 |
$('.item_options', editRow).attr('value', item_options); |
| 511 |
|
| 512 |
|
| 513 |
$('.select', editRow).each(function () { |
| 514 |
temp_select = $(this).prev('span').text(); |
| 515 |
if (temp_select == 'Heading') { |
| 516 |
$('.option-desc', editRow).hide(); |
| 517 |
$('.option-options', editRow).hide(); |
| 518 |
} else if ( |
| 519 |
temp_select == 'Checkbox' || |
| 520 |
temp_select == 'Radio' || |
| 521 |
temp_select == 'Select' |
| 522 |
) { |
| 523 |
$('.option-desc', editRow).show(); |
| 524 |
$('.option-options', editRow).show(); |
| 525 |
/*avatar */ |
| 526 |
} else if (temp_select == 'Avatar'){ |
| 527 |
$('.regular').hide(); |
| 528 |
$('.alternative').show().html('<strong>Avatar Size:</strong> Enter a numeric value (between 20 and 200) for size of the avatar.'); |
| 529 |
$('.option-desc', editRow).show(); |
| 530 |
$('.option-options', editRow).show(); |
| 531 |
/* end avatar */ |
| 532 |
} else { |
| 533 |
if (temp_select == 'Textarea') { |
| 534 |
$('.regular').hide(); |
| 535 |
$('.alternative').show().html('<strong>Row Count:</strong> Enter a numeric value for the number of rows in your textarea.'); |
| 536 |
$('.option-desc', editRow).show(); |
| 537 |
$('.option-options', editRow).show(); |
| 538 |
} else if ( |
| 539 |
temp_select == 'Custom Post' || |
| 540 |
temp_select == 'Custom Posts' |
| 541 |
) { |
| 542 |
$('.regular').hide(); |
| 543 |
$('.alternative').show().html('<strong>Post Type:</strong> Enter your custom post_type.'); |
| 544 |
$('.option-desc', editRow).show(); |
| 545 |
$('.option-options', editRow).show(); |
| 546 |
} else { |
| 547 |
$('.option-desc', editRow).show(); |
| 548 |
$('.option-options', editRow).hide(); |
| 549 |
} |
| 550 |
} |
| 551 |
}); |
| 552 |
|
| 553 |
$('.select').live('change', function () { |
| 554 |
temp_select = $(this).prev('span').text(); |
| 555 |
if (temp_select == 'Heading') { |
| 556 |
$('.option-desc', editRow).hide(); |
| 557 |
$('.option-options', editRow).hide(); |
| 558 |
} else if ( |
| 559 |
temp_select == 'Checkbox' || |
| 560 |
temp_select == 'Radio' || |
| 561 |
temp_select == 'Select' |
| 562 |
) { |
| 563 |
$('.alternative').hide(); |
| 564 |
$('.regular').show(); |
| 565 |
$('.option-desc', editRow).show(); |
| 566 |
$('.option-options', editRow).show(); |
| 567 |
/*avatar */ |
| 568 |
} else if (temp_select == 'Avatar'){ |
| 569 |
$('.regular').hide(); |
| 570 |
$('.alternative').show().html('<strong>Avatar Size:</strong> Enter a numeric value (between 20 and 200) for size of the avatar.'); |
| 571 |
$('.option-desc', editRow).show(); |
| 572 |
$('.option-options', editRow).show(); |
| 573 |
/* end avatar */ |
| 574 |
} else { |
| 575 |
if (temp_select == 'Textarea') { |
| 576 |
$('.regular').hide(); |
| 577 |
$('.alternative').show().html('<strong>Row Count:</strong> Enter a numeric value for the number of rows in your textarea.'); |
| 578 |
$('.option-desc', editRow).show(); |
| 579 |
$('.option-options', editRow).show(); |
| 580 |
} else if ( |
| 581 |
temp_select == 'Custom Post' || |
| 582 |
temp_select == 'Custom Posts' |
| 583 |
) { |
| 584 |
$('.regular').hide(); |
| 585 |
$('.alternative').show().html('<strong>Post Type:</strong> Enter your custom post_type.'); |
| 586 |
$('.option-desc', editRow).show(); |
| 587 |
$('.option-options', editRow).show(); |
| 588 |
} else { |
| 589 |
$('.option-desc', editRow).show(); |
| 590 |
$('.option-options', editRow).hide(); |
| 591 |
} |
| 592 |
} |
| 593 |
}); |
| 594 |
|
| 595 |
// Show The Editor |
| 596 |
$(editRow).attr('id', 'edit-'+c).addClass('inline-editor').show(); |
| 597 |
|
| 598 |
// Scroll |
| 599 |
var target = $('#edit-'+c); |
| 600 |
if (c > 1) { |
| 601 |
var top = target.offset().top; |
| 602 |
$('html,body').animate({scrollTop: top}, 500); |
| 603 |
return false; |
| 604 |
} |
| 605 |
|
| 606 |
return false; |
| 607 |
}, |
| 608 |
editSave: function (e) { |
| 609 |
var d, b, c, f, g, itemId; |
| 610 |
e = $("tr.inline-editor").attr("id"); |
| 611 |
e = e.substr(e.lastIndexOf("-") + 1); |
| 612 |
f = $("#edit-" + e); |
| 613 |
g = $("#inline_" + e); |
| 614 |
itemId = $.trim($("input.item_id", f).val().toLowerCase()).replace(/(\s+)/g,'_'); |
| 615 |
if (!itemId) { |
| 616 |
itemId = $.trim($("input.item_title", f).val().toLowerCase()).replace(/(\s+)/g,'_'); |
| 617 |
} |
| 618 |
d = { |
| 619 |
action: "profile_builder_edit", |
| 620 |
id: e, |
| 621 |
item_id: itemId, |
| 622 |
item_title: $("input.item_title", f).val(), |
| 623 |
item_desc: $("textarea.item_desc", f).val(), |
| 624 |
item_type: $("select.item_type", f).val(), |
| 625 |
item_options: $("input.item_options", f).val() |
| 626 |
}; |
| 627 |
b = $("#edit-" + e + " :input").serialize(); |
| 628 |
d = b + "&" + $.param(d); |
| 629 |
$.post(ajaxurl, d, function (r) { |
| 630 |
if (r) { |
| 631 |
if (r == 'updated') { |
| 632 |
inlineEditOption.afterSave(e); |
| 633 |
$("#edit-" + e).remove(); |
| 634 |
$("#option-" + e).show(); |
| 635 |
$('.ajax-message').ajaxMessage('<div class="message"><span> </span>Option Saved.</div>'); |
| 636 |
} else { |
| 637 |
$('.ajax-message').ajaxMessage('<div class="message warning"><span> </span>'+r+'</div>'); |
| 638 |
} |
| 639 |
} else { |
| 640 |
$('.ajax-message').ajaxMessage('<div class="message warning"><span> </span>'+r+'</div>'); |
| 641 |
} |
| 642 |
}); |
| 643 |
return false; |
| 644 |
}, |
| 645 |
afterSave: function (e) { |
| 646 |
var x, y, z, |
| 647 |
n, m, o, p, q, r = true; |
| 648 |
x = $("#edit-" + e); |
| 649 |
y = $("#option-" + e); |
| 650 |
z = $("#inline_" + e); |
| 651 |
$('.option').show(); |
| 652 |
$('a.cancel', x).removeClass('undo-add'); |
| 653 |
$('a.save', x).removeClass('add-save'); |
| 654 |
$("a.add-option").removeClass('disable'); |
| 655 |
$('a.edit-inline').removeClass('disable'); |
| 656 |
$('a.delete-inline').removeClass('disable'); |
| 657 |
if (n = $("input.item_title", x).val()) { |
| 658 |
if ($("select.item_type", x).val() != 'heading') { |
| 659 |
$(y).removeClass('col-heading'); |
| 660 |
$('.col-title', y).attr('colspan', 1); |
| 661 |
$(".col-key", y).show(); |
| 662 |
$(".col-type", y).show(); |
| 663 |
$(".col-title", y).text('- ' + n); |
| 664 |
} else { |
| 665 |
$(y).addClass('col-heading'); |
| 666 |
$('.col-title', y).attr('colspan', 3); |
| 667 |
$(".col-key", y).hide(); |
| 668 |
$(".col-type", y).hide(); |
| 669 |
$(".col-title", y).text(n); |
| 670 |
} |
| 671 |
$(".item_title", z).text(n); |
| 672 |
} |
| 673 |
if (m = $.trim($("input.item_id", x).val().toLowerCase()).replace(/(\s+)/g,'_')) { |
| 674 |
$(".col-key", y).text(m); |
| 675 |
$(".item_id", z).text(m); |
| 676 |
} else { |
| 677 |
m = $.trim($("input.item_title", x).val().toLowerCase()).replace(/(\s+)/g,'_'); |
| 678 |
$(".col-key", y).text(m); |
| 679 |
$(".item_id", z).text(m); |
| 680 |
} |
| 681 |
if (o = $("select.item_type option:selected", x).val()) { |
| 682 |
$(".col-type", y).text(o); |
| 683 |
$(".item_type", z).text(o); |
| 684 |
} |
| 685 |
if (p = $("textarea.item_desc", x).val()) { |
| 686 |
$(".item_desc", z).text(p); |
| 687 |
} |
| 688 |
if (r = $("input.item_options", x).val()) { |
| 689 |
$(".item_options", z).text(r); |
| 690 |
} |
| 691 |
}, |
| 692 |
revert: function () { |
| 693 |
var b, |
| 694 |
n, m, o, p, q, r = true; |
| 695 |
if (b = $(".inline-editor").attr("id")) { |
| 696 |
$('#'+ b).remove(); |
| 697 |
b = b.substr(b.lastIndexOf("-") + 1); |
| 698 |
$('.option').show(); |
| 699 |
$("#option-" + b).show(); |
| 700 |
} |
| 701 |
return false; |
| 702 |
} |
| 703 |
}; |
| 704 |
$(document).ready(function () { |
| 705 |
inlineEditOption.init(); |
| 706 |
}) |
| 707 |
})(jQuery); |