From c0be0e4b128fb9e39e8a263f6f736197592bc8cd Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 13 Mar 2024 15:27:54 +0100 Subject: [PATCH] Remove duplicated code --- www/code/inner.js | 29 +++-------------------------- www/slide/inner.js | 23 +++++++++-------------- 2 files changed, 12 insertions(+), 40 deletions(-) diff --git a/www/code/inner.js b/www/code/inner.js index b556b3f4c..c05251615 100644 --- a/www/code/inner.js +++ b/www/code/inner.js @@ -102,15 +102,7 @@ define([ name: 'authormarks', icon: 'fa-paint-brush', }).hide(); - - var $showAuthorColors = UIElements.createDropdownEntry({ - tag: 'a', - attributes: {'class': 'fa fa-paint-brush ' + $showAuthorColorsButton.attr('class')}, - content: h('span', $showAuthorColorsButton.text()), - action: function () { - $showAuthorColorsButton.click(); - }, - }).hide(); + var $showAuthorColors = UIElements.getEntryFromButton($showAuthorColorsButton).hide(); $showAuthorColors.find('span').addClass('cp-toolbar-name cp-toolbar-drawer-element'); framework._.toolbar.$theme.append($showAuthorColors); markers.setButton($showAuthorColors); @@ -123,14 +115,6 @@ define([ window.print(); framework.feedback('PRINT_CODE'); }); - // var $print = UIElements.createDropdownEntry({ - // tag: 'a', - // attributes: { 'class': $printButton.attr('class') }, - // content: h('span', $printButton.text()), - // action: function () { - // $printButton.click(); - // } - // }); var $print = UIElements.getEntryFromButton($printButton); framework._.toolbar.$drawer.append($print); }; @@ -412,15 +396,8 @@ define([ setButton(!markers.getState()); UI.alert(content); }); - var $cba = UIElements.createDropdownEntry({ - tag: 'a', - attributes: {'class': 'fa fa-paint-brush ' + $cbaButton.attr('class')}, - content: h('span', $cbaButton.text()), - action: function () { - $cbaButton.click(); - }, - }); - framework._.toolbar.$theme.prepend($cba); // Put at the top + var $cba = UIElements.getEntryFromButton($cbaButton); + framework._.toolbar.$theme.prepend($cba); }; var mkFilePicker = function (framework, editor, evModeChange) { diff --git a/www/slide/inner.js b/www/slide/inner.js index 9d50a0bd2..f21836aff 100644 --- a/www/slide/inner.js +++ b/www/slide/inner.js @@ -122,20 +122,15 @@ define([ var mkPrintButton = function (framework, editor, $content, $print) { var $printButton = framework._.sfCommon.createButton('print', true); - // var $print = UIElements.createDropdownEntry({ - // tag: 'a', - // attributes: { 'class': $printButton.attr('class') }, - // content: h('span', $printButton.text()), - // action: function () { - // Slide.update(editor.getValue(), true); - // $print.html($content.html()); - // window.focus(); - // window.print(); - // framework.feedback('PRINT_SLIDES'); - // } - // }); - var $print = UIElements.getEntryFromButton($printButton); - framework._.toolbar.$drawer.append($print); + $printButton.click(function () { + Slide.update(editor.getValue(), true); + $print.html($content.html()); + window.focus(); + window.print(); + framework.feedback('PRINT_SLIDES'); + }); + var $printEntry = UIElements.getEntryFromButton($printButton); + framework._.toolbar.$drawer.append($printEntry); }; // Flag to check if a file from the filepicker is a mediatag for the slides or a background image