source: OKFNAnnotator (for Zope)/annotator_files/lib/widget.js @ 4:6979313586cf

Last change on this file since 4:6979313586cf was 4:6979313586cf, checked in by casties, 12 years ago

new version of annotator.

File size: 2.0 KB
Line 
1// Generated by CoffeeScript 1.3.3
2var __hasProp = {}.hasOwnProperty,
3  __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; };
4
5Annotator.Widget = (function(_super) {
6
7  __extends(Widget, _super);
8
9  Widget.prototype.classes = {
10    hide: 'annotator-hide',
11    invert: {
12      x: 'annotator-invert-x',
13      y: 'annotator-invert-y'
14    }
15  };
16
17  function Widget(element, options) {
18    Widget.__super__.constructor.apply(this, arguments);
19    this.classes = $.extend({}, Annotator.Widget.prototype.classes, this.classes);
20  }
21
22  Widget.prototype.checkOrientation = function() {
23    var current, offset, viewport, widget, window;
24    this.resetOrientation();
25    window = $(util.getGlobal());
26    widget = this.element.children(":first");
27    offset = widget.offset();
28    viewport = {
29      top: window.scrollTop(),
30      right: window.width() + window.scrollLeft()
31    };
32    current = {
33      top: offset.top,
34      right: offset.left + widget.width()
35    };
36    if ((current.top - viewport.top) < 0) {
37      this.invertY();
38    }
39    if ((current.right - viewport.right) > 0) {
40      this.invertX();
41    }
42    return this;
43  };
44
45  Widget.prototype.resetOrientation = function() {
46    this.element.removeClass(this.classes.invert.x).removeClass(this.classes.invert.y);
47    return this;
48  };
49
50  Widget.prototype.invertX = function() {
51    this.element.addClass(this.classes.invert.x);
52    return this;
53  };
54
55  Widget.prototype.invertY = function() {
56    this.element.addClass(this.classes.invert.y);
57    return this;
58  };
59
60  Widget.prototype.isInvertedY = function() {
61    return this.element.hasClass(this.classes.invert.y);
62  };
63
64  Widget.prototype.isInvertedX = function() {
65    return this.element.hasClass(this.classes.invert.x);
66  };
67
68  return Widget;
69
70})(Delegator);
Note: See TracBrowser for help on using the repository browser.