Introducing Site Icon, favicon management for WordPress.
This v1 marries Jetpack's Site Icon module with the Media Modal, reusing code
from the Custom Header admin. For now, the core-provided icons will be limited
to a favicon, an iOS app icon, and a Windows tile icon, leaving `.ico` support
and additional icons to plugins to add.
Props obenland, tyxla, flixos90, jancbeck, markjaquith, scruffian.
See #16434.
Built from https://develop.svn.wordpress.org/trunk@32994
git-svn-id: http://core.svn.wordpress.org/trunk@32965 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-29 14:58:25 +02:00
|
|
|
/* global wpSiteIconCropData, jQuery */
|
|
|
|
(function($) {
|
|
|
|
var jcrop_api = {},
|
|
|
|
siteIconCrop = {
|
|
|
|
|
|
|
|
updateCoords : function ( coords ) {
|
|
|
|
$( '#crop-x' ).val( coords.x );
|
|
|
|
$( '#crop-y' ).val( coords.y );
|
|
|
|
$( '#crop-width' ).val( coords.w );
|
|
|
|
$( '#crop-height' ).val( coords.h );
|
|
|
|
|
|
|
|
siteIconCrop.showPreview( coords );
|
|
|
|
},
|
|
|
|
|
|
|
|
showPreview : function( coords ){
|
|
|
|
var rx = 64 / coords.w,
|
|
|
|
ry = 64 / coords.h,
|
|
|
|
preview_rx = 16 / coords.w,
|
2015-07-02 23:16:24 +02:00
|
|
|
preview_ry = 16 / coords.h;
|
|
|
|
|
|
|
|
$( '#preview-homeicon' ).css({
|
|
|
|
width: Math.round(rx * wpSiteIconCropData.width ) + 'px',
|
|
|
|
height: Math.round(ry * wpSiteIconCropData.height ) + 'px',
|
Introducing Site Icon, favicon management for WordPress.
This v1 marries Jetpack's Site Icon module with the Media Modal, reusing code
from the Custom Header admin. For now, the core-provided icons will be limited
to a favicon, an iOS app icon, and a Windows tile icon, leaving `.ico` support
and additional icons to plugins to add.
Props obenland, tyxla, flixos90, jancbeck, markjaquith, scruffian.
See #16434.
Built from https://develop.svn.wordpress.org/trunk@32994
git-svn-id: http://core.svn.wordpress.org/trunk@32965 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-29 14:58:25 +02:00
|
|
|
marginLeft: '-' + Math.round(rx * coords.x) + 'px',
|
|
|
|
marginTop: '-' + Math.round(ry * coords.y) + 'px'
|
|
|
|
});
|
|
|
|
|
2015-07-02 23:16:24 +02:00
|
|
|
$( '#preview-favicon' ).css({
|
|
|
|
width: Math.round( preview_rx * wpSiteIconCropData.width ) + 'px',
|
|
|
|
height: Math.round( preview_ry * wpSiteIconCropData.height ) + 'px',
|
Introducing Site Icon, favicon management for WordPress.
This v1 marries Jetpack's Site Icon module with the Media Modal, reusing code
from the Custom Header admin. For now, the core-provided icons will be limited
to a favicon, an iOS app icon, and a Windows tile icon, leaving `.ico` support
and additional icons to plugins to add.
Props obenland, tyxla, flixos90, jancbeck, markjaquith, scruffian.
See #16434.
Built from https://develop.svn.wordpress.org/trunk@32994
git-svn-id: http://core.svn.wordpress.org/trunk@32965 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-29 14:58:25 +02:00
|
|
|
marginLeft: '-' + Math.round( preview_rx * coords.x ) + 'px',
|
|
|
|
marginTop: '-' + Math.floor( preview_ry* coords.y ) + 'px'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
ready: function() {
|
|
|
|
jcrop_api = $.Jcrop( '#crop-image' );
|
|
|
|
jcrop_api.setOptions({
|
2015-07-02 19:16:26 +02:00
|
|
|
bgColor: 'transparent',
|
Introducing Site Icon, favicon management for WordPress.
This v1 marries Jetpack's Site Icon module with the Media Modal, reusing code
from the Custom Header admin. For now, the core-provided icons will be limited
to a favicon, an iOS app icon, and a Windows tile icon, leaving `.ico` support
and additional icons to plugins to add.
Props obenland, tyxla, flixos90, jancbeck, markjaquith, scruffian.
See #16434.
Built from https://develop.svn.wordpress.org/trunk@32994
git-svn-id: http://core.svn.wordpress.org/trunk@32965 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-29 14:58:25 +02:00
|
|
|
aspectRatio: 1,
|
|
|
|
onSelect: siteIconCrop.updateCoords,
|
|
|
|
onChange: siteIconCrop.updateCoords,
|
2015-07-02 23:16:24 +02:00
|
|
|
trueSize: [ wpSiteIconCropData.width, wpSiteIconCropData.height ],
|
Introducing Site Icon, favicon management for WordPress.
This v1 marries Jetpack's Site Icon module with the Media Modal, reusing code
from the Custom Header admin. For now, the core-provided icons will be limited
to a favicon, an iOS app icon, and a Windows tile icon, leaving `.ico` support
and additional icons to plugins to add.
Props obenland, tyxla, flixos90, jancbeck, markjaquith, scruffian.
See #16434.
Built from https://develop.svn.wordpress.org/trunk@32994
git-svn-id: http://core.svn.wordpress.org/trunk@32965 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-29 14:58:25 +02:00
|
|
|
minSize: [ wpSiteIconCropData.min_size, wpSiteIconCropData.min_size ]
|
|
|
|
});
|
|
|
|
jcrop_api.animateTo([wpSiteIconCropData.init_x, wpSiteIconCropData.init_y, wpSiteIconCropData.init_size, wpSiteIconCropData.init_size]);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
siteIconCrop.ready();
|
|
|
|
|
|
|
|
})(jQuery);
|