- function contain(event, ui) {
- var fix = self.allowedPosition(ui.position);
- console.log("fix: ", fix);
- if (fix !== undefined) {
- return false;
- };
- };
- self.element.draggable({drag: contain});
+ self._initial_mark = null;
+ function clean_initial_mark() {
+ if (self._initial_mark) {
+ self._initial_mark.remove();
+ self._initial_mark = null;
+ }
+ }
+ var initial_hash = window.location.hash;
+ if (initial_hash) {
+ var mk = null,
+ objectPrefix = '#object-',
+ themePrefix = '#theme-';
+ if (initial_hash.substr(0, objectPrefix.length) === objectPrefix) {
+ $("[href=#picture-objects]").trigger('click');
+ } else if (initial_hash.substr(0, themePrefix.length) === themePrefix) {
+ $("[href=#picture-themes]").trigger('click');
+ }
+ mk = $("[href=" + initial_hash + "]").eq(0);
+ self._initial_mark = self.createMark({
+ label: mk.text(),
+ coords: mk.data('coords')
+ });
+ }
+
+
+ self.options.areas_links.hover(function() {
+ clean_initial_mark();
+ $this = $(this);
+ var coords = $this.data("coords");
+ this._picture_mark = self.createMark({
+// label: $this.text(),
+ coords: coords,
+ });
+ }, function() {
+ $(this._picture_mark).remove();
+ this._picture_mark = undefined;
+ }).click(function(ev) {
+ ev.preventDefault();
+ var $mark = self.element.find('.mark').eq(0);
+ var markPos = $mark.offset();
+ markPos = [markPos.left, markPos.top];
+ var markSize = [ $mark.width(), $mark.height() ]
+ var wSize = [ window.innerWidth, window.innerHeight ];
+ window.scrollTo(
+ markPos[0] + markSize[0]/2 - wSize[0]/2,
+ markPos[1] + markSize[1]/2 - wSize[1]/2
+ );
+
+ });
+
+