X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcolor%2Fpreview.es6.js;fp=web%2Fcore%2Fmodules%2Fcolor%2Fpreview.es6.js;h=cfc5e76b78d2e12423768c21ddcafab8d1ceef2f;hp=357a62680bc833f02d42b45ac5ae346ec5479c3f;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/modules/color/preview.es6.js b/web/core/modules/color/preview.es6.js index 357a62680..cfc5e76b7 100644 --- a/web/core/modules/color/preview.es6.js +++ b/web/core/modules/color/preview.es6.js @@ -38,34 +38,28 @@ form.find('#text a, #text h2').css('color', form.find('.color-palette input[name="palette[link]"]').val()); function gradientLineColor(i, element) { - for (const k in accum) { - if (accum.hasOwnProperty(k)) { - accum[k] += delta[k]; - } - } + Object.keys(accum || {}).forEach((k) => { + accum[k] += delta[k]; + }); element.style.backgroundColor = farb.pack(accum); } // Set up gradients if there are some. - let color_start; - let color_end; - for (const i in settings.gradients) { - if (settings.gradients.hasOwnProperty(i)) { - color_start = farb.unpack(form.find(`.color-palette input[name="palette[${settings.gradients[i].colors[0]}]"]`).val()); - color_end = farb.unpack(form.find(`.color-palette input[name="palette[${settings.gradients[i].colors[1]}]"]`).val()); - if (color_start && color_end) { - delta = []; - for (const j in color_start) { - if (color_start.hasOwnProperty(j)) { - delta[j] = (color_end[j] - color_start[j]) / (settings.gradients[i].vertical ? height[i] : width[i]); - } - } - accum = color_start; - // Render gradient lines. - form.find(`#gradient-${i} > div`).each(gradientLineColor); - } + let colorStart; + let colorEnd; + Object.keys(settings.gradients || {}).forEach((i) => { + colorStart = farb.unpack(form.find(`.color-palette input[name="palette[${settings.gradients[i].colors[0]}]"]`).val()); + colorEnd = farb.unpack(form.find(`.color-palette input[name="palette[${settings.gradients[i].colors[1]}]"]`).val()); + if (colorStart && colorEnd) { + delta = []; + Object.keys(colorStart || {}).forEach((colorStartKey) => { + delta[colorStartKey] = (colorEnd[colorStartKey] - colorStart[colorStartKey]) / (settings.gradients[i].vertical ? height[i] : width[i]); + }); + accum = colorStart; + // Render gradient lines. + form.find(`#gradient-${i} > div`).each(gradientLineColor); } - } + }); }, }; }(jQuery, Drupal));