(function($) { $.anwidget("an.Video", { options: { left: 0, top: 0, width: 400, height: 300, source: "", autoplay: true, position: "absolute" }, _props: ["left", "top", "width", "height", "position", "transform-origin", "transform"], _attrs: ["id", "src", "controls", "autoplay", "loop", "class", "muted", "poster"], getCreateOptions: function() { return $.extend(this.options, { 'id': "video" + _widgetID++ }); }, getCreateString: function() { return "
"; }, getProperties: function() { return this._props; }, attach: function() { if(this._attached) return; this._superApply(arguments); this._$div = $(this._element); this._$this = this._$div.find('video'); this.update(true); }, detach: function() { if(!this._$div) return; this._$div.remove(); this._attached = false; this._$div = null; $(parent).trigger("detached", this.getEventData("detached")); }, getAttributes: function() { return this._attrs; }, show: function() { if(this._$div) this._$div.show(); }, hide: function() { if(this._$div) this._$div.hide(); }, applyAttributes: function($el, force) { this._superApply(arguments); if(!this._options["muted"]) { $el.removeAttr("muted"); } }, update: function(force) { if(!this._$div) return; var updateSize = force || this._dirty["width"] || this._dirty["height"]; this.applyProperties(this._$div, force); this.applyAttributes(this._$this, force); if(updateSize) { // Copy the width and height from parent this._$this.css("width", this._$div.css("width")); this._$this.css("height", this._$div.css("height")); } } }); })(jQuery);