Index: branches/5.2.x/core/admin_templates/js/template_manager.js =================================================================== diff -u -N -r16405 -r16409 --- branches/5.2.x/core/admin_templates/js/template_manager.js (.../template_manager.js) (revision 16405) +++ branches/5.2.x/core/admin_templates/js/template_manager.js (.../template_manager.js) (revision 16409) @@ -1,132 +1,146 @@ function TemplateManager ( $settings ) { + this.languagePrefix = ''; this.pageId = 0; this.editUrl = ''; this.browseUrl = ''; this.saveLayoutUrl = ''; + this.saveContentUrl = ''; this.editingMode = 0; // from {1 - browse, 2 - content, 3 - design} this.pageInfo = {editors: [], revisions: {}}; // information about page in "Content Mode" + this.pageInfoUpdateTimer = null; + this.revisionStatusMap = { + 1: 'cms-revision-published', + 2: 'cms-revision-pending', + 0: 'cms-revision-declined' + }; + this._blocks = {}; - this._blockOrder = Array (); + this._blockOrder = []; this.inDrag = false; // don't process mouse over/out events while in drag mode $.extend(this, $settings); - var $template_manager = this; + var $me = this; - $(document).ready( - function() { - $template_manager.searchBlocks(); + $(document).ready(function() { + $me.init(); + }); +} - if (!$template_manager.editingMode) { - return ; - } +TemplateManager.prototype.init = function () { + this.searchBlocks(); - // show special toolbar when in any of 3 browse modes - var $head_frame = getFrame('head'); - var $extra_toolbar = $head_frame.$('div.front-extra-toolbar').clone(); // clone to keep original untouched + if ( !this.editingMode ) { + return; + } - $('a', $extra_toolbar).each( - function() { - // cut from end, because IE7 adds base_href to beginning of href - var $editing_mode = $(this).attr('href'); - $editing_mode = $editing_mode.substr($editing_mode.length - 1, 1); + // show special toolbar when in any of 3 browse modes + var $template_manager = this, + $head_frame = getFrame('head'), + $extra_toolbar = $head_frame.$('div.front-extra-toolbar').clone(); // clone to keep original untouched - $(this).attr('href', $template_manager.browseUrl.replace('#EDITING_MODE#', $editing_mode)); + $('a', $extra_toolbar).each(function () { + // cut from end, because IE7 adds base_href to beginning of href + var $editing_mode = $(this).attr('href'); + $editing_mode = $editing_mode.substr($editing_mode.length - 1, 1); - if ($editing_mode == $template_manager.editingMode) { - $(this).parents('td:first').addClass('button-active').prevAll('td:first').addClass('button-active'); - } - } - ); + $(this).attr('href', $template_manager.browseUrl.replace('#EDITING_MODE#', $editing_mode)); - $head_frame.$('#extra_toolbar').html( $extra_toolbar.html() ); + if ( $editing_mode == $template_manager.editingMode ) { + $(this).parents('td:first').addClass('button-active').prevAll('td:first').addClass('button-active'); + } + }); - var $hover_effect = []; + $head_frame.$('#extra_toolbar').html($extra_toolbar.html()); - if ($template_manager.editingMode > 1) { - // all modes except for "Browse Mode" -// $hover_effect.push('div.cms-section-properties-btn:first'); - } + var $hover_effect = []; - if ($template_manager.editingMode == 2) { - // Content Mode -// $hover_effect.push('div.cms-edit-btn'); -// $hover_effect.push('div.admin-edit-btn'); + if ( $template_manager.editingMode > 1 ) { + // all modes except for "Browse Mode" +// $hover_effect.push('div.cms-section-properties-btn:first'); + } - // make all spans with phrases clickable - $template_manager.setupEditTranslationButtons(document); + if ( $template_manager.editingMode == 2 ) { + // Content Mode +// $hover_effect.push('div.cms-edit-btn'); +// $hover_effect.push('div.admin-edit-btn'); - // hide "Revision History" div on every body click (bubbled), but not a "toolbar button", that opens it - $('body').click( - function ($e) { - var $target = $($e.target), - $id = $target.attr('id'); + // make all spans with phrases clickable + $template_manager.setupEditTranslationButtons(document); - if ( $id && ($id == 'div_history' || $target.parent().attr('id') == 'div_history') ) { - return ; - } + // hide "Revision History" div on every body click (bubbled), but not a "toolbar button", that opens it + $('body').click(function ($e) { + var $target = $($e.target), + $id = $target.attr('id'); - $('#cms-revision-dropdown:visible').hide(); - } - ); + if ( $id && ($id == 'div_history' || $target.parent().attr('id') == 'div_history') ) { + return; } - if ($template_manager.editingMode == 3) { - // Design Mode -// $hover_effect.push('div.cms-save-layout-btn:first, div.cms-cancel-layout-btn:first'); + $('#cms-revision-dropdown:visible').hide(); + }); + } - $template_manager.renumberMovableElements(); + if ( $template_manager.editingMode == 3 ) { + // Design Mode +// $hover_effect.push('div.cms-save-layout-btn:first, div.cms-cancel-layout-btn:first'); - $('div.movable-area').sortable( - { - placeholder: 'move-helper', - handle: '.movable-header', - items: 'div.movable-element', - connectWith: ['div.movable-area'], - tolerance: 'pointer', - start: function(e, ui) { - $template_manager.inDrag = true; - ui.placeholder.height( ui.item.height() ); - }, - stop: function(e, ui) { - $template_manager.inDrag = false; + $template_manager.renumberMovableElements(); - // mouseout doesn't happen while in drag, so compensate it here - var $header = $('.movable-header', ui.item); - $('div.block-edit-block-btn-container', $header).mouseout(); - }, - change: function(e, ui) { - $('div.cms-layout-btn-container').show(); - } - } - ); - } + $('div.movable-area').sortable({ + placeholder: 'move-helper', + handle: '.movable-header', + items: 'div.movable-element', + connectWith: ['div.movable-area'], + tolerance: 'pointer', + start: function (e, ui) { + $template_manager.inDrag = true; + ui.placeholder.height(ui.item.height()); + }, + stop: function (e, ui) { + $template_manager.inDrag = false; - // make requested elements fully visible on mouseover - if ( $hover_effect.length ) { - $($hover_effect.join(', ')) - .mouseover( - function(e) { - $(this).css('opacity', 1); - } - ) - .mouseout( - function(e) { - $(this).css('opacity', 0.5); - } - ); + // mouseout doesn't happen while in drag, so compensate it here + var $header = $('.movable-header', ui.item); + $('div.block-edit-block-btn-container', $header).mouseout(); + }, + change: function (e, ui) { + $('div.cms-layout-btn-container').show(); } + }); + } - // related to content revision control toolbar - if ( $('#cms-revision-toolbar-layer').length == 1 ) { - $template_manager.initRevisionToolbar(); - } - } - ); -} + // make requested elements fully visible on mouseover + if ( $hover_effect.length ) { + $($hover_effect.join(', ')) + .mouseover(function (e) { + $(this).css('opacity', 1); + }) + .mouseout(function (e) { + $(this).css('opacity', 0.5); + }); + } + // related to content revision control toolbar + if ( $template_manager.revisionToolbarEnabled() ) { + $template_manager.initRevisionToolbar(); + } + + $('body') + .bind('InlineEditor.Focus', function ($e, $editor_event) { + $template_manager.inlineEditorFocus($editor_event); + }) + .bind('InlineEditor.Blur', function ($e, $editor_event) { + $template_manager.inlineEditorBlur($editor_event); + }); +}; + +TemplateManager.prototype.revisionToolbarEnabled = function () { + return $('#cms-revision-toolbar-layer').length == 1; +}; + TemplateManager.prototype.initRevisionToolbar = function () { var $template_manager = this; @@ -168,16 +182,16 @@ $e.preventDefault(); }); - $('.toolbar-button', '#cms-revision-toolbar').click(function ($e) { - var $button_name = $(this).attr('id').replace(/^(tool|div)_/, ''); + $('body').on('click', '#cms-revision-dropdown .top .item', function ($e) { + $('a:first', this).click(); - $template_manager.revisionToolbarClick($button_name); + $e.preventDefault(); }); setInterval( function () { $.getJSON( - $('#kf_revisions_' + $template_manager.pageId).attr('action').replace('-d-', '-s-') + '&events[page-revision]=OnGetInfo', + $('#kf_revisions_' + $template_manager.pageId).attr('action') + '&events[page-revision]=OnGetInfo', function ($data) { $template_manager.pageInfo = $data; $template_manager.processPageInfo(); @@ -189,43 +203,76 @@ if ( !$.isEmptyObject($template_manager.pageInfo) ) { $template_manager.processPageInfo(); } -} +}; -TemplateManager.prototype.processPageInfo = function () { - var $class_mapping = { - 1: 'cms-revision-published', - 2: 'cms-revision-pending', - 0: 'cms-revision-declined' - }; +TemplateManager.prototype.requirePageInfoUpdate = function ($now) { + var $me = this; - var $title = $('.revision-title', '#cms-current-revision-info'); + if ( $now === undefined || $now === false ) { + clearTimeout(this.pageInfoUpdateTimer); + this.pageInfoUpdateTimer = setInterval(function () { $me.requirePageInfoUpdate(true); }, 20 * 1000); // 20 seconds - $title.html( this.pageInfo.current_revision.title ); - $('.draft-saved', '#cms-current-revision-info').html( this.pageInfo.current_revision.saved ); - - for (var $status in $class_mapping) { - $title.toggleClass( $class_mapping[$status], $status === this.pageInfo.current_revision.status ); + return; } + $.getJSON( + $('#kf_revisions_' + this.pageId).attr('action').replace('-d-', '-s-') + '&events[page-revision]=OnGetInfo', + function ($data) { + $me.pageInfo = $data; + $me.processPageInfo(); + } + ); +}; + +TemplateManager.prototype.processPageInfo = function () { + this.updateCurrentRevision(); + if ( $('#cms-toggle-revision-toolbar').hasClass('opened') ) { - var $notice = $('#cms-editing-notice'); + this.showEditingNotice(); + } - if ( this.pageInfo.editors.length ) { - if ( $('span:first', $notice).attr('prev_editors') != this.pageInfo.editors.join(',') ) { - // show notice, only when editors change occurs - $('span:first', $notice).html(this.pageInfo.editors_warning).attr('prev_editors', this.pageInfo.editors.join(',')); + this.updateRevisionHistory(); +}; - if ( $notice.is(':hidden') ) { - $notice.fadeIn(); - } +TemplateManager.prototype.updateCurrentRevision = function () { + var $me = this, + $title = $('.revision-title', '#cms-current-revision-info'); + + $title.html(this.pageInfo.current_revision.title); + $('.draft-saved', '#cms-current-revision-info').html(this.pageInfo.current_revision.saved); + + $.each(this.revisionStatusMap, function ($status, $class_name) { + $title.toggleClass($class_name, $status === $me.pageInfo.current_revision.status); + }); + + $.each(this.pageInfo.current_revision.toolbar_state, function ($button_name, $is_enabled) { + a_toolbar.SetEnabled($button_name, $is_enabled); + }); +}; + +TemplateManager.prototype.showEditingNotice = function () { + var $notice = $('#cms-editing-notice'); + + if ( this.pageInfo.editors.length ) { + var $notice_span = $('span:first', $notice); + + if ( $notice_span.data('prev_editors') != this.pageInfo.editors.join(',') ) { + // show notice, only when editors change occurs + $notice_span.html(this.pageInfo.editors_warning).data('prev_editors', this.pageInfo.editors.join(',')); + + if ( $notice.is(':hidden') ) { + $notice.fadeIn(); } } - else if ( $notice.is(':visible') ) { - $notice.fadeOut(); - } } + else if ( $notice.is(':visible') ) { + $notice.fadeOut(); + } +}; - var $revision_container = $('.top', '#cms-revision-dropdown'), +TemplateManager.prototype.updateRevisionHistory = function () { + var $me = this, + $revision_container = $('.top', '#cms-revision-dropdown'), $revision_mask = '
\ {TITLE} ({STATUS_LABEL})\
{DATETIME}
\ @@ -236,49 +283,70 @@ $revision_container.empty(); if ( $.isArray(this.pageInfo.revisions) ) { - // no revisions yet + return; } - else { - for (var $revision in this.pageInfo.revisions) { - var $html = $revision_mask, - $revision_info = this.pageInfo.revisions[$revision]; - for (var $field in $revision_info) { - $html = $html.replace( new RegExp('{' + $field.toUpperCase() + '}', 'g'), $revision_info[$field] ); - } + $.each(this.pageInfo.revisions, function ($revision_number, $revision_info) { + var $html = $revision_mask; - $html = $html.replace(/{CLASS}/g, $class_mapping[$revision_info.status] ); + $.each($revision_info, function ($field, $value) { + $html = $html.replace(new RegExp('{' + $field.toUpperCase() + '}', 'g'), $value); + }); - if ( $revision_info['draft'] ) { - $html = $html.replace(/{LINK}/g, this.browseUrl.replace('#EDITING_MODE#', 2) ); - } - else { - $html = $html.replace(/{LINK}/g, this.browseUrl.replace('#EDITING_MODE#', 2) + '&revision=' + $revision.substr(1) ); - } + $html = $html.replace(/{CLASS}/g, $me.revisionStatusMap[$revision_info.status]); - $revision_container.append($html); + if ( $revision_info['draft'] ) { + $html = $html.replace(/{LINK}/g, $me.browseUrl.replace('#EDITING_MODE#', '2')); } + else { + $html = $html.replace(/{LINK}/g, $me.browseUrl.replace('#EDITING_MODE#', '2') + '&revision=' + $revision_number.substr(1)); + } - $('.item', '#cms-revision-dropdown .top').each( - function () { - var $row = $(this); + $revision_container.append($html); + }); +}; - $('a:first', $row).click( - function ($e) { - $e.stopPropagation(); - } - ); +TemplateManager.prototype.inlineEditorFocus = function ($editor_event) { + var $container = $($editor_event.editor.element.$).parent('.cms-edit-btn-container'); - $row.click( - function ($e) { - window.location.href = $('a:first', this).attr('href'); - } - ); - } - ); + $container.removeClass('mode-inline-edit'); +}; + +TemplateManager.prototype.inlineEditorBlur = function ($editor_event) { + var $me = this, + $element = $($editor_event.editor.element.$), + $container = $element.parent('.cms-edit-btn-container'), + $url_params = {}, + $content_id = $container.data('content-id'); + + if ( $element.data('no_save_on_blur') === true ) { + $element.data('no_save_on_blur', null); + return; } -} + $element.css('position', 'static'); + $container.addClass('mode-inline-saving'); + + $url_params["content[" + $content_id + "][" + this.languagePrefix + "Content]"] = $editor_event.editor.getData(); + + $.post( + this.saveContentUrl, + $url_params, + function ($data) { + if ( $data != 'OK' ) { + return; + } + + if ( $me.revisionToolbarEnabled() ) { + $me.requirePageInfoUpdate(true); + } + + $element.css('position', 'relative'); + $container.removeClass('mode-inline-saving').addClass('mode-inline-edit'); + } + ); +}; + TemplateManager.prototype.revisionToolbarClick = function ($button_name) { // console.log('button ', $button_name, ' clicked'); @@ -293,114 +361,105 @@ $form_name = 'kf_revisions_' + this.pageId; submit_event('page-revision', $button_event_map[$button_name]); - return ; + return; } switch ( $button_name ) { case 'preview': var $url = this.browseUrl.replace('#EDITING_MODE#', 0).replace(/&(admin|editing_mode)=[\d]/g, ''); - window.open( $url + '&preview=1' ); + window.open($url + '&preview=1'); break; case 'history': $('#cms-revision-dropdown').toggle(); break; } -} +}; TemplateManager.prototype.setupEditTranslationButtons = function ($container) { - $("span[name='cms-translate-phrase']", $container).each( - function() { - var $me = $(this); - var $parent_link = $me.parents('a:first'); + $("span[name='cms-translate-phrase']", $container).each(function() { + var $me = $(this), + $parent_link = $me.parents('a:first'); - if ($parent_link.length == 0) { - // span in not inside "a" tag + if ( $parent_link.length == 0 ) { + // span in not inside "a" tag + $me.prepend('
Edit
'); + $('div.cms-edit-btn:first', $me).click(TemplateManager.prototype.translatePhrase); - $me.prepend('
Edit
'); - $('div.cms-edit-btn:first', $me).click(TemplateManager.prototype.translatePhrase); - $me.dblclick( - function ($e) { - $('div.cms-edit-btn:first', this).click(); + $me.dblclick(function ($e) { + $('div.cms-edit-btn:first', this).click(); - $e.preventDefault(); - } - ); + $e.preventDefault(); + }); - var $effect_element = $me; - } - else { - // span is inside "a" tag - var $clone = $me.clone(); - $clone.empty().attr('title', ''); + var $effect_element = $me; + } + else { + // span is inside "a" tag + var $clone = $me.clone(); + $clone.empty().attr('title', ''); - // in case if "a" tag is "display: block", then make "span" the same - $clone.css('display', $parent_link.css('display')); + // in case if "a" tag is "display: block", then make "span" the same + $clone.css('display', $parent_link.css('display')); - $parent_link.html( $me.html() ).wrap($clone); - $parent_link.before('
Edit
'); - $parent_link.prev('div.cms-edit-btn:first').click(TemplateManager.prototype.translatePhrase); + $parent_link.html($me.html()).wrap($clone); + $parent_link.before('
Edit
'); + $parent_link.prev('div.cms-edit-btn:first').click(TemplateManager.prototype.translatePhrase); - var $effect_element = $parent_link.parents("span[name='cms-translate-phrase']:first"); - } - - $effect_element - .mouseover( - function($e) { - $('div.cms-edit-btn', this).css('display', 'inline'); - } - ) - .mouseout( - function($e) { - $('div.cms-edit-btn', this).hide(); - } - ); + var $effect_element = $parent_link.parents("span[name='cms-translate-phrase']:first"); } - ); -} + $effect_element + .mouseover(function($e) { + $('div.cms-edit-btn', this).css('display', 'inline'); + }) + .mouseout(function($e) { + $('div.cms-edit-btn', this).hide(); + }); + }); +}; + TemplateManager.prototype.translatePhrase = function ($e) { var $translate_url = $(this).parents("span[name='cms-translate-phrase']:first").attr('href'); - if ($translate_url.match(/javascript:(.*)/)) { + if ( $translate_url.match(/javascript:(.*)/) ) { eval(RegExp.$1); } else { window.location.href = $translate_url; } $e.preventDefault(); -} +}; TemplateManager.prototype.renumberMovableElements = function () { var $area_index = 0; + // 1. dynamically assign IDs to all movable elements - $('div.movable-area').each( - function() { - var $element_index = 0; - $('div.movable-element', this).each( - function() { - $(this).attr('id', 'target_order_a' + $area_index + 'e' + $element_index); - $element_index++; - } - ); + $('div.movable-area').each(function () { + var $element_index = 0; - $area_index++; - } - ); -} + $('div.movable-element', this).each(function () { + $(this).attr('id', 'target_order_a' + $area_index + 'e' + $element_index); + $element_index++; + }); + $area_index++; + }); +}; + TemplateManager.prototype.saveLayout = function () { // prepare order string var $sort_order = []; - $('div.movable-area').each( - function($area_index) { - var $order = $(this).sortable('serialize').replace(/target_order\[\]/g, 'target_order[' + $area_index + '][]'); - if ($order) { - $sort_order.push($order); - } + + $('div.movable-area').each(function ($area_index) { + var $order = $(this).sortable('serialize').replace(/target_order\[\]/g, 'target_order[' + $area_index + '][]'); + + if ( $order ) { + $sort_order.push($order); } - ); + }); + $sort_order = $sort_order.join('&'); // save order string @@ -412,7 +471,7 @@ onDataReceived: function ($data) { var $message = ''; - if ($data == 'OK') { + if ( $data == 'OK' ) { $message = 'New Layout Saved'; $('div.cms-layout-btn-container').hide(); $me.renumberMovableElements(); @@ -427,13 +486,13 @@ } }; - TB.setWindowTitle( window.top.document.title.replace(main_title + ' :: ', '') ); + TB.setWindowTitle(window.top.document.title.replace(main_title + ' :: ', '')); TB.show($settings); -} +}; TemplateManager.prototype.cancelLayout = function () { window.location.href = window.location.href; -} +}; TemplateManager.prototype.onBtnClick = function ($e, $element) { var $id = $element.id.replace(/_btn$/, ''); @@ -443,20 +502,21 @@ direct_edit('theme-file', $url); $e.stopPropagation(); -} +}; TemplateManager.prototype.onMouseOver = function ($e, $element) { - if (this.inDrag) { - return ; + if ( this.inDrag ) { + return; } $element = $($element); - if ($element.hasClass('block-edit-design-btn-container')) { + if ( $element.hasClass('block-edit-design-btn-container') ) { $($element).addClass('block-edit-design-btn-container-over'); var $button_group = $('div.cms-edit-design-btn-container:first', $element); - if ($button_group.length) { + + if ( $button_group.length ) { $button_group.show(); } else { @@ -469,20 +529,21 @@ } $e.stopPropagation(); -} +}; TemplateManager.prototype.onMouseOut = function ($e, $element) { - if (this.inDrag) { - return ; + if ( this.inDrag ) { + return; } $element = $($element); - if ($element.hasClass('block-edit-design-btn-container')) { + if ( $element.hasClass('block-edit-design-btn-container') ) { $($element).removeClass('block-edit-design-btn-container-over'); var $button_group = $('div.cms-edit-design-btn-container:first', $element); - if ($button_group.length) { + + if ( $button_group.length ) { $button_group.hide(); } else { @@ -495,61 +556,55 @@ } $e.stopPropagation(); -} +}; TemplateManager.prototype.searchBlocks = function () { var $design_containers = $('div.block-edit-design-btn-container'); var $block_containers = $('div.block-edit-block-btn-container'); - $design_containers.each( - function() { - var $block_container = $('div.block-edit-block-btn-container:first', this); + $design_containers.each(function () { + var $block_container = $('div.block-edit-block-btn-container:first', this); - if ($block_container.length) { - $block_containers = $block_containers.not($block_container); + if ( $block_container.length ) { + $block_containers = $block_containers.not($block_container); - // place "Edit Block" button near "Edit Design" button - var $edit_design_btn = $('.cms-edit-design-btn:first', this); - var $edit_block_btn = $('.cms-edit-block-btn:first', $block_container); + // place "Edit Block" button near "Edit Design" button + var $edit_design_btn = $('.cms-edit-design-btn:first', this); + var $edit_block_btn = $('.cms-edit-block-btn:first', $block_container); - $edit_design_btn - .wrap('
') - .before( $edit_block_btn.clone() ); + $edit_design_btn + .wrap('
') + .before($edit_block_btn.clone()); - $edit_block_btn.remove(); + $edit_block_btn.remove(); - // make "hint" from "Edit Block" button container main - $(this).attr('title', $block_container.attr('title')); - $block_container.attr('title', ''); + // make "hint" from "Edit Block" button container main + $(this).attr('title', $block_container.attr('title')); + $block_container.attr('title', ''); - TemplateManager.prototype.registerBlock.call(aTemplateManager, $block_container.get(0), ['hover']); - } - - TemplateManager.prototype.registerBlock.call(aTemplateManager, this, ['dblclick']); + TemplateManager.prototype.registerBlock.call(aTemplateManager, $block_container.get(0), ['hover']); } - ); - $block_containers.each( - function() { - TemplateManager.prototype.registerBlock.call(aTemplateManager, this); - } - ); + TemplateManager.prototype.registerBlock.call(aTemplateManager, this, ['dblclick']); + }); -// $('div').each ( -// function () { -// /*var $id = $(this).attr('id'); -// -// if (!$id || $id.match(/parser_block\[.*\].*_btn$/) || !$id.match(/parser_block\[.*\]/)) { -// // skip other divs -// return true; -// }*/ -// -// -// TemplateManager.prototype.registerBlock.call(aTemplateManager, this); -// } -// ); -} + $block_containers.each(function() { + TemplateManager.prototype.registerBlock.call(aTemplateManager, this); + }); + /*$('div').each (function () { + *//*var $id = $(this).attr('id'); + + if ( !$id || $id.match(/parser_block\[.*\].*_btn$/) || !$id.match(/parser_block\[.*\]/) ) { + // skip other divs + return true; + }*//* + + + TemplateManager.prototype.registerBlock.call(aTemplateManager, this); + });*/ +}; + TemplateManager.prototype.registerBlock = function ($element, $skip_events) { var $params = $element.getAttribute('params').split(':'); @@ -560,38 +615,29 @@ var $btn = document.getElementById($element.id + '_btn'); - $($btn).click( - function(ev) { - TemplateManager.prototype.onBtnClick.call(aTemplateManager, ev, this); - } - ); + $($btn).click(function (ev) { + TemplateManager.prototype.onBtnClick.call(aTemplateManager, ev, this); + }); - if ($skip_events === undefined) { + if ( $skip_events === undefined ) { $skip_events = []; } - if (!in_array('dblclick', $skip_events)) { - $($element) - .dblclick( - function(ev) { - TemplateManager.prototype.onBtnClick.call(aTemplateManager, ev, this); - } - ) + if ( !in_array('dblclick', $skip_events) ) { + $($element).dblclick(function (ev) { + TemplateManager.prototype.onBtnClick.call(aTemplateManager, ev, this); + }); } - if (!in_array('hover', $skip_events)) { + if ( !in_array('hover', $skip_events) ) { $($element) - .mouseover( - function(ev) { - TemplateManager.prototype.onMouseOver.call(aTemplateManager, ev, this); - } - ) - .mouseout( - function(ev) { - TemplateManager.prototype.onMouseOut.call(aTemplateManager, ev, this); - } - ); + .mouseover(function (ev) { + TemplateManager.prototype.onMouseOver.call(aTemplateManager, ev, this); + }) + .mouseout(function (ev) { + TemplateManager.prototype.onMouseOut.call(aTemplateManager, ev, this); + }); } this._blockOrder.push($element.id); -} +};