forked from cc-archive/wp-plugin-creativecommons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.js
51 lines (42 loc) · 1.7 KB
/
admin.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
// @source: https://github.com/creativecommons/wordpress-plugin/
// @license: http://creativecommons.org/publicdomain/zero/1.0/
jQuery(document).ready(function license($) {
// ensure that misc-pub-section-last is actually on the last one
$('.misc-pub-section').removeClass('misc-pub-section-last');
$('.misc-pub-section:last').addClass('misc-pub-section-last');
if ($('#license').length) { // if there's a license block...
var setLicenseImage = function setLicenseImage() {
if ($('#hidden-license-deed').val() == '') {
$('#license-display').html('<i>No license chosen</i>').show();
} else {
var img = $('<a target="_new"><img /></a>')
.attr('href',$('#hidden-license-deed').val())
.attr('alt',$('#hidden-license-name').val())
.find('img')
.attr('src',$('#hidden-license-image').val())
.attr('title',$('#hidden-license-name').val())
.end();
$('#license-display').html('').append(img).show();
}
}
window.setLicenseImage = setLicenseImage;
window.setLicense = function setLicense(obj) {
$('#hidden-license-deed').val(obj.deed);
$('#hidden-license-image').val(obj.button);
$('#hidden-license-name').val(obj.name);
setLicenseImage();
}
// setup license image for current license
setLicenseImage();
}
})
// for now need to integrate this better with the other js code
jQuery(document).ready( function() {
jQuery('.license-attribution-options').change( function() {
if( jQuery('#license-other').is(':checked') ) {
jQuery('#attribute-other-data').removeClass('hidden');
} else {
jQuery('#attribute-other-data').addClass('hidden');
}
})
});