function CasinoSlot (options) { options = options || {}; this.el = options.el; this.startButtonImage = options.startButtonImage || ''; this.startButtonOffsetX = options.startButtonOffsetX || 0; this.startButtonOffsetY = options.startButtonOffsetY || 0; this.startButtonWidth = options.startButtonWidth || 90; this.startButtonHeight = options.startButtonHeight || 40; this.slotOffsetX = options.slotOffsetX || 0; this.slotOffsetY = options.slotOffsetY || 0; this.slotBackgroundImage = options.slotBackgroundImage || ''; this.slotWidth = options.slotWidth || 50; this.slotHeight = options.slotHeight || 100; this.slotSpacing = options.slotSpacing || 0; this.loseImage = options.loseImage || ''; this.prize = options.prize || []; this.onStart = options.onStart || new Function; this.onWin = options.onWin || new Function; this.onLose = options.onLose || new Function; this.render() } CasinoSlot.prototype.render = function () { function slotStyle (id) { return { 'position': 'absolute', 'width': this.slotWidth, 'left': this.slotOffsetX + id * (this.slotWidth + this.slotSpacing), 'top': this.slotOffsetY, 'width': this.slotWidth, 'height': this.slotHeight, 'background-image': 'url(' + this.slotBackgroundImage + ')', 'overflow': 'hidden', 'margin': 0, 'padding': 0 }; } function getPrizeList ($slot) { for (var i = -1; i < this.prize.length; i++) { var $prize = $('
'); $prize.css({ 'background-image': ~i ? this.prize[i].image : this.loseImage, 'width': this.slotWidth, 'height': this.slotHeight, 'list-style': 'none' }); $slot.append($prize); } } var $casino = $(this.el); var casinoPosition = $casino.css('position'); $slots = $(''); $slot0 = $('