Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;(function($){
- var defaults = {
- question: "Which is your favourite Javascript library?",
- url: "",
- buttonText: "Answer!",
- categories: ["jQuery", "YUI", "Dojo", "ExtJS", "Zepto"]
- }
- function Nupoll(element,options){
- this.config = $.extend({}, defaults, options);
- this.element = element;
- this.init();
- }
- Nupoll.prototype.init = function(){
- $("<h1/>",{
- text: this.config.question
- }).appendTo(this.element);
- var form = $("<form/>").appendTo(this.element);
- var x, y;
- for (x = 0, y = this.config.categories.length; x < y; x++){
- $("<input/>",{
- type: "radio",
- name: "categories",
- id: this.config.categories[x],
- value: this.config.categories[x]
- }).appendTo(form);
- $("<label/>",{
- text: this.config.categories[x],
- "for" : this.config.categories[x]
- }).appendTo(form);
- }
- $("<button/>",{
- text: this.config.buttonText
- }).appendTo(form);
- }
- $.fn.nupoll = function(options){
- new Nupoll(this.first(),options);
- return this.first;
- };
- }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement