Как найти нужный шаблон *.tpl
Когда нужно что-то изменить в интерфейсе часто начинаешь искать место в шаблоне, куда необходимо внести изменения. Скрипт ниже, будучи добавленным в конец файла js/template.js шаблона будет подсвечивать, нажатые мышкой с удержанием ctrl, области и указывать имена шаблонов так:.
Сам код:
Не все шаблоны охвачены селекторами — остальныев работе. Хотелось бы услышать мнения. Если идея понравиться, реализую в виде расширения для chrome или плагина.
Сам код:
$(function() {
var lsTplfinder = {
counter: 0,
draw : function($this, text) {
$this.find('*:first').each(function() {
$(this).prepend(
$('<div class="capt" style="z-index: 99999; font-size: 12px; color: red; background: black; ' +
'padding: 6px; width: auto; float: left; position: absolute; display: block; opacity: 1; ' +
'border-radius: 4px 0 4px;">'+
text +
'</div><div class="drawit" style="z-index: 99999; position: absolute; width: ' +
$(this).parent().width() + 'px; height: ' + $(this).parent().height() + 'px; opacity: 0.5; ' +
'background: gray; display: block; border-radius: 4px; "></div>')
);
return true;
});
},
hideAll: function() {
$('.drawit, .capt').remove()
lsTplfinder.counter = 0;
},
initBlockBySelector: function(selector, tpl) {
$(selector)
.click(function(evt) {
if (evt.ctrlKey) {
lsTplfinder.draw($(this), tpl);
lsTplfinder.counter++;
}
})
},
initBlockByObject: function(selector, tpl) {
selector
.click(function(evt) {
if (evt.ctrlKey) {
lsTplfinder.draw($(this), tpl);
lsTplfinder.counter++;
}
})
}
};
$(window).keyup(function() {
lsTplfinder.hideAll();
});
// Шаблоны
lsTplfinder.initBlockBySelector('header.topic-header', 'topic_part_header.tpl');
lsTplfinder.initBlockBySelector('footer.topic-footer', 'topic_part_footer.tpl');
lsTplfinder.initBlockBySelector('.comments.comment-list', 'comment_list.tpl');
lsTplfinder.initBlockBySelector('section.comment', 'comment.tpl');
lsTplfinder.initBlockBySelector('.pagination.pagination-comments', 'comment_paging.tpl');
lsTplfinder.initBlockBySelector('#comments', 'comment_tree.tpl');
lsTplfinder.initBlockBySelector('#footer', 'footer.tpl');
lsTplfinder.initBlockBySelector('#header', 'header_top.tpl');
lsTplfinder.initBlockBySelector('.nav-filter-wrapper', 'menu.blog.tpl');
lsTplfinder.initBlockBySelector('.dropdown-create', 'menu.create.tpl');
lsTplfinder.initBlockBySelector('.dropdown-create', 'menu.create.tpl');
lsTplfinder.initBlockBySelector('#nav', 'nav.tpl');
lsTplfinder.initBlockBySelector('#sidebar', 'sidebar.tpl');
lsTplfinder.initBlockBySelector('.stat-performance', 'stat_performance.tpl');
lsTplfinder.initBlockBySelector('#tags-help', 'tags_help.tpl');
lsTplfinder.initBlockBySelector('.toolbar-admin', 'toolbar_admin.tpl');
lsTplfinder.initBlockBySelector('#update', 'toolbar_comment.tpl');
lsTplfinder.initBlockBySelector('#toolbar_scrollup', 'toolbar_scrollup.tpl');
lsTplfinder.initBlockBySelector('.toolbar-topic', 'toolbar_topic.tpl');
lsTplfinder.initBlockBySelector('.topic-url', 'topic_link.tpl');
lsTplfinder.initBlockBySelector('div.topic-content.text', 'topic_[ВИД ТОПИКА].tpl');
lsTplfinder.initBlockBySelector('div.user-item', 'user_list.tpl');
lsTplfinder.initBlockBySelector('#favourite-form-tags', 'favourite_form_tags.tpl');
lsTplfinder.initBlockBySelector('#modal_write', 'modal_write.tpl');
lsTplfinder.initBlockBySelector('#window_login_form', 'window_login.tpl');
lsTplfinder.initBlockBySelector('#window_upload_img', 'window_upload_img.tpl');
// Блоки
lsTplfinder.initBlockBySelector('.block.block-type-blog', 'block.blog.tpl');
lsTplfinder.initBlockBySelector('.block.block-type-blog-actions', 'block.blogActions.tpl');
lsTplfinder.initBlockBySelector('.block.block-type-blog-admins', 'block.blogAdmins.tpl');
lsTplfinder.initBlockBySelector('#block_blogs', 'block.[blogs|stream].tpl');
lsTplfinder.initBlockBySelector('.block.block-type-blog-users', 'block.blogUsers.tpl');
lsTplfinder.initBlockBySelector('.js-title-commen', 'block.stream_comment.tpl');
lsTplfinder.initBlockBySelector('.js-title-topic', 'block.stream_topic.tpl');
lsTplfinder.initBlockBySelector('.block.block-type-activity', '[block.streamConfig.tpl|block.userfeedBlogs.tpl|block.userfeedUsers]');
lsTplfinder.initBlockBySelector('.block.block-type-tags', 'block.tags.tpl');
lsTplfinder.initBlockBySelector('.block.block-type-foldable.block-type-favourite-topic', 'block.tagsFavouriteTopic.tpl');
// Экшены
lsTplfinder.initBlockBySelector('#form-topic-add *', 'ActioTopic/add.tpl');
lsTplfinder.initBlockBySelector('#userfeed_loaded_topics, #userfeed_last_id, #userfeed_get_more', 'ActioUserfeed/list.tpl');
lsTplfinder.initBlockByObject($('input#blog_title').parent().parent().find('*'), 'ActioBlog/add.tpl');
});
Не все шаблоны охвачены селекторами — остальныев работе. Хотелось бы услышать мнения. Если идея понравиться, реализую в виде расширения для chrome или плагина.
5 комментариев
1. Я могу исследовать и другие сайты на ls.
2. Оно не меняет мой код.