/
themes.js
65 lines (54 loc) · 1.97 KB
/
themes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
(function ($) {
$(document).ready(function () {
$( '#apple_news_create_theme' ).on( 'click', function( e ) {
e.preventDefault();
appleNewsThemesSubmit( $( this ), 'apple_news_create_theme' );
});
$( '#apple_news_load_example_themes' ).on( 'click', function( e ) {
e.preventDefault();
appleNewsThemesSubmit( $( this ), 'apple_news_load_example_themes' );
});
$( '#apple_news_start_import' ).on( 'click', function( e ) {
e.preventDefault();
$( '.apple-news-theme-form' ).hide();
$( '#apple_news_import_theme' ).show();
});
$( '#apple_news_upload_theme' ).on( 'click', function( e ) {
e.preventDefault();
appleNewsThemesSubmit( $( this ), 'apple_news_upload_theme' );
});
$( '#apple_news_cancel_upload_theme' ).on( 'click', function( e ) {
e.preventDefault();
$( '#apple_news_import_theme' ).hide();
});
$( '.apple-news-delete-theme' ).on( 'click', function( e ) {
e.preventDefault();
if ( confirm( appleNewsThemes.deleteWarning + ' ' + $( this ).data( 'theme' ) + '?' ) ) {
$( '#apple_news_theme' ).val( $( this ).data( 'theme' ) );
appleNewsThemesSubmit( $( this ), 'apple_news_delete_theme' );
}
});
$( '.apple-news-export-theme' ).on( 'click', function( e ) {
e.preventDefault();
$( '#apple_news_theme' ).val( $( this ).data( 'theme' ) );
appleNewsThemesSubmit( $( this ), 'apple_news_export_theme' );
});
$( '.apple-news-activate-theme' ).on( 'click', function( e ) {
e.preventDefault();
var $this = $( this );
$this.siblings( 'input[name="apple_news_active_theme"]' ).prop( 'checked', 'checked' );
appleNewsThemesSubmit( $this, 'apple_news_set_theme' );
});
});
function appleNewsThemesShowError( selector, message ) {
$( selector ).append( $( '<p>' )
.attr( 'id', 'apple_news_theme_error' )
.addClass( 'error-message' )
.text( message )
);
}
function appleNewsThemesSubmit( $el, action ) {
$( '#apple_news_action' ).val( action );
$el.parents( 'form' ).submit();
}
}( jQuery ) );