~canonical-sysadmins/wordpress/4.6

« back to all changes in this revision

Viewing changes to wp-admin/js/comment.js

  • Committer: Jacek Nykis
  • Date: 2015-01-05 16:17:05 UTC
  • Revision ID: jacek.nykis@canonical.com-20150105161705-w544l1h5mcg7u4w9
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* global postboxes:true, commentL10n:true */
 
2
jQuery(document).ready( function($) {
 
3
 
 
4
        postboxes.add_postbox_toggles('comment');
 
5
 
 
6
        var stamp = $('#timestamp').html();
 
7
        $('.edit-timestamp').click(function () {
 
8
                if ($('#timestampdiv').is(':hidden')) {
 
9
                        $('#timestampdiv').slideDown('normal');
 
10
                        $('.edit-timestamp').hide();
 
11
                }
 
12
                return false;
 
13
        });
 
14
 
 
15
        $('.cancel-timestamp').click(function() {
 
16
                $('#timestampdiv').slideUp('normal');
 
17
                $('#mm').val($('#hidden_mm').val());
 
18
                $('#jj').val($('#hidden_jj').val());
 
19
                $('#aa').val($('#hidden_aa').val());
 
20
                $('#hh').val($('#hidden_hh').val());
 
21
                $('#mn').val($('#hidden_mn').val());
 
22
                $('#timestamp').html(stamp);
 
23
                $('.edit-timestamp').show();
 
24
                return false;
 
25
        });
 
26
 
 
27
        $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels
 
28
                var aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(),
 
29
                        newD = new Date( aa, mm - 1, jj, hh, mn );
 
30
 
 
31
                if ( newD.getFullYear() != aa || (1 + newD.getMonth()) != mm || newD.getDate() != jj || newD.getMinutes() != mn ) {
 
32
                        $('.timestamp-wrap', '#timestampdiv').addClass('form-invalid');
 
33
                        return false;
 
34
                } else {
 
35
                        $('.timestamp-wrap', '#timestampdiv').removeClass('form-invalid');
 
36
                }
 
37
 
 
38
                $('#timestampdiv').slideUp('normal');
 
39
                $('.edit-timestamp').show();
 
40
                $('#timestamp').html(
 
41
                        commentL10n.submittedOn + ' <b>' +
 
42
                        $( '#mm option[value="' + mm + '"]' ).text() + ' ' +
 
43
                        jj + ', ' +
 
44
                        aa + ' @ ' +
 
45
                        hh + ':' +
 
46
                        mn + '</b> '
 
47
                );
 
48
                return false;
 
49
        });
 
50
});