2019-11-27 17:12:05 +00:00
|
|
|
module.exports = function (grunt, rootpathprefix) {
|
2019-11-21 07:58:05 +00:00
|
|
|
const sprite_name = 'iconssmall';
|
|
|
|
const sprite_name_big = 'iconsbig';
|
2021-01-26 20:52:43 +00:00
|
|
|
const sprite_name_huge = 'iconshuge';
|
2019-11-27 17:12:05 +00:00
|
|
|
|
2019-11-21 07:58:05 +00:00
|
|
|
const helpers = {
|
|
|
|
parselang: (name, options) => {
|
|
|
|
if (/\((\S+)\)$/.test(name)) {
|
2019-11-27 17:12:05 +00:00
|
|
|
let _match = /(.+)\((\S+)\)$/.exec(name);
|
2019-11-21 07:58:05 +00:00
|
|
|
return '[applang=' + _match[2] + '] ' + options.fn({name:_match[1]});
|
|
|
|
}
|
|
|
|
|
|
|
|
return options.fn({name:name});
|
|
|
|
},
|
2019-11-27 17:12:05 +00:00
|
|
|
half: num => {return num/2;},
|
|
|
|
scaled: (num, factor) => {return num / factor;}
|
2019-11-21 07:58:05 +00:00
|
|
|
};
|
|
|
|
|
2019-11-27 17:12:05 +00:00
|
|
|
const _prefix = rootpathprefix || '../../';
|
|
|
|
const configTemplate = opts => {
|
|
|
|
let _editor_res_root = `${_prefix}apps/${opts.editor}/main/resources`,
|
|
|
|
_common_res_root = `${_prefix}apps/common/main/resources`,
|
2021-01-26 20:52:43 +00:00
|
|
|
_scaled_path = `${opts.scale}/${opts.extpath ? opts.extpath : '.'}`;
|
2019-11-27 17:12:05 +00:00
|
|
|
return {
|
|
|
|
src: [`${_editor_res_root}/img/toolbar/${_scaled_path}/*.png`, `${_common_res_root}/img/toolbar/${_scaled_path}/*.png`],
|
|
|
|
dest: `${_editor_res_root}/img/${opts.scale != '1x' ? opts.spritename + '@' + opts.scale : opts.spritename}.png`,
|
|
|
|
destCss: `${_editor_res_root}/less/sprites/${opts.spritename}@${opts.scale}.less`,
|
|
|
|
cssTemplate: `${_common_res_root}/img/toolbar/${_scaled_path}/.css.handlebars`,
|
|
|
|
algorithm: 'top-down',
|
|
|
|
cssHandlebarsHelpers: helpers
|
|
|
|
};
|
|
|
|
};
|
2019-11-21 07:58:05 +00:00
|
|
|
|
2019-11-27 17:12:05 +00:00
|
|
|
grunt.initConfig({
|
|
|
|
sprite: {
|
|
|
|
'word-1x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '1x'
|
|
|
|
}),
|
|
|
|
'word-big-1x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '1x',
|
2021-01-26 20:52:43 +00:00
|
|
|
extpath: 'big'
|
|
|
|
}),
|
|
|
|
'word-huge-1x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name_huge,
|
|
|
|
scale: '1x',
|
|
|
|
extpath: 'huge'
|
2019-11-27 17:12:05 +00:00
|
|
|
}),
|
|
|
|
'word-2x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '2x'
|
|
|
|
}),
|
|
|
|
'word-big-2x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '2x',
|
2021-01-26 20:52:43 +00:00
|
|
|
extpath: 'big'
|
|
|
|
}),
|
|
|
|
'word-huge-2x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name_huge,
|
|
|
|
scale: '2x',
|
|
|
|
extpath: 'huge'
|
2019-11-27 17:12:05 +00:00
|
|
|
}),
|
2021-05-21 08:19:26 +00:00
|
|
|
|
|
|
|
'word1.25x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '1.25x'
|
|
|
|
}),
|
|
|
|
'word-big-1.25x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '1.25x',
|
|
|
|
extpath: 'big'
|
|
|
|
}),
|
|
|
|
'word-huge-1.25x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name_huge,
|
|
|
|
scale: '1.25x',
|
|
|
|
extpath: 'huge'
|
|
|
|
}),
|
|
|
|
|
2019-11-27 17:12:05 +00:00
|
|
|
'word1.5x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '1.5x'
|
|
|
|
}),
|
|
|
|
'word-big-1.5x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '1.5x',
|
2021-01-26 20:52:43 +00:00
|
|
|
extpath: 'big'
|
|
|
|
}),
|
|
|
|
'word-huge-1.5x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name_huge,
|
|
|
|
scale: '1.5x',
|
|
|
|
extpath: 'huge'
|
2019-11-27 17:12:05 +00:00
|
|
|
}),
|
2021-05-21 08:19:26 +00:00
|
|
|
|
|
|
|
'word1.75x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '1.75x'
|
|
|
|
}),
|
|
|
|
'word-big-1.75x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '1.75x',
|
|
|
|
extpath: 'big'
|
|
|
|
}),
|
|
|
|
'word-huge-1.75x': configTemplate({
|
|
|
|
editor:'documenteditor',
|
|
|
|
spritename: sprite_name_huge,
|
|
|
|
scale: '1.75x',
|
|
|
|
extpath: 'huge'
|
|
|
|
}),
|
|
|
|
|
2019-11-27 17:12:05 +00:00
|
|
|
'slide-1x': configTemplate({
|
|
|
|
editor:'presentationeditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '1x'
|
|
|
|
}),
|
|
|
|
'slide-big-1x': configTemplate({
|
|
|
|
editor:'presentationeditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '1x',
|
2021-01-26 20:52:43 +00:00
|
|
|
extpath: 'big'
|
2019-11-27 17:12:05 +00:00
|
|
|
}),
|
2021-05-21 10:07:09 +00:00
|
|
|
|
2019-11-27 17:12:05 +00:00
|
|
|
'slide-2x': configTemplate({
|
|
|
|
editor:'presentationeditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '2x'
|
|
|
|
}),
|
|
|
|
'slide-big-2x': configTemplate({
|
|
|
|
editor:'presentationeditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '2x',
|
2021-01-26 20:52:43 +00:00
|
|
|
extpath: 'big'
|
2019-11-27 17:12:05 +00:00
|
|
|
}),
|
2021-05-21 10:07:09 +00:00
|
|
|
|
2019-11-27 17:12:05 +00:00
|
|
|
'slide-1.5x': configTemplate({
|
|
|
|
editor:'presentationeditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '1.5x'
|
|
|
|
}),
|
|
|
|
'slide-big-1.5x': configTemplate({
|
|
|
|
editor:'presentationeditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '1.5x',
|
2021-01-26 20:52:43 +00:00
|
|
|
extpath: 'big'
|
2019-11-27 17:12:05 +00:00
|
|
|
}),
|
2021-05-21 10:07:09 +00:00
|
|
|
|
|
|
|
'slide-1.25x': configTemplate({
|
|
|
|
editor:'presentationeditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '1.25x'
|
|
|
|
}),
|
|
|
|
'slide-big-1.25x': configTemplate({
|
|
|
|
editor:'presentationeditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '1.25x',
|
|
|
|
extpath: 'big'
|
|
|
|
}),
|
|
|
|
|
|
|
|
'slide-1.75x': configTemplate({
|
|
|
|
editor:'presentationeditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '1.75x'
|
|
|
|
}),
|
|
|
|
'slide-big-1.75x': configTemplate({
|
|
|
|
editor:'presentationeditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '1.75x',
|
|
|
|
extpath: 'big'
|
|
|
|
}),
|
|
|
|
|
2019-11-27 17:12:05 +00:00
|
|
|
'cell-1x': configTemplate({
|
|
|
|
editor:'spreadsheeteditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '1x'
|
|
|
|
}),
|
|
|
|
'cell-big-1x': configTemplate({
|
|
|
|
editor:'spreadsheeteditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '1x',
|
2021-01-26 20:52:43 +00:00
|
|
|
extpath: 'big'
|
2019-11-27 17:12:05 +00:00
|
|
|
}),
|
2021-05-21 10:07:09 +00:00
|
|
|
|
2019-11-27 17:12:05 +00:00
|
|
|
'cell-2x': configTemplate({
|
|
|
|
editor:'spreadsheeteditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '2x'
|
|
|
|
}),
|
|
|
|
'cell-big-2x': configTemplate({
|
|
|
|
editor:'spreadsheeteditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '2x',
|
2021-01-26 20:52:43 +00:00
|
|
|
extpath: 'big'
|
2019-11-27 17:12:05 +00:00
|
|
|
}),
|
2021-05-21 10:07:09 +00:00
|
|
|
|
2019-11-27 17:12:05 +00:00
|
|
|
'cell-1.5x': configTemplate({
|
|
|
|
editor:'spreadsheeteditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '1.5x'
|
|
|
|
}),
|
|
|
|
'cell-big-1.5x': configTemplate({
|
|
|
|
editor:'spreadsheeteditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '1.5x',
|
2021-01-26 20:52:43 +00:00
|
|
|
extpath: 'big'
|
2021-05-21 10:07:09 +00:00
|
|
|
}),
|
|
|
|
|
|
|
|
'cell-1.25x': configTemplate({
|
|
|
|
editor:'spreadsheeteditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '1.25x'
|
|
|
|
}),
|
|
|
|
'cell-big-1.25x': configTemplate({
|
|
|
|
editor:'spreadsheeteditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '1.25x',
|
|
|
|
extpath: 'big'
|
|
|
|
}),
|
|
|
|
|
|
|
|
'cell-1.75x': configTemplate({
|
|
|
|
editor:'spreadsheeteditor',
|
|
|
|
spritename: sprite_name,
|
|
|
|
scale: '1.75x'
|
|
|
|
}),
|
|
|
|
'cell-big-1.75x': configTemplate({
|
|
|
|
editor:'spreadsheeteditor',
|
|
|
|
spritename: sprite_name_big,
|
|
|
|
scale: '1.75x',
|
|
|
|
extpath: 'big'
|
|
|
|
}),
|
2019-11-27 17:12:05 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Load in `grunt-spritesmith`
|
|
|
|
grunt.loadNpmTasks('grunt-spritesmith');
|
|
|
|
|
2021-01-26 20:52:43 +00:00
|
|
|
grunt.registerTask('word-icons', ['sprite:word-1x', 'sprite:word-big-1x', 'sprite:word-huge-1x', 'sprite:word-2x', 'sprite:word-big-2x', 'sprite:word-huge-2x',
|
2021-05-21 08:19:26 +00:00
|
|
|
'sprite:word1.25x', 'sprite:word-big-1.25x', 'sprite:word-huge-1.25x',
|
|
|
|
'sprite:word1.5x', 'sprite:word-big-1.5x', 'sprite:word-huge-1.5x',
|
|
|
|
'sprite:word1.75x', 'sprite:word-big-1.75x', 'sprite:word-huge-1.75x']);
|
2021-05-21 10:07:09 +00:00
|
|
|
grunt.registerTask('slide-icons', ['sprite:slide-1x', 'sprite:slide-big-1x','sprite:slide-2x', 'sprite:slide-big-2x',
|
|
|
|
'sprite:slide-1.5x', 'sprite:slide-big-1.5x',
|
|
|
|
'sprite:slide-1.25x', 'sprite:slide-big-1.25x',
|
|
|
|
'sprite:slide-1.75x', 'sprite:slide-big-1.75x']);
|
|
|
|
grunt.registerTask('cell-icons', ['sprite:cell-1x', 'sprite:cell-big-1x','sprite:cell-2x', 'sprite:cell-big-2x',
|
|
|
|
'sprite:cell-1.5x', 'sprite:cell-big-1.5x',
|
|
|
|
'sprite:cell-1.25x', 'sprite:cell-big-1.25x',
|
|
|
|
'sprite:cell-1.75x', 'sprite:cell-big-1.75x']);
|
2019-11-27 17:12:05 +00:00
|
|
|
|
|
|
|
grunt.registerTask('all-icons-sprite', ['word-icons','slide-icons','cell-icons']);
|
|
|
|
grunt.registerTask('default', ['all-icons-sprite']);
|
2019-11-21 07:58:05 +00:00
|
|
|
};
|