| 1 | (function($) { |
||
| 2 | |||
| 3 | function podlove_init_color_buttons() { |
||
| 4 | jQuery(document).ready( function($) { |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 5 | var params = { |
||
| 6 | change: function(e, ui) { |
||
| 7 | $( e.target ).val( ui.color.toString() ); |
||
| 8 | $( e.target ).trigger('change'); // enable widget "Save" button |
||
|
0 ignored issues
–
show
|
|||
| 9 | }, |
||
| 10 | } |
||
| 11 | |||
| 12 | $('.podlove_subscribe_button_color').not('[id*="__i__"]').wpColorPicker( params ); |
||
|
0 ignored issues
–
show
|
|||
| 13 | }) |
||
| 14 | } |
||
| 15 | |||
| 16 | $( document ).ready( function() { |
||
| 17 | |||
| 18 | $("#Podlove_cover_image_select").on( 'click', function(event) { |
||
| 19 | podlove_cover_image_selector = wp.media.frames.customHeader = wp.media( { |
||
| 20 | title: i18n.media_library, |
||
| 21 | library: { |
||
| 22 | type: 'image' |
||
| 23 | }, |
||
| 24 | button: { |
||
| 25 | text: i18n.use_for |
||
| 26 | }, |
||
| 27 | multiple: false |
||
| 28 | } ); |
||
| 29 | podlove_cover_image_selector.open(); |
||
| 30 | |||
| 31 | podlove_cover_image_selector.on('select', function() { |
||
| 32 | var podcast_image_url = podlove_cover_image_selector.state().get('selection').first().toJSON().url; |
||
| 33 | $("#podlove-button-cover").val(podcast_image_url); |
||
| 34 | $("#podlove-button-cover").trigger('change'); |
||
| 35 | }); |
||
| 36 | } ); |
||
| 37 | |||
| 38 | $(document).ready(function () { |
||
| 39 | podlove_init_color_buttons(); |
||
| 40 | |||
| 41 | jQuery(document).on('widget-updated', podlove_init_color_buttons); |
||
| 42 | jQuery(document).on('widget-added', podlove_init_color_buttons); |
||
| 43 | |||
| 44 | // re-init after saving configs |
||
| 45 | jQuery(document).on('ajaxComplete', function(e){ |
||
| 46 | podlove_init_color_buttons(); |
||
| 47 | }); |
||
| 48 | }) |
||
| 49 | |||
| 50 | var feed_counter = 0; |
||
| 51 | var source = $("#feed_line_template").html(); |
||
| 52 | |||
| 53 | $(".add_feed").on( 'click', function () { |
||
| 54 | add_new_feed(); |
||
| 55 | } ); |
||
| 56 | |||
| 57 | if ( window.feeds !== undefined ) { |
||
| 58 | $.each( feeds, function (index, feed) { |
||
| 59 | add_existing_feed(feed); |
||
| 60 | } ); |
||
| 61 | } |
||
| 62 | |||
| 63 | function add_new_feed() { |
||
| 64 | row = source.replace( /\{\{url\}\}/g, '' ); |
||
| 65 | row = row.replace( /\{\{itunesfeedid\}\}/g, '' ); |
||
| 66 | row = row.replace( /\{\{id\}\}/g, feed_counter ); |
||
| 67 | |||
| 68 | $("#feeds_table_body").append(row); |
||
| 69 | |||
| 70 | new_row = $("#feeds_table_body tr:last"); |
||
| 71 | new_row.find("input:first").focus(); |
||
| 72 | |||
| 73 | $(".podlove-icon-remove").on( 'click', function () { |
||
| 74 | $(this).closest("tr").remove(); |
||
| 75 | } ); |
||
| 76 | |||
| 77 | feed_counter++; |
||
| 78 | } |
||
| 79 | |||
| 80 | function add_existing_feed( feed ) { |
||
| 81 | row = source.replace( /\{\{url\}\}/g, feed.url ); |
||
| 82 | row = row.replace( /\{\{id\}\}/g, feed_counter ); |
||
| 83 | if ( feed.itunesfeedid == null ) { |
||
| 84 | row = row.replace( /\{\{itunesfeedid\}\}/g, '' ); |
||
| 85 | } else { |
||
| 86 | row = row.replace( /\{\{itunesfeedid\}\}/g, feed.itunesfeedid ); |
||
| 87 | } |
||
| 88 | |||
| 89 | $("#feeds_table_body").append(row); |
||
| 90 | |||
| 91 | new_row = $("#feeds_table_body tr:last"); |
||
| 92 | new_row.find('select.podlove-media-format option[value="' + feed.format + '"]').attr('selected',true); |
||
| 93 | |||
| 94 | $(".podlove-icon-remove").on( 'click', function () { |
||
| 95 | $(this).closest("tr").remove(); |
||
| 96 | } ); |
||
| 97 | |||
| 98 | feed_counter++; |
||
| 99 | } |
||
| 100 | |||
| 101 | } ); |
||
| 102 | }(jQuery)); |