From 7a2ef77fa7eef047ea898132322f0436cdf9bfef Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Tue, 1 Oct 2013 21:46:51 -0500 Subject: [PATCH] Quick logical shortcut --- js/ext/simple/toggle.js | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/js/ext/simple/toggle.js b/js/ext/simple/toggle.js index 06fb768126..c5cfbc0895 100644 --- a/js/ext/simple/toggle.js +++ b/js/ext/simple/toggle.js @@ -9,30 +9,29 @@ }, init: function(el) { - if(el) { + if(!el) { return; } - // check if we've already created a Toggle instance for this element - if(!el.component) { + // check if we've already created a Toggle instance for this element + if(!el.component) { - // find all the required elements that make up a toggle - var opts = { - el: el, - checkbox: el.querySelector("input[type='checkbox']"), - track: el.querySelector(".track"), - handle: el.querySelector(".handle") - }; + // find all the required elements that make up a toggle + var opts = { + el: el, + checkbox: el.querySelector("input[type='checkbox']"), + track: el.querySelector(".track"), + handle: el.querySelector(".handle") + }; - // validate its a well formed toggle with the required pieces - if(!opts.checkbox || !opts.track || !opts.handle) return; + // validate its a well formed toggle with the required pieces + if(!opts.checkbox || !opts.track || !opts.handle) return; - // initialize an instance of a Toggle - el.component = new ionic.views.Toggle(opts); - } - - return el.component; + // initialize an instance of a Toggle + el.component = new ionic.views.Toggle(opts); } + + return el.component; } }); -})(ionic); \ No newline at end of file +})(ionic);