| 1 |
jQuery(document).ready(function() { |
| 2 |
|
| 3 |
/*---------------------------------------------------------*/ |
| 4 |
/* Book Display Mode */ |
| 5 |
/*---------------------------------------------------------*/ |
| 6 |
|
| 7 |
if(jQuery('#mbt_display_modes').length > 0) { |
| 8 |
var book_display_modes = {}; |
| 9 |
try { book_display_modes = JSON.parse(jQuery('#mbt_display_modes').val()); } catch(err) {} |
| 10 |
|
| 11 |
function update_display_mode() { |
| 12 |
var display_mode = jQuery('#mbt_display_mode').val(); |
| 13 |
if(book_display_modes[display_mode]) { |
| 14 |
var display_mode_supports = book_display_modes[display_mode].supports; |
| 15 |
jQuery('[data-mbt-supports]').hide(); |
| 16 |
for(var i = display_mode_supports.length - 1; i >= 0; i--) { |
| 17 |
jQuery('[data-mbt-supports="'+display_mode_supports[i]+'"]').show(); |
| 18 |
} |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
update_display_mode(); |
| 23 |
jQuery('#mbt_display_mode').change(update_display_mode); |
| 24 |
} |
| 25 |
|
| 26 |
/*---------------------------------------------------------*/ |
| 27 |
/* Buy Buttons Metabox */ |
| 28 |
/*---------------------------------------------------------*/ |
| 29 |
|
| 30 |
function mbt_reset_buybutton_numbers() { |
| 31 |
//there needs to be two passes so that ids are never reused, which breaks radio buttons |
| 32 |
jQuery('#mbt_buybutton_editors .mbt_buybutton_editor').each(function(i) { |
| 33 |
jQuery(this).find('div, input, textarea, select').each(function() { |
| 34 |
var ele = jQuery(this); |
| 35 |
if(ele.attr('name')) { ele.attr('name', ele.attr('name').replace(/mbt_buybutton\d*/, 'mbt_buybutton_new_'+(i+1))); } |
| 36 |
if(ele.attr('id')) { ele.attr('id', ele.attr('id').replace(/mbt_buybutton\d*/, 'mbt_buybutton_new_'+(i+1))); } |
| 37 |
}); |
| 38 |
}).each(function() { |
| 39 |
jQuery(this).find('div, input, textarea, select').each(function() { |
| 40 |
var ele = jQuery(this); |
| 41 |
if(ele.attr('name')) { ele.attr('name', ele.attr('name').replace(/mbt_buybutton_new_*/, 'mbt_buybutton')); } |
| 42 |
if(ele.attr('id')) { ele.attr('id', ele.attr('id').replace(/mbt_buybutton_new_*/, 'mbt_buybutton')); } |
| 43 |
}); |
| 44 |
}); |
| 45 |
} |
| 46 |
|
| 47 |
jQuery('#mbt_buybutton_adder').click(function(e) { |
| 48 |
if(!jQuery('#mbt_store_selector').val()){return false;} |
| 49 |
jQuery('#mbt_store_selector').attr('disabled', 'disabled'); |
| 50 |
jQuery('#mbt_buybutton_adder').attr('disabled', 'disabled'); |
| 51 |
jQuery.post(ajaxurl, |
| 52 |
{ |
| 53 |
action: 'mbt_buybuttons_metabox', |
| 54 |
store: jQuery('#mbt_store_selector').val(), |
| 55 |
mbt_nonce: jQuery('#mbt_buybutton_nonce').attr('data-nonce'), |
| 56 |
}, |
| 57 |
function(response) { |
| 58 |
//console.log(response); |
| 59 |
jQuery('#mbt_store_selector').removeAttr('disabled'); |
| 60 |
jQuery('#mbt_buybutton_adder').removeAttr('disabled'); |
| 61 |
element = jQuery(response); |
| 62 |
jQuery('#mbt_buybutton_editors').prepend(element); |
| 63 |
mbt_reset_buybutton_numbers(); |
| 64 |
} |
| 65 |
); |
| 66 |
return false; |
| 67 |
}); |
| 68 |
|
| 69 |
jQuery('#mbt_buybutton_editors').on('click', '.mbt_buybutton_remover', function() { |
| 70 |
jQuery(this).parents('.mbt_buybutton_editor').remove(); |
| 71 |
mbt_reset_buybutton_numbers(); |
| 72 |
}); |
| 73 |
|
| 74 |
jQuery('#mbt_buybutton_editors').sortable({cancel: '.mbt_buybutton_editor_content,.mbt_buybutton_display_selector', stop: function(){mbt_reset_buybutton_numbers();}}); |
| 75 |
|
| 76 |
// need to undisable form inputs or they will not be saved |
| 77 |
jQuery('form#post').submit(function() { |
| 78 |
jQuery('#mbt_buybutton_editors .mbt_buybutton_editor textarea').removeAttr('disabled'); |
| 79 |
jQuery('#mbt_unique_id_isbn').removeAttr('disabled'); |
| 80 |
jQuery('#mbt_unique_id_asin').removeAttr('disabled'); |
| 81 |
}); |
| 82 |
|
| 83 |
jQuery('#mbt_buybutton_editors').on('click', '.mbt_buybutton_editor_search', function(event) { |
| 84 |
//console.log('something happened'); |
| 85 |
//console.log(jQuery(event.target).attr('data-href')); |
| 86 |
event.target.href = jQuery(event.target).attr('data-href').replace('${title}', encodeURIComponent(jQuery('#title').val())); |
| 87 |
}); |
| 88 |
|
| 89 |
/*---------------------------------------------------------*/ |
| 90 |
/* Details Metabox */ |
| 91 |
/*---------------------------------------------------------*/ |
| 92 |
|
| 93 |
// book image |
| 94 |
jQuery('#mbt_book_image_id').change(function() { |
| 95 |
jQuery.post(ajaxurl, |
| 96 |
{ |
| 97 |
action: 'mbt_book_image_preview', |
| 98 |
image_id: jQuery('#mbt_book_image_id').val(), |
| 99 |
mbt_nonce: jQuery('#mbt_metadata_nonce').attr('data-nonce'), |
| 100 |
}, |
| 101 |
function(response) { |
| 102 |
jQuery('#mbt_metadata .mbt-book-image').remove(); |
| 103 |
if(response) { |
| 104 |
jQuery('#mbt_metadata .mbt-cover-image-title').after(jQuery('<img src="'+response+'" class="mbt-book-image">')); |
| 105 |
} |
| 106 |
} |
| 107 |
); |
| 108 |
}); |
| 109 |
|
| 110 |
// kindle instant preview asin warning |
| 111 |
if(jQuery('#mbt_show_instant_preview_asin_warning').length > 0) { |
| 112 |
jQuery('#mbt_unique_id_asin').change(function() { jQuery('#mbt_show_instant_preview_asin_warning').remove(); }); |
| 113 |
} |
| 114 |
|
| 115 |
// color pickers |
| 116 |
jQuery('.mbt-colorpicker').each(function() { |
| 117 |
var ele = jQuery(this); |
| 118 |
ele.spectrum({preferredFormat: 'hex', showInput: true, color: ele.val() ? ele.val() : ele.attr('data-default-color')}); |
| 119 |
}); |
| 120 |
jQuery('.mbt-colorpicker-clear').click(function() { |
| 121 |
jQuery(this).siblings('.mbt-colorpicker').spectrum('set', '#000000').val(''); |
| 122 |
}); |
| 123 |
|
| 124 |
/*---------------------------------------------------------*/ |
| 125 |
/* Overview Metabox */ |
| 126 |
/*---------------------------------------------------------*/ |
| 127 |
|
| 128 |
jQuery("#mbt_overview_image").change(function() { |
| 129 |
jQuery.post(ajaxurl, |
| 130 |
{ |
| 131 |
action: 'mbt_overview_image_preview', |
| 132 |
image_id: jQuery('#mbt_overview_image').val(), |
| 133 |
mbt_nonce: jQuery('#mbt_overview_nonce').attr('data-nonce'), |
| 134 |
}, |
| 135 |
function(response) { |
| 136 |
jQuery('.mbt_overview_image_preview').html(response); |
| 137 |
} |
| 138 |
); |
| 139 |
}); |
| 140 |
|
| 141 |
/*---------------------------------------------------------*/ |
| 142 |
/* Endorsements Metabox */ |
| 143 |
/*---------------------------------------------------------*/ |
| 144 |
|
| 145 |
var endorsement_editors = jQuery('.mbt_endorsements_editors'); |
| 146 |
var endorsement_id = 0; |
| 147 |
|
| 148 |
function new_endorsement() { |
| 149 |
var id = endorsement_id++; |
| 150 |
|
| 151 |
src = ''; |
| 152 |
src += '<div class="mbt_endorsement_editor">'; |
| 153 |
src += ' <div class="mbt_endorsement_header">'; |
| 154 |
src += ' <button class="mbt_endorsement_remover button">Remove</button>'; |
| 155 |
src += ' <div style="clear:both"></div>'; |
| 156 |
src += ' </div>'; |
| 157 |
src += ' <div class="mbt_endorsement_content">'; |
| 158 |
src += ' <div class="mbt_endorsement_image_field">'; |
| 159 |
src += ' <label class="mbt_endorsement_image_title">Image:</label>'; |
| 160 |
src += ' <div class="mbt_endorsement_image_preview_'+id+'"></div>'; |
| 161 |
src += ' <input type="hidden" class="mbt_endorsement_image" id="mbt_endorsement_image_'+id+'" value="" />'; |
| 162 |
src += ' <input class="mbt_endorsement_image_upload button" data-upload-property="id" data-upload-target="mbt_endorsement_image_'+id+'" type="button" value="Choose" />'; |
| 163 |
src += ' <input class="mbt_endorsement_image_upload_clear button" data-upload-target="mbt_endorsement_image_'+id+'" type="button" value="X" />'; |
| 164 |
src += ' </div>'; |
| 165 |
src += ' <div class="mbt_endorsement_content_field">'; |
| 166 |
src += ' <label>Endorsement:<br><textarea class="mbt_endorsement_content_text"></textarea></label>'; |
| 167 |
src += ' </div>'; |
| 168 |
src += ' <div class="mbt_endorsement_name_field">'; |
| 169 |
src += ' <label>Name: <input type="text" class="mbt_endorsement_name" value="" autocomplete="off"></label>'; |
| 170 |
src += ' </div>'; |
| 171 |
src += ' <div class="mbt_endorsement_name_url_field">'; |
| 172 |
src += ' <label>Name URL: <input type="text" class="mbt_endorsement_name_url" value="" autocomplete="off"></label>'; |
| 173 |
src += ' </div>'; |
| 174 |
src += ' <div style="clear:both"></div>'; |
| 175 |
src += ' </div>'; |
| 176 |
src += '</div>'; |
| 177 |
|
| 178 |
new_item = jQuery(src); |
| 179 |
endorsement_editors.prepend(new_item); |
| 180 |
|
| 181 |
new_item.find('.mbt_endorsement_image_upload').mbt_upload_button(); |
| 182 |
new_item.find('.mbt_endorsement_image_upload_clear').mbt_upload_clear_button(); |
| 183 |
new_item.find('.mbt_endorsement_image').change(function() { |
| 184 |
jQuery.post(ajaxurl, |
| 185 |
{ |
| 186 |
action: 'mbt_endorsement_image_preview', |
| 187 |
image_id: jQuery('#mbt_endorsement_image_'+id).val(), |
| 188 |
mbt_nonce: jQuery('#mbt_endorsement_nonce').attr('data-nonce'), |
| 189 |
}, |
| 190 |
function(response) { |
| 191 |
|
| 192 |
jQuery('.mbt_endorsement_image_preview_'+id).empty(); |
| 193 |
if(response) { |
| 194 |
jQuery('.mbt_endorsement_image_preview_'+id).html('<img src="'+response+'">'); |
| 195 |
} |
| 196 |
} |
| 197 |
); |
| 198 |
}); |
| 199 |
|
| 200 |
return new_item; |
| 201 |
} |
| 202 |
|
| 203 |
function load_endorsements() { |
| 204 |
var items = JSON.parse(jQuery('.mbt_endorsements').val()); |
| 205 |
for(var i = items.length - 1; i >= 0; i--) { |
| 206 |
var element = new_endorsement(); |
| 207 |
|
| 208 |
element.find('.mbt_endorsement_image').val(items[i]['image_id']).trigger('change'); |
| 209 |
element.find('.mbt_endorsement_content_text').val(items[i]['content']); |
| 210 |
element.find('.mbt_endorsement_name').val(items[i]['name']); |
| 211 |
element.find('.mbt_endorsement_name_url').val(items[i]['name_url']); |
| 212 |
}; |
| 213 |
} |
| 214 |
|
| 215 |
function save_endorsements() { |
| 216 |
var items = []; |
| 217 |
endorsement_editors.find('.mbt_endorsement_editor').each(function(i, e) { |
| 218 |
var element = jQuery(e); |
| 219 |
var new_item = {} |
| 220 |
|
| 221 |
new_item['image_id'] = element.find('.mbt_endorsement_image').val(); |
| 222 |
new_item['content'] = element.find('.mbt_endorsement_content_text').val(); |
| 223 |
new_item['name'] = element.find('.mbt_endorsement_name').val(); |
| 224 |
new_item['name_url'] = element.find('.mbt_endorsement_name_url').val(); |
| 225 |
|
| 226 |
items.push(new_item); |
| 227 |
}); |
| 228 |
jQuery('.mbt_endorsements').val(JSON.stringify(items)); |
| 229 |
} |
| 230 |
|
| 231 |
if(jQuery('.mbt_endorsements').length > 0) { |
| 232 |
jQuery('.mbt_endorsement_adder').click(new_endorsement); |
| 233 |
endorsement_editors.sortable({cancel: '.mbt_endorsement_content,.mbt_endorsement_title,.mbt_endorsement_remover'}); |
| 234 |
endorsement_editors.on('click', '.mbt_endorsement_remover', function() { jQuery(this).parents('.mbt_endorsement_editor').remove(); }); |
| 235 |
jQuery('input[type="submit"]').click(save_endorsements); |
| 236 |
load_endorsements(); |
| 237 |
} |
| 238 |
|
| 239 |
/*---------------------------------------------------------*/ |
| 240 |
/* Authors Metabox */ |
| 241 |
/*---------------------------------------------------------*/ |
| 242 |
|
| 243 |
function update_main_author_link() { |
| 244 |
authors = []; |
| 245 |
jQuery('input[name="tax_input[mbt_author][]"]:checked').each(function(i, e) { |
| 246 |
authors.push(jQuery(e).val()); |
| 247 |
}); |
| 248 |
jQuery.post(ajaxurl, |
| 249 |
{ |
| 250 |
action: 'mbt_main_author_url', |
| 251 |
authors: authors, |
| 252 |
mbt_nonce: jQuery('#mbt_main_author_link').attr('data-nonce'), |
| 253 |
}, |
| 254 |
function(response) { |
| 255 |
jQuery('#mbt_main_author_link').attr('href', response); |
| 256 |
} |
| 257 |
); |
| 258 |
} |
| 259 |
jQuery('input[name="tax_input[mbt_author][]"]').change(update_main_author_link); |
| 260 |
update_main_author_link(); |
| 261 |
|
| 262 |
/*---------------------------------------------------------*/ |
| 263 |
/* Book Club Metabox */ |
| 264 |
/*---------------------------------------------------------*/ |
| 265 |
|
| 266 |
var bookclub_link_editors = jQuery('.mbt_bookclub_link_editors'); |
| 267 |
var bookclub_link_id = 0; |
| 268 |
|
| 269 |
function new_bookclub_link() { |
| 270 |
var id = bookclub_link_id++; |
| 271 |
|
| 272 |
src = ''; |
| 273 |
src += '<div class="mbt_bookclub_link_editor">'; |
| 274 |
src += ' <div class="mbt_bookclub_link_header">'; |
| 275 |
src += ' <button class="mbt_bookclub_link_remover button">Remove</button>'; |
| 276 |
src += ' <div style="clear:both"></div>'; |
| 277 |
src += ' </div>'; |
| 278 |
src += ' <div class="mbt_bookclub_link_content">'; |
| 279 |
src += ' <div class="mbt_bookclub_link_url_field">'; |
| 280 |
src += ' <label>Resource URL: <input type="text" class="mbt_bookclub_link_url" id="mbt_bookclub_link_url_'+id+'" value="" autocomplete="off"></label>'; |
| 281 |
src += ' <input class="mbt_bookclub_link_upload button" data-upload-target="mbt_bookclub_link_url_'+id+'" type="button" value="Choose File" />'; |
| 282 |
src += ' </div>'; |
| 283 |
src += ' <div class="mbt_bookclub_link_text_field">'; |
| 284 |
src += ' <label>Link Text: <input type="text" class="mbt_bookclub_link_text" value="" autocomplete="off"></label>'; |
| 285 |
src += ' </div>'; |
| 286 |
src += ' <div style="clear:both"></div>'; |
| 287 |
src += ' </div>'; |
| 288 |
src += '</div>'; |
| 289 |
|
| 290 |
new_item = jQuery(src); |
| 291 |
bookclub_link_editors.prepend(new_item); |
| 292 |
|
| 293 |
new_item.find('.mbt_bookclub_link_upload').mbt_upload_button(); |
| 294 |
|
| 295 |
return new_item; |
| 296 |
} |
| 297 |
|
| 298 |
function load_bookclub_links() { |
| 299 |
var items = JSON.parse(jQuery('.mbt_bookclub_links').val()); |
| 300 |
for(var i = items.length - 1; i >= 0; i--) { |
| 301 |
var element = new_bookclub_link(); |
| 302 |
|
| 303 |
element.find('.mbt_bookclub_link_url').val(items[i]['url']); |
| 304 |
element.find('.mbt_bookclub_link_text').val(items[i]['text']); |
| 305 |
}; |
| 306 |
} |
| 307 |
|
| 308 |
function save_bookclub_links() { |
| 309 |
var items = []; |
| 310 |
bookclub_link_editors.find('.mbt_bookclub_link_editor').each(function(i, e) { |
| 311 |
var element = jQuery(e); |
| 312 |
var new_item = {} |
| 313 |
|
| 314 |
new_item['url'] = element.find('.mbt_bookclub_link_url').val(); |
| 315 |
new_item['text'] = element.find('.mbt_bookclub_link_text').val(); |
| 316 |
|
| 317 |
items.push(new_item); |
| 318 |
}); |
| 319 |
jQuery('.mbt_bookclub_links').val(JSON.stringify(items)); |
| 320 |
} |
| 321 |
|
| 322 |
if(jQuery('.mbt_bookclub_links').length > 0) { |
| 323 |
jQuery('.mbt_bookclub_link_adder').click(new_bookclub_link); |
| 324 |
bookclub_link_editors.sortable({cancel: '.mbt_bookclub_link_content,.mbt_bookclub_link_title,.mbt_bookclub_link_remover'}); |
| 325 |
bookclub_link_editors.on('click', '.mbt_bookclub_link_remover', function() { jQuery(this).parents('.mbt_bookclub_link_editor').remove(); }); |
| 326 |
jQuery('input[type="submit"]').click(save_bookclub_links); |
| 327 |
load_bookclub_links(); |
| 328 |
} |
| 329 |
|
| 330 |
/*---------------------------------------------------------*/ |
| 331 |
/* Audio Book Metabox */ |
| 332 |
/*---------------------------------------------------------*/ |
| 333 |
|
| 334 |
var audiobook_link_editors = jQuery('.mbt_audiobook_link_editors'); |
| 335 |
var audiobook_link_id = 0; |
| 336 |
|
| 337 |
function new_audiobook_link() { |
| 338 |
var id = audiobook_link_id++; |
| 339 |
|
| 340 |
src = ''; |
| 341 |
src += '<div class="mbt_audiobook_link_editor">'; |
| 342 |
src += ' <div class="mbt_audiobook_link_header">'; |
| 343 |
src += ' <button class="mbt_audiobook_link_remover button">Remove</button>'; |
| 344 |
src += ' <div style="clear:both"></div>'; |
| 345 |
src += ' </div>'; |
| 346 |
src += ' <div class="mbt_audiobook_link_content">'; |
| 347 |
src += ' <div class="mbt_audiobook_link_url_field">'; |
| 348 |
src += ' <label>Resource URL: <input type="text" class="mbt_audiobook_link_url" id="mbt_audiobook_link_url_'+id+'" value="" autocomplete="off"></label>'; |
| 349 |
src += ' <input class="mbt_audiobook_link_upload button" data-upload-target="mbt_audiobook_link_url_'+id+'" type="button" value="Choose File" />'; |
| 350 |
src += ' </div>'; |
| 351 |
src += ' <div class="mbt_audiobook_link_text_field">'; |
| 352 |
src += ' <label>Link Text: <input type="text" class="mbt_audiobook_link_text" value="" autocomplete="off"></label>'; |
| 353 |
src += ' </div>'; |
| 354 |
src += ' <div style="clear:both"></div>'; |
| 355 |
src += ' </div>'; |
| 356 |
src += '</div>'; |
| 357 |
|
| 358 |
new_item = jQuery(src); |
| 359 |
audiobook_link_editors.prepend(new_item); |
| 360 |
|
| 361 |
new_item.find('.mbt_audiobook_link_upload').mbt_upload_button(); |
| 362 |
|
| 363 |
return new_item; |
| 364 |
} |
| 365 |
|
| 366 |
function load_audiobook_links() { |
| 367 |
var items = JSON.parse(jQuery('.mbt_audiobook_links').val()); |
| 368 |
for(var i = items.length - 1; i >= 0; i--) { |
| 369 |
var element = new_audiobook_link(); |
| 370 |
|
| 371 |
element.find('.mbt_audiobook_link_url').val(items[i]['url']); |
| 372 |
element.find('.mbt_audiobook_link_text').val(items[i]['text']); |
| 373 |
}; |
| 374 |
} |
| 375 |
|
| 376 |
function save_audiobook_links() { |
| 377 |
var items = []; |
| 378 |
audiobook_link_editors.find('.mbt_audiobook_link_editor').each(function(i, e) { |
| 379 |
var element = jQuery(e); |
| 380 |
var new_item = {} |
| 381 |
|
| 382 |
new_item['url'] = element.find('.mbt_audiobook_link_url').val(); |
| 383 |
new_item['text'] = element.find('.mbt_audiobook_link_text').val(); |
| 384 |
|
| 385 |
items.push(new_item); |
| 386 |
}); |
| 387 |
jQuery('.mbt_audiobook_links').val(JSON.stringify(items)); |
| 388 |
} |
| 389 |
|
| 390 |
if(jQuery('.mbt_audiobook_links').length > 0) { |
| 391 |
jQuery('.mbt_audiobook_link_adder').click(new_audiobook_link); |
| 392 |
audiobook_link_editors.sortable({cancel: '.mbt_audiobook_link_content,.mbt_audiobook_link_title,.mbt_audiobook_link_remover'}); |
| 393 |
audiobook_link_editors.on('click', '.mbt_audiobook_link_remover', function() { jQuery(this).parents('.mbt_audiobook_link_editor').remove(); }); |
| 394 |
jQuery('input[type="submit"]').click(save_audiobook_links); |
| 395 |
load_audiobook_links(); |
| 396 |
} |
| 397 |
|
| 398 |
/*---------------------------------------------------------*/ |
| 399 |
/* Section Sorting Metabox */ |
| 400 |
/*--------------------------------------------------------*/ |
| 401 |
|
| 402 |
function load_booksections() { |
| 403 |
var items = JSON.parse(jQuery('.mbt_booksections').val()); |
| 404 |
for(var i = items.length - 1; i >= 0; i--) { |
| 405 |
jQuery('.mbt_booksections_sorters').prepend(jQuery('<div class="mbt_booksection_sorter" data-booksection-id="'+items[i]['id']+'">'+items[i]['name']+'</div>')); |
| 406 |
}; |
| 407 |
} |
| 408 |
|
| 409 |
function save_booksections() { |
| 410 |
var items = []; |
| 411 |
jQuery('.mbt_booksections_sorters .mbt_booksection_sorter').each(function(i, e) { |
| 412 |
items.push(jQuery(e).attr('data-booksection-id')); |
| 413 |
}); |
| 414 |
jQuery('.mbt_booksections').val(JSON.stringify(items)); |
| 415 |
} |
| 416 |
|
| 417 |
function change_booksections_displaymode(reset) { |
| 418 |
var display_mode; |
| 419 |
if(reset) { |
| 420 |
display_mode = jQuery('.mbt_booksections_displaymode').val(); |
| 421 |
} else { |
| 422 |
display_mode = jQuery('#mbt_display_mode').val(); |
| 423 |
} |
| 424 |
jQuery.post(ajaxurl, |
| 425 |
{ |
| 426 |
action: 'mbt_change_booksections_displaymode', |
| 427 |
display_mode: display_mode, |
| 428 |
reset: !!reset, |
| 429 |
mbt_nonce: jQuery('#mbt_sectionsorting_nonce').attr('data-nonce'), |
| 430 |
}, |
| 431 |
function(response) { |
| 432 |
jQuery('.mbt_booksections_displaymode').val(display_mode); |
| 433 |
jQuery('.mbt_booksections').val(response); |
| 434 |
jQuery('.mbt_booksections_sorters').empty(); |
| 435 |
load_booksections(); |
| 436 |
} |
| 437 |
); |
| 438 |
} |
| 439 |
|
| 440 |
if(jQuery('.mbt_booksections').length > 0) { |
| 441 |
jQuery('.mbt_booksections_sorters').sortable(); |
| 442 |
jQuery('input[type="submit"]').click(save_booksections); |
| 443 |
load_booksections(); |
| 444 |
jQuery('#mbt_display_mode').change(function() { change_booksections_displaymode(); }); |
| 445 |
jQuery('.mbt_booksections_reset').click(function() { change_booksections_displaymode(true); }); |
| 446 |
} |
| 447 |
|
| 448 |
}); |
| 449 |
|