Mercurial > hg > OKFNAnnotator
comparison annotator_files/lib/widget.js @ 3:6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
author | casties |
---|---|
date | Thu, 05 Apr 2012 19:37:27 +0200 |
parents | |
children | 6979313586cf |
comparison
equal
deleted
inserted
replaced
2:4c6c8835fc5c | 3:6356e78ccf5c |
---|---|
1 var __hasProp = Object.prototype.hasOwnProperty, | |
2 __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; }; | |
3 | |
4 Annotator.Widget = (function(_super) { | |
5 | |
6 __extends(Widget, _super); | |
7 | |
8 Widget.prototype.classes = { | |
9 hide: 'annotator-hide', | |
10 invert: { | |
11 x: 'annotator-invert-x', | |
12 y: 'annotator-invert-y' | |
13 } | |
14 }; | |
15 | |
16 function Widget(element, options) { | |
17 Widget.__super__.constructor.apply(this, arguments); | |
18 this.classes = $.extend({}, Annotator.Widget.prototype.classes, this.classes); | |
19 } | |
20 | |
21 Widget.prototype.checkOrientation = function() { | |
22 var current, offset, viewport, widget, window; | |
23 this.resetOrientation(); | |
24 window = $(util.getGlobal()); | |
25 widget = this.element.children(":first"); | |
26 offset = widget.offset(); | |
27 viewport = { | |
28 top: window.scrollTop(), | |
29 right: window.width() + window.scrollLeft() | |
30 }; | |
31 current = { | |
32 top: offset.top, | |
33 right: offset.left + widget.width() | |
34 }; | |
35 if ((current.top - viewport.top) < 0) this.invertY(); | |
36 if ((current.right - viewport.right) > 0) this.invertX(); | |
37 return this; | |
38 }; | |
39 | |
40 Widget.prototype.resetOrientation = function() { | |
41 this.element.removeClass(this.classes.invert.x).removeClass(this.classes.invert.y); | |
42 return this; | |
43 }; | |
44 | |
45 Widget.prototype.invertX = function() { | |
46 this.element.addClass(this.classes.invert.x); | |
47 return this; | |
48 }; | |
49 | |
50 Widget.prototype.invertY = function() { | |
51 this.element.addClass(this.classes.invert.y); | |
52 return this; | |
53 }; | |
54 | |
55 Widget.prototype.isInvertedY = function() { | |
56 return this.element.hasClass(this.classes.invert.y); | |
57 }; | |
58 | |
59 Widget.prototype.isInvertedX = function() { | |
60 return this.element.hasClass(this.classes.invert.x); | |
61 }; | |
62 | |
63 return Widget; | |
64 | |
65 })(Delegator); |