on xenial help sign in
Use ternary operators as suggested by Andrea
commitae2d1a197f238832d64be1b9b7b7c47c4c0d73d3 authorAlbert Astals Cid <albert.astals@canonical.com> dateWed 17 Feb 2016, 15:10 (11 years ago) parent8dad1d7
1 file changed+5−22
plugins/Dash/CardCreator.js+5−22
plugins/Dash/CardCreator.js+5−22
@@ -226,12 +226,7 @@ function kHeaderRowCodeGenerator() {
226226 }\n';
227227 var args = Array.prototype.slice.call(arguments);
228228 var isCardTool = args.shift();
229− var heightCode;
230− if (!isCardTool) {
231− heightCode = "height: root.fixedHeaderHeight; \n";
232− } else {
233− heightCode = "";
234− }
229+ var heightCode = isCardTool ? "" : "height: root.fixedHeaderHeight; \n";
235230 var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(heightCode).arg(args.join(',\n'));
236231 return code;
237232}
@@ -431,11 +426,7 @@ function cardString(template, components, isCardTool) {
431426 enabled: %1; \n\
432427 \n'.arg(templateInteractive);
433428
434− if (!isCardTool) {
435− code = code.arg("property int fixedHeaderHeight: -1; \n");
436− } else {
437− code = code.arg("");
438− }
429+ code = code.arg(isCardTool ? "" : "property int fixedHeaderHeight: -1; \n");
439430
440431 var hasArt = components["art"] && components["art"]["field"] || false;
441432 var hasSummary = components["summary"] || false;
@@ -538,12 +529,7 @@ function cardString(template, components, isCardTool) {
538529 }
539530
540531 if (headerAsOverlay) {
541− var headerHeightCode;
542− if (isCardTool) {
543− headerHeightCode = "headerHeight";
544− } else {
545− headerHeightCode = "root.fixedHeaderHeight";
546− }
532+ var headerHeightCode = isCardTool ? "headerHeight" : "root.fixedHeaderHeight";
547533 code += kOverlayLoaderCode.arg(asynchronous).arg(headerHeightCode);
548534 }
549535
@@ -829,11 +815,8 @@ function cardString(template, components, isCardTool) {
829815 } else {
830816 audioButtonAnchorsFill = 'undefined';
831817 audioButtonWidth = 'height';
832− if (isCardTool) {
833− audioButtonHeight = 'headerHeight + 2 * units.gu(1)';
834− } else {
835− audioButtonHeight = 'root.fixedHeaderHeight + 2 * units.gu(1)';
836− }
818+ audioButtonHeight = isCardTool ? 'headerHeight + 2 * units.gu(1)'
819+ : 'root.fixedHeaderHeight + 2 * units.gu(1)';
837820 }
838821 code += kAudioButtonCode.arg(audioButtonAnchorsFill).arg(audioButtonWidth).arg(audioButtonHeight);
839822 }