mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 23:16:52 +08:00
Quick logical shortcut
This commit is contained in:
@ -9,30 +9,29 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
init: function(el) {
|
init: function(el) {
|
||||||
if(el) {
|
if(!el) { return; }
|
||||||
|
|
||||||
// check if we've already created a Toggle instance for this element
|
// check if we've already created a Toggle instance for this element
|
||||||
if(!el.component) {
|
if(!el.component) {
|
||||||
|
|
||||||
// find all the required elements that make up a toggle
|
// find all the required elements that make up a toggle
|
||||||
var opts = {
|
var opts = {
|
||||||
el: el,
|
el: el,
|
||||||
checkbox: el.querySelector("input[type='checkbox']"),
|
checkbox: el.querySelector("input[type='checkbox']"),
|
||||||
track: el.querySelector(".track"),
|
track: el.querySelector(".track"),
|
||||||
handle: el.querySelector(".handle")
|
handle: el.querySelector(".handle")
|
||||||
};
|
};
|
||||||
|
|
||||||
// validate its a well formed toggle with the required pieces
|
// validate its a well formed toggle with the required pieces
|
||||||
if(!opts.checkbox || !opts.track || !opts.handle) return;
|
if(!opts.checkbox || !opts.track || !opts.handle) return;
|
||||||
|
|
||||||
// initialize an instance of a Toggle
|
// initialize an instance of a Toggle
|
||||||
el.component = new ionic.views.Toggle(opts);
|
el.component = new ionic.views.Toggle(opts);
|
||||||
}
|
|
||||||
|
|
||||||
return el.component;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return el.component;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})(ionic);
|
})(ionic);
|
||||||
|
|||||||
Reference in New Issue
Block a user