<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>portfolio Archives - rweber.net</title>
	<atom:link href="https://www.rweber.net/tag/portfolio/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.rweber.net/tag/portfolio/</link>
	<description>trying to be a mile wide AND a mile deep</description>
	<lastBuildDate>Sun, 20 Jan 2019 03:13:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">37896774</site>	<item>
		<title>Google Analytics: Simple RegExp for Advanced Filtration</title>
		<link>https://www.rweber.net/help-desk/google-analytics-simple-regexp-advanced-filtration/</link>
					<comments>https://www.rweber.net/help-desk/google-analytics-simple-regexp-advanced-filtration/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 14 Aug 2017 12:00:27 +0000</pubDate>
				<category><![CDATA[Analytics]]></category>
		<category><![CDATA[Help Desk]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[regex]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=40115</guid>

					<description><![CDATA[<div><img width="300" height="271" src="https://www.rweber.net/wp-content/uploads/2017/08/Manual_coffee_preperation-300x271.jpg" class="attachment-medium size-medium wp-post-image" alt="Photo by miheco on Flickr, https://www.flickr.com/photos/miheco/8043987177/" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" fetchpriority="high" srcset="https://www.rweber.net/wp-content/uploads/2017/08/Manual_coffee_preperation-300x271.jpg 300w, https://www.rweber.net/wp-content/uploads/2017/08/Manual_coffee_preperation-768x694.jpg 768w, https://www.rweber.net/wp-content/uploads/2017/08/Manual_coffee_preperation.jpg 1024w, https://www.rweber.net/wp-content/uploads/2017/08/Manual_coffee_preperation-150x136.jpg 150w" sizes="(max-width: 300px) 100vw, 300px" /></div>
<p>A non-developer-oriented introduction to regular expressions (abbreviated RegExp or regex) for more flexible filtration in Google Analytics.</p>
<p>The post <a href="https://www.rweber.net/help-desk/google-analytics-simple-regexp-advanced-filtration/">Google Analytics: Simple RegExp for Advanced Filtration</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="271" src="https://www.rweber.net/wp-content/uploads/2017/08/Manual_coffee_preperation-300x271.jpg" class="attachment-medium size-medium wp-post-image" alt="Photo by miheco on Flickr, https://www.flickr.com/photos/miheco/8043987177/" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" srcset="https://www.rweber.net/wp-content/uploads/2017/08/Manual_coffee_preperation-300x271.jpg 300w, https://www.rweber.net/wp-content/uploads/2017/08/Manual_coffee_preperation-768x694.jpg 768w, https://www.rweber.net/wp-content/uploads/2017/08/Manual_coffee_preperation.jpg 1024w, https://www.rweber.net/wp-content/uploads/2017/08/Manual_coffee_preperation-150x136.jpg 150w" sizes="(max-width: 300px) 100vw, 300px" /></div><p>Just a little bit of special syntax for describing patterns can greatly increase the flexibility of your filters in Google Analytics. This post is to give you that bit.</p>
<h2>What are we working with?</h2>
<p>In Google Analytics you can filter using what I&#8217;ll call the <strong>basic filtration box</strong>, that input box with the magnifying glass button above the table of data, and the <strong>advanced filtration area</strong> which opens if you click the &#8220;advanced&#8221; link next to the basic filtration box.</p>
<p>I&#8217;ll assume in this post that we&#8217;re looking at <a href="http://www.revedreams.com/">my craft blog&#8217;s</a> analytics, specifically the Behavior > Site Content > All Pages report, with the default primary dimension of Page.</p>
<p>The basic filtration box will give you generic pattern-matching: typing &#8220;crochet&#8221; will give you all URLs that have &#8220;crochet&#8221; anywhere from the beginning to the end. In the advanced area you can further specify that the URL begin with, exactly match, or end with your search string. In both locations you can use regular expressions.</p>
<p><strong>Regular expressions</strong> are a way to describe a pattern to be matched. In full generality the language is extensive and can express very complex patterns. We don&#8217;t need the full language (and GA doesn&#8217;t support all parts of it anyway), but a little RegExp goes a long way toward easily filtering to the data you&#8217;re interested in.</p>
<h2>Your first batch of syntax</h2>
<p>Regular expressions work by having a collection of <strong>reserved characters</strong>, symbols that hold special meaning in the RegExp context.</p>
<p>The most useful in GA is <code>|</code> (pipe), found above the return key along with backslash. It means &#8220;or.&#8221; For example, I did a series about embroidery on crochet where the introductory post&#8217;s slug is embroider-crochet and the later posts&#8217; slugs begin embroidery-crochet. I can capture both together with<br />
<code>embroider-crochet|embroidery-crochet</code></p>
<p>Portions of a regular expression can be enclosed in parentheses. This does nothing by itself, but can be combined with other operations. Enclosing an &#8220;or&#8221; expression in parentheses lets you make it part of a longer expression. This lets me shorten my previous filter, such as to<br />
<code>(embroidery|embroider)-crochet</code></p>
<p>Since regular expressions are their own singular option in the advanced filters, you have to use RegExp symbols to get &#8220;begins with,&#8221; &#8220;ends with,&#8221; and &#8220;exactly matches&#8221; filters (unless otherwise specified RegExps match like &#8220;contains&#8221;). Preceding your expression with <code>^</code> means &#8220;begins with&#8221; and following your expression with <code>$</code> means &#8220;ends with.&#8221; Using both gives you &#8220;exactly matches.&#8221;</p>
<p>For example, if I filtered by <code>/embroidery</code>, I would get both posts in the embroidery category (they begin with /embroidery) and the posts in the &#8220;embroidery on crochet&#8221; series (which contain /embroidery but begin /crochet). To limit myself to posts in the embroidery category I can filter with <code>^/embroidery</code>. If for some reason I wanted to filter to just the main blog page, which shows up as /, I could filter with <code>^/$</code>.</p>
<h3>Summary</h3>
<p><code>exp1|exp2</code> : matches strings matching exp1 or exp2<br />
<code>^exp1</code> : matches strings beginning with a match to exp1<br />
<code>exp1$</code> : matches strings ending with a match to exp1<br />
<code>(exp1)</code> : allows exp1 to be part of a longer pattern</p>
<h2>Special characters versus ordinary characters</h2>
<p>What if you need to use a reserved character literally? Very few reserved characters would ever appear in a URL, but they could in page titles and elsewhere.</p>
<p>There is a straightforward means to get your regular expression to interpret a character as the ordinary version and not the special RegExp version: precede it with a backslash. This is called <strong>escaping</strong> the character. For example, <code>\(</code> and <code>\)</code> get you literal parentheses.</p>
<p>Characters that need to be escaped are: <code>\ ^ $ . | ? * + ( ) [ {</code></p>
<p>I have a Related Posts plugin on the craft blog that adds query parameters to its links. If I put <code>/?related</code> into the filtration box, it wouldn&#8217;t give me what I was expecting. The ? needs to be escaped: <code>/\?related</code>.</p>
<h3>Cautionary notes</h3>
<p>In the basic filtration box, you always need to escape reserved characters since it assumes you&#8217;ve typed a regular expression by default (though GA is smart enough to interpret a lone or leading ?, say, as a literal character &#8211; meaning in our last example filtering on <code>?related</code> without the / would work just fine).</p>
<p>In the advanced filtration area, the match type drop-down must be set to “Matching RegExp” for the filter to be interpreted as a regular expression. In that case you must escape special characters, but in any other case the backslash will be interpreted literally and break your filter.</p>
<h2>A second batch of syntax</h2>
<p>What&#8217;s above may meet all of your needs. However, you may find situations in which you can&#8217;t quite get where you need to be with pipe, parens, caret and dollar sign, or where filters based on those are cumbersome.</p>
<h3>The wildcard</h3>
<p>A period in a regular expression will match any single character. For example, <code>/page/./</code> will match /page/2/ but not /page/10/. <code>/page/../</code> will match /page/10/ but not /page/2/, unless it happened to actually be /page/2//. Since I know my data doesn&#8217;t include any URLs with double slashes, I can see ultra-deep dives into content by filtering on <code>/page/../</code> to get only pages 10 and up.</p>
<h3>Repeats</h3>
<p>Instead of typing some large number of periods to match a longer string that varies, we can use characters that indicate repetition. This also allows us to match when the varying string does not always have the same length.</p>
<p>Repetition is indicated by one of three &#8220;suffix&#8221; characters: question mark, asterisk, or plus sign. They mean, respectively, 0 or 1 repeat, 0 or more repeats, 1 or more repeats. For an example:<br />
<code>A.?</code> matches A, AB, A5; does not match ABC, AB12<br />
<code>A.*</code> matches A, AB, A5, ABC, AB12<br />
<code>A.+</code> matches AB, A5, ABC, AB12; does not match A<br />
(the lists of strings matched or not matched is representative, not comprehensive)</p>
<p>Going back to the page number example, I&#8217;d like to look at engagement with pages 2 and later of all category archives. I know the URL structure will be /category/[category-name]/page/[number]/, and that the part from &#8220;page&#8221; on doesn&#8217;t exist on the first page.</p>
<p>Basically I need /category/ and /page/ with something in between, so here is my RegExp:<br />
<code>/category/.+/page/</code><br />
.* could be used interchangeably with .+ here, because there won&#8217;t be a match to category//page.</p>
<p>All three modifiers &#8211; ?, +, and * &#8211; can be used on any character, not just the period. This lets us simplify our &#8220;embroidery on crochet&#8221; filter even further. The only different between embroidery-crochet and embroider-crochet is the y, so <code>embroidery?-crochet</code> will match both. It will not match embroiders-crochet, though either <code>embroider.?-crochet</code> or <code>embroider(y|s)?-crochet</code> would match all three.</p>
<h3>Summary</h3>
<p><code>.</code> : matches any single character<br />
<code>?</code> : indicates the part of the pattern preceding it can occur 0 or 1 times<br />
<code>*</code> : indicates the part of the pattern preceding it can occur 0 or more times<br />
<code>+</code> : indicates the part of the pattern preceding it can occur 1 or more times</p>
<h2>One little side note</h2>
<p>All of my regular expressions so far have matched the case of the URLs I was trying to filter down to. By default, though, Google Analytics makes matches in a case-insensitive manner, meaning &#8220;thread&#8221; would match &#8220;Thread&#8221; and &#8220;THREAD&#8221; as well as the all-lowercase version. This generally is a helpful simplification but if capitalization is meaningful for your site, be aware you can&#8217;t filter for it simply by capitalizing in your RegExp.</p>
<h2>The full reference list</h2>
<p>Characters that need to be escaped (preceded with a backslash) to be interpreted literally:<br />
<code>\ ^ $ . | ? * + ( ) [ {</code></p>
<table>
<tr>
<td><code>|</code> </td>
<td>or </td>
<td><code>exp1|exp2</code> matches strings matching <code>exp1</code> or <code>exp2</code></td>
</tr>
<tr>
<td><code>^</code> </td>
<td>beginning </td>
<td><code>^exp1</code> matches strings beginning with a match to <code>exp1</code></td>
</tr>
<tr>
<td><code>$</code> </td>
<td>end </td>
<td><code>exp1$</code> matches strings ending with a match to <code>exp1</code></td>
</tr>
<tr>
<td><code>()</code> </td>
<td>enclosure </td>
<td><code>(exp1)</code> allows <code>exp1</code> to be part of a longer pattern</td>
</tr>
<tr>
<td><code>.</code> </td>
<td>wildcard </td>
<td><code>.</code> matches any single character</td>
</tr>
<tr>
<td><code>?</code> </td>
<td>optional </td>
<td><code>AB?</code> matches A and AB</td>
</tr>
<tr>
<td><code>*</code> </td>
<td>unlimited </td>
<td><code>AB*</code> matches A, AB, ABB, ABBB, ABBBB, &#8230;</td>
</tr>
<tr>
<td><code>+</code> </td>
<td>at least 1 </td>
<td><code>AB+</code> matches AB, ABB, ABBB, ABBBB, &#8230; but not A</td>
</tr>
</table>
<hr>
<p><small>Coffee photo by <a href="https://www.flickr.com/photos/miheco/8043987177/">miheco on Flickr</a>.</small></p>
<p>The post <a href="https://www.rweber.net/help-desk/google-analytics-simple-regexp-advanced-filtration/">Google Analytics: Simple RegExp for Advanced Filtration</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/help-desk/google-analytics-simple-regexp-advanced-filtration/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">40115</post-id>	</item>
		<item>
		<title>Feedable Fish</title>
		<link>https://www.rweber.net/projects/feedable-fish/</link>
					<comments>https://www.rweber.net/projects/feedable-fish/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 16 Jan 2017 13:00:06 +0000</pubDate>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[fishpond]]></category>
		<category><![CDATA[portfolio]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=40023</guid>

					<description><![CDATA[<div><img width="300" height="186" src="https://www.rweber.net/wp-content/uploads/2016/12/feeding-fish-300x186.jpg" class="attachment-medium size-medium wp-post-image" alt="animated fish feeding" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" srcset="https://www.rweber.net/wp-content/uploads/2016/12/feeding-fish-300x186.jpg 300w, https://www.rweber.net/wp-content/uploads/2016/12/feeding-fish-768x476.jpg 768w, https://www.rweber.net/wp-content/uploads/2016/12/feeding-fish-150x93.jpg 150w, https://www.rweber.net/wp-content/uploads/2016/12/feeding-fish.jpg 956w" sizes="(max-width: 300px) 100vw, 300px" /></div>
<p>Feedable fish who are somewhat attracted to your mouse pointer, now here and <a href="https://github.com/ReveWeber/fishpond-experiments">on Github</a>.</p>
<p>The post <a href="https://www.rweber.net/projects/feedable-fish/">Feedable Fish</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="186" src="https://www.rweber.net/wp-content/uploads/2016/12/feeding-fish-300x186.jpg" class="attachment-medium size-medium wp-post-image" alt="animated fish feeding" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/12/feeding-fish-300x186.jpg 300w, https://www.rweber.net/wp-content/uploads/2016/12/feeding-fish-768x476.jpg 768w, https://www.rweber.net/wp-content/uploads/2016/12/feeding-fish-150x93.jpg 150w, https://www.rweber.net/wp-content/uploads/2016/12/feeding-fish.jpg 956w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>More progress on <a href="https://www.rweber.net/web-development/javascript/here-fishy-fishy/">the fishpond</a>! The fish are slightly attracted to the mouse pointer when it&#8217;s inside the canvas, and you can click to feed them, which attracts them more. They also got a tiny upgrade in attractiveness. They&#8217;re still twitchy and awkward but I have various thoughts on how to improve that situation.</p>
<p><canvas id="myCanvas" width="480" height="320" style="background: radial-gradient(#94daff, #dbf3ff); display: block; margin: 0 auto;">[Visit my blog to see the fish in action]</canvas></p>
<p><script src="/wp-content/uploads/2017/01/fishpond2.js"></script></p>
<p>Code for this is <a href="https://github.com/ReveWeber/fishpond-experiments">on Github</a>.</p>
<p>The post <a href="https://www.rweber.net/projects/feedable-fish/">Feedable Fish</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/projects/feedable-fish/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">40023</post-id>	</item>
		<item>
		<title>Return of the Color Scheme Picker</title>
		<link>https://www.rweber.net/toys-and-games/return-color-scheme-picker/</link>
					<comments>https://www.rweber.net/toys-and-games/return-color-scheme-picker/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 11 Jul 2016 12:00:19 +0000</pubDate>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Toys and Games]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[portfolio]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39924</guid>

					<description><![CDATA[<div><img width="204" height="300" src="https://www.rweber.net/wp-content/uploads/2016/07/color-preview-backgrounds-204x300.png" class="attachment-medium size-medium wp-post-image" alt="color scheme picker featuring the new additions" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/07/color-preview-backgrounds-204x300.png 204w, https://www.rweber.net/wp-content/uploads/2016/07/color-preview-backgrounds-768x1127.png 768w, https://www.rweber.net/wp-content/uploads/2016/07/color-preview-backgrounds.png 698w, https://www.rweber.net/wp-content/uploads/2016/07/color-preview-backgrounds-102x150.png 102w" sizes="auto, (max-width: 204px) 100vw, 204px" /></div>
<p>A new edition: now select up to five colors and have them highlighted and previewed below the options grid.</p>
<p>The post <a href="https://www.rweber.net/toys-and-games/return-color-scheme-picker/">Return of the Color Scheme Picker</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="204" height="300" src="https://www.rweber.net/wp-content/uploads/2016/07/color-preview-backgrounds-204x300.png" class="attachment-medium size-medium wp-post-image" alt="color scheme picker featuring the new additions" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/07/color-preview-backgrounds-204x300.png 204w, https://www.rweber.net/wp-content/uploads/2016/07/color-preview-backgrounds-768x1127.png 768w, https://www.rweber.net/wp-content/uploads/2016/07/color-preview-backgrounds.png 698w, https://www.rweber.net/wp-content/uploads/2016/07/color-preview-backgrounds-102x150.png 102w" sizes="auto, (max-width: 204px) 100vw, 204px" /></div><p>I got back to this sooner than I thought &#8211; and good thing, too, since I found a bug dating clear back to my <a href="https://www.rweber.net/web-development/javascript/flattening-color-layers-javascript/">color layer flattener</a> (not accounting for leading zeroes when converting to a hex string is a lot more noticeable once you are doing something with said hex string besides displaying it). You can read about the idea behind this in the <a href="https://www.rweber.net/web-development/javascript/color-scheme-picker-take-1/">previous color scheme picker post</a>.</p>
<p>You can now select up to five colors from the grid of fifteen and have those colors show as the highlight on the corresponding hex code and in boxes below against black and white backgrounds. You can actually select more than five but only the first five (left to right, top to bottom in the grid) will show up below. Have fun!</p>
<div id="csp-container" style="clear:left;" data-path="wp-content/uploads/2016/07">[visit my blog to see the picker in action]</div>
<p><script type="text/javascript" src="/wp-content/uploads/2016/07/jscsp-no-jquery.js"></script></p>
<p>Up-to-date code is available in the <a href="https://github.com/ReveWeber/color-scheme-picker">GitHub repo</a>. Thanks again to <a href="https://github.com/bgrins/spectrum">Brian Grinstead</a> and <a href="https://github.com/davidmerfield/randomColor">David Merfield</a> for the color utilities they&#8217;ve written and made freely available.</p>
<p>The post <a href="https://www.rweber.net/toys-and-games/return-color-scheme-picker/">Return of the Color Scheme Picker</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/toys-and-games/return-color-scheme-picker/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39924</post-id>	</item>
		<item>
		<title>Flattening Color Layers with JavaScript</title>
		<link>https://www.rweber.net/projects/flattening-color-layers-javascript/</link>
					<comments>https://www.rweber.net/projects/flattening-color-layers-javascript/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 16 May 2016 12:00:17 +0000</pubDate>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Toys and Games]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[portfolio]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39671</guid>

					<description><![CDATA[<div><img width="225" height="300" src="https://www.rweber.net/wp-content/uploads/2016/04/rainbow_cake_by_dabbisch-d5gbink-225x300.jpg" class="attachment-medium size-medium wp-post-image" alt="Rainbow Cake (both cake and photo) by Dabbisch on Deviantart [CC BY-NC-ND 3.0]" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/04/rainbow_cake_by_dabbisch-d5gbink-225x300.jpg 225w, https://www.rweber.net/wp-content/uploads/2016/04/rainbow_cake_by_dabbisch-d5gbink.jpg 768w, https://www.rweber.net/wp-content/uploads/2016/04/rainbow_cake_by_dabbisch-d5gbink-112x150.jpg 112w" sizes="auto, (max-width: 225px) 100vw, 225px" /></div>
<p>I wrote a little JavaScript program to calculate the displayed color when up to two translucent layers are displayed on an opaque background. It's a toy, but a fun one!</p>
<p>The post <a href="https://www.rweber.net/projects/flattening-color-layers-javascript/">Flattening Color Layers with JavaScript</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="225" height="300" src="https://www.rweber.net/wp-content/uploads/2016/04/rainbow_cake_by_dabbisch-d5gbink-225x300.jpg" class="attachment-medium size-medium wp-post-image" alt="Rainbow Cake (both cake and photo) by Dabbisch on Deviantart [CC BY-NC-ND 3.0]" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/04/rainbow_cake_by_dabbisch-d5gbink-225x300.jpg 225w, https://www.rweber.net/wp-content/uploads/2016/04/rainbow_cake_by_dabbisch-d5gbink.jpg 768w, https://www.rweber.net/wp-content/uploads/2016/04/rainbow_cake_by_dabbisch-d5gbink-112x150.jpg 112w" sizes="auto, (max-width: 225px) 100vw, 225px" /></div><p>A while ago I was trying to find an appropriate opaque fallback color for a translucent background color. Although after some thought I understand what the method is to calculate such a thing, at the time I just did a search and came across <a href="https://www.viget.com/articles/equating-color-and-transparency">an article by Lance Gutin relating transparency and color for grayscale</a>. I thought I might expand it to full-color, and after little time on the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/">Mozilla Development Network</a> and a lot in <a href="http://stackoverflow.com/">Stack Overflow</a> and <a href="http://brackets.io/">Brackets</a>, I have a little utility for you. You can use it here or <a href="https://github.com/ReveWeber/js-color-layer-flattener">grab it on GitHub.</a></p>
<div id="jsclf-container" data-path="wp-content/uploads/2016/04" style="clear:left;"></div>
<p><script type="text/javascript" src="/wp-content/uploads/2016/04/jsclf.js"></script></p>
<p>Since the arithmetic turned out to be straightforward and my need for this sort of calculation is infrequent, this project turned more into a way to practice non-DOM-manipulation and plain-vanilla JavaScript. My goal was for any valid color specification syntax to be acceptable, and maybe for it to be even more forgiving than that. I found the MDN pages on <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value">the color CSS data type</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions">regular expressions in JavaScript</a> most helpful.</p>
<h3>Mathity Math</h3>
<p>The simplest calculation is on an opaque background, where you take a weighted average of the color values. If the alpha of your overlay color is set to 0.8, to find the red value of the color you see (the composite color), you&#8217;ll calculate <code>0.8*(red value of overlay) + (1 - 0.8)*(red value of background)</code>. Do that for all three color channels and you have the code for the composite color. You can make this calculation for some opacities via the <a href="http://meyerweb.com/eric/tools/color-blend/#:::hex">Color Blender from Eric Meyer</a> (opacity must be a fraction with denominator less than or equal to 11).</p>
<p>When you add translucency as an option for the background the arithmetic increases in length but not really in complexity: <a href="https://www.w3.org/TR/2003/REC-SVG11-20030114/masking.html#SimpleAlphaBlending">the spec for simple alpha blending or compositing</a> (which applies to both SVG and CSS) simply takes a doubly-weighted average, though it does not take the color underneath the background into account.</p>
<p>Here&#8217;s the fully written out calculation, for the red channel:<br />
<code>(composite alpha)*(composite red) = (1 - overlay alpha)*(background alpha)*(background red) + (overlay alpha)*(overlay red)</code><br />
The composite color&#8217;s alpha value will be <code>1 - (1 - overlay alpha)*(1 - background alpha)</code>. If either background or overlay is opaque, the composite will be opaque. If the background is opaque the equation simplifies to the one we had previously; if the overlay is opaque it simplifies to <code>composite red = overlay red</code>.</p>
<p>A translucent background on an opaque bottom layer (the tallest stack I was interested in manipulating) can be dealt with in two steps: average the background and the bottom layer and then average that with the overlay.</p>
<p>Turns out that calculation is the simplest of the bunch, though, and extracting the color information from the assorted kinds of input permitted is much more complicated. I&#8217;ll leave that story to the code itself, though.</p>
<hr>
<p><small>Rainbow Cake (both cake and photo) by <a href="http://dabbisch.deviantart.com/art/Rainbow-Cake-329742128">Dabbisch on Deviantart</a> [<a href="http://creativecommons.org/licenses/by-nc-nd/3.0/">CC BY-NC-ND 3.0</a>].</small></p>
<p>The post <a href="https://www.rweber.net/projects/flattening-color-layers-javascript/">Flattening Color Layers with JavaScript</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/projects/flattening-color-layers-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39671</post-id>	</item>
		<item>
		<title>Learn by doing: the WordPress Customizer</title>
		<link>https://www.rweber.net/javascript/learn-by-doing-wordpress-customizer/</link>
					<comments>https://www.rweber.net/javascript/learn-by-doing-wordpress-customizer/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 14 Mar 2016 12:00:22 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP and MySQL]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Customizer]]></category>
		<category><![CDATA[WordPress theming]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39529</guid>

					<description><![CDATA[<div><img width="300" height="214" src="https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85-300x214.jpg" class="attachment-medium size-medium wp-post-image" alt="Marionettes in a museum by Jürgen Howaldt via Wikimedia Commons" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85-300x214.jpg 300w, https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85-150x107.jpg 150w, https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85.jpg 512w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div>
<p>My experience incorporating the WordPress Customizer into my theme Amalgamation; notes and things to watch out for on both the PHP and the JavaScript sides.</p>
<p>The post <a href="https://www.rweber.net/javascript/learn-by-doing-wordpress-customizer/">Learn by doing: the WordPress Customizer</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="214" src="https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85-300x214.jpg" class="attachment-medium size-medium wp-post-image" alt="Marionettes in a museum by Jürgen Howaldt via Wikimedia Commons" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85-300x214.jpg 300w, https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85-150x107.jpg 150w, https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85.jpg 512w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>After the basics were in place, I started adding to Amalgamation (this site&#8217;s theme) to make it customizable for someone who might want, say, different pages featured in the front page&#8217;s panels. The correct place to put appearance-affecting settings is now the Customizer, which meant a lot of new learning.</p>
<p>It was not without its <s>swearing</s>difficulties, and for a while I had a nice little hack in place (labeled as such) but I got a handle on it and thought I&#8217;d write a bit about the parts that took me while to figure out or were difficult to find information on. This isn&#8217;t intended as a self-contained tutorial; I&#8217;ll follow this post up with a post of resources. <strong>Edit 3/12:</strong> The <a href="https://www.rweber.net/web-development/wordpress/wordpress-customizer-resources/">Customizer resource post</a> is up now.</p>
<h3>Customizer PHP</h3>
<p>In Amalgamation, this is all in <a href="https://github.com/ReveWeber/Amalgamation-WP-theme/blob/master/inc/customizer.php">customizer.php</a>.</p>
<p><a href="http://underscores.me/">Underscores</a> is a good start on the Customizer, especially for mimicking JavaScript syntax, but begins quite light on the PHP side. All it does is implement partial refresh for a few of the built-in settings. I wanted to add a bunch of new settings and also remove the irrelevant defaults, which you can see near the beginning of <code>amalgamation_customize_register()</code>.</p>
<p>There were two things I remember giving me pause when adding settings (<a href="http://pastebin.com/fdNX3AZ6">see code on Pastebin</a>):</p>
<p><script src="//pastebin.com/embed_js/fdNX3AZ6"></script></p>
<p>The first was keeping the pieces straight, including what needed the same name. The setup is a little convoluted; sections and controls are UI entities &#8211; they are about what appears and how in the Customizer pane. Settings are data entities &#8211; they hold the values you use controls within sections to select. That&#8217;s why they don&#8217;t exist within sections like controls do, and why the label and description are set within the control definition. They are, however, tightly coupled to controls, which is why they both get the same label as their first parameter.</p>
<p>The other mild slowdown was not knowing how to define a radio button selection, but hopefully my example makes it clear: in the choices array it is &#8216;setting&#8217;s value&#8217; => &#8216;value&#8217;s description&#8217;.</p>
<p><a id="custom-control"></a>WordPress has a page dropdown included, but I wanted to allow posts as well so I needed a custom control. I began by using a post select dropdown from <a href="https://github.com/paulund/wordpress-theme-customizer-custom-controls">Paul Underwood</a>, but changing the selection didn&#8217;t alert the Customizer that a change had been made &#8211; the Save button remained grayed out. Since I didn&#8217;t need the flexibility of that control I switched to one by <a href="https://github.com/tommusrhodus/">Tom Rhodes</a> that has since disappeared from his GitHub. That one worked, and I&#8217;ve since determined that the key was in the <code>select</code> element having the attribute <code>data-customize-setting-link="&lt;?php echo $this->id; ?&gt;"</code>. When I added that attribute to Paulund&#8217;s code, it worked as desired.</p>
<p>Note that the definition of the custom control needs to be accessible from within the function that&#8217;s adding the custom control. The easiest way to do that is to define it within the function, whether directly or via an include statement.</p>
<p>Using the settings in your theme is easy: <code>get_theme_mod( 'setting_name' );</code> returns (rather than echoes) the value.</p>
<h3>Customizer JavaScript</h3>
<p>This is in two files in Amalgamation: <a href="https://github.com/ReveWeber/Amalgamation-WP-theme/blob/master/js/customizer.js">customizer.js</a> and <a href="https://github.com/ReveWeber/Amalgamation-WP-theme/blob/master/js/customizer-controls.js">customizer-controls.js</a>; the enqueuings are in <a href="https://github.com/ReveWeber/Amalgamation-WP-theme/blob/master/inc/customizer.php">customizer.php</a>.</p>
<p>JavaScript is currently optional for the Customizer but developers are encouraged to use it for essentially all the functionality. I did not (though I intend to at least try it out in the future) but I made good use of JavaScript for dynamic display of controls in the sidebar and for partial refresh in the preview so a small change did not require the whole thing to reload.</p>
<p>The first thing to note is that there are two different actions to hook your script enqueue functions into, depending on whether the script affects the sidebar or the preview pane. The preview is in an iframe so it is effectively a completely separate website; scripts that live in one location can&#8217;t affect elements in the other.</p>
<p>For dynamic controls, the enqueue command is this (<a href="//pastebin.com/1gwtmpjm">view on Pastebin</a>):</p>
<p><script src="//pastebin.com/embed_js/1gwtmpjm"></script></p>
<p>You can code these as you would any other show/hide commands, but I found I needed to enclose them in an extra <code>$(function(){});</code> to delay execution and prevent them being overridden. The necessary ids for your elements will be generated following a standard pattern and are easy to find in the web inspector.</p>
<p>For preview AJAX, the enqueue command is this (<a href="//pastebin.com/hcfEsHLw">view on Pastebin</a>):</p>
<p><script src="//pastebin.com/embed_js/hcfEsHLw"></script></p>
<p>Note that I&#8217;m localizing the script also, as in <a href="https://www.rweber.net/web-development/wordpress/ajax-in-wp-a-simple-example/">my previous post about AJAX in WordPress</a>. This of course is only necessary if you actually plan to make AJAX calls. Within the script you have to follow the pattern</p>
<pre>wp.customize( 'setting_name', function (value) {
    value.bind(function (to) {
        // your css/html change or ajax call
    });
});</pre>
<p>If you leave out value.bind it won&#8217;t work. From what I understand, &#8220;value&#8221; here is the fact of the change, and &#8220;to&#8221; is the result or contents of the change (e.g. the color code, text of the byline, or id of the page you selected from the dropdown). Once you&#8217;re inside you can do whatever you want; it&#8217;s no different from JavaScript written from scratch to enact a change on the page. In particular <a href="https://www.rweber.net/web-development/wordpress/ajax-in-wp-a-simple-example/">AJAX works the same way as in WP at large</a>.</p>
<hr>
<p>There&#8217;s my contribution for now. Stay tuned for the resource post. <strong>Edit 3/21:</strong> <a href="https://www.rweber.net/web-development/wordpress/wordpress-customizer-resources/">My selection of customizer resources</a> is posted now.</p>
<p><small>Marionette photo by Jürgen Howaldt (Own work (selbst erstelltes Foto)) [<a href="http://creativecommons.org/licenses/by-sa/3.0/de/deed.en">CC BY-SA 3.0 de</a>], <a href="https://commons.wikimedia.org/wiki/File%3ATheaterFigurenMuseum_85.jpg">via Wikimedia Commons</a>.</small></p>
<p>The post <a href="https://www.rweber.net/javascript/learn-by-doing-wordpress-customizer/">Learn by doing: the WordPress Customizer</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/javascript/learn-by-doing-wordpress-customizer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39529</post-id>	</item>
		<item>
		<title>Old project, new repo</title>
		<link>https://www.rweber.net/projects/old-project-new-repo/</link>
					<comments>https://www.rweber.net/projects/old-project-new-repo/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 25 Jan 2016 13:00:16 +0000</pubDate>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[portfolio]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39514</guid>

					<description><![CDATA[<div><img width="288" height="300" src="https://www.rweber.net/wp-content/uploads/2016/01/screenshot-288x300.png" class="attachment-medium size-medium wp-post-image" alt="screenshot of storyboard app" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/01/screenshot-288x300.png 288w, https://www.rweber.net/wp-content/uploads/2016/01/screenshot-768x799.png 768w, https://www.rweber.net/wp-content/uploads/2016/01/screenshot-144x150.png 144w, https://www.rweber.net/wp-content/uploads/2016/01/screenshot.png 770w" sizes="auto, (max-width: 288px) 100vw, 288px" /></div>
<p>I've put a tabled work-in-progress on GitHub: a <a href="https://github.com/ReveWeber/storyboardapp">storyboarding collaboration system</a>.</p>
<p>The post <a href="https://www.rweber.net/projects/old-project-new-repo/">Old project, new repo</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="288" height="300" src="https://www.rweber.net/wp-content/uploads/2016/01/screenshot-288x300.png" class="attachment-medium size-medium wp-post-image" alt="screenshot of storyboard app" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/01/screenshot-288x300.png 288w, https://www.rweber.net/wp-content/uploads/2016/01/screenshot-768x799.png 768w, https://www.rweber.net/wp-content/uploads/2016/01/screenshot-144x150.png 144w, https://www.rweber.net/wp-content/uploads/2016/01/screenshot.png 770w" sizes="auto, (max-width: 288px) 100vw, 288px" /></div><p>Early last summer my business partner approached me with a challenge: could I create a program that would allow her to collaborate remotely on a short video storyboard with a client? She&#8217;d done some looking and found nothing to suit her needs. I started in, eager to do some full-stack development, and produced a program that would allow creation of a scene-by-scene storyboard, with form inputs for the various pieces of information and an area in which to sketch (that last using <a href="http://wpaint.websanova.com/">wPaint by Websanova</a>, which draws with the HTML5 Canvas element). New scenes can be inserted and existing scenes can be rearranged, deleted, and collapsed.</p>
<p>It was a marvelous challenge. We started with no system for users; we just hid the whole page behind password access. I subsequently added a user-login system which is functional but incomplete in the sense that the only way for two users to share a storyboard is for the sysadmin to manually add permissions to the database. There is, however, an access locking mechanism to keep people from overwriting each others&#8217; changes repeatedly, and an autosave that updates the session to keep accidental reloads from erasing changes.</p>
<p>Except for the drawing area I built it from scratch, learning PDO, password recovery systems, and JSON along the way. It&#8217;s far from complete and what&#8217;s there could use some refactoring (in particular to get more DRY), but I&#8217;m quite proud of it and glad to be putting it into the world: <a href="https://github.com/ReveWeber/storyboardapp">Storyboard on GitHub</a>.</p>
<p>The post <a href="https://www.rweber.net/projects/old-project-new-repo/">Old project, new repo</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/projects/old-project-new-repo/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39514</post-id>	</item>
		<item>
		<title>Parallax without Plugins</title>
		<link>https://www.rweber.net/css/parallax-without-plugins/</link>
					<comments>https://www.rweber.net/css/parallax-without-plugins/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 16 Nov 2015 14:00:31 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[portfolio]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39226</guid>

					<description><![CDATA[<div><img width="300" height="151" src="https://www.rweber.net/wp-content/uploads/2015/11/race-801940_1280-300x151.jpg" class="attachment-medium size-medium wp-post-image" alt="photo of runners waiting to race down their lanes" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/11/race-801940_1280-300x151.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/11/race-801940_1280.jpg 1024w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div>
<p>We've done some simple parallax on a couple of websites recently, using jQuery but no additional JavaScript libraries. It takes some hand-tweaking - and you have to know your items in advance - but is also much lighter weight than a plugin. Here's how.</p>
<p>The post <a href="https://www.rweber.net/css/parallax-without-plugins/">Parallax without Plugins</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="151" src="https://www.rweber.net/wp-content/uploads/2015/11/race-801940_1280-300x151.jpg" class="attachment-medium size-medium wp-post-image" alt="photo of runners waiting to race down their lanes" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/11/race-801940_1280-300x151.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/11/race-801940_1280.jpg 1024w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>We&#8217;ve done some simple parallax on a couple of websites recently, using jQuery but no additional JavaScript libraries. It takes some hand-tweaking &#8211; and you have to know your items in advance &#8211; but is also much lighter weight than a plugin.</p>
<p>The simplest version is elements scrolling independently of the page and each other, for decorative effect &#8211; so where they are when isn&#8217;t so crucial. Each needs to be fixed position and you&#8217;ll likely want some horizontal placement in the form of margins or left/right values.</p>
<p>In the JavaScript we&#8217;ll manipulate the CSS top value according to the amount we&#8217;ve scrolled the page.</p>
<p><iframe src="http://pastebin.com/embed_iframe.php?i=usqDCxNi" style="border:none;width:100%;height:250px;"></iframe></p>
<p>Bind a function to the scroll event, then within that function calculate how far the page has been scrolled and use it to compute a new top value for each parallaxed element. In this case, starting 800px from the top, the element will scroll one quarter as fast as the page itself. The initial value for top in the CSS should also be 800px, or the element will jump when the page is first scrolled (if you are starting with very large &#8211; i.e. always offscreen &#8211; top values they probably don&#8217;t need to match, but there&#8217;s also no reason not to match them).</p>
<p>By changing the initial value and the multiplier to how much the page has been scrolled, you can get a variety of rates and entry points. Careful of your opacity &#8211; with abstract images, one showing through another can be lovely, but with representative images it may just be weird and distracting.</p>
<h2>Multiple Items with Coordination</h2>
<p>Since using that version of parallax I was called on to create a more complicated version. In this, we&#8217;re scrolling many items separately from the page, but certain subsets of them have to align at points along the way. This made tweaking just starting point and rate of scroll completely impractical &#8211; it would have taken forever. It also made screen height an important consideration.</p>
<p>Algebra to the rescue: All of the parallax in this post is linear; that is, the calculation of the CSS top value from the amount the page has been scrolled is the equation of a line. We can make our choice of linear equation more deliberate with two points on the line and the following equation:<br />
<img decoding="async" src="https://s0.wp.com/latex.php?latex=+y+-+y_1+%3D+%5Cfrac%7By_2+-+y_1%7D%7Bx_2+-+x_1%7D+%28x+-+x_1%29+&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt=" y - y_1 = &#92;frac{y_2 - y_1}{x_2 - x_1} (x - x_1) " class="latex" /><br />
In this case, x is the amount of scroll and y is the top value. What are the two points? I used the point where the element should touch the bottom of the screen and the point when all of a batch of elements should be in their proper relative positions. You can get some complicated arithmetic, but fortunately JavaScript knows how to do that. I ended up with a helper function:</p>
<p><iframe src="http://pastebin.com/embed_iframe.php?i=wbUxmf1y" style="border:none;width:100%;height:262px;"></iframe></p>
<p>Since I had a good number of elements calling this function I expected calculating screen height once and then passing it as a function input was more efficient than calling that jQuery function repeatedly. The function above takes the inputs x<sub>1</sub>, y<sub>1</sub>, x<sub>2</sub>, y<sub>2</sub>, x, and returns y.</p>
<p>There&#8217;s more algebra to determine what the appropriate ending top value should be, dependent of course on number and desired alignment of items. I wanted three rows of items, equally spaced, with margins of 48px above, between, and below. I also wanted them to align that way when the page had been scrolled 1.25 times the screen height &#8211; they were &#8220;page two&#8221; but I needed the breathing room of that extra quarter-screen for the parallax effect.</p>
<p><iframe src="http://pastebin.com/embed_iframe.php?i=fBfvu7e5" style="border:none;width:100%;height:330px;"></iframe></p>
<p>Why not 3/4 screen height on that third item? Because that gave it far too long to get to its final position, and as a result it took forever to disappear off the top of the screen &#8211; long enough to overlap with &#8220;page three,&#8221; the items lined up when we&#8217;d scrolled 2.5 times the screen height. With 7/8 screen height it still lingers, but gets out of the way in time.</p>
<p>The post <a href="https://www.rweber.net/css/parallax-without-plugins/">Parallax without Plugins</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/css/parallax-without-plugins/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39226</post-id>	</item>
		<item>
		<title>Tweaking the simple auto-playing slideshow</title>
		<link>https://www.rweber.net/javascript/tweaking-simple-auto-playing-slideshow/</link>
					<comments>https://www.rweber.net/javascript/tweaking-simple-auto-playing-slideshow/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 10 Aug 2015 12:00:55 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[portfolio]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=38469</guid>

					<description><![CDATA[<div><img width="300" height="206" src="https://www.rweber.net/wp-content/uploads/2015/07/Projecteur_de_diapositives_Prestinox_début_des_années_1960-300x206.jpg" class="attachment-medium size-medium wp-post-image" alt="image of slide projector" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/07/Projecteur_de_diapositives_Prestinox_début_des_années_1960-300x206.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/07/Projecteur_de_diapositives_Prestinox_début_des_années_1960.jpg 752w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div>
<p>Two variations on CSS-Tricks' Simple Auto-Playing Slideshow (jQuery): one to load slideshow content via AJAX, and one to turn each slideshow item into a question-answer pair.</p>
<p>The post <a href="https://www.rweber.net/javascript/tweaking-simple-auto-playing-slideshow/">Tweaking the simple auto-playing slideshow</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="206" src="https://www.rweber.net/wp-content/uploads/2015/07/Projecteur_de_diapositives_Prestinox_début_des_années_1960-300x206.jpg" class="attachment-medium size-medium wp-post-image" alt="image of slide projector" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/07/Projecteur_de_diapositives_Prestinox_début_des_années_1960-300x206.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/07/Projecteur_de_diapositives_Prestinox_début_des_années_1960.jpg 752w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>Ever since I found it probably close to a year ago, I&#8217;ve been a big fan of the <a href="https://css-tricks.com/snippets/jquery/simple-auto-playing-slideshow/">simple auto-playing slideshow on CSS-Tricks</a> (though perhaps surprisingly I have yet to apply it to a Media Library Assistant-generated WordPress gallery). I&#8217;ve tweaked it multiple times to serve different purposes, and thought I&#8217;d share two.</p>
<p>The first tweak is more of a wrapper than a modification. It has two features: it loads the slideshow content via AJAX, and it has a small change to the CSS to smooth the beginning of the slideshow.</p>
<p>I wanted to load the slideshow dynamically so I could turn it off entirely on mobile, without a Very Helpful Browser loading the images in case they were used later, slowing down the site. The page itself had the slideshow as a banner header, and it was collapsed at small sizes, so I used its height as the test in the JavaScript. There was a #slideshow div which had a background image set in CSS (via a class JavaScript removed) in case someone&#8217;s JavaScript was disabled, and the slideshow images were in a separate file as naked HTML (though the file was .php for no particular reason) to be pulled in with jQuery.load(). </p>
<p>As for the CSS, I found that trying to hide all but one image via CSS and have the JavaScript take over from there gave me a herky-jerky first transition. Instead, I hid everything in the CSS and used JavaScript to show the first image just as soon as the images were loaded up.</p>
<p>AJAXified slideshow JavaScript:</p>
<p><iframe src="http://pastebin.com/embed_iframe.php?i=RtXdEw1d" style="border:none;width:100%;height:175px;"></iframe></p>
<p>This and the JavaScript below need to be wrapped in a $(document).ready(function () { &#8230; }); to operate most smoothly.</p>
<p>CSS:</p>
<p><iframe src="http://pastebin.com/embed_iframe.php?i=PGNHEvtc" style="border:none;width:100%;height:250px;"></iframe></p>
<hr>
<p>The second tweak makes it a double slideshow: question and answer. In situ it uses WordPress text widgets, the title for the question and the content for its answer, but you can do it with any paired elements. The code below assumes a div with both class and id slideshow-wrapper, holding divs with class slideshow-item, each holding a pair of divs: .question and .answer. There are two different timeframes. The loop moves from pair to pair, and within it the question appears first, then the answer, they stay put for a while for reading, and then both fade away.</p>
<p>The other change to this one is that there&#8217;s a lone single animation outside the setInterval loop. Your choices without this separate bit are to have both the question and the answer in view immediately upon loading the page, or to wait with blank space for the entire first interval.</p>
<p>Q&#038;A slideshow JavaScript:</p>
<p><iframe src="http://pastebin.com/embed_iframe.php?i=UKTKj68q" style="border:none;width:100%;height:250px;"></iframe></p>
<p>CSS:</p>
<p><iframe src="http://pastebin.com/embed_iframe.php?i=HYYnqgmb" style="border:none;width:100%;height:250px;"></iframe></p>
<p><small><a href="https://commons.wikimedia.org/wiki/File:Projecteur_de_diapositives_Prestinox_d%C3%A9but_des_ann%C3%A9es_1960.jpg">Slide projector image by Jean-Jacques Milan via Wikimedia Commons</a></small></p>
<p>The post <a href="https://www.rweber.net/javascript/tweaking-simple-auto-playing-slideshow/">Tweaking the simple auto-playing slideshow</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/javascript/tweaking-simple-auto-playing-slideshow/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">38469</post-id>	</item>
		<item>
		<title>Conquering scrollbars</title>
		<link>https://www.rweber.net/css/conquering-scrollbars/</link>
					<comments>https://www.rweber.net/css/conquering-scrollbars/#comments</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 06 Jul 2015 12:00:34 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Fancy Fifteen]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[website layout]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=38333</guid>

					<description><![CDATA[<div><img width="300" height="150" src="https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-300x150.png" class="attachment-medium size-medium wp-post-image" alt="image of tangled scroll" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-300x150.png 300w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-768x384.png 768w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-1024x512.png 1024w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-150x75.png 150w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280.png 1280w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div>
<p>So suppose you want to fix the sidebar on a Twenty Fifteen WordPress site, because most of the time it's going to be short enough to fit entirely on the screen. And suppose you don't want the nice wide scrollbar Internet Explorer (even 11) will put down the edge of your sidebar whether or not scrolling is happening or even possible. Let's talk about that.</p>
<p>The post <a href="https://www.rweber.net/css/conquering-scrollbars/">Conquering scrollbars</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="150" src="https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-300x150.png" class="attachment-medium size-medium wp-post-image" alt="image of tangled scroll" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-300x150.png 300w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-768x384.png 768w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-1024x512.png 1024w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-150x75.png 150w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280.png 1280w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>So suppose you want to fix the sidebar on a Twenty Fifteen WordPress site, because most of the time it&#8217;s going to be short enough to fit entirely on the screen. Maybe it&#8217;s not always going to be, or maybe it&#8217;s just a little too long so you want to have it scrollable but not tied to the scrolling of the rest of the page. You can do that. Actually, it&#8217;s pretty easy if you aren&#8217;t concerned with aesthetics: <code>position:fixed; height:100%; overflow:scroll;</code> on the sidebar should cover you. However, Internet Explorer (even 11) will put a nice wide scrollbar down the edge of your sidebar whether or not scrolling is happening or even possible. Here we&#8217;ll talk about making that not happen.</p>
<p>The key is a lightweight jQuery plugin called <a href="http://rocha.la/jQuery-slimScroll/">jQuery-slimScroll</a>. It adds a lovely and styleable scrollbar only as necessary, and allows you to avoid overflow:scroll entirely (which is the source of the IE scrollbar).</p>
<p>In your wp-content/themes/fancyfifteen folder you&#8217;ll need 4 files: functions.php, style.css, aqa-pretty-scrolling.js, and header.php (the scrolling requires adding a wrapper to the sidebar content, which in Twenty Fifteen is in the header file).</p>
<p>As will now be standard, you can get the code for all of my Twenty Fifteen modifications in one big (but separable) <a href="https://github.com/ReveWeber/fancyfifteen">Twenty Fifteen child theme on GitHub</a>.</p>
<p>header.php:<br />
<iframe src="https://pastebin.com/embed_iframe.php?i=H5b9vFFV" style="border:none;width:100%"></iframe></p>
<p>The only thing in header.php that is different is the div with id &#8220;pretty-scroll&#8221;, just inside the div with id &#8220;sidebar&#8221;. Everything else is exactly as in Twenty Fifteen, which is why I haven&#8217;t bothered making this very large.</p>
<p>functions.php:<br />
<iframe src="https://pastebin.com/embed_iframe.php?i=hvTWxVHB" style="border:none;width:100%"></iframe></p>
<p>This is also very standard: enqueue your parent and child stylesheets, then enqueue jQuery-slimScroll and our JavaScript program that makes use of it. These enqueuings could be combined.</p>
<p>style.css:<br />
<iframe src="https://pastebin.com/embed_iframe.php?i=p81eN61a" style="border:none;width:100%;height:400px;"></iframe></p>
<p>This is simple but getting more interesting. The sidebar isn&#8217;t along the side until the screen gets sufficiently large, hence the media query. If a visitor has JavaScript turned off, they will get a fixed sidebar with overflow: scroll, trading an ugly scrollbar for a usable sidebar. Otherwise, the code will tack on the hide-scroll class, erasing the scrollbar. The rest of the styles bring the widgets closer together; if you are not accordion-folding them you may not want them closer, but then again if you&#8217;re not accordioning them what are the odds you have few enough to want to fix your sidebar?</p>
<p>aqa-pretty-scrolling.js:<br />
<iframe src="https://pastebin.com/embed_iframe.php?i=bFQnD8wR" style="border:none;width:100%;height:275px;"></iframe></p>
<p>Finally, we have the little bit of code that sets everything up and activates jQuery-slimScroll. If the sidebar is fixed (this seemed an easier indicator to use than sizes), the sidebar and pretty-scroll div get overflow:hidden on them, and then slimScroll scrolls pretty-scroll within sidebar. If you have trouble with bits of your sidebar not scrolling with the rest, uncomment the line that sets position: relative on pretty-scroll. For a quick and easy style match, set the scrollbar color to one of your site&#8217;s main colors. It will be translucent, so a darker one will likely look better.</p>
<p>There you have it. It took a little while for me to get this set up so there was no scrollbar visible on IE, but now that I have a template I&#8217;ll be using this whenever I have a piece of a page that scrolls independently of the rest of the page.</p>
<p><small>Complicated scroll from <a href="https://pixabay.com/en/ribbon-fancy-banner-scroll-border-32696/">Pixabay</a></small></p>
<p>The post <a href="https://www.rweber.net/css/conquering-scrollbars/">Conquering scrollbars</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/css/conquering-scrollbars/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">38333</post-id>	</item>
		<item>
		<title>Accordion Widgets for Twenty Fifteen</title>
		<link>https://www.rweber.net/css/accordion-widgets-for-twenty-fifteen/</link>
					<comments>https://www.rweber.net/css/accordion-widgets-for-twenty-fifteen/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 29 Jun 2015 12:00:27 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Fancy Fifteen]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=38318</guid>

					<description><![CDATA[<div><img width="275" height="300" src="https://www.rweber.net/wp-content/uploads/2015/06/sparrow-158178_1280-275x300.png" class="attachment-medium size-medium wp-post-image" alt="illustration of sparrow playing accordion" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/06/sparrow-158178_1280-275x300.png 275w, https://www.rweber.net/wp-content/uploads/2015/06/sparrow-158178_1280-768x839.png 768w, https://www.rweber.net/wp-content/uploads/2015/06/sparrow-158178_1280.png 938w, https://www.rweber.net/wp-content/uploads/2015/06/sparrow-158178_1280-137x150.png 137w" sizes="auto, (max-width: 275px) 100vw, 275px" /></div>
<p>Let's accordion the sidebar widgets in Twenty Fifteen to make a fairly short sidebar even shorter - perhaps short enough to fit entirely within the screen and be fixed in place.</p>
<p>The post <a href="https://www.rweber.net/css/accordion-widgets-for-twenty-fifteen/">Accordion Widgets for Twenty Fifteen</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="275" height="300" src="https://www.rweber.net/wp-content/uploads/2015/06/sparrow-158178_1280-275x300.png" class="attachment-medium size-medium wp-post-image" alt="illustration of sparrow playing accordion" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/06/sparrow-158178_1280-275x300.png 275w, https://www.rweber.net/wp-content/uploads/2015/06/sparrow-158178_1280-768x839.png 768w, https://www.rweber.net/wp-content/uploads/2015/06/sparrow-158178_1280.png 938w, https://www.rweber.net/wp-content/uploads/2015/06/sparrow-158178_1280-137x150.png 137w" sizes="auto, (max-width: 275px) 100vw, 275px" /></div><p>More additions to Twenty Fifteen! Why not gather these all together into a single child theme? Well, why not? You can <a href="https://github.com/ReveWeber/fancyfifteen">see it all on GitHub</a>, though I haven&#8217;t yet caught up with myself.</p>
<p>I haven&#8217;t said what we&#8217;re doing yet. So you have a website with Twenty Fifteen, and you don&#8217;t have too much in your sidebar &#8211; the menu, which isn&#8217;t too long, and maybe a few widgets. What if you made the sidebar collapse down nice and short so you could fix it in place? It is wonderfully simple to do.</p>
<p>You&#8217;ll need a folder in your wp-content/themes/ directory called &#8220;fancyfifteen&#8221; to use these files as-is. It will have three files in it: functions.php, aqa-sidebar-accordion.js, and style.css.</p>
<p>functions.php:<br />
<iframe src="https://pastebin.com/embed_iframe.php?i=kneN241L" style="border:none;width:100%;height:350px;"></iframe></p>
<p>There are three chunks of code in functions.php: the first brings in the stylesheets for both Twenty Fifteen and Fancy Fifteen, the second adds HTML to widget titles that we will later use for drop-down/collapse-up arrows, and the third brings in the JavaScript that actually does the accordioning. You can leave out the middle section if you don&#8217;t want the arrows.</p>
<p>aqa-sidebar-accordion.js:<br />
<iframe src="https://pastebin.com/embed_iframe.php?i=eZtm4GWr" style="border:none;width:100%;height:350px;"></iframe></p>
<p>Progressive enhancement! If the site visitor has JavaScript turned off, all widgets will be open. Otherwise they will all close up. The commented-out line would then reopen the first one, provided it has a title; that seemed to be the most efficient way to have the first widget auto-open. The way I wrote this JavaScript, any widget without a title won&#8217;t collapse (ever). You could use that fact to have, say, a search bar that is always visible.</p>
<p><a href="https://github.com/ReveWeber/fancyfifteen/blob/master/style.css">For style.css, visit GitHub.</a> There&#8217;s nothing tremendously interesting there &#8211; it just mimics the built-in support for drop-down submenus. If you decided to leave out the middle chunk of functions.php and forgo arrows, you only need the top comment block of style.css &#8212; but you definitely need that! It&#8217;s got the information WordPress needs to understand the theme and its relationship to Twenty Fifteen.</p>
<p>Next time we&#8217;ll discuss actually fixing the sidebar in place. The trick is to allow scrolling if the contents are longer than the page, but avoid the economy-sized scrollbar Internet Explorer slaps on anything styled overflow:scroll.</p>
<p><small>Accordion-playing bird from <a href="https://pixabay.com/en/sparrow-bird-brown-feather-hat-158178/">Pixabay</a>.</small></p>
<p>The post <a href="https://www.rweber.net/css/accordion-widgets-for-twenty-fifteen/">Accordion Widgets for Twenty Fifteen</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/css/accordion-widgets-for-twenty-fifteen/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">38318</post-id>	</item>
	</channel>
</rss>
