var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; Annotator.Widget = (function(_super) { __extends(Widget, _super); Widget.prototype.classes = { hide: 'annotator-hide', invert: { x: 'annotator-invert-x', y: 'annotator-invert-y' } }; function Widget(element, options) { Widget.__super__.constructor.apply(this, arguments); this.classes = $.extend({}, Annotator.Widget.prototype.classes, this.classes); } Widget.prototype.checkOrientation = function() { var current, offset, viewport, widget, window; this.resetOrientation(); window = $(util.getGlobal()); widget = this.element.children(":first"); offset = widget.offset(); viewport = { top: window.scrollTop(), right: window.width() + window.scrollLeft() }; current = { top: offset.top, right: offset.left + widget.width() }; if ((current.top - viewport.top) < 0) this.invertY(); if ((current.right - viewport.right) > 0) this.invertX(); return this; }; Widget.prototype.resetOrientation = function() { this.element.removeClass(this.classes.invert.x).removeClass(this.classes.invert.y); return this; }; Widget.prototype.invertX = function() { this.element.addClass(this.classes.invert.x); return this; }; Widget.prototype.invertY = function() { this.element.addClass(this.classes.invert.y); return this; }; Widget.prototype.isInvertedY = function() { return this.element.hasClass(this.classes.invert.y); }; Widget.prototype.isInvertedX = function() { return this.element.hasClass(this.classes.invert.x); }; return Widget; })(Delegator);