summaryrefslogtreecommitdiff
blob: 6d4f0824aaa2edb7ee482f0ad289b4a66e6fc59b (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
( function ( $ ) {
	var safe, win, safecssResize, safecssInit;

	safecssResize = function () {
		safe.height( win.height() - safe.offset().top - 250 );
	};

	safecssInit = function() {
		safe = $( '#safecss' );
		win  = $( window );

		postboxes.add_postbox_toggles( 'editcss' );
		safecssResize();

		// Bound on a parent to ensure that this click event executes last.
		$( '#safecssform' ).on( 'click', '#preview', function ( e ) {
			e.preventDefault();

			document.forms["safecssform"].target = "csspreview";
			document.forms["safecssform"].action.value = 'preview';
			document.forms["safecssform"].submit();
			document.forms["safecssform"].target = "";
			document.forms["safecssform"].action.value = 'save';
		} );
	};

	window.onresize = safecssResize;
	addLoadEvent( safecssInit );
} )( jQuery );

jQuery( function ( $ ) {
	$( '.edit-preprocessor' ).bind( 'click', function ( e ) {
		e.preventDefault();

		$( '#preprocessor-select' ).slideDown();
		$( this ).hide();
	} );

	$( '.cancel-preprocessor' ).bind( 'click', function ( e ) {
		e.preventDefault();

		$( '#preprocessor-select' ).slideUp( function () {
			$( '.edit-preprocessor' ).show();
			$( '#preprocessor_choices' ).val( $( '#custom_css_preprocessor' ).val() );
		} );
	} );

	$( '.save-preprocessor' ).bind( 'click', function ( e ) {
		e.preventDefault();

		$( '#preprocessor-select' ).slideUp();
		$( '#preprocessor-display' ).text( $( '#preprocessor_choices option:selected' ).text() );
		$( '#custom_css_preprocessor' ).val( $( '#preprocessor_choices' ).val() ).change();
		$( '.edit-preprocessor' ).show();
	} );

	$( '.edit-css-mode' ).bind( 'click', function ( e ) {
		e.preventDefault();

		$( '#css-mode-select' ).slideDown();
		$( this ).hide();
	} );

	$( '.cancel-css-mode' ).bind( 'click', function ( e ) {
		e.preventDefault();

		$( '#css-mode-select' ).slideUp( function () {
			$( '.edit-css-mode' ).show();
			$( 'input[name=add_to_existing_display][value=' + $( '#add_to_existing' ).val() + ']' ).attr( 'checked', true );
		} );
	} );

	$( '.save-css-mode' ).bind( 'click', function ( e ) {
		e.preventDefault();

		$( '#css-mode-select' ).slideUp();
		$( '#css-mode-display' ).text( $( 'input[name=add_to_existing_display]:checked' ).val() == 'true' ? 'Add-on' : 'Replacement' );
		$( '#add_to_existing' ).val( $( 'input[name=add_to_existing_display]:checked' ).val() );
		$( '.edit-css-mode' ).show();
	} );
} );