remove renkan management to an other django app (see renkan hg repo)
authorcavaliet
Mon, 21 Jul 2014 16:07:00 +0200
changeset 299 8e00641076e7
parent 298 8234cb238783
child 300 108fd2717177
remove renkan management to an other django app (see renkan hg repo)
.pydevproject
.settings/org.eclipse.core.resources.prefs
src/hdabo/settings.py
src/hdalab/migrations/0012_auto__add_hdalabrenkan.py
src/hdalab/migrations/0012_auto__add_renkan.py
src/hdalab/models/__init__.py
src/hdalab/models/renkan.py
src/hdalab/static/hdalab/lib/FileSaver.js
src/hdalab/static/hdalab/lib/backbone-relational.js
src/hdalab/static/hdalab/lib/backbone.js
src/hdalab/static/hdalab/lib/jquery.mousewheel.min.js
src/hdalab/static/hdalab/lib/paper.js
src/hdalab/static/hdalab/lib/renkan/css/renkan.css
src/hdalab/static/hdalab/lib/renkan/css/renkan.min.css
src/hdalab/static/hdalab/lib/renkan/img/edit.png
src/hdalab/static/hdalab/lib/renkan/img/enlarge.png
src/hdalab/static/hdalab/lib/renkan/img/goto.png
src/hdalab/static/hdalab/lib/renkan/img/image-placeholder.png
src/hdalab/static/hdalab/lib/renkan/img/ldt-point.png
src/hdalab/static/hdalab/lib/renkan/img/ldt-segment.png
src/hdalab/static/hdalab/lib/renkan/img/ldt-tag.png
src/hdalab/static/hdalab/lib/renkan/img/link.png
src/hdalab/static/hdalab/lib/renkan/img/more.png
src/hdalab/static/hdalab/lib/renkan/img/refresh.png
src/hdalab/static/hdalab/lib/renkan/img/remove.png
src/hdalab/static/hdalab/lib/renkan/img/revert.png
src/hdalab/static/hdalab/lib/renkan/img/search-logos.png
src/hdalab/static/hdalab/lib/renkan/img/search.png
src/hdalab/static/hdalab/lib/renkan/img/shrink.png
src/hdalab/static/hdalab/lib/renkan/img/tooltiparrow.png
src/hdalab/static/hdalab/lib/renkan/img/topbarbuttons.png
src/hdalab/static/hdalab/lib/renkan/img/wikipedia.png
src/hdalab/static/hdalab/lib/renkan/img/zoombuttons.png
src/hdalab/static/hdalab/lib/renkan/renkan.js
src/hdalab/static/hdalab/lib/renkan/renkan.min.js
src/hdalab/static/hdalab/lib/renkan/renkan.min.map
src/hdalab/static/hdalab/lib/require.js
src/hdalab/static/hdalab/lib/underscore-min.js
src/hdalab/templates/profile_home.html
src/hdalab/templates/renkan_edit.html
src/hdalab/templates/renkan_view.html
src/hdalab/urls.py
src/hdalab/views/pages.py
src/hdalab/views/profile.py
src/hdalab/views/renkan.py
--- a/.pydevproject	Fri Jul 18 13:29:53 2014 +0200
+++ b/.pydevproject	Mon Jul 21 16:07:00 2014 +0200
@@ -2,9 +2,12 @@
 <?eclipse-pydev version="1.0"?>
 
 <pydev_project>
-<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">hdabo_python</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
 <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
 <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
 <path>/${PROJECT_DIR_NAME}/src</path>
 </pydev_pathproperty>
+<pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH">
+<path>/Users/tc/dev/eclipse_workspace/renkan/server/python/django</path>
+</pydev_pathproperty>
 </pydev_project>
--- a/.settings/org.eclipse.core.resources.prefs	Fri Jul 18 13:29:53 2014 +0200
+++ b/.settings/org.eclipse.core.resources.prefs	Mon Jul 21 16:07:00 2014 +0200
@@ -42,6 +42,7 @@
 encoding//src/hdalab/migrations/0006_dbpedia_fields_one_to_one.py=utf-8
 encoding//src/hdalab/migrations/0007_geographic_inclusion.py=utf-8
 encoding//src/hdalab/migrations/0008_datasheet_insee.py=utf-8
+encoding//src/hdalab/migrations/0012_auto__add_hdalabrenkan.py=utf-8
 encoding//src/hdalab/models/dataviz.py=utf-8
 encoding//src/hdalab/settings.py=utf-8
 encoding//src/hdalab/urls.py=utf-8
@@ -49,6 +50,5 @@
 encoding//src/hdalab/views/ajax.py=utf-8
 encoding//src/hdalab/views/pages.py=utf-8
 encoding//src/hdalab/views/profile.py=utf-8
-encoding//src/hdalab/views/renkan.py=utf-8
 encoding//web/hdalab/config.py=utf-8
 encoding//web/hdalab/management/commands/fill_country_codes.py=utf-8
--- a/src/hdabo/settings.py	Fri Jul 18 13:29:53 2014 +0200
+++ b/src/hdabo/settings.py	Mon Jul 21 16:07:00 2014 +0200
@@ -131,6 +131,7 @@
     'registration',
     'haystack',
     'hdalab',
+    'renkanmanager',
     'easy_thumbnails',
 )
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdalab/migrations/0012_auto__add_hdalabrenkan.py	Mon Jul 21 16:07:00 2014 +0200
@@ -0,0 +1,324 @@
+# -*- coding: utf-8 -*-
+from south.utils import datetime_utils as datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        # Adding model 'HdalabRenkan'
+        db.create_table(u'hdalab_hdalabrenkan', (
+            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('renkan', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['renkanmanager.Renkan'])),
+            ('state', self.gf('django.db.models.fields.IntegerField')(default=1)),
+        ))
+        db.send_create_signal('hdalab', ['HdalabRenkan'])
+
+
+    def backwards(self, orm):
+        # Deleting model 'HdalabRenkan'
+        db.delete_table(u'hdalab_hdalabrenkan')
+
+
+    models = {
+        u'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        u'auth.permission': {
+            'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        u'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        u'hdabo.author': {
+            'Meta': {'object_name': 'Author'},
+            'firstname': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}),
+            'hda_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'lastname': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'})
+        },
+        u'hdabo.datasheet': {
+            'Meta': {'object_name': 'Datasheet'},
+            'author': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Author']", 'null': 'True', 'blank': 'True'}),
+            'college_periods': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'college_periods_datasheets'", 'symmetrical': 'False', 'through': u"orm['hdabo.Datasheet_college_periods']", 'to': u"orm['hdabo.TimePeriod']"}),
+            'college_themes': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'college_themes_datasheets'", 'symmetrical': 'False', 'through': u"orm['hdabo.Datasheet_college_themes']", 'to': u"orm['hdabo.Domain']"}),
+            'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'domains': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'datasheets'", 'symmetrical': 'False', 'through': u"orm['hdabo.Datasheet_domains']", 'to': u"orm['hdabo.Domain']"}),
+            'format': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.DocumentFormat']", 'null': 'True', 'blank': 'True'}),
+            'hda_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512'}),
+            'highschool_periods': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'highschool_periods_datasheets'", 'symmetrical': 'False', 'through': u"orm['hdabo.Datasheet_highschool_periods']", 'to': u"orm['hdabo.TimePeriod']"}),
+            'highschool_themes': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'highschool_themes_datasheets'", 'symmetrical': 'False', 'through': u"orm['hdabo.Datasheet_highschool_themes']", 'to': u"orm['hdabo.Domain']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'manual_order': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'modification_datetime': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'organisation': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Organisation']", 'null': 'True'}),
+            'original_creation_date': ('django.db.models.fields.DateField', [], {}),
+            'original_modification_date': ('django.db.models.fields.DateField', [], {}),
+            'primary_periods': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'primary_periods_datasheets'", 'symmetrical': 'False', 'through': u"orm['hdabo.Datasheet_primary_periods']", 'to': u"orm['hdabo.TimePeriod']"}),
+            'primary_themes': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'primary_themes_datasheets'", 'symmetrical': 'False', 'through': u"orm['hdabo.Datasheet_primary_themes']", 'to': u"orm['hdabo.Domain']"}),
+            'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['hdabo.Tag']", 'through': u"orm['hdabo.TaggedSheet']", 'symmetrical': 'False'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '2048'}),
+            'town': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Location']", 'null': 'True', 'blank': 'True'}),
+            'url': ('django.db.models.fields.URLField', [], {'max_length': '2048', 'null': 'True', 'blank': 'True'}),
+            'validated': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'validation_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+            'validator': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.User']", 'null': 'True', 'blank': 'True'})
+        },
+        u'hdabo.datasheet_college_periods': {
+            'Meta': {'ordering': "['sort_value']", 'object_name': 'Datasheet_college_periods'},
+            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'sort_value': ('django.db.models.fields.IntegerField', [], {}),
+            'timeperiod': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.TimePeriod']"})
+        },
+        u'hdabo.datasheet_college_themes': {
+            'Meta': {'ordering': "['sort_value']", 'object_name': 'Datasheet_college_themes'},
+            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
+            'domain': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Domain']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'sort_value': ('django.db.models.fields.IntegerField', [], {})
+        },
+        u'hdabo.datasheet_domains': {
+            'Meta': {'ordering': "['sort_value']", 'object_name': 'Datasheet_domains'},
+            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
+            'domain': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Domain']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'sort_value': ('django.db.models.fields.IntegerField', [], {})
+        },
+        u'hdabo.datasheet_highschool_periods': {
+            'Meta': {'ordering': "['sort_value']", 'object_name': 'Datasheet_highschool_periods'},
+            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'sort_value': ('django.db.models.fields.IntegerField', [], {}),
+            'timeperiod': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.TimePeriod']"})
+        },
+        u'hdabo.datasheet_highschool_themes': {
+            'Meta': {'ordering': "['sort_value']", 'object_name': 'Datasheet_highschool_themes'},
+            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
+            'domain': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Domain']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'sort_value': ('django.db.models.fields.IntegerField', [], {})
+        },
+        u'hdabo.datasheet_primary_periods': {
+            'Meta': {'ordering': "['sort_value']", 'object_name': 'Datasheet_primary_periods'},
+            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'sort_value': ('django.db.models.fields.IntegerField', [], {}),
+            'timeperiod': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.TimePeriod']"})
+        },
+        u'hdabo.datasheet_primary_themes': {
+            'Meta': {'ordering': "['sort_value']", 'object_name': 'Datasheet_primary_themes'},
+            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
+            'domain': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Domain']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'sort_value': ('django.db.models.fields.IntegerField', [], {})
+        },
+        u'hdabo.documentformat': {
+            'Meta': {'object_name': 'DocumentFormat'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512'})
+        },
+        u'hdabo.domain': {
+            'Meta': {'unique_together': "(('label', 'school_period'),)", 'object_name': 'Domain'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
+            'school_period': ('django.db.models.fields.IntegerField', [], {})
+        },
+        u'hdabo.location': {
+            'Meta': {'object_name': 'Location'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'insee': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '5'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '512'})
+        },
+        u'hdabo.organisation': {
+            'Meta': {'object_name': 'Organisation'},
+            'hda_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'location': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
+            'website': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'null': 'True', 'blank': 'True'})
+        },
+        u'hdabo.tag': {
+            'Meta': {'unique_together': "(('label', 'original_label', 'url_status'),)", 'object_name': 'Tag'},
+            'alias': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+            'alternative_label': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+            'alternative_wikipedia_pageid': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
+            'alternative_wikipedia_url': ('django.db.models.fields.URLField', [], {'db_index': 'True', 'max_length': '2048', 'null': 'True', 'blank': 'True'}),
+            'category': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.TagCategory']", 'null': 'True', 'blank': 'True'}),
+            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'dbpedia_uri': ('django.db.models.fields.URLField', [], {'db_index': 'True', 'max_length': '2048', 'null': 'True', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'db_index': 'True'}),
+            'normalized_label': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'db_index': 'True'}),
+            'original_label': ('django.db.models.fields.CharField', [], {'max_length': '1024'}),
+            'popularity': ('django.db.models.fields.IntegerField', [], {'default': '0', 'db_index': 'True'}),
+            'url_status': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True', 'db_index': 'True', 'blank': 'True'}),
+            'wikipedia_pageid': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
+            'wikipedia_url': ('django.db.models.fields.URLField', [], {'db_index': 'True', 'max_length': '2048', 'null': 'True', 'blank': 'True'})
+        },
+        u'hdabo.tagcategory': {
+            'Meta': {'object_name': 'TagCategory'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512'})
+        },
+        u'hdabo.taggedsheet': {
+            'Meta': {'object_name': 'TaggedSheet'},
+            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'index_note': ('django.db.models.fields.FloatField', [], {'default': '0.0', 'db_index': 'True'}),
+            'order': ('django.db.models.fields.IntegerField', [], {'default': '0', 'db_index': 'True'}),
+            'original_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'tag': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Tag']"}),
+            'wikipedia_revision_id': ('django.db.models.fields.BigIntegerField', [], {'null': 'True', 'blank': 'True'})
+        },
+        u'hdabo.timeperiod': {
+            'Meta': {'unique_together': "(('label', 'school_period'),)", 'object_name': 'TimePeriod'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
+            'school_period': ('django.db.models.fields.IntegerField', [], {})
+        },
+        u'hdabo.user': {
+            'Meta': {'object_name': 'User', 'db_table': "'auth_user'"},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'hdalab.country': {
+            'Meta': {'object_name': 'Country'},
+            'dbpedia_uri': ('django.db.models.fields.URLField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
+        },
+        'hdalab.datasheetextras': {
+            'Meta': {'object_name': 'DatasheetExtras'},
+            'datasheet': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'extras'", 'unique': 'True', 'to': u"orm['hdabo.Datasheet']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'insee': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['hdalab.InseeCoords']", 'null': 'True', 'blank': 'True'})
+        },
+        'hdalab.dbpediafields': {
+            'Meta': {'object_name': 'DbpediaFields'},
+            'abstract': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'dbpedia_uri': ('django.db.models.fields.URLField', [], {'max_length': '2048', 'db_index': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'null': 'True', 'blank': 'True'}),
+            'tag': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'dbpedia_fields'", 'unique': 'True', 'null': 'True', 'to': u"orm['hdabo.Tag']"}),
+            'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '2048', 'null': 'True', 'blank': 'True'})
+        },
+        'hdalab.dbpediafieldstranslation': {
+            'Meta': {'unique_together': "(('master', 'language_code'),)", 'object_name': 'DbpediaFieldsTranslation'},
+            'abstract': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_abstract_translated': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_label_translated': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'blank': 'True'}),
+            'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
+            'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'to': "orm['hdalab.DbpediaFields']"})
+        },
+        'hdalab.geoinclusion': {
+            'Meta': {'object_name': 'GeoInclusion'},
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'includes'", 'to': "orm['hdalab.Country']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'tag': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'locatedin'", 'unique': 'True', 'to': u"orm['hdabo.Tag']"})
+        },
+        'hdalab.hdalabrenkan': {
+            'Meta': {'object_name': 'HdalabRenkan'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'renkan': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['renkanmanager.Renkan']"}),
+            'state': ('django.db.models.fields.IntegerField', [], {'default': '1'})
+        },
+        'hdalab.hdasession': {
+            'Meta': {'object_name': 'HdaSession'},
+            'data': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'sessionid': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '36', 'db_index': 'True'})
+        },
+        'hdalab.infoboxparameter': {
+            'Meta': {'unique_together': "(('tag_infobox', 'param_name'),)", 'object_name': 'InfoboxParameter'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'param_name': ('django.db.models.fields.CharField', [], {'max_length': '2048'}),
+            'param_value': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'tag_infobox': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['hdalab.TagInfobox']"})
+        },
+        'hdalab.inseecoords': {
+            'Meta': {'object_name': 'InseeCoords'},
+            'city_name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'insee': ('django.db.models.fields.IntegerField', [], {'primary_key': 'True'}),
+            'latitude': ('django.db.models.fields.FloatField', [], {}),
+            'longitude': ('django.db.models.fields.FloatField', [], {})
+        },
+        'hdalab.taginfobox': {
+            'Meta': {'unique_together': "(('tag', 'name', 'revision_id'),)", 'object_name': 'TagInfobox'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '2048'}),
+            'revision_id': ('django.db.models.fields.BigIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'source': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'infoboxes'", 'to': u"orm['hdabo.Tag']"})
+        },
+        'hdalab.taglinks': {
+            'Meta': {'object_name': 'TagLinks'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'object': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'taglinks_objects'", 'to': u"orm['hdabo.Tag']"}),
+            'subject': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'taglinks_subjects'", 'to': u"orm['hdabo.Tag']"})
+        },
+        'hdalab.tagwpcategory': {
+            'Meta': {'unique_together': "(('tag', 'wp_category', 'hidden'),)", 'object_name': 'TagWpCategory'},
+            'hidden': ('django.db.models.fields.BooleanField', [], {}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'wp_categories'", 'to': u"orm['hdabo.Tag']"}),
+            'wp_category': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tags'", 'to': "orm['hdalab.WpCategory']"})
+        },
+        'hdalab.tagyears': {
+            'Meta': {'object_name': 'TagYears'},
+            'end_year': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'start_year': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
+            'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'years'", 'to': u"orm['hdabo.Tag']"})
+        },
+        'hdalab.wpcategory': {
+            'Meta': {'object_name': 'WpCategory'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '2048'})
+        },
+        'hdalab.wpcategoryinclusion': {
+            'Meta': {'unique_together': "(('parent_category', 'child_category'),)", 'object_name': 'WpCategoryInclusion'},
+            'child_category': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'parent_categories'", 'to': "orm['hdalab.WpCategory']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'parent_category': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'child_categories'", 'to': "orm['hdalab.WpCategory']"})
+        },
+        'renkanmanager.renkan': {
+            'Meta': {'object_name': 'Renkan'},
+            'content': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'image': ('django.db.models.fields.files.ImageField', [], {'default': "'thumbnails/renkan/renkan_default_icon.png'", 'max_length': '100'}),
+            'modification_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.User']", 'null': 'True', 'blank': 'True'}),
+            'rk_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '1024'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True'})
+        }
+    }
+
+    complete_apps = ['hdalab']
\ No newline at end of file
--- a/src/hdalab/migrations/0012_auto__add_renkan.py	Fri Jul 18 13:29:53 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,325 +0,0 @@
-# -*- coding: utf-8 -*-
-from south.utils import datetime_utils as datetime
-from south.db import db
-from south.v2 import SchemaMigration
-from django.db import models
-
-
-class Migration(SchemaMigration):
-
-    def forwards(self, orm):
-        # Adding model 'Renkan'
-        db.create_table(u'hdalab_renkan', (
-            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
-            ('owner', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['hdabo.User'])),
-            ('rk_id', self.gf('django.db.models.fields.CharField')(unique=True, max_length=1024)),
-            ('content', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
-            ('title', self.gf('django.db.models.fields.CharField')(max_length=1024, null=True)),
-            ('state', self.gf('django.db.models.fields.IntegerField')(default=1)),
-            ('image', self.gf('django.db.models.fields.files.ImageField')(default='thumbnails/renkan/renkan_default_icon.png', max_length=100)),
-            ('creation_date', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
-            ('modification_date', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
-        ))
-        db.send_create_signal('hdalab', ['Renkan'])
-
-
-    def backwards(self, orm):
-        # Deleting model 'Renkan'
-        db.delete_table(u'hdalab_renkan')
-
-
-    models = {
-        u'auth.group': {
-            'Meta': {'object_name': 'Group'},
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
-            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
-        },
-        u'auth.permission': {
-            'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
-            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
-            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
-        },
-        u'contenttypes.contenttype': {
-            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
-            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
-            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
-        },
-        u'hdabo.author': {
-            'Meta': {'object_name': 'Author'},
-            'firstname': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}),
-            'hda_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512'}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'lastname': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'})
-        },
-        u'hdabo.datasheet': {
-            'Meta': {'object_name': 'Datasheet'},
-            'author': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Author']", 'null': 'True', 'blank': 'True'}),
-            'college_periods': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'college_periods_datasheets'", 'symmetrical': 'False', 'through': u"orm['hdabo.Datasheet_college_periods']", 'to': u"orm['hdabo.TimePeriod']"}),
-            'college_themes': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'college_themes_datasheets'", 'symmetrical': 'False', 'through': u"orm['hdabo.Datasheet_college_themes']", 'to': u"orm['hdabo.Domain']"}),
-            'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
-            'domains': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'datasheets'", 'symmetrical': 'False', 'through': u"orm['hdabo.Datasheet_domains']", 'to': u"orm['hdabo.Domain']"}),
-            'format': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.DocumentFormat']", 'null': 'True', 'blank': 'True'}),
-            'hda_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512'}),
-            'highschool_periods': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'highschool_periods_datasheets'", 'symmetrical': 'False', 'through': u"orm['hdabo.Datasheet_highschool_periods']", 'to': u"orm['hdabo.TimePeriod']"}),
-            'highschool_themes': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'highschool_themes_datasheets'", 'symmetrical': 'False', 'through': u"orm['hdabo.Datasheet_highschool_themes']", 'to': u"orm['hdabo.Domain']"}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'manual_order': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
-            'modification_datetime': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
-            'organisation': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Organisation']", 'null': 'True'}),
-            'original_creation_date': ('django.db.models.fields.DateField', [], {}),
-            'original_modification_date': ('django.db.models.fields.DateField', [], {}),
-            'primary_periods': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'primary_periods_datasheets'", 'symmetrical': 'False', 'through': u"orm['hdabo.Datasheet_primary_periods']", 'to': u"orm['hdabo.TimePeriod']"}),
-            'primary_themes': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'primary_themes_datasheets'", 'symmetrical': 'False', 'through': u"orm['hdabo.Datasheet_primary_themes']", 'to': u"orm['hdabo.Domain']"}),
-            'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['hdabo.Tag']", 'through': u"orm['hdabo.TaggedSheet']", 'symmetrical': 'False'}),
-            'title': ('django.db.models.fields.CharField', [], {'max_length': '2048'}),
-            'town': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Location']", 'null': 'True', 'blank': 'True'}),
-            'url': ('django.db.models.fields.URLField', [], {'max_length': '2048', 'null': 'True', 'blank': 'True'}),
-            'validated': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
-            'validation_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
-            'validator': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.User']", 'null': 'True', 'blank': 'True'})
-        },
-        u'hdabo.datasheet_college_periods': {
-            'Meta': {'ordering': "['sort_value']", 'object_name': 'Datasheet_college_periods'},
-            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'sort_value': ('django.db.models.fields.IntegerField', [], {}),
-            'timeperiod': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.TimePeriod']"})
-        },
-        u'hdabo.datasheet_college_themes': {
-            'Meta': {'ordering': "['sort_value']", 'object_name': 'Datasheet_college_themes'},
-            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
-            'domain': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Domain']"}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'sort_value': ('django.db.models.fields.IntegerField', [], {})
-        },
-        u'hdabo.datasheet_domains': {
-            'Meta': {'ordering': "['sort_value']", 'object_name': 'Datasheet_domains'},
-            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
-            'domain': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Domain']"}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'sort_value': ('django.db.models.fields.IntegerField', [], {})
-        },
-        u'hdabo.datasheet_highschool_periods': {
-            'Meta': {'ordering': "['sort_value']", 'object_name': 'Datasheet_highschool_periods'},
-            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'sort_value': ('django.db.models.fields.IntegerField', [], {}),
-            'timeperiod': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.TimePeriod']"})
-        },
-        u'hdabo.datasheet_highschool_themes': {
-            'Meta': {'ordering': "['sort_value']", 'object_name': 'Datasheet_highschool_themes'},
-            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
-            'domain': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Domain']"}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'sort_value': ('django.db.models.fields.IntegerField', [], {})
-        },
-        u'hdabo.datasheet_primary_periods': {
-            'Meta': {'ordering': "['sort_value']", 'object_name': 'Datasheet_primary_periods'},
-            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'sort_value': ('django.db.models.fields.IntegerField', [], {}),
-            'timeperiod': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.TimePeriod']"})
-        },
-        u'hdabo.datasheet_primary_themes': {
-            'Meta': {'ordering': "['sort_value']", 'object_name': 'Datasheet_primary_themes'},
-            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
-            'domain': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Domain']"}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'sort_value': ('django.db.models.fields.IntegerField', [], {})
-        },
-        u'hdabo.documentformat': {
-            'Meta': {'object_name': 'DocumentFormat'},
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512'})
-        },
-        u'hdabo.domain': {
-            'Meta': {'unique_together': "(('label', 'school_period'),)", 'object_name': 'Domain'},
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'label': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
-            'school_period': ('django.db.models.fields.IntegerField', [], {})
-        },
-        u'hdabo.location': {
-            'Meta': {'object_name': 'Location'},
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'insee': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '5'}),
-            'name': ('django.db.models.fields.CharField', [], {'max_length': '512'})
-        },
-        u'hdabo.organisation': {
-            'Meta': {'object_name': 'Organisation'},
-            'hda_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512'}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'location': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}),
-            'name': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
-            'website': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'null': 'True', 'blank': 'True'})
-        },
-        u'hdabo.tag': {
-            'Meta': {'unique_together': "(('label', 'original_label', 'url_status'),)", 'object_name': 'Tag'},
-            'alias': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
-            'alternative_label': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
-            'alternative_wikipedia_pageid': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
-            'alternative_wikipedia_url': ('django.db.models.fields.URLField', [], {'db_index': 'True', 'max_length': '2048', 'null': 'True', 'blank': 'True'}),
-            'category': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.TagCategory']", 'null': 'True', 'blank': 'True'}),
-            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
-            'dbpedia_uri': ('django.db.models.fields.URLField', [], {'db_index': 'True', 'max_length': '2048', 'null': 'True', 'blank': 'True'}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'label': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'db_index': 'True'}),
-            'normalized_label': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'db_index': 'True'}),
-            'original_label': ('django.db.models.fields.CharField', [], {'max_length': '1024'}),
-            'popularity': ('django.db.models.fields.IntegerField', [], {'default': '0', 'db_index': 'True'}),
-            'url_status': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True', 'db_index': 'True', 'blank': 'True'}),
-            'wikipedia_pageid': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
-            'wikipedia_url': ('django.db.models.fields.URLField', [], {'db_index': 'True', 'max_length': '2048', 'null': 'True', 'blank': 'True'})
-        },
-        u'hdabo.tagcategory': {
-            'Meta': {'object_name': 'TagCategory'},
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512'})
-        },
-        u'hdabo.taggedsheet': {
-            'Meta': {'object_name': 'TaggedSheet'},
-            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
-            'datasheet': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Datasheet']"}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'index_note': ('django.db.models.fields.FloatField', [], {'default': '0.0', 'db_index': 'True'}),
-            'order': ('django.db.models.fields.IntegerField', [], {'default': '0', 'db_index': 'True'}),
-            'original_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
-            'tag': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.Tag']"}),
-            'wikipedia_revision_id': ('django.db.models.fields.BigIntegerField', [], {'null': 'True', 'blank': 'True'})
-        },
-        u'hdabo.timeperiod': {
-            'Meta': {'unique_together': "(('label', 'school_period'),)", 'object_name': 'TimePeriod'},
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'label': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
-            'school_period': ('django.db.models.fields.IntegerField', [], {})
-        },
-        u'hdabo.user': {
-            'Meta': {'object_name': 'User', 'db_table': "'auth_user'"},
-            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
-            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
-            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
-            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
-            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
-            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
-            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
-            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
-            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
-            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
-            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
-        },
-        'hdalab.country': {
-            'Meta': {'object_name': 'Country'},
-            'dbpedia_uri': ('django.db.models.fields.URLField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
-        },
-        'hdalab.datasheetextras': {
-            'Meta': {'object_name': 'DatasheetExtras'},
-            'datasheet': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'extras'", 'unique': 'True', 'to': u"orm['hdabo.Datasheet']"}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'insee': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['hdalab.InseeCoords']", 'null': 'True', 'blank': 'True'})
-        },
-        'hdalab.dbpediafields': {
-            'Meta': {'object_name': 'DbpediaFields'},
-            'abstract': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
-            'dbpedia_uri': ('django.db.models.fields.URLField', [], {'max_length': '2048', 'db_index': 'True'}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'label': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'null': 'True', 'blank': 'True'}),
-            'tag': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'dbpedia_fields'", 'unique': 'True', 'null': 'True', 'to': u"orm['hdabo.Tag']"}),
-            'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '2048', 'null': 'True', 'blank': 'True'})
-        },
-        'hdalab.dbpediafieldstranslation': {
-            'Meta': {'unique_together': "(('master', 'language_code'),)", 'object_name': 'DbpediaFieldsTranslation'},
-            'abstract': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'is_abstract_translated': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
-            'is_label_translated': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
-            'label': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'blank': 'True'}),
-            'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
-            'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'to': "orm['hdalab.DbpediaFields']"})
-        },
-        'hdalab.geoinclusion': {
-            'Meta': {'object_name': 'GeoInclusion'},
-            'country': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'includes'", 'to': "orm['hdalab.Country']"}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'tag': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'locatedin'", 'unique': 'True', 'to': u"orm['hdabo.Tag']"})
-        },
-        'hdalab.hdasession': {
-            'Meta': {'object_name': 'HdaSession'},
-            'data': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'sessionid': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '36', 'db_index': 'True'})
-        },
-        'hdalab.infoboxparameter': {
-            'Meta': {'unique_together': "(('tag_infobox', 'param_name'),)", 'object_name': 'InfoboxParameter'},
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'param_name': ('django.db.models.fields.CharField', [], {'max_length': '2048'}),
-            'param_value': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
-            'tag_infobox': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['hdalab.TagInfobox']"})
-        },
-        'hdalab.inseecoords': {
-            'Meta': {'object_name': 'InseeCoords'},
-            'city_name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
-            'insee': ('django.db.models.fields.IntegerField', [], {'primary_key': 'True'}),
-            'latitude': ('django.db.models.fields.FloatField', [], {}),
-            'longitude': ('django.db.models.fields.FloatField', [], {})
-        },
-        'hdalab.renkan': {
-            'Meta': {'object_name': 'Renkan'},
-            'content': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
-            'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'image': ('django.db.models.fields.files.ImageField', [], {'default': "'thumbnails/renkan/renkan_default_icon.png'", 'max_length': '100'}),
-            'modification_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
-            'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['hdabo.User']"}),
-            'rk_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '1024'}),
-            'state': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
-            'title': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True'})
-        },
-        'hdalab.taginfobox': {
-            'Meta': {'unique_together': "(('tag', 'name', 'revision_id'),)", 'object_name': 'TagInfobox'},
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'name': ('django.db.models.fields.CharField', [], {'max_length': '2048'}),
-            'revision_id': ('django.db.models.fields.BigIntegerField', [], {'null': 'True', 'blank': 'True'}),
-            'source': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
-            'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'infoboxes'", 'to': u"orm['hdabo.Tag']"})
-        },
-        'hdalab.taglinks': {
-            'Meta': {'object_name': 'TagLinks'},
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'object': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'taglinks_objects'", 'to': u"orm['hdabo.Tag']"}),
-            'subject': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'taglinks_subjects'", 'to': u"orm['hdabo.Tag']"})
-        },
-        'hdalab.tagwpcategory': {
-            'Meta': {'unique_together': "(('tag', 'wp_category', 'hidden'),)", 'object_name': 'TagWpCategory'},
-            'hidden': ('django.db.models.fields.BooleanField', [], {}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'wp_categories'", 'to': u"orm['hdabo.Tag']"}),
-            'wp_category': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tags'", 'to': "orm['hdalab.WpCategory']"})
-        },
-        'hdalab.tagyears': {
-            'Meta': {'object_name': 'TagYears'},
-            'end_year': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'start_year': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
-            'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'years'", 'to': u"orm['hdabo.Tag']"})
-        },
-        'hdalab.wpcategory': {
-            'Meta': {'object_name': 'WpCategory'},
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '2048'})
-        },
-        'hdalab.wpcategoryinclusion': {
-            'Meta': {'unique_together': "(('parent_category', 'child_category'),)", 'object_name': 'WpCategoryInclusion'},
-            'child_category': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'parent_categories'", 'to': "orm['hdalab.WpCategory']"}),
-            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'parent_category': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'child_categories'", 'to': "orm['hdalab.WpCategory']"})
-        }
-    }
-
-    complete_apps = ['hdalab']
\ No newline at end of file
--- a/src/hdalab/models/__init__.py	Fri Jul 18 13:29:53 2014 +0200
+++ b/src/hdalab/models/__init__.py	Mon Jul 21 16:07:00 2014 +0200
@@ -1,6 +1,6 @@
 from hdalab.models.categories import (WpCategory, InfoboxParameter, TagInfobox, 
     TagWpCategory, WpCategoryInclusion)
 from hdalab.models.dataviz import TagYears, Country, GeoInclusion, TagLinks, DbpediaFields, HdaSession, InseeCoords, DatasheetExtras, DbpediaFieldsTranslation
-from hdalab.models.renkan import Renkan
+from hdalab.models.renkan import HdalabRenkan
 
-__all__ = ['WpCategory', 'InfoboxParameter', 'TagInfobox', 'TagWpCategory', 'TagYears', 'Country', 'GeoInclusion', 'TagLinks', 'DbpediaFields', 'DbpediaFieldsTranslation', 'HdaSession', 'InseeCoords', 'DatasheetExtras', 'WpCategoryInclusion', 'Renkan']
\ No newline at end of file
+__all__ = ['WpCategory', 'InfoboxParameter', 'TagInfobox', 'TagWpCategory', 'TagYears', 'Country', 'GeoInclusion', 'TagLinks', 'DbpediaFields', 'DbpediaFieldsTranslation', 'HdaSession', 'InseeCoords', 'DatasheetExtras', 'WpCategoryInclusion', 'HdalabRenkan']
\ No newline at end of file
--- a/src/hdalab/models/renkan.py	Fri Jul 18 13:29:53 2014 +0200
+++ b/src/hdalab/models/renkan.py	Mon Jul 21 16:07:00 2014 +0200
@@ -3,13 +3,11 @@
 
 @author: tc
 '''
-from django.conf import settings
 from django.db import models
-from hdabo.models import User
-from easy_thumbnails.fields import ThumbnailerImageField
+from renkanmanager.models import Renkan
 
 
-class Renkan(models.Model):
+class HdalabRenkan(models.Model):
     
     EDITION = 1
     PUBLISHED = 2
@@ -23,14 +21,8 @@
     (REJECTED, 'rejected'),
     )
     
-    owner = models.ForeignKey(User, blank=False, null=False)
-    rk_id = models.CharField(max_length=1024, unique=True, blank=False, null=False) # typically UUID
-    content = models.TextField(blank=True, null=True)
-    title = models.CharField(max_length=1024, null=True)
+    renkan = models.ForeignKey(Renkan, blank=False, null=False)
     state = models.IntegerField(choices=STATE_CHOICES, default=1)
-    image = ThumbnailerImageField(upload_to="thumbnails/renkan/", default=settings.DEFAULT_RENKAN_ICON)
-    creation_date = models.DateTimeField(auto_now_add=True)
-    modification_date = models.DateTimeField(auto_now=True)
     
     class Meta:
         app_label = 'hdalab'
--- a/src/hdalab/static/hdalab/lib/FileSaver.js	Fri Jul 18 13:29:53 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,253 +0,0 @@
-/*! FileSaver.js
- *  A saveAs() FileSaver implementation.
- *  2014-01-24
- *
- *  By Eli Grey, http://eligrey.com
- *  License: X11/MIT
- *    See LICENSE.md
- */
-
-/*global self */
-/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
-
-/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
-
-var saveAs = saveAs
-  // IE 10+ (native saveAs)
-  || (typeof navigator !== "undefined" &&
-      navigator.msSaveOrOpenBlob && navigator.msSaveOrOpenBlob.bind(navigator))
-  // Everyone else
-  || (function(view) {
-	"use strict";
-	// IE <10 is explicitly unsupported
-	if (typeof navigator !== "undefined" &&
-	    /MSIE [1-9]\./.test(navigator.userAgent)) {
-		return;
-	}
-	var
-		  doc = view.document
-		  // only get URL when necessary in case BlobBuilder.js hasn't overridden it yet
-		, get_URL = function() {
-			return view.URL || view.webkitURL || view;
-		}
-		, URL = view.URL || view.webkitURL || view
-		, save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
-		, can_use_save_link = !view.externalHost && "download" in save_link
-		, click = function(node) {
-			var event = doc.createEvent("MouseEvents");
-			event.initMouseEvent(
-				"click", true, false, view, 0, 0, 0, 0, 0
-				, false, false, false, false, 0, null
-			);
-			node.dispatchEvent(event);
-		}
-		, webkit_req_fs = view.webkitRequestFileSystem
-		, req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem
-		, throw_outside = function(ex) {
-			(view.setImmediate || view.setTimeout)(function() {
-				throw ex;
-			}, 0);
-		}
-		, force_saveable_type = "application/octet-stream"
-		, fs_min_size = 0
-		, deletion_queue = []
-		, process_deletion_queue = function() {
-			var i = deletion_queue.length;
-			while (i--) {
-				var file = deletion_queue[i];
-				if (typeof file === "string") { // file is an object URL
-					URL.revokeObjectURL(file);
-				} else { // file is a File
-					file.remove();
-				}
-			}
-			deletion_queue.length = 0; // clear queue
-		}
-		, dispatch = function(filesaver, event_types, event) {
-			event_types = [].concat(event_types);
-			var i = event_types.length;
-			while (i--) {
-				var listener = filesaver["on" + event_types[i]];
-				if (typeof listener === "function") {
-					try {
-						listener.call(filesaver, event || filesaver);
-					} catch (ex) {
-						throw_outside(ex);
-					}
-				}
-			}
-		}
-		, FileSaver = function(blob, name) {
-			// First try a.download, then web filesystem, then object URLs
-			var
-				  filesaver = this
-				, type = blob.type
-				, blob_changed = false
-				, object_url
-				, target_view
-				, get_object_url = function() {
-					var object_url = get_URL().createObjectURL(blob);
-					deletion_queue.push(object_url);
-					return object_url;
-				}
-				, dispatch_all = function() {
-					dispatch(filesaver, "writestart progress write writeend".split(" "));
-				}
-				// on any filesys errors revert to saving with object URLs
-				, fs_error = function() {
-					// don't create more object URLs than needed
-					if (blob_changed || !object_url) {
-						object_url = get_object_url(blob);
-					}
-					if (target_view) {
-						target_view.location.href = object_url;
-					} else {
-						window.open(object_url, "_blank");
-					}
-					filesaver.readyState = filesaver.DONE;
-					dispatch_all();
-				}
-				, abortable = function(func) {
-					return function() {
-						if (filesaver.readyState !== filesaver.DONE) {
-							return func.apply(this, arguments);
-						}
-					};
-				}
-				, create_if_not_found = {create: true, exclusive: false}
-				, slice
-			;
-			filesaver.readyState = filesaver.INIT;
-			if (!name) {
-				name = "download";
-			}
-			if (can_use_save_link) {
-				object_url = get_object_url(blob);
-				// FF for Android has a nasty garbage collection mechanism
-				// that turns all objects that are not pure javascript into 'deadObject'
-				// this means `doc` and `save_link` are unusable and need to be recreated
-				// `view` is usable though:
-				doc = view.document;
-				save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a");
-				save_link.href = object_url;
-				save_link.download = name;
-				var event = doc.createEvent("MouseEvents");
-				event.initMouseEvent(
-					"click", true, false, view, 0, 0, 0, 0, 0
-					, false, false, false, false, 0, null
-				);
-				save_link.dispatchEvent(event);
-				filesaver.readyState = filesaver.DONE;
-				dispatch_all();
-				return;
-			}
-			// Object and web filesystem URLs have a problem saving in Google Chrome when
-			// viewed in a tab, so I force save with application/octet-stream
-			// http://code.google.com/p/chromium/issues/detail?id=91158
-			if (view.chrome && type && type !== force_saveable_type) {
-				slice = blob.slice || blob.webkitSlice;
-				blob = slice.call(blob, 0, blob.size, force_saveable_type);
-				blob_changed = true;
-			}
-			// Since I can't be sure that the guessed media type will trigger a download
-			// in WebKit, I append .download to the filename.
-			// https://bugs.webkit.org/show_bug.cgi?id=65440
-			if (webkit_req_fs && name !== "download") {
-				name += ".download";
-			}
-			if (type === force_saveable_type || webkit_req_fs) {
-				target_view = view;
-			}
-			if (!req_fs) {
-				fs_error();
-				return;
-			}
-			fs_min_size += blob.size;
-			req_fs(view.TEMPORARY, fs_min_size, abortable(function(fs) {
-				fs.root.getDirectory("saved", create_if_not_found, abortable(function(dir) {
-					var save = function() {
-						dir.getFile(name, create_if_not_found, abortable(function(file) {
-							file.createWriter(abortable(function(writer) {
-								writer.onwriteend = function(event) {
-									target_view.location.href = file.toURL();
-									deletion_queue.push(file);
-									filesaver.readyState = filesaver.DONE;
-									dispatch(filesaver, "writeend", event);
-								};
-								writer.onerror = function() {
-									var error = writer.error;
-									if (error.code !== error.ABORT_ERR) {
-										fs_error();
-									}
-								};
-								"writestart progress write abort".split(" ").forEach(function(event) {
-									writer["on" + event] = filesaver["on" + event];
-								});
-								writer.write(blob);
-								filesaver.abort = function() {
-									writer.abort();
-									filesaver.readyState = filesaver.DONE;
-								};
-								filesaver.readyState = filesaver.WRITING;
-							}), fs_error);
-						}), fs_error);
-					};
-					dir.getFile(name, {create: false}, abortable(function(file) {
-						// delete file if it already exists
-						file.remove();
-						save();
-					}), abortable(function(ex) {
-						if (ex.code === ex.NOT_FOUND_ERR) {
-							save();
-						} else {
-							fs_error();
-						}
-					}));
-				}), fs_error);
-			}), fs_error);
-		}
-		, FS_proto = FileSaver.prototype
-		, saveAs = function(blob, name) {
-			return new FileSaver(blob, name);
-		}
-	;
-	FS_proto.abort = function() {
-		var filesaver = this;
-		filesaver.readyState = filesaver.DONE;
-		dispatch(filesaver, "abort");
-	};
-	FS_proto.readyState = FS_proto.INIT = 0;
-	FS_proto.WRITING = 1;
-	FS_proto.DONE = 2;
-
-	FS_proto.error =
-	FS_proto.onwritestart =
-	FS_proto.onprogress =
-	FS_proto.onwrite =
-	FS_proto.onabort =
-	FS_proto.onerror =
-	FS_proto.onwriteend =
-		null;
-
-	view.addEventListener("unload", process_deletion_queue, false);
-	saveAs.unload = function() {
-		process_deletion_queue();
-		view.removeEventListener("unload", process_deletion_queue, false);
-	};
-	return saveAs;
-}(
-	   typeof self !== "undefined" && self
-	|| typeof window !== "undefined" && window
-	|| this.content
-));
-// `self` is undefined in Firefox for Android content script context
-// while `this` is nsIContentFrameMessageManager
-// with an attribute `content` that corresponds to the window
-
-if (typeof module !== "undefined" && module !== null) {
-  module.exports = saveAs;
-} else if ((typeof define !== "undefined" && define !== null) && (define.amd != null)) {
-  define([], function() {
-    return saveAs;
-  });
-}
--- a/src/hdalab/static/hdalab/lib/backbone-relational.js	Fri Jul 18 13:29:53 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1860 +0,0 @@
-/* vim: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */
-/**
- * Backbone-relational.js 0.8.5
- * (c) 2011-2013 Paul Uithol and contributors (https://github.com/PaulUithol/Backbone-relational/graphs/contributors)
- * 
- * Backbone-relational may be freely distributed under the MIT license; see the accompanying LICENSE.txt.
- * For details and documentation: https://github.com/PaulUithol/Backbone-relational.
- * Depends on Backbone (and thus on Underscore as well): https://github.com/documentcloud/backbone.
- */
-( function( undefined ) {
-	"use strict";
-
-	/**
-	 * CommonJS shim
-	 **/
-	var _, Backbone, exports;
-	if ( typeof window === 'undefined' ) {
-		_ = require( 'underscore' );
-		Backbone = require( 'backbone' );
-		exports = module.exports = Backbone;
-	}
-	else {
-		_ = window._;
-		Backbone = window.Backbone;
-		exports = window;
-	}
-
-	Backbone.Relational = {
-		showWarnings: true
-	};
-
-	/**
-	 * Semaphore mixin; can be used as both binary and counting.
-	 **/
-	Backbone.Semaphore = {
-		_permitsAvailable: null,
-		_permitsUsed: 0,
-
-		acquire: function() {
-			if ( this._permitsAvailable && this._permitsUsed >= this._permitsAvailable ) {
-				throw new Error( 'Max permits acquired' );
-			}
-			else {
-				this._permitsUsed++;
-			}
-		},
-
-		release: function() {
-			if ( this._permitsUsed === 0 ) {
-				throw new Error( 'All permits released' );
-			}
-			else {
-				this._permitsUsed--;
-			}
-		},
-
-		isLocked: function() {
-			return this._permitsUsed > 0;
-		},
-
-		setAvailablePermits: function( amount ) {
-			if ( this._permitsUsed > amount ) {
-				throw new Error( 'Available permits cannot be less than used permits' );
-			}
-			this._permitsAvailable = amount;
-		}
-	};
-
-	/**
-	 * A BlockingQueue that accumulates items while blocked (via 'block'),
-	 * and processes them when unblocked (via 'unblock').
-	 * Process can also be called manually (via 'process').
-	 */
-	Backbone.BlockingQueue = function() {
-		this._queue = [];
-	};
-	_.extend( Backbone.BlockingQueue.prototype, Backbone.Semaphore, {
-		_queue: null,
-
-		add: function( func ) {
-			if ( this.isBlocked() ) {
-				this._queue.push( func );
-			}
-			else {
-				func();
-			}
-		},
-
-		process: function() {
-			while ( this._queue && this._queue.length ) {
-				this._queue.shift()();
-			}
-		},
-
-		block: function() {
-			this.acquire();
-		},
-
-		unblock: function() {
-			this.release();
-			if ( !this.isBlocked() ) {
-				this.process();
-			}
-		},
-
-		isBlocked: function() {
-			return this.isLocked();
-		}
-	});
-	/**
-	 * Global event queue. Accumulates external events ('add:<key>', 'remove:<key>' and 'change:<key>')
-	 * until the top-level object is fully initialized (see 'Backbone.RelationalModel').
-	 */
-	Backbone.Relational.eventQueue = new Backbone.BlockingQueue();
-
-	/**
-	 * Backbone.Store keeps track of all created (and destruction of) Backbone.RelationalModel.
-	 * Handles lookup for relations.
-	 */
-	Backbone.Store = function() {
-		this._collections = [];
-		this._reverseRelations = [];
-		this._orphanRelations = [];
-		this._subModels = [];
-		this._modelScopes = [ exports ];
-	};
-	_.extend( Backbone.Store.prototype, Backbone.Events, {
-		/**
-		 * Create a new `Relation`.
-		 * @param {Backbone.RelationalModel} [model]
-		 * @param {Object} relation
-		 * @param {Object} [options]
-		 */
-		initializeRelation: function( model, relation, options ) {
-			var type = !_.isString( relation.type ) ? relation.type : Backbone[ relation.type ] || this.getObjectByName( relation.type );
-			if ( type && type.prototype instanceof Backbone.Relation ) {
-				new type( model, relation, options ); // Also pushes the new Relation into `model._relations`
-			}
-			else {
-				Backbone.Relational.showWarnings && typeof console !== 'undefined' && console.warn( 'Relation=%o; missing or invalid relation type!', relation );
-			}
-		},
-
-		/**
-		 * Add a scope for `getObjectByName` to look for model types by name.
-		 * @param {Object} scope
-		 */
-		addModelScope: function( scope ) {
-			this._modelScopes.push( scope );
-		},
-
-		/**
-		 * Remove a scope.
-		 * @param {Object} scope
-		 */
-		removeModelScope: function( scope ) {
-			this._modelScopes = _.without( this._modelScopes, scope );
-		},
-
-		/**
-		 * Add a set of subModelTypes to the store, that can be used to resolve the '_superModel'
-		 * for a model later in 'setupSuperModel'.
-		 *
-		 * @param {Backbone.RelationalModel} subModelTypes
-		 * @param {Backbone.RelationalModel} superModelType
-		 */
-		addSubModels: function( subModelTypes, superModelType ) {
-			this._subModels.push({
-				'superModelType': superModelType,
-				'subModels': subModelTypes
-			});
-		},
-
-		/**
-		 * Check if the given modelType is registered as another model's subModel. If so, add it to the super model's
-		 * '_subModels', and set the modelType's '_superModel', '_subModelTypeName', and '_subModelTypeAttribute'.
-		 *
-		 * @param {Backbone.RelationalModel} modelType
-		 */
-		setupSuperModel: function( modelType ) {
-			_.find( this._subModels, function( subModelDef ) {
-				return _.find( subModelDef.subModels || [], function( subModelTypeName, typeValue ) {
-					var subModelType = this.getObjectByName( subModelTypeName );
-
-					if ( modelType === subModelType ) {
-						// Set 'modelType' as a child of the found superModel
-						subModelDef.superModelType._subModels[ typeValue ] = modelType;
-
-						// Set '_superModel', '_subModelTypeValue', and '_subModelTypeAttribute' on 'modelType'.
-						modelType._superModel = subModelDef.superModelType;
-						modelType._subModelTypeValue = typeValue;
-						modelType._subModelTypeAttribute = subModelDef.superModelType.prototype.subModelTypeAttribute;
-						return true;
-					}
-				}, this );
-			}, this );
-		},
-
-		/**
-		 * Add a reverse relation. Is added to the 'relations' property on model's prototype, and to
-		 * existing instances of 'model' in the store as well.
-		 * @param {Object} relation
-		 * @param {Backbone.RelationalModel} relation.model
-		 * @param {String} relation.type
-		 * @param {String} relation.key
-		 * @param {String|Object} relation.relatedModel
-		 */
-		addReverseRelation: function( relation ) {
-			var exists = _.any( this._reverseRelations, function( rel ) {
-				return _.all( relation || [], function( val, key ) {
-					return val === rel[ key ];
-				});
-			});
-			
-			if ( !exists && relation.model && relation.type ) {
-				this._reverseRelations.push( relation );
-				this._addRelation( relation.model, relation );
-				this.retroFitRelation( relation );
-			}
-		},
-
-		/**
-		 * Deposit a `relation` for which the `relatedModel` can't be resolved at the moment.
-		 *
-		 * @param {Object} relation
-		 */
-		addOrphanRelation: function( relation ) {
-			var exists = _.any( this._orphanRelations, function( rel ) {
-				return _.all( relation || [], function( val, key ) {
-					return val === rel[ key ];
-				});
-			});
-
-			if ( !exists && relation.model && relation.type ) {
-				this._orphanRelations.push( relation );
-			}
-		},
-
-		/**
-		 * Try to initialize any `_orphanRelation`s
-		 */
-		processOrphanRelations: function() {
-			// Make sure to operate on a copy since we're removing while iterating
-			_.each( this._orphanRelations.slice( 0 ), function( rel ) {
-				var relatedModel = Backbone.Relational.store.getObjectByName( rel.relatedModel );
-				if ( relatedModel ) {
-					this.initializeRelation( null, rel );
-					this._orphanRelations = _.without( this._orphanRelations, rel );
-				}
-			}, this );
-		},
-
-		/**
-		 *
-		 * @param {Backbone.RelationalModel.constructor} type
-		 * @param {Object} relation
-		 * @private
-		 */
-		_addRelation: function( type, relation ) {
-			if ( !type.prototype.relations ) {
-				type.prototype.relations = [];
-			}
-			type.prototype.relations.push( relation );
-
-			_.each( type._subModels || [], function( subModel ) {
-				this._addRelation( subModel, relation );
-			}, this );
-		},
-
-		/**
-		 * Add a 'relation' to all existing instances of 'relation.model' in the store
-		 * @param {Object} relation
-		 */
-		retroFitRelation: function( relation ) {
-			var coll = this.getCollection( relation.model, false );
-			coll && coll.each( function( model ) {
-				if ( !( model instanceof relation.model ) ) {
-					return;
-				}
-
-				new relation.type( model, relation );
-			}, this );
-		},
-
-		/**
-		 * Find the Store's collection for a certain type of model.
-		 * @param {Backbone.RelationalModel} type
-		 * @param {Boolean} [create=true] Should a collection be created if none is found?
-		 * @return {Backbone.Collection} A collection if found (or applicable for 'model'), or null
-		 */
-		getCollection: function( type, create ) {
-			if ( type instanceof Backbone.RelationalModel ) {
-				type = type.constructor;
-			}
-			
-			var rootModel = type;
-			while ( rootModel._superModel ) {
-				rootModel = rootModel._superModel;
-			}
-			
-			var coll = _.findWhere( this._collections, { model: rootModel } );
-			
-			if ( !coll && create !== false ) {
-				coll = this._createCollection( rootModel );
-			}
-			
-			return coll;
-		},
-
-		/**
-		 * Find a model type on one of the modelScopes by name. Names are split on dots.
-		 * @param {String} name
-		 * @return {Object}
-		 */
-		getObjectByName: function( name ) {
-			var parts = name.split( '.' ),
-				type = null;
-
-			_.find( this._modelScopes, function( scope ) {
-				type = _.reduce( parts || [], function( memo, val ) {
-					return memo ? memo[ val ] : undefined;
-				}, scope );
-
-				if ( type && type !== scope ) {
-					return true;
-				}
-			}, this );
-
-			return type;
-		},
-
-		_createCollection: function( type ) {
-			var coll;
-			
-			// If 'type' is an instance, take its constructor
-			if ( type instanceof Backbone.RelationalModel ) {
-				type = type.constructor;
-			}
-			
-			// Type should inherit from Backbone.RelationalModel.
-			if ( type.prototype instanceof Backbone.RelationalModel ) {
-				coll = new Backbone.Collection();
-				coll.model = type;
-				
-				this._collections.push( coll );
-			}
-			
-			return coll;
-		},
-
-		/**
-		 * Find the attribute that is to be used as the `id` on a given object
-		 * @param type
-		 * @param {String|Number|Object|Backbone.RelationalModel} item
-		 * @return {String|Number}
-		 */
-		resolveIdForItem: function( type, item ) {
-			var id = _.isString( item ) || _.isNumber( item ) ? item : null;
-
-			if ( id === null ) {
-				if ( item instanceof Backbone.RelationalModel ) {
-					id = item.id;
-				}
-				else if ( _.isObject( item ) ) {
-					id = item[ type.prototype.idAttribute ];
-				}
-			}
-
-			// Make all falsy values `null` (except for 0, which could be an id.. see '/issues/179')
-			if ( !id && id !== 0 ) {
-				id = null;
-			}
-
-			return id;
-		},
-
-		/**
-		 * Find a specific model of a certain `type` in the store
-		 * @param type
-		 * @param {String|Number|Object|Backbone.RelationalModel} item
-		 */
-		find: function( type, item ) {
-			var id = this.resolveIdForItem( type, item );
-			var coll = this.getCollection( type );
-			
-			// Because the found object could be of any of the type's superModel
-			// types, only return it if it's actually of the type asked for.
-			if ( coll ) {
-				var obj = coll.get( id );
-
-				if ( obj instanceof type ) {
-					return obj;
-				}
-			}
-
-			return null;
-		},
-
-		/**
-		 * Add a 'model' to its appropriate collection. Retain the original contents of 'model.collection'.
-		 * @param {Backbone.RelationalModel} model
-		 */
-		register: function( model ) {
-			var coll = this.getCollection( model );
-
-			if ( coll ) {
-				var modelColl = model.collection;
-				coll.add( model );
-				this.listenTo( model, 'destroy', this.unregister, this );
-				model.collection = modelColl;
-			}
-		},
-
-		/**
-		 * Check if the given model may use the given `id`
-		 * @param model
-		 * @param [id]
-		 */
-		checkId: function( model, id ) {
-			var coll = this.getCollection( model ),
-				duplicate = coll && coll.get( id );
-
-			if ( duplicate && model !== duplicate ) {
-				if ( Backbone.Relational.showWarnings && typeof console !== 'undefined' ) {
-					console.warn( 'Duplicate id! Old RelationalModel=%o, new RelationalModel=%o', duplicate, model );
-				}
-
-				throw new Error( "Cannot instantiate more than one Backbone.RelationalModel with the same id per type!" );
-			}
-		},
-
-		/**
-		 * Explicitly update a model's id in its store collection
-		 * @param {Backbone.RelationalModel} model
-		 */
-		update: function( model ) {
-			var coll = this.getCollection( model );
-			// This triggers updating the lookup indices kept in a collection
-			coll._onModelEvent( 'change:' + model.idAttribute, model, coll );
-
-			// Trigger an event on model so related models (having the model's new id in their keyContents) can add it.
-			model.trigger( 'relational:change:id', model, coll );
-		},
-
-		/**
-		 * Remove a 'model' from the store.
-		 * @param {Backbone.RelationalModel} model
-		 */
-		unregister: function( model ) {
-			this.stopListening( model, 'destroy', this.unregister );
-			var coll = this.getCollection( model );
-			coll && coll.remove( model );
-		},
-
-		/**
-		 * Reset the `store` to it's original state. The `reverseRelations` are kept though, since attempting to
-		 * re-initialize these on models would lead to a large amount of warnings.
-		 */
-		reset: function() {
-			this.stopListening();
-			this._collections = [];
-			this._subModels = [];
-			this._modelScopes = [ exports ];
-		}
-	});
-	Backbone.Relational.store = new Backbone.Store();
-
-	/**
-	 * The main Relation class, from which 'HasOne' and 'HasMany' inherit. Internally, 'relational:<key>' events
-	 * are used to regulate addition and removal of models from relations.
-	 *
-	 * @param {Backbone.RelationalModel} [instance] Model that this relation is created for. If no model is supplied,
-	 *      Relation just tries to instantiate it's `reverseRelation` if specified, and bails out after that.
-	 * @param {Object} options
-	 * @param {string} options.key
-	 * @param {Backbone.RelationalModel.constructor} options.relatedModel
-	 * @param {Boolean|String} [options.includeInJSON=true] Serialize the given attribute for related model(s)' in toJSON, or just their ids.
-	 * @param {Boolean} [options.createModels=true] Create objects from the contents of keys if the object is not found in Backbone.store.
-	 * @param {Object} [options.reverseRelation] Specify a bi-directional relation. If provided, Relation will reciprocate
-	 *    the relation to the 'relatedModel'. Required and optional properties match 'options', except that it also needs
-	 *    {Backbone.Relation|String} type ('HasOne' or 'HasMany').
-	 * @param {Object} opts
-	 */
-	Backbone.Relation = function( instance, options, opts ) {
-		this.instance = instance;
-		// Make sure 'options' is sane, and fill with defaults from subclasses and this object's prototype
-		options = _.isObject( options ) ? options : {};
-		this.reverseRelation = _.defaults( options.reverseRelation || {}, this.options.reverseRelation );
-		this.options = _.defaults( options, this.options, Backbone.Relation.prototype.options );
-
-		this.reverseRelation.type = !_.isString( this.reverseRelation.type ) ? this.reverseRelation.type :
-			Backbone[ this.reverseRelation.type ] || Backbone.Relational.store.getObjectByName( this.reverseRelation.type );
-
-		this.key = this.options.key;
-		this.keySource = this.options.keySource || this.key;
-		this.keyDestination = this.options.keyDestination || this.keySource || this.key;
-
-		this.model = this.options.model || this.instance.constructor;
-		this.relatedModel = this.options.relatedModel;
-		if ( _.isString( this.relatedModel ) ) {
-			this.relatedModel = Backbone.Relational.store.getObjectByName( this.relatedModel );
-		}
-
-		if ( !this.checkPreconditions() ) {
-			return;
-		}
-
-		// Add the reverse relation on 'relatedModel' to the store's reverseRelations
-		if ( !this.options.isAutoRelation && this.reverseRelation.type && this.reverseRelation.key ) {
-			Backbone.Relational.store.addReverseRelation( _.defaults( {
-					isAutoRelation: true,
-					model: this.relatedModel,
-					relatedModel: this.model,
-					reverseRelation: this.options // current relation is the 'reverseRelation' for its own reverseRelation
-				},
-				this.reverseRelation // Take further properties from this.reverseRelation (type, key, etc.)
-			) );
-		}
-
-		if ( instance ) {
-			var contentKey = this.keySource;
-			if ( contentKey !== this.key && typeof this.instance.get( this.key ) === 'object' ) {
-				contentKey = this.key;
-			}
-
-			this.setKeyContents( this.instance.get( contentKey ) );
-			this.relatedCollection = Backbone.Relational.store.getCollection( this.relatedModel );
-
-			// Explicitly clear 'keySource', to prevent a leaky abstraction if 'keySource' differs from 'key'.
-			if ( this.keySource !== this.key ) {
-				this.instance.unset( this.keySource, { silent: true } );
-			}
-
-			// Add this Relation to instance._relations
-			this.instance._relations[ this.key ] = this;
-
-			this.initialize( opts );
-
-			if ( this.options.autoFetch ) {
-				this.instance.fetchRelated( this.key, _.isObject( this.options.autoFetch ) ? this.options.autoFetch : {} );
-			}
-
-			// When 'relatedModel' are created or destroyed, check if it affects this relation.
-			this.listenTo( this.instance, 'destroy', this.destroy )
-				.listenTo( this.relatedCollection, 'relational:add relational:change:id', this.tryAddRelated )
-				.listenTo( this.relatedCollection, 'relational:remove', this.removeRelated )
-		}
-	};
-	// Fix inheritance :\
-	Backbone.Relation.extend = Backbone.Model.extend;
-	// Set up all inheritable **Backbone.Relation** properties and methods.
-	_.extend( Backbone.Relation.prototype, Backbone.Events, Backbone.Semaphore, {
-		options: {
-			createModels: true,
-			includeInJSON: true,
-			isAutoRelation: false,
-			autoFetch: false,
-			parse: false
-		},
-
-		instance: null,
-		key: null,
-		keyContents: null,
-		relatedModel: null,
-		relatedCollection: null,
-		reverseRelation: null,
-		related: null,
-
-		/**
-		 * Check several pre-conditions.
-		 * @return {Boolean} True if pre-conditions are satisfied, false if they're not.
-		 */
-		checkPreconditions: function() {
-			var i = this.instance,
-				k = this.key,
-				m = this.model,
-				rm = this.relatedModel,
-				warn = Backbone.Relational.showWarnings && typeof console !== 'undefined';
-
-			if ( !m || !k || !rm ) {
-				warn && console.warn( 'Relation=%o: missing model, key or relatedModel (%o, %o, %o).', this, m, k, rm );
-				return false;
-			}
-			// Check if the type in 'model' inherits from Backbone.RelationalModel
-			if ( !( m.prototype instanceof Backbone.RelationalModel ) ) {
-				warn && console.warn( 'Relation=%o: model does not inherit from Backbone.RelationalModel (%o).', this, i );
-				return false;
-			}
-			// Check if the type in 'relatedModel' inherits from Backbone.RelationalModel
-			if ( !( rm.prototype instanceof Backbone.RelationalModel ) ) {
-				warn && console.warn( 'Relation=%o: relatedModel does not inherit from Backbone.RelationalModel (%o).', this, rm );
-				return false;
-			}
-			// Check if this is not a HasMany, and the reverse relation is HasMany as well
-			if ( this instanceof Backbone.HasMany && this.reverseRelation.type === Backbone.HasMany ) {
-				warn && console.warn( 'Relation=%o: relation is a HasMany, and the reverseRelation is HasMany as well.', this );
-				return false;
-			}
-			// Check if we're not attempting to create a relationship on a `key` that's already used.
-			if ( i && _.keys( i._relations ).length ) {
-				var existing = _.find( i._relations, function( rel ) {
-					return rel.key === k;
-				}, this );
-
-				if ( existing ) {
-					warn && console.warn( 'Cannot create relation=%o on %o for model=%o: already taken by relation=%o.',
-						this, k, i, existing );
-					return false;
-				}
-			}
-
-			return true;
-		},
-
-		/**
-		 * Set the related model(s) for this relation
-		 * @param {Backbone.Model|Backbone.Collection} related
-		 */
-		setRelated: function( related ) {
-			this.related = related;
-
-			this.instance.acquire();
-			this.instance.attributes[ this.key ] = related;
-			this.instance.release();
-		},
-
-		/**
-		 * Determine if a relation (on a different RelationalModel) is the reverse
-		 * relation of the current one.
-		 * @param {Backbone.Relation} relation
-		 * @return {Boolean}
-		 */
-		_isReverseRelation: function( relation ) {
-			return relation.instance instanceof this.relatedModel && this.reverseRelation.key === relation.key &&
-				this.key === relation.reverseRelation.key;
-		},
-
-		/**
-		 * Get the reverse relations (pointing back to 'this.key' on 'this.instance') for the currently related model(s).
-		 * @param {Backbone.RelationalModel} [model] Get the reverse relations for a specific model.
-		 *    If not specified, 'this.related' is used.
-		 * @return {Backbone.Relation[]}
-		 */
-		getReverseRelations: function( model ) {
-			var reverseRelations = [];
-			// Iterate over 'model', 'this.related.models' (if this.related is a Backbone.Collection), or wrap 'this.related' in an array.
-			var models = !_.isUndefined( model ) ? [ model ] : this.related && ( this.related.models || [ this.related ] );
-			_.each( models || [], function( related ) {
-				_.each( related.getRelations() || [], function( relation ) {
-						if ( this._isReverseRelation( relation ) ) {
-							reverseRelations.push( relation );
-						}
-					}, this );
-			}, this );
-			
-			return reverseRelations;
-		},
-
-		/**
-		 * When `this.instance` is destroyed, cleanup our relations.
-		 * Get reverse relation, call removeRelated on each.
-		 */
-		destroy: function() {
-			this.stopListening();
-
-			if ( this instanceof Backbone.HasOne ) {
-				this.setRelated( null );
-			}
-			else if ( this instanceof Backbone.HasMany ) {
-				this.setRelated( this._prepareCollection() );
-			}
-			
-			_.each( this.getReverseRelations(), function( relation ) {
-				relation.removeRelated( this.instance );
-			}, this );
-		}
-	});
-
-	Backbone.HasOne = Backbone.Relation.extend({
-		options: {
-			reverseRelation: { type: 'HasMany' }
-		},
-
-		initialize: function( opts ) {
-			this.listenTo( this.instance, 'relational:change:' + this.key, this.onChange );
-
-			var related = this.findRelated( opts );
-			this.setRelated( related );
-
-			// Notify new 'related' object of the new relation.
-			_.each( this.getReverseRelations(), function( relation ) {
-				relation.addRelated( this.instance, opts );
-			}, this );
-		},
-
-		/**
-		 * Find related Models.
-		 * @param {Object} [options]
-		 * @return {Backbone.Model}
-		 */
-		findRelated: function( options ) {
-			var related = null;
-
-			options = _.defaults( { parse: this.options.parse }, options );
-
-			if ( this.keyContents instanceof this.relatedModel ) {
-				related = this.keyContents;
-			}
-			else if ( this.keyContents || this.keyContents === 0 ) { // since 0 can be a valid `id` as well
-				var opts = _.defaults( { create: this.options.createModels }, options );
-				related = this.relatedModel.findOrCreate( this.keyContents, opts );
-			}
-
-			// Nullify `keyId` if we have a related model; in case it was already part of the relation
-			if ( this.related ) {
-				this.keyId = null;
-			}
-
-			return related;
-		},
-
-		/**
-		 * Normalize and reduce `keyContents` to an `id`, for easier comparison
-		 * @param {String|Number|Backbone.Model} keyContents
-		 */
-		setKeyContents: function( keyContents ) {
-			this.keyContents = keyContents;
-			this.keyId = Backbone.Relational.store.resolveIdForItem( this.relatedModel, this.keyContents );
-		},
-
-		/**
-		 * Event handler for `change:<key>`.
-		 * If the key is changed, notify old & new reverse relations and initialize the new relation.
-		 */
-		onChange: function( model, attr, options ) {
-			// Don't accept recursive calls to onChange (like onChange->findRelated->findOrCreate->initializeRelations->addRelated->onChange)
-			if ( this.isLocked() ) {
-				return;
-			}
-			this.acquire();
-			options = options ? _.clone( options ) : {};
-			
-			// 'options.__related' is set by 'addRelated'/'removeRelated'. If it is set, the change
-			// is the result of a call from a relation. If it's not, the change is the result of 
-			// a 'set' call on this.instance.
-			var changed = _.isUndefined( options.__related ),
-				oldRelated = changed ? this.related : options.__related;
-			
-			if ( changed ) {
-				this.setKeyContents( attr );
-				var related = this.findRelated( options );
-				this.setRelated( related );
-			}
-			
-			// Notify old 'related' object of the terminated relation
-			if ( oldRelated && this.related !== oldRelated ) {
-				_.each( this.getReverseRelations( oldRelated ), function( relation ) {
-					relation.removeRelated( this.instance, null, options );
-				}, this );
-			}
-
-			// Notify new 'related' object of the new relation. Note we do re-apply even if this.related is oldRelated;
-			// that can be necessary for bi-directional relations if 'this.instance' was created after 'this.related'.
-			// In that case, 'this.instance' will already know 'this.related', but the reverse might not exist yet.
-			_.each( this.getReverseRelations(), function( relation ) {
-				relation.addRelated( this.instance, options );
-			}, this );
-			
-			// Fire the 'change:<key>' event if 'related' was updated
-			if ( !options.silent && this.related !== oldRelated ) {
-				var dit = this;
-				this.changed = true;
-				Backbone.Relational.eventQueue.add( function() {
-					dit.instance.trigger( 'change:' + dit.key, dit.instance, dit.related, options, true );
-					dit.changed = false;
-				});
-			}
-			this.release();
-		},
-
-		/**
-		 * If a new 'this.relatedModel' appears in the 'store', try to match it to the last set 'keyContents'
-		 */
-		tryAddRelated: function( model, coll, options ) {
-			if ( ( this.keyId || this.keyId === 0 ) && model.id === this.keyId ) { // since 0 can be a valid `id` as well
-				this.addRelated( model, options );
-				this.keyId = null;
-			}
-		},
-
-		addRelated: function( model, options ) {
-			// Allow 'model' to set up its relations before proceeding.
-			// (which can result in a call to 'addRelated' from a relation of 'model')
-			var dit = this;
-			model.queue( function() {
-				if ( model !== dit.related ) {
-					var oldRelated = dit.related || null;
-					dit.setRelated( model );
-					dit.onChange( dit.instance, model, _.defaults( { __related: oldRelated }, options ) );
-				}
-			});
-		},
-
-		removeRelated: function( model, coll, options ) {
-			if ( !this.related ) {
-				return;
-			}
-			
-			if ( model === this.related ) {
-				var oldRelated = this.related || null;
-				this.setRelated( null );
-				this.onChange( this.instance, model, _.defaults( { __related: oldRelated }, options ) );
-			}
-		}
-	});
-
-	Backbone.HasMany = Backbone.Relation.extend({
-		collectionType: null,
-
-		options: {
-			reverseRelation: { type: 'HasOne' },
-			collectionType: Backbone.Collection,
-			collectionKey: true,
-			collectionOptions: {}
-		},
-
-		initialize: function( opts ) {
-			this.listenTo( this.instance, 'relational:change:' + this.key, this.onChange );
-			
-			// Handle a custom 'collectionType'
-			this.collectionType = this.options.collectionType;
-			if ( _.isString( this.collectionType ) ) {
-				this.collectionType = Backbone.Relational.store.getObjectByName( this.collectionType );
-			}
-			if ( this.collectionType !== Backbone.Collection && !( this.collectionType.prototype instanceof Backbone.Collection ) ) {
-				throw new Error( '`collectionType` must inherit from Backbone.Collection' );
-			}
-
-			var related = this.findRelated( opts );
-			this.setRelated( related );
-		},
-
-		/**
-		 * Bind events and setup collectionKeys for a collection that is to be used as the backing store for a HasMany.
-		 * If no 'collection' is supplied, a new collection will be created of the specified 'collectionType' option.
-		 * @param {Backbone.Collection} [collection]
-		 * @return {Backbone.Collection}
-		 */
-		_prepareCollection: function( collection ) {
-			if ( this.related ) {
-				this.stopListening( this.related );
-			}
-
-			if ( !collection || !( collection instanceof Backbone.Collection ) ) {
-				var options = _.isFunction( this.options.collectionOptions ) ?
-					this.options.collectionOptions( this.instance ) : this.options.collectionOptions;
-
-				collection = new this.collectionType( null, options );
-			}
-
-			collection.model = this.relatedModel;
-			
-			if ( this.options.collectionKey ) {
-				var key = this.options.collectionKey === true ? this.options.reverseRelation.key : this.options.collectionKey;
-				
-				if ( collection[ key ] && collection[ key ] !== this.instance ) {
-					if ( Backbone.Relational.showWarnings && typeof console !== 'undefined' ) {
-						console.warn( 'Relation=%o; collectionKey=%s already exists on collection=%o', this, key, this.options.collectionKey );
-					}
-				}
-				else if ( key ) {
-					collection[ key ] = this.instance;
-				}
-			}
-
-			this.listenTo( collection, 'relational:add', this.handleAddition )
-				.listenTo( collection, 'relational:remove', this.handleRemoval )
-				.listenTo( collection, 'relational:reset', this.handleReset );
-			
-			return collection;
-		},
-
-		/**
-		 * Find related Models.
-		 * @param {Object} [options]
-		 * @return {Backbone.Collection}
-		 */
-		findRelated: function( options ) {
-			var related = null;
-
-			options = _.defaults( { parse: this.options.parse }, options );
-
-			// Replace 'this.related' by 'this.keyContents' if it is a Backbone.Collection
-			if ( this.keyContents instanceof Backbone.Collection ) {
-				this._prepareCollection( this.keyContents );
-				related = this.keyContents;
-			}
-			// Otherwise, 'this.keyContents' should be an array of related object ids.
-			// Re-use the current 'this.related' if it is a Backbone.Collection; otherwise, create a new collection.
-			else {
-				var toAdd = [];
-
-				_.each( this.keyContents, function( attributes ) {
-					if ( attributes instanceof this.relatedModel ) {
-						var model = attributes;
-					}
-					else {
-						// If `merge` is true, update models here, instead of during update.
-						model = this.relatedModel.findOrCreate( attributes,
-							_.extend( { merge: true }, options, { create: this.options.createModels } )
-						);
-					}
-
-					model && toAdd.push( model );
-				}, this );
-
-				if ( this.related instanceof Backbone.Collection ) {
-					related = this.related;
-				}
-				else {
-					related = this._prepareCollection();
-				}
-
-				// By now, both `merge` and `parse` will already have been executed for models if they were specified.
-				// Disable them to prevent additional calls.
-				related.set( toAdd, _.defaults( { merge: false, parse: false }, options ) );
-			}
-
-			// Remove entries from `keyIds` that were already part of the relation (and are thus 'unchanged')
-			this.keyIds = _.difference( this.keyIds, _.pluck( related.models, 'id' ) );
-
-			return related;
-		},
-
-		/**
-		 * Normalize and reduce `keyContents` to a list of `ids`, for easier comparison
-		 * @param {String|Number|String[]|Number[]|Backbone.Collection} keyContents
-		 */
-		setKeyContents: function( keyContents ) {
-			this.keyContents = keyContents instanceof Backbone.Collection ? keyContents : null;
-			this.keyIds = [];
-
-			if ( !this.keyContents && ( keyContents || keyContents === 0 ) ) { // since 0 can be a valid `id` as well
-				// Handle cases the an API/user supplies just an Object/id instead of an Array
-				this.keyContents = _.isArray( keyContents ) ? keyContents : [ keyContents ];
-
-				_.each( this.keyContents, function( item ) {
-					var itemId = Backbone.Relational.store.resolveIdForItem( this.relatedModel, item );
-					if ( itemId || itemId === 0 ) {
-						this.keyIds.push( itemId );
-					}
-				}, this );
-			}
-		},
-
-		/**
-		 * Event handler for `change:<key>`.
-		 * If the contents of the key are changed, notify old & new reverse relations and initialize the new relation.
-		 */
-		onChange: function( model, attr, options ) {
-			options = options ? _.clone( options ) : {};
-			this.setKeyContents( attr );
-			this.changed = false;
-
-			var related = this.findRelated( options );
-			this.setRelated( related );
-
-			if ( !options.silent ) {
-				var dit = this;
-				Backbone.Relational.eventQueue.add( function() {
-					// The `changed` flag can be set in `handleAddition` or `handleRemoval`
-					if ( dit.changed ) {
-						dit.instance.trigger( 'change:' + dit.key, dit.instance, dit.related, options, true );
-						dit.changed = false;
-					}
-				});
-			}
-		},
-
-		/**
-		 * When a model is added to a 'HasMany', trigger 'add' on 'this.instance' and notify reverse relations.
-		 * (should be 'HasOne', must set 'this.instance' as their related).
-		*/
-		handleAddition: function( model, coll, options ) {
-			//console.debug('handleAddition called; args=%o', arguments);
-			options = options ? _.clone( options ) : {};
-			this.changed = true;
-			
-			_.each( this.getReverseRelations( model ), function( relation ) {
-				relation.addRelated( this.instance, options );
-			}, this );
-
-			// Only trigger 'add' once the newly added model is initialized (so, has its relations set up)
-			var dit = this;
-			!options.silent && Backbone.Relational.eventQueue.add( function() {
-				dit.instance.trigger( 'add:' + dit.key, model, dit.related, options );
-			});
-		},
-
-		/**
-		 * When a model is removed from a 'HasMany', trigger 'remove' on 'this.instance' and notify reverse relations.
-		 * (should be 'HasOne', which should be nullified)
-		 */
-		handleRemoval: function( model, coll, options ) {
-			//console.debug('handleRemoval called; args=%o', arguments);
-			options = options ? _.clone( options ) : {};
-			this.changed = true;
-			
-			_.each( this.getReverseRelations( model ), function( relation ) {
-				relation.removeRelated( this.instance, null, options );
-			}, this );
-			
-			var dit = this;
-			!options.silent && Backbone.Relational.eventQueue.add( function() {
-				 dit.instance.trigger( 'remove:' + dit.key, model, dit.related, options );
-			});
-		},
-
-		handleReset: function( coll, options ) {
-			var dit = this;
-			options = options ? _.clone( options ) : {};
-			!options.silent && Backbone.Relational.eventQueue.add( function() {
-				dit.instance.trigger( 'reset:' + dit.key, dit.related, options );
-			});
-		},
-
-		tryAddRelated: function( model, coll, options ) {
-			var item = _.contains( this.keyIds, model.id );
-
-			if ( item ) {
-				this.addRelated( model, options );
-				this.keyIds = _.without( this.keyIds, model.id );
-			}
-		},
-
-		addRelated: function( model, options ) {
-			// Allow 'model' to set up its relations before proceeding.
-			// (which can result in a call to 'addRelated' from a relation of 'model')
-			var dit = this;
-			model.queue( function() {
-				if ( dit.related && !dit.related.get( model ) ) {
-					dit.related.add( model, _.defaults( { parse: false }, options ) );
-				}
-			});
-		},
-
-		removeRelated: function( model, coll, options ) {
-			if ( this.related.get( model ) ) {
-				this.related.remove( model, options );
-			}
-		}
-	});
-
-	/**
-	 * A type of Backbone.Model that also maintains relations to other models and collections.
-	 * New events when compared to the original:
-	 *  - 'add:<key>' (model, related collection, options)
-	 *  - 'remove:<key>' (model, related collection, options)
-	 *  - 'change:<key>' (model, related model or collection, options)
-	 */
-	Backbone.RelationalModel = Backbone.Model.extend({
-		relations: null, // Relation descriptions on the prototype
-		_relations: null, // Relation instances
-		_isInitialized: false,
-		_deferProcessing: false,
-		_queue: null,
-
-		subModelTypeAttribute: 'type',
-		subModelTypes: null,
-
-		constructor: function( attributes, options ) {
-			// Nasty hack, for cases like 'model.get( <HasMany key> ).add( item )'.
-			// Defer 'processQueue', so that when 'Relation.createModels' is used we trigger 'HasMany'
-			// collection events only after the model is really fully set up.
-			// Example: event for "p.on( 'add:jobs' )" -> "p.get('jobs').add( { company: c.id, person: p.id } )".
-			if ( options && options.collection ) {
-				var dit = this,
-					collection = this.collection =  options.collection;
-
-				// Prevent `collection` from cascading down to nested models; they shouldn't go into this `if` clause.
-				delete options.collection;
-
-				this._deferProcessing = true;
-
-				var processQueue = function( model ) {
-					if ( model === dit ) {
-						dit._deferProcessing = false;
-						dit.processQueue();
-						collection.off( 'relational:add', processQueue );
-					}
-				};
-				collection.on( 'relational:add', processQueue );
-
-				// So we do process the queue eventually, regardless of whether this model actually gets added to 'options.collection'.
-				_.defer( function() {
-					processQueue( dit );
-				});
-			}
-
-			Backbone.Relational.store.processOrphanRelations();
-			
-			this._queue = new Backbone.BlockingQueue();
-			this._queue.block();
-			Backbone.Relational.eventQueue.block();
-
-			try {
-				Backbone.Model.apply( this, arguments );
-			}
-			finally {
-				// Try to run the global queue holding external events
-				Backbone.Relational.eventQueue.unblock();
-			}
-		},
-
-		/**
-		 * Override 'trigger' to queue 'change' and 'change:*' events
-		 */
-		trigger: function( eventName ) {
-			if ( eventName.length > 5 && eventName.indexOf( 'change' ) === 0 ) {
-				var dit = this,
-					args = arguments;
-
-				Backbone.Relational.eventQueue.add( function() {
-					if ( !dit._isInitialized ) {
-						return;
-					}
-
-					// Determine if the `change` event is still valid, now that all relations are populated
-					var changed = true;
-					if ( eventName === 'change' ) {
-						changed = dit.hasChanged();
-					}
-					else {
-						var attr = eventName.slice( 7 ),
-							rel = dit.getRelation( attr );
-
-						if ( rel ) {
-							// If `attr` is a relation, `change:attr` get triggered from `Relation.onChange`.
-							// These take precedence over `change:attr` events triggered by `Model.set`.
-							// The relation set a fourth attribute to `true`. If this attribute is present,
-							// continue triggering this event; otherwise, it's from `Model.set` and should be stopped.
-							changed = ( args[ 4 ] === true );
-
-							// If this event was triggered by a relation, set the right value in `this.changed`
-							// (a Collection or Model instead of raw data).
-							if ( changed ) {
-								dit.changed[ attr ] = args[ 2 ];
-							}
-							// Otherwise, this event is from `Model.set`. If the relation doesn't report a change,
-							// remove attr from `dit.changed` so `hasChanged` doesn't take it into account.
-							else if ( !rel.changed ) {
-								delete dit.changed[ attr ];
-							}
-						}
-					}
-
-					changed && Backbone.Model.prototype.trigger.apply( dit, args );
-				});
-			}
-			else {
-				Backbone.Model.prototype.trigger.apply( this, arguments );
-			}
-
-			return this;
-		},
-
-		/**
-		 * Initialize Relations present in this.relations; determine the type (HasOne/HasMany), then creates a new instance.
-		 * Invoked in the first call so 'set' (which is made from the Backbone.Model constructor).
-		 */
-		initializeRelations: function( options ) {
-			this.acquire(); // Setting up relations often also involve calls to 'set', and we only want to enter this function once
-			this._relations = {};
-
-			_.each( this.relations || [], function( rel ) {
-				Backbone.Relational.store.initializeRelation( this, rel, options );
-			}, this );
-
-			this._isInitialized = true;
-			this.release();
-			this.processQueue();
-		},
-
-		/**
-		 * When new values are set, notify this model's relations (also if options.silent is set).
-		 * (Relation.setRelated locks this model before calling 'set' on it to prevent loops)
-		 */
-		updateRelations: function( options ) {
-			if ( this._isInitialized && !this.isLocked() ) {
-				_.each( this._relations, function( rel ) {
-					// Update from data in `rel.keySource` if set, or `rel.key` otherwise
-					var val = this.attributes[ rel.keySource ] || this.attributes[ rel.key ];
-					if ( rel.related !== val ) {
-						this.trigger( 'relational:change:' + rel.key, this, val, options || {} );
-					}
-				}, this );
-			}
-		},
-
-		/**
-		 * Either add to the queue (if we're not initialized yet), or execute right away.
-		 */
-		queue: function( func ) {
-			this._queue.add( func );
-		},
-
-		/**
-		 * Process _queue
-		 */
-		processQueue: function() {
-			if ( this._isInitialized && !this._deferProcessing && this._queue.isBlocked() ) {
-				this._queue.unblock();
-			}
-		},
-
-		/**
-		 * Get a specific relation.
-		 * @param key {string} The relation key to look for.
-		 * @return {Backbone.Relation} An instance of 'Backbone.Relation', if a relation was found for 'key', or null.
-		 */
-		getRelation: function( key ) {
-			return this._relations[ key ];
-		},
-
-		/**
-		 * Get all of the created relations.
-		 * @return {Backbone.Relation[]}
-		 */
-		getRelations: function() {
-			return _.values( this._relations );
-		},
-
-		/**
-		 * Retrieve related objects.
-		 * @param key {string} The relation key to fetch models for.
-		 * @param [options] {Object} Options for 'Backbone.Model.fetch' and 'Backbone.sync'.
-		 * @param [refresh=false] {boolean} Fetch existing models from the server as well (in order to update them).
-		 * @return {jQuery.when[]} An array of request objects
-		 */
-		fetchRelated: function( key, options, refresh ) {
-			// Set default `options` for fetch
-			options = _.extend( { update: true, remove: false }, options );
-
-			var setUrl,
-				requests = [],
-				rel = this.getRelation( key ),
-				idsToFetch = rel && ( rel.keyIds || ( ( rel.keyId || rel.keyId === 0 ) ? [ rel.keyId ] : [] ) );
-
-			// On `refresh`, add the ids for current models in the relation to `idsToFetch`
-			if ( refresh ) {
-				var models = rel.related instanceof Backbone.Collection ? rel.related.models : [ rel.related ];
-				_.each( models, function( model ) {
-					if ( model.id || model.id === 0 ) {
-						idsToFetch.push( model.id );
-					}
-				});
-			}
-
-			if ( idsToFetch && idsToFetch.length ) {
-				// Find (or create) a model for each one that is to be fetched
-				var created = [],
-					models = _.map( idsToFetch, function( id ) {
-						var model = Backbone.Relational.store.find( rel.relatedModel, id );
-						
-						if ( !model ) {
-							var attrs = {};
-							attrs[ rel.relatedModel.prototype.idAttribute ] = id;
-							model = rel.relatedModel.findOrCreate( attrs, options );
-							created.push( model );
-						}
-
-						return model;
-					}, this );
-				
-				// Try if the 'collection' can provide a url to fetch a set of models in one request.
-				if ( rel.related instanceof Backbone.Collection && _.isFunction( rel.related.url ) ) {
-					setUrl = rel.related.url( models );
-				}
-
-				// An assumption is that when 'Backbone.Collection.url' is a function, it can handle building of set urls.
-				// To make sure it can, test if the url we got by supplying a list of models to fetch is different from
-				// the one supplied for the default fetch action (without args to 'url').
-				if ( setUrl && setUrl !== rel.related.url() ) {
-					var opts = _.defaults(
-						{
-							error: function() {
-								var args = arguments;
-								_.each( created, function( model ) {
-									model.trigger( 'destroy', model, model.collection, options );
-									options.error && options.error.apply( model, args );
-								});
-							},
-							url: setUrl
-						},
-						options
-					);
-
-					requests = [ rel.related.fetch( opts ) ];
-				}
-				else {
-					requests = _.map( models, function( model ) {
-						var opts = _.defaults(
-							{
-								error: function() {
-									if ( _.contains( created, model ) ) {
-										model.trigger( 'destroy', model, model.collection, options );
-										options.error && options.error.apply( model, arguments );
-									}
-								}
-							},
-							options
-						);
-						return model.fetch( opts );
-					}, this );
-				}
-			}
-			
-			return requests;
-		},
-
-		get: function( attr ) {
-			var originalResult = Backbone.Model.prototype.get.call( this, attr );
-
-			// Use `originalResult` get if dotNotation not enabled or not required because no dot is in `attr`
-			if ( !this.dotNotation || attr.indexOf( '.' ) === -1 ) {
-				return originalResult;
-			}
-
-			// Go through all splits and return the final result
-			var splits = attr.split( '.' );
-			var result = _.reduce(splits, function( model, split ) {
-				if ( !( model instanceof Backbone.Model ) ) {
-					throw new Error( 'Attribute must be an instanceof Backbone.Model. Is: ' + model + ', currentSplit: ' + split );
-				}
-
-				return Backbone.Model.prototype.get.call( model, split );
-			}, this );
-
-			if ( originalResult !== undefined && result !== undefined ) {
-				throw new Error( "Ambiguous result for '" + attr + "'. direct result: " + originalResult + ", dotNotation: " + result );
-			}
-
-			return originalResult || result;
-		},
-
-		set: function( key, value, options ) {
-			Backbone.Relational.eventQueue.block();
-
-			// Duplicate backbone's behavior to allow separate key/value parameters, instead of a single 'attributes' object
-			var attributes;
-			if ( _.isObject( key ) || key == null ) {
-				attributes = key;
-				options = value;
-			}
-			else {
-				attributes = {};
-				attributes[ key ] = value;
-			}
-
-			try {
-				var id = this.id,
-					newId = attributes && this.idAttribute in attributes && attributes[ this.idAttribute ];
-
-				// Check if we're not setting a duplicate id before actually calling `set`.
-				Backbone.Relational.store.checkId( this, newId );
-
-				var result = Backbone.Model.prototype.set.apply( this, arguments );
-
-				// Ideal place to set up relations, if this is the first time we're here for this model
-				if ( !this._isInitialized && !this.isLocked() ) {
-					this.constructor.initializeModelHierarchy();
-					Backbone.Relational.store.register( this );
-					this.initializeRelations( options );
-				}
-				// The store should know about an `id` update asap
-				else if ( newId && newId !== id ) {
-					Backbone.Relational.store.update( this );
-				}
-
-				if ( attributes ) {
-					this.updateRelations( options );
-				}
-			}
-			finally {
-				// Try to run the global queue holding external events
-				Backbone.Relational.eventQueue.unblock();
-			}
-			
-			return result;
-		},
-
-		unset: function( attribute, options ) {
-			Backbone.Relational.eventQueue.block();
-
-			var result = Backbone.Model.prototype.unset.apply( this, arguments );
-			this.updateRelations( options );
-
-			// Try to run the global queue holding external events
-			Backbone.Relational.eventQueue.unblock();
-
-			return result;
-		},
-
-		clear: function( options ) {
-			Backbone.Relational.eventQueue.block();
-			
-			var result = Backbone.Model.prototype.clear.apply( this, arguments );
-			this.updateRelations( options );
-
-			// Try to run the global queue holding external events
-			Backbone.Relational.eventQueue.unblock();
-
-			return result;
-		},
-
-		clone: function() {
-			var attributes = _.clone( this.attributes );
-			if ( !_.isUndefined( attributes[ this.idAttribute ] ) ) {
-				attributes[ this.idAttribute ] = null;
-			}
-
-			_.each( this.getRelations(), function( rel ) {
-				delete attributes[ rel.key ];
-			});
-
-			return new this.constructor( attributes );
-		},
-
-		/**
-		 * Convert relations to JSON, omits them when required
-		 */
-		toJSON: function( options ) {
-			// If this Model has already been fully serialized in this branch once, return to avoid loops
-			if ( this.isLocked() ) {
-				return this.id;
-			}
-
-			this.acquire();
-			var json = Backbone.Model.prototype.toJSON.call( this, options );
-
-			if ( this.constructor._superModel && !( this.constructor._subModelTypeAttribute in json ) ) {
-				json[ this.constructor._subModelTypeAttribute ] = this.constructor._subModelTypeValue;
-			}
-
-			_.each( this._relations, function( rel ) {
-				var related = json[ rel.key ],
-					includeInJSON = rel.options.includeInJSON,
-					value = null;
-
-				if ( includeInJSON === true ) {
-					if ( related && _.isFunction( related.toJSON ) ) {
-						value = related.toJSON( options );
-					}
-				}
-				else if ( _.isString( includeInJSON ) ) {
-					if ( related instanceof Backbone.Collection ) {
-						value = related.pluck( includeInJSON );
-					}
-					else if ( related instanceof Backbone.Model ) {
-						value = related.get( includeInJSON );
-					}
-
-					// Add ids for 'unfound' models if includeInJSON is equal to (only) the relatedModel's `idAttribute`
-					if ( includeInJSON === rel.relatedModel.prototype.idAttribute ) {
-						if ( rel instanceof Backbone.HasMany ) {
-							value = value.concat( rel.keyIds );
-						}
-						else if  ( rel instanceof Backbone.HasOne ) {
-							value = value || rel.keyId;
-						}
-					}
-				}
-				else if ( _.isArray( includeInJSON ) ) {
-					if ( related instanceof Backbone.Collection ) {
-						value = [];
-						related.each( function( model ) {
-							var curJson = {};
-							_.each( includeInJSON, function( key ) {
-								curJson[ key ] = model.get( key );
-							});
-							value.push( curJson );
-						});
-					}
-					else if ( related instanceof Backbone.Model ) {
-						value = {};
-						_.each( includeInJSON, function( key ) {
-							value[ key ] = related.get( key );
-						});
-					}
-				}
-				else {
-					delete json[ rel.key ];
-				}
-
-				if ( includeInJSON ) {
-					json[ rel.keyDestination ] = value;
-				}
-
-				if ( rel.keyDestination !== rel.key ) {
-					delete json[ rel.key ];
-				}
-			});
-			
-			this.release();
-			return json;
-		}
-	},
-	{
-		/**
-		 *
-		 * @param superModel
-		 * @returns {Backbone.RelationalModel.constructor}
-		 */
-		setup: function( superModel ) {
-			// We don't want to share a relations array with a parent, as this will cause problems with
-			// reverse relations.
-			this.prototype.relations = ( this.prototype.relations || [] ).slice( 0 );
-
-			this._subModels = {};
-			this._superModel = null;
-
-			// If this model has 'subModelTypes' itself, remember them in the store
-			if ( this.prototype.hasOwnProperty( 'subModelTypes' ) ) {
-				Backbone.Relational.store.addSubModels( this.prototype.subModelTypes, this );
-			}
-			// The 'subModelTypes' property should not be inherited, so reset it.
-			else {
-				this.prototype.subModelTypes = null;
-			}
-
-			// Initialize all reverseRelations that belong to this new model.
-			_.each( this.prototype.relations || [], function( rel ) {
-				if ( !rel.model ) {
-					rel.model = this;
-				}
-				
-				if ( rel.reverseRelation && rel.model === this ) {
-					var preInitialize = true;
-					if ( _.isString( rel.relatedModel ) ) {
-						/**
-						 * The related model might not be defined for two reasons
-						 *  1. it is related to itself
-						 *  2. it never gets defined, e.g. a typo
-						 *  3. the model hasn't been defined yet, but will be later
-						 * In neither of these cases do we need to pre-initialize reverse relations.
-						 * However, for 3. (which is, to us, indistinguishable from 2.), we do need to attempt
-						 * setting up this relation again later, in case the related model is defined later.
-						 */
-						var relatedModel = Backbone.Relational.store.getObjectByName( rel.relatedModel );
-						preInitialize = relatedModel && ( relatedModel.prototype instanceof Backbone.RelationalModel );
-					}
-
-					if ( preInitialize ) {
-						Backbone.Relational.store.initializeRelation( null, rel );
-					}
-					else if ( _.isString( rel.relatedModel ) ) {
-						Backbone.Relational.store.addOrphanRelation( rel );
-					}
-				}
-			}, this );
-			
-			return this;
-		},
-
-		/**
-		 * Create a 'Backbone.Model' instance based on 'attributes'.
-		 * @param {Object} attributes
-		 * @param {Object} [options]
-		 * @return {Backbone.Model}
-		 */
-		build: function( attributes, options ) {
-			var model = this;
-
-			// 'build' is a possible entrypoint; it's possible no model hierarchy has been determined yet.
-			this.initializeModelHierarchy();
-
-			// Determine what type of (sub)model should be built if applicable.
-			// Lookup the proper subModelType in 'this._subModels'.
-			if ( this._subModels && this.prototype.subModelTypeAttribute in attributes ) {
-				var subModelTypeAttribute = attributes[ this.prototype.subModelTypeAttribute ];
-				var subModelType = this._subModels[ subModelTypeAttribute ];
-				if ( subModelType ) {
-					model = subModelType;
-				}
-			}
-			
-			return new model( attributes, options );
-		},
-
-		/**
-		 *
-		 */
-		initializeModelHierarchy: function() {
-			// If we're here for the first time, try to determine if this modelType has a 'superModel'.
-			if ( _.isUndefined( this._superModel ) || _.isNull( this._superModel ) ) {
-				Backbone.Relational.store.setupSuperModel( this );
-
-				// If a superModel has been found, copy relations from the _superModel if they haven't been
-				// inherited automatically (due to a redefinition of 'relations').
-				// Otherwise, make sure we don't get here again for this type by making '_superModel' false so we fail
-				// the isUndefined/isNull check next time.
-				if ( this._superModel && this._superModel.prototype.relations ) {
-					// Find relations that exist on the `_superModel`, but not yet on this model.
-					var inheritedRelations = _.select( this._superModel.prototype.relations || [], function( superRel ) {
-						return !_.any( this.prototype.relations || [], function( rel ) {
-							return superRel.relatedModel === rel.relatedModel && superRel.key === rel.key;
-						}, this );
-					}, this );
-
-					this.prototype.relations = inheritedRelations.concat( this.prototype.relations );
-				}
-				else {
-					this._superModel = false;
-				}
-			}
-
-			// If we came here through 'build' for a model that has 'subModelTypes', and not all of them have been resolved yet, try to resolve each.
-			if ( this.prototype.subModelTypes && _.keys( this.prototype.subModelTypes ).length !== _.keys( this._subModels ).length ) {
-				_.each( this.prototype.subModelTypes || [], function( subModelTypeName ) {
-					var subModelType = Backbone.Relational.store.getObjectByName( subModelTypeName );
-					subModelType && subModelType.initializeModelHierarchy();
-				});
-			}
-		},
-
-		/**
-		 * Find an instance of `this` type in 'Backbone.Relational.store'.
-		 * - If `attributes` is a string or a number, `findOrCreate` will just query the `store` and return a model if found.
-		 * - If `attributes` is an object and is found in the store, the model will be updated with `attributes` unless `options.update` is `false`.
-		 *   Otherwise, a new model is created with `attributes` (unless `options.create` is explicitly set to `false`).
-		 * @param {Object|String|Number} attributes Either a model's id, or the attributes used to create or update a model.
-		 * @param {Object} [options]
-		 * @param {Boolean} [options.create=true]
-		 * @param {Boolean} [options.merge=true]
-		 * @param {Boolean} [options.parse=false]
-		 * @return {Backbone.RelationalModel}
-		 */
-		findOrCreate: function( attributes, options ) {
-			options || ( options = {} );
-			var parsedAttributes = ( _.isObject( attributes ) && options.parse && this.prototype.parse ) ?
-				this.prototype.parse( attributes ) : attributes;
-
-			// Try to find an instance of 'this' model type in the store
-			var model = Backbone.Relational.store.find( this, parsedAttributes );
-
-			// If we found an instance, update it with the data in 'item' (unless 'options.merge' is false).
-			// If not, create an instance (unless 'options.create' is false).
-			if ( _.isObject( attributes ) ) {
-				if ( model && options.merge !== false ) {
-					// Make sure `options.collection` doesn't cascade to nested models
-					delete options.collection;
-
-					model.set( parsedAttributes, options );
-				}
-				else if ( !model && options.create !== false ) {
-					model = this.build( attributes, options );
-				}
-			}
-
-			return model;
-		}
-	});
-	_.extend( Backbone.RelationalModel.prototype, Backbone.Semaphore );
-
-	/**
-	 * Override Backbone.Collection._prepareModel, so objects will be built using the correct type
-	 * if the collection.model has subModels.
-	 * Attempts to find a model for `attrs` in Backbone.store through `findOrCreate`
-	 * (which sets the new properties on it if found), or instantiates a new model.
-	 */
-	Backbone.Collection.prototype.__prepareModel = Backbone.Collection.prototype._prepareModel;
-	Backbone.Collection.prototype._prepareModel = function ( attrs, options ) {
-		var model;
-		
-		if ( attrs instanceof Backbone.Model ) {
-			if ( !attrs.collection ) {
-				attrs.collection = this;
-			}
-			model = attrs;
-		}
-		else {
-			options || ( options = {} );
-			options.collection = this;
-			
-			if ( typeof this.model.findOrCreate !== 'undefined' ) {
-				model = this.model.findOrCreate( attrs, options );
-			}
-			else {
-				model = new this.model( attrs, options );
-			}
-			
-			if ( model && model.isNew() && !model._validate( attrs, options ) ) {
-				this.trigger( 'invalid', this, attrs, options );
-				model = false;
-			}
-		}
-		
-		return model;
-	};
-
-
-	/**
-	 * Override Backbone.Collection.set, so we'll create objects from attributes where required,
-	 * and update the existing models. Also, trigger 'relational:add'.
-	 */
-	var set = Backbone.Collection.prototype.__set = Backbone.Collection.prototype.set;
-	Backbone.Collection.prototype.set = function( models, options ) {
-		// Short-circuit if this Collection doesn't hold RelationalModels
-		if ( !( this.model.prototype instanceof Backbone.RelationalModel ) ) {
-			return set.apply( this, arguments );
-		}
-
-		if ( options && options.parse ) {
-			models = this.parse( models, options );
-		}
-
-		if ( !_.isArray( models ) ) {
-			models = models ? [ models ] : [];
-		}
-
-		var newModels = [],
-			toAdd = [];
-
-		//console.debug( 'calling add on coll=%o; model=%o, options=%o', this, models, options );
-		_.each( models, function( model ) {
-			if ( !( model instanceof Backbone.Model ) ) {
-				model = Backbone.Collection.prototype._prepareModel.call( this, model, options );
-			}
-
-			if ( model ) {
-				toAdd.push( model );
-
-				if ( !( this.get( model ) || this.get( model.cid ) ) ) {
-					newModels.push( model );
-				}
-				// If we arrive in `add` while performing a `set` (after a create, so the model gains an `id`),
-				// we may get here before `_onModelEvent` has had the chance to update `_byId`.
-				else if ( model.id != null ) {
-					this._byId[ model.id ] = model;
-				}
-			}
-		}, this );
-
-		// Add 'models' in a single batch, so the original add will only be called once (and thus 'sort', etc).
-		// If `parse` was specified, the collection and contained models have been parsed now.
-		set.call( this, toAdd, _.defaults( { parse: false }, options ) );
-
-		_.each( newModels, function( model ) {
-			// Fire a `relational:add` event for any model in `newModels` that has actually been added to the collection.
-			if ( this.get( model ) || this.get( model.cid ) ) {
-				this.trigger( 'relational:add', model, this, options );
-			}
-		}, this );
-		
-		return this;
-	};
-
-	/**
-	 * Override 'Backbone.Collection.remove' to trigger 'relational:remove'.
-	 */
-	var remove = Backbone.Collection.prototype.__remove = Backbone.Collection.prototype.remove;
-	Backbone.Collection.prototype.remove = function( models, options ) {
-		// Short-circuit if this Collection doesn't hold RelationalModels
-		if ( !( this.model.prototype instanceof Backbone.RelationalModel ) ) {
-			return remove.apply( this, arguments );
-		}
-
-		models = _.isArray( models ) ? models.slice() : [ models ];
-		options || ( options = {} );
-
-		var toRemove = [];
-
-		//console.debug('calling remove on coll=%o; models=%o, options=%o', this, models, options );
-		_.each( models, function( model ) {
-			model = this.get( model ) || this.get( model.cid );
-			model && toRemove.push( model );
-		}, this );
-
-		if ( toRemove.length ) {
-			remove.call( this, toRemove, options );
-
-			_.each( toRemove, function( model ) {
-				this.trigger('relational:remove', model, this, options);
-			}, this );
-		}
-		
-		return this;
-	};
-
-	/**
-	 * Override 'Backbone.Collection.reset' to trigger 'relational:reset'.
-	 */
-	var reset = Backbone.Collection.prototype.__reset = Backbone.Collection.prototype.reset;
-	Backbone.Collection.prototype.reset = function( models, options ) {
-		options = _.extend( { merge: true }, options );
-		reset.call( this, models, options );
-
-		if ( this.model.prototype instanceof Backbone.RelationalModel ) {
-			this.trigger( 'relational:reset', this, options );
-		}
-
-		return this;
-	};
-
-	/**
-	 * Override 'Backbone.Collection.sort' to trigger 'relational:reset'.
-	 */
-	var sort = Backbone.Collection.prototype.__sort = Backbone.Collection.prototype.sort;
-	Backbone.Collection.prototype.sort = function( options ) {
-		sort.call( this, options );
-
-		if ( this.model.prototype instanceof Backbone.RelationalModel ) {
-			this.trigger( 'relational:reset', this, options );
-		}
-
-		return this;
-	};
-
-	/**
-	 * Override 'Backbone.Collection.trigger' so 'add', 'remove' and 'reset' events are queued until relations
-	 * are ready.
-	 */
-	var trigger = Backbone.Collection.prototype.__trigger = Backbone.Collection.prototype.trigger;
-	Backbone.Collection.prototype.trigger = function( eventName ) {
-		// Short-circuit if this Collection doesn't hold RelationalModels
-		if ( !( this.model.prototype instanceof Backbone.RelationalModel ) ) {
-			return trigger.apply( this, arguments );
-		}
-
-		if ( eventName === 'add' || eventName === 'remove' || eventName === 'reset' ) {
-			var dit = this,
-				args = arguments;
-			
-			if ( _.isObject( args[ 3 ] ) ) {
-				args = _.toArray( args );
-				// the fourth argument is the option object.
-				// we need to clone it, as it could be modified while we wait on the eventQueue to be unblocked
-				args[ 3 ] = _.clone( args[ 3 ] );
-			}
-			
-			Backbone.Relational.eventQueue.add( function() {
-				trigger.apply( dit, args );
-			});
-		}
-		else {
-			trigger.apply( this, arguments );
-		}
-		
-		return this;
-	};
-
-	// Override .extend() to automatically call .setup()
-	Backbone.RelationalModel.extend = function( protoProps, classProps ) {
-		var child = Backbone.Model.extend.apply( this, arguments );
-		
-		child.setup( this );
-
-		return child;
-	};
-})();
--- a/src/hdalab/static/hdalab/lib/backbone.js	Fri Jul 18 13:29:53 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-(function(){var t=this;var e=t.Backbone;var i=[];var r=i.push;var s=i.slice;var n=i.splice;var a;if(typeof exports!=="undefined"){a=exports}else{a=t.Backbone={}}a.VERSION="1.0.0";var h=t._;if(!h&&typeof require!=="undefined")h=require("underscore");a.$=t.jQuery||t.Zepto||t.ender||t.$;a.noConflict=function(){t.Backbone=e;return this};a.emulateHTTP=false;a.emulateJSON=false;var o=a.Events={on:function(t,e,i){if(!l(this,"on",t,[e,i])||!e)return this;this._events||(this._events={});var r=this._events[t]||(this._events[t]=[]);r.push({callback:e,context:i,ctx:i||this});return this},once:function(t,e,i){if(!l(this,"once",t,[e,i])||!e)return this;var r=this;var s=h.once(function(){r.off(t,s);e.apply(this,arguments)});s._callback=e;return this.on(t,s,i)},off:function(t,e,i){var r,s,n,a,o,u,c,f;if(!this._events||!l(this,"off",t,[e,i]))return this;if(!t&&!e&&!i){this._events={};return this}a=t?[t]:h.keys(this._events);for(o=0,u=a.length;o<u;o++){t=a[o];if(n=this._events[t]){this._events[t]=r=[];if(e||i){for(c=0,f=n.length;c<f;c++){s=n[c];if(e&&e!==s.callback&&e!==s.callback._callback||i&&i!==s.context){r.push(s)}}}if(!r.length)delete this._events[t]}}return this},trigger:function(t){if(!this._events)return this;var e=s.call(arguments,1);if(!l(this,"trigger",t,e))return this;var i=this._events[t];var r=this._events.all;if(i)c(i,e);if(r)c(r,arguments);return this},stopListening:function(t,e,i){var r=this._listeners;if(!r)return this;var s=!e&&!i;if(typeof e==="object")i=this;if(t)(r={})[t._listenerId]=t;for(var n in r){r[n].off(e,i,this);if(s)delete this._listeners[n]}return this}};var u=/\s+/;var l=function(t,e,i,r){if(!i)return true;if(typeof i==="object"){for(var s in i){t[e].apply(t,[s,i[s]].concat(r))}return false}if(u.test(i)){var n=i.split(u);for(var a=0,h=n.length;a<h;a++){t[e].apply(t,[n[a]].concat(r))}return false}return true};var c=function(t,e){var i,r=-1,s=t.length,n=e[0],a=e[1],h=e[2];switch(e.length){case 0:while(++r<s)(i=t[r]).callback.call(i.ctx);return;case 1:while(++r<s)(i=t[r]).callback.call(i.ctx,n);return;case 2:while(++r<s)(i=t[r]).callback.call(i.ctx,n,a);return;case 3:while(++r<s)(i=t[r]).callback.call(i.ctx,n,a,h);return;default:while(++r<s)(i=t[r]).callback.apply(i.ctx,e)}};var f={listenTo:"on",listenToOnce:"once"};h.each(f,function(t,e){o[e]=function(e,i,r){var s=this._listeners||(this._listeners={});var n=e._listenerId||(e._listenerId=h.uniqueId("l"));s[n]=e;if(typeof i==="object")r=this;e[t](i,r,this);return this}});o.bind=o.on;o.unbind=o.off;h.extend(a,o);var d=a.Model=function(t,e){var i;var r=t||{};e||(e={});this.cid=h.uniqueId("c");this.attributes={};h.extend(this,h.pick(e,p));if(e.parse)r=this.parse(r,e)||{};if(i=h.result(this,"defaults")){r=h.defaults({},r,i)}this.set(r,e);this.changed={};this.initialize.apply(this,arguments)};var p=["url","urlRoot","collection"];h.extend(d.prototype,o,{changed:null,validationError:null,idAttribute:"id",initialize:function(){},toJSON:function(t){return h.clone(this.attributes)},sync:function(){return a.sync.apply(this,arguments)},get:function(t){return this.attributes[t]},escape:function(t){return h.escape(this.get(t))},has:function(t){return this.get(t)!=null},set:function(t,e,i){var r,s,n,a,o,u,l,c;if(t==null)return this;if(typeof t==="object"){s=t;i=e}else{(s={})[t]=e}i||(i={});if(!this._validate(s,i))return false;n=i.unset;o=i.silent;a=[];u=this._changing;this._changing=true;if(!u){this._previousAttributes=h.clone(this.attributes);this.changed={}}c=this.attributes,l=this._previousAttributes;if(this.idAttribute in s)this.id=s[this.idAttribute];for(r in s){e=s[r];if(!h.isEqual(c[r],e))a.push(r);if(!h.isEqual(l[r],e)){this.changed[r]=e}else{delete this.changed[r]}n?delete c[r]:c[r]=e}if(!o){if(a.length)this._pending=true;for(var f=0,d=a.length;f<d;f++){this.trigger("change:"+a[f],this,c[a[f]],i)}}if(u)return this;if(!o){while(this._pending){this._pending=false;this.trigger("change",this,i)}}this._pending=false;this._changing=false;return this},unset:function(t,e){return this.set(t,void 0,h.extend({},e,{unset:true}))},clear:function(t){var e={};for(var i in this.attributes)e[i]=void 0;return this.set(e,h.extend({},t,{unset:true}))},hasChanged:function(t){if(t==null)return!h.isEmpty(this.changed);return h.has(this.changed,t)},changedAttributes:function(t){if(!t)return this.hasChanged()?h.clone(this.changed):false;var e,i=false;var r=this._changing?this._previousAttributes:this.attributes;for(var s in t){if(h.isEqual(r[s],e=t[s]))continue;(i||(i={}))[s]=e}return i},previous:function(t){if(t==null||!this._previousAttributes)return null;return this._previousAttributes[t]},previousAttributes:function(){return h.clone(this._previousAttributes)},fetch:function(t){t=t?h.clone(t):{};if(t.parse===void 0)t.parse=true;var e=this;var i=t.success;t.success=function(r){if(!e.set(e.parse(r,t),t))return false;if(i)i(e,r,t);e.trigger("sync",e,r,t)};R(this,t);return this.sync("read",this,t)},save:function(t,e,i){var r,s,n,a=this.attributes;if(t==null||typeof t==="object"){r=t;i=e}else{(r={})[t]=e}if(r&&(!i||!i.wait)&&!this.set(r,i))return false;i=h.extend({validate:true},i);if(!this._validate(r,i))return false;if(r&&i.wait){this.attributes=h.extend({},a,r)}if(i.parse===void 0)i.parse=true;var o=this;var u=i.success;i.success=function(t){o.attributes=a;var e=o.parse(t,i);if(i.wait)e=h.extend(r||{},e);if(h.isObject(e)&&!o.set(e,i)){return false}if(u)u(o,t,i);o.trigger("sync",o,t,i)};R(this,i);s=this.isNew()?"create":i.patch?"patch":"update";if(s==="patch")i.attrs=r;n=this.sync(s,this,i);if(r&&i.wait)this.attributes=a;return n},destroy:function(t){t=t?h.clone(t):{};var e=this;var i=t.success;var r=function(){e.trigger("destroy",e,e.collection,t)};t.success=function(s){if(t.wait||e.isNew())r();if(i)i(e,s,t);if(!e.isNew())e.trigger("sync",e,s,t)};if(this.isNew()){t.success();return false}R(this,t);var s=this.sync("delete",this,t);if(!t.wait)r();return s},url:function(){var t=h.result(this,"urlRoot")||h.result(this.collection,"url")||U();if(this.isNew())return t;return t+(t.charAt(t.length-1)==="/"?"":"/")+encodeURIComponent(this.id)},parse:function(t,e){return t},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return this.id==null},isValid:function(t){return this._validate({},h.extend(t||{},{validate:true}))},_validate:function(t,e){if(!e.validate||!this.validate)return true;t=h.extend({},this.attributes,t);var i=this.validationError=this.validate(t,e)||null;if(!i)return true;this.trigger("invalid",this,i,h.extend(e||{},{validationError:i}));return false}});var v=["keys","values","pairs","invert","pick","omit"];h.each(v,function(t){d.prototype[t]=function(){var e=s.call(arguments);e.unshift(this.attributes);return h[t].apply(h,e)}});var g=a.Collection=function(t,e){e||(e={});if(e.url)this.url=e.url;if(e.model)this.model=e.model;if(e.comparator!==void 0)this.comparator=e.comparator;this._reset();this.initialize.apply(this,arguments);if(t)this.reset(t,h.extend({silent:true},e))};var m={add:true,remove:true,merge:true};var y={add:true,merge:false,remove:false};h.extend(g.prototype,o,{model:d,initialize:function(){},toJSON:function(t){return this.map(function(e){return e.toJSON(t)})},sync:function(){return a.sync.apply(this,arguments)},add:function(t,e){return this.set(t,h.defaults(e||{},y))},remove:function(t,e){t=h.isArray(t)?t.slice():[t];e||(e={});var i,r,s,n;for(i=0,r=t.length;i<r;i++){n=this.get(t[i]);if(!n)continue;delete this._byId[n.id];delete this._byId[n.cid];s=this.indexOf(n);this.models.splice(s,1);this.length--;if(!e.silent){e.index=s;n.trigger("remove",n,this,e)}this._removeReference(n)}return this},set:function(t,e){e=h.defaults(e||{},m);if(e.parse)t=this.parse(t,e);if(!h.isArray(t))t=t?[t]:[];var i,s,a,o,u,l;var c=e.at;var f=this.comparator&&c==null&&e.sort!==false;var d=h.isString(this.comparator)?this.comparator:null;var p=[],v=[],g={};for(i=0,s=t.length;i<s;i++){if(!(a=this._prepareModel(t[i],e)))continue;if(u=this.get(a)){if(e.remove)g[u.cid]=true;if(e.merge){u.set(a.attributes,e);if(f&&!l&&u.hasChanged(d))l=true}}else if(e.add){p.push(a);a.on("all",this._onModelEvent,this);this._byId[a.cid]=a;if(a.id!=null)this._byId[a.id]=a}}if(e.remove){for(i=0,s=this.length;i<s;++i){if(!g[(a=this.models[i]).cid])v.push(a)}if(v.length)this.remove(v,e)}if(p.length){if(f)l=true;this.length+=p.length;if(c!=null){n.apply(this.models,[c,0].concat(p))}else{r.apply(this.models,p)}}if(l)this.sort({silent:true});if(e.silent)return this;for(i=0,s=p.length;i<s;i++){(a=p[i]).trigger("add",a,this,e)}if(l)this.trigger("sort",this,e);return this},reset:function(t,e){e||(e={});for(var i=0,r=this.models.length;i<r;i++){this._removeReference(this.models[i])}e.previousModels=this.models;this._reset();this.add(t,h.extend({silent:true},e));if(!e.silent)this.trigger("reset",this,e);return this},push:function(t,e){t=this._prepareModel(t,e);this.add(t,h.extend({at:this.length},e));return t},pop:function(t){var e=this.at(this.length-1);this.remove(e,t);return e},unshift:function(t,e){t=this._prepareModel(t,e);this.add(t,h.extend({at:0},e));return t},shift:function(t){var e=this.at(0);this.remove(e,t);return e},slice:function(t,e){return this.models.slice(t,e)},get:function(t){if(t==null)return void 0;return this._byId[t.id!=null?t.id:t.cid||t]},at:function(t){return this.models[t]},where:function(t,e){if(h.isEmpty(t))return e?void 0:[];return this[e?"find":"filter"](function(e){for(var i in t){if(t[i]!==e.get(i))return false}return true})},findWhere:function(t){return this.where(t,true)},sort:function(t){if(!this.comparator)throw new Error("Cannot sort a set without a comparator");t||(t={});if(h.isString(this.comparator)||this.comparator.length===1){this.models=this.sortBy(this.comparator,this)}else{this.models.sort(h.bind(this.comparator,this))}if(!t.silent)this.trigger("sort",this,t);return this},sortedIndex:function(t,e,i){e||(e=this.comparator);var r=h.isFunction(e)?e:function(t){return t.get(e)};return h.sortedIndex(this.models,t,r,i)},pluck:function(t){return h.invoke(this.models,"get",t)},fetch:function(t){t=t?h.clone(t):{};if(t.parse===void 0)t.parse=true;var e=t.success;var i=this;t.success=function(r){var s=t.reset?"reset":"set";i[s](r,t);if(e)e(i,r,t);i.trigger("sync",i,r,t)};R(this,t);return this.sync("read",this,t)},create:function(t,e){e=e?h.clone(e):{};if(!(t=this._prepareModel(t,e)))return false;if(!e.wait)this.add(t,e);var i=this;var r=e.success;e.success=function(s){if(e.wait)i.add(t,e);if(r)r(t,s,e)};t.save(null,e);return t},parse:function(t,e){return t},clone:function(){return new this.constructor(this.models)},_reset:function(){this.length=0;this.models=[];this._byId={}},_prepareModel:function(t,e){if(t instanceof d){if(!t.collection)t.collection=this;return t}e||(e={});e.collection=this;var i=new this.model(t,e);if(!i._validate(t,e)){this.trigger("invalid",this,t,e);return false}return i},_removeReference:function(t){if(this===t.collection)delete t.collection;t.off("all",this._onModelEvent,this)},_onModelEvent:function(t,e,i,r){if((t==="add"||t==="remove")&&i!==this)return;if(t==="destroy")this.remove(e,r);if(e&&t==="change:"+e.idAttribute){delete this._byId[e.previous(e.idAttribute)];if(e.id!=null)this._byId[e.id]=e}this.trigger.apply(this,arguments)}});var _=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","indexOf","shuffle","lastIndexOf","isEmpty","chain"];h.each(_,function(t){g.prototype[t]=function(){var e=s.call(arguments);e.unshift(this.models);return h[t].apply(h,e)}});var w=["groupBy","countBy","sortBy"];h.each(w,function(t){g.prototype[t]=function(e,i){var r=h.isFunction(e)?e:function(t){return t.get(e)};return h[t](this.models,r,i)}});var b=a.View=function(t){this.cid=h.uniqueId("view");this._configure(t||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()};var x=/^(\S+)\s*(.*)$/;var E=["model","collection","el","id","attributes","className","tagName","events"];h.extend(b.prototype,o,{tagName:"div",$:function(t){return this.$el.find(t)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();this.stopListening();return this},setElement:function(t,e){if(this.$el)this.undelegateEvents();this.$el=t instanceof a.$?t:a.$(t);this.el=this.$el[0];if(e!==false)this.delegateEvents();return this},delegateEvents:function(t){if(!(t||(t=h.result(this,"events"))))return this;this.undelegateEvents();for(var e in t){var i=t[e];if(!h.isFunction(i))i=this[t[e]];if(!i)continue;var r=e.match(x);var s=r[1],n=r[2];i=h.bind(i,this);s+=".delegateEvents"+this.cid;if(n===""){this.$el.on(s,i)}else{this.$el.on(s,n,i)}}return this},undelegateEvents:function(){this.$el.off(".delegateEvents"+this.cid);return this},_configure:function(t){if(this.options)t=h.extend({},h.result(this,"options"),t);h.extend(this,h.pick(t,E));this.options=t},_ensureElement:function(){if(!this.el){var t=h.extend({},h.result(this,"attributes"));if(this.id)t.id=h.result(this,"id");if(this.className)t["class"]=h.result(this,"className");var e=a.$("<"+h.result(this,"tagName")+">").attr(t);this.setElement(e,false)}else{this.setElement(h.result(this,"el"),false)}}});a.sync=function(t,e,i){var r=k[t];h.defaults(i||(i={}),{emulateHTTP:a.emulateHTTP,emulateJSON:a.emulateJSON});var s={type:r,dataType:"json"};if(!i.url){s.url=h.result(e,"url")||U()}if(i.data==null&&e&&(t==="create"||t==="update"||t==="patch")){s.contentType="application/json";s.data=JSON.stringify(i.attrs||e.toJSON(i))}if(i.emulateJSON){s.contentType="application/x-www-form-urlencoded";s.data=s.data?{model:s.data}:{}}if(i.emulateHTTP&&(r==="PUT"||r==="DELETE"||r==="PATCH")){s.type="POST";if(i.emulateJSON)s.data._method=r;var n=i.beforeSend;i.beforeSend=function(t){t.setRequestHeader("X-HTTP-Method-Override",r);if(n)return n.apply(this,arguments)}}if(s.type!=="GET"&&!i.emulateJSON){s.processData=false}if(s.type==="PATCH"&&window.ActiveXObject&&!(window.external&&window.external.msActiveXFilteringEnabled)){s.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var o=i.xhr=a.ajax(h.extend(s,i));e.trigger("request",e,o,i);return o};var k={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};a.ajax=function(){return a.$.ajax.apply(a.$,arguments)};var S=a.Router=function(t){t||(t={});if(t.routes)this.routes=t.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var $=/\((.*?)\)/g;var T=/(\(\?)?:\w+/g;var H=/\*\w+/g;var A=/[\-{}\[\]+?.,\\\^$|#\s]/g;h.extend(S.prototype,o,{initialize:function(){},route:function(t,e,i){if(!h.isRegExp(t))t=this._routeToRegExp(t);if(h.isFunction(e)){i=e;e=""}if(!i)i=this[e];var r=this;a.history.route(t,function(s){var n=r._extractParameters(t,s);i&&i.apply(r,n);r.trigger.apply(r,["route:"+e].concat(n));r.trigger("route",e,n);a.history.trigger("route",r,e,n)});return this},navigate:function(t,e){a.history.navigate(t,e);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=h.result(this,"routes");var t,e=h.keys(this.routes);while((t=e.pop())!=null){this.route(t,this.routes[t])}},_routeToRegExp:function(t){t=t.replace(A,"\\$&").replace($,"(?:$1)?").replace(T,function(t,e){return e?t:"([^/]+)"}).replace(H,"(.*?)");return new RegExp("^"+t+"$")},_extractParameters:function(t,e){var i=t.exec(e).slice(1);return h.map(i,function(t){return t?decodeURIComponent(t):null})}});var I=a.History=function(){this.handlers=[];h.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var N=/^[#\/]|\s+$/g;var P=/^\/+|\/+$/g;var O=/msie [\w.]+/;var C=/\/$/;I.started=false;h.extend(I.prototype,o,{interval:50,getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(t,e){if(t==null){if(this._hasPushState||!this._wantsHashChange||e){t=this.location.pathname;var i=this.root.replace(C,"");if(!t.indexOf(i))t=t.substr(i.length)}else{t=this.getHash()}}return t.replace(N,"")},start:function(t){if(I.started)throw new Error("Backbone.history has already been started");I.started=true;this.options=h.extend({},{root:"/"},this.options,t);this.root=this.options.root;this._wantsHashChange=this.options.hashChange!==false;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var e=this.getFragment();var i=document.documentMode;var r=O.exec(navigator.userAgent.toLowerCase())&&(!i||i<=7);this.root=("/"+this.root+"/").replace(P,"/");if(r&&this._wantsHashChange){this.iframe=a.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow;this.navigate(e)}if(this._hasPushState){a.$(window).on("popstate",this.checkUrl)}else if(this._wantsHashChange&&"onhashchange"in window&&!r){a.$(window).on("hashchange",this.checkUrl)}else if(this._wantsHashChange){this._checkUrlInterval=setInterval(this.checkUrl,this.interval)}this.fragment=e;var s=this.location;var n=s.pathname.replace(/[^\/]$/,"$&/")===this.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!n){this.fragment=this.getFragment(null,true);this.location.replace(this.root+this.location.search+"#"+this.fragment);return true}else if(this._wantsPushState&&this._hasPushState&&n&&s.hash){this.fragment=this.getHash().replace(N,"");this.history.replaceState({},document.title,this.root+this.fragment+s.search)}if(!this.options.silent)return this.loadUrl()},stop:function(){a.$(window).off("popstate",this.checkUrl).off("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);I.started=false},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if(e===this.fragment&&this.iframe){e=this.getFragment(this.getHash(this.iframe))}if(e===this.fragment)return false;if(this.iframe)this.navigate(e);this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(t){var e=this.fragment=this.getFragment(t);var i=h.any(this.handlers,function(t){if(t.route.test(e)){t.callback(e);return true}});return i},navigate:function(t,e){if(!I.started)return false;if(!e||e===true)e={trigger:e};t=this.getFragment(t||"");if(this.fragment===t)return;this.fragment=t;var i=this.root+t;if(this._hasPushState){this.history[e.replace?"replaceState":"pushState"]({},document.title,i)}else if(this._wantsHashChange){this._updateHash(this.location,t,e.replace);if(this.iframe&&t!==this.getFragment(this.getHash(this.iframe))){if(!e.replace)this.iframe.document.open().close();this._updateHash(this.iframe.location,t,e.replace)}}else{return this.location.assign(i)}if(e.trigger)this.loadUrl(t)},_updateHash:function(t,e,i){if(i){var r=t.href.replace(/(javascript:|#).*$/,"");t.replace(r+"#"+e)}else{t.hash="#"+e}}});a.history=new I;var j=function(t,e){var i=this;var r;if(t&&h.has(t,"constructor")){r=t.constructor}else{r=function(){return i.apply(this,arguments)}}h.extend(r,i,e);var s=function(){this.constructor=r};s.prototype=i.prototype;r.prototype=new s;if(t)h.extend(r.prototype,t);r.__super__=i.prototype;return r};d.extend=g.extend=S.extend=b.extend=I.extend=j;var U=function(){throw new Error('A "url" property or function must be specified')};var R=function(t,e){var i=e.error;e.error=function(r){if(i)i(t,r,e);t.trigger("error",t,r,e)}}}).call(this);
-/*
-//@ sourceMappingURL=backbone-min.map
-*/
\ No newline at end of file
--- a/src/hdalab/static/hdalab/lib/jquery.mousewheel.min.js	Fri Jul 18 13:29:53 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,201 +0,0 @@
-/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
- * Licensed under the MIT License (LICENSE.txt).
- *
- * Version: 3.1.9
- *
- * Requires: jQuery 1.2.2+
- */
-
-(function (factory) {
-    if ( typeof define === 'function' && define.amd ) {
-        // AMD. Register as an anonymous module.
-        define(['jquery'], factory);
-    } else if (typeof exports === 'object') {
-        // Node/CommonJS style for Browserify
-        module.exports = factory;
-    } else {
-        // Browser globals
-        factory(jQuery);
-    }
-}(function ($) {
-
-    var toFix  = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
-        toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
-                    ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
-        slice  = Array.prototype.slice,
-        nullLowestDeltaTimeout, lowestDelta;
-
-    if ( $.event.fixHooks ) {
-        for ( var i = toFix.length; i; ) {
-            $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
-        }
-    }
-
-    var special = $.event.special.mousewheel = {
-        version: '3.1.9',
-
-        setup: function() {
-            if ( this.addEventListener ) {
-                for ( var i = toBind.length; i; ) {
-                    this.addEventListener( toBind[--i], handler, false );
-                }
-            } else {
-                this.onmousewheel = handler;
-            }
-            // Store the line height and page height for this particular element
-            $.data(this, 'mousewheel-line-height', special.getLineHeight(this));
-            $.data(this, 'mousewheel-page-height', special.getPageHeight(this));
-        },
-
-        teardown: function() {
-            if ( this.removeEventListener ) {
-                for ( var i = toBind.length; i; ) {
-                    this.removeEventListener( toBind[--i], handler, false );
-                }
-            } else {
-                this.onmousewheel = null;
-            }
-        },
-
-        getLineHeight: function(elem) {
-            return parseInt($(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10);
-        },
-
-        getPageHeight: function(elem) {
-            return $(elem).height();
-        },
-
-        settings: {
-            adjustOldDeltas: true
-        }
-    };
-
-    $.fn.extend({
-        mousewheel: function(fn) {
-            return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
-        },
-
-        unmousewheel: function(fn) {
-            return this.unbind('mousewheel', fn);
-        }
-    });
-
-
-    function handler(event) {
-        var orgEvent   = event || window.event,
-            args       = slice.call(arguments, 1),
-            delta      = 0,
-            deltaX     = 0,
-            deltaY     = 0,
-            absDelta   = 0;
-        event = $.event.fix(orgEvent);
-        event.type = 'mousewheel';
-
-        // Old school scrollwheel delta
-        if ( 'detail'      in orgEvent ) { deltaY = orgEvent.detail * -1;      }
-        if ( 'wheelDelta'  in orgEvent ) { deltaY = orgEvent.wheelDelta;       }
-        if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY;      }
-        if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
-
-        // Firefox < 17 horizontal scrolling related to DOMMouseScroll event
-        if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
-            deltaX = deltaY * -1;
-            deltaY = 0;
-        }
-
-        // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
-        delta = deltaY === 0 ? deltaX : deltaY;
-
-        // New school wheel delta (wheel event)
-        if ( 'deltaY' in orgEvent ) {
-            deltaY = orgEvent.deltaY * -1;
-            delta  = deltaY;
-        }
-        if ( 'deltaX' in orgEvent ) {
-            deltaX = orgEvent.deltaX;
-            if ( deltaY === 0 ) { delta  = deltaX * -1; }
-        }
-
-        // No change actually happened, no reason to go any further
-        if ( deltaY === 0 && deltaX === 0 ) { return; }
-
-        // Need to convert lines and pages to pixels if we aren't already in pixels
-        // There are three delta modes:
-        //   * deltaMode 0 is by pixels, nothing to do
-        //   * deltaMode 1 is by lines
-        //   * deltaMode 2 is by pages
-        if ( orgEvent.deltaMode === 1 ) {
-            var lineHeight = $.data(this, 'mousewheel-line-height');
-            delta  *= lineHeight;
-            deltaY *= lineHeight;
-            deltaX *= lineHeight;
-        } else if ( orgEvent.deltaMode === 2 ) {
-            var pageHeight = $.data(this, 'mousewheel-page-height');
-            delta  *= pageHeight;
-            deltaY *= pageHeight;
-            deltaX *= pageHeight;
-        }
-
-        // Store lowest absolute delta to normalize the delta values
-        absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
-
-        if ( !lowestDelta || absDelta < lowestDelta ) {
-            lowestDelta = absDelta;
-
-            // Adjust older deltas if necessary
-            if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
-                lowestDelta /= 40;
-            }
-        }
-
-        // Adjust older deltas if necessary
-        if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
-            // Divide all the things by 40!
-            delta  /= 40;
-            deltaX /= 40;
-            deltaY /= 40;
-        }
-
-        // Get a whole, normalized value for the deltas
-        delta  = Math[ delta  >= 1 ? 'floor' : 'ceil' ](delta  / lowestDelta);
-        deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
-        deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
-
-        // Add information to the event object
-        event.deltaX = deltaX;
-        event.deltaY = deltaY;
-        event.deltaFactor = lowestDelta;
-        // Go ahead and set deltaMode to 0 since we converted to pixels
-        // Although this is a little odd since we overwrite the deltaX/Y
-        // properties with normalized deltas.
-        event.deltaMode = 0;
-
-        // Add event and delta to the front of the arguments
-        args.unshift(event, delta, deltaX, deltaY);
-
-        // Clearout lowestDelta after sometime to better
-        // handle multiple device types that give different
-        // a different lowestDelta
-        // Ex: trackpad = 3 and mouse wheel = 120
-        if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
-        nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
-
-        return ($.event.dispatch || $.event.handle).apply(this, args);
-    }
-
-    function nullLowestDelta() {
-        lowestDelta = null;
-    }
-
-    function shouldAdjustOldDeltas(orgEvent, absDelta) {
-        // If this is an older event and the delta is divisable by 120,
-        // then we are assuming that the browser is treating this as an
-        // older mouse wheel event and that we should divide the deltas
-        // by 40 to try and get a more usable deltaFactor.
-        // Side note, this actually impacts the reported scroll distance
-        // in older browsers and can cause scrolling to be slower than native.
-        // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
-        return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
-    }
-
-}));
--- a/src/hdalab/static/hdalab/lib/paper.js	Fri Jul 18 13:29:53 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12218 +0,0 @@
-/*!
- * Paper.js v0.9.15 - The Swiss Army Knife of Vector Graphics Scripting.
- * http://paperjs.org/
- *
- * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey
- * http://lehni.org/ & http://jonathanpuckey.com/
- *
- * Distributed under the MIT license. See LICENSE file for details.
- *
- * All rights reserved.
- *
- * Date: Sun Dec 1 23:54:52 2013 +0100
- *
- ***
- *
- * straps.js - Class inheritance library with support for bean-style accessors
- *
- * Copyright (c) 2006 - 2013 Juerg Lehni
- * http://lehni.org/
- *
- * Distributed under the MIT license.
- *
- ***
- *
- * acorn.js
- * http://marijnhaverbeke.nl/acorn/
- *
- * Acorn is a tiny, fast JavaScript parser written in JavaScript,
- * created by Marijn Haverbeke and released under an MIT license.
- *
- */
-
-var paper = new function(undefined) {
-
-var Base = new function() {
-	var hidden = /^(statics|generics|preserve|enumerable|prototype|toString|valueOf)$/,
-		slice = [].slice,
-
-		forEach = [].forEach || function(iter, bind) {
-			for (var i = 0, l = this.length; i < l; i++)
-				iter.call(bind, this[i], i, this);
-		},
-
-		forIn = function(iter, bind) {
-			for (var i in this)
-				if (this.hasOwnProperty(i))
-					iter.call(bind, this[i], i, this);
-		},
-
-		create = Object.create || function(proto) {
-			return { __proto__: proto };
-		},
-
-		describe = Object.getOwnPropertyDescriptor || function(obj, name) {
-			var get = obj.__lookupGetter__ && obj.__lookupGetter__(name);
-			return get
-					? { get: get, set: obj.__lookupSetter__(name),
-						enumerable: true, configurable: true }
-					: obj.hasOwnProperty(name)
-						? { value: obj[name], enumerable: true,
-							configurable: true, writable: true }
-						: null;
-		},
-
-		_define = Object.defineProperty || function(obj, name, desc) {
-			if ((desc.get || desc.set) && obj.__defineGetter__) {
-				if (desc.get)
-					obj.__defineGetter__(name, desc.get);
-				if (desc.set)
-					obj.__defineSetter__(name, desc.set);
-			} else {
-				obj[name] = desc.value;
-			}
-			return obj;
-		},
-
-		define = function(obj, name, desc) {
-			delete obj[name];
-			return _define(obj, name, desc);
-		};
-
-	function inject(dest, src, enumerable, base, preserve, generics) {
-		var beans;
-
-		function field(name, val, dontCheck, generics) {
-			var val = val || (val = describe(src, name))
-					&& (val.get ? val : val.value);
-			if (typeof val === 'string' && val[0] === '#')
-				val = dest[val.substring(1)] || val;
-			var isFunc = typeof val === 'function',
-				res = val,
-				prev = preserve || isFunc
-					? (val && val.get ? name in dest : dest[name]) : null,
-				bean;
-			if ((dontCheck || val !== undefined && src.hasOwnProperty(name))
-					&& (!preserve || !prev)) {
-				if (isFunc && prev)
-					val.base = prev;
-				if (isFunc && beans && val.length === 0
-						&& (bean = name.match(/^(get|is)(([A-Z])(.*))$/)))
-					beans.push([ bean[3].toLowerCase() + bean[4], bean[2] ]);
-				if (!res || isFunc || !res.get || typeof res.get !== 'function'
-						|| res.get.length !== 0)
-					res = { value: res, writable: true };
-				if ((describe(dest, name)
-						|| { configurable: true }).configurable) {
-					res.configurable = true;
-					res.enumerable = enumerable;
-				}
-				define(dest, name, res);
-			}
-			if (generics && isFunc && (!preserve || !generics[name])) {
-				generics[name] = function(bind) {
-					return bind && dest[name].apply(bind,
-							slice.call(arguments, 1));
-				};
-			}
-		}
-		if (src) {
-			beans = [];
-			for (var name in src)
-				if (src.hasOwnProperty(name) && !hidden.test(name))
-					field(name, null, true, generics);
-			field('toString');
-			field('valueOf');
-			for (var i = 0, l = beans.length; i < l; i++) {
-				var bean = beans[i],
-					part = bean[1];
-				field(bean[0], {
-					get: dest['get' + part] || dest['is' + part],
-					set: dest['set' + part]
-				}, true);
-			}
-		}
-		return dest;
-	}
-
-	function each(obj, iter, bind) {
-		if (obj)
-			('length' in obj && !obj.getLength
-					&& typeof obj.length === 'number'
-				? forEach
-				: forIn).call(obj, iter, bind = bind || obj);
-		return bind;
-	}
-
-	function copy(dest, source) {
-		for (var i in source)
-			if (source.hasOwnProperty(i))
-				dest[i] = source[i];
-		return dest;
-	}
-
-	function clone(obj) {
-		return copy(new obj.constructor(), obj);
-	}
-
-	return inject(function Base() {
-		for (var i = 0, l = arguments.length; i < l; i++)
-			copy(this, arguments[i]);
-	}, {
-		inject: function(src) {
-			if (src) {
-				var proto = this.prototype,
-					base = Object.getPrototypeOf(proto).constructor,
-					statics = src.statics === true ? src : src.statics;
-				if (statics != src)
-					inject(proto, src, src.enumerable, base && base.prototype,
-							src.preserve, src.generics && this);
-				inject(this, statics, true, base, src.preserve);
-			}
-			for (var i = 1, l = arguments.length; i < l; i++)
-				this.inject(arguments[i]);
-			return this;
-		},
-
-		extend: function() {
-			var base = this,
-				ctor;
-			for (var i = 0, l = arguments.length; i < l; i++)
-				if (ctor = arguments[i].initialize)
-					break;
-			ctor = ctor || function() {
-				base.apply(this, arguments);
-			};
-			ctor.prototype = create(this.prototype);
-			define(ctor.prototype, 'constructor',
-					{ value: ctor, writable: true, configurable: true });
-			inject(ctor, this, true);
-			return arguments.length ? this.inject.apply(ctor, arguments) : ctor;
-		}
-	}, true).inject({
-		inject: function() {
-			for (var i = 0, l = arguments.length; i < l; i++)
-				inject(this, arguments[i], arguments[i].enumerable);
-			return this;
-		},
-
-		extend: function() {
-			var res = create(this);
-			return res.inject.apply(res, arguments);
-		},
-
-		each: function(iter, bind) {
-			return each(this, iter, bind);
-		},
-
-		clone: function() {
-			return new this.constructor(this);
-		},
-
-		statics: {
-			each: each,
-			create: create,
-			define: define,
-			describe: describe,
-			copy: copy,
-
-			clone: function(obj) {
-				return copy(new obj.constructor(), obj);
-			},
-
-			isPlainObject: function(obj) {
-				var ctor = obj != null && obj.constructor;
-				return ctor && (ctor === Object || ctor === Base
-						|| ctor.name === 'Object');
-			},
-
-			pick: function() {
-				for (var i = 0, l = arguments.length; i < l; i++)
-					if (arguments[i] !== undefined)
-						return arguments[i];
-				return null;
-			}
-		}
-	});
-};
-
-if (typeof module !== 'undefined')
-	module.exports = Base;
-
-Base.inject({
-	generics: true,
-
-	toString: function() {
-		return this._id != null
-			?  (this._class || 'Object') + (this._name
-				? " '" + this._name + "'"
-				: ' @' + this._id)
-			: '{ ' + Base.each(this, function(value, key) {
-				if (!/^_/.test(key)) {
-					var type = typeof value;
-					this.push(key + ': ' + (type === 'number'
-							? Formatter.instance.number(value)
-							: type === 'string' ? "'" + value + "'" : value));
-				}
-			}, []).join(', ') + ' }';
-	},
-
-	exportJSON: function(options) {
-		return Base.exportJSON(this, options);
-	},
-
-	toJSON: function() {
-		return Base.serialize(this);
-	},
-
-	_set: function(props, exclude) {
-		if (props && Base.isPlainObject(props)) {
-			var orig = props._filtering || props;
-			for (var key in orig) {
-				if (key in this && orig.hasOwnProperty(key)
-						&& (!exclude || !exclude[key])) {
-					var value = props[key];
-					if (value !== undefined)
-						this[key] = value;
-				}
-			}
-			return true;
-		}
-	},
-
-	statics: {
-
-		exports: {},
-
-		extend: function extend() {
-			var res = extend.base.apply(this, arguments),
-				name = res.prototype._class;
-			if (name && !Base.exports[name])
-				Base.exports[name] = res;
-			return res;
-		},
-
-		equals: function(obj1, obj2) {
-			function checkKeys(o1, o2) {
-				for (var i in o1)
-					if (o1.hasOwnProperty(i) && !o2.hasOwnProperty(i))
-						return false;
-				return true;
-			}
-			if (obj1 === obj2)
-				return true;
-			if (obj1 && obj1.equals)
-				return obj1.equals(obj2);
-			if (obj2 && obj2.equals)
-				return obj2.equals(obj1);
-			if (Array.isArray(obj1) && Array.isArray(obj2)) {
-				if (obj1.length !== obj2.length)
-					return false;
-				for (var i = 0, l = obj1.length; i < l; i++) {
-					if (!Base.equals(obj1[i], obj2[i]))
-						return false;
-				}
-				return true;
-			}
-			if (obj1 && typeof obj1 === 'object'
-					&& obj2 && typeof obj2 === 'object') {
-				if (!checkKeys(obj1, obj2) || !checkKeys(obj2, obj1))
-					return false;
-				for (var i in obj1) {
-					if (obj1.hasOwnProperty(i) && !Base.equals(obj1[i], obj2[i]))
-						return false;
-				}
-				return true;
-			}
-			return false;
-		},
-
-		read: function(list, start, length, options) {
-			if (this === Base) {
-				var value = this.peek(list, start);
-				list._index++;
-				list.__read = 1;
-				return value;
-			}
-			var proto = this.prototype,
-				readIndex = proto._readIndex,
-				index = start || readIndex && list._index || 0;
-			if (!length)
-				length = list.length - index;
-			var obj = list[index];
-			if (obj instanceof this
-				|| options && options.readNull && obj == null && length <= 1) {
-				if (readIndex)
-					list._index = index + 1;
-				return obj && options && options.clone ? obj.clone() : obj;
-			}
-			obj = Base.create(this.prototype);
-			if (readIndex)
-				obj.__read = true;
-			if (options)
-				obj.__options = options;
-			obj = obj.initialize.apply(obj, index > 0 || length < list.length
-				? Array.prototype.slice.call(list, index, index + length)
-				: list) || obj;
-			if (readIndex) {
-				list._index = index + obj.__read;
-				list.__read = obj.__read;
-				delete obj.__read;
-				if (options)
-					delete obj.__options;
-			}
-			return obj;
-		},
-
-		peek: function(list, start) {
-			return list[list._index = start || list._index || 0];
-		},
-
-		readAll: function(list, start, options) {
-			var res = [], entry;
-			for (var i = start || 0, l = list.length; i < l; i++) {
-				res.push(Array.isArray(entry = list[i])
-						? this.read(entry, 0, 0, options)
-						: this.read(list, i, 1, options));
-			}
-			return res;
-		},
-
-		readNamed: function(list, name, start, length, options) {
-			var value = this.getNamed(list, name),
-				hasObject = value !== undefined;
-			if (hasObject) {
-				var filtered = list._filtered;
-				if (!filtered) {
-					filtered = list._filtered = Base.create(list[0]);
-					filtered._filtering = list[0];
-				}
-				filtered[name] = undefined;
-			}
-			return this.read(hasObject ? [value] : list, start, length, options);
-		},
-
-		getNamed: function(list, name) {
-			var arg = list[0];
-			if (list._hasObject === undefined)
-				list._hasObject = list.length === 1 && Base.isPlainObject(arg);
-			if (list._hasObject)
-				return name ? arg[name] : list._filtered || arg;
-		},
-
-		hasNamed: function(list, name) {
-			return !!this.getNamed(list, name);
-		},
-
-		isPlainValue: function(obj) {
-			return this.isPlainObject(obj) || Array.isArray(obj);
-		},
-
-		serialize: function(obj, options, compact, dictionary) {
-			options = options || {};
-
-			var root = !dictionary,
-				res;
-			if (root) {
-				options.formatter = new Formatter(options.precision);
-				dictionary = {
-					length: 0,
-					definitions: {},
-					references: {},
-					add: function(item, create) {
-						var id = '#' + item._id,
-							ref = this.references[id];
-						if (!ref) {
-							this.length++;
-							var res = create.call(item),
-								name = item._class;
-							if (name && res[0] !== name)
-								res.unshift(name);
-							this.definitions[id] = res;
-							ref = this.references[id] = [id];
-						}
-						return ref;
-					}
-				};
-			}
-			if (obj && obj._serialize) {
-				res = obj._serialize(options, dictionary);
-				var name = obj._class;
-				if (name && !compact && !res._compact && res[0] !== name)
-					res.unshift(name);
-			} else if (Array.isArray(obj)) {
-				res = [];
-				for (var i = 0, l = obj.length; i < l; i++)
-					res[i] = Base.serialize(obj[i], options, compact,
-							dictionary);
-				if (compact)
-					res._compact = true;
-			} else if (Base.isPlainObject(obj)) {
-				res = {};
-				for (var i in obj)
-					if (obj.hasOwnProperty(i))
-						res[i] = Base.serialize(obj[i], options, compact,
-								dictionary);
-			} else if (typeof obj === 'number') {
-				res = options.formatter.number(obj, options.precision);
-			} else {
-				res = obj;
-			}
-			return root && dictionary.length > 0
-					? [['dictionary', dictionary.definitions], res]
-					: res;
-		},
-
-		deserialize: function(json, create, _data) {
-			var res = json;
-			_data = _data || {};
-			if (Array.isArray(json)) {
-				var type = json[0],
-					isDictionary = type === 'dictionary';
-				if (!isDictionary) {
-					if (_data.dictionary && json.length == 1 && /^#/.test(type))
-						return _data.dictionary[type];
-					type = Base.exports[type];
-				}
-				res = [];
-				for (var i = type ? 1 : 0, l = json.length; i < l; i++)
-					res.push(Base.deserialize(json[i], create, _data));
-				if (isDictionary) {
-					_data.dictionary = res[0];
-				} else if (type) {
-					var args = res;
-					if (create) {
-						res = create(type, args);
-					} else {
-						res = Base.create(type.prototype);
-						type.apply(res, args);
-					}
-				}
-			} else if (Base.isPlainObject(json)) {
-				res = {};
-				for (var key in json)
-					res[key] = Base.deserialize(json[key], create, _data);
-			}
-			return res;
-		},
-
-		exportJSON: function(obj, options) {
-			return JSON.stringify(Base.serialize(obj, options));
-		},
-
-		importJSON: function(json, target) {
-			return Base.deserialize(
-					typeof json === 'string' ? JSON.parse(json) : json,
-					function(type, args) {
-						var obj = target && target.constructor === type
-								? target
-								: Base.create(type.prototype),
-							isTarget = obj === target;
-						if (args.length === 1 && obj instanceof Item
-								&& (!(obj instanceof Layer) || isTarget)) {
-							var arg = args[0];
-							if (Base.isPlainObject(arg))
-								arg.insert = false;
-						}
-						type.apply(obj, args);
-						if (isTarget)
-							target = null;
-						return obj;
-					});
-		},
-
-		splice: function(list, items, index, remove) {
-			var amount = items && items.length,
-				append = index === undefined;
-			index = append ? list.length : index;
-			if (index > list.length)
-				index = list.length;
-			for (var i = 0; i < amount; i++)
-				items[i]._index = index + i;
-			if (append) {
-				list.push.apply(list, items);
-				return [];
-			} else {
-				var args = [index, remove];
-				if (items)
-					args.push.apply(args, items);
-				var removed = list.splice.apply(list, args);
-				for (var i = 0, l = removed.length; i < l; i++)
-					delete removed[i]._index;
-				for (var i = index + amount, l = list.length; i < l; i++)
-					list[i]._index = i;
-				return removed;
-			}
-		},
-
-		capitalize: function(str) {
-			return str.replace(/\b[a-z]/g, function(match) {
-				return match.toUpperCase();
-			});
-		},
-
-		camelize: function(str) {
-			return str.replace(/-(.)/g, function(all, chr) {
-				return chr.toUpperCase();
-			});
-		},
-
-		hyphenate: function(str) {
-			return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
-		}
-	}
-});
-
-var Callback = {
-	attach: function(type, func) {
-		if (typeof type !== 'string') {
-			Base.each(type, function(value, key) {
-				this.attach(key, value);
-			}, this);
-			return;
-		}
-		var entry = this._eventTypes[type];
-		if (entry) {
-			var handlers = this._handlers = this._handlers || {};
-			handlers = handlers[type] = handlers[type] || [];
-			if (handlers.indexOf(func) == -1) { 
-				handlers.push(func);
-				if (entry.install && handlers.length == 1)
-					entry.install.call(this, type);
-			}
-		}
-	},
-
-	detach: function(type, func) {
-		if (typeof type !== 'string') {
-			Base.each(type, function(value, key) {
-				this.detach(key, value);
-			}, this);
-			return;
-		}
-		var entry = this._eventTypes[type],
-			handlers = this._handlers && this._handlers[type],
-			index;
-		if (entry && handlers) {
-			if (!func || (index = handlers.indexOf(func)) != -1
-					&& handlers.length == 1) {
-				if (entry.uninstall)
-					entry.uninstall.call(this, type);
-				delete this._handlers[type];
-			} else if (index != -1) {
-				handlers.splice(index, 1);
-			}
-		}
-	},
-
-	once: function(type, func) {
-		this.attach(type, function() {
-			func.apply(this, arguments);
-			this.detach(type, func);
-		});
-	},
-
-	fire: function(type, event) {
-		var handlers = this._handlers && this._handlers[type];
-		if (!handlers)
-			return false;
-		var args = [].slice.call(arguments, 1),
-			PaperScript = paper.PaperScript,
-			handleException = PaperScript && PaperScript.handleException,
-			that = this;
-
-		function callHandlers() {
-			for (var i in handlers) {
-				if (handlers[i].apply(that, args) === false
-						&& event && event.stop)
-					event.stop();
-			}
-		}
-
-		if (handleException) {
-			try {
-				callHandlers();
-			} catch (e) {
-				handleException(e);
-			}
-		} else {
-			callHandlers();
-		}
-		return true;
-	},
-
-	responds: function(type) {
-		return !!(this._handlers && this._handlers[type]);
-	},
-
-	on: '#attach',
-	off: '#detach',
-	trigger: '#fire',
-
-	statics: {
-		inject: function inject() {
-			for (var i = 0, l = arguments.length; i < l; i++) {
-				var src = arguments[i],
-					events = src._events;
-				if (events) {
-					var types = {};
-					Base.each(events, function(entry, key) {
-						var isString = typeof entry === 'string',
-							name = isString ? entry : key,
-							part = Base.capitalize(name),
-							type = name.substring(2).toLowerCase();
-						types[type] = isString ? {} : entry;
-						name = '_' + name;
-						src['get' + part] = function() {
-							return this[name];
-						};
-						src['set' + part] = function(func) {
-							if (func) {
-								this.attach(type, func);
-							} else if (this[name]) {
-								this.detach(type, this[name]);
-							}
-							this[name] = func;
-						};
-					});
-					src._eventTypes = types;
-				}
-				inject.base.call(this, src);
-			}
-			return this;
-		}
-	}
-};
-
-var PaperScope = Base.extend({
-	_class: 'PaperScope',
-
-	initialize: function PaperScope(script) {
-		paper = this;
-		this.project = null;
-		this.projects = [];
-		this.tools = [];
-		this.palettes = [];
-		this._id = script && (script.getAttribute('id') || script.src)
-				|| ('paperscope-' + (PaperScope._id++));
-		if (script)
-			script.setAttribute('id', this._id);
-		PaperScope._scopes[this._id] = this;
-		if (!this.support) {
-			var ctx = CanvasProvider.getContext(1, 1);
-			PaperScope.prototype.support = {
-				nativeDash: 'setLineDash' in ctx || 'mozDash' in ctx,
-				nativeBlendModes: BlendMode.nativeModes
-			};
-			CanvasProvider.release(ctx);
-		}
-	},
-
-	version: '0.9.15',
-
-	getView: function() {
-		return this.project && this.project.view;
-	},
-
-	getTool: function() {
-		if (!this._tool)
-			this._tool = new Tool();
-		return this._tool;
-	},
-
-	getPaper: function() {
-		return this;
-	},
-
-	evaluate: function(code) {
-		var res = paper.PaperScript.evaluate(code, this);
-		View.updateFocus();
-		return res;
-	},
-
-	install: function(scope) {
-		var that = this;
-		Base.each(['project', 'view', 'tool'], function(key) {
-			Base.define(scope, key, {
-				configurable: true,
-				get: function() {
-					return that[key];
-				}
-			});
-		});
-		for (var key in this) {
-			if (!/^(version|_id)/.test(key))
-				scope[key] = this[key];
-		}
-	},
-
-	setup: function(canvas) {
-		paper = this;
-		this.project = new Project(canvas);
-		return this;
-	},
-
-	activate: function() {
-		paper = this;
-	},
-
-	clear: function() {
-		for (var i = this.projects.length - 1; i >= 0; i--)
-			this.projects[i].remove();
-		for (var i = this.tools.length - 1; i >= 0; i--)
-			this.tools[i].remove();
-		for (var i = this.palettes.length - 1; i >= 0; i--)
-			this.palettes[i].remove();
-	},
-
-	remove: function() {
-		this.clear();
-		delete PaperScope._scopes[this._id];
-	},
-
-	statics: new function() {
-		function handleAttribute(name) {
-			name += 'Attribute';
-			return function(el, attr) {
-				return el[name](attr) || el[name]('data-paper-' + attr);
-			};
-		}
-
-		return {
-			_scopes: {},
-			_id: 0,
-
-			get: function(id) {
-				if (typeof id === 'object')
-					id = id.getAttribute('id');
-				return this._scopes[id] || null;
-			},
-
-			getAttribute: handleAttribute('get'),
-			hasAttribute: handleAttribute('has')
-		};
-	}
-});
-
-var PaperScopeItem = Base.extend(Callback, {
-
-	initialize: function(activate) {
-		this._scope = paper;
-		this._index = this._scope[this._list].push(this) - 1;
-		if (activate || !this._scope[this._reference])
-			this.activate();
-	},
-
-	activate: function() {
-		if (!this._scope)
-			return false;
-		var prev = this._scope[this._reference];
-		if (prev && prev !== this)
-			prev.fire('deactivate');
-		this._scope[this._reference] = this;
-		this.fire('activate', prev);
-		return true;
-	},
-
-	isActive: function() {
-		return this._scope[this._reference] === this;
-	},
-
-	remove: function() {
-		if (this._index == null)
-			return false;
-		Base.splice(this._scope[this._list], null, this._index, 1);
-		if (this._scope[this._reference] == this)
-			this._scope[this._reference] = null;
-		this._scope = null;
-		return true;
-	}
-});
-
-var Formatter = Base.extend({
-	initialize: function(precision) {
-		this.precision = precision || 5;
-		this.multiplier = Math.pow(10, this.precision);
-	},
-
-	number: function(val) {
-		return Math.round(val * this.multiplier) / this.multiplier;
-	},
-
-	point: function(val, separator) {
-		return this.number(val.x) + (separator || ',') + this.number(val.y);
-	},
-
-	size: function(val, separator) {
-		return this.number(val.width) + (separator || ',')
-				+ this.number(val.height);
-	},
-
-	rectangle: function(val, separator) {
-		return this.point(val, separator) + (separator || ',')
-				+ this.size(val, separator);
-	}
-});
-
-Formatter.instance = new Formatter();
-
-var Numerical = new function() {
-
-	var abscissas = [
-		[  0.5773502691896257645091488],
-		[0,0.7745966692414833770358531],
-		[  0.3399810435848562648026658,0.8611363115940525752239465],
-		[0,0.5384693101056830910363144,0.9061798459386639927976269],
-		[  0.2386191860831969086305017,0.6612093864662645136613996,0.9324695142031520278123016],
-		[0,0.4058451513773971669066064,0.7415311855993944398638648,0.9491079123427585245261897],
-		[  0.1834346424956498049394761,0.5255324099163289858177390,0.7966664774136267395915539,0.9602898564975362316835609],
-		[0,0.3242534234038089290385380,0.6133714327005903973087020,0.8360311073266357942994298,0.9681602395076260898355762],
-		[  0.1488743389816312108848260,0.4333953941292471907992659,0.6794095682990244062343274,0.8650633666889845107320967,0.9739065285171717200779640],
-		[0,0.2695431559523449723315320,0.5190961292068118159257257,0.7301520055740493240934163,0.8870625997680952990751578,0.9782286581460569928039380],
-		[  0.1252334085114689154724414,0.3678314989981801937526915,0.5873179542866174472967024,0.7699026741943046870368938,0.9041172563704748566784659,0.9815606342467192506905491],
-		[0,0.2304583159551347940655281,0.4484927510364468528779129,0.6423493394403402206439846,0.8015780907333099127942065,0.9175983992229779652065478,0.9841830547185881494728294],
-		[  0.1080549487073436620662447,0.3191123689278897604356718,0.5152486363581540919652907,0.6872929048116854701480198,0.8272013150697649931897947,0.9284348836635735173363911,0.9862838086968123388415973],
-		[0,0.2011940939974345223006283,0.3941513470775633698972074,0.5709721726085388475372267,0.7244177313601700474161861,0.8482065834104272162006483,0.9372733924007059043077589,0.9879925180204854284895657],
-		[  0.0950125098376374401853193,0.2816035507792589132304605,0.4580167776572273863424194,0.6178762444026437484466718,0.7554044083550030338951012,0.8656312023878317438804679,0.9445750230732325760779884,0.9894009349916499325961542]
-	];
-
-	var weights = [
-		[1],
-		[0.8888888888888888888888889,0.5555555555555555555555556],
-		[0.6521451548625461426269361,0.3478548451374538573730639],
-		[0.5688888888888888888888889,0.4786286704993664680412915,0.2369268850561890875142640],
-		[0.4679139345726910473898703,0.3607615730481386075698335,0.1713244923791703450402961],
-		[0.4179591836734693877551020,0.3818300505051189449503698,0.2797053914892766679014678,0.1294849661688696932706114],
-		[0.3626837833783619829651504,0.3137066458778872873379622,0.2223810344533744705443560,0.1012285362903762591525314],
-		[0.3302393550012597631645251,0.3123470770400028400686304,0.2606106964029354623187429,0.1806481606948574040584720,0.0812743883615744119718922],
-		[0.2955242247147528701738930,0.2692667193099963550912269,0.2190863625159820439955349,0.1494513491505805931457763,0.0666713443086881375935688],
-		[0.2729250867779006307144835,0.2628045445102466621806889,0.2331937645919904799185237,0.1862902109277342514260976,0.1255803694649046246346943,0.0556685671161736664827537],
-		[0.2491470458134027850005624,0.2334925365383548087608499,0.2031674267230659217490645,0.1600783285433462263346525,0.1069393259953184309602547,0.0471753363865118271946160],
-		[0.2325515532308739101945895,0.2262831802628972384120902,0.2078160475368885023125232,0.1781459807619457382800467,0.1388735102197872384636018,0.0921214998377284479144218,0.0404840047653158795200216],
-		[0.2152638534631577901958764,0.2051984637212956039659241,0.1855383974779378137417166,0.1572031671581935345696019,0.1215185706879031846894148,0.0801580871597602098056333,0.0351194603317518630318329],
-		[0.2025782419255612728806202,0.1984314853271115764561183,0.1861610000155622110268006,0.1662692058169939335532009,0.1395706779261543144478048,0.1071592204671719350118695,0.0703660474881081247092674,0.0307532419961172683546284],
-		[0.1894506104550684962853967,0.1826034150449235888667637,0.1691565193950025381893121,0.1495959888165767320815017,0.1246289712555338720524763,0.0951585116824927848099251,0.0622535239386478928628438,0.0271524594117540948517806]
-	];
-
-	var abs = Math.abs,
-		sqrt = Math.sqrt,
-		pow = Math.pow,
-		cos = Math.cos,
-		PI = Math.PI;
-
-	return {
-		TOLERANCE: 10e-6,
-		EPSILON: 10e-12,
-		KAPPA: 4 * (sqrt(2) - 1) / 3,
-
-		isZero: function(val) {
-			return abs(val) <= Numerical.EPSILON;
-		},
-
-		integrate: function(f, a, b, n) {
-			var x = abscissas[n - 2],
-				w = weights[n - 2],
-				A = 0.5 * (b - a),
-				B = A + a,
-				i = 0,
-				m = (n + 1) >> 1,
-				sum = n & 1 ? w[i++] * f(B) : 0; 
-			while (i < m) {
-				var Ax = A * x[i];
-				sum += w[i++] * (f(B + Ax) + f(B - Ax));
-			}
-			return A * sum;
-		},
-
-		findRoot: function(f, df, x, a, b, n, tolerance) {
-			for (var i = 0; i < n; i++) {
-				var fx = f(x),
-					dx = fx / df(x);
-				if (abs(dx) < tolerance)
-					return x;
-				var nx = x - dx;
-				if (fx > 0) {
-					b = x;
-					x = nx <= a ? 0.5 * (a + b) : nx;
-				} else {
-					a = x;
-					x = nx >= b ? 0.5 * (a + b) : nx;
-				}
-			}
-		},
-
-		solveQuadratic: function(a, b, c, roots, min, max) {
-			var epsilon = Numerical.EPSILON,
-				unbound = min === undefined,
-				minE = min - epsilon,
-				maxE = max + epsilon,
-				count = 0;
-
-			function add(root) {
-				if (unbound || root > minE && root < maxE)
-					roots[count++] = root < min ? min : root > max ? max : root;
-				return count;
-			}
-
-			if (abs(a) < epsilon) {
-				if (abs(b) >= epsilon)
-					return add(-c / b);
-				return abs(c) < epsilon ? -1 : 0; 
-			}
-			var p = b / (2 * a);
-			var q = c / a;
-			var p2 = p * p;
-			if (p2 < q - epsilon)
-				return 0;
-			var s = p2 > q ? sqrt(p2 - q) : 0;
-			add (s - p);
-			if (s > 0)
-				add(-s - p);
-			return count;
-		},
-
-		solveCubic: function(a, b, c, d, roots, min, max) {
-			var epsilon = Numerical.EPSILON;
-			if (abs(a) < epsilon)
-				return Numerical.solveQuadratic(b, c, d, roots, min, max);
-
-			var unbound = min === undefined,
-				minE = min - epsilon,
-				maxE = max + epsilon,
-				count = 0;
-
-			function add(root) {
-				if (unbound || root > minE && root < maxE)
-					roots[count++] = root < min ? min : root > max ? max : root;
-				return count;
-			}
-
-			b /= a;
-			c /= a;
-			d /= a;
-			var bb = b * b,
-				p = (bb - 3 * c) / 9,
-				q = (2 * bb * b - 9 * b * c + 27 * d) / 54,
-				ppp = p * p * p,
-				D = q * q - ppp;
-			b /= 3;
-			if (abs(D) < epsilon) {
-				if (abs(q) < epsilon) 
-					return add(-b);
-				var sqp = sqrt(p),
-					snq = q > 0 ? 1 : -1;
-				add(-snq * 2 * sqp - b);
-				return add(snq * sqp - b);
-			}
-			if (D < 0) { 
-				var sqp = sqrt(p),
-					phi = Math.acos(q / (sqp * sqp * sqp)) / 3,
-					t = -2 * sqp,
-					o = 2 * PI / 3;
-				add(t * cos(phi) - b);
-				add(t * cos(phi + o) - b);
-				return add(t * cos(phi - o) - b);
-			}
-			var A = (q > 0 ? -1 : 1) * pow(abs(q) + sqrt(D), 1 / 3);
-			return add(A + p / A - b);
-		}
-	};
-};
-
-var Point = Base.extend({
-	_class: 'Point',
-	_readIndex: true,
-
-	initialize: function Point(arg0, arg1) {
-		var type = typeof arg0;
-		if (type === 'number') {
-			var hasY = typeof arg1 === 'number';
-			this.x = arg0;
-			this.y = hasY ? arg1 : arg0;
-			if (this.__read)
-				this.__read = hasY ? 2 : 1;
-		} else if (type === 'undefined' || arg0 === null) {
-			this.x = this.y = 0;
-			if (this.__read)
-				this.__read = arg0 === null ? 1 : 0;
-		} else {
-			if (Array.isArray(arg0)) {
-				this.x = arg0[0];
-				this.y = arg0.length > 1 ? arg0[1] : arg0[0];
-			} else if (arg0.x != null) {
-				this.x = arg0.x;
-				this.y = arg0.y;
-			} else if (arg0.width != null) {
-				this.x = arg0.width;
-				this.y = arg0.height;
-			} else if (arg0.angle != null) {
-				this.x = arg0.length;
-				this.y = 0;
-				this.setAngle(arg0.angle);
-			} else {
-				this.x = this.y = 0;
-				if (this.__read)
-					this.__read = 0;
-			}
-			if (this.__read)
-				this.__read = 1;
-		}
-	},
-
-	set: function(x, y) {
-		this.x = x;
-		this.y = y;
-		return this;
-	},
-
-	equals: function(point) {
-		return point === this || point && (this.x === point.x
-				&& this.y === point.y
-				|| Array.isArray(point) && this.x === point[0]
-					&& this.y === point[1]) || false;
-	},
-
-	clone: function() {
-		return new Point(this.x, this.y);
-	},
-
-	toString: function() {
-		var f = Formatter.instance;
-		return '{ x: ' + f.number(this.x) + ', y: ' + f.number(this.y) + ' }';
-	},
-
-	_serialize: function(options) {
-		var f = options.formatter;
-		return [f.number(this.x), f.number(this.y)];
-	},
-
-	add: function(point) {
-		point = Point.read(arguments);
-		return new Point(this.x + point.x, this.y + point.y);
-	},
-
-	subtract: function(point) {
-		point = Point.read(arguments);
-		return new Point(this.x - point.x, this.y - point.y);
-	},
-
-	multiply: function(point) {
-		point = Point.read(arguments);
-		return new Point(this.x * point.x, this.y * point.y);
-	},
-
-	divide: function(point) {
-		point = Point.read(arguments);
-		return new Point(this.x / point.x, this.y / point.y);
-	},
-
-	modulo: function(point) {
-		point = Point.read(arguments);
-		return new Point(this.x % point.x, this.y % point.y);
-	},
-
-	negate: function() {
-		return new Point(-this.x, -this.y);
-	},
-
-	transform: function(matrix) {
-		return matrix ? matrix._transformPoint(this) : this;
-	},
-
-	getDistance: function(point, squared) {
-		point = Point.read(arguments);
-		var x = point.x - this.x,
-			y = point.y - this.y,
-			d = x * x + y * y;
-		return squared ? d : Math.sqrt(d);
-	},
-
-	getLength: function() {
-		var length = this.x * this.x + this.y * this.y;
-		return arguments.length && arguments[0] ? length : Math.sqrt(length);
-	},
-
-	setLength: function(length) {
-		if (this.isZero()) {
-			var angle = this._angle || 0;
-			this.set(
-				Math.cos(angle) * length,
-				Math.sin(angle) * length
-			);
-		} else {
-			var scale = length / this.getLength();
-			if (Numerical.isZero(scale))
-				this.getAngle();
-			this.set(
-				this.x * scale,
-				this.y * scale
-			);
-		}
-		return this;
-	},
-
-	normalize: function(length) {
-		if (length === undefined)
-			length = 1;
-		var current = this.getLength(),
-			scale = current !== 0 ? length / current : 0,
-			point = new Point(this.x * scale, this.y * scale);
-		point._angle = this._angle;
-		return point;
-	},
-
-	getAngle: function() {
-		return this.getAngleInRadians(arguments[0]) * 180 / Math.PI;
-	},
-
-	setAngle: function(angle) {
-		angle = this._angle = angle * Math.PI / 180;
-		if (!this.isZero()) {
-			var length = this.getLength();
-			this.set(
-				Math.cos(angle) * length,
-				Math.sin(angle) * length
-			);
-		}
-		return this;
-	},
-
-	getAngleInRadians: function() {
-		if (arguments[0] === undefined) {
-			return this.isZero()
-					? this._angle || 0
-					: this._angle = Math.atan2(this.y, this.x);
-		} else {
-			var point = Point.read(arguments),
-				div = this.getLength() * point.getLength();
-			if (Numerical.isZero(div)) {
-				return NaN;
-			} else {
-				return Math.acos(this.dot(point) / div);
-			}
-		}
-	},
-
-	getAngleInDegrees: function() {
-		return this.getAngle(arguments[0]);
-	},
-
-	getQuadrant: function() {
-		return this.x >= 0 ? this.y >= 0 ? 1 : 4 : this.y >= 0 ? 2 : 3;
-	},
-
-	getDirectedAngle: function(point) {
-		point = Point.read(arguments);
-		return Math.atan2(this.cross(point), this.dot(point)) * 180 / Math.PI;
-	},
-
-	rotate: function(angle, center) {
-		if (angle === 0)
-			return this.clone();
-		angle = angle * Math.PI / 180;
-		var point = center ? this.subtract(center) : this,
-			s = Math.sin(angle),
-			c = Math.cos(angle);
-		point = new Point(
-			point.x * c - point.y * s,
-			point.y * c + point.x * s
-		);
-		return center ? point.add(center) : point;
-	},
-
-	isInside: function(rect) {
-		return rect.contains(this);
-	},
-
-	isClose: function(point, tolerance) {
-		return this.getDistance(point) < tolerance;
-	},
-
-	isColinear: function(point) {
-		return this.cross(point) < 0.00001;
-	},
-
-	isOrthogonal: function(point) {
-		return this.dot(point) < 0.00001;
-	},
-
-	isZero: function() {
-		return Numerical.isZero(this.x) && Numerical.isZero(this.y);
-	},
-
-	isNaN: function() {
-		return isNaN(this.x) || isNaN(this.y);
-	},
-
-	dot: function(point) {
-		point = Point.read(arguments);
-		return this.x * point.x + this.y * point.y;
-	},
-
-	cross: function(point) {
-		point = Point.read(arguments);
-		return this.x * point.y - this.y * point.x;
-	},
-
-	project: function(point) {
-		point = Point.read(arguments);
-		if (point.isZero()) {
-			return new Point(0, 0);
-		} else {
-			var scale = this.dot(point) / point.dot(point);
-			return new Point(
-				point.x * scale,
-				point.y * scale
-			);
-		}
-	},
-
-	statics: {
-		min: function() {
-			var point1 = Point.read(arguments);
-				point2 = Point.read(arguments);
-			return new Point(
-				Math.min(point1.x, point2.x),
-				Math.min(point1.y, point2.y)
-			);
-		},
-
-		max: function() {
-			var point1 = Point.read(arguments);
-				point2 = Point.read(arguments);
-			return new Point(
-				Math.max(point1.x, point2.x),
-				Math.max(point1.y, point2.y)
-			);
-		},
-
-		random: function() {
-			return new Point(Math.random(), Math.random());
-		}
-	}
-}, Base.each(['round', 'ceil', 'floor', 'abs'], function(name) {
-	var op = Math[name];
-	this[name] = function() {
-		return new Point(op(this.x), op(this.y));
-	};
-}, {}));
-
-var LinkedPoint = Point.extend({
-	initialize: function Point(x, y, owner, setter) {
-		this._x = x;
-		this._y = y;
-		this._owner = owner;
-		this._setter = setter;
-	},
-
-	set: function(x, y, _dontNotify) {
-		this._x = x;
-		this._y = y;
-		if (!_dontNotify)
-			this._owner[this._setter](this);
-		return this;
-	},
-
-	getX: function() {
-		return this._x;
-	},
-
-	setX: function(x) {
-		this._x = x;
-		this._owner[this._setter](this);
-	},
-
-	getY: function() {
-		return this._y;
-	},
-
-	setY: function(y) {
-		this._y = y;
-		this._owner[this._setter](this);
-	}
-});
-
-var Size = Base.extend({
-	_class: 'Size',
-	_readIndex: true,
-
-	initialize: function Size(arg0, arg1) {
-		var type = typeof arg0;
-		if (type === 'number') {
-			var hasHeight = typeof arg1 === 'number';
-			this.width = arg0;
-			this.height = hasHeight ? arg1 : arg0;
-			if (this.__read)
-				this.__read = hasHeight ? 2 : 1;
-		} else if (type === 'undefined' || arg0 === null) {
-			this.width = this.height = 0;
-			if (this.__read)
-				this.__read = arg0 === null ? 1 : 0;
-		} else {
-			if (Array.isArray(arg0)) {
-				this.width = arg0[0];
-				this.height = arg0.length > 1 ? arg0[1] : arg0[0];
-			} else if (arg0.width != null) {
-				this.width = arg0.width;
-				this.height = arg0.height;
-			} else if (arg0.x != null) {
-				this.width = arg0.x;
-				this.height = arg0.y;
-			} else {
-				this.width = this.height = 0;
-				if (this.__read)
-					this.__read = 0;
-			}
-			if (this.__read)
-				this.__read = 1;
-		}
-	},
-
-	set: function(width, height) {
-		this.width = width;
-		this.height = height;
-		return this;
-	},
-
-	equals: function(size) {
-		return size === this || size && (this.width === size.width
-				&& this.height === size.height
-				|| Array.isArray(size) && this.width === size[0]
-					&& this.height === size[1]) || false;
-	},
-
-	clone: function() {
-		return new Size(this.width, this.height);
-	},
-
-	toString: function() {
-		var f = Formatter.instance;
-		return '{ width: ' + f.number(this.width)
-				+ ', height: ' + f.number(this.height) + ' }';
-	},
-
-	_serialize: function(options) {
-		var f = options.formatter;
-		return [f.number(this.width),
-				f.number(this.height)];
-	},
-
-	add: function(size) {
-		size = Size.read(arguments);
-		return new Size(this.width + size.width, this.height + size.height);
-	},
-
-	subtract: function(size) {
-		size = Size.read(arguments);
-		return new Size(this.width - size.width, this.height - size.height);
-	},
-
-	multiply: function(size) {
-		size = Size.read(arguments);
-		return new Size(this.width * size.width, this.height * size.height);
-	},
-
-	divide: function(size) {
-		size = Size.read(arguments);
-		return new Size(this.width / size.width, this.height / size.height);
-	},
-
-	modulo: function(size) {
-		size = Size.read(arguments);
-		return new Size(this.width % size.width, this.height % size.height);
-	},
-
-	negate: function() {
-		return new Size(-this.width, -this.height);
-	},
-
-	isZero: function() {
-		return Numerical.isZero(this.width) && Numerical.isZero(this.height);
-	},
-
-	isNaN: function() {
-		return isNaN(this.width) || isNaN(this.height);
-	},
-
-	statics: {
-		min: function(size1, size2) {
-			return new Size(
-				Math.min(size1.width, size2.width),
-				Math.min(size1.height, size2.height));
-		},
-
-		max: function(size1, size2) {
-			return new Size(
-				Math.max(size1.width, size2.width),
-				Math.max(size1.height, size2.height));
-		},
-
-		random: function() {
-			return new Size(Math.random(), Math.random());
-		}
-	}
-}, Base.each(['round', 'ceil', 'floor', 'abs'], function(name) {
-	var op = Math[name];
-	this[name] = function() {
-		return new Size(op(this.width), op(this.height));
-	};
-}, {}));
-
-var LinkedSize = Size.extend({
-	initialize: function Size(width, height, owner, setter) {
-		this._width = width;
-		this._height = height;
-		this._owner = owner;
-		this._setter = setter;
-	},
-
-	set: function(width, height, _dontNotify) {
-		this._width = width;
-		this._height = height;
-		if (!_dontNotify)
-			this._owner[this._setter](this);
-		return this;
-	},
-
-	getWidth: function() {
-		return this._width;
-	},
-
-	setWidth: function(width) {
-		this._width = width;
-		this._owner[this._setter](this);
-	},
-
-	getHeight: function() {
-		return this._height;
-	},
-
-	setHeight: function(height) {
-		this._height = height;
-		this._owner[this._setter](this);
-	}
-});
-
-var Rectangle = Base.extend({
-	_class: 'Rectangle',
-	_readIndex: true,
-
-	initialize: function Rectangle(arg0, arg1, arg2, arg3) {
-		var type = typeof arg0,
-			read = 0;
-		if (type === 'number') {
-			this.x = arg0;
-			this.y = arg1;
-			this.width = arg2;
-			this.height = arg3;
-			read = 4;
-		} else if (type === 'undefined' || arg0 === null) {
-			this.x = this.y = this.width = this.height = 0;
-			read = arg0 === null ? 1 : 0;
-		} else if (arguments.length === 1) {
-			if (Array.isArray(arg0)) {
-				this.x = arg0[0];
-				this.y = arg0[1];
-				this.width = arg0[2];
-				this.height = arg0[3];
-				read = 1;
-			} else if (arg0.x !== undefined || arg0.width !== undefined) {
-				this.x = arg0.x || 0;
-				this.y = arg0.y || 0;
-				this.width = arg0.width || 0;
-				this.height = arg0.height || 0;
-				read = 1;
-			} else if (arg0.from === undefined && arg0.to === undefined) {
-				this.x = this.y = this.width = this.height = 0;
-				this._set(arg0);
-				read = 1;
-			}
-		}
-		if (!read) {
-			var point = Point.readNamed(arguments, 'from'),
-				next = Base.peek(arguments);
-			this.x = point.x;
-			this.y = point.y;
-			if (next && next.x !== undefined || Base.hasNamed(arguments, 'to')) {
-				var to = Point.readNamed(arguments, 'to');
-				this.width = to.x - point.x;
-				this.height = to.y - point.y;
-				if (this.width < 0) {
-					this.x = to.x;
-					this.width = -this.width;
-				}
-				if (this.height < 0) {
-					this.y = to.y;
-					this.height = -this.height;
-				}
-			} else {
-				var size = Size.read(arguments);
-				this.width = size.width;
-				this.height = size.height;
-			}
-			read = arguments._index;
-		}
-		if (this.__read)
-			this.__read = read;
-	},
-
-	set: function(x, y, width, height) {
-		this.x = x;
-		this.y = y;
-		this.width = width;
-		this.height = height;
-		return this;
-	},
-
-	clone: function() {
-		return new Rectangle(this.x, this.y, this.width, this.height);
-	},
-
-	equals: function(rect) {
-		if (Base.isPlainValue(rect))
-			rect = Rectangle.read(arguments);
-		return rect === this
-				|| rect && this.x === rect.x && this.y === rect.y
-					&& this.width === rect.width && this.height === rect.height
-				|| false;
-	},
-
-	toString: function() {
-		var f = Formatter.instance;
-		return '{ x: ' + f.number(this.x)
-				+ ', y: ' + f.number(this.y)
-				+ ', width: ' + f.number(this.width)
-				+ ', height: ' + f.number(this.height)
-				+ ' }';
-	},
-
-	_serialize: function(options) {
-		var f = options.formatter;
-		return [f.number(this.x),
-				f.number(this.y),
-				f.number(this.width),
-				f.number(this.height)];
-	},
-
-	getPoint: function() {
-		return new (arguments[0] ? Point : LinkedPoint)
-				(this.x, this.y, this, 'setPoint');
-	},
-
-	setPoint: function(point) {
-		point = Point.read(arguments);
-		this.x = point.x;
-		this.y = point.y;
-	},
-
-	getSize: function() {
-		return new (arguments[0] ? Size : LinkedSize)
-				(this.width, this.height, this, 'setSize');
-	},
-
-	setSize: function(size) {
-		size = Size.read(arguments);
-		if (this._fixX)
-			this.x += (this.width - size.width) * this._fixX;
-		if (this._fixY)
-			this.y += (this.height - size.height) * this._fixY;
-		this.width = size.width;
-		this.height = size.height;
-		this._fixW = 1;
-		this._fixH = 1;
-	},
-
-	getLeft: function() {
-		return this.x;
-	},
-
-	setLeft: function(left) {
-		if (!this._fixW)
-			this.width -= left - this.x;
-		this.x = left;
-		this._fixX = 0;
-	},
-
-	getTop: function() {
-		return this.y;
-	},
-
-	setTop: function(top) {
-		if (!this._fixH)
-			this.height -= top - this.y;
-		this.y = top;
-		this._fixY = 0;
-	},
-
-	getRight: function() {
-		return this.x + this.width;
-	},
-
-	setRight: function(right) {
-		if (this._fixX !== undefined && this._fixX !== 1)
-			this._fixW = 0;
-		if (this._fixW)
-			this.x = right - this.width;
-		else
-			this.width = right - this.x;
-		this._fixX = 1;
-	},
-
-	getBottom: function() {
-		return this.y + this.height;
-	},
-
-	setBottom: function(bottom) {
-		if (this._fixY !== undefined && this._fixY !== 1)
-			this._fixH = 0;
-		if (this._fixH)
-			this.y = bottom - this.height;
-		else
-			this.height = bottom - this.y;
-		this._fixY = 1;
-	},
-
-	getCenterX: function() {
-		return this.x + this.width * 0.5;
-	},
-
-	setCenterX: function(x) {
-		this.x = x - this.width * 0.5;
-		this._fixX = 0.5;
-	},
-
-	getCenterY: function() {
-		return this.y + this.height * 0.5;
-	},
-
-	setCenterY: function(y) {
-		this.y = y - this.height * 0.5;
-		this._fixY = 0.5;
-	},
-
-	getCenter: function() {
-		return new (arguments[0] ? Point : LinkedPoint)
-				(this.getCenterX(), this.getCenterY(), this, 'setCenter');
-	},
-
-	setCenter: function(point) {
-		point = Point.read(arguments);
-		this.setCenterX(point.x);
-		this.setCenterY(point.y);
-		return this;
-	},
-
-	isEmpty: function() {
-		return this.width == 0 || this.height == 0;
-	},
-
-	contains: function(arg) {
-		return arg && arg.width !== undefined
-				|| (Array.isArray(arg) ? arg : arguments).length == 4
-				? this._containsRectangle(Rectangle.read(arguments))
-				: this._containsPoint(Point.read(arguments));
-	},
-
-	_containsPoint: function(point) {
-		var x = point.x,
-			y = point.y;
-		return x >= this.x && y >= this.y
-				&& x <= this.x + this.width
-				&& y <= this.y + this.height;
-	},
-
-	_containsRectangle: function(rect) {
-		var x = rect.x,
-			y = rect.y;
-		return x >= this.x && y >= this.y
-				&& x + rect.width <= this.x + this.width
-				&& y + rect.height <= this.y + this.height;
-	},
-
-	intersects: function(rect) {
-		rect = Rectangle.read(arguments);
-		return rect.x + rect.width > this.x
-				&& rect.y + rect.height > this.y
-				&& rect.x < this.x + this.width
-				&& rect.y < this.y + this.height;
-	},
-
-	touches: function(rect) {
-		rect = Rectangle.read(arguments);
-		return rect.x + rect.width >= this.x
-				&& rect.y + rect.height >= this.y
-				&& rect.x <= this.x + this.width
-				&& rect.y <= this.y + this.height;
-	},
-
-	intersect: function(rect) {
-		rect = Rectangle.read(arguments);
-		var x1 = Math.max(this.x, rect.x),
-			y1 = Math.max(this.y, rect.y),
-			x2 = Math.min(this.x + this.width, rect.x + rect.width),
-			y2 = Math.min(this.y + this.height, rect.y + rect.height);
-		return new Rectangle(x1, y1, x2 - x1, y2 - y1);
-	},
-
-	unite: function(rect) {
-		rect = Rectangle.read(arguments);
-		var x1 = Math.min(this.x, rect.x),
-			y1 = Math.min(this.y, rect.y),
-			x2 = Math.max(this.x + this.width, rect.x + rect.width),
-			y2 = Math.max(this.y + this.height, rect.y + rect.height);
-		return new Rectangle(x1, y1, x2 - x1, y2 - y1);
-	},
-
-	include: function(point) {
-		point = Point.read(arguments);
-		var x1 = Math.min(this.x, point.x),
-			y1 = Math.min(this.y, point.y),
-			x2 = Math.max(this.x + this.width, point.x),
-			y2 = Math.max(this.y + this.height, point.y);
-		return new Rectangle(x1, y1, x2 - x1, y2 - y1);
-	},
-
-	expand: function(hor, ver) {
-		if (ver === undefined)
-			ver = hor;
-		return new Rectangle(this.x - hor / 2, this.y - ver / 2,
-				this.width + hor, this.height + ver);
-	},
-
-	scale: function(hor, ver) {
-		return this.expand(this.width * hor - this.width,
-				this.height * (ver === undefined ? hor : ver) - this.height);
-	}
-}, new function() {
-	return Base.each([
-			['Top', 'Left'], ['Top', 'Right'],
-			['Bottom', 'Left'], ['Bottom', 'Right'],
-			['Left', 'Center'], ['Top', 'Center'],
-			['Right', 'Center'], ['Bottom', 'Center']
-		],
-		function(parts, index) {
-			var part = parts.join('');
-			var xFirst = /^[RL]/.test(part);
-			if (index >= 4)
-				parts[1] += xFirst ? 'Y' : 'X';
-			var x = parts[xFirst ? 0 : 1],
-				y = parts[xFirst ? 1 : 0],
-				getX = 'get' + x,
-				getY = 'get' + y,
-				setX = 'set' + x,
-				setY = 'set' + y,
-				get = 'get' + part,
-				set = 'set' + part;
-			this[get] = function() {
-				return new (arguments[0] ? Point : LinkedPoint)
-						(this[getX](), this[getY](), this, set);
-			};
-			this[set] = function(point) {
-				point = Point.read(arguments);
-				this[setX](point.x);
-				this[setY](point.y);
-			};
-		}, {});
-});
-
-var LinkedRectangle = Rectangle.extend({
-	initialize: function Rectangle(x, y, width, height, owner, setter) {
-		this.set(x, y, width, height, true);
-		this._owner = owner;
-		this._setter = setter;
-	},
-
-	set: function(x, y, width, height, _dontNotify) {
-		this._x = x;
-		this._y = y;
-		this._width = width;
-		this._height = height;
-		if (!_dontNotify)
-			this._owner[this._setter](this);
-		return this;
-	}
-}, new function() {
-	var proto = Rectangle.prototype;
-
-	return Base.each(['x', 'y', 'width', 'height'], function(key) {
-		var part = Base.capitalize(key);
-		var internal = '_' + key;
-		this['get' + part] = function() {
-			return this[internal];
-		};
-
-		this['set' + part] = function(value) {
-			this[internal] = value;
-			if (!this._dontNotify)
-				this._owner[this._setter](this);
-		};
-	}, Base.each(['Point', 'Size', 'Center',
-			'Left', 'Top', 'Right', 'Bottom', 'CenterX', 'CenterY',
-			'TopLeft', 'TopRight', 'BottomLeft', 'BottomRight',
-			'LeftCenter', 'TopCenter', 'RightCenter', 'BottomCenter'],
-		function(key) {
-			var name = 'set' + key;
-			this[name] = function() {
-				this._dontNotify = true;
-				proto[name].apply(this, arguments);
-				delete this._dontNotify;
-				this._owner[this._setter](this);
-			};
-		}, {
-			isSelected: function() {
-				return this._owner._boundsSelected;
-			},
-
-			setSelected: function(selected) {
-				var owner = this._owner;
-				if (owner.setSelected) {
-					owner._boundsSelected = selected;
-					owner.setSelected(selected || owner._selectedSegmentState > 0);
-				}
-			}
-		})
-	);
-});
-
-var Matrix = Base.extend({
-	_class: 'Matrix',
-
-	initialize: function Matrix(arg) {
-		var count = arguments.length,
-			ok = true;
-		if (count === 6) {
-			this.set.apply(this, arguments);
-		} else if (count === 1) {
-			if (arg instanceof Matrix) {
-				this.set(arg._a, arg._c, arg._b, arg._d, arg._tx, arg._ty);
-			} else if (Array.isArray(arg)) {
-				this.set.apply(this, arg);
-			} else {
-				ok = false;
-			}
-		} else if (count === 0) {
-			this.reset();
-		} else {
-			ok = false;
-		}
-		if (!ok)
-			throw new Error('Unsupported matrix parameters');
-	},
-
-	set: function(a, c, b, d, tx, ty, _dontNotify) {
-		this._a = a;
-		this._c = c;
-		this._b = b;
-		this._d = d;
-		this._tx = tx;
-		this._ty = ty;
-		if (!_dontNotify)
-			this._changed();
-		return this;
-	},
-
-	_serialize: function(options) {
-		return Base.serialize(this.getValues(), options);
-	},
-
-	_changed: function() {
-		if (this._owner)
-			this._owner._changed(5);
-	},
-
-	clone: function() {
-		return new Matrix(this._a, this._c, this._b, this._d,
-				this._tx, this._ty);
-	},
-
-	equals: function(mx) {
-		return mx === this || mx && this._a === mx._a && this._b === mx._b
-				&& this._c === mx._c && this._d === mx._d
-				&& this._tx === mx._tx && this._ty === mx._ty
-				|| false;
-	},
-
-	toString: function() {
-		var f = Formatter.instance;
-		return '[[' + [f.number(this._a), f.number(this._b),
-					f.number(this._tx)].join(', ') + '], ['
-				+ [f.number(this._c), f.number(this._d),
-					f.number(this._ty)].join(', ') + ']]';
-	},
-
-	reset: function() {
-		this._a = this._d = 1;
-		this._c = this._b = this._tx = this._ty = 0;
-		this._changed();
-		return this;
-	},
-
-	scale: function() {
-		var scale = Point.read(arguments),
-			center = Point.read(arguments, 0, 0, { readNull: true });
-		if (center)
-			this.translate(center);
-		this._a *= scale.x;
-		this._c *= scale.x;
-		this._b *= scale.y;
-		this._d *= scale.y;
-		if (center)
-			this.translate(center.negate());
-		this._changed();
-		return this;
-	},
-
-	translate: function(point) {
-		point = Point.read(arguments);
-		var x = point.x,
-			y = point.y;
-		this._tx += x * this._a + y * this._b;
-		this._ty += x * this._c + y * this._d;
-		this._changed();
-		return this;
-	},
-
-	rotate: function(angle, center) {
-		center = Point.read(arguments, 1);
-		angle = angle * Math.PI / 180;
-		var x = center.x,
-			y = center.y,
-			cos = Math.cos(angle),
-			sin = Math.sin(angle),
-			tx = x - x * cos + y * sin,
-			ty = y - x * sin - y * cos,
-			a = this._a,
-			b = this._b,
-			c = this._c,
-			d = this._d;
-		this._a = cos * a + sin * b;
-		this._b = -sin * a + cos * b;
-		this._c = cos * c + sin * d;
-		this._d = -sin * c + cos * d;
-		this._tx += tx * a + ty * b;
-		this._ty += tx * c + ty * d;
-		this._changed();
-		return this;
-	},
-
-	shear: function() {
-		var point = Point.read(arguments),
-			center = Point.read(arguments, 0, 0, { readNull: true });
-		if (center)
-			this.translate(center);
-		var a = this._a,
-			c = this._c;
-		this._a += point.y * this._b;
-		this._c += point.y * this._d;
-		this._b += point.x * a;
-		this._d += point.x * c;
-		if (center)
-			this.translate(center.negate());
-		this._changed();
-		return this;
-	},
-
-	concatenate: function(mx) {
-		var a = this._a,
-			b = this._b,
-			c = this._c,
-			d = this._d;
-		this._a = mx._a * a + mx._c * b;
-		this._b = mx._b * a + mx._d * b;
-		this._c = mx._a * c + mx._c * d;
-		this._d = mx._b * c + mx._d * d;
-		this._tx += mx._tx * a + mx._ty * b;
-		this._ty += mx._tx * c + mx._ty * d;
-		this._changed();
-		return this;
-	},
-
-	preConcatenate: function(mx) {
-		var a = this._a,
-			b = this._b,
-			c = this._c,
-			d = this._d,
-			tx = this._tx,
-			ty = this._ty;
-		this._a = mx._a * a + mx._b * c;
-		this._b = mx._a * b + mx._b * d;
-		this._c = mx._c * a + mx._d * c;
-		this._d = mx._c * b + mx._d * d;
-		this._tx = mx._a * tx + mx._b * ty + mx._tx;
-		this._ty = mx._c * tx + mx._d * ty + mx._ty;
-		this._changed();
-		return this;
-	},
-
-	isIdentity: function() {
-		return this._a === 1 && this._c === 0 && this._b === 0 && this._d === 1
-				&& this._tx === 0 && this._ty === 0;
-	},
-
-	isInvertible: function() {
-		return !!this._getDeterminant();
-	},
-
-	isSingular: function() {
-		return !this._getDeterminant();
-	},
-
-	transform: function( src, srcOffset, dst, dstOffset, count) {
-		return arguments.length < 5
-			? this._transformPoint(Point.read(arguments))
-			: this._transformCoordinates(src, srcOffset, dst, dstOffset, count);
-	},
-
-	_transformPoint: function(point, dest, _dontNotify) {
-		var x = point.x,
-			y = point.y;
-		if (!dest)
-			dest = new Point();
-		return dest.set(
-			x * this._a + y * this._b + this._tx,
-			x * this._c + y * this._d + this._ty,
-			_dontNotify
-		);
-	},
-
-	_transformCoordinates: function(src, srcOffset, dst, dstOffset, count) {
-		var i = srcOffset,
-			j = dstOffset,
-			max = i + 2 * count;
-		while (i < max) {
-			var x = src[i++],
-				y = src[i++];
-			dst[j++] = x * this._a + y * this._b + this._tx;
-			dst[j++] = x * this._c + y * this._d + this._ty;
-		}
-		return dst;
-	},
-
-	_transformCorners: function(rect) {
-		var x1 = rect.x,
-			y1 = rect.y,
-			x2 = x1 + rect.width,
-			y2 = y1 + rect.height,
-			coords = [ x1, y1, x2, y1, x2, y2, x1, y2 ];
-		return this._transformCoordinates(coords, 0, coords, 0, 4);
-	},
-
-	_transformBounds: function(bounds, dest, _dontNotify) {
-		var coords = this._transformCorners(bounds),
-			min = coords.slice(0, 2),
-			max = coords.slice();
-		for (var i = 2; i < 8; i++) {
-			var val = coords[i],
-				j = i & 1;
-			if (val < min[j])
-				min[j] = val;
-			else if (val > max[j])
-				max[j] = val;
-		}
-		if (!dest)
-			dest = new Rectangle();
-		return dest.set(min[0], min[1], max[0] - min[0], max[1] - min[1],
-				_dontNotify);
-	},
-
-	inverseTransform: function() {
-		return this._inverseTransform(Point.read(arguments));
-	},
-
-	_getDeterminant: function() {
-		var det = this._a * this._d - this._b * this._c;
-		return isFinite(det) && !Numerical.isZero(det)
-				&& isFinite(this._tx) && isFinite(this._ty)
-				? det : null;
-	},
-
-	_inverseTransform: function(point, dest, _dontNotify) {
-		var det = this._getDeterminant();
-		if (!det)
-			return null;
-		var x = point.x - this._tx,
-			y = point.y - this._ty;
-		if (!dest)
-			dest = new Point();
-		return dest.set(
-			(x * this._d - y * this._b) / det,
-			(y * this._a - x * this._c) / det,
-			_dontNotify
-		);
-	},
-
-	decompose: function() {
-		var a = this._a, b = this._b, c = this._c, d = this._d;
-		if (Numerical.isZero(a * d - b * c))
-			return null;
-
-		var scaleX = Math.sqrt(a * a + b * b);
-		a /= scaleX;
-		b /= scaleX;
-
-		var shear = a * c + b * d;
-		c -= a * shear;
-		d -= b * shear;
-
-		var scaleY = Math.sqrt(c * c + d * d);
-		c /= scaleY;
-		d /= scaleY;
-		shear /= scaleY;
-
-		if (a * d < b * c) {
-			a = -a;
-			b = -b;
-			shear = -shear;
-			scaleX = -scaleX;
-		}
-
-		return {
-			translation: this.getTranslation(),
-			scaling: new Point(scaleX, scaleY),
-			rotation: -Math.atan2(b, a) * 180 / Math.PI,
-			shearing: shear
-		};
-	},
-
-	getValues: function() {
-		return [ this._a, this._c, this._b, this._d, this._tx, this._ty ];
-	},
-
-	getTranslation: function() {
-		return new Point(this._tx, this._ty);
-	},
-
-	setTranslation: function() {
-		var point = Point.read(arguments);
-		this._tx = point.x;
-		this._ty = point.y;
-		this._changed();
-	},
-
-	getScaling: function() {
-		return (this.decompose() || {}).scaling;
-	},
-
-	setScaling: function() {
-		var scaling = this.getScaling();
-		if (scaling != null) {
-			var scale = Point.read(arguments);
-			(this._owner || this).scale(
-					scale.x / scaling.x, scale.y / scaling.y);
-		}
-	},
-
-	getRotation: function() {
-		return (this.decompose() || {}).rotation;
-	},
-
-	setRotation: function(angle) {
-		var rotation = this.getRotation();
-		if (rotation != null)
-			(this._owner || this).rotate(angle - rotation);
-	},
-
-	inverted: function() {
-		var det = this._getDeterminant();
-		return det && new Matrix(
-				this._d / det,
-				-this._c / det,
-				-this._b / det,
-				this._a / det,
-				(this._b * this._ty - this._d * this._tx) / det,
-				(this._c * this._tx - this._a * this._ty) / det);
-	},
-
-	shiftless: function() {
-		return new Matrix(this._a, this._c, this._b, this._d, 0, 0);
-	},
-
-	applyToContext: function(ctx) {
-		ctx.transform(this._a, this._c, this._b, this._d, this._tx, this._ty);
-	}
-}, new function() {
-	return Base.each({
-		scaleX: '_a',
-		scaleY: '_d',
-		translateX: '_tx',
-		translateY: '_ty',
-		shearX: '_b',
-		shearY: '_c'
-	}, function(prop, name) {
-		name = Base.capitalize(name);
-		this['get' + name] = function() {
-			return this[prop];
-		};
-		this['set' + name] = function(value) {
-			this[prop] = value;
-			this._changed();
-		};
-	}, {});
-});
-
-var Line = Base.extend({
-	_class: 'Line',
-
-	initialize: function Line(arg0, arg1, arg2, arg3, arg4) {
-		var asVector = false;
-		if (arguments.length >= 4) {
-			this._px = arg0;
-			this._py = arg1;
-			this._vx = arg2;
-			this._vy = arg3;
-			asVector = arg4;
-		} else {
-			this._px = arg0.x;
-			this._py = arg0.y;
-			this._vx = arg1.x;
-			this._vy = arg1.y;
-			asVector = arg2;
-		}
-		if (!asVector) {
-			this._vx -= this._px;
-			this._vy -= this._py;
-		}
-	},
-
-	getPoint: function() {
-		return new Point(this._px, this._py);
-	},
-
-	getVector: function() {
-		return new Point(this._vx, this._vy);
-	},
-
-	getLength: function() {
-		return this.getVector().getLength();
-	},
-
-	intersect: function(line, isInfinite) {
-		return Line.intersect(
-				this._px, this._py, this._vx, this._vy,
-				line._px, line._py, line._vx, line._vy,
-				true, isInfinite);
-	},
-
-	getSide: function(point) {
-		return Line.getSide(
-				this._px, this._py, this._vx, this._vy,
-				point.x, point.y, true);
-	},
-
-	getDistance: function(point) {
-		return Math.abs(Line.getSignedDistance(
-				this._px, this._py, this._vx, this._vy,
-				point.x, point.y, true));
-	},
-
-	statics: {
-		intersect: function(apx, apy, avx, avy, bpx, bpy, bvx, bvy, asVector,
-				isInfinite) {
-			if (!asVector) {
-				avx -= apx;
-				avy -= apy;
-				bvx -= bpx;
-				bvy -= bpy;
-			}
-			var cross = bvy * avx - bvx * avy;
-			if (!Numerical.isZero(cross)) {
-				var dx = apx - bpx,
-					dy = apy - bpy,
-					ta = (bvx * dy - bvy * dx) / cross,
-					tb = (avx * dy - avy * dx) / cross;
-				if ((isInfinite || 0 <= ta && ta <= 1)
-						&& (isInfinite || 0 <= tb && tb <= 1))
-					return new Point(
-								apx + ta * avx,
-								apy + ta * avy);
-			}
-		},
-
-		getSide: function(px, py, vx, vy, x, y, asVector) {
-			if (!asVector) {
-				vx -= px;
-				vy -= py;
-			}
-			var v2x = x - px,
-				v2y = y - py,
-				ccw = v2x * vy - v2y * vx; 
-			if (ccw === 0) {
-				ccw = v2x * vx + v2y * vy; 
-				if (ccw > 0) {
-					v2x -= vx;
-					v2y -= vy;
-					ccw = v2x * vx + v2y * vy;
-					if (ccw < 0)
-						ccw = 0;
-				}
-			}
-			return ccw < 0 ? -1 : ccw > 0 ? 1 : 0;
-		},
-
-		getSignedDistance: function(px, py, vx, vy, x, y, asVector) {
-			if (!asVector) {
-				vx -= px;
-				vy -= py;
-			}
-			var m = vy / vx, 
-				b = py - m * px; 
-			return (y - (m * x) - b) / Math.sqrt(m * m + 1);
-		}
-	}
-});
-
-var Project = PaperScopeItem.extend({
-	_class: 'Project',
-	_list: 'projects',
-	_reference: 'project',
-
-	initialize: function Project(view) {
-		PaperScopeItem.call(this, true);
-		this.layers = [];
-		this.symbols = [];
-		this._currentStyle = new Style();
-		this.activeLayer = new Layer();
-		if (view)
-			this.view = view instanceof View ? view : View.create(view);
-		this._selectedItems = {};
-		this._selectedItemCount = 0;
-		this._drawCount = 0;
-		this.options = {};
-	},
-
-	_serialize: function(options, dictionary) {
-		return Base.serialize(this.layers, options, true, dictionary);
-	},
-
-	clear: function() {
-		for (var i = this.layers.length - 1; i >= 0; i--)
-			this.layers[i].remove();
-		this.symbols = [];
-	},
-
-	isEmpty: function() {
-		return this.layers.length <= 1
-			&& (!this.activeLayer || this.activeLayer.isEmpty());
-	},
-
-	remove: function remove() {
-		if (!remove.base.call(this))
-			return false;
-		if (this.view)
-			this.view.remove();
-		return true;
-	},
-
-	getCurrentStyle: function() {
-		return this._currentStyle;
-	},
-
-	setCurrentStyle: function(style) {
-		this._currentStyle.initialize(style);
-	},
-
-	getIndex: function() {
-		return this._index;
-	},
-
-	addChild: function(child) {
-		if (child instanceof Layer) {
-			Base.splice(this.layers, [child]);
-			if (!this.activeLayer)
-				this.activeLayer = child;
-		} else if (child instanceof Item) {
-			(this.activeLayer
-				|| this.addChild(new Layer({ insert: false }))).addChild(child);
-		} else {
-			child = null;
-		}
-		return child;
-	},
-
-	getSelectedItems: function() {
-		var items = [];
-		for (var id in this._selectedItems) {
-			var item = this._selectedItems[id];
-			if (item.isInserted())
-				items.push(item);
-		}
-		return items;
-	},
-
-	_updateSelection: function(item) {
-		var id = item._id,
-			selectedItems = this._selectedItems;
-		if (item._selected) {
-			if (selectedItems[id] !== item) {
-				this._selectedItemCount++;
-				selectedItems[id] = item;
-			}
-		} else if (selectedItems[id] === item) {
-			this._selectedItemCount--;
-			delete selectedItems[id];
-		}
-	},
-
-	selectAll: function() {
-		var layers = this.layers;
-		for (var i = 0, l = layers.length; i < l; i++)
-			layers[i].setFullySelected(true);
-	},
-
-	deselectAll: function() {
-		var selectedItems = this._selectedItems;
-		for (var i in selectedItems)
-			selectedItems[i].setFullySelected(false);
-	},
-
-	hitTest: function(point, options) {
-		point = Point.read(arguments);
-		options = HitResult.getOptions(Base.read(arguments));
-		for (var i = this.layers.length - 1; i >= 0; i--) {
-			var res = this.layers[i].hitTest(point, options);
-			if (res) return res;
-		}
-		return null;
-	}
-}, new function() {
-	function getItems(project, match, list) {
-		var layers = project.layers,
-			items = list && [];
-		for (var i = 0, l = layers.length; i < l; i++) {
-			var res = layers[i][list ? 'getItems' : 'getItem'](match);
-			if (list) {
-				items.push.apply(items, res);
-			} else if (res)
-				return res;
-		}
-		return list ? items : null;
-	}
-
-	return {
-		getItems: function(match) {
-			return getItems(this, match, true);
-		},
-
-		getItem: function(match) {
-			return getItems(this, match, false);
-		}
-	};
-}, {
-
-	importJSON: function(json) {
-		this.activate();
-		var layer = this.activeLayer;
-		return Base.importJSON(json, layer && layer.isEmpty() && layer);
-	},
-
-	draw: function(ctx, matrix, ratio) {
-		this._drawCount++;
-		ctx.save();
-		matrix.applyToContext(ctx);
-		var param = new Base({
-			offset: new Point(0, 0),
-			ratio: ratio,
-			transforms: [matrix],
-			trackTransforms: true
-		});
-		for (var i = 0, l = this.layers.length; i < l; i++)
-			this.layers[i].draw(ctx, param);
-		ctx.restore();
-
-		if (this._selectedItemCount > 0) {
-			ctx.save();
-			ctx.strokeWidth = 1;
-			for (var id in this._selectedItems) {
-				var item = this._selectedItems[id];
-				if (item._drawCount === this._drawCount
-						&& (item._drawSelected || item._boundsSelected)) {
-					var color = item.getSelectedColor()
-							|| item.getLayer().getSelectedColor();
-					ctx.strokeStyle = ctx.fillStyle = color
-							? color.toCanvasStyle(ctx) : '#009dec';
-					var mx = item._globalMatrix;
-					if (item._drawSelected)
-						item._drawSelected(ctx, mx);
-					if (item._boundsSelected) {
-						var coords = mx._transformCorners(
-								item._getBounds('getBounds'));
-						ctx.beginPath();
-						for (var i = 0; i < 8; i++)
-							ctx[i === 0 ? 'moveTo' : 'lineTo'](
-									coords[i], coords[++i]);
-						ctx.closePath();
-						ctx.stroke();
-						for (var i = 0; i < 8; i++) {
-							ctx.beginPath();
-							ctx.rect(coords[i] - 2, coords[++i] - 2, 4, 4);
-							ctx.fill();
-						}
-					}
-				}
-			}
-			ctx.restore();
-		}
-	}
-});
-
-var Symbol = Base.extend({
-	_class: 'Symbol',
-
-	initialize: function Symbol(item, dontCenter) {
-		this._id = Symbol._id = (Symbol._id || 0) + 1;
-		this.project = paper.project;
-		this.project.symbols.push(this);
-		if (item)
-			this.setDefinition(item, dontCenter);
-		this._instances = {};
-	},
-
-	_serialize: function(options, dictionary) {
-		return dictionary.add(this, function() {
-			return Base.serialize([this._class, this._definition],
-					options, false, dictionary);
-		});
-	},
-
-	_changed: function(flags) {
-		Base.each(this._instances, function(item) {
-			item._changed(flags);
-		});
-	},
-
-	getDefinition: function() {
-		return this._definition;
-	},
-
-	setDefinition: function(item ) {
-		if (item._parentSymbol)
-			item = item.clone();
-		if (this._definition)
-			delete this._definition._parentSymbol;
-		this._definition = item;
-		item.remove();
-		item.setSelected(false);
-		if (!arguments[1])
-			item.setPosition(new Point());
-		item._parentSymbol = this;
-		this._changed(5);
-	},
-
-	place: function(position) {
-		return new PlacedSymbol(this, position);
-	},
-
-	clone: function() {
-		return new Symbol(this._definition.clone(false));
-	}
-});
-
-var Item = Base.extend(Callback, {
-	statics: {
-		extend: function extend(src) {
-			if (src._serializeFields)
-				src._serializeFields = new Base(
-						this.prototype._serializeFields, src._serializeFields);
-			var res = extend.base.apply(this, arguments),
-				proto = res.prototype,
-				name = proto._class;
-			if (name)
-				proto._type = Base.hyphenate(name);
-			return res;
-		}
-	},
-
-	_class: 'Item',
-	_transformContent: true,
-	_boundsSelected: false,
-	_serializeFields: {
-		name: null,
-		matrix: new Matrix(),
-		locked: false,
-		visible: true,
-		blendMode: 'normal',
-		opacity: 1,
-		guide: false,
-		selected: false,
-		clipMask: false,
-		data: {}
-	},
-
-	initialize: function Item() {
-	},
-
-	_initialize: function(props, point) {
-		this._id = Item._id = (Item._id || 0) + 1;
-		if (!this._project) {
-			var project = paper.project;
-			if (props && props.insert === false) {
-				this._setProject(project);
-			} else {
-				(project.activeLayer || new Layer()).addChild(this);
-			}
-		}
-		this._style = new Style(this._project._currentStyle, this);
-		var matrix = this._matrix = new Matrix();
-		if (point)
-			matrix.translate(point);
-		matrix._owner = this;
-		return props ? this._set(props, { insert: true }) : true;
-	},
-
-	_events: new function() {
-
-		var mouseFlags = {
-			mousedown: {
-				mousedown: 1,
-				mousedrag: 1,
-				click: 1,
-				doubleclick: 1
-			},
-			mouseup: {
-				mouseup: 1,
-				mousedrag: 1,
-				click: 1,
-				doubleclick: 1
-			},
-			mousemove: {
-				mousedrag: 1,
-				mousemove: 1,
-				mouseenter: 1,
-				mouseleave: 1
-			}
-		};
-
-		var mouseEvent = {
-			install: function(type) {
-				var counters = this._project.view._eventCounters;
-				if (counters) {
-					for (var key in mouseFlags) {
-						counters[key] = (counters[key] || 0)
-								+ (mouseFlags[key][type] || 0);
-					}
-				}
-			},
-			uninstall: function(type) {
-				var counters = this._project.view._eventCounters;
-				if (counters) {
-					for (var key in mouseFlags)
-						counters[key] -= mouseFlags[key][type] || 0;
-				}
-			}
-		};
-
-		return Base.each(['onMouseDown', 'onMouseUp', 'onMouseDrag', 'onClick',
-			'onDoubleClick', 'onMouseMove', 'onMouseEnter', 'onMouseLeave'],
-			function(name) {
-				this[name] = mouseEvent;
-			}, {
-				onFrame: {
-					install: function() {
-						this._animateItem(true);
-					},
-					uninstall: function() {
-						this._animateItem(false);
-					}
-				},
-
-				onLoad: {}
-			}
-		);
-	},
-
-	_animateItem: function(animate) {
-		this._project.view._animateItem(this, animate);
-	},
-
-	_serialize: function(options, dictionary) {
-		var props = {},
-			that = this;
-
-		function serialize(fields) {
-			for (var key in fields) {
-				var value = that[key];
-				if (!Base.equals(value, key === 'leading'
-						? fields.fontSize * 1.2 : fields[key])) {
-					props[key] = Base.serialize(value, options,
-							key !== 'data', dictionary);
-				}
-			}
-		}
-
-		serialize(this._serializeFields);
-		if (!(this instanceof Group))
-			serialize(this._style._defaults);
-		return [ this._class, props ];
-	},
-
-	_changed: function(flags) {
-		var parent = this._parent,
-			project = this._project,
-			symbol = this._parentSymbol;
-		this._drawCount = null;
-		if (flags & 4) {
-			delete this._bounds;
-			delete this._position;
-		}
-		if (parent && (flags
-				& (4 | 8))) {
-			parent._clearBoundsCache();
-		}
-		if (flags & 2) {
-			this._clearBoundsCache();
-		}
-		if (project) {
-			if (flags & 1) {
-				project._needsRedraw = true;
-			}
-			if (project._changes) {
-				var entry = project._changesById[this._id];
-				if (entry) {
-					entry.flags |= flags;
-				} else {
-					entry = { item: this, flags: flags };
-					project._changesById[this._id] = entry;
-					project._changes.push(entry);
-				}
-			}
-		}
-		if (symbol)
-			symbol._changed(flags);
-	},
-
-	set: function(props) {
-		if (props)
-			this._set(props);
-		return this;
-	},
-
-	getId: function() {
-		return this._id;
-	},
-
-	getType: function() {
-		return this._type;
-	},
-
-	getName: function() {
-		return this._name;
-	},
-
-	setName: function(name, unique) {
-
-		if (this._name)
-			this._removeNamed();
-		if (name === (+name) + '')
-			throw new Error(
-					'Names consisting only of numbers are not supported.');
-		if (name && this._parent) {
-			var children = this._parent._children,
-				namedChildren = this._parent._namedChildren,
-				orig = name,
-				i = 1;
-			while (unique && children[name])
-				name = orig + ' ' + (i++);
-			(namedChildren[name] = namedChildren[name] || []).push(this);
-			children[name] = this;
-		}
-		this._name = name || undefined;
-		this._changed(32);
-	},
-
-	getStyle: function() {
-		return this._style;
-	},
-
-	setStyle: function(style) {
-		this.getStyle().set(style);
-	},
-
-	hasFill: function() {
-		return this.getStyle().hasFill();
-	},
-
-	hasStroke: function() {
-		return this.getStyle().hasStroke();
-	},
-
-	hasShadow: function() {
-		return this.getStyle().hasShadow();
-	}
-}, Base.each(['locked', 'visible', 'blendMode', 'opacity', 'guide'],
-	function(name) {
-		var part = Base.capitalize(name),
-			name = '_' + name;
-		this['get' + part] = function() {
-			return this[name];
-		};
-		this['set' + part] = function(value) {
-			if (value != this[name]) {
-				this[name] = value;
-				this._changed(name === '_locked'
-						? 32 : 33);
-			}
-		};
-}, {}), {
-
-	_locked: false,
-
-	_visible: true,
-
-	_blendMode: 'normal',
-
-	_opacity: 1,
-
-	_guide: false,
-
-	isSelected: function() {
-		if (this._children) {
-			for (var i = 0, l = this._children.length; i < l; i++)
-				if (this._children[i].isSelected())
-					return true;
-		}
-		return this._selected;
-	},
-
-	setSelected: function(selected ) {
-		if (this._children && !arguments[1]) {
-			for (var i = 0, l = this._children.length; i < l; i++)
-				this._children[i].setSelected(selected);
-		}
-		if ((selected = !!selected) != this._selected) {
-			this._selected = selected;
-			this._project._updateSelection(this);
-			this._changed(33);
-		}
-	},
-
-	_selected: false,
-
-	isFullySelected: function() {
-		if (this._children && this._selected) {
-			for (var i = 0, l = this._children.length; i < l; i++)
-				if (!this._children[i].isFullySelected())
-					return false;
-			return true;
-		}
-		return this._selected;
-	},
-
-	setFullySelected: function(selected) {
-		if (this._children) {
-			for (var i = 0, l = this._children.length; i < l; i++)
-				this._children[i].setFullySelected(selected);
-		}
-		this.setSelected(selected, true);
-	},
-
-	isClipMask: function() {
-		return this._clipMask;
-	},
-
-	setClipMask: function(clipMask) {
-		if (this._clipMask != (clipMask = !!clipMask)) {
-			this._clipMask = clipMask;
-			if (clipMask) {
-				this.setFillColor(null);
-				this.setStrokeColor(null);
-			}
-			this._changed(33);
-			if (this._parent)
-				this._parent._changed(256);
-		}
-	},
-
-	_clipMask: false,
-
-	getData: function() {
-		if (!this._data)
-			this._data = {};
-		return this._data;
-	},
-
-	setData: function(data) {
-		this._data = data;		
-	},
-
-	getPosition: function() {
-		var pos = this._position
-				|| (this._position = this.getBounds().getCenter(true));
-		return new (arguments[0] ? Point : LinkedPoint)
-				(pos.x, pos.y, this, 'setPosition');
-	},
-
-	setPosition: function() {
-		this.translate(Point.read(arguments).subtract(this.getPosition(true)));
-	}
-}, Base.each(['getBounds', 'getStrokeBounds', 'getHandleBounds', 'getRoughBounds'],
-	function(name) {
-		this[name] = function() {
-			var getter = this._boundsGetter,
-				bounds = this._getCachedBounds(typeof getter == 'string'
-						? getter : getter && getter[name] || name, arguments[0]);
-			return name === 'getBounds'
-					? new LinkedRectangle(bounds.x, bounds.y, bounds.width,
-							bounds.height, this, 'setBounds') 
-					: bounds;
-		};
-	},
-{
-	_getCachedBounds: function(getter, matrix, cacheItem) {
-		var cache = (!matrix || matrix.equals(this._matrix)) && getter;
-		if (cacheItem && this._parent) {
-			var id = cacheItem._id,
-				ref = this._parent._boundsCache
-					= this._parent._boundsCache || {
-				ids: {},
-				list: []
-			};
-			if (!ref.ids[id]) {
-				ref.list.push(cacheItem);
-				ref.ids[id] = cacheItem;
-			}
-		}
-		if (cache && this._bounds && this._bounds[cache])
-			return this._bounds[cache].clone();
-		var identity = this._matrix.isIdentity();
-		matrix = !matrix || matrix.isIdentity()
-				? identity ? null : this._matrix
-				: identity ? matrix : matrix.clone().concatenate(this._matrix);
-		var bounds = this._getBounds(getter, matrix, cache ? this : cacheItem);
-		if (cache) {
-			if (!this._bounds)
-				this._bounds = {};
-			this._bounds[cache] = bounds.clone();
-		}
-		return bounds;
-	},
-
-	_clearBoundsCache: function() {
-		if (this._boundsCache) {
-			for (var i = 0, list = this._boundsCache.list, l = list.length;
-					i < l; i++) {
-				var item = list[i];
-				delete item._bounds;
-				if (item != this && item._boundsCache)
-					item._clearBoundsCache();
-			}
-			delete this._boundsCache;
-		}
-	},
-
-	_getBounds: function(getter, matrix, cacheItem) {
-		var children = this._children;
-		if (!children || children.length == 0)
-			return new Rectangle();
-		var x1 = Infinity,
-			x2 = -x1,
-			y1 = x1,
-			y2 = x2;
-		for (var i = 0, l = children.length; i < l; i++) {
-			var child = children[i];
-			if (child._visible && !child.isEmpty()) {
-				var rect = child._getCachedBounds(getter, matrix, cacheItem);
-				x1 = Math.min(rect.x, x1);
-				y1 = Math.min(rect.y, y1);
-				x2 = Math.max(rect.x + rect.width, x2);
-				y2 = Math.max(rect.y + rect.height, y2);
-			}
-		}
-		return isFinite(x1)
-				? new Rectangle(x1, y1, x2 - x1, y2 - y1)
-				: new Rectangle();
-	},
-
-	setBounds: function(rect) {
-		rect = Rectangle.read(arguments);
-		var bounds = this.getBounds(),
-			matrix = new Matrix(),
-			center = rect.getCenter();
-		matrix.translate(center);
-		if (rect.width != bounds.width || rect.height != bounds.height) {
-			matrix.scale(
-					bounds.width != 0 ? rect.width / bounds.width : 1,
-					bounds.height != 0 ? rect.height / bounds.height : 1);
-		}
-		center = bounds.getCenter();
-		matrix.translate(-center.x, -center.y);
-		this.transform(matrix);
-	}
-
-}), {
-	getMatrix: function() {
-		return this._matrix;
-	},
-
-	setMatrix: function(matrix) {
-		this._matrix.initialize(matrix);
-		if (this._transformContent)
-			this.applyMatrix(true);
-		this._changed(5);
-	},
-
-	getGlobalMatrix: function() {
-		return this._drawCount === this._project._drawCount
-				&& this._globalMatrix || null;
-	},
-
-	getTransformContent: function() {
-		return this._transformContent;
-	},
-
-	setTransformContent: function(transform) {
-		this._transformContent = transform;
-		if (transform)
-			this.applyMatrix();
-	},
-
-	getProject: function() {
-		return this._project;
-	},
-
-	_setProject: function(project) {
-		if (this._project != project) {
-			var hasOnFrame = this.responds('frame');
-			if (hasOnFrame)
-				this._animateItem(false);
-			this._project = project;
-			if (hasOnFrame)
-				this._animateItem(true);
-			if (this._children) {
-				for (var i = 0, l = this._children.length; i < l; i++) {
-					this._children[i]._setProject(project);
-				}
-			}
-		}
-	},
-
-	getLayer: function() {
-		var parent = this;
-		while (parent = parent._parent) {
-			if (parent instanceof Layer)
-				return parent;
-		}
-		return null;
-	},
-
-	getParent: function() {
-		return this._parent;
-	},
-
-	setParent: function(item) {
-		return item.addChild(this);
-	},
-
-	getChildren: function() {
-		return this._children;
-	},
-
-	setChildren: function(items) {
-		this.removeChildren();
-		this.addChildren(items);
-	},
-
-	getFirstChild: function() {
-		return this._children && this._children[0] || null;
-	},
-
-	getLastChild: function() {
-		return this._children && this._children[this._children.length - 1]
-				|| null;
-	},
-
-	getNextSibling: function() {
-		return this._parent && this._parent._children[this._index + 1] || null;
-	},
-
-	getPreviousSibling: function() {
-		return this._parent && this._parent._children[this._index - 1] || null;
-	},
-
-	getIndex: function() {
-		return this._index;
-	},
-
-	isInserted: function() {
-		return this._parent ? this._parent.isInserted() : false;
-	},
-
-	equals: function(item) {
-		return item === this || item && this._class === item._class
-				&& this._style.equals(item._style) 
-				&& this._matrix.equals(item._matrix)
-				&& this._locked === item._locked
-				&& this._visible === item._visible
-				&& this._blendMode === item._blendMode
-				&& this._opacity === item._opacity
-				&& this._clipMask === item._clipMask
-				&& this._guide === item._guide
-				&& this._equals(item)
-				|| false;
-	},
-
-	_equals: function(item) {
-		return Base.equals(this._children, item._children);
-	},
-
-	clone: function(insert) {
-		return this._clone(new this.constructor({ insert: false }), insert);
-	},
-
-	_clone: function(copy, insert) {
-		copy.setStyle(this._style);
-		if (this._children) {
-			for (var i = 0, l = this._children.length; i < l; i++)
-				copy.addChild(this._children[i].clone(false), true);
-		}
-		if (insert || insert === undefined)
-			copy.insertAbove(this);
-		var keys = ['_locked', '_visible', '_blendMode', '_opacity',
-				'_clipMask', '_guide'];
-		for (var i = 0, l = keys.length; i < l; i++) {
-			var key = keys[i];
-			if (this.hasOwnProperty(key))
-				copy[key] = this[key];
-		}
-		copy._matrix.initialize(this._matrix);
-		copy._data = this._data ? Base.clone(this._data) : null;
-		copy.setSelected(this._selected);
-		if (this._name)
-			copy.setName(this._name, true);
-		return copy;
-	},
-
-	copyTo: function(itemOrProject) {
-		return itemOrProject.addChild(this.clone(false));
-	},
-
-	rasterize: function(resolution) {
-		var bounds = this.getStrokeBounds(),
-			scale = (resolution || 72) / 72,
-			topLeft = bounds.getTopLeft().floor(),
-			bottomRight = bounds.getBottomRight().ceil()
-			size = new Size(bottomRight.subtract(topLeft)),
-			canvas = CanvasProvider.getCanvas(size),
-			ctx = canvas.getContext('2d'),
-			matrix = new Matrix().scale(scale).translate(topLeft.negate());
-		ctx.save();
-		matrix.applyToContext(ctx);
-		this.draw(ctx, new Base({ transforms: [matrix] }));
-		ctx.restore();
-		var raster = new Raster({
-			canvas: canvas,
-			insert: false
-		});
-		raster.setPosition(topLeft.add(size.divide(2)));
-		raster.insertAbove(this);
-		return raster;
-	},
-
-	contains: function() {
-		return !!this._contains(
-				this._matrix._inverseTransform(Point.read(arguments)));
-	},
-
-	_contains: function(point) {
-		if (this._children) {
-			for (var i = this._children.length - 1; i >= 0; i--) {
-				if (this._children[i].contains(point))
-					return true;
-			}
-			return false;
-		}
-		return point.isInside(this._getBounds('getBounds'));
-	},
-
-	hitTest: function(point, options) {
-		point = Point.read(arguments);
-		options = HitResult.getOptions(Base.read(arguments));
-
-		if (this._locked || !this._visible || this._guide && !options.guides)
-			return null;
-
-		if (!this._children && !this.getRoughBounds()
-				.expand(2 * options.tolerance)._containsPoint(point))
-			return null;
-		point = this._matrix._inverseTransform(point);
-
-		var that = this,
-			res;
-		function checkBounds(type, part) {
-			var pt = bounds['get' + part]();
-			if (point.getDistance(pt) < options.tolerance)
-				return new HitResult(type, that,
-						{ name: Base.hyphenate(part), point: pt });
-		}
-
-		if ((options.center || options.bounds) &&
-				!(this instanceof Layer && !this._parent)) {
-			var bounds = this._getBounds('getBounds');
-			if (options.center)
-				res = checkBounds('center', 'Center');
-			if (!res && options.bounds) {
-				var points = [
-					'TopLeft', 'TopRight', 'BottomLeft', 'BottomRight',
-					'LeftCenter', 'TopCenter', 'RightCenter', 'BottomCenter'
-				];
-				for (var i = 0; i < 8 && !res; i++)
-					res = checkBounds('bounds', points[i]);
-			}
-		}
-
-		if ((res || (res = this._children || !(options.guides && !this._guide
-				|| options.selected && !this._selected)
-					? this._hitTest(point, options) : null))
-				&& res.point) {
-			res.point = that._matrix.transform(res.point);
-		}
-		return res;
-	},
-
-	_hitTest: function(point, options) {
-		var children = this._children;
-		if (children) {
-			for (var i = children.length - 1, res; i >= 0; i--)
-				if (res = children[i].hitTest(point, options))
-					return res;
-		} else if (options.fill && this.hasFill() && this._contains(point)) {
-			return new HitResult('fill', this);
-		}
-	},
-
-	matches: function(match) {
-		function matchObject(obj1, obj2) {
-			for (var i in obj1) {
-				if (obj1.hasOwnProperty(i)) {
-					var val1 = obj1[i],
-						val2 = obj2[i];
-					if (Base.isPlainObject(val1) && Base.isPlainObject(val2)) {
-						if (!matchObject(val1, val2))
-							return false;
-					} else if (!Base.equals(val1, val2)) {
-						return false;
-					}
-				}
-			}
-			return true;
-		}
-		for (var key in match) {
-			if (match.hasOwnProperty(key)) {
-				var value = this[key],
-					compare = match[key];
-				if (compare instanceof RegExp) {
-					if (!compare.test(value))
-						return false;
-				} else if (typeof compare === 'function') {
-					if (!compare(value))
-						return false;
-				} else if (Base.isPlainObject(compare)) {
-					if (!matchObject(compare, value))
-						return false;
-				} else if (!Base.equals(value, compare)) {
-					return false;
-				}
-			}
-		}
-		return true;
-	}
-}, new function() {
-	function getItems(item, match, list) {
-		var children = item._children,
-			items = list && [];
-		for (var i = 0, l = children && children.length; i < l; i++) {
-			var child = children[i];
-			if (child.matches(match)) {
-				if (list) {
-					items.push(child);
-				} else {
-					return child;
-				}
-			}
-			var res = getItems(child, match, list);
-			if (list) {
-				items.push.apply(items, res);
-			} else if (res) {
-				return res;
-			}
-		}
-		return list ? items : null;
-	}
-
-	return {
-		getItems: function(match) {
-			return getItems(this, match, true);
-		},
-
-		getItem: function(match) {
-			return getItems(this, match, false);
-		}
-	};
-}, {
-
-	importJSON: function(json) {
-		var res = Base.importJSON(json, this);
-		return res !== this
-				? this.addChild(res)
-				: res;
-	},
-
-	addChild: function(item, _preserve) {
-		return this.insertChild(undefined, item, _preserve);
-	},
-
-	insertChild: function(index, item, _preserve) {
-		var res = this.insertChildren(index, [item], _preserve);
-		return res && res[0];
-	},
-
-	addChildren: function(items, _preserve) {
-		return this.insertChildren(this._children.length, items, _preserve);
-	},
-
-	insertChildren: function(index, items, _preserve, _type) {
-		var children = this._children;
-		if (children && items && items.length > 0) {
-			items = Array.prototype.slice.apply(items);
-			for (var i = items.length - 1; i >= 0; i--) {
-				var item = items[i];
-				if (_type && item._type !== _type)
-					items.splice(i, 1);
-				else
-					item._remove(true);
-			}
-			Base.splice(children, items, index, 0);
-			for (var i = 0, l = items.length; i < l; i++) {
-				var item = items[i];
-				item._parent = this;
-				item._setProject(this._project);
-				if (item._name)
-					item.setName(item._name);
-			}
-			this._changed(7);
-		} else {
-			items = null;
-		}
-		return items;
-	},
-
-	_insert: function(above, item, _preserve) {
-		if (!item._parent)
-			return null;
-		var index = item._index + (above ? 1 : 0);
-		if (item._parent === this._parent && index > this._index)
-			 index--;
-		return item._parent.insertChild(index, this, _preserve);
-	},
-
-	insertAbove: function(item, _preserve) {
-		return this._insert(true, item, _preserve);
-	},
-
-	insertBelow: function(item, _preserve) {
-	 	return this._insert(false, item, _preserve);
-	 },
-
-	sendToBack: function() {
-		return this._parent.insertChild(0, this);
-	},
-
-	bringToFront: function() {
-		return this._parent.addChild(this);
-	},
-
-	appendTop: '#addChild',
-
-	appendBottom: function(item) {
-		return this.insertChild(0, item);
-	},
-
-	moveAbove: '#insertAbove',
-
-	moveBelow: '#insertBelow',
-
-	reduce: function() {
-		if (this._children && this._children.length === 1) {
-			var child = this._children[0];
-			child.insertAbove(this);
-			child.setStyle(this._style);
-			this.remove();
-			return child;
-		}
-		return this;
-	},
-
-	_removeNamed: function() {
-		var children = this._parent._children,
-			namedChildren = this._parent._namedChildren,
-			name = this._name,
-			namedArray = namedChildren[name],
-			index = namedArray ? namedArray.indexOf(this) : -1;
-		if (index == -1)
-			return;
-		if (children[name] == this)
-			delete children[name];
-		namedArray.splice(index, 1);
-		if (namedArray.length) {
-			children[name] = namedArray[namedArray.length - 1];
-		} else {
-			delete namedChildren[name];
-		}
-	},
-
-	_remove: function(notify) {
-		if (this._parent) {
-			if (this._name)
-				this._removeNamed();
-			if (this._index != null)
-				Base.splice(this._parent._children, null, this._index, 1);
-			if (this.responds('frame'))
-				this._animateItem(false);
-			if (notify)
-				this._parent._changed(7);
-			this._parent = null;
-			return true;
-		}
-		return false;
-	},
-
-	remove: function() {
-		return this._remove(true);
-	},
-
-	removeChildren: function(from, to) {
-		if (!this._children)
-			return null;
-		from = from || 0;
-		to = Base.pick(to, this._children.length);
-		var removed = Base.splice(this._children, null, from, to - from);
-		for (var i = removed.length - 1; i >= 0; i--)
-			removed[i]._remove(false);
-		if (removed.length > 0)
-			this._changed(7);
-		return removed;
-	},
-
-	clear: '#removeChildren',
-
-	reverseChildren: function() {
-		if (this._children) {
-			this._children.reverse();
-			for (var i = 0, l = this._children.length; i < l; i++)
-				this._children[i]._index = i;
-			this._changed(7);
-		}
-	},
-
-	isEmpty: function() {
-		return !this._children || this._children.length == 0;
-	},
-
-	isEditable: function() {
-		var item = this;
-		while (item) {
-			if (!item._visible || item._locked)
-				return false;
-			item = item._parent;
-		}
-		return true;
-	},
-
-	_getOrder: function(item) {
-		function getList(item) {
-			var list = [];
-			do {
-				list.unshift(item);
-			} while (item = item._parent);
-			return list;
-		}
-		var list1 = getList(this),
-			list2 = getList(item);
-		for (var i = 0, l = Math.min(list1.length, list2.length); i < l; i++) {
-			if (list1[i] != list2[i]) {
-				return list1[i]._index < list2[i]._index ? 1 : -1;
-			}
-		}
-		return 0;
-	},
-
-	hasChildren: function() {
-		return this._children && this._children.length > 0;
-	},
-
-	isAbove: function(item) {
-		return this._getOrder(item) === -1;
-	},
-
-	isBelow: function(item) {
-		return this._getOrder(item) === 1;
-	},
-
-	isParent: function(item) {
-		return this._parent === item;
-	},
-
-	isChild: function(item) {
-		return item && item._parent === this;
-	},
-
-	isDescendant: function(item) {
-		var parent = this;
-		while (parent = parent._parent) {
-			if (parent == item)
-				return true;
-		}
-		return false;
-	},
-
-	isAncestor: function(item) {
-		return item ? item.isDescendant(this) : false;
-	},
-
-	isGroupedWith: function(item) {
-		var parent = this._parent;
-		while (parent) {
-			if (parent._parent
-				&& /^(group|layer|compound-path)$/.test(parent._type)
-				&& item.isDescendant(parent))
-					return true;
-			parent = parent._parent;
-		}
-		return false;
-	},
-
-	scale: function(hor, ver , center) {
-		if (arguments.length < 2 || typeof ver === 'object') {
-			center = ver;
-			ver = hor;
-		}
-		return this.transform(new Matrix().scale(hor, ver,
-				center || this.getPosition(true)));
-	},
-
-	translate: function() {
-		var mx = new Matrix();
-		return this.transform(mx.translate.apply(mx, arguments));
-	},
-
-	rotate: function(angle, center) {
-		return this.transform(new Matrix().rotate(angle,
-				center || this.getPosition(true)));
-	},
-
-	shear: function(hor, ver, center) {
-		if (arguments.length < 2 || typeof ver === 'object') {
-			center = ver;
-			ver = hor;
-		}
-		return this.transform(new Matrix().shear(hor, ver,
-				center || this.getPosition(true)));
-	},
-
-	transform: function(matrix ) {
-		var bounds = this._bounds,
-			position = this._position;
-		this._matrix.preConcatenate(matrix);
-		if (this._transformContent || arguments[1])
-			this.applyMatrix(true);
-		this._changed(5);
-		if (bounds && matrix.getRotation() % 90 === 0) {
-			for (var key in bounds) {
-				var rect = bounds[key];
-				matrix._transformBounds(rect, rect);
-			}
-			var getter = this._boundsGetter,
-				rect = bounds[getter && getter.getBounds || getter || 'getBounds'];
-			if (rect)
-				this._position = rect.getCenter(true);
-			this._bounds = bounds;
-		} else if (position) {
-			this._position = matrix._transformPoint(position, position);
-		}
-		return this;
-	},
-
-	_applyMatrix: function(matrix, applyMatrix) {
-		var children = this._children;
-		if (children && children.length > 0) {
-			for (var i = 0, l = children.length; i < l; i++)
-				children[i].transform(matrix, applyMatrix);
-			return true;
-		}
-	},
-
-	applyMatrix: function(_dontNotify) {
-		var matrix = this._matrix;
-		if (this._applyMatrix(matrix, true)) {
-			var style = this._style,
-				fillColor = style.getFillColor(true),
-				strokeColor = style.getStrokeColor(true);
-			if (fillColor)
-				fillColor.transform(matrix);
-			if (strokeColor)
-				strokeColor.transform(matrix);
-			matrix.reset();
-		}
-		if (!_dontNotify)
-			this._changed(5);
-	},
-
-	globalToLocal: function() {
-		var matrix = this.getGlobalMatrix();
-		return matrix && matrix._transformPoint(Point.read(arguments));
-	},
-
-	localToGlobal: function() {
-		var matrix = this.getGlobalMatrix();
-		return matrix && matrix._inverseTransform(Point.read(arguments));
-	},
-
-	fitBounds: function(rectangle, fill) {
-		rectangle = Rectangle.read(arguments);
-		var bounds = this.getBounds(),
-			itemRatio = bounds.height / bounds.width,
-			rectRatio = rectangle.height / rectangle.width,
-			scale = (fill ? itemRatio > rectRatio : itemRatio < rectRatio)
-					? rectangle.width / bounds.width
-					: rectangle.height / bounds.height,
-			newBounds = new Rectangle(new Point(),
-					new Size(bounds.width * scale, bounds.height * scale));
-		newBounds.setCenter(rectangle.getCenter());
-		this.setBounds(newBounds);
-	},
-
-	_setStyles: function(ctx) {
-		var style = this._style,
-			fillColor = style.getFillColor(),
-			strokeColor = style.getStrokeColor(),
-			shadowColor = style.getShadowColor();
-		if (fillColor)
-			ctx.fillStyle = fillColor.toCanvasStyle(ctx);
-		if (strokeColor) {
-			var strokeWidth = style.getStrokeWidth();
-			if (strokeWidth > 0) {
-				ctx.strokeStyle = strokeColor.toCanvasStyle(ctx);
-				ctx.lineWidth = strokeWidth;
-				var strokeJoin = style.getStrokeJoin(),
-					strokeCap = style.getStrokeCap(),
-					miterLimit = style.getMiterLimit();
-				if (strokeJoin)
-					ctx.lineJoin = strokeJoin;
-				if (strokeCap)
-					ctx.lineCap = strokeCap;
-				if (miterLimit)
-					ctx.miterLimit = miterLimit;
-				if (paper.support.nativeDash) {
-					var dashArray = style.getDashArray(),
-						dashOffset = style.getDashOffset();
-					if (dashArray && dashArray.length) {
-						if ('setLineDash' in ctx) {
-							ctx.setLineDash(dashArray);
-							ctx.lineDashOffset = dashOffset;
-						} else {
-							ctx.mozDash = dashArray;
-							ctx.mozDashOffset = dashOffset;
-						}
-					}
-				}
-			}
-		}
-		if (shadowColor) {
-			var shadowBlur = style.getShadowBlur();
-			if (shadowBlur > 0) {
-				ctx.shadowColor = shadowColor.toCanvasStyle(ctx);
-				ctx.shadowBlur = shadowBlur;
-				var offset = this.getShadowOffset();
-				ctx.shadowOffsetX = offset.x;
-				ctx.shadowOffsetY = offset.y;
-			}
-		}
-	},
-
-	draw: function(ctx, param) {
-		if (!this._visible || this._opacity === 0)
-			return;
-		this._drawCount = this._project._drawCount;
-		var trackTransforms = param.trackTransforms,
-			transforms = param.transforms,
-			parentMatrix = transforms[transforms.length - 1],
-			globalMatrix = parentMatrix.clone().concatenate(this._matrix);
-		if (trackTransforms)
-			transforms.push(this._globalMatrix = globalMatrix);
-		var blendMode = this._blendMode,
-			opacity = this._opacity,
-			normalBlend = blendMode === 'normal',
-			nativeBlend = BlendMode.nativeModes[blendMode],
-			direct = normalBlend && opacity === 1
-					|| (nativeBlend || normalBlend && opacity < 1)
-						&& this._canComposite(),
-			mainCtx, itemOffset, prevOffset;
-		if (!direct) {
-			var bounds = this.getStrokeBounds(parentMatrix);
-			if (!bounds.width || !bounds.height)
-				return;
-			prevOffset = param.offset;
-			itemOffset = param.offset = bounds.getTopLeft().floor();
-			mainCtx = ctx;
-			ctx = CanvasProvider.getContext(
-					bounds.getSize().ceil().add(new Size(1, 1)), param.ratio);
-		}
-		ctx.save();
-		if (direct) {
-			ctx.globalAlpha = opacity;
-			if (nativeBlend)
-				ctx.globalCompositeOperation = blendMode;
-		} else {
-			ctx.translate(-itemOffset.x, -itemOffset.y);
-		}
-		(direct ? this._matrix : globalMatrix).applyToContext(ctx);
-		if (!direct && param.clipItem)
-			param.clipItem.draw(ctx, param.extend({ clip: true }));
-		this._draw(ctx, param);
-		ctx.restore();
-		if (trackTransforms)
-			transforms.pop();
-		if (param.clip)
-			ctx.clip();
-		if (!direct) {
-			BlendMode.process(blendMode, ctx, mainCtx, opacity,
-					itemOffset.subtract(prevOffset).multiply(param.ratio));
-			CanvasProvider.release(ctx);
-			param.offset = prevOffset;
-		}
-	},
-
-	_canComposite: function() {
-		return false;
-	}
-}, Base.each(['down', 'drag', 'up', 'move'], function(name) {
-	this['removeOn' + Base.capitalize(name)] = function() {
-		var hash = {};
-		hash[name] = true;
-		return this.removeOn(hash);
-	};
-}, {
-
-	removeOn: function(obj) {
-		for (var name in obj) {
-			if (obj[name]) {
-				var key = 'mouse' + name,
-					project = this._project,
-					sets = project._removeSets = project._removeSets || {};
-				sets[key] = sets[key] || {};
-				sets[key][this._id] = this;
-			}
-		}
-		return this;
-	}
-}));
-
-var Group = Item.extend({
-	_class: 'Group',
-	_serializeFields: {
-		children: []
-	},
-
-	initialize: function Group(arg) {
-		this._children = [];
-		this._namedChildren = {};
-		if (!this._initialize(arg))
-			this.addChildren(Array.isArray(arg) ? arg : arguments);
-	},
-
-	_changed: function _changed(flags) {
-		_changed.base.call(this, flags);
-		if (flags & 2 && this._transformContent
-				&& !this._matrix.isIdentity()) {
-			this.applyMatrix();
-		}
-		if (flags & (2 | 256)) {
-			delete this._clipItem;
-		}
-	},
-
-	_getClipItem: function() {
-		if (this._clipItem !== undefined)
-			return this._clipItem;
-		for (var i = 0, l = this._children.length; i < l; i++) {
-			var child = this._children[i];
-			if (child._clipMask)
-				return this._clipItem = child;
-		}
-		return this._clipItem = null;
-	},
-
-	isClipped: function() {
-		return !!this._getClipItem();
-	},
-
-	setClipped: function(clipped) {
-		var child = this.getFirstChild();
-		if (child)
-			child.setClipMask(clipped);
-	},
-
-	_draw: function(ctx, param) {
-		var clipItem = param.clipItem = this._getClipItem();
-		if (clipItem)
-			clipItem.draw(ctx, param.extend({ clip: true }));
-		for (var i = 0, l = this._children.length; i < l; i++) {
-			var item = this._children[i];
-			if (item !== clipItem)
-				item.draw(ctx, param);
-		}
-		param.clipItem = null;
-	}
-});
-
-var Layer = Group.extend({
-	_class: 'Layer',
-
-	initialize: function Layer(arg) {
-		var props = Base.isPlainObject(arg)
-				? new Base(arg) 
-				: { children: Array.isArray(arg) ? arg : arguments },
-			insert = props.insert;
-		props.insert = false;
-		Group.call(this, props);
-		if (insert || insert === undefined) {
-			this._project.addChild(this);
-			this.activate();
-		}
-	},
-
-	_remove: function _remove(notify) {
-		if (this._parent)
-			return _remove.base.call(this, notify);
-		if (this._index != null) {
-			if (this._project.activeLayer === this)
-				this._project.activeLayer = this.getNextSibling()
-						|| this.getPreviousSibling();
-			Base.splice(this._project.layers, null, this._index, 1);
-			this._project._needsRedraw = true;
-			return true;
-		}
-		return false;
-	},
-
-	getNextSibling: function getNextSibling() {		
-		return this._parent ? getNextSibling.base.call(this)
-				: this._project.layers[this._index + 1] || null;
-	},
-
-	getPreviousSibling: function getPreviousSibling() {
-		return this._parent ? getPreviousSibling.base.call(this)
-				: this._project.layers[this._index - 1] || null;
-	},
-
-	isInserted: function isInserted() {
-		return this._parent ? isInserted.base.call(this) : this._index != null;
-	},
-
-	activate: function() {
-		this._project.activeLayer = this;
-	},
-
-	_insert: function _insert(above, item, _preserve) {
-		if (item instanceof Layer && !item._parent) {
-			this._remove(true);
-			Base.splice(item._project.layers, [this],
-					item._index + (above ? 1 : 0), 0);
-			this._setProject(item._project);
-			return this;
-		}
-		return _insert.base.call(this, above, item, _preserve);
-	}
-});
-
-var Shape = Item.extend({
-	_class: 'Shape',
-	_transformContent: false,
-	_boundsSelected: true,
-
-	initialize: function Shape(shape, center, size, radius, props) {
-		this._shape = shape;
-		this._size = size;
-		this._radius = radius;
-		this._initialize(props, center);
-	},
-
-	_equals: function(item) {
-		return this._shape === item._shape
-			&& this._size.equals(item._size)
-			&& Base.equals(this._radius, item._radius);
-	},
-
-	clone: function(insert) {
-		return this._clone(new Shape(this._shape, this.getPosition(true),
-				this._size.clone(),
-				this._radius.clone ? this._radius.clone() : this._radius,
-				{ insert: false }), insert);
-	},
-
-	getShape: function() {
-		return this._shape;
-	},
-
-	getSize: function() {
-		var size = this._size;
-		return new LinkedSize(size.width, size.height, this, 'setSize');
-	},
-
-	setSize: function() {
-		var shape = this._shape,
-			size = Size.read(arguments);
-		if (!this._size.equals(size)) {
-			var width = size.width,
-				height = size.height;
-			if (shape === 'rectangle') {
-				var radius = Size.min(this._radius, size.divide(2));
-				this._radius.set(radius.width, radius.height);
-			} else if (shape === 'circle') {
-				width = height = (width + height) / 2;
-				this._radius = width / 2;
-			} else if (shape === 'ellipse') {
-				this._radius.set(width / 2, height / 2);
-			}
-			this._size.set(width, height);
-			this._changed(5);
-		}
-	},
-
-	getRadius: function() {
-		var rad = this._radius;
-		return this._shape === 'circle'
-				? rad
-				: new LinkedSize(rad.width, rad.height, this, 'setRadius');
-	},
-
-	setRadius: function(radius) {
-		var shape = this._shape;
-		if (shape === 'circle') {
-			if (radius === this._radius)
-				return;
-			var size = radius * 2;
-			this._radius = radius;
-			this._size.set(size, size);
-		} else {
-			radius = Size.read(arguments);
-			if (this._radius.equals(radius))
-				return;
-			this._radius.set(radius.width, radius.height);
-			if (shape === 'rectangle') {
-				var size = Size.max(this._size, radius.multiply(2));
-				this._size.set(size.width, size.height);
-			} else if (shape === 'ellipse') {
-				this._size.set(radius.width * 2, radius.height * 2);
-			}
-		}
-		this._changed(5);
-	},
-
-	isEmpty: function() {
-		return false;
-	},
-
-	toPath: function(insert) {
-		var path = new Path[Base.capitalize(this._shape)]({
-			center: new Point(),
-			size: this._size,
-			radius: this._radius,
-			insert: false
-		});
-		path.setStyle(this._style);
-		path.transform(this._matrix);
-		if (insert || insert === undefined)
-			path.insertAbove(this);
-		return path;
-	},
-
-	_draw: function(ctx, param) {
-		var style = this._style,
-			hasFill = style.hasFill(),
-			hasStroke = style.hasStroke(),
-			clip = param.clip;
-		if (hasFill || hasStroke || clip) {
-			var radius = this._radius,
-				shape = this._shape;
-			ctx.beginPath();
-			if (shape === 'circle') {
-				ctx.arc(0, 0, radius, 0, Math.PI * 2, true);
-			} else {
-				var rx = radius.width,
-					ry = radius.height,
-					kappa = Numerical.KAPPA;
-				if (shape === 'ellipse') {
-					var	cx = rx * kappa,
-						cy = ry * kappa;
-					ctx.moveTo(-rx, 0);
-					ctx.bezierCurveTo(-rx, -cy, -cx, -ry, 0, -ry);
-					ctx.bezierCurveTo(cx, -ry, rx, -cy, rx, 0);
-					ctx.bezierCurveTo(rx, cy, cx, ry, 0, ry);
-					ctx.bezierCurveTo(-cx, ry, -rx, cy, -rx, 0);
-				} else { 
-					var size = this._size,
-						width = size.width,
-						height = size.height;
-					if (rx === 0 && ry === 0) {
-						ctx.rect(-width / 2, -height / 2, width, height);
-					} else {
-						kappa = 1 - kappa;
-						var x = width / 2,
-							y = height / 2,
-							cx = rx * kappa,
-							cy = ry * kappa;
-						ctx.moveTo(-x, -y + ry);
-						ctx.bezierCurveTo(-x, -y + cy, -x + cx, -y, -x + rx, -y);
-						ctx.lineTo(x - rx, -y);
-						ctx.bezierCurveTo(x - cx, -y, x, -y + cy, x, -y + ry);
-						ctx.lineTo(x, y - ry);
-						ctx.bezierCurveTo(x, y - cy, x - cx, y, x - rx, y);
-						ctx.lineTo(-x + rx, y);
-						ctx.bezierCurveTo(-x + cx, y, -x, y - cy, -x, y - ry);
-					}
-				}
-			}
-			ctx.closePath();
-		}
-		if (!clip && (hasFill || hasStroke)) {
-			this._setStyles(ctx);
-			if (hasFill) {
-				ctx.fill(style.getWindingRule());
-				ctx.shadowColor = 'rgba(0,0,0,0)';
-			}
-			if (hasStroke)
-				ctx.stroke();
-		}
-	},
-
-	_canComposite: function() {
-		return !(this.hasFill() && this.hasStroke());
-	},
-
-	_getBounds: function(getter, matrix) {
-		var rect = new Rectangle(this._size).setCenter(0, 0);
-		if (getter !== 'getBounds' && this.hasStroke())
-			rect = rect.expand(this.getStrokeWidth());
-		return matrix ? matrix._transformBounds(rect) : rect;
-	}
-},
-new function() { 
-
-	function getCornerCenter(that, point, expand) {
-		var radius = that._radius;
-		if (!radius.isZero()) {
-			var halfSize = that._size.divide(2);
-			for (var i = 0; i < 4; i++) {
-				var dir = new Point(i & 1 ? 1 : -1, i > 1 ? 1 : -1),
-					corner = dir.multiply(halfSize),
-					center = corner.subtract(dir.multiply(radius)),
-					rect = new Rectangle(corner, center);
-				if ((expand ? rect.expand(expand) : rect).contains(point))
-					return center;
-			}
-		}
-	}
-
-	function getEllipseRadius(point, radius) {
-		var angle = point.getAngleInRadians(),
-			width = radius.width * 2,
-			height = radius.height * 2,
-			x = width * Math.sin(angle),
-			y = height * Math.cos(angle);
-		return width * height / (2 * Math.sqrt(x * x + y * y));
-	}
-
-	return {
-		_contains: function _contains(point) {
-			if (this._shape === 'rectangle') {
-				var center = getCornerCenter(this, point);
-				return center
-						? point.subtract(center).divide(this._radius)
-							.getLength() <= 1
-						: _contains.base.call(this, point);
-			} else {
-				return point.divide(this.size).getLength() <= 0.5;
-			}
-		},
-
-		_hitTest: function _hitTest(point, options) {
-			var hit = false;
-			if (this.hasStroke()) {
-				var shape = this._shape,
-					radius = this._radius,
-					strokeWidth = this.getStrokeWidth() + 2 * options.tolerance;
-				if (shape === 'rectangle') {
-					var center = getCornerCenter(this, point, strokeWidth);
-					if (center) {
-						var pt = point.subtract(center);
-						hit = 2 * Math.abs(pt.getLength()
-								- getEllipseRadius(pt, radius)) <= strokeWidth;
-					} else {
-						var rect = new Rectangle(this._size).setCenter(0, 0),
-							outer = rect.expand(strokeWidth),
-							inner = rect.expand(-strokeWidth);
-						hit = outer._containsPoint(point)
-								&& !inner._containsPoint(point);
-					}
-				} else {
-					if (shape === 'ellipse')
-						radius = getEllipseRadius(point, radius);
-					hit = 2 * Math.abs(point.getLength() - radius)
-							<= strokeWidth;
-				}
-			}
-			return hit
-					? new HitResult('stroke', this)
-					: _hitTest.base.apply(this, arguments);
-		}
-	};
-}, {
-
-statics: new function() {
-	function createShape(shape, point, size, radius, args) {
-		return new Shape(shape, point, size, radius, Base.getNamed(args));
-	}
-
-	return {
-		Circle: function() {
-			var center = Point.readNamed(arguments, 'center'),
-				radius = Base.readNamed(arguments, 'radius');
-			return createShape('circle', center, new Size(radius * 2), radius,
-					arguments);
-		},
-
-		Rectangle: function() {
-			var rect = Rectangle.readNamed(arguments, 'rectangle'),
-				radius = Size.min(Size.readNamed(arguments, 'radius'),
-						rect.getSize(true).divide(2));
-			return createShape('rectangle', rect.getCenter(true),
-					rect.getSize(true), radius, arguments);
-		},
-
-		Ellipse: function() {
-			var ellipse = Shape._readEllipse(arguments);
-				radius = ellipse.radius;
-			return createShape('ellipse', ellipse.center, radius.multiply(2),
-					radius, arguments);
-		},
-
-		_readEllipse: function(args) {
-			var center,
-				radius;
-			if (Base.hasNamed(args, 'radius')) {
-				center = Point.readNamed(args, 'center');
-				radius = Size.readNamed(args, 'radius');
-			} else {
-				var rect = Rectangle.readNamed(args, 'rectangle');
-				center = rect.getCenter(true);
-				radius = rect.getSize(true).divide(2);
-			}
-			return { center: center, radius: radius };
-		}
-	};
-}});
-
-var Raster = Item.extend({
-	_class: 'Raster',
-	_transformContent: false,
-	_boundsGetter: 'getBounds',
-	_boundsSelected: true,
-	_serializeFields: {
-		source: null
-	},
-
-	initialize: function Raster(object, position) {
-		if (!this._initialize(object,
-				position !== undefined && Point.read(arguments, 1))) {
-			if (typeof object === 'string') {
-				this.setSource(object);
-			} else {
-				this.setImage(object);
-			}
-		}
-		if (!this._size)
-			this._size = new Size();
-	},
-
-	_equals: function(item) {
-		return this.getSource() === item.getSource();
-	},
-
-	clone: function(insert) {
-		var param = { insert: false },
-			image = this._image;
-		if (image) {
-			param.image = image;
-		} else if (this._canvas) {
-			var canvas = param.canvas = CanvasProvider.getCanvas(this._size);
-			canvas.getContext('2d').drawImage(this._canvas, 0, 0);
-		}
-		return this._clone(new Raster(param), insert);
-	},
-
-	getSize: function() {
-		var size = this._size;
-		return new LinkedSize(size.width, size.height, this, 'setSize');
-	},
-
-	setSize: function() {
-		var size = Size.read(arguments);
-		if (!this._size.equals(size)) {
-			var element = this.getElement();
-			this.setCanvas(CanvasProvider.getCanvas(size));
-			if (element)
-				this.getContext(true).drawImage(element, 0, 0,
-						size.width, size.height);
-		}
-	},
-
-	getWidth: function() {
-		return this._size.width;
-	},
-
-	getHeight: function() {
-		return this._size.height;
-	},
-
-	isEmpty: function() {
-		return this._size.width == 0 && this._size.height == 0;
-	},
-
-	getPpi: function() {
-		var matrix = this._matrix,
-			orig = new Point(0, 0).transform(matrix),
-			u = new Point(1, 0).transform(matrix).subtract(orig),
-			v = new Point(0, 1).transform(matrix).subtract(orig);
-		return new Size(
-			72 / u.getLength(),
-			72 / v.getLength()
-		);
-	},
-
-	getImage: function() {
-		return this._image;
-	},
-
-	setImage: function(image) {
-		if (this._canvas)
-			CanvasProvider.release(this._canvas);
-		if (image.getContext) {
-			this._image = null;
-			this._canvas = image;
-		} else {
-			this._image = image;
-			this._canvas = null;
-		}
-		this._size = new Size(
-				image.naturalWidth || image.width,
-				image.naturalHeight || image.height);
-		this._context = null;
-		this._changed(5 | 129);
-	},
-
-	getCanvas: function() {
-		if (!this._canvas) {
-			var ctx = CanvasProvider.getContext(this._size);
-			try {
-				if (this._image)
-					ctx.drawImage(this._image, 0, 0);
-				this._canvas = ctx.canvas;
-			} catch (e) {
-				CanvasProvider.release(ctx);
-			}
-		}
-		return this._canvas;
-	},
-
-	setCanvas: '#setImage',
-
-	getContext: function() {
-		if (!this._context)
-			this._context = this.getCanvas().getContext('2d');
-		if (arguments[0]) {
-			this._image = null;
-			this._changed(129);
-		}
-		return this._context;
-	},
-
-	setContext: function(context) {
-		this._context = context;
-	},
-
-	getSource: function() {
-		return this._image && this._image.src || this.toDataURL();
-	},
-
-	setSource: function(src) {
-		var that = this,
-			image = document.getElementById(src) || new Image();
-
-		function loaded() {
-			var view = that._project.view;
-			if (view)
-				paper = view._scope;
-			that.fire('load');
-			if (view)
-				view.draw(true);
-		}
-
-		if (image.naturalWidth && image.naturalHeight) {
-			setTimeout(loaded, 0);
-		} else {
-			DomEvent.add(image, {
-				load: function() {
-					that.setImage(image);
-					loaded();
-				}
-			});
-			if (!image.src)
-				image.src = src;
-		}
-		this.setImage(image);
-	},
-
-	getElement: function() {
-		return this._canvas || this._image;
-	},
-
-	getSubCanvas: function(rect) {
-		rect = Rectangle.read(arguments);
-		var ctx = CanvasProvider.getContext(rect.getSize());
-		ctx.drawImage(this.getCanvas(), rect.x, rect.y,
-				rect.width, rect.height, 0, 0, rect.width, rect.height);
-		return ctx.canvas;
-	},
-
-	getSubRaster: function(rect) {
-		rect = Rectangle.read(arguments);
-		var raster = new Raster({
-			canvas: this.getSubCanvas(rect),
-			insert: false
-		});
-		raster.translate(rect.getCenter().subtract(this.getSize().divide(2)));
-		raster._matrix.preConcatenate(this._matrix);
-		raster.insertAbove(this);
-		return raster;
-	},
-
-	toDataURL: function() {
-		var src = this._image && this._image.src;
-		if (/^data:/.test(src))
-			return src;
-		var canvas = this.getCanvas();
-		return canvas ? canvas.toDataURL() : null;
-	},
-
-	drawImage: function(image, point) {
-		point = Point.read(arguments, 1);
-		this.getContext(true).drawImage(image, point.x, point.y);
-	},
-
-	getAverageColor: function(object) {
-		var bounds, path;
-		if (!object) {
-			bounds = this.getBounds();
-		} else if (object instanceof PathItem) {
-			path = object;
-			bounds = object.getBounds();
-		} else if (object.width) {
-			bounds = new Rectangle(object);
-		} else if (object.x) {
-			bounds = new Rectangle(object.x - 0.5, object.y - 0.5, 1, 1);
-		}
-		var sampleSize = 32,
-			width = Math.min(bounds.width, sampleSize),
-			height = Math.min(bounds.height, sampleSize);
-		var ctx = Raster._sampleContext;
-		if (!ctx) {
-			ctx = Raster._sampleContext = CanvasProvider.getContext(
-					new Size(sampleSize));
-		} else {
-			ctx.clearRect(0, 0, sampleSize + 1, sampleSize + 1);
-		}
-		ctx.save();
-		var matrix = new Matrix()
-				.scale(width / bounds.width, height / bounds.height)
-				.translate(-bounds.x, -bounds.y);
-		matrix.applyToContext(ctx);
-		if (path)
-			path.draw(ctx, new Base({ clip: true, transforms: [matrix] }));
-		this._matrix.applyToContext(ctx);
-		ctx.drawImage(this.getElement(),
-				-this._size.width / 2, -this._size.height / 2);
-		ctx.restore();
-		var pixels = ctx.getImageData(0.5, 0.5, Math.ceil(width),
-				Math.ceil(height)).data,
-			channels = [0, 0, 0],
-			total = 0;
-		for (var i = 0, l = pixels.length; i < l; i += 4) {
-			var alpha = pixels[i + 3];
-			total += alpha;
-			alpha /= 255;
-			channels[0] += pixels[i] * alpha;
-			channels[1] += pixels[i + 1] * alpha;
-			channels[2] += pixels[i + 2] * alpha;
-		}
-		for (var i = 0; i < 3; i++)
-			channels[i] /= total;
-		return total ? Color.read(channels) : null;
-	},
-
-	getPixel: function(point) {
-		point = Point.read(arguments);
-		var data = this.getContext().getImageData(point.x, point.y, 1, 1).data;
-		return new Color('rgb', [data[0] / 255, data[1] / 255, data[2] / 255],
-				data[3] / 255);
-	},
-
-	setPixel: function() {
-		var point = Point.read(arguments),
-			color = Color.read(arguments),
-			components = color._convert('rgb'),
-			alpha = color._alpha,
-			ctx = this.getContext(true),
-			imageData = ctx.createImageData(1, 1),
-			data = imageData.data;
-		data[0] = components[0] * 255;
-		data[1] = components[1] * 255;
-		data[2] = components[2] * 255;
-		data[3] = alpha != null ? alpha * 255 : 255;
-		ctx.putImageData(imageData, point.x, point.y);
-	},
-
-	createImageData: function(size) {
-		size = Size.read(arguments);
-		return this.getContext().createImageData(size.width, size.height);
-	},
-
-	getImageData: function(rect) {
-		rect = Rectangle.read(arguments);
-		if (rect.isEmpty())
-			rect = new Rectangle(this._size);
-		return this.getContext().getImageData(rect.x, rect.y,
-				rect.width, rect.height);
-	},
-
-	setImageData: function(data, point) {
-		point = Point.read(arguments, 1);
-		this.getContext(true).putImageData(data, point.x, point.y);
-	},
-
-	_getBounds: function(getter, matrix) {
-		var rect = new Rectangle(this._size).setCenter(0, 0);
-		return matrix ? matrix._transformBounds(rect) : rect;
-	},
-
-	_hitTest: function(point) {
-		if (this._contains(point)) {
-			var that = this;
-			return new HitResult('pixel', that, {
-				offset: point.add(that._size.divide(2)).round(),
-				color: {
-					get: function() {
-						return that.getPixel(this.offset);
-					}
-				}
-			});
-		}
-	},
-
-	_draw: function(ctx) {
-		var element = this.getElement();
-		if (element) {
-			ctx.globalAlpha = this._opacity;
-			ctx.drawImage(element,
-					-this._size.width / 2, -this._size.height / 2);
-		}
-	},
-
-	_canComposite: function() {
-		return true;
-	}
-});
-
-var PlacedSymbol = Item.extend({
-	_class: 'PlacedSymbol',
-	_transformContent: false,
-	_boundsGetter: { getBounds: 'getStrokeBounds' },
-	_boundsSelected: true,
-	_serializeFields: {
-		symbol: null
-	},
-
-	initialize: function PlacedSymbol(arg0, arg1) {
-		if (!this._initialize(arg0,
-				arg1 !== undefined && Point.read(arguments, 1)))
-			this.setSymbol(arg0 instanceof Symbol ? arg0 : new Symbol(arg0));
-	},
-
-	_equals: function(item) {
-		return this._symbol === item._symbol;
-	},
-
-	getSymbol: function() {
-		return this._symbol;
-	},
-
-	setSymbol: function(symbol) {
-		if (this._symbol)
-			delete this._symbol._instances[this._id];
-		this._symbol = symbol;
-		symbol._instances[this._id] = this;
-	},
-
-	clone: function(insert) {
-		return this._clone(new PlacedSymbol({
-			symbol: this.symbol,
-			insert: false
-		}), insert);
-	},
-
-	isEmpty: function() {
-		return this._symbol._definition.isEmpty();
-	},
-
-	_getBounds: function(getter, matrix) {
-		return this.symbol._definition._getCachedBounds(getter, matrix);
-	},
-
-	_hitTest: function(point, options, matrix) {
-		var result = this._symbol._definition._hitTest(point, options, matrix);
-		if (result)
-			result.item = this;
-		return result;
-	},
-
-	_draw: function(ctx, param) {
-		this.symbol._definition.draw(ctx, param);
-	}
-
-});
-
-var HitResult = Base.extend({
-	_class: 'HitResult',
-
-	initialize: function HitResult(type, item, values) {
-		this.type = type;
-		this.item = item;
-		if (values) {
-			values.enumerable = true;
-			this.inject(values);
-		}
-	},
-
-	statics: {
-		getOptions: function(options) {
-			return options && options._merged ? options : new Base({
-				type: null,
-				tolerance: paper.project.options.hitTolerance || 2,
-				fill: !options,
-				stroke: !options,
-				segments: !options,
-				handles: false,
-				ends: false,
-				center: false,
-				bounds: false,
-				guides: false,
-				selected: false,
-				_merged: true
-			}, options);
-		}
-	}
-});
-
-var Segment = Base.extend({
-	_class: 'Segment',
-
-	initialize: function Segment(arg0, arg1, arg2, arg3, arg4, arg5) {
-		var count = arguments.length,
-			point, handleIn, handleOut;
-		if (count === 0) {
-		} else if (count === 1) {
-			if (arg0.point) {
-				point = arg0.point;
-				handleIn = arg0.handleIn;
-				handleOut = arg0.handleOut;
-			} else {
-				point = arg0;
-			}
-		} else if (count === 2 && typeof arg0 === 'number') {
-			point = arguments;
-		} else if (count <= 3) {
-			point = arg0;
-			handleIn = arg1;
-			handleOut = arg2;
-		} else { 
-			point = arg0 !== undefined ? [ arg0, arg1 ] : null;
-			handleIn = arg2 !== undefined ? [ arg2, arg3 ] : null;
-			handleOut = arg4 !== undefined ? [ arg4, arg5 ] : null;
-		}
-		new SegmentPoint(point, this, '_point');
-		new SegmentPoint(handleIn, this, '_handleIn');
-		new SegmentPoint(handleOut, this, '_handleOut');
-	},
-
-	_serialize: function(options) {
-		return Base.serialize(this.isLinear() ? this._point
-				: [this._point, this._handleIn, this._handleOut], options, true);
-	},
-
-	_changed: function(point) {
-		if (!this._path)
-			return;
-		var curve = this._path._curves && this.getCurve(),
-			other;
-		if (curve) {
-			curve._changed();
-			if (other = (curve[point == this._point
-					|| point == this._handleIn && curve._segment1 == this
-					? 'getPrevious' : 'getNext']())) {
-				other._changed();
-			}
-		}
-		this._path._changed(5);
-	},
-
-	getPoint: function() {
-		return this._point;
-	},
-
-	setPoint: function(point) {
-		point = Point.read(arguments);
-		this._point.set(point.x, point.y);
-	},
-
-	getHandleIn: function() {
-		return this._handleIn;
-	},
-
-	setHandleIn: function(point) {
-		point = Point.read(arguments);
-		this._handleIn.set(point.x, point.y);
-	},
-
-	getHandleOut: function() {
-		return this._handleOut;
-	},
-
-	setHandleOut: function(point) {
-		point = Point.read(arguments);
-		this._handleOut.set(point.x, point.y);
-	},
-
-	isLinear: function() {
-		return this._handleIn.isZero() && this._handleOut.isZero();
-	},
-
-	setLinear: function() {
-		this._handleIn.set(0, 0);
-		this._handleOut.set(0, 0);
-	},
-
-	isColinear: function(segment) {
-		var next1 = this.getNext(),
-			next2 = segment.getNext();
-		return this._handleOut.isZero() && next1._handleIn.isZero()
-				&& segment._handleOut.isZero() && next2._handleIn.isZero()
-				&& next1._point.subtract(this._point).isColinear(
-					next2._point.subtract(segment._point));
-	},
-
-	isOrthogonal: function() {
-		var prev = this.getPrevious(),
-			next = this.getNext();
-		return prev._handleOut.isZero() && this._handleIn.isZero()
-			&& this._handleOut.isZero() && next._handleIn.isZero()
-			&& this._point.subtract(prev._point).isOrthogonal(
-					next._point.subtract(this._point));
-	},
-
-	isArc: function() {
-		var next = this.getNext(),
-			handle1 = this._handleOut,
-			handle2 = next._handleIn,
-			kappa = Numerical.KAPPA;
-		if (handle1.isOrthogonal(handle2)) {
-			var from = this._point,
-				to = next._point,
-				corner = new Line(from, handle1, true).intersect(
-						new Line(to, handle2, true), true);
-			return corner && Numerical.isZero(handle1.getLength() /
-					corner.subtract(from).getLength() - kappa)
-				&& Numerical.isZero(handle2.getLength() /
-					corner.subtract(to).getLength() - kappa);
-		}
-		return false;
-	},
-
-	_isSelected: function(point) {
-		var state = this._selectionState;
-		return point == this._point ? !!(state & 4)
-			: point == this._handleIn ? !!(state & 1)
-			: point == this._handleOut ? !!(state & 2)
-			: false;
-	},
-
-	_setSelected: function(point, selected) {
-		var path = this._path,
-			selected = !!selected, 
-			state = this._selectionState || 0,
-			selection = [
-				!!(state & 4),
-				!!(state & 1),
-				!!(state & 2)
-			];
-		if (point === this._point) {
-			if (selected) {
-				selection[1] = selection[2] = false;
-			} else {
-				var previous = this.getPrevious(),
-					next = this.getNext();
-				selection[1] = previous && (previous._point.isSelected()
-						|| previous._handleOut.isSelected());
-				selection[2] = next && (next._point.isSelected()
-						|| next._handleIn.isSelected());
-			}
-			selection[0] = selected;
-		} else {
-			var index = point === this._handleIn ? 1 : 2;
-			if (selection[index] != selected) {
-				if (selected)
-					selection[0] = false;
-				selection[index] = selected;
-			}
-		}
-		this._selectionState = (selection[0] ? 4 : 0)
-				| (selection[1] ? 1 : 0)
-				| (selection[2] ? 2 : 0);
-		if (path && state != this._selectionState) {
-			path._updateSelection(this, state, this._selectionState);
-			path._changed(33);
-		}
-	},
-
-	isSelected: function() {
-		return this._isSelected(this._point);
-	},
-
-	setSelected: function(selected) {
-		this._setSelected(this._point, selected);
-	},
-
-	getIndex: function() {
-		return this._index !== undefined ? this._index : null;
-	},
-
-	getPath: function() {
-		return this._path || null;
-	},
-
-	getCurve: function() {
-		var path = this._path,
-			index = this._index;
-		if (path) {
-			if (!path._closed && index == path._segments.length - 1)
-				index--;
-			return path.getCurves()[index] || null;
-		}
-		return null;
-	},
-
-	getLocation: function() {
-		var curve = this.getCurve();
-		return curve ? new CurveLocation(curve, curve.getNext() ? 0 : 1) : null;
-	},
-
-	getNext: function() {
-		var segments = this._path && this._path._segments;
-		return segments && (segments[this._index + 1]
-				|| this._path._closed && segments[0]) || null;
-	},
-
-	getPrevious: function() {
-		var segments = this._path && this._path._segments;
-		return segments && (segments[this._index - 1]
-				|| this._path._closed && segments[segments.length - 1]) || null;
-	},
-
-	reverse: function() {
-		return new Segment(this._point, this._handleOut, this._handleIn);
-	},
-
-	remove: function() {
-		return this._path ? !!this._path.removeSegment(this._index) : false;
-	},
-
-	clone: function() {
-		return new Segment(this._point, this._handleIn, this._handleOut);
-	},
-
-	equals: function(segment) {
-		return segment === this || segment && this._class === segment._class
-				&& this._point.equals(segment._point)
-				&& this._handleIn.equals(segment._handleIn)
-				&& this._handleOut.equals(segment._handleOut)
-				|| false;
-	},
-
-	toString: function() {
-		var parts = [ 'point: ' + this._point ];
-		if (!this._handleIn.isZero())
-			parts.push('handleIn: ' + this._handleIn);
-		if (!this._handleOut.isZero())
-			parts.push('handleOut: ' + this._handleOut);
-		return '{ ' + parts.join(', ') + ' }';
-	},
-
-	_transformCoordinates: function(matrix, coords, change) {
-		var point = this._point,
-			handleIn =  !change || !this._handleIn.isZero()
-					? this._handleIn : null,
-			handleOut = !change || !this._handleOut.isZero()
-					? this._handleOut : null,
-			x = point._x,
-			y = point._y,
-			i = 2;
-		coords[0] = x;
-		coords[1] = y;
-		if (handleIn) {
-			coords[i++] = handleIn._x + x;
-			coords[i++] = handleIn._y + y;
-		}
-		if (handleOut) {
-			coords[i++] = handleOut._x + x;
-			coords[i++] = handleOut._y + y;
-		}
-		if (matrix) {
-			matrix._transformCoordinates(coords, 0, coords, 0, i / 2);
-			x = coords[0];
-			y = coords[1];
-			if (change) {
-				point._x = x;
-				point._y = y;
-				i  = 2;
-				if (handleIn) {
-					handleIn._x = coords[i++] - x;
-					handleIn._y = coords[i++] - y;
-				}
-				if (handleOut) {
-					handleOut._x = coords[i++] - x;
-					handleOut._y = coords[i++] - y;
-				}
-			} else {
-				if (!handleIn) {
-					coords[i++] = x;
-					coords[i++] = y;
-				}
-				if (!handleOut) {
-					coords[i++] = x;
-					coords[i++] = y;
-				}
-			}
-		}
-		return coords;
-	}
-});
-
-var SegmentPoint = Point.extend({
-	initialize: function SegmentPoint(point, owner, key) {
-		var x, y, selected;
-		if (!point) {
-			x = y = 0;
-		} else if ((x = point[0]) !== undefined) { 
-			y = point[1];
-		} else {
-			if ((x = point.x) === undefined) {
-				point = Point.read(arguments);
-				x = point.x;
-			}
-			y = point.y;
-			selected = point.selected;
-		}
-		this._x = x;
-		this._y = y;
-		this._owner = owner;
-		owner[key] = this;
-		if (selected)
-			this.setSelected(true);
-	},
-
-	set: function(x, y) {
-		this._x = x;
-		this._y = y;
-		this._owner._changed(this);
-		return this;
-	},
-
-	_serialize: function(options) {
-		var f = options.formatter,
-			x = f.number(this._x),
-			y = f.number(this._y);
-		return this.isSelected()
-				? { x: x, y: y, selected: true }
-				: [x, y];
-	},
-
-	getX: function() {
-		return this._x;
-	},
-
-	setX: function(x) {
-		this._x = x;
-		this._owner._changed(this);
-	},
-
-	getY: function() {
-		return this._y;
-	},
-
-	setY: function(y) {
-		this._y = y;
-		this._owner._changed(this);
-	},
-
-	isZero: function() {
-		return Numerical.isZero(this._x) && Numerical.isZero(this._y);
-	},
-
-	setSelected: function(selected) {
-		this._owner._setSelected(this, selected);
-	},
-
-	isSelected: function() {
-		return this._owner._isSelected(this);
-	}
-});
-
-var Curve = Base.extend({
-	_class: 'Curve',
-	initialize: function Curve(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
-		var count = arguments.length;
-		if (count === 3) {
-			this._path = arg0;
-			this._segment1 = arg1;
-			this._segment2 = arg2;
-		} else if (count === 0) {
-			this._segment1 = new Segment();
-			this._segment2 = new Segment();
-		} else if (count === 1) {
-			this._segment1 = new Segment(arg0.segment1);
-			this._segment2 = new Segment(arg0.segment2);
-		} else if (count === 2) {
-			this._segment1 = new Segment(arg0);
-			this._segment2 = new Segment(arg1);
-		} else {
-			var point1, handle1, handle2, point2;
-			if (count === 4) {
-				point1 = arg0;
-				handle1 = arg1;
-				handle2 = arg2;
-				point2 = arg3;
-			} else if (count === 8) {
-				point1 = [arg0, arg1];
-				point2 = [arg6, arg7];
-				handle1 = [arg2 - arg0, arg3 - arg1];
-				handle2 = [arg4 - arg6, arg5 - arg7];
-			}
-			this._segment1 = new Segment(point1, null, handle1);
-			this._segment2 = new Segment(point2, handle2, null);
-		}
-	},
-
-	_changed: function() {
-		delete this._length;
-		delete this._bounds;
-	},
-
-	getPoint1: function() {
-		return this._segment1._point;
-	},
-
-	setPoint1: function(point) {
-		point = Point.read(arguments);
-		this._segment1._point.set(point.x, point.y);
-	},
-
-	getPoint2: function() {
-		return this._segment2._point;
-	},
-
-	setPoint2: function(point) {
-		point = Point.read(arguments);
-		this._segment2._point.set(point.x, point.y);
-	},
-
-	getHandle1: function() {
-		return this._segment1._handleOut;
-	},
-
-	setHandle1: function(point) {
-		point = Point.read(arguments);
-		this._segment1._handleOut.set(point.x, point.y);
-	},
-
-	getHandle2: function() {
-		return this._segment2._handleIn;
-	},
-
-	setHandle2: function(point) {
-		point = Point.read(arguments);
-		this._segment2._handleIn.set(point.x, point.y);
-	},
-
-	getSegment1: function() {
-		return this._segment1;
-	},
-
-	getSegment2: function() {
-		return this._segment2;
-	},
-
-	getPath: function() {
-		return this._path;
-	},
-
-	getIndex: function() {
-		return this._segment1._index;
-	},
-
-	getNext: function() {
-		var curves = this._path && this._path._curves;
-		return curves && (curves[this._segment1._index + 1]
-				|| this._path._closed && curves[0]) || null;
-	},
-
-	getPrevious: function() {
-		var curves = this._path && this._path._curves;
-		return curves && (curves[this._segment1._index - 1]
-				|| this._path._closed && curves[curves.length - 1]) || null;
-	},
-
-	isSelected: function() {
-		return this.getHandle1().isSelected() && this.getHandle2().isSelected();
-	},
-
-	setSelected: function(selected) {
-		this.getHandle1().setSelected(selected);
-		this.getHandle2().setSelected(selected);
-	},
-
-	getValues: function() {
-		return Curve.getValues(this._segment1, this._segment2);
-	},
-
-	getPoints: function() {
-		var coords = this.getValues(),
-			points = [];
-		for (var i = 0; i < 8; i += 2)
-			points.push(new Point(coords[i], coords[i + 1]));
-		return points;
-	},
-
-	getLength: function() {
-		var from = arguments[0],
-			to = arguments[1],
-			fullLength = arguments.length === 0 || from === 0 && to === 1;
-		if (fullLength && this._length != null)
-			return this._length;
-		var length = Curve.getLength(this.getValues(), from, to);
-		if (fullLength)
-			this._length = length;
-		return length;
-	},
-
-	getArea: function() {
-		return Curve.getArea(this.getValues());
-	},
-
-	getPart: function(from, to) {
-		return new Curve(Curve.getPart(this.getValues(), from, to));
-	},
-
-	isLinear: function() {
-		return this._segment1._handleOut.isZero()
-				&& this._segment2._handleIn.isZero();
-	},
-
-	getIntersections: function(curve) {
-		return Curve.getIntersections(this.getValues(), curve.getValues(),
-				this, curve, []);
-	},
-
-	reverse: function() {
-		return new Curve(this._segment2.reverse(), this._segment1.reverse());
-	},
-
-	_getParameter: function(offset, isParameter) {
-		return isParameter
-				? offset
-				: offset && offset.curve === this
-					? offset.parameter
-					: offset === undefined && isParameter === undefined
-						? 0.5 
-						: this.getParameterAt(offset, 0);
-	},
-
-	divide: function(offset, isParameter) {
-		var parameter = this._getParameter(offset, isParameter),
-			tolerance = 0.00001,
-			res = null;
-		if (parameter > tolerance && parameter < 1 - tolerance) {
-			var parts = Curve.subdivide(this.getValues(), parameter),
-				isLinear = this.isLinear(),
-				left = parts[0],
-				right = parts[1];
-
-			if (!isLinear) {
-				this._segment1._handleOut.set(left[2] - left[0],
-						left[3] - left[1]);
-				this._segment2._handleIn.set(right[4] - right[6],
-						right[5] - right[7]);
-			}
-
-			var x = left[6], y = left[7],
-				segment = new Segment(new Point(x, y),
-						!isLinear && new Point(left[4] - x, left[5] - y),
-						!isLinear && new Point(right[2] - x, right[3] - y));
-
-			if (this._path) {
-				if (this._segment1._index > 0 && this._segment2._index === 0) {
-					this._path.add(segment);
-				} else {
-					this._path.insert(this._segment2._index, segment);
-				}
-				res = this; 
-			} else {
-				var end = this._segment2;
-				this._segment2 = segment;
-				res = new Curve(segment, end);
-			}
-		}
-		return res;
-	},
-
-	split: function(offset, isParameter) {
-		return this._path
-			? this._path.split(this._segment1._index,
-					this._getParameter(offset, isParameter))
-			: null;
-	},
-
-	clone: function() {
-		return new Curve(this._segment1, this._segment2);
-	},
-
-	toString: function() {
-		var parts = [ 'point1: ' + this._segment1._point ];
-		if (!this._segment1._handleOut.isZero())
-			parts.push('handle1: ' + this._segment1._handleOut);
-		if (!this._segment2._handleIn.isZero())
-			parts.push('handle2: ' + this._segment2._handleIn);
-		parts.push('point2: ' + this._segment2._point);
-		return '{ ' + parts.join(', ') + ' }';
-	},
-
-statics: {
-	getValues: function(segment1, segment2) {
-		var p1 = segment1._point,
-			h1 = segment1._handleOut,
-			h2 = segment2._handleIn,
-			p2 = segment2._point;
-		return [
-			p1._x, p1._y,
-			p1._x + h1._x, p1._y + h1._y,
-			p2._x + h2._x, p2._y + h2._y,
-			p2._x, p2._y
-		];
-	},
-
-	evaluate: function(v, t, type) {
-		var p1x = v[0], p1y = v[1],
-			c1x = v[2], c1y = v[3],
-			c2x = v[4], c2y = v[5],
-			p2x = v[6], p2y = v[7],
-			x, y;
-
-		if (type === 0 && (t === 0 || t === 1)) {
-			x = t === 0 ? p1x : p2x;
-			y = t === 0 ? p1y : p2y;
-		} else {
-			var cx = 3 * (c1x - p1x),
-				bx = 3 * (c2x - c1x) - cx,
-				ax = p2x - p1x - cx - bx,
-
-				cy = 3 * (c1y - p1y),
-				by = 3 * (c2y - c1y) - cy,
-				ay = p2y - p1y - cy - by;
-			if (type === 0) {
-				x = ((ax * t + bx) * t + cx) * t + p1x;
-				y = ((ay * t + by) * t + cy) * t + p1y;
-			} else {
-				var tolerance = 0.00001;
-				if (t < tolerance && c1x === p1x && c1y === p1y
-						|| t > 1 - tolerance && c2x === p2x && c2y === p2y) {
-					x = p2x - p1x;
-					y = p2y - p1y;
-				} else {
-					x = (3 * ax * t + 2 * bx) * t + cx;
-					y = (3 * ay * t + 2 * by) * t + cy;
-				}
-				if (type === 3) {
-					var x2 = 6 * ax * t + 2 * bx,
-						y2 = 6 * ay * t + 2 * by;
-					return (x * y2 - y * x2) / Math.pow(x * x + y * y, 3 / 2);
-				}
-			}
-		}
-		return type == 2 ? new Point(y, -x) : new Point(x, y);
-	},
-
-	subdivide: function(v, t) {
-		var p1x = v[0], p1y = v[1],
-			c1x = v[2], c1y = v[3],
-			c2x = v[4], c2y = v[5],
-			p2x = v[6], p2y = v[7];
-		if (t === undefined)
-			t = 0.5;
-		var u = 1 - t,
-			p3x = u * p1x + t * c1x, p3y = u * p1y + t * c1y,
-			p4x = u * c1x + t * c2x, p4y = u * c1y + t * c2y,
-			p5x = u * c2x + t * p2x, p5y = u * c2y + t * p2y,
-			p6x = u * p3x + t * p4x, p6y = u * p3y + t * p4y,
-			p7x = u * p4x + t * p5x, p7y = u * p4y + t * p5y,
-			p8x = u * p6x + t * p7x, p8y = u * p6y + t * p7y;
-		return [
-			[p1x, p1y, p3x, p3y, p6x, p6y, p8x, p8y], 
-			[p8x, p8y, p7x, p7y, p5x, p5y, p2x, p2y] 
-		];
-	},
-
-	solveCubic: function (v, coord, val, roots, min, max) {
-		var p1 = v[coord],
-			c1 = v[coord + 2],
-			c2 = v[coord + 4],
-			p2 = v[coord + 6],
-			c = 3 * (c1 - p1),
-			b = 3 * (c2 - c1) - c,
-			a = p2 - p1 - c - b;
-		return Numerical.solveCubic(a, b, c, p1 - val, roots, min, max);
-	},
-
-	getParameterOf: function(v, x, y) {
-		if (Math.abs(v[0] - x) < 0.00001
-				&& Math.abs(v[1] - y) < 0.00001)
-			return 0;
-		if (Math.abs(v[6] - x) < 0.00001
-				&& Math.abs(v[7] - y) < 0.00001)
-			return 1;
-		var txs = [],
-			tys = [],
-			sx = Curve.solveCubic(v, 0, x, txs),
-			sy = Curve.solveCubic(v, 1, y, tys),
-			tx, ty;
-		for (var cx = 0;  sx == -1 || cx < sx;) {
-			if (sx == -1 || (tx = txs[cx++]) >= 0 && tx <= 1) {
-				for (var cy = 0; sy == -1 || cy < sy;) {
-					if (sy == -1 || (ty = tys[cy++]) >= 0 && ty <= 1) {
-						if (sx == -1) tx = ty;
-						else if (sy == -1) ty = tx;
-						if (Math.abs(tx - ty) < 0.00001)
-							return (tx + ty) * 0.5;
-					}
-				}
-				if (sx == -1)
-					break;
-			}
-		}
-		return null;
-	},
-
-	getPart: function(v, from, to) {
-		if (from > 0)
-			v = Curve.subdivide(v, from)[1]; 
-		if (to < 1)
-			v = Curve.subdivide(v, (to - from) / (1 - from))[0]; 
-		return v;
-	},
-
-	isLinear: function(v) {
-		var isZero = Numerical.isZero;
-		return isZero(v[0] - v[2]) && isZero(v[1] - v[3])
-				&& isZero(v[4] - v[6]) && isZero(v[5] - v[7]);
-	},
-
-	isFlatEnough: function(v, tolerance) {
-		var p1x = v[0], p1y = v[1],
-			c1x = v[2], c1y = v[3],
-			c2x = v[4], c2y = v[5],
-			p2x = v[6], p2y = v[7],
-			ux = 3 * c1x - 2 * p1x - p2x,
-			uy = 3 * c1y - 2 * p1y - p2y,
-			vx = 3 * c2x - 2 * p2x - p1x,
-			vy = 3 * c2y - 2 * p2y - p1y;
-		return Math.max(ux * ux, vx * vx) + Math.max(uy * uy, vy * vy)
-				< 10 * tolerance * tolerance;
-	},
-
-	getArea: function(v) {
-		var p1x = v[0], p1y = v[1],
-			c1x = v[2], c1y = v[3],
-			c2x = v[4], c2y = v[5],
-			p2x = v[6], p2y = v[7];
-		return (  3.0 * c1y * p1x - 1.5 * c1y * c2x
-				- 1.5 * c1y * p2x - 3.0 * p1y * c1x
-				- 1.5 * p1y * c2x - 0.5 * p1y * p2x
-				+ 1.5 * c2y * p1x + 1.5 * c2y * c1x
-				- 3.0 * c2y * p2x + 0.5 * p2y * p1x
-				+ 1.5 * p2y * c1x + 3.0 * p2y * c2x) / 10;
-	},
-
-	getBounds: function(v) {
-		var min = v.slice(0, 2), 
-			max = min.slice(), 
-			roots = [0, 0];
-		for (var i = 0; i < 2; i++)
-			Curve._addBounds(v[i], v[i + 2], v[i + 4], v[i + 6],
-					i, 0, min, max, roots);
-		return new Rectangle(min[0], min[1], max[0] - min[0], max[1] - min[1]);
-	},
-
-	_addBounds: function(v0, v1, v2, v3, coord, padding, min, max, roots) {
-		function add(value, padding) {
-			var left = value - padding,
-				right = value + padding;
-			if (left < min[coord])
-				min[coord] = left;
-			if (right > max[coord])
-				max[coord] = right;
-		}
-		var a = 3 * (v1 - v2) - v0 + v3,
-			b = 2 * (v0 + v2) - 4 * v1,
-			c = v1 - v0,
-			count = Numerical.solveQuadratic(a, b, c, roots),
-			tMin = 0.00001,
-			tMax = 1 - tMin;
-		add(v3, 0);
-		for (var i = 0; i < count; i++) {
-			var t = roots[i],
-				u = 1 - t;
-			if (tMin < t && t < tMax)
-				add(u * u * u * v0
-					+ 3 * u * u * t * v1
-					+ 3 * u * t * t * v2
-					+ t * t * t * v3,
-					padding);
-		}
-	},
-
-	_getWinding: function(v, prev, x, y, roots1, roots2) {
-		var tolerance = 0.00001,
-			abs = Math.abs;
-
-		function getDirection(v) {
-			var y0 = v[1],
-				y1 = v[7],
-				dir = y0 > y1 ? -1 : 1;
-			return dir === 1 && (y < y0 || y > y1)
-					|| dir === -1 && (y < y1 || y > y0)
-					? 0
-					: dir;
-		}
-
-		if (Curve.isLinear(v)) {
-			var dir = getDirection(v);
-			if (!dir)
-				return 0;
-			var cross = (v[6] - v[0]) * (y - v[1]) - (v[7] - v[1]) * (x - v[0]);
-			return (cross < -tolerance ? -1 : 1) == dir ? 0 : dir;
-		}
-
-		var y0 = v[1],
-			y1 = v[3],
-			y2 = v[5],
-			y3 = v[7];
-		var a = 3 * (y1 - y2) - y0 + y3,
-			b = 2 * (y0 + y2) - 4 * y1,
-			c = y1 - y0;
-		var count = Numerical.solveQuadratic(a, b, c, roots1, tolerance,
-				1 - tolerance),
-			part, 
-			rest = v, 
-			t1 = roots1[0], 
-			winding = 0;
-		for (var i = 0; i <= count; i++) {
-			if (i === count) {
-				part = rest;
-			} else {
-				var curves = Curve.subdivide(rest, t1);
-				part = curves[0];
-				rest = curves[1];
-				t1 = roots1[i];
-				t1 = (roots1[i + 1] - t1) / (1 - t1);
-			}
-			if (i > 0)
-				part[3] = part[1]; 
-			if (i < count)
-				part[5] = rest[1]; 
-			var dir = getDirection(part);
-			if (!dir)
-			    continue;
-			var t2,
-				px;
-			if (Curve.solveCubic(part, 1, y, roots2, -tolerance, 1 + -tolerance)
-					=== 1) {
-				t2 = roots2[0];
-				px = Curve.evaluate(part, t2, 0).x;
-			} else {
-				var mid = (part[1] + part[7]) / 2;
-				t2 = y < mid && dir > 0 ? 0 : 1;
-				if (t2 === 1 && y == part[7])
-					continue;
-				px = t2 === 0 ? part[0] : part[6];
-			}
-			var slope = Curve.evaluate(part, t2, 1).y,
-				stationary = abs(slope) < tolerance || t2 < tolerance
-						&& Curve.evaluate(prev, 1, 1).y * slope < 0;
-			if (x >= px + (stationary ? -tolerance : tolerance * dir)
-					&& !(stationary && (abs(t2) < tolerance
-							&& abs(x - part[0]) > tolerance
-						|| abs(t2 - 1) < tolerance
-							&& abs(x - part[6]) > tolerance))) {
-				winding += stationary && abs(t2 - (dir > 0 ? 1 : 0)) < tolerance
-						? -dir : dir;
-			}
-			prev = part;
-		}
-		return winding;
-	}
-}}, Base.each(['getBounds', 'getStrokeBounds', 'getHandleBounds', 'getRoughBounds'],
-	function(name) {
-		this[name] = function() {
-			if (!this._bounds)
-				this._bounds = {};
-			var bounds = this._bounds[name];
-			if (!bounds) {
-				bounds = this._bounds[name] = Path[name]([this._segment1,
-						this._segment2], false, this._path.getStyle());
-			}
-			return bounds.clone();
-		};
-	},
-{
-
-}), Base.each(['getPoint', 'getTangent', 'getNormal', 'getCurvature'],
-	function(name, index) {
-		this[name + 'At'] = function(offset, isParameter) {
-			var values = this.getValues();
-			return Curve.evaluate(values, isParameter
-					? offset : Curve.getParameterAt(values, offset, 0), index);
-		};
-		this[name] = function(parameter) {
-			return Curve.evaluate(this.getValues(), parameter, index);
-		};
-	},
-{
-	getParameterAt: function(offset, start) {
-		return Curve.getParameterAt(this.getValues(), offset,
-				start !== undefined ? start : offset < 0 ? 1 : 0);
-	},
-
-	getParameterOf: function(point) {
-		point = Point.read(arguments);
-		return Curve.getParameterOf(this.getValues(), point.x, point.y);
-	},
-
-	getLocationAt: function(offset, isParameter) {
-		if (!isParameter)
-			offset = this.getParameterAt(offset);
-		return new CurveLocation(this, offset);
-	},
-
-	getLocationOf: function(point) {
-		point = Point.read(arguments);
-		var t = this.getParameterOf(point);
-		return t != null ? new CurveLocation(this, t) : null;
-	},
-
-	getNearestLocation: function(point) {
-		point = Point.read(arguments);
-		var values = this.getValues(),
-			count = 100,
-			tolerance = Numerical.TOLERANCE,
-			minDist = Infinity,
-			minT = 0;
-
-		function refine(t) {
-			if (t >= 0 && t <= 1) {
-				var dist = point.getDistance(
-						Curve.evaluate(values, t, 0), true);
-				if (dist < minDist) {
-					minDist = dist;
-					minT = t;
-					return true;
-				}
-			}
-		}
-
-		for (var i = 0; i <= count; i++)
-			refine(i / count);
-
-		var step = 1 / (count * 2);
-		while (step > tolerance) {
-			if (!refine(minT - step) && !refine(minT + step))
-				step /= 2;
-		}
-		var pt = Curve.evaluate(values, minT, 0);
-		return new CurveLocation(this, minT, pt, null, null, null,
-				point.getDistance(pt));
-	},
-
-	getNearestPoint: function(point) {
-		point = Point.read(arguments);
-		return this.getNearestLocation(point).getPoint();
-	}
-
-}),
-new function() { 
-
-	function getLengthIntegrand(v) {
-		var p1x = v[0], p1y = v[1],
-			c1x = v[2], c1y = v[3],
-			c2x = v[4], c2y = v[5],
-			p2x = v[6], p2y = v[7],
-
-			ax = 9 * (c1x - c2x) + 3 * (p2x - p1x),
-			bx = 6 * (p1x + c2x) - 12 * c1x,
-			cx = 3 * (c1x - p1x),
-
-			ay = 9 * (c1y - c2y) + 3 * (p2y - p1y),
-			by = 6 * (p1y + c2y) - 12 * c1y,
-			cy = 3 * (c1y - p1y);
-
-		return function(t) {
-			var dx = (ax * t + bx) * t + cx,
-				dy = (ay * t + by) * t + cy;
-			return Math.sqrt(dx * dx + dy * dy);
-		};
-	}
-
-	function getIterations(a, b) {
-		return Math.max(2, Math.min(16, Math.ceil(Math.abs(b - a) * 32)));
-	}
-
-	return {
-		statics: true,
-
-		getLength: function(v, a, b) {
-			if (a === undefined)
-				a = 0;
-			if (b === undefined)
-				b = 1;
-			var isZero = Numerical.isZero;
-			if (isZero(v[0] - v[2]) && isZero(v[1] - v[3])
-					&& isZero(v[6] - v[4]) && isZero(v[7] - v[5])) {
-				var dx = v[6] - v[0], 
-					dy = v[7] - v[1]; 
-				return (b - a) * Math.sqrt(dx * dx + dy * dy);
-			}
-			var ds = getLengthIntegrand(v);
-			return Numerical.integrate(ds, a, b, getIterations(a, b));
-		},
-
-		getParameterAt: function(v, offset, start) {
-			if (offset === 0)
-				return start;
-			var forward = offset > 0,
-				a = forward ? start : 0,
-				b = forward ? 1 : start,
-				offset = Math.abs(offset),
-				ds = getLengthIntegrand(v),
-				rangeLength = Numerical.integrate(ds, a, b,
-						getIterations(a, b));
-			if (offset >= rangeLength)
-				return forward ? b : a;
-			var guess = offset / rangeLength,
-				length = 0;
-			function f(t) {
-				var count = getIterations(start, t);
-				length += start < t
-						? Numerical.integrate(ds, start, t, count)
-						: -Numerical.integrate(ds, t, start, count);
-				start = t;
-				return length - offset;
-			}
-			return Numerical.findRoot(f, ds,
-					forward ? a + guess : b - guess, 
-					a, b, 16, 0.00001);
-		}
-	};
-}, new function() { 
-	function addLocation(locations, curve1, t1, point1, curve2, t2, point2) {
-		var first = locations[0],
-			last = locations[locations.length - 1];
-		if ((!first || !point1.isClose(first._point, Numerical.EPSILON))
-				&& (!last || !point1.isClose(last._point, Numerical.EPSILON)))
-			locations.push(
-					new CurveLocation(curve1, t1, point1, curve2, t2, point2));
-	}
-
-	function addCurveIntersections(v1, v2, curve1, curve2, locations,
-			range1, range2, recursion) {
-		recursion = (recursion || 0) + 1;
-		if (recursion > 20)
-			return;
-		range1 = range1 || [ 0, 1 ];
-		range2 = range2 || [ 0, 1 ];
-		var part1 = Curve.getPart(v1, range1[0], range1[1]),
-			part2 = Curve.getPart(v2, range2[0], range2[1]),
-			iteration = 0;
-		while (iteration++ < 20) {
-			var range,
-				intersects1 = clipFatLine(part1, part2, range = range2.slice()),
-				intersects2 = 0;
-			if (intersects1 === 0)
-				break;
-			if (intersects1 > 0) {
-				range2 = range;
-				part2 = Curve.getPart(v2, range2[0], range2[1]);
-				intersects2 = clipFatLine(part2, part1, range = range1.slice());
-				if (intersects2 === 0)
-					break;
-				if (intersects1 > 0) {
-					range1 = range;
-					part1 = Curve.getPart(v1, range1[0], range1[1]);
-				}
-			}
-			if (intersects1 < 0 || intersects2 < 0) {
-				if (range1[1] - range1[0] > range2[1] - range2[0]) {
-					var t = (range1[0] + range1[1]) / 2;
-					addCurveIntersections(v1, v2, curve1, curve2, locations,
-							[ range1[0], t ], range2, recursion);
-					addCurveIntersections(v1, v2, curve1, curve2, locations,
-							[ t, range1[1] ], range2, recursion);
-					break;
-				} else {
-					var t = (range2[0] + range2[1]) / 2;
-					addCurveIntersections(v1, v2, curve1, curve2, locations,
-							range1, [ range2[0], t ], recursion);
-					addCurveIntersections(v1, v2, curve1, curve2, locations,
-							range1, [ t, range2[1] ], recursion);
-					break;
-				}
-			}
-			if (Math.abs(range1[1] - range1[0]) <= 0.00001 &&
-				Math.abs(range2[1] - range2[0]) <= 0.00001) {
-				var t1 = (range1[0] + range1[1]) / 2,
-					t2 = (range2[0] + range2[1]) / 2;
-				addLocation(locations,
-						curve1, t1, Curve.evaluate(v1, t1, 0),
-						curve2, t2, Curve.evaluate(v2, t2, 0));
-				break;
-			}
-		}
-	}
-
-	function clipFatLine(v1, v2, range2) {
-		var p0x = v1[0], p0y = v1[1], p1x = v1[2], p1y = v1[3],
-			p2x = v1[4], p2y = v1[5], p3x = v1[6], p3y = v1[7],
-			q0x = v2[0], q0y = v2[1], q1x = v2[2], q1y = v2[3],
-			q2x = v2[4], q2y = v2[5], q3x = v2[6], q3y = v2[7],
-			getSignedDistance = Line.getSignedDistance,
-			d1 = getSignedDistance(p0x, p0y, p3x, p3y, p1x, p1y) || 0,
-			d2 = getSignedDistance(p0x, p0y, p3x, p3y, p2x, p2y) || 0,
-			factor = d1 * d2 > 0 ? 3 / 4 : 4 / 9,
-			dmin = factor * Math.min(0, d1, d2),
-			dmax = factor * Math.max(0, d1, d2),
-			dq0 = getSignedDistance(p0x, p0y, p3x, p3y, q0x, q0y),
-			dq1 = getSignedDistance(p0x, p0y, p3x, p3y, q1x, q1y),
-			dq2 = getSignedDistance(p0x, p0y, p3x, p3y, q2x, q2y),
-			dq3 = getSignedDistance(p0x, p0y, p3x, p3y, q3x, q3y);
-		if (dmin > Math.max(dq0, dq1, dq2, dq3)
-				|| dmax < Math.min(dq0, dq1, dq2, dq3))
-			return 0;
-		var hull = getConvexHull(dq0, dq1, dq2, dq3),
-			swap;
-		if (dq3 < dq0) {
-			swap = dmin;
-			dmin = dmax;
-			dmax = swap;
-		}
-		var tmaxdmin = -Infinity,
-			tmin = Infinity,
-			tmax = -Infinity;
-		for (var i = 0, l = hull.length; i < l; i++) {
-			var p1 = hull[i],
-				p2 = hull[(i + 1) % l];
-			if (p2[1] < p1[1]) {
-				swap = p2;
-				p2 = p1;
-				p1 = swap;
-			}
-			var	x1 = p1[0],
-				y1 = p1[1],
-				x2 = p2[0],
-				y2 = p2[1];
-			var inv = (y2 - y1) / (x2 - x1);
-			if (dmin >= y1 && dmin <= y2) {
-				var ixdx = x1 + (dmin - y1) / inv;
-				if (ixdx < tmin)
-					tmin = ixdx;
-				if (ixdx > tmaxdmin)
-					tmaxdmin = ixdx;
-			}
-			if (dmax >= y1 && dmax <= y2) {
-				var ixdx = x1 + (dmax - y1) / inv;
-				if (ixdx > tmax)
-					tmax = ixdx;
-				if (ixdx < tmin)
-					tmin = 0;
-			}
-		}
-		if (tmin !== Infinity && tmax !== -Infinity) {
-			var min = Math.min(dmin, dmax),
-				max = Math.max(dmin, dmax);
-			if (dq3 > min && dq3 < max)
-				tmax = 1;
-			if (dq0 > min && dq0 < max)
-				tmin = 0;
-			if (tmaxdmin > tmax)
-				tmax = 1;
-			var v2tmin = range2[0],
-				tdiff = range2[1] - v2tmin;
-			range2[0] = v2tmin + tmin * tdiff;
-			range2[1] = v2tmin + tmax * tdiff;
-			if ((tdiff - (range2[1] - range2[0])) / tdiff >= 0.2)
-				return 1;
-		}
-		if (Curve.getBounds(v1).touches(Curve.getBounds(v2)))
-			return -1;
-		return 0;
-	}
-
-	function getConvexHull(dq0, dq1, dq2, dq3) {
-		var p0 = [ 0, dq0 ],
-			p1 = [ 1 / 3, dq1 ],
-			p2 = [ 2 / 3, dq2 ],
-			p3 = [ 1, dq3 ],
-			getSignedDistance = Line.getSignedDistance,
-			dist1 = getSignedDistance(0, dq0, 1, dq3, 1 / 3, dq1),
-			dist2 = getSignedDistance(0, dq0, 1, dq3, 2 / 3, dq2);
-		if (dist1 * dist2 < 0) {
-			return [ p0, p1, p3, p2 ];
-		}
-		var pmax, cross;
-		if (Math.abs(dist1) > Math.abs(dist2)) {
-			pmax = p1;
-			cross = (dq3 - dq2 - (dq3 - dq0) / 3)
-					* (2 * (dq3 - dq2) - dq3 + dq1) / 3;
-		} else {
-			pmax = p2;
-			cross = (dq1 - dq0 + (dq0 - dq3) / 3)
-					* (-2 * (dq0 - dq1) + dq0 - dq2) / 3;
-		}
-		return cross < 0
-				? [ p0, pmax, p3 ]
-				: [ p0, p1, p2, p3 ];
-	}
-
-	function addCurveLineIntersections(v1, v2, curve1, curve2, locations) {
-		var flip = Curve.isLinear(v1),
-			vc = flip ? v2 : v1,
-			vl = flip ? v1 : v2,
-			lx1 = vl[0], ly1 = vl[1],
-			lx2 = vl[6], ly2 = vl[7],
-			ldx = lx2 - lx1,
-			ldy = ly2 - ly1,
-			angle = Math.atan2(-ldy, ldx),
-			sin = Math.sin(angle),
-			cos = Math.cos(angle),
-			rlx2 = ldx * cos - ldy * sin,
-			rvl = [0, 0, 0, 0, rlx2, 0, rlx2, 0],
-			rvc = [];
-		for(var i = 0; i < 8; i += 2) {
-			var x = vc[i] - lx1,
-				y = vc[i + 1] - ly1;
-			rvc.push(
-				x * cos - y * sin,
-				y * cos + x * sin);
-		}
-		var roots = [],
-			count = Curve.solveCubic(rvc, 1, 0, roots, 0, 1);
-		for (var i = 0; i < count; i++) {
-			var tc = roots[i],
-				x = Curve.evaluate(rvc, tc, 0).x;
-			if (x >= 0 && x <= rlx2) {
-				var tl = Curve.getParameterOf(rvl, x, 0),
-					t1 = flip ? tl : tc,
-					t2 = flip ? tc : tl;
-				addLocation(locations,
-						curve1, t1, Curve.evaluate(v1, t1, 0),
-						curve2, t2, Curve.evaluate(v2, t2, 0));
-			}
-		}
-	}
-
-	function addLineIntersection(v1, v2, curve1, curve2, locations) {
-		var point = Line.intersect(
-				v1[0], v1[1], v1[6], v1[7],
-				v2[0], v2[1], v2[6], v2[7]);
-		if (point)
-			addLocation(locations, curve1, null, point, curve2);
-	}
-
-	return { statics: {
-		getIntersections: function(v1, v2, curve1, curve2, locations) {
-			var linear1 = Curve.isLinear(v1),
-				linear2 = Curve.isLinear(v2),
-				c1p1 = curve1.getPoint1(),
-				c1p2 = curve1.getPoint2(),
-				c2p1 = curve2.getPoint1(),
-				c2p2 = curve2.getPoint2(),
-				tolerance = 0.00001;
-			if (c1p1.isClose(c2p1, tolerance))
-				addLocation(locations, curve1, 0, c1p1, curve2, 0, c1p1);
-			if (c1p1.isClose(c2p2, tolerance))
-				addLocation(locations, curve1, 0, c1p1, curve2, 1, c1p1);
-			(linear1 && linear2
-				? addLineIntersection
-				: linear1 || linear2
-					? addCurveLineIntersections
-					: addCurveIntersections)(v1, v2, curve1, curve2, locations);
-			if (c1p2.isClose(c2p1, tolerance))
-				addLocation(locations, curve1, 1, c1p2, curve2, 0, c1p2);
-			if (c1p2.isClose(c2p2, tolerance))
-				addLocation(locations, curve1, 1, c1p2, curve2, 1, c1p2);
-			return locations;
-		}
-	}};
-});
-
-var CurveLocation = Base.extend({
-	_class: 'CurveLocation',
-	initialize: function CurveLocation(curve, parameter, point, _curve2,
-			_parameter2, _point2, _distance) {
-		this._id = CurveLocation._id = (CurveLocation._id || 0) + 1;
-		this._curve = curve;
-		this._segment1 = curve._segment1;
-		this._segment2 = curve._segment2;
-		this._parameter = parameter;
-		this._point = point;
-		this._curve2 = _curve2;
-		this._parameter2 = _parameter2;
-		this._point2 = _point2;
-		this._distance = _distance;
-	},
-
-	getSegment: function() {
-		if (!this._segment) {
-			var curve = this.getCurve(),
-				parameter = this.getParameter();
-			if (parameter === 1) {
-				this._segment = curve._segment2;
-			} else if (parameter === 0 || arguments[0]) {
-				this._segment = curve._segment1;
-			} else if (parameter == null) {
-				return null;
-			} else {
-				this._segment = curve.getLength(0, parameter)
-					< curve.getLength(parameter, 1)
-						? curve._segment1
-						: curve._segment2;
-			}
-		}
-		return this._segment;
-	},
-
-	getCurve: function() {
-		if (!this._curve || arguments[0]) {
-			this._curve = this._segment1.getCurve();
-			if (this._curve.getParameterOf(this._point) == null)
-				this._curve = this._segment2.getPrevious().getCurve();
-		}
-		return this._curve;
-	},
-
-	getIntersection: function() {
-		var intersection = this._intersection;
-		if (!intersection && this._curve2) {
-			var param = this._parameter2;
-			this._intersection = intersection = new CurveLocation(
-					this._curve2, param, this._point2 || this._point, this);
-			intersection._intersection = this;
-		}
-		return intersection;
-	},
-
-	getPath: function() {
-		var curve = this.getCurve();
-		return curve && curve._path;
-	},
-
-	getIndex: function() {
-		var curve = this.getCurve();
-		return curve && curve.getIndex();
-	},
-
-	getOffset: function() {
-		var path = this.getPath();
-		return path && path._getOffset(this);
-	},
-
-	getCurveOffset: function() {
-		var curve = this.getCurve(),
-			parameter = this.getParameter();
-		return parameter != null && curve && curve.getLength(0, parameter);
-	},
-
-	getParameter: function() {
-		if ((this._parameter == null || arguments[0]) && this._point) {
-			var curve = this.getCurve(arguments[0] && this._point);
-			this._parameter = curve && curve.getParameterOf(this._point);
-		}
-		return this._parameter;
-	},
-
-	getPoint: function() {
-		if ((!this._point || arguments[0]) && this._parameter != null) {
-			var curve = this.getCurve();
-			this._point = curve && curve.getPointAt(this._parameter, true);
-		}
-		return this._point;
-	},
-
-	getTangent: function() {
-		var parameter = this.getParameter(),
-			curve = this.getCurve();
-		return parameter != null && curve && curve.getTangentAt(parameter, true);
-	},
-
-	getNormal: function() {
-		var parameter = this.getParameter(),
-			curve = this.getCurve();
-		return parameter != null && curve && curve.getNormalAt(parameter, true);
-	},
-
-	getDistance: function() {
-		return this._distance;
-	},
-
-	divide: function() {
-		var curve = this.getCurve(true);
-		return curve && curve.divide(this.getParameter(true), true);
-	},
-
-	split: function() {
-		var curve = this.getCurve(true);
-		return curve && curve.split(this.getParameter(true), true);
-	},
-
-	toString: function() {
-		var parts = [],
-			point = this.getPoint(),
-			f = Formatter.instance;
-		if (point)
-			parts.push('point: ' + point);
-		var index = this.getIndex();
-		if (index != null)
-			parts.push('index: ' + index);
-		var parameter = this.getParameter();
-		if (parameter != null)
-			parts.push('parameter: ' + f.number(parameter));
-		if (this._distance != null)
-			parts.push('distance: ' + f.number(this._distance));
-		return '{ ' + parts.join(', ') + ' }';
-	}
-});
-
-var PathItem = Item.extend({
-	_class: 'PathItem',
-
-	initialize: function PathItem() {
-	},
-
-	getIntersections: function(path) {
-		if (!this.getBounds().touches(path.getBounds()))
-			return [];
-		var locations = [],
-			curves1 = this.getCurves(),
-			curves2 = path.getCurves(),
-			length2 = curves2.length,
-			values2 = [];
-		for (var i = 0; i < length2; i++)
-			values2[i] = curves2[i].getValues();
-		for (var i = 0, l = curves1.length; i < l; i++) {
-			var curve1 = curves1[i],
-				values1 = curve1.getValues();
-			for (var j = 0; j < length2; j++)
-				Curve.getIntersections(values1, values2[j], curve1, curves2[j],
-						locations);
-		}
-		return locations;
-	},
-
-	setPathData: function(data) {
-
-		var parts = data.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/ig),
-			coords,
-			relative = false,
-			control,
-			current = new Point(); 
-
-		function getCoord(index, coord, isCurrent) {
-			var val = parseFloat(coords[index]);
-			if (relative)
-				val += current[coord];
-			if (isCurrent)
-				current[coord] = val;
-			return val;
-		}
-
-		function getPoint(index, isCurrent) {
-			return new Point(
-				getCoord(index, 'x', isCurrent),
-				getCoord(index + 1, 'y', isCurrent)
-			);
-		}
-
-		this.clear();
-
-		for (var i = 0, l = parts.length; i < l; i++) {
-			var part = parts[i],
-				cmd = part[0],
-				lower = cmd.toLowerCase();
-			coords = part.match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g);
-			var length = coords && coords.length;
-			relative = cmd === lower;
-			switch (lower) {
-			case 'm':
-			case 'l':
-				for (var j = 0; j < length; j += 2)
-					this[j === 0 && lower === 'm' ? 'moveTo' : 'lineTo'](
-							getPoint(j, true));
-				control = current;
-				break;
-			case 'h':
-			case 'v':
-				var coord = lower == 'h' ? 'x' : 'y';
-				for (var j = 0; j < length; j++) {
-					getCoord(j, coord, true);
-					this.lineTo(current);
-				}
-				control = current;
-				break;
-			case 'c':
-				for (var j = 0; j < length; j += 6) {
-					this.cubicCurveTo(
-							getPoint(j),
-							control = getPoint(j + 2),
-							getPoint(j + 4, true));
-				}
-				break;
-			case 's':
-				for (var j = 0; j < length; j += 4) {
-					this.cubicCurveTo(
-							current.multiply(2).subtract(control),
-							control = getPoint(j),
-							getPoint(j + 2, true));
-				}
-				break;
-			case 'q':
-				for (var j = 0; j < length; j += 4) {
-					this.quadraticCurveTo(
-							control = getPoint(j),
-							getPoint(j + 2, true));
-				}
-				break;
-			case 't':
-				for (var j = 0; j < length; j += 2) {
-					this.quadraticCurveTo(
-							control = current.multiply(2).subtract(control),
-							getPoint(j, true));
-				}
-				break;
-			case 'a':
-				break;
-			case 'z':
-				this.closePath();
-				break;
-			}
-		}
-	},
-
-	_canComposite: function() {
-		return !(this.hasFill() && this.hasStroke());
-	},
-
-	_contains: function(point) {
-		var winding = this._getWinding(point);
-		return !!(this.getWindingRule() === 'evenodd' ? winding & 1 : winding);
-	}
-
-});
-
-var Path = PathItem.extend({
-	_class: 'Path',
-	_serializeFields: {
-		segments: [],
-		closed: false
-	},
-
-	initialize: function Path(arg) {
-		this._closed = false;
-		this._segments = [];
-		var segments = Array.isArray(arg)
-			? typeof arg[0] === 'object'
-				? arg
-				: arguments
-			: arg && (arg.point !== undefined && arg.size === undefined
-					|| arg.x !== undefined)
-				? arguments
-				: null;
-		this.setSegments(segments || []);
-		this._initialize(!segments && arg);
-	},
-
-	_equals: function(item) {
-		return Base.equals(this._segments, item._segments);
-	},
-
-	clone: function(insert) {
-		var copy = this._clone(new Path({
-			segments: this._segments,
-			insert: false
-		}), insert);
-		copy._closed = this._closed;
-		if (this._clockwise !== undefined)
-			copy._clockwise = this._clockwise;
-		return copy;
-	},
-
-	_changed: function _changed(flags) {
-		_changed.base.call(this, flags);
-		if (flags & 4) {
-			delete this._length;
-			delete this._clockwise;
-			if (this._curves) {
-				for (var i = 0, l = this._curves.length; i < l; i++)
-					this._curves[i]._changed(5);
-			}
-		} else if (flags & 8) {
-			delete this._bounds;
-		}
-	},
-
-	getSegments: function() {
-		return this._segments;
-	},
-
-	setSegments: function(segments) {
-		var fullySelected = this.isFullySelected();
-		this._segments.length = 0;
-		this._selectedSegmentState = 0;
-		delete this._curves;
-		this._add(Segment.readAll(segments));
-		if (fullySelected)
-			this.setFullySelected(true);
-	},
-
-	getFirstSegment: function() {
-		return this._segments[0];
-	},
-
-	getLastSegment: function() {
-		return this._segments[this._segments.length - 1];
-	},
-
-	getCurves: function() {
-		var curves = this._curves,
-			segments = this._segments;
-		if (!curves) {
-			var length = this._countCurves();
-			curves = this._curves = new Array(length);
-			for (var i = 0; i < length; i++)
-				curves[i] = new Curve(this, segments[i],
-					segments[i + 1] || segments[0]);
-		}
-		return curves;
-	},
-
-	getFirstCurve: function() {
-		return this.getCurves()[0];
-	},
-
-	getLastCurve: function() {
-		var curves = this.getCurves();
-		return curves[curves.length - 1];
-	},
-
-	getPathData: function() {
-		var segments = this._segments,
-			precision = arguments[0],
-			f = Formatter.instance,
-			parts = [];
-
-		function addCurve(seg1, seg2, skipLine) {
-			var point1 = seg1._point,
-				point2 = seg2._point,
-				handle1 = seg1._handleOut,
-				handle2 = seg2._handleIn;
-			if (handle1.isZero() && handle2.isZero()) {
-				if (!skipLine) {
-					parts.push('L' + f.point(point2, precision));
-				}
-			} else {
-				var end = point2.subtract(point1);
-				parts.push('c' + f.point(handle1, precision)
-						+ ' ' + f.point(end.add(handle2), precision)
-						+ ' ' + f.point(end, precision));
-			}
-		}
-
-		if (segments.length === 0)
-			return '';
-		parts.push('M' + f.point(segments[0]._point));
-		for (var i = 0, l = segments.length  - 1; i < l; i++)
-			addCurve(segments[i], segments[i + 1], false);
-		if (this._closed) {
-			addCurve(segments[segments.length - 1], segments[0], true);
-			parts.push('z');
-		}
-		return parts.join('');
-	},
-
-	isClosed: function() {
-		return this._closed;
-	},
-
-	setClosed: function(closed) {
-		if (this._closed != (closed = !!closed)) {
-			this._closed = closed;
-			if (this._curves) {
-				var length = this._curves.length = this._countCurves();
-				if (closed)
-					this._curves[length - 1] = new Curve(this,
-						this._segments[length - 1], this._segments[0]);
-			}
-			this._changed(5);
-		}
-	},
-
-	isEmpty: function() {
-		return this._segments.length === 0;
-	},
-
-	isPolygon: function() {
-		for (var i = 0, l = this._segments.length; i < l; i++) {
-			if (!this._segments[i].isLinear())
-				return false;
-		}
-		return true;
-	},
-
-	_applyMatrix: function(matrix) {
-		var coords = new Array(6);
-		for (var i = 0, l = this._segments.length; i < l; i++)
-			this._segments[i]._transformCoordinates(matrix, coords, true);
-		return true;
-	},
-
-	_add: function(segs, index) {
-		var segments = this._segments,
-			curves = this._curves,
-			amount = segs.length,
-			append = index == null,
-			index = append ? segments.length : index;
-		for (var i = 0; i < amount; i++) {
-			var segment = segs[i];
-			if (segment._path)
-				segment = segs[i] = segment.clone();
-			segment._path = this;
-			segment._index = index + i;
-			if (segment._selectionState)
-				this._updateSelection(segment, 0, segment._selectionState);
-		}
-		if (append) {
-			segments.push.apply(segments, segs);
-		} else {
-			segments.splice.apply(segments, [index, 0].concat(segs));
-			for (var i = index + amount, l = segments.length; i < l; i++)
-				segments[i]._index = i;
-		}
-		if (curves || segs._curves) {
-			if (!curves)
-				curves = this._curves = [];
-			var from = index > 0 ? index - 1 : index,
-				start = from,
-				to = Math.min(from + amount, this._countCurves());
-			if (segs._curves) {
-				curves.splice.apply(curves, [from, 0].concat(segs._curves));
-				start += segs._curves.length;
-			}
-			for (var i = start; i < to; i++)
-				curves.splice(i, 0, new Curve(this, null, null));
-			this._adjustCurves(from, to);
-		}
-		this._changed(5);
-		return segs;
-	},
-
-	_adjustCurves: function(from, to) {
-		var segments = this._segments,
-			curves = this._curves,
-			curve;
-		for (var i = from; i < to; i++) {
-			curve = curves[i];
-			curve._path = this;
-			curve._segment1 = segments[i];
-			curve._segment2 = segments[i + 1] || segments[0];
-		}
-		if (curve = curves[this._closed && from === 0 ? segments.length - 1
-				: from - 1])
-			curve._segment2 = segments[from] || segments[0];
-		if (curve = curves[to])
-			curve._segment1 = segments[to];
-	},
-
-	_countCurves: function() {
-		var length = this._segments.length;
-		return !this._closed && length > 0 ? length - 1 : length;
-	},
-
-	add: function(segment1 ) {
-		return arguments.length > 1 && typeof segment1 !== 'number'
-			? this._add(Segment.readAll(arguments))
-			: this._add([ Segment.read(arguments) ])[0];
-	},
-
-	insert: function(index, segment1 ) {
-		return arguments.length > 2 && typeof segment1 !== 'number'
-			? this._add(Segment.readAll(arguments, 1), index)
-			: this._add([ Segment.read(arguments, 1) ], index)[0];
-	},
-
-	addSegment: function() {
-		return this._add([ Segment.read(arguments) ])[0];
-	},
-
-	insertSegment: function(index ) {
-		return this._add([ Segment.read(arguments, 1) ], index)[0];
-	},
-
-	addSegments: function(segments) {
-		return this._add(Segment.readAll(segments));
-	},
-
-	insertSegments: function(index, segments) {
-		return this._add(Segment.readAll(segments), index);
-	},
-
-	removeSegment: function(index) {
-		return this.removeSegments(index, index + 1)[0] || null;
-	},
-
-	removeSegments: function(from, to) {
-		from = from || 0;
-		to = Base.pick(to, this._segments.length);
-		var segments = this._segments,
-			curves = this._curves,
-			count = segments.length, 
-			removed = segments.splice(from, to - from),
-			amount = removed.length;
-		if (!amount)
-			return removed;
-		for (var i = 0; i < amount; i++) {
-			var segment = removed[i];
-			if (segment._selectionState)
-				this._updateSelection(segment, segment._selectionState, 0);
-			delete segment._index;
-			delete segment._path;
-		}
-		for (var i = from, l = segments.length; i < l; i++)
-			segments[i]._index = i;
-		if (curves) {
-			var index = from > 0 && to === count + (this._closed ? 1 : 0)
-					? from - 1
-					: from,
-				curves = curves.splice(index, amount);
-			if (arguments[2])
-				removed._curves = curves.slice(1);
-			this._adjustCurves(index, index);
-		}
-		this._changed(5);
-		return removed;
-	},
-
-	clear: '#removeSegments',
-
-	isFullySelected: function() {
-		var length = this._segments.length;
-		return this._selected && length > 0 && this._selectedSegmentState
-				=== length * 4;
-	},
-
-	setFullySelected: function(selected) {
-		if (selected)
-			this._selectSegments(true);
-		this.setSelected(selected);
-	},
-
-	setSelected: function setSelected(selected) {
-		if (!selected)
-			this._selectSegments(false);
-		setSelected.base.call(this, selected);
-	},
-
-	_selectSegments: function(selected) {
-		var length = this._segments.length;
-		this._selectedSegmentState = selected
-				? length * 4 : 0;
-		for (var i = 0; i < length; i++)
-			this._segments[i]._selectionState = selected
-					? 4 : 0;
-	},
-
-	_updateSelection: function(segment, oldState, newState) {
-		segment._selectionState = newState;
-		var total = this._selectedSegmentState += newState - oldState;
-		if (total > 0)
-			this.setSelected(true);
-	},
-
-	flatten: function(maxDistance) {
-		var flattener = new PathFlattener(this),
-			pos = 0,
-			step = flattener.length / Math.ceil(flattener.length / maxDistance),
-			end = flattener.length + (this._closed ? -step : step) / 2;
-		var segments = [];
-		while (pos <= end) {
-			segments.push(new Segment(flattener.evaluate(pos, 0)));
-			pos += step;
-		}
-		this.setSegments(segments);
-	},
-
-	simplify: function(tolerance) {
-		if (this._segments.length > 2) {
-			var fitter = new PathFitter(this, tolerance || 2.5);
-			this.setSegments(fitter.fit());
-		}
-	},
-
-	split: function(index, parameter) {
-		if (parameter === null)
-			return;
-		if (arguments.length === 1) {
-			var arg = index;
-			if (typeof arg === 'number')
-				arg = this.getLocationAt(arg);
-			index = arg.index;
-			parameter = arg.parameter;
-		}
-		if (parameter >= 1) {
-			index++;
-			parameter--;
-		}
-		var curves = this.getCurves();
-		if (index >= 0 && index < curves.length) {
-			if (parameter > 0) {
-				curves[index++].divide(parameter, true);
-			}
-			var segs = this.removeSegments(index, this._segments.length, true),
-				path;
-			if (this._closed) {
-				this.setClosed(false);
-				path = this;
-			} else if (index > 0) {
-				path = this._clone(new Path().insertAbove(this, true));
-			}
-			path._add(segs, 0);
-			this.addSegment(segs[0]);
-			return path;
-		}
-		return null;
-	},
-
-	isClockwise: function() {
-		if (this._clockwise !== undefined)
-			return this._clockwise;
-		return Path.isClockwise(this._segments);
-	},
-
-	setClockwise: function(clockwise) {
-		if (this.isClockwise() != (clockwise = !!clockwise))
-			this.reverse();
-		this._clockwise = clockwise;
-	},
-
-	reverse: function() {
-		this._segments.reverse();
-		for (var i = 0, l = this._segments.length; i < l; i++) {
-			var segment = this._segments[i];
-			var handleIn = segment._handleIn;
-			segment._handleIn = segment._handleOut;
-			segment._handleOut = handleIn;
-			segment._index = i;
-		}
-		delete this._curves;
-		if (this._clockwise !== undefined)
-			this._clockwise = !this._clockwise;
-	},
-
-	join: function(path) {
-		if (path) {
-			var segments = path._segments,
-				last1 = this.getLastSegment(),
-				last2 = path.getLastSegment();
-			if (last1._point.equals(last2._point))
-				path.reverse();
-			var first1,
-				first2 = path.getFirstSegment();
-			if (last1._point.equals(first2._point)) {
-				last1.setHandleOut(first2._handleOut);
-				this._add(segments.slice(1));
-			} else {
-				first1 = this.getFirstSegment();
-				if (first1._point.equals(first2._point))
-					path.reverse();
-				last2 = path.getLastSegment();
-				if (first1._point.equals(last2._point)) {
-					first1.setHandleIn(last2._handleIn);
-					this._add(segments.slice(0, segments.length - 1), 0);
-				} else {
-					this._add(segments.slice());
-				}
-			}
-			if (path.closed)
-				this._add([segments[0]]);
-			path.remove();
-			first1 = this.getFirstSegment();
-			last1 = this.getLastSegment();
-			if (last1._point.equals(first1._point)) {
-				first1.setHandleIn(last1._handleIn);
-				last1.remove();
-				this.setClosed(true);
-			}
-			this._changed(5);
-			return true;
-		}
-		return false;
-	},
-
-	getLength: function() {
-		if (this._length == null) {
-			var curves = this.getCurves();
-			this._length = 0;
-			for (var i = 0, l = curves.length; i < l; i++)
-				this._length += curves[i].getLength();
-		}
-		return this._length;
-	},
-
-	getArea: function() {
-		var curves = this.getCurves();
-		var area = 0;
-		for (var i = 0, l = curves.length; i < l; i++)
-			area += curves[i].getArea();
-		return area;
-	},
-
-	_getOffset: function(location) {
-		var index = location && location.getIndex();
-		if (index != null) {
-			var curves = this.getCurves(),
-				offset = 0;
-			for (var i = 0; i < index; i++)
-				offset += curves[i].getLength();
-			var curve = curves[index];
-			return offset + curve.getLength(0, location.getParameter());
-		}
-		return null;
-	},
-
-	getLocationOf: function(point) {
-		point = Point.read(arguments);
-		var curves = this.getCurves();
-		for (var i = 0, l = curves.length; i < l; i++) {
-			var loc = curves[i].getLocationOf(point);
-			if (loc)
-				return loc;
-		}
-		return null;
-	},
-
-	getLocationAt: function(offset, isParameter) {
-		var curves = this.getCurves(),
-			length = 0;
-		if (isParameter) {
-			var index = ~~offset; 
-			return curves[index].getLocationAt(offset - index, true);
-		}
-		for (var i = 0, l = curves.length; i < l; i++) {
-			var start = length,
-				curve = curves[i];
-			length += curve.getLength();
-			if (length >= offset) {
-				return curve.getLocationAt(offset - start);
-			}
-		}
-		if (offset <= this.getLength())
-			return new CurveLocation(curves[curves.length - 1], 1);
-		return null;
-	},
-
-	getPointAt: function(offset, isParameter) {
-		var loc = this.getLocationAt(offset, isParameter);
-		return loc && loc.getPoint();
-	},
-
-	getTangentAt: function(offset, isParameter) {
-		var loc = this.getLocationAt(offset, isParameter);
-		return loc && loc.getTangent();
-	},
-
-	getNormalAt: function(offset, isParameter) {
-		var loc = this.getLocationAt(offset, isParameter);
-		return loc && loc.getNormal();
-	},
-
-	getNearestLocation: function(point) {
-		point = Point.read(arguments);
-		var curves = this.getCurves(),
-			minDist = Infinity,
-			minLoc = null;
-		for (var i = 0, l = curves.length; i < l; i++) {
-			var loc = curves[i].getNearestLocation(point);
-			if (loc._distance < minDist) {
-				minDist = loc._distance;
-				minLoc = loc;
-			}
-		}
-		return minLoc;
-	},
-
-	getNearestPoint: function(point) {
-		point = Point.read(arguments);
-		return this.getNearestLocation(point).getPoint();
-	},
-
-	getStyle: function() {
-		var parent = this._parent;
-		return (parent && parent._type === 'compound-path'
-				? parent : this)._style;
-	},
-
-	toShape: function(insert) {
-		if (!this._closed)
-			return null;
-
-		var segments = this._segments,
-			type,
-			size,
-			radius,
-			topCenter;
-
-		function isColinear(i, j) {
-			return segments[i].isColinear(segments[j]);
-		}
-
-		function isOrthogonal(i) {
-			return segments[i].isOrthogonal();
-		}
-
-		function isArc(i) {
-			return segments[i].isArc();
-		}
-
-		function getDistance(i, j) {
-			return segments[i]._point.getDistance(segments[j]._point);
-		}
-
-		if (this.isPolygon() && segments.length === 4
-				&& isColinear(0, 2) && isColinear(1, 3) && isOrthogonal(1)) {
-			type = Shape.Rectangle;
-			size = new Size(getDistance(0, 3), getDistance(0, 1));
-			topCenter = segments[1]._point.add(segments[2]._point).divide(2);
-		} else if (segments.length === 8 && isArc(0) && isArc(2) && isArc(4)
-				&& isArc(6) && isColinear(1, 5) && isColinear(3, 7)) {
-			type = Shape.Rectangle;
-			size = new Size(getDistance(1, 6), getDistance(0, 3));
-			radius = size.subtract(new Size(getDistance(0, 7),
-					getDistance(1, 2))).divide(2);
-			topCenter = segments[3]._point.add(segments[4]._point).divide(2);
-		} else if (segments.length === 4
-				&& isArc(0) && isArc(1) && isArc(2) && isArc(3)) {
-			if (Numerical.isZero(getDistance(0, 2) - getDistance(1, 3))) {
-				type = Shape.Circle;
-				radius = getDistance(0, 2) / 2;
-			} else {
-				type = Shape.Ellipse;
-				radius = new Size(getDistance(2, 0) / 2, getDistance(3, 1) / 2);
-			}
-			topCenter = segments[1]._point;
-		}
-
-		if (type) {
-			var center = this.getPosition(true),
-				shape = new type({
-					center: center,
-					size: size,
-					radius: radius,
-					insert: false
-				});
-			shape.rotate(topCenter.subtract(center).getAngle() + 90);
-			shape.setStyle(this._style);
-			if (insert || insert === undefined)
-				shape.insertAbove(this);
-			return shape;
-		}
-		return null;
-	},
-
-	_getWinding: function(point) {
-		var closed = this._closed;
-		if (!closed && !this.hasFill()
-				|| !this._getBounds('getRoughBounds')._containsPoint(point))
-			return 0;
-		var curves = this.getCurves(),
-			segments = this._segments,
-			winding = 0,
-			roots1 = [],
-			roots2 = [],
-			last = (closed
-					? curves[curves.length - 1]
-					: new Curve(segments[segments.length - 1]._point,
-						segments[0]._point)).getValues(),
-			previous = last;
-		for (var i = 0, l = curves.length; i < l; i++) {
-			var curve = curves[i].getValues(),
-				x = curve[0],
-				y = curve[1];
-			if (!(x === curve[2] && y === curve[3] && x === curve[4]
-					&& y === curve[5] && x === curve[6] && y === curve[7])) {
-				winding += Curve._getWinding(curve, previous, point.x, point.y,
-						roots1, roots2);
-				previous = curve;
-			}
-		}
-		if (!closed) {
-			winding += Curve._getWinding(last, previous, point.x, point.y,
-					roots1, roots2);
-		}
-		return winding;
-	},
-
-	_hitTest: function(point, options) {
-		var style = this.getStyle(),
-			segments = this._segments,
-			closed = this._closed,
-			tolerance = options.tolerance,
-			radius = 0, join, cap, miterLimit,
-			that = this,
-			area, loc, res;
-
-		if (options.stroke) {
-			radius = style.getStrokeWidth() / 2;
-			if (radius > 0) {
-				join = style.getStrokeJoin();
-				cap = style.getStrokeCap();
-				miterLimit = radius * style.getMiterLimit();
-			} else {
-				join = cap = 'round';
-			}
-			radius += tolerance;
-		}
-
-		function checkPoint(seg, pt, name) {
-			if (point.getDistance(pt) < tolerance)
-				return new HitResult(name, that, { segment: seg, point: pt });
-		}
-
-		function checkSegmentPoints(seg, ends) {
-			var pt = seg._point;
-			return (ends || options.segments) && checkPoint(seg, pt, 'segment')
-				|| (!ends && options.handles) && (
-					checkPoint(seg, pt.add(seg._handleIn), 'handle-in') ||
-					checkPoint(seg, pt.add(seg._handleOut), 'handle-out'));
-		}
-
-		function addAreaPoint(point) {
-			area.push(point);
-		}
-
-		function getAreaCurve(index) {
-			var p1 = area[index],
-				p2 = area[(index + 1) % area.length];
-			return [p1.x, p1.y, p1.x, p1.y, p2.x, p2.y, p2.x ,p2.y];
-		}
-
-		function isInArea(point) {
-			var length = area.length,
-				previous = getAreaCurve(length - 1),
-				roots1 = [],
-				roots2 = [],
-				winding = 0;
-			for (var i = 0; i < length; i++) {
-				var curve = getAreaCurve(i);
-				winding += Curve._getWinding(curve, previous, point.x, point.y,
-						roots1, roots2);
-				previous = curve;
-			}
-			return !!winding;
-		}
-
-		function checkSegmentStroke(segment) {
-			if (join !== 'round' || cap !== 'round') {
-				area = [];
-				if (closed || segment._index > 0
-						&& segment._index < segments.length - 1) {
-					if (join !== 'round' && (segment._handleIn.isZero() 
-							|| segment._handleOut.isZero()))
-						Path._addSquareJoin(segment, join, radius, miterLimit,
-								addAreaPoint, true);
-				} else if (cap !== 'round') {
-					Path._addSquareCap(segment, cap, radius, addAreaPoint, true);
-				}
-				if (area.length > 0)
-					return isInArea(point);
-			}
-			return point.getDistance(segment._point) <= radius;
-		}
-
-		if (options.ends && !options.segments && !closed) {
-			if (res = checkSegmentPoints(segments[0], true)
-					|| checkSegmentPoints(segments[segments.length - 1], true))
-				return res;
-		} else if (options.segments || options.handles) {
-			for (var i = 0, l = segments.length; i < l; i++) {
-				if (res = checkSegmentPoints(segments[i]))
-					return res;
-			}
-		}
-		if (radius > 0) {
-			loc = this.getNearestLocation(point);
-			if (loc) {
-				var parameter = loc.getParameter();
-				if (parameter === 0 || parameter === 1) {
-					if (!checkSegmentStroke(loc.getSegment()))
-						loc = null;
-				} else  if (loc._distance > radius) {
-					loc = null;
-				}
-			}
-			if (!loc && join === 'miter') {
-				for (var i = 0, l = segments.length; i < l; i++) {
-					var segment = segments[i];
-					if (point.getDistance(segment._point) <= miterLimit
-							&& checkSegmentStroke(segment)) {
-						loc = segment.getLocation();
-						break;
-					}
-				}
-			}
-		}
-		return !loc && options.fill && this.hasFill() && this._contains(point)
-				? new HitResult('fill', this)
-				: loc
-					? new HitResult('stroke', this, { location: loc })
-					: null;
-	}
-
-}, new function() { 
-
-	function drawHandles(ctx, segments, matrix, size) {
-		var half = size / 2;
-
-		function drawHandle(index) {
-			var hX = coords[index],
-				hY = coords[index + 1];
-			if (pX != hX || pY != hY) {
-				ctx.beginPath();
-				ctx.moveTo(pX, pY);
-				ctx.lineTo(hX, hY);
-				ctx.stroke();
-				ctx.beginPath();
-				ctx.arc(hX, hY, half, 0, Math.PI * 2, true);
-				ctx.fill();
-			}
-		}
-
-		var coords = new Array(6);
-		for (var i = 0, l = segments.length; i < l; i++) {
-			var segment = segments[i];
-			segment._transformCoordinates(matrix, coords, false);
-			var state = segment._selectionState,
-				selected = state & 4,
-				pX = coords[0],
-				pY = coords[1];
-			if (selected || (state & 1))
-				drawHandle(2);
-			if (selected || (state & 2))
-				drawHandle(4);
-			ctx.save();
-			ctx.beginPath();
-			ctx.rect(pX - half, pY - half, size, size);
-			ctx.fill();
-			if (!selected) {
-				ctx.beginPath();
-				ctx.rect(pX - half + 1, pY - half + 1, size - 2, size - 2);
-				ctx.fillStyle = '#ffffff';
-				ctx.fill();
-			}
-			ctx.restore();
-		}
-	}
-
-	function drawSegments(ctx, path, matrix) {
-		var segments = path._segments,
-			length = segments.length,
-			coords = new Array(6),
-			first = true,
-			curX, curY,
-			prevX, prevY,
-			inX, inY,
-			outX, outY;
-
-		function drawSegment(i) {
-			var segment = segments[i];
-			if (matrix) {
-				segment._transformCoordinates(matrix, coords, false);
-				curX = coords[0];
-				curY = coords[1];
-			} else {
-				var point = segment._point;
-				curX = point._x;
-				curY = point._y;
-			}
-			if (first) {
-				ctx.moveTo(curX, curY);
-				first = false;
-			} else {
-				if (matrix) {
-					inX = coords[2];
-					inY = coords[3];
-				} else {
-					var handle = segment._handleIn;
-					inX = curX + handle._x;
-					inY = curY + handle._y;
-				}
-				if (inX == curX && inY == curY && outX == prevX && outY == prevY) {
-					ctx.lineTo(curX, curY);
-				} else {
-					ctx.bezierCurveTo(outX, outY, inX, inY, curX, curY);
-				}
-			}
-			prevX = curX;
-			prevY = curY;
-			if (matrix) {
-				outX = coords[4];
-				outY = coords[5];
-			} else {
-				var handle = segment._handleOut;
-				outX = prevX + handle._x;
-				outY = prevY + handle._y;
-			}
-		}
-
-		for (var i = 0; i < length; i++)
-			drawSegment(i);
-		if (path._closed && length > 1)
-			drawSegment(0);
-	}
-
-	return {
-		_draw: function(ctx, param) {
-			var clip = param.clip,
-				compound = param.compound;
-			if (!compound)
-				ctx.beginPath();
-
-			var style = this.getStyle(),
-				hasFill = style.hasFill(),
-				hasStroke = style.hasStroke(),
-				dashArray = style.getDashArray(),
-				dashLength = !paper.support.nativeDash && hasStroke
-						&& dashArray && dashArray.length;
-
-			function getOffset(i) {
-				return dashArray[((i % dashLength) + dashLength) % dashLength];
-			}
-
-			if (hasFill || hasStroke && !dashLength || compound || clip)
-				drawSegments(ctx, this);
-			if (this._closed)
-				ctx.closePath();
-
-			if (!clip && !compound && (hasFill || hasStroke)) {
-				this._setStyles(ctx);
-				if (hasFill) {
-					ctx.fill(style.getWindingRule());
-					ctx.shadowColor = 'rgba(0,0,0,0)';
-				}
-				if (hasStroke) {
-					if (dashLength) {
-						ctx.beginPath();
-						var flattener = new PathFlattener(this),
-							length = flattener.length,
-							from = -style.getDashOffset(), to,
-							i = 0;
-						from = from % length;
-						while (from > 0) {
-							from -= getOffset(i--) + getOffset(i--);
-						}
-						while (from < length) {
-							to = from + getOffset(i++);
-							if (from > 0 || to > 0)
-								flattener.drawPart(ctx,
-										Math.max(from, 0), Math.max(to, 0));
-							from = to + getOffset(i++);
-						}
-					}
-					ctx.stroke();
-				}
-			}
-		},
-
-		_drawSelected: function(ctx, matrix) {
-			ctx.beginPath();
-			drawSegments(ctx, this, matrix);
-			ctx.stroke();
-			drawHandles(ctx, this._segments, matrix,
-					this._project.options.handleSize || 4);
-		}
-	};
-}, new function() { 
-
-	function getFirstControlPoints(rhs) {
-		var n = rhs.length,
-			x = [], 
-			tmp = [], 
-			b = 2;
-		x[0] = rhs[0] / b;
-		for (var i = 1; i < n; i++) {
-			tmp[i] = 1 / b;
-			b = (i < n - 1 ? 4 : 2) - tmp[i];
-			x[i] = (rhs[i] - x[i - 1]) / b;
-		}
-		for (var i = 1; i < n; i++) {
-			x[n - i - 1] -= tmp[n - i] * x[n - i];
-		}
-		return x;
-	}
-
-	return {
-		smooth: function() {
-			var segments = this._segments,
-				size = segments.length,
-				closed = this._closed,
-				n = size,
-				overlap = 0;
-			if (size <= 2)
-				return;
-			if (closed) {
-				overlap = Math.min(size, 4);
-				n += Math.min(size, overlap) * 2;
-			}
-			var knots = [];
-			for (var i = 0; i < size; i++)
-				knots[i + overlap] = segments[i]._point;
-			if (closed) {
-				for (var i = 0; i < overlap; i++) {
-					knots[i] = segments[i + size - overlap]._point;
-					knots[i + size + overlap] = segments[i]._point;
-				}
-			} else {
-				n--;
-			}
-			var rhs = [];
-
-			for (var i = 1; i < n - 1; i++)
-				rhs[i] = 4 * knots[i]._x + 2 * knots[i + 1]._x;
-			rhs[0] = knots[0]._x + 2 * knots[1]._x;
-			rhs[n - 1] = 3 * knots[n - 1]._x;
-			var x = getFirstControlPoints(rhs);
-
-			for (var i = 1; i < n - 1; i++)
-				rhs[i] = 4 * knots[i]._y + 2 * knots[i + 1]._y;
-			rhs[0] = knots[0]._y + 2 * knots[1]._y;
-			rhs[n - 1] = 3 * knots[n - 1]._y;
-			var y = getFirstControlPoints(rhs);
-
-			if (closed) {
-				for (var i = 0, j = size; i < overlap; i++, j++) {
-					var f1 = i / overlap,
-						f2 = 1 - f1,
-						ie = i + overlap,
-						je = j + overlap;
-					x[j] = x[i] * f1 + x[j] * f2;
-					y[j] = y[i] * f1 + y[j] * f2;
-					x[je] = x[ie] * f2 + x[je] * f1;
-					y[je] = y[ie] * f2 + y[je] * f1;
-				}
-				n--;
-			}
-			var handleIn = null;
-			for (var i = overlap; i <= n - overlap; i++) {
-				var segment = segments[i - overlap];
-				if (handleIn)
-					segment.setHandleIn(handleIn.subtract(segment._point));
-				if (i < n) {
-					segment.setHandleOut(
-							new Point(x[i], y[i]).subtract(segment._point));
-					handleIn = i < n - 1
-							? new Point(
-								2 * knots[i + 1]._x - x[i + 1],
-								2 * knots[i + 1]._y - y[i + 1])
-							: new Point(
-								(knots[n]._x + x[n - 1]) / 2,
-								(knots[n]._y + y[n - 1]) / 2);
-				}
-			}
-			if (closed && handleIn) {
-				var segment = this._segments[0];
-				segment.setHandleIn(handleIn.subtract(segment._point));
-			}
-		}
-	};
-}, new function() { 
-	function getCurrentSegment(that) {
-		var segments = that._segments;
-		if (segments.length == 0)
-			throw new Error('Use a moveTo() command first');
-		return segments[segments.length - 1];
-	}
-
-	return {
-		moveTo: function() {
-			if (this._segments.length === 1)
-				this.removeSegment(0);
-			if (!this._segments.length)
-				this._add([ new Segment(Point.read(arguments)) ]);
-		},
-
-		moveBy: function() {
-			throw new Error('moveBy() is unsupported on Path items.');
-		},
-
-		lineTo: function() {
-			this._add([ new Segment(Point.read(arguments)) ]);
-		},
-
-		cubicCurveTo: function() {
-			var handle1 = Point.read(arguments),
-				handle2 = Point.read(arguments),
-				to = Point.read(arguments),
-				current = getCurrentSegment(this);
-			current.setHandleOut(handle1.subtract(current._point));
-			this._add([ new Segment(to, handle2.subtract(to)) ]);
-		},
-
-		quadraticCurveTo: function() {
-			var handle = Point.read(arguments),
-				to = Point.read(arguments),
-				current = getCurrentSegment(this)._point;
-			this.cubicCurveTo(
-				handle.add(current.subtract(handle).multiply(1 / 3)),
-				handle.add(to.subtract(handle).multiply(1 / 3)),
-				to
-			);
-		},
-
-		curveTo: function() {
-			var through = Point.read(arguments),
-				to = Point.read(arguments),
-				t = Base.pick(Base.read(arguments), 0.5),
-				t1 = 1 - t,
-				current = getCurrentSegment(this)._point,
-				handle = through.subtract(current.multiply(t1 * t1))
-					.subtract(to.multiply(t * t)).divide(2 * t * t1);
-			if (handle.isNaN())
-				throw new Error(
-					'Cannot put a curve through points with parameter = ' + t);
-			this.quadraticCurveTo(handle, to);
-		},
-
-		arcTo: function() {
-			var current = getCurrentSegment(this),
-				from = current._point,
-				through,
-				to = Point.read(arguments),
-				clockwise = Base.pick(Base.peek(arguments), true);
-			if (typeof clockwise === 'boolean') {
-				var middle = from.add(to).divide(2),
-				through = middle.add(middle.subtract(from).rotate(
-						clockwise ? -90 : 90));
-			} else {
-				through = to;
-				to = Point.read(arguments);
-			}
-			var l1 = new Line(from.add(through).divide(2),
-						through.subtract(from).rotate(90), true),
-				l2 = new Line(through.add(to).divide(2),
-						to.subtract(through).rotate(90), true),
-				center = l1.intersect(l2, true),
-				line = new Line(from, to),
-				throughSide = line.getSide(through);
-			if (!center) {
-				if (!throughSide)
-					return this.lineTo(to);
-				throw new Error('Cannot put an arc through the given points: '
-					+ [from, through, to]);
-			}
-			var vector = from.subtract(center),
-				extent = vector.getDirectedAngle(to.subtract(center)),
-				centerSide = line.getSide(center);
-			if (centerSide == 0) {
-				extent = throughSide * Math.abs(extent);
-			} else if (throughSide == centerSide) {
-				extent -= 360 * (extent < 0 ? -1 : 1);
-			}
-			var ext = Math.abs(extent),
-				count =  ext >= 360 ? 4 : Math.ceil(ext / 90),
-				inc = extent / count,
-				half = inc * Math.PI / 360,
-				z = 4 / 3 * Math.sin(half) / (1 + Math.cos(half)),
-				segments = [];
-			for (var i = 0; i <= count; i++) {
-				var pt = i < count ? center.add(vector) : to;
-				var out = i < count ? vector.rotate(90).multiply(z) : null;
-				if (i == 0) {
-					current.setHandleOut(out);
-				} else {
-					segments.push(
-						new Segment(pt, vector.rotate(-90).multiply(z), out));
-				}
-				vector = vector.rotate(inc);
-			}
-			this._add(segments);
-		},
-
-		lineBy: function() {
-			var to = Point.read(arguments),
-				current = getCurrentSegment(this)._point;
-			this.lineTo(current.add(to));
-		},
-
-		curveBy: function() {
-			var through = Point.read(arguments),
-				to = Point.read(arguments),
-				parameter = Base.read(arguments),
-				current = getCurrentSegment(this)._point;
-			this.curveTo(current.add(through), current.add(to), parameter);
-		},
-
-		cubicCurveBy: function() {
-			var handle1 = Point.read(arguments),
-				handle2 = Point.read(arguments),
-				to = Point.read(arguments),
-				current = getCurrentSegment(this)._point;
-			this.cubicCurveTo(current.add(handle1), current.add(handle2),
-					current.add(to));
-		},
-
-		quadraticCurveBy: function() {
-			var handle = Point.read(arguments),
-				to = Point.read(arguments),
-				current = getCurrentSegment(this)._point;
-			this.quadraticCurveTo(current.add(handle), current.add(to));
-		},
-
-		arcBy: function() {
-			var current = getCurrentSegment(this)._point,
-				point = current.add(Point.read(arguments)),
-				clockwise = Base.pick(Base.peek(arguments), true);
-			if (typeof clockwise === 'boolean') {
-				this.arcTo(point, clockwise);
-			} else {
-				this.arcTo(point, current.add(Point.read(arguments)));
-			}
-		},
-
-		closePath: function() {
-			var first = this.getFirstSegment(),
-				last = this.getLastSegment();
-			if (first._point.equals(last._point)) {
-				first.setHandleIn(last._handleIn);
-				last.remove();
-			}
-			this.setClosed(true);
-		}
-	};
-}, {  
-
-	_getBounds: function(getter, matrix) {
-		return Path[getter](this._segments, this._closed, this.getStyle(),
-				matrix);
-	},
-
-statics: {
-	isClockwise: function(segments) {
-		var sum = 0;
-		for (var i = 0, l = segments.length; i < l; i++) {
-			var v = Curve.getValues(
-					segments[i], segments[i + 1 < l ? i + 1 : 0]);
-			for (var j = 2; j < 8; j += 2)
-				sum += (v[j - 2] - v[j]) * (v[j + 1] + v[j - 1]);
-		}
-		return sum > 0;
-	},
-
-	getBounds: function(segments, closed, style, matrix, strokePadding) {
-		var first = segments[0];
-		if (!first)
-			return new Rectangle();
-		var coords = new Array(6),
-			prevCoords = first._transformCoordinates(matrix, new Array(6), false),
-			min = prevCoords.slice(0, 2), 
-			max = min.slice(), 
-			roots = new Array(2);
-
-		function processSegment(segment) {
-			segment._transformCoordinates(matrix, coords, false);
-			for (var i = 0; i < 2; i++) {
-				Curve._addBounds(
-					prevCoords[i], 
-					prevCoords[i + 4], 
-					coords[i + 2], 
-					coords[i], 
-					i, strokePadding ? strokePadding[i] : 0, min, max, roots);
-			}
-			var tmp = prevCoords;
-			prevCoords = coords;
-			coords = tmp;
-		}
-
-		for (var i = 1, l = segments.length; i < l; i++)
-			processSegment(segments[i]);
-		if (closed)
-			processSegment(first);
-		return new Rectangle(min[0], min[1], max[0] - min[0], max[1] - min[1]);
-	},
-
-	getStrokeBounds: function(segments, closed, style, matrix) {
-		function getPenPadding(radius, matrix) {
-			if (!matrix)
-				return [radius, radius];
-			var mx = matrix.shiftless(),
-				hor = mx.transform(new Point(radius, 0)),
-				ver = mx.transform(new Point(0, radius)),
-				phi = hor.getAngleInRadians(),
-				a = hor.getLength(),
-				b = ver.getLength();
-			var sin = Math.sin(phi),
-				cos = Math.cos(phi),
-				tan = Math.tan(phi),
-				tx = -Math.atan(b * tan / a),
-				ty = Math.atan(b / (tan * a));
-			return [Math.abs(a * Math.cos(tx) * cos - b * Math.sin(tx) * sin),
-					Math.abs(b * Math.sin(ty) * cos + a * Math.cos(ty) * sin)];
-		}
-
-		if (!style.hasStroke())
-			return Path.getBounds(segments, closed, style, matrix);
-		var length = segments.length - (closed ? 0 : 1),
-			radius = style.getStrokeWidth() / 2,
-			padding = getPenPadding(radius, matrix),
-			bounds = Path.getBounds(segments, closed, style, matrix, padding),
-			join = style.getStrokeJoin(),
-			cap = style.getStrokeCap(),
-			miterLimit = radius * style.getMiterLimit();
-		var joinBounds = new Rectangle(new Size(padding).multiply(2));
-
-		function add(point) {
-			bounds = bounds.include(matrix
-				? matrix._transformPoint(point, point) : point);
-		}
-
-		function addJoin(segment, join) {
-			if (join === 'round' || !segment._handleIn.isZero()
-					&& !segment._handleOut.isZero()) {
-				bounds = bounds.unite(joinBounds.setCenter(matrix
-					? matrix._transformPoint(segment._point) : segment._point));
-			} else {
-				Path._addSquareJoin(segment, join, radius, miterLimit, add);
-			}
-		}
-
-		function addCap(segment, cap) {
-			switch (cap) {
-			case 'round':
-				addJoin(segment, cap);
-				break;
-			case 'butt':
-			case 'square':
-				Path._addSquareCap(segment, cap, radius, add); 
-				break;
-			}
-		}
-
-		for (var i = 1; i < length; i++)
-			addJoin(segments[i], join);
-		if (closed) {
-			addJoin(segments[0], join);
-		} else {
-			addCap(segments[0], cap);
-			addCap(segments[segments.length - 1], cap);
-		}
-		return bounds;
-	},
-
-	_addSquareJoin: function(segment, join, radius, miterLimit, addPoint, area) {
-		var curve2 = segment.getCurve(),
-			curve1 = curve2.getPrevious(),
-			point = curve2.getPointAt(0, true),
-			normal1 = curve1.getNormalAt(1, true),
-			normal2 = curve2.getNormalAt(0, true),
-			step = normal1.getDirectedAngle(normal2) < 0 ? -radius : radius;
-		normal1.setLength(step);
-		normal2.setLength(step);
-		if (area) {
-			addPoint(point);
-			addPoint(point.add(normal1));
-		}
-		if (join === 'miter') {
-			var corner = new Line(
-					point.add(normal1),
-					new Point(-normal1.y, normal1.x), true
-				).intersect(new Line(
-					point.add(normal2),
-					new Point(-normal2.y, normal2.x), true
-				), true);
-			if (corner && point.getDistance(corner) <= miterLimit) {
-				addPoint(corner);
-				if (!area)
-					return;
-			}
-		}
-		if (!area)
-			addPoint(point.add(normal1));
-		addPoint(point.add(normal2));
-	},
-
-	_addSquareCap: function(segment, cap, radius, addPoint, area) {
-		var point = segment._point,
-			loc = segment.getLocation(),
-			normal = loc.getNormal().normalize(radius);
-		if (area) {
-			addPoint(point.subtract(normal));
-			addPoint(point.add(normal));
-		}
-		if (cap === 'square')
-			point = point.add(normal.rotate(loc.getParameter() == 0 ? -90 : 90));
-		addPoint(point.add(normal));
-		addPoint(point.subtract(normal));
-	},
-
-	getHandleBounds: function(segments, closed, style, matrix, strokePadding,
-			joinPadding) {
-		var coords = new Array(6),
-			x1 = Infinity,
-			x2 = -x1,
-			y1 = x1,
-			y2 = x2;
-		strokePadding = strokePadding / 2 || 0;
-		joinPadding = joinPadding / 2 || 0;
-		for (var i = 0, l = segments.length; i < l; i++) {
-			var segment = segments[i];
-			segment._transformCoordinates(matrix, coords, false);
-			for (var j = 0; j < 6; j += 2) {
-				var padding = j == 0 ? joinPadding : strokePadding,
-					x = coords[j],
-					y = coords[j + 1],
-					xn = x - padding,
-					xx = x + padding,
-					yn = y - padding,
-					yx = y + padding;
-				if (xn < x1) x1 = xn;
-				if (xx > x2) x2 = xx;
-				if (yn < y1) y1 = yn;
-				if (yx > y2) y2 = yx;
-			}
-		}
-		return new Rectangle(x1, y1, x2 - x1, y2 - y1);
-	},
-
-	getRoughBounds: function(segments, closed, style, matrix) {
-		var strokeWidth = style.getStrokeColor() ? style.getStrokeWidth() : 0,
-			joinWidth = strokeWidth;
-		if (strokeWidth === 0) {
-			strokeWidth = 0.00001;
-		} else {
-			if (style.getStrokeJoin() === 'miter')
-				joinWidth = strokeWidth * style.getMiterLimit();
-			if (style.getStrokeCap() === 'square')
-				joinWidth = Math.max(joinWidth, strokeWidth * Math.sqrt(2));
-		}
-		return Path.getHandleBounds(segments, closed, style, matrix,
-				strokeWidth, joinWidth);
-	}
-}});
-
-Path.inject({ statics: new function() {
-
-	var kappa = Numerical.KAPPA,
-		ellipseSegments = [
-			new Segment([-1, 0], [0, kappa ], [0, -kappa]),
-			new Segment([0, -1], [-kappa, 0], [kappa, 0 ]),
-			new Segment([1, 0], [0, -kappa], [0, kappa ]),
-			new Segment([0, 1], [kappa, 0 ], [-kappa, 0])
-		];
-
-	function createEllipse(center, radius, args) {
-		var path = new Path(),
-			segments = new Array(4);
-		for (var i = 0; i < 4; i++) {
-			var segment = ellipseSegments[i];
-			segments[i] = new Segment(
-				segment._point.multiply(radius).add(center),
-				segment._handleIn.multiply(radius),
-				segment._handleOut.multiply(radius)
-			);
-		}
-		path._add(segments);
-		path._closed = true;
-		return path.set(Base.getNamed(args));
-	}
-
-	return {
-		Line: function() {
-			return new Path(
-				Point.readNamed(arguments, 'from'),
-				Point.readNamed(arguments, 'to')
-			).set(Base.getNamed(arguments));
-		},
-
-		Circle: function() {
-			var center = Point.readNamed(arguments, 'center'),
-				radius = Base.readNamed(arguments, 'radius');
-			return createEllipse(center, new Size(radius), arguments);
-		},
-
-		Rectangle: function() {
-			var rect = Rectangle.readNamed(arguments, 'rectangle'),
-				radius = Size.readNamed(arguments, 'radius', 0, 0,
-						{ readNull: true }),
-				bl = rect.getBottomLeft(true),
-				tl = rect.getTopLeft(true),
-				tr = rect.getTopRight(true),
-				br = rect.getBottomRight(true);
-				path = new Path();
-			if (!radius || radius.isZero()) {
-				path._add([
-					new Segment(bl),
-					new Segment(tl),
-					new Segment(tr),
-					new Segment(br)
-				]);
-			} else {
-				radius = Size.min(radius, rect.getSize(true).divide(2));
-				var rx = radius.width,
-					ry = radius.height,
-					hx = rx * kappa,
-					hy = ry * kappa;
-				path._add([
-					new Segment(bl.add(rx, 0), null, [-hx, 0]),
-					new Segment(bl.subtract(0, ry), [0, hy]),
-					new Segment(tl.add(0, ry), null, [0, -hy]),
-					new Segment(tl.add(rx, 0), [-hx, 0], null),
-					new Segment(tr.subtract(rx, 0), null, [hx, 0]),
-					new Segment(tr.add(0, ry), [0, -hy], null),
-					new Segment(br.subtract(0, ry), null, [0, hy]),
-					new Segment(br.subtract(rx, 0), [hx, 0])
-				]);
-			}
-			path._closed = true;
-			return path.set(Base.getNamed(arguments));
-		},
-
-		RoundRectangle: '#Rectangle',
-
-		Ellipse: function() {
-			var ellipse = Shape._readEllipse(arguments);
-			return createEllipse(ellipse.center, ellipse.radius, arguments);
-		},
-
-		Oval: '#Ellipse',
-
-		Arc: function() {
-			var from = Point.readNamed(arguments, 'from'),
-				through = Point.readNamed(arguments, 'through'),
-				to = Point.readNamed(arguments, 'to'),
-				path = new Path();
-			path.moveTo(from);
-			path.arcTo(through, to);
-			return path.set(Base.getNamed(arguments));
-		},
-
-		RegularPolygon: function() {
-			var center = Point.readNamed(arguments, 'center'),
-				sides = Base.readNamed(arguments, 'sides'),
-				radius = Base.readNamed(arguments, 'radius'),
-				path = new Path(),
-				step = 360 / sides,
-				three = !(sides % 3),
-				vector = new Point(0, three ? -radius : radius),
-				offset = three ? -1 : 0.5,
-				segments = new Array(sides);
-			for (var i = 0; i < sides; i++) {
-				segments[i] = new Segment(center.add(
-					vector.rotate((i + offset) * step)));
-			}
-			path._add(segments);
-			path._closed = true;
-			return path.set(Base.getNamed(arguments));
-		},
-
-		Star: function() {
-			var center = Point.readNamed(arguments, 'center'),
-				points = Base.readNamed(arguments, 'points') * 2,
-				radius1 = Base.readNamed(arguments, 'radius1'),
-				radius2 = Base.readNamed(arguments, 'radius2'),
-				path = new Path(),
-				step = 360 / points,
-				vector = new Point(0, -1),
-				segments = new Array(points);
-			for (var i = 0; i < points; i++) {
-				segments[i] = new Segment(center.add(
-					vector.rotate(step * i).multiply(i % 2 ? radius2 : radius1)));
-			}
-			path._add(segments);
-			path._closed = true;
-			return path.set(Base.getNamed(arguments));
-		}
-	};
-}});
-
-var CompoundPath = PathItem.extend({
-	_class: 'CompoundPath',
-	_serializeFields: {
-		children: []
-	},
-
-	initialize: function CompoundPath(arg) {
-		this._children = [];
-		this._namedChildren = {};
-		if (!this._initialize(arg))
-			this.addChildren(Array.isArray(arg) ? arg : arguments);
-	},
-
-	insertChildren: function insertChildren(index, items, _preserve) {
-		items = insertChildren.base.call(this, index, items, _preserve, 'path');
-		for (var i = 0, l = !_preserve && items && items.length; i < l; i++) {
-			var item = items[i];
-			if (item._clockwise === undefined)
-				item.setClockwise(item._index === 0);
-		}
-		return items;
-	},
-
-	reverse: function() {
-		var children = this._children;
-		for (var i = 0, l = children.length; i < l; i++)
-			children[i].reverse();
-	},
-
-	smooth: function() {
-		for (var i = 0, l = this._children.length; i < l; i++)
-			this._children[i].smooth();
-	},
-
-	isClockwise: function() {
-		var child = this.getFirstChild();
-		return child && child.isClockwise();
-	},
-
-	setClockwise: function(clockwise) {
-		if (this.isClockwise() != !!clockwise)
-			this.reverse();
-	},
-
-	getFirstSegment: function() {
-		var first = this.getFirstChild();
-		return first && first.getFirstSegment();
-	},
-
-	getLastSegment: function() {
-		var last = this.getLastChild();
-		return last && last.getLastSegment();
-	},
-
-	getCurves: function() {
-		var children = this._children,
-			curves = [];
-		for (var i = 0, l = children.length; i < l; i++)
-			curves = curves.concat(children[i].getCurves());
-		return curves;
-	},
-
-	getFirstCurve: function() {
-		var first = this.getFirstChild();
-		return first && first.getFirstCurve();
-	},
-
-	getLastCurve: function() {
-		var last = this.getLastChild();
-		return last && last.getFirstCurve();
-	},
-
-	getArea: function() {
-		var children = this._children,
-			area = 0;
-		for (var i = 0, l = children.length; i < l; i++)
-			area += children[i].getArea();
-		return area;
-	},
-
-	getPathData: function() {
-		var children = this._children,
-			paths = [];
-		for (var i = 0, l = children.length; i < l; i++)
-			paths.push(children[i].getPathData(arguments[0]));
-		return paths.join(' ');
-	},
-
-	_getWinding: function(point) {
-		var children =  this._children,
-			winding = 0;
-		for (var i = 0, l = children.length; i < l; i++)
-			winding += children[i]._getWinding(point);
-		return winding;
-	},
-
-	_hitTest : function _hitTest(point, options) {
-		var res = _hitTest.base.call(this, point,
-				new Base(options, { fill: false }));
-		if (!res) {
-			if (options.compoundChildren) {
-				var children =  this._children;
-				for (var i = children.length - 1; i >= 0 && !res; i--)
-					res = children[i]._hitTest(point, options);
-			} else if (options.fill && this.hasFill()
-					&& this._contains(point)) {
-				res = new HitResult('fill', this);
-			}
-		} 
-		return res;
-	},
-
-	_draw: function(ctx, param) {
-		var children = this._children;
-		if (children.length === 0)
-			return;
-
-		ctx.beginPath();
-		param = param.extend({ compound: true });
-		for (var i = 0, l = children.length; i < l; i++)
-			children[i].draw(ctx, param);
-
-		if (!param.clip) {
-			this._setStyles(ctx);
-			var style = this._style;
-			if (style.hasFill()) {
-				ctx.fill(style.getWindingRule());
-				ctx.shadowColor = 'rgba(0,0,0,0)';
-			}
-			if (style.hasStroke())
-				ctx.stroke();
-		}
-	}
-}, new function() { 
-	function getCurrentPath(that) {
-		if (!that._children.length)
-			throw new Error('Use a moveTo() command first');
-		return that._children[that._children.length - 1];
-	}
-
-	var fields = {
-		moveTo: function() {
-			var path = new Path();
-			this.addChild(path);
-			path.moveTo.apply(path, arguments);
-		},
-
-		moveBy: function() {
-			this.moveTo(getCurrentPath(this).getLastSegment()._point.add(
-					Point.read(arguments)));
-		},
-
-		closePath: function() {
-			getCurrentPath(this).closePath();
-		}
-	};
-
-	Base.each(['lineTo', 'cubicCurveTo', 'quadraticCurveTo', 'curveTo', 'arcTo',
-			'lineBy', 'cubicCurveBy', 'quadraticCurveBy', 'curveBy', 'arcBy'],
-			function(key) {
-				fields[key] = function() {
-					var path = getCurrentPath(this);
-					path[key].apply(path, arguments);
-				};
-			}
-	);
-
-	return fields;
-});
-
-var PathFlattener = Base.extend({
-	initialize: function(path) {
-		this.curves = []; 
-		this.parts = []; 
-		this.length = 0; 
-		this.index = 0;
-
-		var segments = path._segments,
-			segment1 = segments[0],
-			segment2,
-			that = this;
-
-		function addCurve(segment1, segment2) {
-			var curve = Curve.getValues(segment1, segment2);
-			that.curves.push(curve);
-			that._computeParts(curve, segment1._index, 0, 1);
-		}
-
-		for (var i = 1, l = segments.length; i < l; i++) {
-			segment2 = segments[i];
-			addCurve(segment1, segment2);
-			segment1 = segment2;
-		}
-		if (path._closed)
-			addCurve(segment2, segments[0]);
-	},
-
-	_computeParts: function(curve, index, minT, maxT) {
-		if ((maxT - minT) > 1 / 32 && !Curve.isFlatEnough(curve, 0.25)) {
-			var curves = Curve.subdivide(curve);
-			var halfT = (minT + maxT) / 2;
-			this._computeParts(curves[0], index, minT, halfT);
-			this._computeParts(curves[1], index, halfT, maxT);
-		} else {
-			var x = curve[6] - curve[0],
-				y = curve[7] - curve[1],
-				dist = Math.sqrt(x * x + y * y);
-			if (dist > 0.00001) {
-				this.length += dist;
-				this.parts.push({
-					offset: this.length,
-					value: maxT,
-					index: index
-				});
-			}
-		}
-	},
-
-	getParameterAt: function(offset) {
-		var i, j = this.index;
-		for (;;) {
-			i = j;
-			if (j == 0 || this.parts[--j].offset < offset)
-				break;
-		}
-		for (var l = this.parts.length; i < l; i++) {
-			var part = this.parts[i];
-			if (part.offset >= offset) {
-				this.index = i;
-				var prev = this.parts[i - 1];
-				var prevVal = prev && prev.index == part.index ? prev.value : 0,
-					prevLen = prev ? prev.offset : 0;
-				return {
-					value: prevVal + (part.value - prevVal)
-						* (offset - prevLen) /  (part.offset - prevLen),
-					index: part.index
-				};
-			}
-		}
-		var part = this.parts[this.parts.length - 1];
-		return {
-			value: 1,
-			index: part.index
-		};
-	},
-
-	evaluate: function(offset, type) {
-		var param = this.getParameterAt(offset);
-		return Curve.evaluate(this.curves[param.index], param.value, type);
-	},
-
-	drawPart: function(ctx, from, to) {
-		from = this.getParameterAt(from);
-		to = this.getParameterAt(to);
-		for (var i = from.index; i <= to.index; i++) {
-			var curve = Curve.getPart(this.curves[i],
-					i == from.index ? from.value : 0,
-					i == to.index ? to.value : 1);
-			if (i == from.index)
-				ctx.moveTo(curve[0], curve[1]);
-			ctx.bezierCurveTo.apply(ctx, curve.slice(2));
-		}
-	}
-});
-
-var PathFitter = Base.extend({
-	initialize: function(path, error) {
-		this.points = [];
-		var segments = path._segments,
-			prev;
-		for (var i = 0, l = segments.length; i < l; i++) {
-			var point = segments[i].point.clone();
-			if (!prev || !prev.equals(point)) {
-				this.points.push(point);
-				prev = point;
-			}
-		}
-		this.error = error;
-	},
-
-	fit: function() {
-		var points = this.points,
-			length = points.length;
-		this.segments = length > 0 ? [new Segment(points[0])] : [];
-		if (length > 1)
-			this.fitCubic(0, length - 1,
-				points[1].subtract(points[0]).normalize(),
-				points[length - 2].subtract(points[length - 1]).normalize());
-		return this.segments;
-	},
-
-	fitCubic: function(first, last, tan1, tan2) {
-		if (last - first == 1) {
-			var pt1 = this.points[first],
-				pt2 = this.points[last],
-				dist = pt1.getDistance(pt2) / 3;
-			this.addCurve([pt1, pt1.add(tan1.normalize(dist)),
-					pt2.add(tan2.normalize(dist)), pt2]);
-			return;
-		}
-		var uPrime = this.chordLengthParameterize(first, last),
-			maxError = Math.max(this.error, this.error * this.error),
-			split;
-		for (var i = 0; i <= 4; i++) {
-			var curve = this.generateBezier(first, last, uPrime, tan1, tan2);
-			var max = this.findMaxError(first, last, curve, uPrime);
-			if (max.error < this.error) {
-				this.addCurve(curve);
-				return;
-			}
-			split = max.index;
-			if (max.error >= maxError)
-				break;
-			this.reparameterize(first, last, uPrime, curve);
-			maxError = max.error;
-		}
-		var V1 = this.points[split - 1].subtract(this.points[split]),
-			V2 = this.points[split].subtract(this.points[split + 1]),
-			tanCenter = V1.add(V2).divide(2).normalize();
-		this.fitCubic(first, split, tan1, tanCenter);
-		this.fitCubic(split, last, tanCenter.negate(), tan2);
-	},
-
-	addCurve: function(curve) {
-		var prev = this.segments[this.segments.length - 1];
-		prev.setHandleOut(curve[1].subtract(curve[0]));
-		this.segments.push(
-				new Segment(curve[3], curve[2].subtract(curve[3])));
-	},
-
-	generateBezier: function(first, last, uPrime, tan1, tan2) {
-		var epsilon = 1e-11,
-			pt1 = this.points[first],
-			pt2 = this.points[last],
-			C = [[0, 0], [0, 0]],
-			X = [0, 0];
-
-		for (var i = 0, l = last - first + 1; i < l; i++) {
-			var u = uPrime[i],
-				t = 1 - u,
-				b = 3 * u * t,
-				b0 = t * t * t,
-				b1 = b * t,
-				b2 = b * u,
-				b3 = u * u * u,
-				a1 = tan1.normalize(b1),
-				a2 = tan2.normalize(b2),
-				tmp = this.points[first + i]
-					.subtract(pt1.multiply(b0 + b1))
-					.subtract(pt2.multiply(b2 + b3));
-			C[0][0] += a1.dot(a1);
-			C[0][1] += a1.dot(a2);
-			C[1][0] = C[0][1];
-			C[1][1] += a2.dot(a2);
-			X[0] += a1.dot(tmp);
-			X[1] += a2.dot(tmp);
-		}
-
-		var detC0C1 = C[0][0] * C[1][1] - C[1][0] * C[0][1],
-			alpha1, alpha2;
-		if (Math.abs(detC0C1) > epsilon) {
-			var detC0X  = C[0][0] * X[1]    - C[1][0] * X[0],
-				detXC1  = X[0]    * C[1][1] - X[1]    * C[0][1];
-			alpha1 = detXC1 / detC0C1;
-			alpha2 = detC0X / detC0C1;
-		} else {
-			var c0 = C[0][0] + C[0][1],
-				c1 = C[1][0] + C[1][1];
-			if (Math.abs(c0) > epsilon) {
-				alpha1 = alpha2 = X[0] / c0;
-			} else if (Math.abs(c1) > epsilon) {
-				alpha1 = alpha2 = X[1] / c1;
-			} else {
-				alpha1 = alpha2 = 0;
-			}
-		}
-
-		var segLength = pt2.getDistance(pt1);
-		epsilon *= segLength;
-		if (alpha1 < epsilon || alpha2 < epsilon) {
-			alpha1 = alpha2 = segLength / 3;
-		}
-
-		return [pt1, pt1.add(tan1.normalize(alpha1)),
-				pt2.add(tan2.normalize(alpha2)), pt2];
-	},
-
-	reparameterize: function(first, last, u, curve) {
-		for (var i = first; i <= last; i++) {
-			u[i - first] = this.findRoot(curve, this.points[i], u[i - first]);
-		}
-	},
-
-	findRoot: function(curve, point, u) {
-		var curve1 = [],
-			curve2 = [];
-		for (var i = 0; i <= 2; i++) {
-			curve1[i] = curve[i + 1].subtract(curve[i]).multiply(3);
-		}
-		for (var i = 0; i <= 1; i++) {
-			curve2[i] = curve1[i + 1].subtract(curve1[i]).multiply(2);
-		}
-		var pt = this.evaluate(3, curve, u),
-			pt1 = this.evaluate(2, curve1, u),
-			pt2 = this.evaluate(1, curve2, u),
-			diff = pt.subtract(point),
-			df = pt1.dot(pt1) + diff.dot(pt2);
-		if (Math.abs(df) < 0.00001)
-			return u;
-		return u - diff.dot(pt1) / df;
-	},
-
-	evaluate: function(degree, curve, t) {
-		var tmp = curve.slice();
-		for (var i = 1; i <= degree; i++) {
-			for (var j = 0; j <= degree - i; j++) {
-				tmp[j] = tmp[j].multiply(1 - t).add(tmp[j + 1].multiply(t));
-			}
-		}
-		return tmp[0];
-	},
-
-	chordLengthParameterize: function(first, last) {
-		var u = [0];
-		for (var i = first + 1; i <= last; i++) {
-			u[i - first] = u[i - first - 1]
-					+ this.points[i].getDistance(this.points[i - 1]);
-		}
-		for (var i = 1, m = last - first; i <= m; i++) {
-			u[i] /= u[m];
-		}
-		return u;
-	},
-
-	findMaxError: function(first, last, curve, u) {
-		var index = Math.floor((last - first + 1) / 2),
-			maxDist = 0;
-		for (var i = first + 1; i < last; i++) {
-			var P = this.evaluate(3, curve, u[i - first]);
-			var v = P.subtract(this.points[i]);
-			var dist = v.x * v.x + v.y * v.y; 
-			if (dist >= maxDist) {
-				maxDist = dist;
-				index = i;
-			}
-		}
-		return {
-			error: maxDist,
-			index: index
-		};
-	}
-});
-
-PathItem.inject(new function() {
-
-	function splitPath(intersections, collectOthers) {
-		intersections.sort(function(loc1, loc2) {
-			var path1 = loc1.getPath(),
-				path2 = loc2.getPath();
-			return path1 === path2
-					? (loc1.getIndex() + loc1.getParameter())
-						- (loc2.getIndex() + loc2.getParameter())
-					: path1._id - path2._id;
-		});
-		var others = collectOthers && [];
-		for (var i = intersections.length - 1; i >= 0; i--) {
-			var loc = intersections[i],
-				other = loc.getIntersection(),
-				curve = loc.divide(),
-				segment = curve && curve.getSegment1() || loc.getSegment();
-			if (others)
-				others.push(other);
-			segment._intersection = other;
-			loc._segment = segment;
-		}
-		return others;
-	}
-
-	function reorientPath(path) {
-		if (path instanceof CompoundPath) {
-			var children = path.removeChildren(),
-				length = children.length,
-				bounds = new Array(length),
-				counters = new Array(length),
-				clockwise;
-			children.sort(function(a, b){
-				var b1 = a.getBounds(), b2 = b.getBounds();
-				return b1._width * b1._height < b2._width * b2._height;
-			});
-			path.addChildren(children);
-			clockwise = children[0].isClockwise();
-			for (var i = 0; i < length; i++) {
-				bounds[i] = children[i].getBounds();
-				counters[i] = 0;
-			}
-			for (var i = 0; i < length; i++) {
-				for (var j = 1; j < length; j++) {
-					if (i !== j && bounds[i].contains(bounds[j]))
-						counters[j]++;
-				}
-				if (i > 0 && counters[i] % 2 === 0)
-					children[i].setClockwise(clockwise);
-			}
-		}
-		return path;
-	}
-
-	function computeBoolean(path1, path2, operator, subtract) {
-		path1 = reorientPath(path1.clone(false));
-		path2 = reorientPath(path2.clone(false));
-		var path1Clockwise = path1.isClockwise(),
-			path2Clockwise = path2.isClockwise(),
-			intersections = path1.getIntersections(path2);
-		splitPath(splitPath(intersections, true));
-		if (!path1Clockwise)
-			path1.reverse();
-		if (!(subtract ^ path2Clockwise))
-			path2.reverse();
-		path1Clockwise = true;
-		path2Clockwise = !subtract;
-		var paths = []
-				.concat(path1._children || [path1])
-				.concat(path2._children || [path2]),
-			segments = [],
-			result = new CompoundPath();
-		for (var i = 0, l = paths.length; i < l; i++) {
-			var path = paths[i],
-				parent = path._parent,
-				clockwise = path.isClockwise(),
-				segs = path._segments;
-			path = parent instanceof CompoundPath ? parent : path;
-			for (var j = segs.length - 1; j >= 0; j--) {
-				var segment = segs[j],
-					midPoint = segment.getCurve().getPoint(0.5),
-					insidePath1 = path !== path1 && path1.contains(midPoint)
-							&& (clockwise === path1Clockwise || subtract
-									|| !testOnCurve(path1, midPoint)),
-					insidePath2 = path !== path2 && path2.contains(midPoint)
-							&& (clockwise === path2Clockwise
-									|| !testOnCurve(path2, midPoint));
-				if (operator(path === path1, insidePath1, insidePath2)) {
-					segment._invalid = true;
-				} else {
-					segments.push(segment);
-				}
-			}
-		}
-		for (var i = 0, l = segments.length; i < l; i++) {
-			var segment = segments[i];
-			if (segment._visited)
-				continue;
-			var path = new Path(),
-				loc = segment._intersection,
-				intersection = loc && loc.getSegment(true);
-			if (segment.getPrevious()._invalid)
-				segment.setHandleIn(intersection
-						? intersection._handleIn
-						: new Point(0, 0));
-			do {
-				segment._visited = true;
-				if (segment._invalid && segment._intersection) {
-					var inter = segment._intersection.getSegment(true);
-					path.add(new Segment(segment._point, segment._handleIn,
-							inter._handleOut));
-					inter._visited = true;
-					segment = inter;
-				} else {
-					path.add(segment.clone());
-				}
-				segment = segment.getNext();
-			} while (segment && !segment._visited && segment !== intersection);
-			var amount = path._segments.length;
-			if (amount > 1 && (amount > 2 || !path.isPolygon())) {
-				path.setClosed(true);
-				result.addChild(path, true);
-			} else {
-				path.remove();
-			}
-		}
-		path1.remove();
-		path2.remove();
-		return result.reduce();
-	}
-
-	function testOnCurve(path, point) {
-		var curves = path.getCurves(),
-			bounds = path.getBounds();
-		if (bounds.contains(point)) {
-			for (var i = 0, l = curves.length; i < l; i++) {
-				var curve = curves[i];
-				if (curve.getBounds().contains(point)
-						&& curve.getParameterOf(point))
-					return true;
-			}
-		}
-		return false;
-	}
-
-	return {
-		unite: function(path) {
-			return computeBoolean(this, path,
-					function(isPath1, isInPath1, isInPath2) {
-						return isInPath1 || isInPath2;
-					});
-		},
-
-		intersect: function(path) {
-			return computeBoolean(this, path,
-					function(isPath1, isInPath1, isInPath2) {
-						return !(isInPath1 || isInPath2);
-					});
-		},
-
-		subtract: function(path) {
-			return computeBoolean(this, path,
-					function(isPath1, isInPath1, isInPath2) {
-						return isPath1 && isInPath2 || !isPath1 && !isInPath1;
-					}, true);
-		},
-
-		exclude: function(path) {
-			return new Group([this.subtract(path), path.subtract(this)]);
-		},
-
-		divide: function(path) {
-			return new Group([this.subtract(path), this.intersect(path)]);
-		}
-	};
-});
-
-var TextItem = Item.extend({
-	_class: 'TextItem',
-	_boundsSelected: true,
-	_serializeFields: {
-		content: null
-	},
-	_boundsGetter: 'getBounds',
-
-	initialize: function TextItem(arg) {
-		this._content = '';
-		this._lines = [];
-		var hasProps = arg && Base.isPlainObject(arg)
-				&& arg.x === undefined && arg.y === undefined;
-		this._initialize(hasProps && arg, !hasProps && Point.read(arguments));
-	},
-
-	_equals: function(item) {
-		return this._content === item._content;
-	},
-
-	_clone: function _clone(copy) {
-		copy.setContent(this._content);
-		return _clone.base.call(this, copy);
-	},
-
-	getContent: function() {
-		return this._content;
-	},
-
-	setContent: function(content) {
-		this._content = '' + content;
-		this._lines = this._content.split(/\r\n|\n|\r/mg);
-		this._changed(69);
-	},
-
-	isEmpty: function() {
-		return !this._content;
-	},
-
-	getCharacterStyle: '#getStyle',
-	setCharacterStyle: '#setStyle',
-
-	getParagraphStyle: '#getStyle',
-	setParagraphStyle: '#setStyle'
-});
-
-var PointText = TextItem.extend({
-	_class: 'PointText',
-
-	initialize: function PointText() {
-		TextItem.apply(this, arguments);
-	},
-
-	clone: function(insert) {
-		return this._clone(new PointText({ insert: false }), insert);
-	},
-
-	getPoint: function() {
-		var point = this._matrix.getTranslation();
-		return new LinkedPoint(point.x, point.y, this, 'setPoint');
-	},
-
-	setPoint: function(point) {
-		point = Point.read(arguments);
-		this.translate(point.subtract(this._matrix.getTranslation()));
-	},
-
-	_draw: function(ctx) {
-		if (!this._content)
-			return;
-		this._setStyles(ctx);
-		var style = this._style,
-			lines = this._lines,
-			leading = style.getLeading(),
-			shadowColor = ctx.shadowColor;
-
-		ctx.font = style.getFontStyle();
-		ctx.textAlign = style.getJustification();
-		for (var i = 0, l = lines.length; i < l; i++) {
-			ctx.shadowColor = shadowColor;
-			var line = lines[i];
-			if (style.hasFill()) {
-				ctx.fillText(line, 0, 0);
-				ctx.shadowColor = 'rgba(0,0,0,0)';
-			}
-			if (style.hasStroke())
-				ctx.strokeText(line, 0, 0);
-			ctx.translate(0, leading);
-		}
-	}
-}, new function() {
-	var measureCtx = null;
-
-	return {
-		_getBounds: function(getter, matrix) {
-			if (!measureCtx)
-				measureCtx = CanvasProvider.getContext(1, 1);
-			var style = this._style,
-				lines = this._lines,
-				count = lines.length,
-				justification = style.getJustification(),
-				leading = style.getLeading(),
-				x = 0;
-			measureCtx.font = style.getFontStyle();
-			var width = 0;
-			for (var i = 0; i < count; i++)
-				width = Math.max(width, measureCtx.measureText(lines[i]).width);
-			if (justification !== 'left')
-				x -= width / (justification === 'center' ? 2: 1);
-			var bounds = new Rectangle(x,
-						count ? - 0.75 * leading : 0,
-						width, count * leading);
-			return matrix ? matrix._transformBounds(bounds, bounds) : bounds;
-		}
-	};
-});
-
-var Color = Base.extend(new function() {
-
-	var types = {
-		gray: ['gray'],
-		rgb: ['red', 'green', 'blue'],
-		hsb: ['hue', 'saturation', 'brightness'],
-		hsl: ['hue', 'saturation', 'lightness'],
-		gradient: ['gradient', 'origin', 'destination', 'highlight']
-	};
-
-	var componentParsers = {},
-		colorCache = {},
-		colorCtx;
-
-	function fromCSS(string) {
-		var match = string.match(/^#(\w{1,2})(\w{1,2})(\w{1,2})$/),
-			components;
-		if (match) {
-			components = [0, 0, 0];
-			for (var i = 0; i < 3; i++) {
-				var value = match[i + 1];
-				components[i] = parseInt(value.length == 1
-						? value + value : value, 16) / 255;
-			}
-		} else if (match = string.match(/^rgba?\((.*)\)$/)) {
-			components = match[1].split(',');
-			for (var i = 0, l = components.length; i < l; i++) {
-				var value = parseFloat(components[i]);
-				components[i] = i < 3 ? value / 255 : value;
-			}
-		} else {
-			var cached = colorCache[string];
-			if (!cached) {
-				if (!colorCtx) {
-					colorCtx = CanvasProvider.getContext(1, 1);
-					colorCtx.globalCompositeOperation = 'copy';
-				}
-				colorCtx.fillStyle = 'rgba(0,0,0,0)';
-				colorCtx.fillStyle = string;
-				colorCtx.fillRect(0, 0, 1, 1);
-				var data = colorCtx.getImageData(0, 0, 1, 1).data;
-				cached = colorCache[string] = [
-					data[0] / 255,
-					data[1] / 255,
-					data[2] / 255				
-				];
-			}
-			components = cached.slice();
-		}
-		return components;
-	}
-
-	var hsbIndices = [
-		[0, 3, 1], 
-		[2, 0, 1], 
-		[1, 0, 3], 
-		[1, 2, 0], 
-		[3, 1, 0], 
-		[0, 1, 2]  
-	];
-
-	var converters = {
-		'rgb-hsb': function(r, g, b) {
-			var max = Math.max(r, g, b),
-				min = Math.min(r, g, b),
-				delta = max - min,
-				h = delta === 0 ? 0
-					:   ( max == r ? (g - b) / delta + (g < b ? 6 : 0)
-						: max == g ? (b - r) / delta + 2
-						:            (r - g) / delta + 4) * 60; 
-			return [h, max === 0 ? 0 : delta / max, max];
-		},
-
-		'hsb-rgb': function(h, s, b) {
-			var h = (h / 60) % 6, 
-				i = Math.floor(h), 
-				f = h - i,
-				i = hsbIndices[i],
-				v = [
-					b,						
-					b * (1 - s),			
-					b * (1 - s * f),		
-					b * (1 - s * (1 - f))	
-				];
-			return [v[i[0]], v[i[1]], v[i[2]]];
-		},
-
-		'rgb-hsl': function(r, g, b) {
-			var max = Math.max(r, g, b),
-				min = Math.min(r, g, b),
-				delta = max - min,
-				achromatic = delta === 0,
-				h = achromatic ? 0
-					:   ( max == r ? (g - b) / delta + (g < b ? 6 : 0)
-						: max == g ? (b - r) / delta + 2
-						:            (r - g) / delta + 4) * 60, 
-				l = (max + min) / 2,
-				s = achromatic ? 0 : l < 0.5
-						? delta / (max + min)
-						: delta / (2 - max - min);
-			return [h, s, l];
-		},
-
-		'hsl-rgb': function(h, s, l) {
-			h /= 360;
-			if (s === 0)
-				return [l, l, l];
-			var t3s = [ h + 1 / 3, h, h - 1 / 3 ],
-				t2 = l < 0.5 ? l * (1 + s) : l + s - l * s,
-				t1 = 2 * l - t2,
-				c = [];
-			for (var i = 0; i < 3; i++) {
-				var t3 = t3s[i];
-				if (t3 < 0) t3 += 1;
-				if (t3 > 1) t3 -= 1;
-				c[i] = 6 * t3 < 1
-					? t1 + (t2 - t1) * 6 * t3
-					: 2 * t3 < 1
-						? t2
-						: 3 * t3 < 2
-							? t1 + (t2 - t1) * ((2 / 3) - t3) * 6
-							: t1;
-			}
-			return c;
-		},
-
-		'rgb-gray': function(r, g, b) {
-			return [r * 0.2989 + g * 0.587 + b * 0.114];
-		},
-
-		'gray-rgb': function(g) {
-			return [g, g, g];
-		},
-
-		'gray-hsb': function(g) {
-			return [0, 0, g];
-		},
-
-		'gray-hsl': function(g) {
-			return [0, 0, g];
-		},
-
-		'gradient-rgb': function() {
-			return [];
-		},
-
-		'rgb-gradient': function() {
-			return [];
-		}
-
-	};
-
-	return Base.each(types, function(properties, type) {
-		componentParsers[type] = [];
-		Base.each(properties, function(name, index) {
-			var part = Base.capitalize(name),
-				hasOverlap = /^(hue|saturation)$/.test(name),
-				parser = componentParsers[type][index] = name === 'gradient'
-					? function(value) {
-						var current = this._components[0];
-						value = Gradient.read(
-								Array.isArray(value) ? value : arguments,
-								0, 0, { readNull: true });
-						if (current !== value) {
-							if (current)
-								current._removeOwner(this);
-							if (value)
-								value._addOwner(this);
-						}
-						return value;
-					}
-					: name === 'hue'
-						? function(value) {
-							return isNaN(value) ? 0
-									: ((value % 360) + 360) % 360;
-						}
-						: type === 'gradient'
-							? function() {
-								return Point.read(arguments, 0, 0, {
-										readNull: name === 'highlight',
-										clone: true
-								});
-							}
-							: function(value) {
-								return isNaN(value) ? 0
-										: Math.min(Math.max(value, 0), 1);
-							};
-
-			this['get' + part] = function() {
-				return this._type === type
-					|| hasOverlap && /^hs[bl]$/.test(this._type)
-						? this._components[index]
-						: this._convert(type)[index];
-			};
-
-			this['set' + part] = function(value) {
-				if (this._type !== type
-						&& !(hasOverlap && /^hs[bl]$/.test(this._type))) {
-					this._components = this._convert(type);
-					this._properties = types[type];
-					this._type = type;
-				}
-				value = parser.call(this, value);
-				if (value != null) {
-					this._components[index] = value;
-					this._changed();
-				}
-			};
-		}, this);
-	}, {
-		_class: 'Color',
-		_readIndex: true,
-
-		initialize: function Color(arg) {
-			var slice = Array.prototype.slice,
-				args = arguments,
-				read = 0,
-				parse = true,
-				type,
-				components,
-				alpha,
-				values;
-			if (Array.isArray(arg)) {
-				args = arg;
-				arg = args[0];
-			}
-			var argType = arg != null && typeof arg;
-			if (argType === 'string' && arg in types) {
-				type = arg;
-				arg = args[1];
-				if (Array.isArray(arg)) {
-					components = arg;
-					alpha = args[2];
-				} else {
-					if (this.__read)
-						read = 1; 
-					args = slice.call(args, 1);
-					argType = typeof arg;
-				}
-			}
-			if (!components) {
-				parse = !(this.__options && this.__options.dontParse);
-				values = argType === 'number'
-						? args
-						: argType === 'object' && arg.length != null
-							? arg
-							: null;
-				if (values) {
-					if (!type)
-						type = values.length >= 3
-								? 'rgb'
-								: 'gray';
-					var length = types[type].length;
-					alpha = values[length];
-					if (this.__read)
-						read += values === arguments
-							? length + (alpha != null ? 1 : 0)
-							: 1;
-					if (values.length > length)
-						values = slice.call(values, 0, length);
-				} else if (argType === 'string') {
-					type = 'rgb';
-					components = fromCSS(arg);
-					if (components.length === 4) {
-						alpha = components[3];
-						components.length--;
-					}
-				} else if (argType === 'object') {
-					if (arg.constructor === Color) {
-						type = arg._type;
-						components = arg._components.slice();
-						alpha = arg._alpha;
-						if (type === 'gradient') {
-							for (var i = 1, l = components.length; i < l; i++) {
-								var point = components[i];
-								if (point)
-									components[i] = point.clone();
-							}
-						}
-					} else if (arg.constructor === Gradient) {
-						type = 'gradient';
-						values = args;
-					} else {
-						type = 'hue' in arg
-							? 'lightness' in arg
-								? 'hsl'
-								: 'hsb'
-							: 'gradient' in arg || 'stops' in arg
-									|| 'radial' in arg
-								? 'gradient'
-								: 'gray' in arg
-									? 'gray'
-									: 'rgb';
-						var properties = types[type];
-							parsers = parse && componentParsers[type];
-						this._components = components = [];
-						for (var i = 0, l = properties.length; i < l; i++) {
-							var value = arg[properties[i]];
-							if (value == null && i === 0 && type === 'gradient'
-									&& 'stops' in arg) {
-								value = {
-									stops: arg.stops,
-									radial: arg.radial
-								};
-							}
-							if (parse)
-								value = parsers[i].call(this, value);
-							if (value != null)
-								components[i] = value;
-						}
-						alpha = arg.alpha;
-					}
-				}
-				if (this.__read && type)
-					read = 1;
-			}
-			this._type = type || 'rgb';
-			if (type === 'gradient')
-				this._id = Color._id = (Color._id || 0) + 1;
-			if (!components) {
-				this._components = components = [];
-				var parsers = componentParsers[this._type];
-				for (var i = 0, l = parsers.length; i < l; i++) {
-					var value = values && values[i];
-					if (parse)
-						value = parsers[i].call(this, value);
-					if (value != null)
-						components[i] = value;
-				}
-			}
-			this._components = components;
-			this._properties = types[this._type];
-			this._alpha = alpha;
-			if (this.__read)
-				this.__read = read;
-		},
-
-		_serialize: function(options, dictionary) {
-			var components = this.getComponents();
-			return Base.serialize(
-					/^(gray|rgb)$/.test(this._type)
-						? components
-						: [this._type].concat(components),
-					options, true, dictionary);
-		},
-
-		_changed: function() {
-			this._canvasStyle = null;
-			if (this._owner)
-				this._owner._changed(17);
-		},
-
-		_convert: function(type) {
-			var converter;
-			return this._type === type
-					? this._components.slice()
-					: (converter = converters[this._type + '-' + type])
-						? converter.apply(this, this._components)
-						: converters['rgb-' + type].apply(this,
-							converters[this._type + '-rgb'].apply(this,
-									this._components));
-		},
-
-		convert: function(type) {
-			return new Color(type, this._convert(type), this._alpha);
-		},
-
-		getType: function() {
-			return this._type;
-		},
-
-		setType: function(type) {
-			this._components = this._convert(type);
-			this._properties = types[type];
-			this._type = type;
-		},
-
-		getComponents: function() {
-			var components = this._components.slice();
-			if (this._alpha != null)
-				components.push(this._alpha);
-			return components;
-		},
-
-		getAlpha: function() {
-			return this._alpha != null ? this._alpha : 1;
-		},
-
-		setAlpha: function(alpha) {
-			this._alpha = alpha == null ? null : Math.min(Math.max(alpha, 0), 1);
-			this._changed();
-		},
-
-		hasAlpha: function() {
-			return this._alpha != null;
-		},
-
-		equals: function(color) {
-			if (Base.isPlainValue(color))
-				color = Color.read(arguments);
-			return color === this || color && this._class === color._class
-					&& this._type === color._type
-					&& this._alpha === color._alpha
-					&& Base.equals(this._components, color._components)
-					|| false;
-		},
-
-		toString: function() {
-			var properties = this._properties,
-				parts = [],
-				isGradient = this._type === 'gradient',
-				f = Formatter.instance;
-			for (var i = 0, l = properties.length; i < l; i++) {
-				var value = this._components[i];
-				if (value != null)
-					parts.push(properties[i] + ': '
-							+ (isGradient ? value : f.number(value)));
-			}
-			if (this._alpha != null)
-				parts.push('alpha: ' + f.number(this._alpha));
-			return '{ ' + parts.join(', ') + ' }';
-		},
-
-		toCSS: function(hex) {
-			var components = this._convert('rgb'),
-				alpha = hex || this._alpha == null ? 1 : this._alpha;
-			components = [
-				Math.round(components[0] * 255),
-				Math.round(components[1] * 255),
-				Math.round(components[2] * 255)
-			];
-			if (alpha < 1)
-				components.push(alpha);
-			return hex
-					? '#' + ((1 << 24) + (components[0] << 16)
-						+ (components[1] << 8)
-						+ components[2]).toString(16).slice(1)
-					: (components.length == 4 ? 'rgba(' : 'rgb(')
-						+ components.join(',') + ')';
-		},
-
-		toCanvasStyle: function(ctx) {
-			if (this._canvasStyle)
-				return this._canvasStyle;
-			if (this._type !== 'gradient')
-				return this._canvasStyle = this.toCSS();
-			var components = this._components,
-				gradient = components[0],
-				stops = gradient._stops,
-				origin = components[1],
-				destination = components[2],
-				canvasGradient;
-			if (gradient._radial) {
-				var radius = destination.getDistance(origin),
-					highlight = components[3];
-				if (highlight) {
-					var vector = highlight.subtract(origin);
-					if (vector.getLength() > radius)
-						highlight = origin.add(vector.normalize(radius - 0.1));
-				}
-				var start = highlight || origin;
-				canvasGradient = ctx.createRadialGradient(start.x, start.y,
-						0, origin.x, origin.y, radius);
-			} else {
-				canvasGradient = ctx.createLinearGradient(origin.x, origin.y,
-						destination.x, destination.y);
-			}
-			for (var i = 0, l = stops.length; i < l; i++) {
-				var stop = stops[i];
-				canvasGradient.addColorStop(stop._rampPoint,
-						stop._color.toCanvasStyle());
-			}
-			return this._canvasStyle = canvasGradient;
-		},
-
-		transform: function(matrix) {
-			if (this._type === 'gradient') {
-				var components = this._components;
-				for (var i = 1, l = components.length; i < l; i++) {
-					var point = components[i];
-					matrix._transformPoint(point, point, true);
-				}
-				this._changed();
-			}
-		},
-
-		statics: {
-			_types: types,
-
-			random: function() {
-				var random = Math.random;
-				return new Color(random(), random(), random());
-			}
-		}
-	});
-}, new function() {
-	function clamp(value, hue) {
-		return value < 0
-				? 0
-				: hue && value > 360
-					? 360
-					: !hue && value > 1
-						? 1
-						: value;
-	}
-
-	var operators = {
-		add: function(a, b, hue) {
-			return clamp(a + b, hue);
-		},
-
-		subtract: function(a, b, hue) {
-			return clamp(a - b, hue);
-		},
-
-		multiply: function(a, b, hue) {
-			return clamp(a * b, hue);
-		},
-
-		divide: function(a, b, hue) {
-			return clamp(a / b, hue);
-		}
-	};
-
-	return Base.each(operators, function(operator, name) {
-		var options = { dontParse: /^(multiply|divide)$/.test(name) };
-
-		this[name] = function(color) {
-			color = Color.read(arguments, 0, 0, options);
-			var type = this._type,
-				properties = this._properties,
-				components1 = this._components,
-				components2 = color._convert(type);
-			for (var i = 0, l = components1.length; i < l; i++)
-				components2[i] = operator(components1[i], components2[i],
-						properties[i] === 'hue');
-			return new Color(type, components2,
-					this._alpha != null
-							? operator(this._alpha, color.getAlpha())
-							: null);
-		};
-	}, {
-	});
-});
-
-Base.each(Color._types, function(properties, type) {
-	var ctor = this[Base.capitalize(type) + 'Color'] = function(arg) {
-			var argType = arg != null && typeof arg,
-				components = argType === 'object' && arg.length != null
-					? arg
-					: argType === 'string'
-						? null
-						: arguments;
-			return components
-					? new Color(type, components)
-					: new Color(arg);
-		};
-	if (type.length == 3) {
-		var acronym = type.toUpperCase();
-		Color[acronym] = this[acronym + 'Color'] = ctor;
-	}
-}, Base.exports);
-
-var Gradient = Base.extend({
-	_class: 'Gradient',
-
-	initialize: function Gradient(stops, radial) {
-		this._id = Gradient._id = (Gradient._id || 0) + 1;
-		if (stops && this._set(stops))
-			stops = radial = null;
-		if (!this._stops)
-			this.setStops(stops || ['white', 'black']);
-		if (this._radial == null)
-			this.setRadial(typeof radial === 'string' && radial === 'radial'
-					|| radial || false);
-	},
-
-	_serialize: function(options, dictionary) {
-		return dictionary.add(this, function() {
-			return Base.serialize([this._stops, this._radial],
-					options, true, dictionary);
-		});
-	},
-
-	_changed: function() {
-		for (var i = 0, l = this._owners && this._owners.length; i < l; i++)
-			this._owners[i]._changed();
-	},
-
-	_addOwner: function(color) {
-		if (!this._owners)
-			this._owners = [];
-		this._owners.push(color);
-	},
-
-	_removeOwner: function(color) {
-		var index = this._owners ? this._owners.indexOf(color) : -1;
-		if (index != -1) {
-			this._owners.splice(index, 1);
-			if (this._owners.length === 0)
-				delete this._owners;
-		}
-	},
-
-	clone: function() {
-		var stops = [];
-		for (var i = 0, l = this._stops.length; i < l; i++)
-			stops[i] = this._stops[i].clone();
-		return new Gradient(stops);
-	},
-
-	getStops: function() {
-		return this._stops;
-	},
-
-	setStops: function(stops) {
-		if (this.stops) {
-			for (var i = 0, l = this._stops.length; i < l; i++)
-				delete this._stops[i]._owner;
-		}
-		if (stops.length < 2)
-			throw new Error(
-					'Gradient stop list needs to contain at least two stops.');
-		this._stops = GradientStop.readAll(stops, 0, false, true); 
-		for (var i = 0, l = this._stops.length; i < l; i++) {
-			var stop = this._stops[i];
-			stop._owner = this;
-			if (stop._defaultRamp)
-				stop.setRampPoint(i / (l - 1));
-		}
-		this._changed();
-	},
-
-	getRadial: function() {
-		return this._radial;
-	},
-
-	setRadial: function(radial) {
-		this._radial = radial;
-		this._changed();
-	},
-
-	equals: function(gradient) {
-		if (gradient === this)
-			return true;
-		if (gradient &&  this._class === gradient._class
-				&& this._stops.length === gradient._stops.length) {
-			for (var i = 0, l = this._stops.length; i < l; i++) {
-				if (!this._stops[i].equals(gradient._stops[i]))
-					return false;
-			}
-			return true;
-		}
-		return false;
-	}
-});
-
-var GradientStop = Base.extend({
-	_class: 'GradientStop',
-
-	initialize: function GradientStop(arg0, arg1) {
-		if (arg0) {
-			var color, rampPoint;
-			if (arg1 === undefined && Array.isArray(arg0)) {
-				color = arg0[0];
-				rampPoint = arg0[1];
-			} else if (arg0.color) {
-				color = arg0.color;
-				rampPoint = arg0.rampPoint;
-			} else {
-				color = arg0;
-				rampPoint = arg1;
-			}
-			this.setColor(color);
-			this.setRampPoint(rampPoint);
-		}
-	},
-
-	clone: function() {
-		return new GradientStop(this._color.clone(), this._rampPoint);
-	},
-
-	_serialize: function(options, dictionary) {
-		return Base.serialize([this._color, this._rampPoint], options, true, 
-				dictionary);
-	},
-
-	_changed: function() {
-		if (this._owner)
-			this._owner._changed(17);
-	},
-
-	getRampPoint: function() {
-		return this._rampPoint;
-	},
-
-	setRampPoint: function(rampPoint) {
-		this._defaultRamp = rampPoint == null;
-		this._rampPoint = rampPoint || 0;
-		this._changed();
-	},
-
-	getColor: function() {
-		return this._color;
-	},
-
-	setColor: function(color) {
-		this._color = Color.read(arguments);
-		if (this._color === color)
-			this._color = color.clone();
-		this._color._owner = this;
-		this._changed();
-	},
-
-	equals: function(stop) {
-		return stop === this || stop && this._class === stop._class
-				&& this._color.equals(stop._color)
-				&& this._rampPoint == stop._rampPoint
-				|| false;
-	}
-});
-
-var Style = Base.extend(new function() {
-	var defaults = {
-		fillColor: undefined,
-		strokeColor: undefined,
-		strokeWidth: 1,
-		strokeCap: 'butt',
-		strokeJoin: 'miter',
-		miterLimit: 10,
-		dashOffset: 0,
-		dashArray: [],
-		windingRule: 'nonzero',
-		shadowColor: undefined,
-		shadowBlur: 0,
-		shadowOffset: new Point(),
-		selectedColor: undefined,
-		font: 'sans-serif',
-		fontSize: 12,
-		leading: null,
-		justification: 'left'
-	};
-
-	var flags = {
-		strokeWidth: 25,
-		strokeCap: 25,
-		strokeJoin: 25,
-		miterLimit: 25,
-		font: 5,
-		fontSize: 5,
-		leading: 5,
-		justification: 5
-	};
-
-	var item = {},
-		fields = {
-			_defaults: defaults,
-			_textDefaults: new Base(defaults, {
-				fillColor: new Color() 
-			})
-		};
-
-	Base.each(defaults, function(value, key) {
-		var isColor = /Color$/.test(key),
-			part = Base.capitalize(key),
-			flag = flags[key],
-			set = 'set' + part,
-			get = 'get' + part;
-
-		fields[set] = function(value) {
-			var children = this._item && this._item._children;
-			if (children && children.length > 0
-					&& this._item._type !== 'compound-path') {
-				for (var i = 0, l = children.length; i < l; i++)
-					children[i]._style[set](value);
-			} else {
-				var old = this._values[key];
-				if (old != value) {
-					if (isColor) {
-						if (old)
-							delete old._owner;
-						if (value && value.constructor === Color) {
-							if (value._owner)
-								value = value.clone();
-							value._owner = this._item;
-						}
-					}
-					this._values[key] = value;
-					if (this._item)
-						this._item._changed(flag || 17);
-				}
-			}
-		};
-
-		fields[get] = function() {
-			var value,
-				children = this._item && this._item._children;
-			if (!children || children.length === 0 || arguments[0]
-					|| this._item._type === 'compound-path') {
-				var value = this._values[key];
-				if (value === undefined) {
-					value = this._defaults[key];
-					if (value && value.clone)
-						value = value.clone();
-					this._values[key] = value;
-				} else if (isColor && !(value && value.constructor === Color)) {
-					this._values[key] = value = Color.read(
-							[value], 0, 0, { readNull: true, clone: true });
-					if (value)
-						value._owner = this._item;
-				}
-				return value;
-			}
-			for (var i = 0, l = children.length; i < l; i++) {
-				var childValue = children[i]._style[get]();
-				if (i === 0) {
-					value = childValue;
-				} else if (!Base.equals(value, childValue)) {
-					return undefined;
-				}
-			}
-			return value;
-		};
-
-		item[get] = function() {
-			return this._style[get]();
-		};
-
-		item[set] = function(value) {
-			this._style[set](value);
-		};
-	});
-
-	Item.inject(item);
-	return fields;
-}, {
-	_class: 'Style',
-
-	initialize: function Style(style, _item) {
-		this._values = {};
-		this._item = _item;
-		if (_item instanceof TextItem)
-			this._defaults = this._textDefaults;
-		if (style)
-			this.set(style);
-	},
-
-	set: function(style) {
-		var isStyle = style instanceof Style,
-			values = isStyle ? style._values : style;
-		if (values) {
-			for (var key in values) {
-				if (key in this._defaults) {
-					var value = values[key];
-					this[key] = value && isStyle && value.clone
-							? value.clone() : value;
-				}
-			}
-		}
-	},
-
-	equals: function(style) {
-		return style === this || style && this._class === style._class
-				&& Base.equals(this._values, style._values)
-				|| false;
-	},
-
-	hasFill: function() {
-		return !!this.getFillColor();
-	},
-
-	hasStroke: function() {
-		return !!this.getStrokeColor() && this.getStrokeWidth() > 0;
-	},
-
-	hasShadow: function() {
-		return !!this.getShadowColor() && this.getShadowBlur() > 0;
-	},
-
-	getLeading: function getLeading() {
-		var leading = getLeading.base.call(this);
-		return leading != null ? leading : this.getFontSize() * 1.2;
-	},
-
-	getFontStyle: function() {
-		var size = this.getFontSize();
-		return size + (/[a-z]/i.test(size + '') ? ' ' : 'px ') + this.getFont();
-	}
-
-});
-
-var DomElement = new function() {
-
-	var special = /^(checked|value|selected|disabled)$/i,
-		translated = { text: 'textContent', html: 'innerHTML' },
-		unitless = { lineHeight: 1, zoom: 1, zIndex: 1, opacity: 1 };
-
-	function create(nodes, parent) {
-		var res = [];
-		for (var i =  0, l = nodes && nodes.length; i < l;) {
-			var el = nodes[i++];
-			if (typeof el === 'string') {
-				el = document.createElement(el);
-			} else if (!el || !el.nodeType) {
-				continue;
-			}
-			if (Base.isPlainObject(nodes[i]))
-				DomElement.set(el, nodes[i++]);
-			if (Array.isArray(nodes[i]))
-				create(nodes[i++], el);
-			if (parent)
-				parent.appendChild(el);
-			res.push(el);
-		}
-		return res;
-	}
-
-	return {
-		create: function(nodes, parent) {
-			var isArray = Array.isArray(nodes),
-				res = create(isArray ? nodes : arguments, isArray ? parent : null);
-			return res.length == 1 ? res[0] : res;
-		},
-
-		find: function(selector, root) {
-			return (root || document).querySelector(selector);
-		},
-
-		findAll: function(selector, root) {
-			return (root || document).querySelectorAll(selector);
-		},
-
-		get: function(el, key) {
-			return el
-				? special.test(key)
-					? key === 'value' || typeof el[key] !== 'string'
-						? el[key]
-						: true
-					: key in translated
-						? el[translated[key]]
-						: el.getAttribute(key)
-				: null;
-		},
-
-		set: function(el, key, value) {
-			if (typeof key !== 'string') {
-				for (var name in key)
-					if (key.hasOwnProperty(name))
-						this.set(el, name, key[name]);
-			} else if (!el || value === undefined) {
-				return el;
-			} else if (special.test(key)) {
-				el[key] = value;
-			} else if (key in translated) {
-				el[translated[key]] = value;
-			} else if (key === 'style') {
-				this.setStyle(el, value);
-			} else if (key === 'events') {
-				DomEvent.add(el, value);
-			} else {
-				el.setAttribute(key, value);
-			}
-			return el;
-		},
-
-		getStyles: function(el) {
-			var doc = el && el.nodeType !== 9 ? el.ownerDocument : el,
-				view = doc && doc.defaultView;
-			return view && view.getComputedStyle(el, '');
-		},
-
-		getStyle: function(el, key) {
-			return el && el.style[key] || this.getStyles(el)[key] || null;
-		},
-
-		setStyle: function(el, key, value) {
-			if (typeof key !== 'string') {
-				for (var name in key)
-					if (key.hasOwnProperty(name))
-						this.setStyle(el, name, key[name]);
-			} else {
-				if (/^-?[\d\.]+$/.test(value) && !(key in unitless))
-					value += 'px';
-				el.style[key] = value;
-			}
-			return el;
-		},
-
-		hasClass: function(el, cls) {
-			return new RegExp('\\s*' + cls + '\\s*').test(el.className);
-		},
-
-		addClass: function(el, cls) {
-			el.className = (el.className + ' ' + cls).trim();
-		},
-
-		removeClass: function(el, cls) {
-			el.className = el.className.replace(
-				new RegExp('\\s*' + cls + '\\s*'), ' ').trim();
-		},
-
-		remove: function(el) {
-			if (el.parentNode)
-				el.parentNode.removeChild(el);
-		},
-
-		removeChildren: function(el) {
-			while (el.firstChild)
-				el.removeChild(el.firstChild);
-		},
-
-		getBounds: function(el, viewport) {
-			var doc = el.ownerDocument,
-				body = doc.body,
-				html = doc.documentElement,
-				rect;
-			try {
-				rect = el.getBoundingClientRect();
-			} catch (e) {
-				rect = { left: 0, top: 0, width: 0, height: 0 };
-			}
-			var x = rect.left - (html.clientLeft || body.clientLeft || 0),
-				y = rect.top - (html.clientTop  || body.clientTop  || 0);
-			if (!viewport) {
-				var view = doc.defaultView;
-				x += view.pageXOffset || html.scrollLeft || body.scrollLeft;
-				y += view.pageYOffset || html.scrollTop || body.scrollTop;
-			}
-			return new Rectangle(x, y, rect.width, rect.height);
-		},
-
-		getViewportBounds: function(el) {
-			var doc = el.ownerDocument,
-				view = doc.defaultView,
-				html = doc.documentElement;
-			return new Rectangle(0, 0, 
-				view.innerWidth || html.clientWidth,
-				view.innerHeight || html.clientHeight
-			);
-		},
-
-		getOffset: function(el, viewport) {
-			return this.getBounds(el, viewport).getPoint();
-		},
-
-		getSize: function(el) {
-			return this.getBounds(el, true).getSize();
-		},
-
-		isInvisible: function(el) {
-			return this.getSize(el).equals(new Size(0, 0));
-		},
-
-		isInView: function(el) {
-			return !this.isInvisible(el) && this.getViewportBounds(el).intersects(
-					this.getBounds(el, true));
-		},
-
-		getPrefixValue: function(el, name) {
-			var value = el[name],
-				prefixes = ['webkit', 'moz', 'ms', 'o'],
-				suffix = name[0].toUpperCase() + name.substring(1);
-			for (var i = 0; i < 4 && value == null; i++)
-				value = el[prefixes[i] + suffix];
-			return value;
-		}
-	};
-};
-
-var DomEvent = {
-	add: function(el, events) {
-		for (var type in events) {
-			var func = events[type];
-			if (el.addEventListener) {
-				el.addEventListener(type, func, false);
-			} else if (el.attachEvent) {
-				el.attachEvent('on' + type, func.bound = function() {
-					func.call(el, window.event);
-				});
-			}
-		}
-	},
-
-	remove: function(el, events) {
-		for (var type in events) {
-			var func = events[type];
-			if (el.removeEventListener) {
-				el.removeEventListener(type, func, false);
-			} else if (el.detachEvent) {
-				el.detachEvent('on' + type, func.bound);
-			}
-		}
-	},
-
-	getPoint: function(event) {
-		var pos = event.targetTouches
-				? event.targetTouches.length
-					? event.targetTouches[0]
-					: event.changedTouches[0]
-				: event;
-		return new Point(
-			pos.pageX || pos.clientX + document.documentElement.scrollLeft,
-			pos.pageY || pos.clientY + document.documentElement.scrollTop
-		);
-	},
-
-	getTarget: function(event) {
-		return event.target || event.srcElement;
-	},
-
-	getOffset: function(event, target) {
-		return DomEvent.getPoint(event).subtract(DomElement.getOffset(
-				target || DomEvent.getTarget(event)));
-	},
-
-	preventDefault: function(event) {
-		if (event.preventDefault) {
-			event.preventDefault();
-		} else {
-			event.returnValue = false;
-		}
-	},
-
-	stopPropagation: function(event) {
-		if (event.stopPropagation) {
-			event.stopPropagation();
-		} else {
-			event.cancelBubble = true;
-		}
-	},
-
-	stop: function(event) {
-		DomEvent.stopPropagation(event);
-		DomEvent.preventDefault(event);
-	}
-};
-
-DomEvent.requestAnimationFrame = new function() {
-	var nativeRequest = DomElement.getPrefixValue(window,
-			'requestAnimationFrame'),
-		requested = false,
-		callbacks = [],
-		focused = true,
-		timer;
-
-	DomEvent.add(window, {
-		focus: function() {
-			focused = true;
-		},
-		blur: function() {
-			focused = false;
-		}
-	});
-
-	function handleCallbacks() {
-		for (var i = callbacks.length - 1; i >= 0; i--) {
-			var entry = callbacks[i],
-				func = entry[0],
-				el = entry[1];
-			if (!el || (PaperScope.getAttribute(el, 'keepalive') == 'true'
-					|| focused) && DomElement.isInView(el)) {
-				callbacks.splice(i, 1);
-				func();
-			}
-		}
-		if (nativeRequest) {
-			if (callbacks.length) {
-				nativeRequest(handleCallbacks);
-			} else {
-				requested = false;
-			}
-		}
-	}
-
-	return function(callback, element) {
-		callbacks.push([callback, element]);
-		if (nativeRequest) {
-			if (!requested) {
-				nativeRequest(handleCallbacks);
-				requested = true;
-			}
-		} else if (!timer) {
-			timer = setInterval(handleCallbacks, 1000 / 60);
-		}
-	};
-};
-
-var View = Base.extend(Callback, {
-	_class: 'View',
-
-	initialize: function View(element) {
-		this._scope = paper;
-		this._project = paper.project;
-		this._element = element;
-		var size;
-		this._id = element.getAttribute('id');
-		if (this._id == null)
-			element.setAttribute('id', this._id = 'view-' + View._id++);
-		DomEvent.add(element, this._viewHandlers);
-		if (PaperScope.hasAttribute(element, 'resize')) {
-			var offset = DomElement.getOffset(element, true),
-				that = this;
-			size = DomElement.getViewportBounds(element)
-					.getSize().subtract(offset);
-			this._windowHandlers = {
-				resize: function() {
-					if (!DomElement.isInvisible(element))
-						offset = DomElement.getOffset(element, true);
-					that.setViewSize(DomElement.getViewportBounds(element)
-							.getSize().subtract(offset));
-				}
-			};
-			DomEvent.add(window, this._windowHandlers);
-		} else {
-			size = DomElement.getSize(element);
-			if (size.isNaN() || size.isZero())
-				size = new Size(parseInt(element.getAttribute('width'), 10),
-							parseInt(element.getAttribute('height'), 10));
-		}
-		this._setViewSize(size);
-		if (PaperScope.hasAttribute(element, 'stats')
-				&& typeof Stats !== 'undefined') {
-			this._stats = new Stats();
-			var stats = this._stats.domElement,
-				style = stats.style,
-				offset = DomElement.getOffset(element);
-			style.position = 'absolute';
-			style.left = offset.x + 'px';
-			style.top = offset.y + 'px';
-			document.body.appendChild(stats);
-		}
-		View._views.push(this);
-		View._viewsById[this._id] = this;
-		this._viewSize = size;
-		(this._matrix = new Matrix())._owner = this;
-		this._zoom = 1;
-		if (!View._focused)
-			View._focused = this;
-		this._frameItems = {};
-		this._frameItemCount = 0;
-	},
-
-	remove: function() {
-		if (!this._project)
-			return false;
-		if (View._focused == this)
-			View._focused = null;
-		View._views.splice(View._views.indexOf(this), 1);
-		delete View._viewsById[this._id];
-		if (this._project.view == this)
-			this._project.view = null;
-		DomEvent.remove(this._element, this._viewHandlers);
-		DomEvent.remove(window, this._windowHandlers);
-		this._element = this._project = null;
-		this.detach('frame');
-		this._frameItems = {};
-		return true;
-	},
-
-	_events: {
-		onFrame: {
-			install: function() {
-				this._animate = true;
-				if (!this._requested)
-					this._requestFrame();
-			},
-
-			uninstall: function() {
-				this._animate = false;
-			}
-		},
-
-		onResize: {}
-	},
-
-	_animate: false,
-	_time: 0,
-	_count: 0,
-
-	_requestFrame: function() {
-		var that = this;
-		DomEvent.requestAnimationFrame(function() {
-			that._requested = false;
-			if (!that._animate)
-				return;
-			that._requestFrame();
-			that._handleFrame();
-		}, this._element);
-		this._requested = true;
-	},
-
-	_handleFrame: function() {
-		paper = this._scope;
-		var now = Date.now() / 1000,
-			delta = this._before ? now - this._before : 0;
-		this._before = now;
-		this._handlingFrame = true;
-		this.fire('frame', new Base({
-			delta: delta,
-			time: this._time += delta,
-			count: this._count++
-		}));
-		if (this._stats)
-			this._stats.update();
-		this._handlingFrame = false;
-		this.draw(true);
-	},
-
-	_animateItem: function(item, animate) {
-		var items = this._frameItems;
-		if (animate) {
-			items[item._id] = {
-				item: item,
-				time: 0,
-				count: 0
-			};
-			if (++this._frameItemCount === 1)
-				this.attach('frame', this._handleFrameItems);
-		} else {
-			delete items[item._id];
-			if (--this._frameItemCount === 0) {
-				this.detach('frame', this._handleFrameItems);
-			}
-		}
-	},
-
-	_handleFrameItems: function(event) {
-		for (var i in this._frameItems) {
-			var entry = this._frameItems[i];
-			entry.item.fire('frame', new Base(event, {
-				time: entry.time += event.delta,
-				count: entry.count++
-			}));
-		}
-	},
-
-	_redraw: function() {
-		this._project._needsRedraw = true;
-		if (this._handlingFrame)
-			return;
-		if (this._animate) {
-			this._handleFrame();
-		} else {
-			this.draw();
-		}
-	},
-
-	_changed: function(flags) {
-		if (flags & 1)
-			this._project._needsRedraw = true;
-	},
-
-	_transform: function(matrix) {
-		this._matrix.concatenate(matrix);
-		this._bounds = null;
-		this._redraw();
-	},
-
-	getElement: function() {
-		return this._element;
-	},
-
-	getViewSize: function() {
-		var size = this._viewSize;
-		return new LinkedSize(size.width, size.height, this, 'setViewSize');
-	},
-
-	setViewSize: function(size) {
-		size = Size.read(arguments);
-		var delta = size.subtract(this._viewSize);
-		if (delta.isZero())
-			return;
-		this._viewSize.set(size.width, size.height);
-		this._setViewSize(size);
-		this._bounds = null; 
-		this.fire('resize', {
-			size: size,
-			delta: delta
-		});
-		this._redraw();
-	},
-
-	_setViewSize: function(size) {
-		var element = this._element;
-		element.width = size.width;
-		element.height = size.height;
-	},
-
-	getBounds: function() {
-		if (!this._bounds)
-			this._bounds = this._matrix.inverted()._transformBounds(
-					new Rectangle(new Point(), this._viewSize));
-		return this._bounds;
-	},
-
-	getSize: function() {
-		return this.getBounds().getSize(arguments[0]);
-	},
-
-	getCenter: function() {
-		return this.getBounds().getCenter(arguments[0]);
-	},
-
-	setCenter: function(center) {
-		center = Point.read(arguments);
-		this.scrollBy(center.subtract(this.getCenter()));
-	},
-
-	getZoom: function() {
-		return this._zoom;
-	},
-
-	setZoom: function(zoom) {
-		this._transform(new Matrix().scale(zoom / this._zoom,
-			this.getCenter()));
-		this._zoom = zoom;
-	},
-
-	isVisible: function() {
-		return DomElement.isInView(this._element);
-	},
-
-	scrollBy: function() {
-		this._transform(new Matrix().translate(Point.read(arguments).negate()));
-	},
-
-	projectToView: function() {
-		return this._matrix._transformPoint(Point.read(arguments));
-	},
-
-	viewToProject: function() {
-		return this._matrix._inverseTransform(Point.read(arguments));
-	},
-
-}, {
-	statics: {
-		_views: [],
-		_viewsById: {},
-		_id: 0,
-
-		create: function(element) {
-			if (typeof element === 'string')
-				element = document.getElementById(element);
-			return new CanvasView(element);
-		}
-	}
-}, new function() {
-	var tool,
-		prevFocus,
-		tempFocus,
-		dragging = false;
-
-	function getView(event) {
-		var target = DomEvent.getTarget(event);
-		return target.getAttribute && View._viewsById[target.getAttribute('id')];
-	}
-
-	function viewToProject(view, event) {
-		return view.viewToProject(DomEvent.getOffset(event, view._element));
-	}
-
-	function updateFocus() {
-		if (!View._focused || !View._focused.isVisible()) {
-			for (var i = 0, l = View._views.length; i < l; i++) {
-				var view = View._views[i];
-				if (view && view.isVisible()) {
-					View._focused = tempFocus = view;
-					break;
-				}
-			}
-		}
-	}
-
-	function mousedown(event) {
-		var view = View._focused = getView(event),
-			point = viewToProject(view, event);
-		dragging = true;
-		if (view._onMouseDown)
-			view._onMouseDown(event, point);
-		if (tool = view._scope._tool)
-			tool._onHandleEvent('mousedown', point, event);
-		view.draw(true);
-	}
-
-	function mousemove(event) {
-		var view;
-		if (!dragging) {
-			view = getView(event);
-			if (view) {
-				prevFocus = View._focused;
-				View._focused = tempFocus = view;
-			} else if (tempFocus && tempFocus == View._focused) {
-				View._focused = prevFocus;
-				updateFocus();
-			}
-		}
-		if (!(view = view || View._focused))
-			return;
-		var point = event && viewToProject(view, event);
-		if (view._onMouseMove)
-			view._onMouseMove(event, point);
-		if (tool = view._scope._tool) {
-			if (tool._onHandleEvent(dragging && tool.responds('mousedrag')
-					? 'mousedrag' : 'mousemove', point, event))
-				DomEvent.stop(event);
-		}
-		view.draw(true);
-	}
-
-	function mouseup(event) {
-		var view = View._focused;
-		if (!view || !dragging)
-			return;
-		var point = viewToProject(view, event);
-		curPoint = null;
-		dragging = false;
-		if (view._onMouseUp)
-			view._onMouseUp(event, point);
-		if (tool && tool._onHandleEvent('mouseup', point, event))
-			DomEvent.stop(event);
-		view.draw(true);
-	}
-
-	function selectstart(event) {
-		if (dragging)
-			DomEvent.stop(event);
-	}
-
-	DomEvent.add(document, {
-		mousemove: mousemove,
-		mouseup: mouseup,
-		touchmove: mousemove,
-		touchend: mouseup,
-		selectstart: selectstart,
-		scroll: updateFocus
-	});
-
-	DomEvent.add(window, {
-		load: updateFocus
-	});
-
-	return {
-		_viewHandlers: {
-			mousedown: mousedown,
-			touchstart: mousedown,
-			selectstart: selectstart
-		},
-
-		statics: {
-			updateFocus: updateFocus
-		}
-	};
-});
-
-var CanvasView = View.extend({
-	_class: 'CanvasView',
-
-	initialize: function CanvasView(canvas) {
-		if (!(canvas instanceof HTMLCanvasElement)) {
-			var size = Size.read(arguments);
-			if (size.isZero())
-				throw new Error(
-						'Cannot create CanvasView with the provided argument: '
-						+ canvas);
-			canvas = CanvasProvider.getCanvas(size);
-		}
-		this._context = canvas.getContext('2d');
-		this._eventCounters = {};
-		this._ratio = 1;
-		if (PaperScope.getAttribute(canvas, 'hidpi') !== 'off') {
-			var deviceRatio = window.devicePixelRatio || 1,
-				backingStoreRatio = DomElement.getPrefixValue(this._context,
-						'backingStorePixelRatio') || 1;
-			this._ratio = deviceRatio / backingStoreRatio;
-		}
-		View.call(this, canvas);
-	},
-
-	_setViewSize: function(size) {
-		var width = size.width,
-			height = size.height,
-			ratio = this._ratio,
-			element = this._element,
-			style = element.style;
-		element.width = width * ratio;
-		element.height = height * ratio;
-		if (ratio !== 1) {
-			style.width = width + 'px';
-			style.height = height + 'px';
-			this._context.scale(ratio, ratio);
-		}
-	},
-
-	draw: function(checkRedraw) {
-		if (checkRedraw && !this._project._needsRedraw)
-			return false;
-		var ctx = this._context,
-			size = this._viewSize;
-		ctx.clearRect(0, 0, size.width + 1, size.height + 1);
-		this._project.draw(ctx, this._matrix, this._ratio);
-		this._project._needsRedraw = false;
-		return true;
-	}
-}, new function() { 
-
-	var downPoint,
-		lastPoint,
-		overPoint,
-		downItem,
-		lastItem,
-		overItem,
-		hasDrag,
-		doubleClick,
-		clickTime;
-
-	function callEvent(type, event, point, target, lastPoint, bubble) {
-		var item = target,
-			mouseEvent;
-		while (item) {
-			if (item.responds(type)) {
-				if (!mouseEvent)
-					mouseEvent = new MouseEvent(type, event, point, target,
-							lastPoint ? point.subtract(lastPoint) : null);
-				if (item.fire(type, mouseEvent)
-						&& (!bubble || mouseEvent._stopped))
-					return false;
-			}
-			item = item.getParent();
-		}
-		return true;
-	}
-
-	function handleEvent(view, type, event, point, lastPoint) {
-		if (view._eventCounters[type]) {
-			var project = view._project,
-				hit = project.hitTest(point, {
-					tolerance: project.options.hitTolerance || 0,
-					fill: true,
-					stroke: true
-				}),
-				item = hit && hit.item;
-			if (item) {
-				if (type === 'mousemove' && item != overItem)
-					lastPoint = point;
-				if (type !== 'mousemove' || !hasDrag)
-					callEvent(type, event, point, item, lastPoint);
-				return item;
-			}
-		}
-	}
-
-	return {
-		_onMouseDown: function(event, point) {
-			var item = handleEvent(this, 'mousedown', event, point);
-			doubleClick = lastItem == item && (Date.now() - clickTime < 300);
-			downItem = lastItem = item;
-			downPoint = lastPoint = overPoint = point;
-			hasDrag = downItem && downItem.responds('mousedrag');
-		},
-
-		_onMouseUp: function(event, point) {
-			var item = handleEvent(this, 'mouseup', event, point);
-			if (hasDrag) {
-				if (lastPoint && !lastPoint.equals(point))
-					callEvent('mousedrag', event, point, downItem, lastPoint);
-				if (item != downItem) {
-					overPoint = point;
-					callEvent('mousemove', event, point, item, overPoint);
-				}
-			}
-			if (item === downItem) {
-				clickTime = Date.now();
-				if (!doubleClick
-						|| callEvent('doubleclick', event, downPoint, item))
-					callEvent('click', event, downPoint, item);
-				doubleClick = false;
-			}
-			downItem = null;
-			hasDrag = false;
-		},
-
-		_onMouseMove: function(event, point) {
-			if (downItem)
-				callEvent('mousedrag', event, point, downItem, lastPoint);
-			var item = handleEvent(this, 'mousemove', event, point, overPoint);
-			lastPoint = overPoint = point;
-			if (item !== overItem) {
-				callEvent('mouseleave', event, point, overItem);
-				overItem = item;
-				callEvent('mouseenter', event, point, item);
-			}
-		}
-	};
-});
-
-var Event = Base.extend({
-	_class: 'Event',
-
-	initialize: function Event(event) {
-		this.event = event;
-	},
-
-	preventDefault: function() {
-		this._prevented = true;
-		DomEvent.preventDefault(this.event);
-	},
-
-	stopPropagation: function() {
-		this._stopped = true;
-		DomEvent.stopPropagation(this.event);
-	},
-
-	stop: function() {
-		this.stopPropagation();
-		this.preventDefault();
-	},
-
-	getModifiers: function() {
-		return Key.modifiers;
-	}
-});
-
-var KeyEvent = Event.extend({
-	_class: 'KeyEvent',
-
-	initialize: function KeyEvent(down, key, character, event) {
-		Event.call(this, event);
-		this.type = down ? 'keydown' : 'keyup';
-		this.key = key;
-		this.character = character;
-	},
-
-	toString: function() {
-		return "{ type: '" + this.type
-				+ "', key: '" + this.key
-				+ "', character: '" + this.character
-				+ "', modifiers: " + this.getModifiers()
-				+ " }";
-	}
-});
-
-var Key = new function() {
-
-	var specialKeys = {
-		8: 'backspace',
-		9: 'tab',
-		13: 'enter',
-		16: 'shift',
-		17: 'control',
-		18: 'option',
-		19: 'pause',
-		20: 'caps-lock',
-		27: 'escape',
-		32: 'space',
-		35: 'end',
-		36: 'home',
-		37: 'left',
-		38: 'up',
-		39: 'right',
-		40: 'down',
-		46: 'delete',
-		91: 'command',
-		93: 'command', 
-		224: 'command'  
-	},
-
-	specialChars = {
-		9: true, 
-		13: true, 
-		32: true 
-	},
-
-	modifiers = new Base({
-		shift: false,
-		control: false,
-		option: false,
-		command: false,
-		capsLock: false,
-		space: false
-	}),
-
-	charCodeMap = {}, 
-	keyMap = {}, 
-	downCode; 
-
-	function handleKey(down, keyCode, charCode, event) {
-		var character = charCode ? String.fromCharCode(charCode) : '',
-			specialKey = specialKeys[keyCode],
-			key = specialKey || character.toLowerCase(),
-			type = down ? 'keydown' : 'keyup',
-			view = View._focused,
-			scope = view && view.isVisible() && view._scope,
-			tool = scope && scope._tool,
-			name;
-		keyMap[key] = down;
-		if (specialKey && (name = Base.camelize(specialKey)) in modifiers)
-			modifiers[name] = down;
-		if (down) {
-			charCodeMap[keyCode] = charCode;
-		} else {
-			delete charCodeMap[keyCode];
-		}
-		if (tool && tool.responds(type)) {
-			paper = scope;
-			tool.fire(type, new KeyEvent(down, key, character, event));
-			if (view)
-				view.draw(true);
-		}
-	}
-
-	DomEvent.add(document, {
-		keydown: function(event) {
-			var code = event.which || event.keyCode;
-			if (code in specialKeys) {
-				handleKey(true, code, code in specialChars ? code : 0, event);
-			} else {
-				downCode = code;
-			}
-		},
-
-		keypress: function(event) {
-			if (downCode != null) {
-				handleKey(true, downCode, event.which || event.keyCode, event);
-				downCode = null;
-			}
-		},
-
-		keyup: function(event) {
-			var code = event.which || event.keyCode;
-			if (code in charCodeMap)
-				handleKey(false, code, charCodeMap[code], event);
-		}
-	});
-
-	DomEvent.add(window, {
-		blur: function(event) {
-			for (var code in charCodeMap)
-				handleKey(false, code, charCodeMap[code], event);
-		}
-	});
-
-	return {
-		modifiers: modifiers,
-
-		isDown: function(key) {
-			return !!keyMap[key];
-		}
-	};
-};
-
-var MouseEvent = Event.extend({
-	_class: 'MouseEvent',
-
-	initialize: function MouseEvent(type, event, point, target, delta) {
-		Event.call(this, event);
-		this.type = type;
-		this.point = point;
-		this.target = target;
-		this.delta = delta;
-	},
-
-	toString: function() {
-		return "{ type: '" + this.type
-				+ "', point: " + this.point
-				+ ', target: ' + this.target
-				+ (this.delta ? ', delta: ' + this.delta : '')
-				+ ', modifiers: ' + this.getModifiers()
-				+ ' }';
-	}
-});
-
- Base.extend(Callback, {
-	_class: 'Palette',
-	_events: [ 'onChange' ],
-
-	initialize: function Palette(title, components, values) {
-		var parent = DomElement.find('.palettejs-panel')
-			|| DomElement.find('body').appendChild(
-				DomElement.create('div', { 'class': 'palettejs-panel' }));
-		this._element = parent.appendChild(
-			DomElement.create('table', { 'class': 'palettejs-pane' }));
-		this._title = title;
-		if (!values)
-			values = {};
-		for (var name in (this.components = components)) {
-			var component = components[name];
-			if (!(component instanceof Component)) {
-				if (component.value == null)
-					component.value = values[name];
-				component.name = name;
-				component = components[name] = new Component(component);
-			}
-			this._element.appendChild(component._element);
-			component._palette = this;
-			if (values[name] === undefined)
-				values[name] = component.value;
-		}
-		this.values = Base.each(values, function(value, name) {
-			var component = components[name];
-			if (component) {
-				Base.define(values, name, {
-					enumerable: true,
-					configurable: true,
-					get: function() {
-						return component._value;
-					},
-					set: function(val) {
-						component.setValue(val);
-					}
-				});
-			}
-		});
-		if (window.paper)
-			paper.palettes.push(this);
-	},
-
-	reset: function() {
-		for (var i in this.components)
-			this.components[i].reset();
-	},
-
-	remove: function() {
-		DomElement.remove(this._element);
-	}
-});
-
-var Component = Base.extend(Callback, {
-	_class: 'Component',
-	_events: [ 'onChange', 'onClick' ],
-
-	_types: {
-		'boolean': {
-			type: 'checkbox',
-			value: 'checked'
-		},
-
-		string: {
-			type: 'text'
-		},
-
-		number: {
-			type: 'number',
-			number: true
-		},
-
-		button: {
-			type: 'button'
-		},
-
-		text: {
-			tag: 'div',
-			value: 'text'
-		},
-
-		slider: {
-			type: 'range',
-			number: true
-		},
-
-		list: {
-			tag: 'select',
-
-			setOptions: function() {
-				DomElement.removeChildren(this._input);
-				DomElement.create(Base.each(this._options, function(option) {
-					this.push('option', { value: option, text: option });
-				}, []), this._input);
-			}
-		},
-
-		color: {
-			type: 'color',
-
-			getValue: function(value) {
-				return new Color(value);
-			},
-
-			setValue: function(value) {
-				return new Color(value).toCSS(
-						DomElement.get(this._input, 'type') === 'color');
-			}
-		}
-	},
-
-	initialize: function Component(obj) {
-		this._id = Component._id = (Component._id || 0) + 1;
-		this._type = obj.type in this._types
-			? obj.type
-			: 'options' in obj
-				? 'list'
-				: 'onClick' in obj
-					? 'button'
-					: typeof obj.value;
-		this._meta = this._types[this._type] || { type: this._type };
-		var that = this,
-			id = 'component-' + this._id;
-		this._dontFire = true;
-		this._input = DomElement.create(this._meta.tag || 'input', {
-			id: id,
-			type: this._meta.type,
-			events: {
-				change: function() {
-					that.setValue(
-						DomElement.get(this, that._meta.value || 'value'));
-				},
-				click: function() {
-					that.fire('click');
-				}
-			}
-		});
-		this.attach('change', function(value) {
-			if (!this._dontFire)
-				this._palette.fire('change', this, this.name, value);
-		});
-		this._element = DomElement.create('tr', [
-			'td', [this._label = DomElement.create('label', { 'for': id })],
-			'td', [this._input]
-		]);
-		Base.each(obj, function(value, key) {
-			this[key] = value;
-		}, this);
-		this._defaultValue = this._value;
-		this._dontFire = false;
-	},
-
-	getType: function() {
-		return this._type;
-	},
-
-	getLabel: function() {
-		return this.__label;
-	},
-
-	setLabel: function(label) {
-		this.__label = label;
-		DomElement.set(this._label, 'text', label + ':');
-	},
-
-	getOptions: function() {
-		return this._options;
-	},
-
-	setOptions: function(options) {
-		this._options = options;
-		var setOptions = this._meta.setOptions;
-		if (setOptions)
-			setOptions.call(this);
-	},
-
-	getValue: function() {
-		var value = this._value,
-			getValue = this._meta.getValue;
-		return getValue ? getValue.call(this, value) : value;
-	},
-
-	setValue: function(value) {
-		var key = this._meta.value || 'value',
-			setValue = this._meta.setValue;
-		if (setValue)
-			value = setValue.call(this, value);
-		DomElement.set(this._input, key, value);
-		value = DomElement.get(this._input, key);
-		if (this._meta.number)
-			value = parseFloat(value, 10);
-		if (this._value !== value) {
-			this._value = value;
-			if (!this._dontFire)
-				this.fire('change', this.getValue());
-		}
-	},
-
-	getRange: function() {
-		return [parseFloat(DomElement.get(this._input, 'min')),
-				parseFloat(DomElement.get(this._input, 'max'))];
-	},
-
-	setRange: function(min, max) {
-		var range = Array.isArray(min) ? min : [min, max];
-		DomElement.set(this._input, { min: range[0], max: range[1] });
-	},
-
-	getMin: function() {
-		return this.getRange()[0];
-	},
-
-	setMin: function(min) {
-		this.setRange(min, this.getMax());
-	},
-
-	getMax: function() {
-		return this.getRange()[1];
-	},
-
-	setMax: function(max) {
-		this.setRange(this.getMin(), max);
-	},
-
-	getStep: function() {
-		return parseFloat(DomElement.get(this._input, 'step'));
-	},
-
-	setStep: function(step) {
-		DomElement.set(this._input, 'step', step);
-	},
-
-	reset: function() {
-		this.setValue(this._defaultValue);
-	}
-});
-
-var ToolEvent = Event.extend({
-	_class: 'ToolEvent',
-	_item: null,
-
-	initialize: function ToolEvent(tool, type, event) {
-		this.tool = tool;
-		this.type = type;
-		this.event = event;
-	},
-
-	_choosePoint: function(point, toolPoint) {
-		return point ? point : toolPoint ? toolPoint.clone() : null;
-	},
-
-	getPoint: function() {
-		return this._choosePoint(this._point, this.tool._point);
-	},
-
-	setPoint: function(point) {
-		this._point = point;
-	},
-
-	getLastPoint: function() {
-		return this._choosePoint(this._lastPoint, this.tool._lastPoint);
-	},
-
-	setLastPoint: function(lastPoint) {
-		this._lastPoint = lastPoint;
-	},
-
-	getDownPoint: function() {
-		return this._choosePoint(this._downPoint, this.tool._downPoint);
-	},
-
-	setDownPoint: function(downPoint) {
-		this._downPoint = downPoint;
-	},
-
-	getMiddlePoint: function() {
-		if (!this._middlePoint && this.tool._lastPoint) {
-			return this.tool._point.add(this.tool._lastPoint).divide(2);
-		}
-		return this._middlePoint;
-	},
-
-	setMiddlePoint: function(middlePoint) {
-		this._middlePoint = middlePoint;
-	},
-
-	getDelta: function() {
-		return !this._delta && this.tool._lastPoint
-		 		? this.tool._point.subtract(this.tool._lastPoint)
-				: this._delta;
-	},
-
-	setDelta: function(delta) {
-		this._delta = delta;
-	},
-
-	getCount: function() {
-		return /^mouse(down|up)$/.test(this.type)
-				? this.tool._downCount
-				: this.tool._count;
-	},
-
-	setCount: function(count) {
-		this.tool[/^mouse(down|up)$/.test(this.type) ? 'downCount' : 'count']
-			= count;
-	},
-
-	getItem: function() {
-		if (!this._item) {
-			var result = this.tool._scope.project.hitTest(this.getPoint());
-			if (result) {
-				var item = result.item,
-					parent = item._parent;
-				while (/^(group|compound-path)$/.test(parent._type)) {
-					item = parent;
-					parent = parent._parent;
-				}
-				this._item = item;
-			}
-		}
-		return this._item;
-	},
-	setItem: function(item) {
-		this._item = item;
-	},
-
-	toString: function() {
-		return '{ type: ' + this.type
-				+ ', point: ' + this.getPoint()
-				+ ', count: ' + this.getCount()
-				+ ', modifiers: ' + this.getModifiers()
-				+ ' }';
-	}
-});
-
-var Tool = PaperScopeItem.extend({
-	_class: 'Tool',
-	_list: 'tools',
-	_reference: '_tool', 
-	_events: [ 'onActivate', 'onDeactivate', 'onEditOptions',
-			'onMouseDown', 'onMouseUp', 'onMouseDrag', 'onMouseMove',
-			'onKeyDown', 'onKeyUp' ],
-
-	initialize: function Tool(props) {
-		PaperScopeItem.call(this);
-		this._firstMove = true;
-		this._count = 0;
-		this._downCount = 0;
-		this._set(props);
-	},
-
-	getMinDistance: function() {
-		return this._minDistance;
-	},
-
-	setMinDistance: function(minDistance) {
-		this._minDistance = minDistance;
-		if (this._minDistance != null && this._maxDistance != null
-				&& this._minDistance > this._maxDistance) {
-			this._maxDistance = this._minDistance;
-		}
-	},
-
-	getMaxDistance: function() {
-		return this._maxDistance;
-	},
-
-	setMaxDistance: function(maxDistance) {
-		this._maxDistance = maxDistance;
-		if (this._minDistance != null && this._maxDistance != null
-				&& this._maxDistance < this._minDistance) {
-			this._minDistance = maxDistance;
-		}
-	},
-
-	getFixedDistance: function() {
-		return this._minDistance == this._maxDistance
-			? this._minDistance : null;
-	},
-
-	setFixedDistance: function(distance) {
-		this._minDistance = distance;
-		this._maxDistance = distance;
-	},
-
-	_updateEvent: function(type, point, minDistance, maxDistance, start,
-			needsChange, matchMaxDistance) {
-		if (!start) {
-			if (minDistance != null || maxDistance != null) {
-				var minDist = minDistance != null ? minDistance : 0,
-					vector = point.subtract(this._point),
-					distance = vector.getLength();
-				if (distance < minDist)
-					return false;
-				var maxDist = maxDistance != null ? maxDistance : 0;
-				if (maxDist != 0) {
-					if (distance > maxDist) {
-						point = this._point.add(vector.normalize(maxDist));
-					} else if (matchMaxDistance) {
-						return false;
-					}
-				}
-			}
-			if (needsChange && point.equals(this._point))
-				return false;
-		}
-		this._lastPoint = start && type == 'mousemove' ? point : this._point;
-		this._point = point;
-		switch (type) {
-		case 'mousedown':
-			this._lastPoint = this._downPoint;
-			this._downPoint = this._point;
-			this._downCount++;
-			break;
-		case 'mouseup':
-			this._lastPoint = this._downPoint;
-			break;
-		}
-		this._count = start ? 0 : this._count + 1;
-		return true;
-	},
-
-	_fireEvent: function(type, event) {
-		var sets = paper.project._removeSets;
-		if (sets) {
-			if (type === 'mouseup')
-				sets.mousedrag = null;
-			var set = sets[type];
-			if (set) {
-				for (var id in set) {
-					var item = set[id];
-					for (var key in sets) {
-						var other = sets[key];
-						if (other && other != set)
-							delete other[item._id];
-					}
-					item.remove();
-				}
-				sets[type] = null;
-			}
-		}
-		return this.responds(type)
-				&& this.fire(type, new ToolEvent(this, type, event));
-	},
-
-	_onHandleEvent: function(type, point, event) {
-		paper = this._scope;
-		var called = false;
-		switch (type) {
-		case 'mousedown':
-			this._updateEvent(type, point, null, null, true, false, false);
-			called = this._fireEvent(type, event);
-			break;
-		case 'mousedrag':
-			var needsChange = false,
-				matchMaxDistance = false;
-			while (this._updateEvent(type, point, this.minDistance,
-					this.maxDistance, false, needsChange, matchMaxDistance)) {
-				called = this._fireEvent(type, event) || called;
-				needsChange = true;
-				matchMaxDistance = true;
-			}
-			break;
-		case 'mouseup':
-			if (!point.equals(this._point)
-					&& this._updateEvent('mousedrag', point, this.minDistance,
-							this.maxDistance, false, false, false)) {
-				called = this._fireEvent('mousedrag', event);
-			}
-			this._updateEvent(type, point, null, this.maxDistance, false,
-					false, false);
-			called = this._fireEvent(type, event) || called;
-			this._updateEvent(type, point, null, null, true, false, false);
-			this._firstMove = true;
-			break;
-		case 'mousemove':
-			while (this._updateEvent(type, point, this.minDistance,
-					this.maxDistance, this._firstMove, true, false)) {
-				called = this._fireEvent(type, event) || called;
-				this._firstMove = false;
-			}
-			break;
-		}
-		return called;
-	}
-
-});
-
-var Http = {
-	request: function(method, url, callback) {
-		var xhr = new (window.ActiveXObject || XMLHttpRequest)(
-					'Microsoft.XMLHTTP');
-		xhr.open(method.toUpperCase(), url, true);
-		if ('overrideMimeType' in xhr)
-			xhr.overrideMimeType('text/plain');
-		xhr.onreadystatechange = function() {
-			if (xhr.readyState === 4) {
-				var status = xhr.status;
-				if (status === 0 || status === 200) {
-					callback.call(xhr, xhr.responseText);
-				} else {
-					throw new Error('Could not load ' + url + ' (Error '
-							+ status + ')');
-				}
-			}
-		};
-		return xhr.send(null);
-	}
-};
-
-var CanvasProvider = {
-	canvases: [],
-
-	getCanvas: function(width, height, ratio) {
-		var canvas,
-			init = true;
-		if (typeof width === 'object') {
-			ratio = height;
-			height = width.height;
-			width = width.width;
-		}
-		if (!ratio) {
-			ratio = 1;
-		} else if (ratio !== 1) {
-			width *= ratio;
-			height *= ratio;
-		}
-		if (this.canvases.length) {
-			canvas = this.canvases.pop();
-		} else {
-			canvas = document.createElement('canvas');
-		}
-		var ctx = canvas.getContext('2d');
-		if (canvas.width === width && canvas.height === height) {
-			if (init)
-				ctx.clearRect(0, 0, width + 1, height + 1);
-		} else {
-			canvas.width = width;
-			canvas.height = height;
-		}
-		ctx.save();
-		if (ratio !== 1)
-			ctx.scale(ratio, ratio);
-		return canvas;
-	},
-
-	getContext: function(width, height) {
-		return this.getCanvas(width, height).getContext('2d');
-	},
-
-	release: function(obj) {
-		var canvas = obj.canvas ? obj.canvas : obj;
-		canvas.getContext('2d').restore();
-		this.canvases.push(canvas);
-	}
-};
-
-var BlendMode = new function() {
-	var min = Math.min,
-		max = Math.max,
-		abs = Math.abs,
-		sr, sg, sb, sa, 
-		br, bg, bb, ba, 
-		dr, dg, db;     
-
-	function getLum(r, g, b) {
-		return 0.2989 * r + 0.587 * g + 0.114 * b;
-	}
-
-	function setLum(r, g, b, l) {
-		var d = l - getLum(r, g, b);
-		dr = r + d;
-		dg = g + d;
-		db = b + d;
-		var l = getLum(dr, dg, db),
-			mn = min(dr, dg, db),
-			mx = max(dr, dg, db);
-		if (mn < 0) {
-			var lmn = l - mn;
-			dr = l + (dr - l) * l / lmn;
-			dg = l + (dg - l) * l / lmn;
-			db = l + (db - l) * l / lmn;
-		}
-		if (mx > 255) {
-			var ln = 255 - l,
-				mxl = mx - l;
-			dr = l + (dr - l) * ln / mxl;
-			dg = l + (dg - l) * ln / mxl;
-			db = l + (db - l) * ln / mxl;
-		}
-	}
-
-	function getSat(r, g, b) {
-		return max(r, g, b) - min(r, g, b);
-	}
-
-	function setSat(r, g, b, s) {
-		var col = [r, g, b],
-			mx = max(r, g, b), 
-			mn = min(r, g, b), 
-			md; 
-		mn = mn === r ? 0 : mn === g ? 1 : 2;
-		mx = mx === r ? 0 : mx === g ? 1 : 2;
-		md = min(mn, mx) === 0 ? max(mn, mx) === 1 ? 2 : 1 : 0;
-		if (col[mx] > col[mn]) {
-			col[md] = (col[md] - col[mn]) * s / (col[mx] - col[mn]);
-			col[mx] = s;
-		} else {
-			col[md] = col[mx] = 0;
-		}
-		col[mn] = 0;
-		dr = col[0];
-		dg = col[1];
-		db = col[2];
-	}
-
-	var modes = {
-		multiply: function() {
-			dr = br * sr / 255;
-			dg = bg * sg / 255;
-			db = bb * sb / 255;
-		},
-
-		screen: function() {
-			dr = br + sr - (br * sr / 255);
-			dg = bg + sg - (bg * sg / 255);
-			db = bb + sb - (bb * sb / 255);
-		},
-
-		overlay: function() {
-			dr = br < 128 ? 2 * br * sr / 255 : 255 - 2 * (255 - br) * (255 - sr) / 255;
-			dg = bg < 128 ? 2 * bg * sg / 255 : 255 - 2 * (255 - bg) * (255 - sg) / 255;
-			db = bb < 128 ? 2 * bb * sb / 255 : 255 - 2 * (255 - bb) * (255 - sb) / 255;
-		},
-
-		'soft-light': function() {
-			var t = sr * br / 255;
-			dr = t + br * (255 - (255 - br) * (255 - sr) / 255 - t) / 255;
-			t = sg * bg / 255;
-			dg = t + bg * (255 - (255 - bg) * (255 - sg) / 255 - t) / 255;
-			t = sb * bb / 255;
-			db = t + bb * (255 - (255 - bb) * (255 - sb) / 255 - t) / 255;
-		},
-
-		'hard-light': function() {
-			dr = sr < 128 ? 2 * sr * br / 255 : 255 - 2 * (255 - sr) * (255 - br) / 255;
-			dg = sg < 128 ? 2 * sg * bg / 255 : 255 - 2 * (255 - sg) * (255 - bg) / 255;
-			db = sb < 128 ? 2 * sb * bb / 255 : 255 - 2 * (255 - sb) * (255 - bb) / 255;
-		},
-
-		'color-dodge': function() {
-			dr = br === 0 ? 0 : sr === 255 ? 255 : min(255, 255 * br / (255 - sr));
-			dg = bg === 0 ? 0 : sg === 255 ? 255 : min(255, 255 * bg / (255 - sg));
-			db = bb === 0 ? 0 : sb === 255 ? 255 : min(255, 255 * bb / (255 - sb));
-		},
-
-		'color-burn': function() {
-			dr = br === 255 ? 255 : sr === 0 ? 0 : max(0, 255 - (255 - br) * 255 / sr);
-			dg = bg === 255 ? 255 : sg === 0 ? 0 : max(0, 255 - (255 - bg) * 255 / sg);
-			db = bb === 255 ? 255 : sb === 0 ? 0 : max(0, 255 - (255 - bb) * 255 / sb);
-		},
-
-		darken: function() {
-			dr = br < sr ? br : sr;
-			dg = bg < sg ? bg : sg;
-			db = bb < sb ? bb : sb;
-		},
-
-		lighten: function() {
-			dr = br > sr ? br : sr;
-			dg = bg > sg ? bg : sg;
-			db = bb > sb ? bb : sb;
-		},
-
-		difference: function() {
-			dr = br - sr;
-			if (dr < 0)
-				dr = -dr;
-			dg = bg - sg;
-			if (dg < 0)
-				dg = -dg;
-			db = bb - sb;
-			if (db < 0)
-				db = -db;
-		},
-
-		exclusion: function() {
-			dr = br + sr * (255 - br - br) / 255;
-			dg = bg + sg * (255 - bg - bg) / 255;
-			db = bb + sb * (255 - bb - bb) / 255;
-		},
-
-		hue: function() {
-			setSat(sr, sg, sb, getSat(br, bg, bb));
-			setLum(dr, dg, db, getLum(br, bg, bb));
-		},
-
-		saturation: function() {
-			setSat(br, bg, bb, getSat(sr, sg, sb));
-			setLum(dr, dg, db, getLum(br, bg, bb));
-		},
-
-		luminosity: function() {
-			setLum(br, bg, bb, getLum(sr, sg, sb));
-		},
-
-		color: function() {
-			setLum(sr, sg, sb, getLum(br, bg, bb));
-		},
-
-		add: function() {
-			dr = min(br + sr, 255);
-			dg = min(bg + sg, 255);
-			db = min(bb + sb, 255);
-		},
-
-		subtract: function() {
-			dr = max(br - sr, 0);
-			dg = max(bg - sg, 0);
-			db = max(bb - sb, 0);
-		},
-
-		average: function() {
-			dr = (br + sr) / 2;
-			dg = (bg + sg) / 2;
-			db = (bb + sb) / 2;
-		},
-
-		negation: function() {
-			dr = 255 - abs(255 - sr - br);
-			dg = 255 - abs(255 - sg - bg);
-			db = 255 - abs(255 - sb - bb);
-		}
-	};
-
-	var nativeModes = this.nativeModes = Base.each([
-		'source-over', 'source-in', 'source-out', 'source-atop',
-		'destination-over', 'destination-in', 'destination-out',
-		'destination-atop', 'lighter', 'darker', 'copy', 'xor'
-	], function(mode) {
-		this[mode] = true;
-	}, {});
-
-	var ctx = CanvasProvider.getContext(1, 1);
-	Base.each(modes, function(func, mode) {
-		ctx.save();
-		var darken = mode === 'darken',
-			ok = false;
-		ctx.fillStyle = darken ? '#300' : '#a00';
-		ctx.fillRect(0, 0, 1, 1);
-		ctx.globalCompositeOperation = mode;
-		if (ctx.globalCompositeOperation === mode) {
-			ctx.fillStyle = darken ? '#a00' : '#300';
-			ctx.fillRect(0, 0, 1, 1);
-			ok = ctx.getImageData(0, 0, 1, 1).data[0] !== (darken ? 170 : 51);
-		}
-		nativeModes[mode] = ok; 
-		ctx.restore();
-	});
-	CanvasProvider.release(ctx);
-
-	this.process = function(mode, srcContext, dstContext, alpha, offset) {
-		var srcCanvas = srcContext.canvas,
-			normal = mode === 'normal';
-		if (normal || nativeModes[mode]) {
-			dstContext.save();
-			dstContext.setTransform(1, 0, 0, 1, 0, 0);
-			dstContext.globalAlpha = alpha;
-			if (!normal)
-				dstContext.globalCompositeOperation = mode;
-			dstContext.drawImage(srcCanvas, offset.x, offset.y);
-			dstContext.restore();	
-		} else {
-			var process = modes[mode];
-			if (!process)
-				return;
-			var dstData = dstContext.getImageData(offset.x, offset.y,
-					srcCanvas.width, srcCanvas.height),
-				dst  = dstData.data,
-				src  = srcContext.getImageData(0, 0,
-					srcCanvas.width, srcCanvas.height).data;
-			for (var i = 0, l = dst.length; i < l; i += 4) {
-				sr = src[i];
-				br = dst[i];
-				sg = src[i + 1];
-				bg = dst[i + 1];
-				sb = src[i + 2];
-				bb = dst[i + 2];
-				sa = src[i + 3];
-				ba = dst[i + 3];
-				process();
-				var a1 = sa * alpha / 255,
-					a2 = 1 - a1;
-				dst[i] = a1 * dr + a2 * br;
-				dst[i + 1] = a1 * dg + a2 * bg;
-				dst[i + 2] = a1 * db + a2 * bb;
-				dst[i + 3] = sa * alpha + a2 * ba;
-			}
-			dstContext.putImageData(dstData, offset.x, offset.y);
-		}
-	};
-};
-
-var SVGStyles = Base.each({
-	fillColor: ['fill', 'color'],
-	strokeColor: ['stroke', 'color'],
-	strokeWidth: ['stroke-width', 'number'],
-	strokeCap: ['stroke-linecap', 'string'],
-	strokeJoin: ['stroke-linejoin', 'string'],
-	miterLimit: ['stroke-miterlimit', 'number'],
-	dashArray: ['stroke-dasharray', 'array'],
-	dashOffset: ['stroke-dashoffset', 'number'],
-	font: ['font-family', 'string'],
-	fontSize: ['font-size', 'number'],
-	justification: ['text-anchor', 'lookup', {
-		left: 'start',
-		center: 'middle',
-		right: 'end'
-	}],
-	opacity: ['opacity', 'number'],
-	blendMode: ['mix-blend-mode', 'string']
-}, function(entry, key) {
-	var part = Base.capitalize(key),
-		lookup = entry[2];
-	this[key] = {
-		type: entry[1],
-		property: key,
-		attribute: entry[0],
-		toSVG: lookup,
-		fromSVG: lookup && Base.each(lookup, function(value, name) {
-			this[value] = name;
-		}, {}),
-		get: 'get' + part,
-		set: 'set' + part
-	};
-}, {});
-
-var SVGNamespaces = {
-	href: 'http://www.w3.org/1999/xlink',
-	xlink: 'http://www.w3.org/2000/xmlns'
-};
-
-new function() {
-	var formatter;
-
-	function setAttributes(node, attrs) {
-		for (var key in attrs) {
-			var val = attrs[key],
-				namespace = SVGNamespaces[key];
-			if (typeof val === 'number')
-				val = formatter.number(val);
-			if (namespace) {
-				node.setAttributeNS(namespace, key, val);
-			} else {
-				node.setAttribute(key, val);
-			}
-		}
-		return node;
-	}
-
-	function createElement(tag, attrs) {
-		return setAttributes(
-			document.createElementNS('http://www.w3.org/2000/svg', tag), attrs);
-	}
-
-	function getTransform(item, coordinates, center) {
-		var matrix = item._matrix,
-			trans = matrix.getTranslation(),
-			attrs = {};
-		if (coordinates) {
-			matrix = matrix.shiftless();
-			var point = matrix._inverseTransform(trans);
-			attrs[center ? 'cx' : 'x'] = point.x;
-			attrs[center ? 'cy' : 'y'] = point.y;
-			trans = null;
-		}
-		if (matrix.isIdentity())
-			return attrs;
-		var decomposed = matrix.decompose();
-		if (decomposed && !decomposed.shearing) {
-			var parts = [],
-				angle = decomposed.rotation,
-				scale = decomposed.scaling;
-			if (trans && !trans.isZero())
-				parts.push('translate(' + formatter.point(trans) + ')');
-			if (!Numerical.isZero(scale.x - 1) || !Numerical.isZero(scale.y - 1))
-				parts.push('scale(' + formatter.point(scale) +')');
-			if (angle)
-				parts.push('rotate(' + formatter.number(angle) + ')');
-			attrs.transform = parts.join(' ');
-		} else {
-			attrs.transform = 'matrix(' + matrix.getValues().join(',') + ')';
-		}
-		return attrs;
-	}
-
-	function exportGroup(item, options) {
-		var attrs = getTransform(item),
-			children = item._children;
-		var node = createElement('g', attrs);
-		for (var i = 0, l = children.length; i < l; i++) {
-			var child = children[i];
-			var childNode = exportSVG(child, options);
-			if (childNode) {
-				if (child.isClipMask()) {
-					var clip = createElement('clipPath');
-					clip.appendChild(childNode);
-					setDefinition(child, clip, 'clip');
-					setAttributes(node, {
-						'clip-path': 'url(#' + clip.id + ')'
-					});
-				} else {
-					node.appendChild(childNode);
-				}
-			}
-		}
-		return node;
-	}
-
-	function exportRaster(item) {
-		var attrs = getTransform(item, true),
-			size = item.getSize();
-		attrs.x -= size.width / 2;
-		attrs.y -= size.height / 2;
-		attrs.width = size.width;
-		attrs.height = size.height;
-		attrs.href = item.toDataURL();
-		return createElement('image', attrs);
-	}
-
-	function exportPath(item, options) {
-		if (options.matchShapes) {
-			var shape = item.toShape(false);
-			if (shape)
-				return exportShape(shape, options);
-		}
-		var segments = item._segments,
-			type,
-			attrs;
-		if (segments.length === 0)
-			return null;
-		if (item.isPolygon()) {
-			if (segments.length >= 3) {
-				type = item._closed ? 'polygon' : 'polyline';
-				var parts = [];
-				for(i = 0, l = segments.length; i < l; i++)
-					parts.push(formatter.point(segments[i]._point));
-				attrs = {
-					points: parts.join(' ')
-				};
-			} else {
-				type = 'line';
-				var first = segments[0]._point,
-					last = segments[segments.length - 1]._point;
-				attrs = {
-					x1: first.x,
-					y1: first.y,
-					x2: last.x,
-					y2: last.y
-				};
-			}
-		} else {
-			type = 'path';
-			var data = item.getPathData();
-			attrs = data && { d: data };
-		}
-		return createElement(type, attrs);
-	}
-
-	function exportShape(item) {
-		var shape = item._shape,
-			radius = item._radius,
-			attrs = getTransform(item, true, shape !== 'rectangle');
-		if (shape === 'rectangle') {
-			shape = 'rect'; 
-			var size = item._size,
-				width = size.width,
-				height = size.height;
-			attrs.x -= width / 2;
-			attrs.y -= height / 2;
-			attrs.width = width;
-			attrs.height = height;
-			if (radius.isZero())
-				radius = null;
-		}
-		if (radius) {
-			if (shape === 'circle') {
-				attrs.r = radius;
-			} else {
-				attrs.rx = radius.width;
-				attrs.ry = radius.height;
-			}
-		}
-		return createElement(shape, attrs);
-	}
-
-	function exportCompoundPath(item) {
-		var attrs = getTransform(item, true);
-		var data = item.getPathData();
-		if (data)
-			attrs.d = data;
-		return createElement('path', attrs);
-	}
-
-	function exportPlacedSymbol(item, options) {
-		var attrs = getTransform(item, true),
-			symbol = item.getSymbol(),
-			symbolNode = getDefinition(symbol, 'symbol'),
-			definition = symbol.getDefinition(),
-			bounds = definition.getBounds();
-		if (!symbolNode) {
-			symbolNode = createElement('symbol', {
-				viewBox: formatter.rectangle(bounds)
-			});
-			symbolNode.appendChild(exportSVG(definition, options));
-			setDefinition(symbol, symbolNode, 'symbol');
-		}
-		attrs.href = '#' + symbolNode.id;
-		attrs.x += bounds.x;
-		attrs.y += bounds.y;
-		attrs.width = formatter.number(bounds.width);
-		attrs.height = formatter.number(bounds.height);
-		return createElement('use', attrs);
-	}
-
-	function exportGradient(color) {
-		var gradientNode = getDefinition(color, 'color');
-		if (!gradientNode) {
-			var gradient = color.getGradient(),
-				radial = gradient._radial,
-				origin = color.getOrigin().transform(),
-				destination = color.getDestination().transform(),
-				attrs;
-			if (radial) {
-				attrs = {
-					cx: origin.x,
-					cy: origin.y,
-					r: origin.getDistance(destination)
-				};
-				var highlight = color.getHighlight();
-				if (highlight) {
-					highlight = highlight.transform();
-					attrs.fx = highlight.x;
-					attrs.fy = highlight.y;
-				}
-			} else {
-				attrs = {
-					x1: origin.x,
-					y1: origin.y,
-					x2: destination.x,
-					y2: destination.y
-				};
-			}
-			attrs.gradientUnits = 'userSpaceOnUse';
-			gradientNode = createElement(
-					(radial ? 'radial' : 'linear') + 'Gradient', attrs);
-			var stops = gradient._stops;
-			for (var i = 0, l = stops.length; i < l; i++) {
-				var stop = stops[i],
-					stopColor = stop._color,
-					alpha = stopColor.getAlpha();
-				attrs = {
-					offset: stop._rampPoint,
-					'stop-color': stopColor.toCSS(true)
-				};
-				if (alpha < 1)
-					attrs['stop-opacity'] = alpha;
-				gradientNode.appendChild(createElement('stop', attrs));
-			}
-			setDefinition(color, gradientNode, 'color');
-		}
-		return 'url(#' + gradientNode.id + ')';
-	}
-
-	function exportText(item) {
-		var node = createElement('text', getTransform(item, true));
-		node.textContent = item._content;
-		return node;
-	}
-
-	var exporters = {
-		group: exportGroup,
-		layer: exportGroup,
-		raster: exportRaster,
-		path: exportPath,
-		shape: exportShape,
-		'compound-path': exportCompoundPath,
-		'placed-symbol': exportPlacedSymbol,
-		'point-text': exportText
-	};
-
-	function applyStyle(item, node) {
-		var attrs = {},
-			parent = item.getParent();
-
-		if (item._name != null)
-			attrs.id = item._name;
-
-		Base.each(SVGStyles, function(entry) {
-			var get = entry.get,
-				type = entry.type,
-				value = item[get]();
-			if (!parent || !Base.equals(parent[get](), value)) {
-				if (type === 'color' && value != null) {
-					var alpha = value.getAlpha();
-					if (alpha < 1)
-						attrs[entry.attribute + '-opacity'] = alpha;
-				}
-				attrs[entry.attribute] = value == null
-					? 'none'
-					: type === 'number'
-						? formatter.number(value)
-						: type === 'color'
-							? value.gradient
-								? exportGradient(value, item)
-								: value.toCSS(true)
-							: type === 'array'
-								? value.join(',')
-								: type === 'lookup'
-									? entry.toSVG[value]
-									: value;
-			}
-		});
-
-		if (attrs.opacity === 1)
-			delete attrs.opacity;
-
-		if (item._visibility != null && !item._visibility)
-			attrs.visibility = 'hidden';
-
-		return setAttributes(node, attrs);
-	}
-
-	var definitions;
-	function getDefinition(item, type) {
-		if (!definitions)
-			definitions = { ids: {}, svgs: {} };
-		return item && definitions.svgs[type + '-' + item._id];
-	}
-
-	function setDefinition(item, node, type) {
-		if (!definitions)
-			getDefinition();
-		var id = definitions.ids[type] = (definitions.ids[type] || 0) + 1;
-		node.id = type + '-' + id;
-		definitions.svgs[type + '-' + item._id] = node;
-	}
-
-	function exportDefinitions(node, options) {
-		var svg = node,
-			defs = null;
-		if (definitions) {
-			svg = node.nodeName.toLowerCase() === 'svg' && node;
-			for (var i in definitions.svgs) {
-				if (!defs) {
-					if (!svg) {
-						svg = createElement('svg');
-						svg.appendChild(node);
-					}
-					defs = svg.insertBefore(createElement('defs'),
-							svg.firstChild);
-				}
-				defs.appendChild(definitions.svgs[i]);
-			}
-			definitions = null;
-		}
-		return options.asString
-				? new XMLSerializer().serializeToString(svg)
-				: svg;
-	}
-
-	function exportSVG(item, options) {
-		var exporter = exporters[item._type],
-			node = exporter && exporter(item, options);
-		if (node && item._data)
-			node.setAttribute('data-paper-data', JSON.stringify(item._data));
-		return node && applyStyle(item, node);
-	}
-
-	function setOptions(options) {
-		if (!options)
-			options = {};
-		formatter = new Formatter(options.precision);
-		return options;
-	}
-
-	Item.inject({
-		exportSVG: function(options) {
-			options = setOptions(options);
-			return exportDefinitions(exportSVG(this, options), options);
-		}
-	});
-
-	Project.inject({
-		exportSVG: function(options) {
-			options = setOptions(options);
-			var layers = this.layers,
-				size = this.view.getSize(),
-				node = createElement('svg', {
-					x: 0,
-					y: 0,
-					width: size.width,
-					height: size.height,
-					version: '1.1',
-					xmlns: 'http://www.w3.org/2000/svg',
-					'xmlns:xlink': 'http://www.w3.org/1999/xlink'
-				});
-			for (var i = 0, l = layers.length; i < l; i++)
-				node.appendChild(exportSVG(layers[i], options));
-			return exportDefinitions(node, options);
-		}
-	});
-};
-
-new function() {
-
-	function getValue(node, name, isString, allowNull) {
-		var namespace = SVGNamespaces[name],
-			value = namespace
-				? node.getAttributeNS(namespace, name)
-				: node.getAttribute(name);
-		if (value === 'null')
-			value = null;
-		return value == null
-				? allowNull
-					? null
-					: isString
-						? ''
-						: 0
-				: isString
-					? value
-					: parseFloat(value);
-	}
-
-	function getPoint(node, x, y, allowNull) {
-		x = getValue(node, x, false, allowNull);
-		y = getValue(node, y, false, allowNull);
-		return allowNull && (x == null || y == null) ? null
-				: new Point(x, y);
-	}
-
-	function getSize(node, w, h, allowNull) {
-		w = getValue(node, w, false, allowNull);
-		h = getValue(node, h, false, allowNull);
-		return allowNull && (w == null || h == null) ? null
-				: new Size(w, h);
-	}
-
-	function convertValue(value, type, lookup) {
-		return value === 'none'
-				? null
-				: type === 'number'
-					? parseFloat(value)
-					: type === 'array'
-						? value ? value.split(/[\s,]+/g).map(parseFloat) : []
-						: type === 'color'
-							? getDefinition(value) || value
-							: type === 'lookup'
-								? lookup[value]
-								: value;
-	}
-
-	function importGroup(node, type, isRoot, options) {
-		var nodes = node.childNodes,
-			isClip = type === 'clippath',
-			item = new Group(),
-			project = item._project,
-			currentStyle = project._currentStyle,
-			children = [];
-		if (!isClip) {
-			item._transformContent = false;
-			item = applyAttributes(item, node, isRoot);
-			project._currentStyle = item._style.clone();
-		}
-		for (var i = 0, l = nodes.length; i < l; i++) {
-			var childNode = nodes[i],
-				child;
-			if (childNode.nodeType === 1
-					&& (child = importSVG(childNode, false, options))
-					&& !(child instanceof Symbol))
-				children.push(child);
-		}
-		item.addChildren(children);
-		if (isClip)
-			item = applyAttributes(item.reduce(), node, isRoot);
-		project._currentStyle = currentStyle;
-		if (isClip || type === 'defs') {
-			item.remove();
-			item = null;
-		}
-		return item;
-	}
-
-	function importPoly(node, type) {
-		var path = new Path(),
-			points = node.points;
-		path.moveTo(points.getItem(0));
-		for (var i = 1, l = points.numberOfItems; i < l; i++)
-			path.lineTo(points.getItem(i));
-		if (type === 'polygon')
-			path.closePath();
-		return path;
-	}
-
-	function importPath(node) {
-		var data = node.getAttribute('d'),
-			path = data.match(/m/gi).length > 1
-					? new CompoundPath()
-					: new Path();
-		path.setPathData(data);
-		return path;
-	}
-
-	function importGradient(node, type) {
-		var nodes = node.childNodes,
-			stops = [];
-		for (var i = 0, l = nodes.length; i < l; i++) {
-			var child = nodes[i];
-			if (child.nodeType === 1)
-				stops.push(applyAttributes(new GradientStop(), child));
-		}
-		var isRadial = type === 'radialgradient',
-			gradient = new Gradient(stops, isRadial),
-			origin, destination, highlight;
-		if (isRadial) {
-			origin = getPoint(node, 'cx', 'cy');
-			destination = origin.add(getValue(node, 'r'), 0);
-			highlight = getPoint(node, 'fx', 'fy', true);
-		} else {
-			origin = getPoint(node, 'x1', 'y1');
-			destination = getPoint(node, 'x2', 'y2');
-		}
-		applyAttributes(
-			new Color(gradient, origin, destination, highlight), node);
-		return null;
-	}
-
-	var importers = {
-		'#document': function (node, type, isRoot, options) {
-			var nodes = node.childNodes;
-			for (var i = 0, l = nodes.length; i < l; i++) {
-				var child = nodes[i];
-				if (child.nodeType === 1) {
-					var next = child.nextSibling;
-					document.body.appendChild(child);
-					var item = importSVG(child, isRoot, options);
-					if (next) {
-						node.insertBefore(child, next);
-					} else {
-						node.appendChild(child);
-					}
-					return item;
-				}
-			}
-		},
-		g: importGroup,
-		svg: importGroup,
-		clippath: importGroup,
-		polygon: importPoly,
-		polyline: importPoly,
-		path: importPath,
-		lineargradient: importGradient,
-		radialgradient: importGradient,
-
-		image: function (node) {
-			var raster = new Raster(getValue(node, 'href', true));
-			raster.attach('load', function() {
-				var size = getSize(node, 'width', 'height');
-				this.setSize(size);
-				var center = this._matrix._transformPoint(
-						getPoint(node, 'x', 'y').add(size.divide(2)));
-				this.translate(center);
-			});
-			return raster;
-		},
-
-		symbol: function(node, type, isRoot, options) {
-			return new Symbol(importGroup(node, type, isRoot, options), true);
-		},
-
-		defs: importGroup,
-
-		use: function(node) {
-			var id = (getValue(node, 'href', true) || '').substring(1),
-				definition = definitions[id],
-				point = getPoint(node, 'x', 'y');
-			return definition
-					? definition instanceof Symbol
-						? definition.place(point)
-						: definition.clone().translate(point)
-					: null;
-		},
-
-		circle: function(node) {
-			return new Shape.Circle(getPoint(node, 'cx', 'cy'),
-					getValue(node, 'r'));
-		},
-
-		ellipse: function(node) {
-			return new Shape.Ellipse({
-				center: getPoint(node, 'cx', 'cy'),
-				radius: getSize(node, 'rx', 'ry')
-			});
-		},
-
-		rect: function(node) {
-			var point = getPoint(node, 'x', 'y'),
-				size = getSize(node, 'width', 'height'),
-				radius = getSize(node, 'rx', 'ry');
-			return new Shape.Rectangle(new Rectangle(point, size), radius);
-		},
-
-		line: function(node) {
-			return new Path.Line(getPoint(node, 'x1', 'y1'),
-					getPoint(node, 'x2', 'y2'));
-		},
-
-		text: function(node) {
-			var text = new PointText(getPoint(node, 'x', 'y')
-					.add(getPoint(node, 'dx', 'dy')));
-			text.setContent(node.textContent.trim() || '');
-			return text;
-		}
-	};
-
-	function applyTransform(item, value, name, node) {
-		var transforms = (node.getAttribute(name) || '').split(/\)\s*/g),
-			matrix = new Matrix();
-		for (var i = 0, l = transforms.length; i < l; i++) {
-			var transform = transforms[i];
-			if (!transform)
-				break;
-			var parts = transform.split('('),
-				command = parts[0],
-				v = parts[1].split(/[\s,]+/g);
-			for (var j = 0, m = v.length; j < m; j++)
-				v[j] = parseFloat(v[j]);
-			switch (command) {
-			case 'matrix':
-				matrix.concatenate(
-						new Matrix(v[0], v[1], v[2], v[3], v[4], v[5]));
-				break;
-			case 'rotate':
-				matrix.rotate(v[0], v[1], v[2]);
-				break;
-			case 'translate':
-				matrix.translate(v[0], v[1]);
-				break;
-			case 'scale':
-				matrix.scale(v);
-				break;
-			case 'skewX':
-			case 'skewY':
-				var value = Math.tan(v[0] * Math.PI / 180),
-					isX = command == 'skewX';
-				matrix.shear(isX ? value : 0, isX ? 0 : value);
-				break;
-			}
-		}
-		item.transform(matrix);
-	}
-
-	function applyOpacity(item, value, name) {
-		var color = item[name === 'fill-opacity' ? 'getFillColor'
-				: 'getStrokeColor']();
-		if (color)
-			color.setAlpha(parseFloat(value));
-	}
-
-	var attributes = Base.each(SVGStyles, function(entry) {
-		this[entry.attribute] = function(item, value) {
-			item[entry.set](convertValue(value, entry.type, entry.fromSVG));
-			if (entry.type === 'color' && item instanceof Shape) {
-				var color = item[entry.get]();
-				if (color)
-					color.transform(new Matrix().translate(
-							item.getPosition(true).negate()));
-			}
-		};
-	}, {
-		id: function(item, value) {
-			definitions[value] = item;
-			if (item.setName)
-				item.setName(value);
-		},
-
-		'clip-path': function(item, value) {
-			var clip = getDefinition(value);
-			if (clip) {
-				clip = clip.clone();
-				clip.setClipMask(true);
-				if (item instanceof Group) {
-					item.insertChild(0, clip);
-				} else {
-					return new Group(clip, item);
-				}
-			}
-		},
-
-		gradientTransform: applyTransform,
-		transform: applyTransform,
-
-		'fill-opacity': applyOpacity,
-		'stroke-opacity': applyOpacity,
-
-		visibility: function(item, value) {
-			item.setVisible(value === 'visible');
-		},
-
-		'stop-color': function(item, value) {
-			if (item.setColor)
-				item.setColor(value);
-		},
-
-		'stop-opacity': function(item, value) {
-			if (item._color)
-				item._color.setAlpha(parseFloat(value));
-		},
-
-		offset: function(item, value) {
-			var percentage = value.match(/(.*)%$/);
-			item.setRampPoint(percentage
-					? percentage[1] / 100
-					: parseFloat(value));
-		},
-
-		viewBox: function(item, value, name, node, styles) {
-			var rect = new Rectangle(convertValue(value, 'array')),
-				size = getSize(node, 'width', 'height', true);
-			if (item instanceof Group) {
-				var scale = size ? rect.getSize().divide(size) : 1,
-					matrix = new Matrix().translate(rect.getPoint()).scale(scale);
-				item.transform(matrix.inverted());
-			} else if (item instanceof Symbol) {
-				if (size)
-					rect.setSize(size);
-				var clip = getAttribute(node, 'overflow', styles) != 'visible',
-					group = item._definition;
-				if (clip && !rect.contains(group.getBounds())) {
-					clip = new Shape.Rectangle(rect).transform(group._matrix);
-					clip.setClipMask(true);
-					group.addChild(clip);
-				}
-			}
-		}
-	});
-
-	function getAttribute(node, name, styles) {
-		var attr = node.attributes[name],
-			value = attr && attr.value;
-		if (!value) {
-			var style = Base.camelize(name);
-			value = node.style[style];
-			if (!value && styles.node[style] !== styles.parent[style])
-				value = styles.node[style];
-		}
-		return !value
-				? undefined
-				: value === 'none'
-					? null
-					: value;
-	}
-
-	function applyAttributes(item, node, isRoot) {
-		var styles = {
-			node: DomElement.getStyles(node) || {},
-			parent: !isRoot && DomElement.getStyles(node.parentNode) || {}
-		};
-		Base.each(attributes, function(apply, name) {
-			var value = getAttribute(node, name, styles);
-			if (value !== undefined)
-				item = Base.pick(apply(item, value, name, node, styles), item);
-		});
-		return item;
-	}
-
-	var definitions = {};
-	function getDefinition(value) {
-		var match = value && value.match(/\((?:#|)([^)']+)/);
-		return match && definitions[match[1]];
-	}
-
-	function importSVG(source, isRoot, options) {
-		if (!source)
-			return null;
-		if (!options) {
-			options = {};
-		} else if (typeof options === 'function') {
-			options = { onLoad: options };
-		}
-
-		var node = source,
-			scope = paper;
-
-		function onLoadCallback(svg) {
-			paper = scope;
-			var item = importSVG(svg, isRoot, options),
-				onLoad = options.onLoad,
-				view = scope.project && scope.project.view;
-			if (onLoad)
-				onLoad.call(this, item);
-			view.draw(true);
-		}
-
-		if (isRoot) {
-			if (typeof source === 'string' && !/^.*</.test(source)) {
-				node = document.getElementById(source);
-				if (node) {
-					source = null;
-				} else {
-					return Http.request('get', source, onLoadCallback);
-				}
-			} else if (typeof File !== 'undefined' && source instanceof File) {
-				var reader = new FileReader();
-				reader.onload = function() {
-					onLoadCallback(reader.result);
-				};
-				return reader.readAsText(source);
-			}
-		}
-
-		if (typeof source === 'string')
-			node = new DOMParser().parseFromString(source, 'image/svg+xml');
-		if (!node.nodeName)
-			throw new Error('Unsupported SVG source: ' + source);
-		var type = node.nodeName.toLowerCase(),
-			importer = importers[type],
-			item = importer && importer(node, type, isRoot, options) || null,
-			data = node.getAttribute && node.getAttribute('data-paper-data');
-		if (item) {
-			if (!(item instanceof Group))
-				item = applyAttributes(item, node, isRoot);
-			if (options.expandShapes && item instanceof Shape) {
-				item.remove();
-				item = item.toPath();
-			}
-			if (data)
-				item._data = JSON.parse(data);
-		}
-		if (isRoot)
-			definitions = {};
-		return item;
-	}
-
-	Item.inject({
-		importSVG: function(node, options) {
-			return this.addChild(importSVG(node, true, options));
-		}
-	});
-
-	Project.inject({
-		importSVG: function(node, options) {
-			this.activate();
-			return importSVG(node, true, options);
-		}
-	});
-};
-
-paper = new (PaperScope.inject(new Base(Base.exports, {
-	enumerable: true,
-	Base: Base,
-	Numerical: Numerical,
-	DomElement: DomElement,
-	DomEvent: DomEvent,
-	Http: Http,
-	Key: Key
-})))();
-
-if (typeof define === 'function' && define.amd)
-	define('paper', paper);
-
-return paper;
-};
-
-paper.PaperScope.prototype.PaperScript = (function(root) {
-	var Base = paper.Base,
-		PaperScope = paper.PaperScope,
-		PaperScript,
-		exports, define,
-		scope = this;
-!function(e,r){return"object"==typeof exports&&"object"==typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):(r(e.acorn||(e.acorn={})),void 0)}(this,function(e){"use strict";function r(e){fr=e||{};for(var r in hr)Object.prototype.hasOwnProperty.call(fr,r)||(fr[r]=hr[r]);mr=fr.sourceFile||null}function t(e,r){var t=vr(pr,e);r+=" ("+t.line+":"+t.column+")";var n=new SyntaxError(r);throw n.pos=e,n.loc=t,n.raisedAt=br,n}function n(e){function r(e){if(1==e.length)return t+="return str === "+JSON.stringify(e[0])+";";t+="switch(str){";for(var r=0;r<e.length;++r)t+="case "+JSON.stringify(e[r])+":";t+="return true}return false;"}e=e.split(" ");var t="",n=[];e:for(var a=0;a<e.length;++a){for(var o=0;o<n.length;++o)if(n[o][0].length==e[a].length){n[o].push(e[a]);continue e}n.push([e[a]])}if(n.length>3){n.sort(function(e,r){return r.length-e.length}),t+="switch(str.length){";for(var a=0;a<n.length;++a){var i=n[a];t+="case "+i[0].length+":",r(i)}t+="}"}else r(e);return new Function("str",t)}function a(){this.line=Ar,this.column=br-Sr}function o(){Ar=1,br=Sr=0,Er=!0,u()}function i(e,r){gr=br,fr.locations&&(kr=new a),wr=e,u(),Cr=r,Er=e.beforeExpr}function s(){var e=fr.onComment&&fr.locations&&new a,r=br,n=pr.indexOf("*/",br+=2);if(-1===n&&t(br-2,"Unterminated comment"),br=n+2,fr.locations){Kt.lastIndex=r;for(var o;(o=Kt.exec(pr))&&o.index<br;)++Ar,Sr=o.index+o[0].length}fr.onComment&&fr.onComment(!0,pr.slice(r+2,n),r,br,e,fr.locations&&new a)}function c(){for(var e=br,r=fr.onComment&&fr.locations&&new a,t=pr.charCodeAt(br+=2);dr>br&&10!==t&&13!==t&&8232!==t&&8329!==t;)++br,t=pr.charCodeAt(br);fr.onComment&&fr.onComment(!1,pr.slice(e+2,br),e,br,r,fr.locations&&new a)}function u(){for(;dr>br;){var e=pr.charCodeAt(br);if(32===e)++br;else if(13===e){++br;var r=pr.charCodeAt(br);10===r&&++br,fr.locations&&(++Ar,Sr=br)}else if(10===e)++br,++Ar,Sr=br;else if(14>e&&e>8)++br;else if(47===e){var r=pr.charCodeAt(br+1);if(42===r)s();else{if(47!==r)break;c()}}else if(160===e)++br;else{if(!(e>=5760&&Jt.test(String.fromCharCode(e))))break;++br}}}function l(){var e=pr.charCodeAt(br+1);return e>=48&&57>=e?E(!0):(++br,i(xt))}function f(){var e=pr.charCodeAt(br+1);return Er?(++br,k()):61===e?x(Et,2):x(wt,1)}function p(){var e=pr.charCodeAt(br+1);return 61===e?x(Et,2):x(Ft,1)}function d(e){var r=pr.charCodeAt(br+1);return r===e?x(124===e?Lt:Ut,2):61===r?x(Et,2):x(124===e?Rt:Vt,1)}function m(){var e=pr.charCodeAt(br+1);return 61===e?x(Et,2):x(Tt,1)}function h(e){var r=pr.charCodeAt(br+1);return r===e?x(St,2):61===r?x(Et,2):x(At,1)}function v(e){var r=pr.charCodeAt(br+1),t=1;return r===e?(t=62===e&&62===pr.charCodeAt(br+2)?3:2,61===pr.charCodeAt(br+t)?x(Et,t+1):x(jt,t)):(61===r&&(t=61===pr.charCodeAt(br+2)?3:2),x(Ot,t))}function b(e){var r=pr.charCodeAt(br+1);return 61===r?x(qt,61===pr.charCodeAt(br+2)?3:2):x(61===e?Ct:It,1)}function y(e){switch(e){case 46:return l();case 40:return++br,i(ht);case 41:return++br,i(vt);case 59:return++br,i(yt);case 44:return++br,i(bt);case 91:return++br,i(ft);case 93:return++br,i(pt);case 123:return++br,i(dt);case 125:return++br,i(mt);case 58:return++br,i(gt);case 63:return++br,i(kt);case 48:var r=pr.charCodeAt(br+1);if(120===r||88===r)return C();case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return E(!1);case 34:case 39:return A(e);case 47:return f(e);case 37:case 42:return p();case 124:case 38:return d(e);case 94:return m();case 43:case 45:return h(e);case 60:case 62:return v(e);case 61:case 33:return b(e);case 126:return x(It,1)}return!1}function g(e){if(e?br=yr+1:yr=br,fr.locations&&(xr=new a),e)return k();if(br>=dr)return i(Br);var r=pr.charCodeAt(br);if(Qt(r)||92===r)return L();var n=y(r);if(n===!1){var o=String.fromCharCode(r);if("\\"===o||$t.test(o))return L();t(br,"Unexpected character '"+o+"'")}return n}function x(e,r){var t=pr.slice(br,br+r);br+=r,i(e,t)}function k(){for(var e,r,n="",a=br;;){br>=dr&&t(a,"Unterminated regular expression");var o=pr.charAt(br);if(Gt.test(o)&&t(a,"Unterminated regular expression"),e)e=!1;else{if("["===o)r=!0;else if("]"===o&&r)r=!1;else if("/"===o&&!r)break;e="\\"===o}++br}var n=pr.slice(a,br);++br;var s=I();return s&&!/^[gmsiy]*$/.test(s)&&t(a,"Invalid regexp flag"),i(jr,new RegExp(n,s))}function w(e,r){for(var t=br,n=0,a=0,o=null==r?1/0:r;o>a;++a){var i,s=pr.charCodeAt(br);if(i=s>=97?s-97+10:s>=65?s-65+10:s>=48&&57>=s?s-48:1/0,i>=e)break;++br,n=n*e+i}return br===t||null!=r&&br-t!==r?null:n}function C(){br+=2;var e=w(16);return null==e&&t(yr+2,"Expected hexadecimal number"),Qt(pr.charCodeAt(br))&&t(br,"Identifier directly after number"),i(Or,e)}function E(e){var r=br,n=!1,a=48===pr.charCodeAt(br);e||null!==w(10)||t(r,"Invalid number"),46===pr.charCodeAt(br)&&(++br,w(10),n=!0);var o=pr.charCodeAt(br);(69===o||101===o)&&(o=pr.charCodeAt(++br),(43===o||45===o)&&++br,null===w(10)&&t(r,"Invalid number"),n=!0),Qt(pr.charCodeAt(br))&&t(br,"Identifier directly after number");var s,c=pr.slice(r,br);return n?s=parseFloat(c):a&&1!==c.length?/[89]/.test(c)||Vr?t(r,"Invalid number"):s=parseInt(c,8):s=parseInt(c,10),i(Or,s)}function A(e){br++;for(var r="";;){br>=dr&&t(yr,"Unterminated string constant");var n=pr.charCodeAt(br);if(n===e)return++br,i(Fr,r);if(92===n){n=pr.charCodeAt(++br);var a=/^[0-7]+/.exec(pr.slice(br,br+3));for(a&&(a=a[0]);a&&parseInt(a,8)>255;)a=a.slice(0,a.length-1);if("0"===a&&(a=null),++br,a)Vr&&t(br-2,"Octal literal in strict mode"),r+=String.fromCharCode(parseInt(a,8)),br+=a.length-1;else switch(n){case 110:r+="\n";break;case 114:r+="\r";break;case 120:r+=String.fromCharCode(S(2));break;case 117:r+=String.fromCharCode(S(4));break;case 85:r+=String.fromCharCode(S(8));break;case 116:r+="	";break;case 98:r+="\b";break;case 118:r+="";break;case 102:r+="\f";break;case 48:r+="\0";break;case 13:10===pr.charCodeAt(br)&&++br;case 10:fr.locations&&(Sr=br,++Ar);break;default:r+=String.fromCharCode(n)}}else(13===n||10===n||8232===n||8329===n)&&t(yr,"Unterminated string constant"),r+=String.fromCharCode(n),++br}}function S(e){var r=w(16,e);return null===r&&t(yr,"Bad character escape sequence"),r}function I(){Bt=!1;for(var e,r=!0,n=br;;){var a=pr.charCodeAt(br);if(Yt(a))Bt&&(e+=pr.charAt(br)),++br;else{if(92!==a)break;Bt||(e=pr.slice(n,br)),Bt=!0,117!=pr.charCodeAt(++br)&&t(br,"Expecting Unicode escape sequence \\uXXXX"),++br;var o=S(4),i=String.fromCharCode(o);i||t(br-1,"Invalid Unicode escape"),(r?Qt(o):Yt(o))||t(br-4,"Invalid Unicode escape"),e+=i}r=!1}return Bt?e:pr.slice(n,br)}function L(){var e=I(),r=Dr;return Bt||(Wt(e)?r=lt[e]:(fr.forbidReserved&&(3===fr.ecmaVersion?Mt:zt)(e)||Vr&&Xt(e))&&t(yr,"The keyword '"+e+"' is reserved")),i(r,e)}function U(){Ir=yr,Lr=gr,Ur=kr,g()}function R(e){for(Vr=e,br=Lr;Sr>br;)Sr=pr.lastIndexOf("\n",Sr-2)+1,--Ar;u(),g()}function T(){this.type=null,this.start=yr,this.end=null}function V(){this.start=xr,this.end=null,null!==mr&&(this.source=mr)}function q(){var e=new T;return fr.locations&&(e.loc=new V),fr.ranges&&(e.range=[yr,0]),e}function O(e){var r=new T;return r.start=e.start,fr.locations&&(r.loc=new V,r.loc.start=e.loc.start),fr.ranges&&(r.range=[e.range[0],0]),r}function j(e,r){return e.type=r,e.end=Lr,fr.locations&&(e.loc.end=Ur),fr.ranges&&(e.range[1]=Lr),e}function F(e){return fr.ecmaVersion>=5&&"ExpressionStatement"===e.type&&"Literal"===e.expression.type&&"use strict"===e.expression.value}function D(e){return wr===e?(U(),!0):void 0}function B(){return!fr.strictSemicolons&&(wr===Br||wr===mt||Gt.test(pr.slice(Lr,yr)))}function M(){D(yt)||B()||X()}function z(e){wr===e?U():X()}function X(){t(yr,"Unexpected token")}function N(e){"Identifier"!==e.type&&"MemberExpression"!==e.type&&t(e.start,"Assigning to rvalue"),Vr&&"Identifier"===e.type&&Nt(e.name)&&t(e.start,"Assigning to "+e.name+" in strict mode")}function W(e){Ir=Lr=br,fr.locations&&(Ur=new a),Rr=Vr=null,Tr=[],g();var r=e||q(),t=!0;for(e||(r.body=[]);wr!==Br;){var n=J();r.body.push(n),t&&F(n)&&R(!0),t=!1}return j(r,"Program")}function J(){wr===wt&&g(!0);var e=wr,r=q();switch(e){case Mr:case Nr:U();var n=e===Mr;D(yt)||B()?r.label=null:wr!==Dr?X():(r.label=lr(),M());for(var a=0;a<Tr.length;++a){var o=Tr[a];if(null==r.label||o.name===r.label.name){if(null!=o.kind&&(n||"loop"===o.kind))break;if(r.label&&n)break}}return a===Tr.length&&t(r.start,"Unsyntactic "+e.keyword),j(r,n?"BreakStatement":"ContinueStatement");case Wr:return U(),M(),j(r,"DebuggerStatement");case Pr:return U(),Tr.push(Zt),r.body=J(),Tr.pop(),z(tt),r.test=P(),M(),j(r,"DoWhileStatement");case _r:if(U(),Tr.push(Zt),z(ht),wr===yt)return $(r,null);if(wr===rt){var i=q();return U(),G(i,!0),1===i.declarations.length&&D(ut)?_(r,i):$(r,i)}var i=K(!1,!0);return D(ut)?(N(i),_(r,i)):$(r,i);case Gr:return U(),cr(r,!0);case Kr:return U(),r.test=P(),r.consequent=J(),r.alternate=D(Hr)?J():null,j(r,"IfStatement");case Qr:return Rr||t(yr,"'return' outside of function"),U(),D(yt)||B()?r.argument=null:(r.argument=K(),M()),j(r,"ReturnStatement");case Yr:U(),r.discriminant=P(),r.cases=[],z(dt),Tr.push(en);for(var s,c;wr!=mt;)if(wr===zr||wr===Jr){var u=wr===zr;s&&j(s,"SwitchCase"),r.cases.push(s=q()),s.consequent=[],U(),u?s.test=K():(c&&t(Ir,"Multiple default clauses"),c=!0,s.test=null),z(gt)}else s||X(),s.consequent.push(J());return s&&j(s,"SwitchCase"),U(),Tr.pop(),j(r,"SwitchStatement");case Zr:return U(),Gt.test(pr.slice(Lr,yr))&&t(Lr,"Illegal newline after throw"),r.argument=K(),M(),j(r,"ThrowStatement");case et:if(U(),r.block=H(),r.handler=null,wr===Xr){var l=q();U(),z(ht),l.param=lr(),Vr&&Nt(l.param.name)&&t(l.param.start,"Binding "+l.param.name+" in strict mode"),z(vt),l.guard=null,l.body=H(),r.handler=j(l,"CatchClause")}return r.guardedHandlers=qr,r.finalizer=D($r)?H():null,r.handler||r.finalizer||t(r.start,"Missing catch or finally clause"),j(r,"TryStatement");case rt:return U(),r=G(r),M(),r;case tt:return U(),r.test=P(),Tr.push(Zt),r.body=J(),Tr.pop(),j(r,"WhileStatement");case nt:return Vr&&t(yr,"'with' in strict mode"),U(),r.object=P(),r.body=J(),j(r,"WithStatement");case dt:return H();case yt:return U(),j(r,"EmptyStatement");default:var f=Cr,p=K();if(e===Dr&&"Identifier"===p.type&&D(gt)){for(var a=0;a<Tr.length;++a)Tr[a].name===f&&t(p.start,"Label '"+f+"' is already declared");var d=wr.isLoop?"loop":wr===Yr?"switch":null;return Tr.push({name:f,kind:d}),r.body=J(),Tr.pop(),r.label=p,j(r,"LabeledStatement")}return r.expression=p,M(),j(r,"ExpressionStatement")}}function P(){z(ht);var e=K();return z(vt),e}function H(e){var r,t=q(),n=!0,a=!1;for(t.body=[],z(dt);!D(mt);){var o=J();t.body.push(o),n&&e&&F(o)&&(r=a,R(a=!0)),n=!1}return a&&!r&&R(!1),j(t,"BlockStatement")}function $(e,r){return e.init=r,z(yt),e.test=wr===yt?null:K(),z(yt),e.update=wr===vt?null:K(),z(vt),e.body=J(),Tr.pop(),j(e,"ForStatement")}function _(e,r){return e.left=r,e.right=K(),z(vt),e.body=J(),Tr.pop(),j(e,"ForInStatement")}function G(e,r){for(e.declarations=[],e.kind="var";;){var n=q();if(n.id=lr(),Vr&&Nt(n.id.name)&&t(n.id.start,"Binding "+n.id.name+" in strict mode"),n.init=D(Ct)?K(!0,r):null,e.declarations.push(j(n,"VariableDeclarator")),!D(bt))break}return j(e,"VariableDeclaration")}function K(e,r){var t=Q(r);if(!e&&wr===bt){var n=O(t);for(n.expressions=[t];D(bt);)n.expressions.push(Q(r));return j(n,"SequenceExpression")}return t}function Q(e){var r=Y(e);if(wr.isAssign){var t=O(r);return t.operator=Cr,t.left=r,U(),t.right=Q(e),N(r),j(t,"AssignmentExpression")}return r}function Y(e){var r=Z(e);if(D(kt)){var t=O(r);return t.test=r,t.consequent=K(!0),z(gt),t.alternate=K(!0,e),j(t,"ConditionalExpression")}return r}function Z(e){return er(rr(),-1,e)}function er(e,r,t){var n=wr.binop;if(null!=n&&(!t||wr!==ut)&&n>r){var a=O(e);a.left=e,a.operator=Cr,U(),a.right=er(rr(),n,t);var a=j(a,/&&|\|\|/.test(a.operator)?"LogicalExpression":"BinaryExpression");return er(a,r,t)}return e}function rr(){if(wr.prefix){var e=q(),r=wr.isUpdate;return e.operator=Cr,e.prefix=!0,U(),e.argument=rr(),r?N(e.argument):Vr&&"delete"===e.operator&&"Identifier"===e.argument.type&&t(e.start,"Deleting local variable in strict mode"),j(e,r?"UpdateExpression":"UnaryExpression")}for(var n=tr();wr.postfix&&!B();){var e=O(n);e.operator=Cr,e.prefix=!1,e.argument=n,N(n),U(),n=j(e,"UpdateExpression")}return n}function tr(){return nr(ar())}function nr(e,r){if(D(xt)){var t=O(e);return t.object=e,t.property=lr(!0),t.computed=!1,nr(j(t,"MemberExpression"),r)}if(D(ft)){var t=O(e);return t.object=e,t.property=K(),t.computed=!0,z(pt),nr(j(t,"MemberExpression"),r)}if(!r&&D(ht)){var t=O(e);return t.callee=e,t.arguments=ur(vt,!1),nr(j(t,"CallExpression"),r)}return e}function ar(){switch(wr){case ot:var e=q();return U(),j(e,"ThisExpression");case Dr:return lr();case Or:case Fr:case jr:var e=q();return e.value=Cr,e.raw=pr.slice(yr,gr),U(),j(e,"Literal");case it:case st:case ct:var e=q();return e.value=wr.atomValue,e.raw=wr.keyword,U(),j(e,"Literal");case ht:var r=xr,t=yr;U();var n=K();return n.start=t,n.end=gr,fr.locations&&(n.loc.start=r,n.loc.end=kr),fr.ranges&&(n.range=[t,gr]),z(vt),n;case ft:var e=q();return U(),e.elements=ur(pt,!0,!0),j(e,"ArrayExpression");case dt:return ir();case Gr:var e=q();return U(),cr(e,!1);case at:return or();default:X()}}function or(){var e=q();return U(),e.callee=nr(ar(),!0),e.arguments=D(ht)?ur(vt,!1):qr,j(e,"NewExpression")}function ir(){var e=q(),r=!0,n=!1;for(e.properties=[],U();!D(mt);){if(r)r=!1;else if(z(bt),fr.allowTrailingCommas&&D(mt))break;var a,o={key:sr()},i=!1;if(D(gt)?(o.value=K(!0),a=o.kind="init"):fr.ecmaVersion>=5&&"Identifier"===o.key.type&&("get"===o.key.name||"set"===o.key.name)?(i=n=!0,a=o.kind=o.key.name,o.key=sr(),wr!==ht&&X(),o.value=cr(q(),!1)):X(),"Identifier"===o.key.type&&(Vr||n))for(var s=0;s<e.properties.length;++s){var c=e.properties[s];if(c.key.name===o.key.name){var u=a==c.kind||i&&"init"===c.kind||"init"===a&&("get"===c.kind||"set"===c.kind);u&&!Vr&&"init"===a&&"init"===c.kind&&(u=!1),u&&t(o.key.start,"Redefinition of property")}}e.properties.push(o)}return j(e,"ObjectExpression")}function sr(){return wr===Or||wr===Fr?ar():lr(!0)}function cr(e,r){wr===Dr?e.id=lr():r?X():e.id=null,e.params=[];var n=!0;for(z(ht);!D(vt);)n?n=!1:z(bt),e.params.push(lr());var a=Rr,o=Tr;if(Rr=!0,Tr=[],e.body=H(!0),Rr=a,Tr=o,Vr||e.body.body.length&&F(e.body.body[0]))for(var i=e.id?-1:0;i<e.params.length;++i){var s=0>i?e.id:e.params[i];if((Xt(s.name)||Nt(s.name))&&t(s.start,"Defining '"+s.name+"' in strict mode"),i>=0)for(var c=0;i>c;++c)s.name===e.params[c].name&&t(s.start,"Argument name clash in strict mode")}return j(e,r?"FunctionDeclaration":"FunctionExpression")}function ur(e,r,t){for(var n=[],a=!0;!D(e);){if(a)a=!1;else if(z(bt),r&&fr.allowTrailingCommas&&D(e))break;t&&wr===bt?n.push(null):n.push(K(!0))}return n}function lr(e){var r=q();return r.name=wr===Dr?Cr:e&&!fr.forbidReserved&&wr.keyword||X(),U(),j(r,"Identifier")}e.version="0.3.2";var fr,pr,dr,mr;e.parse=function(e,t){return pr=String(e),dr=pr.length,r(t),o(),W(fr.program)};var hr=e.defaultOptions={ecmaVersion:5,strictSemicolons:!1,allowTrailingCommas:!0,forbidReserved:!1,locations:!1,onComment:null,ranges:!1,program:null,sourceFile:null},vr=e.getLineInfo=function(e,r){for(var t=1,n=0;;){Kt.lastIndex=n;var a=Kt.exec(e);if(!(a&&a.index<r))break;++t,n=a.index+a[0].length}return{line:t,column:r-n}};e.tokenize=function(e,t){function n(e){return g(e),a.start=yr,a.end=gr,a.startLoc=xr,a.endLoc=kr,a.type=wr,a.value=Cr,a}pr=String(e),dr=pr.length,r(t),o();var a={};return n.jumpTo=function(e,r){if(br=e,fr.locations){Ar=1,Sr=Kt.lastIndex=0;for(var t;(t=Kt.exec(pr))&&t.index<e;)++Ar,Sr=t.index+t[0].length}Er=r,u()},n};var br,yr,gr,xr,kr,wr,Cr,Er,Ar,Sr,Ir,Lr,Ur,Rr,Tr,Vr,qr=[],Or={type:"num"},jr={type:"regexp"},Fr={type:"string"},Dr={type:"name"},Br={type:"eof"},Mr={keyword:"break"},zr={keyword:"case",beforeExpr:!0},Xr={keyword:"catch"},Nr={keyword:"continue"},Wr={keyword:"debugger"},Jr={keyword:"default"},Pr={keyword:"do",isLoop:!0},Hr={keyword:"else",beforeExpr:!0},$r={keyword:"finally"},_r={keyword:"for",isLoop:!0},Gr={keyword:"function"},Kr={keyword:"if"},Qr={keyword:"return",beforeExpr:!0},Yr={keyword:"switch"},Zr={keyword:"throw",beforeExpr:!0},et={keyword:"try"},rt={keyword:"var"},tt={keyword:"while",isLoop:!0},nt={keyword:"with"},at={keyword:"new",beforeExpr:!0},ot={keyword:"this"},it={keyword:"null",atomValue:null},st={keyword:"true",atomValue:!0},ct={keyword:"false",atomValue:!1},ut={keyword:"in",binop:7,beforeExpr:!0},lt={"break":Mr,"case":zr,"catch":Xr,"continue":Nr,"debugger":Wr,"default":Jr,"do":Pr,"else":Hr,"finally":$r,"for":_r,"function":Gr,"if":Kr,"return":Qr,"switch":Yr,"throw":Zr,"try":et,"var":rt,"while":tt,"with":nt,"null":it,"true":st,"false":ct,"new":at,"in":ut,"instanceof":{keyword:"instanceof",binop:7,beforeExpr:!0},"this":ot,"typeof":{keyword:"typeof",prefix:!0,beforeExpr:!0},"void":{keyword:"void",prefix:!0,beforeExpr:!0},"delete":{keyword:"delete",prefix:!0,beforeExpr:!0}},ft={type:"[",beforeExpr:!0},pt={type:"]"},dt={type:"{",beforeExpr:!0},mt={type:"}"},ht={type:"(",beforeExpr:!0},vt={type:")"},bt={type:",",beforeExpr:!0},yt={type:";",beforeExpr:!0},gt={type:":",beforeExpr:!0},xt={type:"."},kt={type:"?",beforeExpr:!0},wt={binop:10,beforeExpr:!0},Ct={isAssign:!0,beforeExpr:!0},Et={isAssign:!0,beforeExpr:!0},At={binop:9,prefix:!0,beforeExpr:!0},St={postfix:!0,prefix:!0,isUpdate:!0},It={prefix:!0,beforeExpr:!0},Lt={binop:1,beforeExpr:!0},Ut={binop:2,beforeExpr:!0},Rt={binop:3,beforeExpr:!0},Tt={binop:4,beforeExpr:!0},Vt={binop:5,beforeExpr:!0},qt={binop:6,beforeExpr:!0},Ot={binop:7,beforeExpr:!0},jt={binop:8,beforeExpr:!0},Ft={binop:10,beforeExpr:!0};e.tokTypes={bracketL:ft,bracketR:pt,braceL:dt,braceR:mt,parenL:ht,parenR:vt,comma:bt,semi:yt,colon:gt,dot:xt,question:kt,slash:wt,eq:Ct,name:Dr,eof:Br,num:Or,regexp:jr,string:Fr};for(var Dt in lt)e.tokTypes["_"+Dt]=lt[Dt];var Bt,Mt=n("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile"),zt=n("class enum extends super const export import"),Xt=n("implements interface let package private protected public static yield"),Nt=n("eval arguments"),Wt=n("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this"),Jt=/[\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/,Pt="\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc",Ht="\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5f-\u0b60\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2-\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d46-\u0d48\u0d57\u0d62-\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e34-\u0e3a\u0e40-\u0e45\u0e50-\u0e59\u0eb4-\u0eb9\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f41-\u0f47\u0f71-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1029\u1040-\u1049\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u170e-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17b2\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1920-\u192b\u1930-\u193b\u1951-\u196d\u19b0-\u19c0\u19c8-\u19c9\u19d0-\u19d9\u1a00-\u1a15\u1a20-\u1a53\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b46-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1bb0-\u1bb9\u1be6-\u1bf3\u1c00-\u1c22\u1c40-\u1c49\u1c5b-\u1c7d\u1cd0-\u1cd2\u1d00-\u1dbe\u1e01-\u1f15\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2d81-\u2d96\u2de0-\u2dff\u3021-\u3028\u3099\u309a\ua640-\ua66d\ua674-\ua67d\ua69f\ua6f0-\ua6f1\ua7f8-\ua800\ua806\ua80b\ua823-\ua827\ua880-\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8f3-\ua8f7\ua900-\ua909\ua926-\ua92d\ua930-\ua945\ua980-\ua983\ua9b3-\ua9c0\uaa00-\uaa27\uaa40-\uaa41\uaa4c-\uaa4d\uaa50-\uaa59\uaa7b\uaae0-\uaae9\uaaf2-\uaaf3\uabc0-\uabe1\uabec\uabed\uabf0-\uabf9\ufb20-\ufb28\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f",$t=new RegExp("["+Pt+"]"),_t=new RegExp("["+Pt+Ht+"]"),Gt=/[\n\r\u2028\u2029]/,Kt=/\r\n|[\n\r\u2028\u2029]/g,Qt=e.isIdentifierStart=function(e){return 65>e?36===e:91>e?!0:97>e?95===e:123>e?!0:e>=170&&$t.test(String.fromCharCode(e))},Yt=e.isIdentifierChar=function(e){return 48>e?36===e:58>e?!0:65>e?!1:91>e?!0:97>e?95===e:123>e?!0:e>=170&&_t.test(String.fromCharCode(e))},Zt={kind:"loop"},en={kind:"switch"}});
-
-	var binaryOperators = {
-		'+': '_add',
-		'-': '_subtract',
-		'*': '_multiply',
-		'/': '_divide',
-		'%': '_modulo',
-		'==': 'equals',
-		'!=': 'equals'
-	};
-
-	var unaryOperators = {
-		'-': '_negate',
-		'+': null
-	};
-
-	var fields = Base.each(
-		['add', 'subtract', 'multiply', 'divide', 'modulo', 'negate'],
-		function(name) {
-			this['_' + name] = '#' + name;
-		}, 
-		{}
-	);
-	paper.Point.inject(fields);
-	paper.Size.inject(fields);
-	paper.Color.inject(fields);
-
-	function _$_(left, operator, right) {
-		var handler = binaryOperators[operator];
-		if (left && left[handler]) {
-			var res = left[handler](right);
-			return operator === '!=' ? !res : res;
-		}
-		switch (operator) {
-		case '+': return left + right;
-		case '-': return left - right;
-		case '*': return left * right;
-		case '/': return left / right;
-		case '%': return left % right;
-		case '==': return left == right;
-		case '!=': return left != right;
-		}
-	}
-
-	function $_(operator, value) {
-		var handler = unaryOperators[operator];
-		if (handler && value && value[handler])
-			return value[handler]();
-		switch (operator) {
-		case '+': return +value;
-		case '-': return -value;
-		}
-	}
-
-	function compile(code) {
-
-		var insertions = [];
-
-		function getOffset(offset) {
-			for (var i = 0, l = insertions.length; i < l; i++) {
-				var insertion = insertions[i];
-				if (insertion[0] >= offset)
-					break;
-				offset += insertion[1];
-			}
-			return offset;
-		}
-
-		function getCode(node) {
-			return code.substring(getOffset(node.range[0]),
-					getOffset(node.range[1]));
-		}
-
-		function replaceCode(node, str) {
-			var start = getOffset(node.range[0]),
-				end = getOffset(node.range[1]);
-			var insert = 0;
-			for (var i = insertions.length - 1; i >= 0; i--) {
-				if (start > insertions[i][0]) {
-					insert = i + 1;
-					break;
-				}
-			}
-			insertions.splice(insert, 0, [start, str.length - end + start]);
-			code = code.substring(0, start) + str + code.substring(end);
-		}
-
-		function walkAST(node, parent) {
-			if (!node)
-				return;
-			for (var key in node) {
-				if (key === 'range')
-					continue;
-				var value = node[key];
-				if (Array.isArray(value)) {
-					for (var i = 0, l = value.length; i < l; i++)
-						walkAST(value[i], node);
-				} else if (value && typeof value === 'object') {
-					walkAST(value, node);
-				}
-			}
-			switch (node && node.type) {
-			case 'BinaryExpression':
-				if (node.operator in binaryOperators
-						&& node.left.type !== 'Literal') {
-					var left = getCode(node.left),
-						right = getCode(node.right);
-					replaceCode(node, '_$_(' + left + ', "' + node.operator
-							+ '", ' + right + ')');
-				}
-				break;
-			case 'AssignmentExpression':
-				if (/^.=$/.test(node.operator)
-						&& node.left.type !== 'Literal') {
-					var left = getCode(node.left),
-						right = getCode(node.right);
-					replaceCode(node, left + ' = _$_(' + left + ', "'
-							+ node.operator[0] + '", ' + right + ')');
-				}
-				break;
-			case 'UpdateExpression':
-				if (!node.prefix && !(parent && (
-						parent.type === 'BinaryExpression'
-							&& /^[=!<>]/.test(parent.operator)
-						|| parent.type === 'MemberExpression'
-							&& parent.computed))) {
-					var arg = getCode(node.argument);
-					replaceCode(node, arg + ' = _$_(' + arg + ', "'
-							+ node.operator[0] + '", 1)');
-				}
-				break;
-			case 'UnaryExpression':
-				if (node.operator in unaryOperators
-						&& node.argument.type !== 'Literal') {
-					var arg = getCode(node.argument);
-					replaceCode(node, '$_("' + node.operator + '", '
-							+ arg + ')');
-				}
-				break;
-			}
-		}
-		walkAST(scope.acorn.parse(code, { ranges: true }));
-		return code;
-	}
-
-	function evaluate(code, scope) {
-		paper = scope;
-		var view = scope.project && scope.project.view,
-			res;
-		with (scope) {
-			(function() {
-				var onActivate, onDeactivate, onEditOptions,
-					onMouseDown, onMouseUp, onMouseDrag, onMouseMove,
-					onKeyDown, onKeyUp, onFrame, onResize;
-				code = compile(code);
-				if (root.InstallTrigger) { 
-					var handle = PaperScript.handleException;
-					if (!handle) {
-						handle = PaperScript.handleException = function(e) {
-							throw e.lineNumber >= lineNumber
-									? new Error(e.message, e.fileName,
-										e.lineNumber - lineNumber)
-									: e;
-						}
-						var lineNumber = new Error().lineNumber;
-						lineNumber += (new Error().lineNumber - lineNumber) * 3;
-					}
-					try {
-						res = eval(';' + code);
-					} catch (e) {
-						handle(e);
-					}
-				} else {
-					res = eval(code);
-				}
-				if (/on(?:Key|Mouse)(?:Up|Down|Move|Drag)/.test(code)) {
-					Base.each(paper.Tool.prototype._events, function(key) {
-						var value = eval(key);
-						if (value) {
-							scope.getTool()[key] = value;
-						}
-					});
-				}
-				if (view) {
-					view.setOnResize(onResize);
-					view.fire('resize', {
-						size: view.size,
-						delta: new Point()
-					});
-					if (onFrame)
-						view.setOnFrame(onFrame);
-					view.draw();
-				}
-			}).call(scope);
-		}
-		return res;
-	}
-
-	function load() {
-		Base.each(document.getElementsByTagName('script'), function(script) {
-			if (/^text\/(?:x-|)paperscript$/.test(script.type)
-					&& !script.getAttribute('data-paper-ignore')) {
-				var canvas = PaperScope.getAttribute(script, 'canvas'),
-					scope = PaperScope.get(canvas)
-							|| new PaperScope(script).setup(canvas),
-					src = script.src;
-				if (src) {
-					paper.Http.request('get', src, function(code) {
-						evaluate(code, scope);
-					});
-				} else {
-					evaluate(script.innerHTML, scope);
-				}
-				script.setAttribute('data-paper-ignore', true);
-			}
-		}, this);
-	}
-
-	if (document.readyState === 'complete') {
-		setTimeout(load);
-	} else {
-		paper.DomEvent.add(window, { load: load });
-	}
-
-	return PaperScript = {
-		compile: compile,
-		evaluate: evaluate,
-		load: load,
-		lineNumberBase: 0
-	};
-
-})(this);
--- a/src/hdalab/static/hdalab/lib/renkan/css/renkan.css	Fri Jul 18 13:29:53 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,755 +0,0 @@
-/*! 
- *    _____            _               
- *   |  __ \          | |              
- *   | |__) |___ _ __ | | ____ _ _ __  
- *   |  _  // _ \ '_ \| |/ / _` | '_ \ 
- *   | | \ \  __/ | | |   < (_| | | | |
- *   |_|  \_\___|_| |_|_|\_\__,_|_| |_|
- *
- *  Copyright 2012-2013 Institut de recherche et d'innovation 
- *  contributor(s) : Yves-Marie Haussonne, Raphael Velt, Samuel Huron
- *   
- *  contact@iri.centrepompidou.fr
- *  http://www.iri.centrepompidou.fr 
- *   
- *  This software is a computer program whose purpose is to show and add annotations on a video .
- *  This software is governed by the CeCILL-C license under French law and
- *  abiding by the rules of distribution of free software. You can  use, 
- *  modify and/ or redistribute the software under the terms of the CeCILL-C
- *  license as circulated by CEA, CNRS and INRIA at the following URL
- *  "http://www.cecill.info". 
- *  
- *  The fact that you are presently reading this means that you have had
- *  knowledge of the CeCILL-C license and that you accept its terms.
- */
-/*! renkan - v0.7.10 - Copyright © IRI 2014 */
-
-/* Renkan CSS */
-
-.Rk-Main ul, .Rk-Main li, .Rk-Main h4, .Rk-Main h3, .Rk-Main p {
-    border: 0 none; margin: 0; padding: 0;
-}
-
-.Rk-Main ul, .Rk-Main li {
-    list-style: none;
-}
-
-.Rk-Main input::-moz-focus-inner /*Remove button padding in FF*/
-{ 
-    border: 0;
-    padding: 0;
-}
-
-.Rk-Main table {
-    border-collapse: separate; border-spacing: 0;
-}
-
-.Rk-Main th, .Rk-Main td {
-    vertical-align: top;
-}
-
-.Rk-Main img a {
-    border: none;
-}
-
-.Rk-Main {
-    font-size: 10px; font-family: Arial, Helvetica, sans-serif;
-    background: #ffffff; color: #000000;
-}
-
-.Rk-Main a {
-    color: #6060c0;
-}
-
-.Rk-Main {
-    position: absolute; left: 0; top: 0; right: 0; bottom: 0;
-}
-
-.Rk-Render {
-    position: absolute; top: 0; right: 0; bottom: 0;
-    background: #ffffff;
-}
-
-.Rk-Render-Full {
-    left: 0;
-}
-
-.Rk-Render-Panel {
-    left: 300px;
-}
-
-/* Top Bar */
-
-.Rk-TopBar {
-    position: absolute; left: 0; top: 0; right: 0; height: 35px;
-    background: #333333;
-    background: -moz-linear-gradient(top, #505050 5px, #1e1e1e 30px);
-    background: -webkit-linear-gradient(top, #505050 5px, #1e1e1e 30px);
-    background: -ms-linear-gradient(top, #505050 5px, #1e1e1e 30px);
-    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#505050', endColorstr='#1e1e1e',GradientType=0 );
-}
-
-.Rk-PadTitle {
-    float: left; font-size: 14px; height: 16px; margin: 4px 5px; background: #666666; padding: 4px; border: 1px solid #333333;
-    border-radius: 3px; box-shadow: 0 1px 0 #505050; color: #ffffff; font-weight: bold;
-}
-
-input.Rk-PadTitle {
-    width: 180px;
-}
-
-h2.Rk-PadTitle {
-    min-width: 180px; max-width: 320px; overflow: hidden;
-}
-
-.Rk-Users {
-    float: right; width: 130px; margin: 4px 5px;
-}
-
-.Rk-CurrentUser {
-    font-size: 13px; background: #666666; padding: 4px; border: 1px solid #333333; border-radius: 3px; box-shadow: 0 1px 0 #505050; color: #ffffff;
-}
-
-.Rk-CurrentUser-Color {
-    display: inline-block; width: 12px; height: 12px; border: 1px solid #333333; margin: -2px 2px; position: relative;
-}
-
-.Rk-CurrentUser input {
-    width: 95px; padding: 1px; border: none; border-radius: 2px;
-}
-
-.Rk-UserList {
-    box-shadow: 0 2px 2px #999999;
-    position: relative; z-index: 3; display: none; padding-top: 8px;
-}
-
-.Rk-User {
-    background: #ffffff; padding: 3px; font-size: 12px; border-style: solid solid none; border-color: #cccccc; border-width: 1px;
-}
-
-.Rk-TopBar-Button {
-    float: right; background: url(../img/topbarbuttons.png) no-repeat; height: 35px; cursor: pointer;
-    position: relative;
-}
-
-.Rk-TopBar-Separator {
-    background: #666666;
-    background: -moz-linear-gradient(top, #666666 20%, #333333 80%);
-    background: -webkit-linear-gradient(top, #666666 20%, #333333 80%);
-    background: -ms-linear-gradient(top, #666666 20%, #333333 80%);
-    content: ""; display: block; height: 35px; float: right; width: 1px; border-left: 1px solid #111111;
-    margin: 0 3px;
-}
-
-.Rk-TopBar-Tooltip {
-    position: absolute; top: 31px; left: 50%; margin-left: -60px; width: 120px; z-index: 4; display: none;
-}
-
-.Rk-TopBar-Tooltip-Contents {
-    background: #ffffff;
-    font-size: 13px; font-weight: bold; color: #6060c0; text-align: center; padding: 2px;
-    border-style: none solid solid; border-width: 1px; border-color: #cccccc; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px;
-}
-
-.Rk-TopBar-Tooltip:before {
-    content: "."; display: block; text-indent: -8000px;
-    height: 7px; background: url(../img/tooltiparrow.png) center no-repeat; margin: 0 1px;
-}
-
-.Rk-AddNode-Button {
-    width: 30px; background-position: -2px 0;
-}
-
-.Rk-AddNode-Button:hover {
-    background-position: -2px -35px;
-}
-
-.Rk-FullScreen-Button {
-    width: 30px; background-position: -36px 0;
-}
-
-.Rk-FullScreen-Button:hover {
-    background-position: -36px -35px;
-}
-
-.Rk-AddEdge-Button {
-    width: 30px; background-position: -70px 0;
-}
-
-.Rk-AddEdge-Button:hover {
-    background-position: -70px -35px;
-}
-
-.Rk-Save-Button {
-    width: 30px; background-position: -104px 0;
-}
-
-.Rk-Save-Button.disabled {
-    opacity: .5; cursor: default;
-}
-
-.Rk-Save-Button:hover {
-    background-position: -104px -35px;
-}
-
-.Rk-Save-Button.disabled:hover {
-    opacity: 1; background-position: -104px 0;
-}
-
-.Rk-Save-Button.Rk-Save-ReadOnly, .Rk-Save-Button.Rk-Save-ReadOnly:hover {
-    background-position: -172px -35px;
-}
-
-.Rk-Save-Button.Rk-Save-Online, .Rk-Save-Button.Rk-Save-Online:hover {
-    background-position: -172px 0;
-}
-
-.Rk-Export-Button {
-    width: 30px; background-position: -274px 0;
-}
-
-.Rk-Export-Button.disabled {
-    opacity: .5; cursor: default;
-}
-
-.Rk-Export-Button:hover {
-    background-position: -274px -35px;
-}
-
-.Rk-Export-Button.disabled:hover {
-    opacity: 1; background-position: -274px 0;
-}
-
-.Rk-Bookmarklet-Button {
-    width: 30px; background-position: -138px 0;
-}
-
-.Rk-Bookmarklet-Button.disabled {
-    opacity: .5; cursor: default;
-}
-
-.Rk-Bookmarklet-Button:hover {
-    background-position: -138px -35px;
-}
-
-.Rk-Bookmarklet-Button.disabled:hover {
-    opacity: 1; background-position: -138px 0;
-}
-
-.Rk-Home-Button {
-    width: 30px; background-position: -206px 0;
-}
-
-.Rk-Home-Button:hover {
-    background-position: -206px -35px;
-}
-
-.Rk-Open-Button {
-    width: 30px; background-position: -240px 0;
-}
-
-.Rk-Open-Button:hover {
-    background-position: -240px -35px;
-}
-
-.Rk-GraphSearch-Form {
-    float: right; width: 170px; position: relative;
-}
-
-.Rk-GraphSearch-Form:before, .Rk-GraphSearch-Form:after {
-    position: absolute; display: block; content: "."; text-indent: -9999px;
-}
-
-.Rk-GraphSearch-Form:before {
-    right: 10px; top: 20px; width: 7px; height: 2px; border: none; padding: 0; background: #666666;
-    transform: rotate(40deg); -webkit-transform: rotate(40deg);
-}
-
-.Rk-GraphSearch-Form:after {
-    right: 13px; top: 11px; width: 6px; height: 6px; border-radius: 8px; border: 2px solid #666666;
-}
-
-.Rk-GraphSearch-Field {
-    line-height: 23px; font-size: 14px; height: 23px; padding: 0 5px; border: none; margin: 6px 5px;
-    width: 150px; background: #f0f0f0; box-shadow: 1px 1px 1px #999999 inset; border-radius: 5px;
-    -webkit-appearance: none;
-    -webkit-box-sizing: content-box;
-    -moz-box-sizing: content-box;
-    box-sizing: content-box;
-}
-
-
-/* Canvas */
-
-.Rk-Editing-Space {
-    position: absolute; left: 0; top: 35px; right: 0; bottom: 0; overflow: hidden;
-    background: -moz-radial-gradient( center, circle, #ffffff 40%, #e0e0e0 90%);
-    background: -webkit-radial-gradient( center, circle, #ffffff 40%, #e0e0e0 90%);
-    background: -ms-radial-gradient( center, circle, #ffffff 40%, #e0e0e0 90%);
-}
-
-.Rk-Editing-Space-Full {
-    top: 0;
-}
-
-.Rk-Canvas {
-    position: absolute; left: 0; top: 0; right: 0; bottom: 0; z-index: 2;
-}
-
-/* Node Labels */
-
-.Rk-Highlighted {
-    background: rgba(255,255,0,.5);
-}
-
-.Rk-Labels {
-    position: absolute; left: 0; top: 0; z-index: 1;
-    font-family: "Segoe UI", "Helvetica Neue", Arial, Helvetica, sans-serif;
-}
-
-.Rk-Label {
-    position: absolute; width: 160px; margin-left: -80px; text-align: center; font-size: 13px; line-height: 13px;
-}
-
-.Rk-Edge-Label {
-    font-size: 11px; transform-origin: 50% 0; -moz-transform-origin: 50% 0;
-    -webkit-transform-origin: 50% 0; -ms-transform-origin: 50% 0;
-}
-
-/* Editors */
-
-.Rk-Editor {
-    position: absolute; left: 0; top: 0; z-index: 3;
-}
-
-.Rk-Notifications {
-    position: absolute; right: 15px; top: 15px; width: 200px;
-    padding: 10px; border-radius: 8px; display: none;
-    color: #ffffff; font-size: 13px; text-align: center; font-weight: bold;
-    background: rgba(20,20,20,.7);
-    background: -moz-linear-gradient(top, rgba(40,40,40,.7) 20%, rgba(0,0,0,.7) 80%);
-    background: -webkit-linear-gradient(top, rgba(40,40,40,.7) 20%, rgba(0,0,0,.7) 80%);
-    background: -ms-linear-gradient(top, rgba(40,40,40,.7) 20%, rgba(0,0,0,.7) 80%);
-    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#202020', endColorstr='#000000',GradientType=0 );
-}
-
-.Rk-CloseX {
-    float: right; cursor: pointer;
-}
-
-.Rk-Editor h2 {
-    font-size: 16px; font-weight: bold;
-}
-
-.Rk-Editor p, .Rk-Editor-p {
-    margin: 5px 0; font-size: 12px; clear: both;
-}
-
-.Rk-Editor-Label {
-    float: left; width: 80px;
-}
-
-a.Rk-Edit-Goto {
-    display: block; float: right; width: 18px; height: 17px; margin: 1px 0; border: none; background: url(../img/goto.png);
-}
-
-.Rk-Edit-Title, .Rk-Edit-URI, .Rk-Edit-Image, .Rk-Edit-Image-File, .Rk-Edit-Vocabulary {
-    font-size: 12px; width: 250px;
-}
-
-.Rk-Edit-URI {
-    font-size: 12px; width: 230px;
-}
-
-.Rk-Edit-ImgWrap {
-    text-align: center;
-}
-
-.Rk-Edit-ImgPreview {
-    display: inline-block;
-    border: 1px solid #666; margin: 5px auto;
-    position: relative;
-}
-
-.Rk-Edit-ImgPreview img {
-    display: inline-block; max-width: 253px !important; max-height: 200px !important;
-}
-
-.Rk-Edit-ImgPreview svg {
-    height: 100%;
-    left: 0;
-    position: absolute;
-    top: 0;
-    width: 100%;
-}
-
-.Rk-Editor textarea {
-    width: 250px; height: 120px; resize: none;
-}
-
-.Rk-UserColor {
-    display: inline-block; width: 12px; height: 12px; border: 1px solid #666666; margin: -2px 2px;
-}
-
-.Rk-Edit-Color {
-    display: inline-block; width: 10px; height: 10px; border: 2px solid #333333; margin: -2px 2px; position: relative;
-}
-
-.Rk-Edit-ColorTip {
-    display: block; width: 3px; height: 3px; background: #fff; position: absolute; bottom: 0; right: 0; cursor: pointer;
-}
-
-.Rk-Edit-ColorPicker-Wrapper {
-    display: inline-block; position: relative;
-}
-
-.Rk-Edit-ColorPicker {
-    position: absolute; top: -2px; left: 15px; width: 96px; height: 96px; border: 1px solid #CCCCCC;
-    padding: 5px 4px 4px 5px; background: #ffffff; border-radius: 5px; display: none; z-index: 4;
-}
-
-
-.Rk-CurrentUser .Rk-Edit-ColorPicker {
-    left: -105px; top: 2px;
-}
-
-.Rk-Edit-ColorPicker-Text {
-    color: #303080; font-weight: bold;
-}
-
-.Rk-Edit-ColorPicker li {
-    float: left; width: 11px; height: 11px; margin: 0 1px 1px 0; cursor: pointer;
-}
-
-.Rk-Edit-Size-Up, .Rk-Edit-Size-Down {
-    font-size: 13px; font-weight: bold; padding: 0 4px; background: #ffffff; color: #000000; border: 1px solid #cccccc;
-    text-decoration: none;
-}
-
-.Rk-Edit-Size-Up:hover, .Rk-Edit-Size-Down:hover {
-    background: #666666;
-}
-
-.Rk-Edit-Size-Value {
-    display: inline-block;
-    padding: 0 5px;
-    text-align: center;
-    width: 20px;
-}
-
-.Rk-Edit-Vocabulary-Class {
-    color: #999999; font-style: italic; font-weight: bold;
-}
-
-.Rk-Edit-Vocabulary-Property {
-    padding-left: 20px;
-}
-
-.Rk-Edit-Direction {
-    border: 1px solid #666; padding: 3px 5px; line-height: 20px; border-radius: 3px; background: #f0f0f0; cursor: pointer;
-}
-
-.Rk-Edit-Direction:hover {
-    background: #c0c0c0;
-}
-
-.Rk-Display-Title a {
-    text-decoration: none; color: #000000;
-}
-
-.Rk-Display-Title a:hover {
-    text-decoration: underline;
-}
-
-.Rk-Display-URI {
-    font-style: italic;
-}
-
-.Rk-Display-ImgPreview {
-    margin: 5px auto; display: block; max-width: 255px !important; max-height: 260px !important;
-}
-
-.Rk-Fold-Bins {
-    position: absolute; top: 5px; width: 12px; text-align: center; font-size: 16px; cursor: pointer;
-    line-height: 16px; padding: 4px; color: #ffffff; background: #666666; border-radius: 0 6px 6px 0;
-    font-weight: bold;
-}
-
-.Rk-Fold-Bins:hover {
-    background: #333333;
-}
-
-.Rk-ZoomButtons {
-    position: absolute; left: 0; top: 35px; cursor: pointer;
-}
-
-.Rk-Editing-Space-Full .Rk-ZoomButtons {
-    top: 0;
-}
-
-.Rk-ZoomIn, .Rk-ZoomOut, .Rk-ZoomFit, .Rk-ZoomSave, .Rk-ZoomSetSaved {
-    width: 21px; height: 20px; background: url(../img/zoombuttons.png); margin: 5px;
-}
-.Rk-ZoomIn:hover {
-    background-position: 0 -20px;
-}
-.Rk-ZoomFit {
-    background-position: -42px 0;
-}
-.Rk-ZoomFit:hover {
-    background-position: -42px -20px;
-}
-.Rk-ZoomOut {
-    background-position: -21px 0;
-}
-.Rk-ZoomOut:hover {
-    background-position: -21px -20px;
-}
-.Rk-ZoomSave {
-    background-position: -63px 0;
-}
-.Rk-ZoomSave:hover {
-    background-position: -63px -20px;
-}
-.Rk-ZoomSetSaved {
-    background-position: -84px 0; display: none;
-}
-.Rk-ZoomSetSaved:hover {
-    background-position: -84px -20px;
-}
-
-/* Bins */
-
-.Rk-Bins {
-    background: #ffffff; position: absolute; left: 0; top: 0; width: 299px; bottom: 0;
-    overflow: hidden; border-right: 1px solid #252525;
-}
-
-.Rk-Bins-Title {
-    border: 0 none; width: 290px; height: 15px; line-height: 15px; margin: 0; padding: 15px 0 5px 10px;
-    background: #333333; font-size: 14px; color: #F0F0F0;
-    background: -moz-linear-gradient(top, #1e1e1e 5px, #606060 30px);
-    background: -webkit-linear-gradient(top, #1e1e1e 5px, #606060 30px);
-    background: -ms-linear-gradient(top, #1e1e1e 5px, #606060 30px);
-    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e1e1e', endColorstr='#606060',GradientType=0 );
-}
-
-/* Bin Search Field */
-
-.Rk-Search-Form {
-    padding: 0 10px 8px; height: 27px;
-    background: #606060;
-}
-
-.Rk-Search-Input, .Rk-Search-Select {
-    float: left;  margin: 0;
-}
-
-.Rk-Search-Input {
-    border-top-left-radius: 5px; border-bottom-left-radius: 5px; border: 1px solid #003050;
-    font-size: 13px; background: #ffffff; height: 25px; padding: 0 5px; line-height: 25px;
-    -webkit-appearance: none;
-    -webkit-box-sizing: content-box;
-    -moz-box-sizing: content-box;
-    box-sizing: content-box; 
-}
-
-.Rk-Web-Search-Input {
-     width: 190px;
-}
-
-.Rk-Bins-Search-Input {
-     width: 235px;
-}
-
-.Rk-Search-Select {
-    display: inline-block; position: relative; width: 45px;
-    border-width: 1px; border-color: #003050; border-style: solid none; cursor: pointer;
-    height: 25px; background: #ffffff url(../img/more.png) 30px 10px no-repeat;
-}
-
-.Rk-Search-Select:hover {
-    background-color: #3030FF;
-}
-
-.Rk-Search-Current {
-    width: 40px; height: 20px; margin: 2px; background-repeat: no-repeat;
-}
-
-.Rk-Search-List {
-    width: 180px; margin-left: 15px; font-size: 13px;
-    position: absolute; right: 0; top: 25px; background: #ffffff;
-    box-shadow: 1px 1px 2px #505050; display: none;
-    border: 1px solid #cccccc; z-index: 2;
-}
-
-.Rk-Search-List li {
-    padding: 2px 2px 2px 30px; border-top: 1px solid #cccccc; height: 16px;
-    background-color: #ffffff; background-repeat: no-repeat; cursor: pointer;
-}
-
-.Rk-Search-List li:hover {
-    background-color: #3030ff; color: #ffffff;
-}
-
-.Rk-Search-Submit {
-    border: 1px solid #003050; height: 27px; width: 30px; border-top-right-radius: 5px; border-bottom-right-radius: 5px;
-    background: #333333 center no-repeat url(../img/search.png); cursor: pointer;
-}
-
-.Rk-Search-Submit:hover {
-    background-color: #999999;
-}
-
-/* Individual Bins */
-
-.Rk-Bin-Title {
-    background: #333333;
-    background: -moz-linear-gradient(top, #505050 20%, #1e1e1e 80%);
-    background: -webkit-linear-gradient(top, #505050 20%, #1e1e1e 80%);
-    background: -ms-linear-gradient(top, #505050 20%, #1e1e1e 80%);
-    border-bottom: 1px solid #666666; font-weight: bold;
-    font-size: 14px; padding: 5px; cursor: pointer; color: #f0f0f0; margin: 0; border: 0 none;
-}
-
-.Rk-Bin-Close {
-    float: right; display: block; font-size: 16px; font-weight: bold; margin: 2px 3px 0; color: #f0f0f0; cursor: pointer;
-    text-shadow: -1px -1px 1px #999999, 1px 1px 1px #000000; text-decoration: none;
-}
-
-.Rk-Bin-Close:hover {
-    color: #ffff80;
-}
-
-.Rk-Bin-Title:hover {
-    color: #ffffe0;
-    background: #505050;
-    background: -moz-linear-gradient(top, rgb(20,20,20) 20%, rgb(60,60,60) 80%);
-    background: -webkit-linear-gradient(top, rgb(20,20,20) 20%, rgb(60,60,60) 80%);
-    background: -ms-linear-gradient(top, rgb(20,20,20) 20%, rgb(60,60,60) 80%);
-}
-
-.Rk-Bin-Refresh {
-    width: 18px; height: 17px; background: url(../img/refresh.png); display: block; float: right; margin-top: 4px;
-}
-
-.Rk-Bin-Refresh:hover {
-    background-position: -18px 0;
-}
-
-.Rk-Bin-Count {
-    float: right; background: #c000a0; color: #FFFFFF; text-shadow: 1px 1px 1px #000000; display: none;
-    border-radius: 4px; padding: 1px 3px; font-size: 10px; font-weight: bold; margin-top: 4px;
-}
-
-.Rk-Bin-Title-Icon {
-    float: left; width: 25px; margin: 2px;
-}
-
-.Rk-Bin-Main {
-    overflow: auto;
-    background: #ffffff;
-    background: -moz-linear-gradient(top, #e0e0e0 0, #FFFFFF 2%, #FFFFFF 98%, #e0e0e0 100%);
-    background: -webkit-linear-gradient(top, #e0e0e0 0, #FFFFFF 2%, #FFFFFF 98%, #e0e0e0 100%);
-    background: -ms-linear-gradient(top, #e0e0e0 0, #FFFFFF 2%, #FFFFFF 98%, #e0e0e0 100%);
-}
-
-.Rk-Bin-Item {
-    cursor: move;
-}
-
-.Rk-Bin-Item:hover, .Rk-Bin-Item.hover {
-    background: -moz-linear-gradient(top, rgba(0,0,0,.1) 20%, rgba(128,128,128,.1) 80%);
-    background: -webkit-linear-gradient(top, rgba(0,0,0,.1) 20%, rgba(128,128,128,.1) 80%);
-    background: -ms-linear-gradient(top, rgba(0,0,0,.1) 20%, rgba(128,128,128,.1) 80%);
-    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d0d0d0', endColorstr='#f3f3f3',GradientType=0 );
-}
-
-.Rk-Bin-Item.selected {
-    background: #ffffc0;
-}
-
-.Rk-Bin-Main li {
-    padding: 2px; border-bottom: 1px solid #cccccc;
-    clear: both;
-}
-
-.Rk-Bin-Main h3 {
-    font-size: 14px; font-style: italic; font-weight: bold; text-align: center;
-}
-
-.Rk-Bin-Main h4 {
-    font-size: 12px; font-weight: bold;
-}
-
-.Rk-Bin-Main p {
-    font-size: 11px;
-}
-
-.Rk-Bin-Main h4 a {
-    color: #303080;
-}
-
-.Rk-Bin-Main .searchmatch {
-    background: #ffff80;
-}
-
-.Rk-Wikipedia-Search-Icon {
-    background-image: url(../img/search-logos.png);
-}
-
-.Rk-Wikipedia-Icon {
-    float: left; margin: 3px;
-}
-
-.Rk-Wikipedia-Title-Icon {
-    height: 20px; background: url(../img/search-logos.png);
-}
-
-.Rk-Wikipedia-Lang-en {
-    background-position: 0 -20px;
-}
-
-.Rk-Wikipedia-Lang-fr {
-    background-position: 0 -40px;
-}
-
-.Rk-Wikipedia-Lang-ja {
-    background-position: 0 -60px;
-}
-
-.Rk-Wikipedia-Result {
-    min-height: 51px;
-}
-
-.Rk-Wikipedia-Result p, .Rk-Wikipedia-Result h4 {
-    margin-left: 54px;
-}
-
-.Rk-ResourceList-Image {
-    float: left; max-width: 100px; max-height: 75px; margin-right: 2px;
-}
-
-.Rk-Ldt-Icon, .Rk-Ldt-Title-Icon {
-    background: url(../img/search-logos.png); background-position: 0 -100px; background-repeat: no-repeat;
-}
-
-.Rk-Ldt-Title-Icon {
-    height: 20px; margin-top: 4px;
-}
-
-.Rk-Ldt-Tag-Icon {
-    float: left; margin: 0 2px 0 0;
-}
-
-.Rk-Ldt-Annotation-Icon {
-    float: left; margin: 3px;
-}
-
-.Rk-Clear {
-    clear: both;
-}
-
-h4.Rk-Bin-Loading {
-    margin: 10px; text-align: center; font-size: 20px; color: #999999;
-}
\ No newline at end of file
--- a/src/hdalab/static/hdalab/lib/renkan/css/renkan.min.css	Fri Jul 18 13:29:53 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*! 
- *    _____            _               
- *   |  __ \          | |              
- *   | |__) |___ _ __ | | ____ _ _ __  
- *   |  _  // _ \ '_ \| |/ / _` | '_ \ 
- *   | | \ \  __/ | | |   < (_| | | | |
- *   |_|  \_\___|_| |_|_|\_\__,_|_| |_|
- *
- *  Copyright 2012-2013 Institut de recherche et d'innovation 
- *  contributor(s) : Yves-Marie Haussonne, Raphael Velt, Samuel Huron
- *   
- *  contact@iri.centrepompidou.fr
- *  http://www.iri.centrepompidou.fr 
- *   
- *  This software is a computer program whose purpose is to show and add annotations on a video .
- *  This software is governed by the CeCILL-C license under French law and
- *  abiding by the rules of distribution of free software. You can  use, 
- *  modify and/ or redistribute the software under the terms of the CeCILL-C
- *  license as circulated by CEA, CNRS and INRIA at the following URL
- *  "http://www.cecill.info". 
- *  
- *  The fact that you are presently reading this means that you have had
- *  knowledge of the CeCILL-C license and that you accept its terms.
- */
-/*! renkan - v0.7.10 - Copyright © IRI 2014 */
-
-
-.Rk-Main h3,.Rk-Main h4,.Rk-Main li,.Rk-Main p,.Rk-Main ul{border:0 none;margin:0;padding:0}.Rk-Main li,.Rk-Main ul{list-style:none}.Rk-Main input::-moz-focus-inner{border:0;padding:0}.Rk-Main table{border-collapse:separate;border-spacing:0}.Rk-Main td,.Rk-Main th{vertical-align:top}.Rk-Main img a{border:none}.Rk-Main{font-size:10px;font-family:Arial,Helvetica,sans-serif;background:#fff;color:#000}.Rk-Main a{color:#6060c0}.Rk-Main{position:absolute;left:0;top:0;right:0;bottom:0}.Rk-Render{position:absolute;top:0;right:0;bottom:0;background:#fff}.Rk-Render-Full{left:0}.Rk-Render-Panel{left:300px}.Rk-TopBar{position:absolute;left:0;top:0;right:0;height:35px;background:#333;background:-moz-linear-gradient(top,#505050 5px,#1e1e1e 30px);background:-webkit-linear-gradient(top,#505050 5px,#1e1e1e 30px);background:-ms-linear-gradient(top,#505050 5px,#1e1e1e 30px);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#505050', endColorstr='#1e1e1e', GradientType=0)}.Rk-PadTitle{float:left;font-size:14px;height:16px;margin:4px 5px;background:#666;padding:4px;border:1px solid #333;border-radius:3px;box-shadow:0 1px 0 #505050;color:#fff;font-weight:700}input.Rk-PadTitle{width:180px}h2.Rk-PadTitle{min-width:180px;max-width:320px;overflow:hidden}.Rk-Users{float:right;width:130px;margin:4px 5px}.Rk-CurrentUser{font-size:13px;background:#666;padding:4px;border:1px solid #333;border-radius:3px;box-shadow:0 1px 0 #505050;color:#fff}.Rk-CurrentUser-Color{display:inline-block;width:12px;height:12px;border:1px solid #333;margin:-2px 2px;position:relative}.Rk-CurrentUser input{width:95px;padding:1px;border:none;border-radius:2px}.Rk-UserList{box-shadow:0 2px 2px #999;position:relative;z-index:3;display:none;padding-top:8px}.Rk-User{background:#fff;padding:3px;font-size:12px;border-style:solid solid none;border-color:#ccc;border-width:1px}.Rk-TopBar-Button{float:right;background:url(../img/topbarbuttons.png) no-repeat;height:35px;cursor:pointer;position:relative}.Rk-TopBar-Separator{background:#666;background:-moz-linear-gradient(top,#666 20%,#333 80%);background:-webkit-linear-gradient(top,#666 20%,#333 80%);background:-ms-linear-gradient(top,#666 20%,#333 80%);content:"";display:block;height:35px;float:right;width:1px;border-left:1px solid #111;margin:0 3px}.Rk-TopBar-Tooltip{position:absolute;top:31px;left:50%;margin-left:-60px;width:120px;z-index:4;display:none}.Rk-TopBar-Tooltip-Contents{background:#fff;font-size:13px;font-weight:700;color:#6060c0;text-align:center;padding:2px;border-style:none solid solid;border-width:1px;border-color:#ccc;border-bottom-left-radius:2px;border-bottom-right-radius:2px}.Rk-TopBar-Tooltip:before{content:".";display:block;text-indent:-8000px;height:7px;background:url(../img/tooltiparrow.png) center no-repeat;margin:0 1px}.Rk-AddNode-Button{width:30px;background-position:-2px 0}.Rk-AddNode-Button:hover{background-position:-2px -35px}.Rk-FullScreen-Button{width:30px;background-position:-36px 0}.Rk-FullScreen-Button:hover{background-position:-36px -35px}.Rk-AddEdge-Button{width:30px;background-position:-70px 0}.Rk-AddEdge-Button:hover{background-position:-70px -35px}.Rk-Save-Button{width:30px;background-position:-104px 0}.Rk-Save-Button.disabled{opacity:.5;cursor:default}.Rk-Save-Button:hover{background-position:-104px -35px}.Rk-Save-Button.disabled:hover{opacity:1;background-position:-104px 0}.Rk-Save-Button.Rk-Save-ReadOnly,.Rk-Save-Button.Rk-Save-ReadOnly:hover{background-position:-172px -35px}.Rk-Save-Button.Rk-Save-Online,.Rk-Save-Button.Rk-Save-Online:hover{background-position:-172px 0}.Rk-Export-Button{width:30px;background-position:-274px 0}.Rk-Export-Button.disabled{opacity:.5;cursor:default}.Rk-Export-Button:hover{background-position:-274px -35px}.Rk-Export-Button.disabled:hover{opacity:1;background-position:-274px 0}.Rk-Bookmarklet-Button{width:30px;background-position:-138px 0}.Rk-Bookmarklet-Button.disabled{opacity:.5;cursor:default}.Rk-Bookmarklet-Button:hover{background-position:-138px -35px}.Rk-Bookmarklet-Button.disabled:hover{opacity:1;background-position:-138px 0}.Rk-Home-Button{width:30px;background-position:-206px 0}.Rk-Home-Button:hover{background-position:-206px -35px}.Rk-Open-Button{width:30px;background-position:-240px 0}.Rk-Open-Button:hover{background-position:-240px -35px}.Rk-GraphSearch-Form{float:right;width:170px;position:relative}.Rk-GraphSearch-Form:after,.Rk-GraphSearch-Form:before{position:absolute;display:block;content:".";text-indent:-9999px}.Rk-GraphSearch-Form:before{right:10px;top:20px;width:7px;height:2px;border:none;padding:0;background:#666;transform:rotate(40deg);-webkit-transform:rotate(40deg)}.Rk-GraphSearch-Form:after{right:13px;top:11px;width:6px;height:6px;border-radius:8px;border:2px solid #666}.Rk-GraphSearch-Field{line-height:23px;font-size:14px;height:23px;padding:0 5px;border:none;margin:6px 5px;width:150px;background:#f0f0f0;box-shadow:1px 1px 1px #999 inset;border-radius:5px;-webkit-appearance:none;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}.Rk-Editing-Space{position:absolute;left:0;top:35px;right:0;bottom:0;overflow:hidden;background:-moz-radial-gradient(center,circle,#fff 40%,#e0e0e0 90%);background:-webkit-radial-gradient(center,circle,#fff 40%,#e0e0e0 90%);background:-ms-radial-gradient(center,circle,#fff 40%,#e0e0e0 90%)}.Rk-Editing-Space-Full{top:0}.Rk-Canvas{position:absolute;left:0;top:0;right:0;bottom:0;z-index:2}.Rk-Highlighted{background:rgba(255,255,0,.5)}.Rk-Labels{position:absolute;left:0;top:0;z-index:1;font-family:"Segoe UI","Helvetica Neue",Arial,Helvetica,sans-serif}.Rk-Label{position:absolute;width:160px;margin-left:-80px;text-align:center;font-size:13px;line-height:13px}.Rk-Edge-Label{font-size:11px;transform-origin:50% 0;-moz-transform-origin:50% 0;-webkit-transform-origin:50% 0;-ms-transform-origin:50% 0}.Rk-Editor{position:absolute;left:0;top:0;z-index:3}.Rk-Notifications{position:absolute;right:15px;top:15px;width:200px;padding:10px;border-radius:8px;display:none;color:#fff;font-size:13px;text-align:center;font-weight:700;background:rgba(20,20,20,.7);background:-moz-linear-gradient(top,rgba(40,40,40,.7)20%,rgba(0,0,0,.7)80%);background:-webkit-linear-gradient(top,rgba(40,40,40,.7)20%,rgba(0,0,0,.7)80%);background:-ms-linear-gradient(top,rgba(40,40,40,.7)20%,rgba(0,0,0,.7)80%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#202020', endColorstr='#000000', GradientType=0)}.Rk-CloseX{float:right;cursor:pointer}.Rk-Editor h2{font-size:16px;font-weight:700}.Rk-Editor p,.Rk-Editor-p{margin:5px 0;font-size:12px;clear:both}.Rk-Editor-Label{float:left;width:80px}a.Rk-Edit-Goto{display:block;float:right;width:18px;height:17px;margin:1px 0;border:none;background:url(../img/goto.png)}.Rk-Edit-Image,.Rk-Edit-Image-File,.Rk-Edit-Title,.Rk-Edit-URI,.Rk-Edit-Vocabulary{font-size:12px;width:250px}.Rk-Edit-URI{font-size:12px;width:230px}.Rk-Edit-ImgWrap{text-align:center}.Rk-Edit-ImgPreview{display:inline-block;border:1px solid #666;margin:5px auto;position:relative}.Rk-Edit-ImgPreview img{display:inline-block;max-width:253px!important;max-height:200px!important}.Rk-Edit-ImgPreview svg{height:100%;left:0;position:absolute;top:0;width:100%}.Rk-Editor textarea{width:250px;height:120px;resize:none}.Rk-UserColor{display:inline-block;width:12px;height:12px;border:1px solid #666;margin:-2px 2px}.Rk-Edit-Color{display:inline-block;width:10px;height:10px;border:2px solid #333;margin:-2px 2px;position:relative}.Rk-Edit-ColorTip{display:block;width:3px;height:3px;background:#fff;position:absolute;bottom:0;right:0;cursor:pointer}.Rk-Edit-ColorPicker-Wrapper{display:inline-block;position:relative}.Rk-Edit-ColorPicker{position:absolute;top:-2px;left:15px;width:96px;height:96px;border:1px solid #CCC;padding:5px 4px 4px 5px;background:#fff;border-radius:5px;display:none;z-index:4}.Rk-CurrentUser .Rk-Edit-ColorPicker{left:-105px;top:2px}.Rk-Edit-ColorPicker-Text{color:#303080;font-weight:700}.Rk-Edit-ColorPicker li{float:left;width:11px;height:11px;margin:0 1px 1px 0;cursor:pointer}.Rk-Edit-Size-Down,.Rk-Edit-Size-Up{font-size:13px;font-weight:700;padding:0 4px;background:#fff;color:#000;border:1px solid #ccc;text-decoration:none}.Rk-Edit-Size-Down:hover,.Rk-Edit-Size-Up:hover{background:#666}.Rk-Edit-Size-Value{display:inline-block;padding:0 5px;text-align:center;width:20px}.Rk-Edit-Vocabulary-Class{color:#999;font-style:italic;font-weight:700}.Rk-Edit-Vocabulary-Property{padding-left:20px}.Rk-Edit-Direction{border:1px solid #666;padding:3px 5px;line-height:20px;border-radius:3px;background:#f0f0f0;cursor:pointer}.Rk-Edit-Direction:hover{background:silver}.Rk-Display-Title a{text-decoration:none;color:#000}.Rk-Display-Title a:hover{text-decoration:underline}.Rk-Display-URI{font-style:italic}.Rk-Display-ImgPreview{margin:5px auto;display:block;max-width:255px!important;max-height:260px!important}.Rk-Fold-Bins{position:absolute;top:5px;width:12px;text-align:center;font-size:16px;cursor:pointer;line-height:16px;padding:4px;color:#fff;background:#666;border-radius:0 6px 6px 0;font-weight:700}.Rk-Fold-Bins:hover{background:#333}.Rk-ZoomButtons{position:absolute;left:0;top:35px;cursor:pointer}.Rk-Editing-Space-Full .Rk-ZoomButtons{top:0}.Rk-ZoomFit,.Rk-ZoomIn,.Rk-ZoomOut,.Rk-ZoomSave,.Rk-ZoomSetSaved{width:21px;height:20px;background:url(../img/zoombuttons.png);margin:5px}.Rk-ZoomIn:hover{background-position:0 -20px}.Rk-ZoomFit{background-position:-42px 0}.Rk-ZoomFit:hover{background-position:-42px -20px}.Rk-ZoomOut{background-position:-21px 0}.Rk-ZoomOut:hover{background-position:-21px -20px}.Rk-ZoomSave{background-position:-63px 0}.Rk-ZoomSave:hover{background-position:-63px -20px}.Rk-ZoomSetSaved{background-position:-84px 0;display:none}.Rk-ZoomSetSaved:hover{background-position:-84px -20px}.Rk-Bins{background:#fff;position:absolute;left:0;top:0;width:299px;bottom:0;overflow:hidden;border-right:1px solid #252525}.Rk-Bins-Title{border:0 none;width:290px;height:15px;line-height:15px;margin:0;padding:15px 0 5px 10px;font-size:14px;color:#F0F0F0;background:-moz-linear-gradient(top,#1e1e1e 5px,#606060 30px);background:-webkit-linear-gradient(top,#1e1e1e 5px,#606060 30px);background:-ms-linear-gradient(top,#1e1e1e 5px,#606060 30px);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#1e1e1e', endColorstr='#606060', GradientType=0)}.Rk-Search-Form{padding:0 10px 8px;height:27px;background:#606060}.Rk-Search-Input,.Rk-Search-Select{float:left;margin:0}.Rk-Search-Input{border-top-left-radius:5px;border-bottom-left-radius:5px;border:1px solid #003050;font-size:13px;background:#fff;height:25px;padding:0 5px;line-height:25px;-webkit-appearance:none;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}.Rk-Web-Search-Input{width:190px}.Rk-Bins-Search-Input{width:235px}.Rk-Search-Select{display:inline-block;position:relative;width:45px;border-width:1px;border-color:#003050;border-style:solid none;cursor:pointer;height:25px;background:#fff url(../img/more.png) 30px 10px no-repeat}.Rk-Search-Select:hover{background-color:#3030FF}.Rk-Search-Current{width:40px;height:20px;margin:2px;background-repeat:no-repeat}.Rk-Search-List{width:180px;margin-left:15px;font-size:13px;position:absolute;right:0;top:25px;background:#fff;box-shadow:1px 1px 2px #505050;display:none;border:1px solid #ccc;z-index:2}.Rk-Search-List li{padding:2px 2px 2px 30px;border-top:1px solid #ccc;height:16px;background-color:#fff;background-repeat:no-repeat;cursor:pointer}.Rk-Search-List li:hover{background-color:#3030ff;color:#fff}.Rk-Search-Submit{border:1px solid #003050;height:27px;width:30px;border-top-right-radius:5px;border-bottom-right-radius:5px;background:#333 center no-repeat url(../img/search.png);cursor:pointer}.Rk-Search-Submit:hover{background-color:#999}.Rk-Bin-Title{background:#333;background:-moz-linear-gradient(top,#505050 20%,#1e1e1e 80%);background:-webkit-linear-gradient(top,#505050 20%,#1e1e1e 80%);background:-ms-linear-gradient(top,#505050 20%,#1e1e1e 80%);font-weight:700;font-size:14px;padding:5px;cursor:pointer;color:#f0f0f0;margin:0;border:0 none}.Rk-Bin-Close{float:right;display:block;font-size:16px;font-weight:700;margin:2px 3px 0;color:#f0f0f0;cursor:pointer;text-shadow:-1px -1px 1px #999,1px 1px 1px #000;text-decoration:none}.Rk-Bin-Close:hover{color:#ffff80}.Rk-Bin-Title:hover{color:#ffffe0;background:#505050;background:-moz-linear-gradient(top,#141414 20%,#3c3c3c 80%);background:-webkit-linear-gradient(top,#141414 20%,#3c3c3c 80%);background:-ms-linear-gradient(top,#141414 20%,#3c3c3c 80%)}.Rk-Bin-Refresh{width:18px;height:17px;background:url(../img/refresh.png);display:block;float:right;margin-top:4px}.Rk-Bin-Refresh:hover{background-position:-18px 0}.Rk-Bin-Count{float:right;background:#c000a0;color:#FFF;text-shadow:1px 1px 1px #000;display:none;border-radius:4px;padding:1px 3px;font-size:10px;font-weight:700;margin-top:4px}.Rk-Bin-Title-Icon{float:left;width:25px;margin:2px}.Rk-Bin-Main{overflow:auto;background:#fff;background:-moz-linear-gradient(top,#e0e0e0 0,#FFF 2%,#FFF 98%,#e0e0e0 100%);background:-webkit-linear-gradient(top,#e0e0e0 0,#FFF 2%,#FFF 98%,#e0e0e0 100%);background:-ms-linear-gradient(top,#e0e0e0 0,#FFF 2%,#FFF 98%,#e0e0e0 100%)}.Rk-Bin-Item{cursor:move}.Rk-Bin-Item.hover,.Rk-Bin-Item:hover{background:-moz-linear-gradient(top,rgba(0,0,0,.1)20%,rgba(128,128,128,.1)80%);background:-webkit-linear-gradient(top,rgba(0,0,0,.1)20%,rgba(128,128,128,.1)80%);background:-ms-linear-gradient(top,rgba(0,0,0,.1)20%,rgba(128,128,128,.1)80%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#d0d0d0', endColorstr='#f3f3f3', GradientType=0)}.Rk-Bin-Item.selected{background:#ffffc0}.Rk-Bin-Main li{padding:2px;border-bottom:1px solid #ccc;clear:both}.Rk-Bin-Main h3{font-size:14px;font-style:italic;font-weight:700;text-align:center}.Rk-Bin-Main h4{font-size:12px;font-weight:700}.Rk-Bin-Main p{font-size:11px}.Rk-Bin-Main h4 a{color:#303080}.Rk-Bin-Main .searchmatch{background:#ffff80}.Rk-Wikipedia-Search-Icon{background-image:url(../img/search-logos.png)}.Rk-Wikipedia-Icon{float:left;margin:3px}.Rk-Wikipedia-Title-Icon{height:20px;background:url(../img/search-logos.png)}.Rk-Wikipedia-Lang-en{background-position:0 -20px}.Rk-Wikipedia-Lang-fr{background-position:0 -40px}.Rk-Wikipedia-Lang-ja{background-position:0 -60px}.Rk-Wikipedia-Result{min-height:51px}.Rk-Wikipedia-Result h4,.Rk-Wikipedia-Result p{margin-left:54px}.Rk-ResourceList-Image{float:left;max-width:100px;max-height:75px;margin-right:2px}.Rk-Ldt-Icon,.Rk-Ldt-Title-Icon{background:url(../img/search-logos.png);background-position:0 -100px;background-repeat:no-repeat}.Rk-Ldt-Title-Icon{height:20px;margin-top:4px}.Rk-Ldt-Tag-Icon{float:left;margin:0 2px 0 0}.Rk-Ldt-Annotation-Icon{float:left;margin:3px}.Rk-Clear{clear:both}h4.Rk-Bin-Loading{margin:10px;text-align:center;font-size:20px;color:#999}
\ No newline at end of file
Binary file src/hdalab/static/hdalab/lib/renkan/img/edit.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/enlarge.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/goto.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/image-placeholder.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/ldt-point.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/ldt-segment.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/ldt-tag.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/link.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/more.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/refresh.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/remove.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/revert.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/search-logos.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/search.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/shrink.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/tooltiparrow.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/topbarbuttons.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/wikipedia.png has changed
Binary file src/hdalab/static/hdalab/lib/renkan/img/zoombuttons.png has changed
--- a/src/hdalab/static/hdalab/lib/renkan/renkan.js	Fri Jul 18 13:29:53 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4698 +0,0 @@
-/*! 
- *    _____            _               
- *   |  __ \          | |              
- *   | |__) |___ _ __ | | ____ _ _ __  
- *   |  _  // _ \ '_ \| |/ / _` | '_ \ 
- *   | | \ \  __/ | | |   < (_| | | | |
- *   |_|  \_\___|_| |_|_|\_\__,_|_| |_|
- *
- *  Copyright 2012-2013 Institut de recherche et d'innovation 
- *  contributor(s) : Yves-Marie Haussonne, Raphael Velt, Samuel Huron
- *   
- *  contact@iri.centrepompidou.fr
- *  http://www.iri.centrepompidou.fr 
- *   
- *  This software is a computer program whose purpose is to show and add annotations on a video .
- *  This software is governed by the CeCILL-C license under French law and
- *  abiding by the rules of distribution of free software. You can  use, 
- *  modify and/ or redistribute the software under the terms of the CeCILL-C
- *  license as circulated by CEA, CNRS and INRIA at the following URL
- *  "http://www.cecill.info". 
- *  
- *  The fact that you are presently reading this means that you have had
- *  knowledge of the CeCILL-C license and that you accept its terms.
- */
-/*! renkan - v0.7.10 - Copyright © IRI 2014 */
-
-
-/* Declaring the Renkan Namespace Rkns and Default values */
-
-(function(root) {
-
-"use strict";
-
-if (typeof root.Rkns !== "object") {
-    root.Rkns = {};
-}
-
-var Rkns = root.Rkns;
-var $ = Rkns.$ = root.jQuery;
-var _ = Rkns._ = root._;
-
-Rkns.pickerColors = ["#8f1919", "#a80000", "#d82626", "#ff0000", "#e87c7c", "#ff6565", "#f7d3d3", "#fecccc",
-    "#8f5419", "#a85400", "#d87f26", "#ff7f00", "#e8b27c", "#ffb265", "#f7e5d3", "#fee5cc",
-    "#8f8f19", "#a8a800", "#d8d826", "#feff00", "#e8e87c", "#feff65", "#f7f7d3", "#fefecc",
-    "#198f19", "#00a800", "#26d826", "#00ff00", "#7ce87c", "#65ff65", "#d3f7d3", "#ccfecc",
-    "#198f8f", "#00a8a8", "#26d8d8", "#00feff", "#7ce8e8", "#65feff", "#d3f7f7", "#ccfefe",
-    "#19198f", "#0000a8", "#2626d8", "#0000ff", "#7c7ce8", "#6565ff", "#d3d3f7", "#ccccfe",
-    "#8f198f", "#a800a8", "#d826d8", "#ff00fe", "#e87ce8", "#ff65fe", "#f7d3f7", "#feccfe",
-    "#000000", "#242424", "#484848", "#6d6d6d", "#919191", "#b6b6b6", "#dadada", "#ffffff"];
-
-Rkns.__renkans = [];
-
-var _BaseBin = Rkns._BaseBin = function(_renkan, _opts) {
-    if (typeof _renkan !== "undefined") {
-        this.renkan = _renkan;
-        this.renkan.$.find(".Rk-Bin-Main").hide();
-        this.$ = Rkns.$('<li>')
-            .addClass("Rk-Bin")
-            .appendTo(_renkan.$.find(".Rk-Bin-List"));
-        this.title_icon_$ = Rkns.$('<span>')
-            .addClass("Rk-Bin-Title-Icon")
-            .appendTo(this.$);
-
-        var _this = this;
-
-        Rkns.$('<a>')
-            .attr({
-                href: "#",
-                title: _renkan.translate("Close bin")
-            })
-            .addClass("Rk-Bin-Close")
-            .html('&times;')
-            .appendTo(this.$)
-            .click(function() {
-                _this.destroy();
-                if (!_renkan.$.find(".Rk-Bin-Main:visible").length) {
-                    _renkan.$.find(".Rk-Bin-Main:last").slideDown();
-                }
-                _renkan.resizeBins();
-                return false;
-            });
-        Rkns.$('<a>')
-            .attr({
-                href: "#",
-                title: _renkan.translate("Refresh bin")
-            })
-            .addClass("Rk-Bin-Refresh")
-            .appendTo(this.$)
-            .click(function() {
-                _this.refresh();
-                return false;
-            });
-        this.count_$ = Rkns.$('<div>')
-            .addClass("Rk-Bin-Count")
-            .appendTo(this.$);
-        this.title_$ = Rkns.$('<h2>')
-            .addClass("Rk-Bin-Title")
-            .appendTo(this.$);
-        this.main_$ = Rkns.$('<div>')
-            .addClass("Rk-Bin-Main")
-            .appendTo(this.$)
-            .html('<h4 class="Rk-Bin-Loading">' + _renkan.translate("Loading, please wait") + '</h4>');
-        this.title_$.html(_opts.title || '(new bin)');
-        this.renkan.resizeBins();
-
-        if (_opts.auto_refresh) {
-            window.setInterval(function() {
-                _this.refresh();
-            },_opts.auto_refresh);
-        }
-    }
-};
-
-_BaseBin.prototype.destroy = function() {
-    this.$.detach();
-    this.renkan.resizeBins();
-};
-
-/* Point of entry */
-
-var Renkan = Rkns.Renkan = function(_opts) {
-    var _this = this;
-
-    Rkns.__renkans.push(this);
-
-    this.options = _.defaults(_opts, Rkns.defaults);
-
-    _(this.options.property_files).each(function(f) {
-        Rkns.$.getJSON(f, function(data) {
-            _this.options.properties = _this.options.properties.concat(data);
-        });
-    });
-
-    this.read_only = this.options.read_only || !this.options.editor_mode;
-
-    this.project = new Rkns.Models.Project();
-
-    if (typeof this.options.user_id !== "undefined") {
-        this.current_user = this.options.user_id;
-    }
-    this.$ = Rkns.$("#" + this.options.container);
-    this.$
-        .addClass("Rk-Main")
-        .html(this.template(this));
-
-    this.tabs = [];
-    this.search_engines = [];
-
-    this.current_user_list = new Rkns.Models.UsersList();
-
-    this.current_user_list.on("add remove", function() {
-        if (this.renderer) {
-            this.renderer.redrawUsers();
-        }
-    });
-
-    this.colorPicker = (function() {
-        var _tmpl = _.template('<li data-color="<%=c%>" style="background: <%=c%>"></li>');
-        return '<ul class="Rk-Edit-ColorPicker">' + Rkns.pickerColors.map(function(c) { return _tmpl({c:c});}).join("") + '</ul>';
-    })();
-
-    if (this.options.show_editor) {
-        this.renderer = new Rkns.Renderer.Scene(this);
-    }
-
-    if (!this.options.search.length) {
-        this.$.find(".Rk-Web-Search-Form").detach();
-    } else {
-        var _tmpl = _.template('<li class="<%= className %>" data-key="<%= key %>"><%= title %></li>'),
-            _select = this.$.find(".Rk-Search-List"),
-            _input = this.$.find(".Rk-Web-Search-Input"),
-            _form = this.$.find(".Rk-Web-Search-Form");
-        _(this.options.search).each(function(_search, _key) {
-            if (Rkns[_search.type] && Rkns[_search.type].Search) {
-                _this.search_engines.push(new Rkns[_search.type].Search(_this, _search));
-            }
-        });
-        _select.html(
-            _(this.search_engines).map(function(_search, _key) {
-                return _tmpl({
-                    key: _key,
-                    title: _search.getSearchTitle(),
-                    className: _search.getBgClass()
-                });
-            }).join("")
-        );
-        _select.find("li").click(function() {
-            var _el = Rkns.$(this);
-            _this.setSearchEngine(_el.attr("data-key"));
-            _form.submit();
-        });
-        _form.submit(function() {
-            if (_input.val()) {
-                var _search = _this.search_engine;
-                _search.search(_input.val());
-            }
-            return false;
-        });
-        this.$.find(".Rk-Search-Current").mouseenter(
-            function() { _select.slideDown(); }
-        );
-        this.$.find(".Rk-Search-Select").mouseleave(
-            function() { _select.hide(); }
-        );
-        this.setSearchEngine(0);
-    }
-    _(this.options.bins).each(function(_bin) {
-        if (Rkns[_bin.type] && Rkns[_bin.type].Bin) {
-            _this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin));
-        }
-    });
-
-    var elementDropped = false;
-
-    this.$.find(".Rk-Bins")
-        .on("click",".Rk-Bin-Title,.Rk-Bin-Title-Icon", function() {
-            var _mainDiv = Rkns.$(this).siblings(".Rk-Bin-Main");
-            if (_mainDiv.is(":hidden")) {
-                _this.$.find(".Rk-Bin-Main").slideUp();
-                _mainDiv.slideDown();
-            }
-        });
-
-    if (this.options.show_editor) {
-
-        this.$.find(".Rk-Bins").on("mouseover", ".Rk-Bin-Item", function(_e) {
-            var _t = Rkns.$(this);
-            if (_t && $(_t).attr("data-uri")) {
-                var _models = _this.project.get("nodes").where({
-                    uri: $(_t).attr("data-uri")
-                });
-                _(_models).each(function(_model) {
-                    _this.renderer.highlightModel(_model);
-                });
-            }
-        }).mouseout(function() {
-            _this.renderer.unhighlightAll();
-        }).on("mousemove", ".Rk-Bin-Item", function(e) {
-            try {
-                this.dragDrop();
-            }
-            catch(err) {}
-        }).on("touchstart", ".Rk-Bin-Item", function(e) {
-            elementDropped = false;
-        }).on("touchmove", ".Rk-Bin-Item", function(e) {
-            e.preventDefault();
-            var touch = e.originalEvent.changedTouches[0],
-                off = _this.renderer.canvas_$.offset(),
-                w = _this.renderer.canvas_$.width(),
-                h = _this.renderer.canvas_$.height();
-            if (touch.pageX >= off.left && touch.pageX < (off.left + w) && touch.pageY >= off.top && touch.pageY < (off.top + h)) {
-                if (elementDropped) {
-                    _this.renderer.onMouseMove(touch, true);
-                } else {
-                    elementDropped = true;
-                    var div = document.createElement('div');
-                    div.appendChild(this.cloneNode(true));
-                    _this.renderer.dropData({"text/html": div.innerHTML}, touch);
-                    _this.renderer.onMouseDown(touch, true);
-                }
-            }
-        }).on("touchend", ".Rk-Bin-Item", function(e) {
-            if (elementDropped) {
-                _this.renderer.onMouseUp(e.originalEvent.changedTouches[0], true);
-            }
-            elementDropped = false;
-        }).on("dragstart", ".Rk-Bin-Item", function(e) {
-            var div = document.createElement('div');
-            div.appendChild(this.cloneNode(true));
-            try {
-                e.originalEvent.dataTransfer.setData("text/html",div.innerHTML);
-            }
-            catch(err) {
-                e.originalEvent.dataTransfer.setData("text",div.innerHTML);
-            }
-        });
-
-    }
-
-    Rkns.$(window).resize(function() {
-        _this.resizeBins();
-    });
-
-    var lastsearch = false, lastval = '';
-
-    this.$.find(".Rk-Bins-Search-Input").on("change keyup paste input", function() {
-        var val = Rkns.$(this).val();
-        if (val === lastval) {
-            return;
-        }
-        var search = Rkns.Utils.regexpFromTextOrArray(val.length > 1 ? val: null);
-        if (search.source === lastsearch) {
-            return;
-        }
-        lastsearch = search.source;
-        _(_this.tabs).each(function(tab) {
-            tab.render(search);
-        });
-
-    });
-    this.$.find(".Rk-Bins-Search-Form").submit(function() {
-        return false;
-    });
-
-};
-
-Renkan.prototype.template = _.template(
-    '<% if (options.show_bins) { %><div class="Rk-Bins"><div class="Rk-Bins-Head"><h2 class="Rk-Bins-Title"><%- translate("Select contents:")%></h2>' +
-    '<form class="Rk-Web-Search-Form Rk-Search-Form"><input class="Rk-Web-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search the Web") %>" />' +
-    '<div class="Rk-Search-Select"><div class="Rk-Search-Current"></div><ul class="Rk-Search-List"></ul></div>' +
-    '<input type="submit" value="" class="Rk-Web-Search-Submit Rk-Search-Submit" title="<%- translate("Search the Web") %>" /></form>' +
-    '<form class="Rk-Bins-Search-Form Rk-Search-Form"><input class="Rk-Bins-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search in Bins") %>" />' +
-    '<input type="submit" value="" class="Rk-Bins-Search-Submit Rk-Search-Submit" title="<%- translate("Search in Bins") %>" /></form></div>' +
-    '<ul class="Rk-Bin-List"></ul></div><% } %>' +
-    '<% if (options.show_editor) { %><div class="Rk-Render Rk-Render-<% if (options.show_bins) { %>Panel<% } else { %>Full<% } %>"></div><% } %>'
-);
-
-Renkan.prototype.translate = function(_text) {
-    if (Rkns.i18n[this.options.language] && Rkns.i18n[this.options.language][_text]) {
-        return Rkns.i18n[this.options.language][_text];
-    }
-    if (this.options.language.length > 2 && Rkns.i18n[this.options.language.substr(0,2)] && Rkns.i18n[this.options.language.substr(0,2)][_text]) {
-        return Rkns.i18n[this.options.language.substr(0,2)][_text];
-    }
-    return _text;
-};
-
-Renkan.prototype.onStatusChange = function() {
-    this.renderer.onStatusChange();
-};
-
-Renkan.prototype.setSearchEngine = function(_key) {
-    this.search_engine = this.search_engines[_key];
-    this.$.find(".Rk-Search-Current").attr("class","Rk-Search-Current " + this.search_engine.getBgClass());
-};
-
-Renkan.prototype.resizeBins = function() {
-    var _d = + this.$.find(".Rk-Bins-Head").outerHeight();
-    this.$.find(".Rk-Bin-Title:visible").each(function() {
-        _d += Rkns.$(this).outerHeight();
-    });
-    this.$.find(".Rk-Bin-Main").css({
-        height: this.$.find(".Rk-Bins").height() - _d
-    });
-};
-
-/* Utility functions */
-var getUUID4 = function() {
-    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
-        var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
-        return v.toString(16);
-    });
-};
-
-Rkns.Utils = {
-    getUUID4 : getUUID4,
-    getUID : (function() {
-        function pad(n){
-            return n<10 ? '0'+n : n;
-        }
-        var _d = new Date(),
-            ID_AUTO_INCREMENT = 0,
-            ID_BASE = _d.getUTCFullYear() + '-' +
-              pad(_d.getUTCMonth()+1) + '-' +
-              pad(_d.getUTCDate()) + '-' +
-              getUUID4();
-        return function(_base) {
-            var _n = (++ID_AUTO_INCREMENT).toString(16),
-                _uidbase = (typeof _base === "undefined" ? "" : _base + "-" );
-            while (_n.length < 4) { _n = '0' + _n; }
-            return _uidbase + ID_BASE + '-' + _n;
-        };
-    })(),
-    getFullURL : function(url) {
-
-        if(typeof(url) === 'undefined' || url == null ) {
-            return "";
-        }
-        if(/https?:\/\//.test(url)) {
-            return url;
-        }
-        var img = new Image();
-        img.src = url;
-        var res = img.src;
-        img.src = null;
-        return res;
-
-    },
-    inherit : function(_baseClass, _callbefore) {
-
-        var _class = function(_arg) {
-            if (typeof _callbefore === "function") {
-                _callbefore.apply(this, Array.prototype.slice.call(arguments, 0));
-            }
-            _baseClass.apply(this, Array.prototype.slice.call(arguments, 0));
-            if (typeof this._init === "function" && !this._initialized) {
-                this._init.apply(this, Array.prototype.slice.call(arguments, 0));
-                this._initialized = true;
-            }
-        };
-        _(_class.prototype).extend(_baseClass.prototype);
-
-        return _class;
-
-    },
-    regexpFromTextOrArray: (function() {
-        var charsub = [
-                '[aáàâä]',
-                '[cç]',
-                '[eéèêë]',
-                '[iíìîï]',
-                '[oóòôö]',
-                '[uùûü]'
-            ],
-            removeChars = [
-                String.fromCharCode(768), String.fromCharCode(769), String.fromCharCode(770), String.fromCharCode(771), String.fromCharCode(807),
-                "{", "}", "(", ")", "[", "]", "【", "】", "、", "・", "‥", "。", "「", "」", "『", "』", "〜", ":", "!", "?", " ",
-                ",", " ", ";", "(", ")", ".", "*", "+", "\\", "?", "|", "{", "}", "[", "]", "^", "#", "/"
-            ],
-            remsrc = "[\\" + removeChars.join("\\") + "]",
-            remrx = new RegExp(remsrc, "gm"),
-            charsrx = _(charsub).map(function(c) {
-                return new RegExp(c);
-            });
-
-        function replaceText(_text) {
-            var txt = _text.toLowerCase().replace(remrx,""), src = "";
-            function makeReplaceFunc(l) {
-              return function(k,v) {
-                l = l.replace(charsrx[k], v);
-              };
-            }
-            for (var j = 0; j < txt.length; j++) {
-                if (j) {
-                    src += remsrc + "*";
-                }
-                var l = txt[j];
-                _(charsub).each(makeReplaceFunc(l));
-                src += l;
-            }
-            return src;
-        }
-
-        function getSource(inp) {
-            switch (typeof inp) {
-                case "string":
-                    return replaceText(inp);
-                case "object":
-                    var src = '';
-                    _(inp).each(function(v) {
-                        var res = getSource(v);
-                        if (res) {
-                            if (src) {
-                                src += '|';
-                            }
-                            src += res;
-                        }
-                    });
-                    return src;
-            }
-            return '';
-        }
-
-        return function(_textOrArray) {
-            var source = getSource(_textOrArray);
-            if (source) {
-                var testrx = new RegExp( source, "im"),
-                    replacerx = new RegExp( '(' + source + ')', "igm");
-                return {
-                    isempty: false,
-                    source: source,
-                    test: function(_t) { return testrx.test(_t); },
-                    replace: function(_text, _replace) { return _text.replace(replacerx, _replace); }
-                };
-            } else {
-                return {
-                    isempty: true,
-                    source: '',
-                    test: function() { return true; },
-                    replace: function(_text) { return text; }
-                };
-            }
-        };
-    })(),
-    /* The minimum distance (in pixels) the mouse has to move to consider an element was dragged */
-    _MIN_DRAG_DISTANCE: 2,
-    /* Distance between the inner and outer radius of buttons that appear when hovering on a node */
-    _NODE_BUTTON_WIDTH: 40,
-
-    _EDGE_BUTTON_INNER: 2,
-    _EDGE_BUTTON_OUTER: 40,
-    /* Constants used to know if a specific action is to be performed when clicking on the canvas */
-    _CLICKMODE_ADDNODE: 1,
-    _CLICKMODE_STARTEDGE: 2,
-    _CLICKMODE_ENDEDGE: 3,
-    /* Node size step: Used to calculate the size change when clicking the +/- buttons */
-    _NODE_SIZE_STEP: Math.LN2/4,
-    _MIN_SCALE: 1/20,
-    _MAX_SCALE: 20,
-    _MOUSEMOVE_RATE: 80,
-    _DOUBLETAP_DELAY: 800,
-    /* Maximum distance in pixels (squared, to reduce calculations)
-     * between two taps when double-tapping on a touch terminal */
-    _DOUBLETAP_DISTANCE: 20*20,
-    /* A placeholder so a default colour is displayed when a node has a null value for its user property */
-    _USER_PLACEHOLDER: function(_renkan) {
-        return {
-            color: _renkan.options.default_user_color,
-            title: _renkan.translate("(unknown user)"),
-            get: function(attr) {
-                return this[attr] || false;
-            }
-        };
-    },
-    /* The code for the "Drag and Add Bookmarklet", slightly minified and with whitespaces removed, though
-     * it doesn't seem that it's still a requirement in newer browsers (i.e. the ones compatibles with canvas drawing)
-     */
-    _BOOKMARKLET_CODE: function(_renkan) {
-        return "(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='<p_style=\"position:fixed;top:0;right:0;font:bold_18px_sans-serif;color:#fff;background:#909;padding:10px;z-index:100000;\">" +
-        _renkan.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_") +
-        "</p>'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\/\\/[^\\/]*twitter\\.com\\//,s:'.tweet',n:'twitter'},{r:/https?:\\/\\/[^\\/]*google\\.[^\\/]+\\//,s:'.g',n:'google'},{r:/https?:\\/\\/[^\\/]*lemonde\\.fr\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();";
-    },
-    /* Shortens text to the required length then adds ellipsis */
-    shortenText: function(_text, _maxlength) {
-        return (_text.length > _maxlength ? (_text.substr(0,_maxlength) + '…') : _text);
-    },
-    /* Drawing an edit box with an arrow and positioning the edit box according to the position of the node/edge being edited
-     * Called by Rkns.Renderer.NodeEditor and Rkns.Renderer.EdgeEditor */
-    drawEditBox: function(_options, _coords, _path, _xmargin, _selector) {
-        _selector.css({
-            width: ( _options.tooltip_width - 2* _options.tooltip_padding )
-        });
-        var _height = _selector.outerHeight() + 2* _options.tooltip_padding,
-        _isLeft = (_coords.x < paper.view.center.x ? 1 : -1),
-        _left = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length ),
-        _right = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length + _options.tooltip_width ),
-        _top = _coords.y - _height / 2;
-        if (_top + _height > (paper.view.size.height - _options.tooltip_margin)) {
-            _top = Math.max( paper.view.size.height - _options.tooltip_margin, _coords.y + _options.tooltip_arrow_width / 2 ) - _height;
-        }
-        if (_top < _options.tooltip_margin) {
-            _top = Math.min( _options.tooltip_margin, _coords.y - _options.tooltip_arrow_width / 2 );
-        }
-        var _bottom = _top + _height;
-        /* jshint laxbreak:true */
-        _path.segments[0].point
-          = _path.segments[7].point
-          = _coords.add([_isLeft * _xmargin, 0]);
-        _path.segments[1].point.x
-          = _path.segments[2].point.x
-          = _path.segments[5].point.x
-          = _path.segments[6].point.x
-          = _left;
-        _path.segments[3].point.x
-          = _path.segments[4].point.x
-          = _right;
-        _path.segments[2].point.y
-          = _path.segments[3].point.y
-          = _top;
-        _path.segments[4].point.y
-          = _path.segments[5].point.y
-          = _bottom;
-        _path.segments[1].point.y = _coords.y - _options.tooltip_arrow_width / 2;
-        _path.segments[6].point.y = _coords.y + _options.tooltip_arrow_width / 2;
-        _path.closed = true;
-        _path.fillColor = new paper.GradientColor(new paper.Gradient([_options.tooltip_top_color, _options.tooltip_bottom_color]), [0,_top], [0, _bottom]);
-        _selector.css({
-            left: (_options.tooltip_padding + Math.min(_left, _right)),
-            top: (_options.tooltip_padding + _top)
-        });
-        return _path;
-    }
-};
-})(window);
-
-/* END main.js */
-
-(function() {
-    "use strict";
-    var root = this;
-
-    var Backbone = root.Backbone;
-
-    var Models = root.Rkns.Models = {};
-
-
-    Models.getUID = function(obj) {
-        var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
-            var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
-            return v.toString(16);
-        });
-        if(typeof obj !== 'undefined') {
-            return obj.type + "-" + guid;
-        }
-        else {
-            return guid;
-        }
-    };
-
-
-    var RenkanModel = Backbone.RelationalModel.extend({
-        idAttribute : "_id",
-        constructor: function(options) {
-
-            if (typeof options !== "undefined") {
-                options._id = options._id || options.id || Models.getUID(this);
-                options.title = options.title || "";
-                options.description = options.description || "";
-                options.uri = options.uri || "";
-
-                if(typeof this.prepare === "function") {
-                    options = this.prepare(options);
-                }
-            }
-            Backbone.RelationalModel.prototype.constructor.call(this, options);
-        },
-        validate: function() {
-            if(!this.type) {
-                return "object has no type";
-            }
-        },
-        addReference : function(_options, _propName, _list, _id, _default) {
-            var _element = _list.get(_id);
-            if (typeof _element === "undefined" && typeof _default !== "undefined") {
-                _options[_propName ] = _default;
-            }
-            else {
-                _options[_propName ] = _element;
-            }
-        }
-    });
-
-    // USER
-    var User = Models.User = RenkanModel.extend({
-        type: "user",
-        prepare: function(options) {
-            options.color = options.color || "#666666";
-            return options;
-        },
-        toJSON: function() {
-            return {
-                _id: this.get("_id"),
-                title: this.get("title"),
-                uri: this.get("uri"),
-                description: this.get("description"),
-                color: this.get("color")
-            };
-        }
-    });
-
-    // NODE
-    var Node = Models.Node = RenkanModel.extend({
-        type: "node",
-        relations: [{
-            type: Backbone.HasOne,
-            key: "created_by",
-            relatedModel: User
-        }],
-        prepare: function(options) {
-            var project = options.project;
-            this.addReference(options, "created_by", project.get("users"), options.created_by, project.current_user);
-            options.description = options.description || "";
-            return options;
-        },
-        toJSON: function() {
-            return {
-                _id: this.get("_id"),
-                title: this.get("title"),
-                uri: this.get("uri"),
-                description: this.get("description"),
-                position: this.get("position"),
-                image: this.get("image"),
-                color: this.get("color"),
-                created_by: this.get("created_by") ? this.get("created_by").get("_id") : null,
-                size: this.get("size"),
-                clip_path: this.get("clip_path")
-            };
-        }
-    });
-
-    // EDGE
-    var Edge = Models.Edge = RenkanModel.extend({
-        type: "edge",
-        relations: [
-          {
-            type: Backbone.HasOne,
-            key: "created_by",
-            relatedModel: User
-          },
-          {
-            type: Backbone.HasOne,
-            key: "from",
-            relatedModel: Node
-          },
-          {
-            type: Backbone.HasOne,
-            key: "to",
-            relatedModel: Node
-          }
-        ],
-        prepare: function(options) {
-            var project = options.project;
-            this.addReference(options, "created_by", project.get("users"), options.created_by, project.current_user);
-            this.addReference(options, "from", project.get("nodes"), options.from);
-            this.addReference(options, "to", project.get("nodes"), options.to);
-            return options;
-        },
-        toJSON: function() {
-            return {
-                _id: this.get("_id"),
-                title: this.get("title"),
-                uri: this.get("uri"),
-                description: this.get("description"),
-                from: this.get("from") ? this.get("from").get("_id") : null,
-                to: this.get("to") ? this.get("to").get("_id") : null,
-                color: this.get("color"),
-                created_by: this.get("created_by") ? this.get("created_by").get("_id") : null
-            };
-        }
-    });
-
-    // View
-    var View = Models.View = RenkanModel.extend({
-        type: "view",
-        relations: [
-            {
-                type: Backbone.HasOne,
-                key: "created_by",
-                relatedModel: User
-            }
-        ],
-        prepare: function(options) {
-            var project = options.project;
-            this.addReference(options, "created_by", project.get("users"), options.created_by, project.current_user);
-            options.description = options.description || "";
-            if(typeof options.offset !== "undefined") {
-                var offset = {};
-                if (Array.isArray(options.offset)) {
-                  offset.x = options.offset[0];
-                  offset.y = options.offset.length > 1 ? options.offset[1] : options.offset[0];
-                }
-                else if (options.offset.x != null) {
-                  offset.x = options.offset.x;
-                  offset.y = options.offset.y;
-                }
-                options.offset = offset;
-            }
-            return options;
-        },
-        toJSON: function() {
-            return {
-                _id: this.get("_id"),
-                zoom_level: this.get("zoom_level"),
-                offset: this.get("offset"),
-                title: this.get("title"),
-                description: this.get("description"),
-                created_by: this.get("created_by") ? this.get("created_by").get("_id") : null
-                // Don't need project id
-            };
-        }
-    });
-
-    // PROJECT
-    var Project = Models.Project = RenkanModel.extend({
-        type: "project",
-        relations: [
-          {
-            type: Backbone.HasMany,
-            key: "users",
-            relatedModel: User,
-            reverseRelation: {
-                key: 'project',
-                includeInJSON: '_id'
-            }
-          },
-          {
-            type: Backbone.HasMany,
-            key: "nodes",
-            relatedModel: Node,
-            reverseRelation: {
-                key: 'project',
-                includeInJSON: '_id'
-            }
-          },
-          {
-            type: Backbone.HasMany,
-            key: "edges",
-            relatedModel: Edge,
-            reverseRelation: {
-                key: 'project',
-                includeInJSON: '_id'
-            }
-          },
-          {
-            type: Backbone.HasMany,
-            key: "views",
-            relatedModel: View,
-            reverseRelation: {
-                key: 'project',
-                includeInJSON: '_id'
-            }
-          }
-        ],
-        addUser: function(_props, _options) {
-            _props.project = this;
-            var _user = User.findOrCreate(_props);
-            this.get("users").push(_user, _options);
-            return _user;
-        },
-        addNode: function(_props, _options) {
-            _props.project = this;
-            var _node = Node.findOrCreate(_props);
-            this.get("nodes").push(_node, _options);
-            return _node;
-        },
-        addEdge: function(_props, _options) {
-            _props.project = this;
-            var _edge = Edge.findOrCreate(_props);
-            this.get("edges").push(_edge, _options);
-            return _edge;
-        },
-        addView: function(_props, _options) {
-            _props.project = this;
-            // TODO: check if need to replace with create only
-            var _view = View.findOrCreate(_props);
-            // TODO: Should we remember only one view?
-            this.get("views").push(_view, _options);
-            return _view;
-        },
-        removeNode: function(_model) {
-            this.get("nodes").remove(_model);
-        },
-        removeEdge: function(_model) {
-            this.get("edges").remove(_model);
-        },
-        validate: function(options) {
-            var _project = this;
-            _([].concat(options.users, options.nodes, options.edges, options.views)).each(function(_item) {
-                if(_item) {
-                    _item.project = _project;
-                }
-            });
-        },
-        // Add event handler to remove edges when a node is removed
-        initialize: function() {
-            var _this = this;
-            this.on("remove:nodes", function(_node) {
-                _this.get("edges").remove(
-                    _this.get("edges").filter(function(_edge) {
-                        return _edge.get("from") === _node || _edge.get("to") === _node;
-                    })
-                );
-            });
-        }
-    });
-
-    var RosterUser = Models.RosterUser = Backbone.Model.extend({
-        type: "roster_user",
-        idAttribute : "_id",
-
-        constructor: function(options) {
-
-            if (typeof options !== "undefined") {
-                options._id = options._id || options.id || Models.getUID(this);
-                options.title = options.title || "(untitled " + this.type + ")";
-                options.description = options.description || "";
-                options.uri = options.uri || "";
-                options.project = options.project || null;
-                options.site_id = options.site_id || 0;
-
-                if(typeof this.prepare === "function") {
-                    options = this.prepare(options);
-                }
-            }
-            Backbone.Model.prototype.constructor.call(this, options);
-        },
-
-        validate: function() {
-            if(!this.type) {
-                return "object has no type";
-            }
-        },
-
-        prepare: function(options) {
-            options.color = options.color || "#666666";
-            return options;
-        },
-
-        toJSON: function() {
-            return {
-                _id: this.get("_id"),
-                title: this.get("title"),
-                uri: this.get("uri"),
-                description: this.get("description"),
-                color: this.get("color"),
-                project: (this.get("project") != null)?this.get("project").get("id"):null,
-                site_id: this.get("site_id")
-            };
-        }
-    });
-
-    var UsersList = Models.UsersList = Backbone.Collection.extend({
-        model: RosterUser
-    });
-
-
-}).call(window);
-
-Rkns.defaults = {
-
-    language: (navigator.language || navigator.userLanguage || "en"),
-        /* GUI Language */
-    container: "renkan",
-        /* GUI Container DOM element ID */
-    search: [],
-        /* List of Search Engines */
-    bins: [],
-           /* List of Bins */
-    static_url: "",
-        /* URL for static resources */
-    show_bins: true,
-        /* Show bins in left column */
-    properties: [],
-        /* Semantic properties for edges */
-    show_editor: true,
-        /* Show the graph editor... Setting this to "false" only shows the bins part ! */
-    read_only: false,
-        /* Allows editing of renkan without changing the rest of the GUI. Can be switched on/off on the fly to block/enable editing */
-    editor_mode: true,
-        /* Switch for Publish/Edit GUI. If editor_mode is false, read_only will be true.  */
-    snapshot_mode: false,
-        /* In snapshot mode, clicking on the floppy will save a snapshot. Otherwise, it will show the connection status */
-    show_top_bar: true,
-        /* Show the top bar, (title, buttons, users) */
-    default_user_color: "#303030",
-    size_bug_fix: true,
-        /* Resize the canvas after load (fixes a bug on iPad and FF Mac) */
-    force_resize: false,
-    allow_double_click: true,
-        /* Allows Double Click to create a node on an empty background */
-    zoom_on_scroll: true,
-        /* Allows to use the scrollwheel to zoom */
-    element_delete_delay: 0,
-        /* Delay between clicking on the bin on an element and really deleting it
-           Set to 0 for delete confirm */
-    autoscale_padding: 50,
-    default_view: false,
-	/* Allows to load default view (zoom+offset) at start on read_only mode, instead of autoScale. default_view has to be an integer 0,1,2... */
-
-    /* TOP BAR BUTTONS */
-    show_search_field: true,
-    show_user_list: true,
-    user_name_editable: true,
-    user_color_editable: true,
-    show_save_button: true,
-    show_export_button: true,
-    show_open_button: false,
-    show_addnode_button: true,
-    show_addedge_button: true,
-    show_bookmarklet: true,
-    show_fullscreen_button: true,
-    home_button_url: false,
-    home_button_title: "Home",
-
-    /* MINI-MAP OPTIONS */
-
-    show_minimap: true,
-        /* Show a small map at the bottom right */
-    minimap_width: 160,
-    minimap_height: 120,
-    minimap_padding: 20,
-    minimap_background_color: "#ffffff",
-    minimap_border_color: "#cccccc",
-    minimap_highlight_color: "#ffff00",
-    minimap_highlight_weight: 5,
-
-    /* EDGE/NODE COMMON OPTIONS */
-
-    buttons_background: "#202020",
-    buttons_label_color: "#c000c0",
-    buttons_label_font_size: 9,
-
-    /* NODE DISPLAY OPTIONS */
-
-    show_node_circles: true,
-        /* Show circles for nodes */
-    clip_node_images: true,
-        /* Constraint node images to circles */
-    node_images_fill_mode: false,
-        /* Set to false for "letterboxing" (height/width of node adapted to show full image)
-           Set to true for "crop" (adapted to fill circle) */
-    node_size_base: 25,
-    node_stroke_width: 2,
-    selected_node_stroke_width: 4,
-    node_fill_color: "#ffffff",
-    highlighted_node_fill_color: "#ffff00",
-    node_label_distance: 5,
-        /* Vertical distance between node and label */
-    node_label_max_length: 60,
-        /* Maximum displayed text length */
-    label_untitled_nodes: "(untitled)",
-        /* Label to display on untitled nodes */
-
-    /* EDGE DISPLAY OPTIONS */
-
-    edge_stroke_width: 2,
-    selected_edge_stroke_width: 4,
-    edge_label_distance: 0,
-    edge_label_max_length: 20,
-    edge_arrow_length: 18,
-    edge_arrow_width: 12,
-    edge_gap_in_bundles: 12,
-    label_untitled_edges: "",
-
-    /* CONTEXTUAL DISPLAY (TOOLTIP OR EDITOR) OPTIONS */
-
-    tooltip_width: 275,
-    tooltip_padding: 10,
-    tooltip_margin: 15,
-    tooltip_arrow_length : 20,
-    tooltip_arrow_width : 40,
-    tooltip_top_color: "#f0f0f0",
-    tooltip_bottom_color: "#d0d0d0",
-    tooltip_border_color: "#808080",
-    tooltip_border_width: 1,
-
-    /* NODE EDITOR OPTIONS */
-
-    show_node_editor_uri: true,
-    show_node_editor_description: true,
-    show_node_editor_size: true,
-    show_node_editor_color: true,
-    show_node_editor_image: true,
-    show_node_editor_creator: true,
-    uploaded_image_max_kb: 500,
-
-    /* NODE TOOLTIP OPTIONS */
-
-    show_node_tooltip_uri: true,
-    show_node_tooltip_description: true,
-    show_node_tooltip_color: true,
-    show_node_tooltip_image: true,
-    show_node_tooltip_creator: true,
-
-    /* EDGE EDITOR OPTIONS */
-
-    show_edge_editor_uri: true,
-    show_edge_editor_color: true,
-    show_edge_editor_direction: true,
-    show_edge_editor_nodes: true,
-    show_edge_editor_creator: true,
-
-    /* EDGE TOOLTIP OPTIONS */
-
-    show_edge_tooltip_uri: true,
-    show_edge_tooltip_color: true,
-    show_edge_tooltip_nodes: true,
-    show_edge_tooltip_creator: true
-
-    /* */
-
-};
-
-Rkns.i18n = {
-    fr: {
-        "Edit Node": "Édition d’un nœud",
-        "Edit Edge": "Édition d’un lien",
-        "Title:": "Titre :",
-        "URI:": "URI :",
-        "Description:": "Description :",
-        "From:": "De :",
-        "To:": "Vers :",
-        "Image": "Image",
-        "Image URL:": "URL d'Image",
-        "Choose Image File:": "Choisir un fichier image",
-        "Full Screen": "Mode plein écran",
-        "Add Node": "Ajouter un nœud",
-        "Add Edge": "Ajouter un lien",
-        "Save Project": "Enregistrer le projet",
-        "Open Project": "Ouvrir un projet",
-        "Auto-save enabled": "Enregistrement automatique activé",
-        "Connection lost": "Connexion perdue",
-        "Created by:": "Créé par :",
-        "Zoom In": "Agrandir l’échelle",
-        "Zoom Out": "Rapetisser l’échelle",
-        "Edit": "Éditer",
-        "Remove": "Supprimer",
-        "Cancel deletion": "Annuler la suppression",
-        "Link to another node": "Créer un lien",
-        "Enlarge": "Agrandir",
-        "Shrink": "Rétrécir",
-        "Click on the background canvas to add a node": "Cliquer sur le fond du graphe pour rajouter un nœud",
-        "Click on a first node to start the edge": "Cliquer sur un premier nœud pour commencer le lien",
-        "Click on a second node to complete the edge": "Cliquer sur un second nœud pour terminer le lien",
-        "Wikipedia": "Wikipédia",
-        "Wikipedia in ": "Wikipédia en ",
-        "French": "Français",
-        "English": "Anglais",
-        "Japanese": "Japonais",
-        "Untitled project": "Projet sans titre",
-        "Lignes de Temps": "Lignes de Temps",
-        "Loading, please wait": "Chargement en cours, merci de patienter",
-        "Edge color:": "Couleur :",
-        "Node color:": "Couleur :",
-        "Choose color": "Choisir une couleur",
-        "Change edge direction": "Changer le sens du lien",
-        "Do you really wish to remove node ": "Voulez-vous réellement supprimer le nœud ",
-        "Do you really wish to remove edge ": "Voulez-vous réellement supprimer le lien ",
-        "This file is not an image": "Ce fichier n'est pas une image",
-        "Image size must be under ": "L'image doit peser moins de ",
-        "Size:": "Taille :",
-        "KB": "ko",
-        "Choose from vocabulary:": "Choisir dans un vocabulaire :",
-        "SKOS Documentation properties": "SKOS: Propriétés documentaires",
-        "has note": "a pour note",
-        "has example": "a pour exemple",
-        "has definition": "a pour définition",
-        "SKOS Semantic relations": "SKOS: Relations sémantiques",
-        "has broader": "a pour concept plus large",
-        "has narrower": "a pour concept plus étroit",
-        "has related": "a pour concept apparenté",
-        "Dublin Core Metadata": "Métadonnées Dublin Core",
-        "has contributor": "a pour contributeur",
-        "covers": "couvre",
-        "created by": "créé par",
-        "has date": "a pour date",
-        "published by": "édité par",
-        "has source": "a pour source",
-        "has subject": "a pour sujet",
-        "Dragged resource": "Ressource glisée-déposée",
-        "Search the Web": "Rechercher en ligne",
-        "Search in Bins": "Rechercher dans les chutiers",
-        "Close bin": "Fermer le chutier",
-        "Refresh bin": "Rafraîchir le chutier",
-        "(untitled)": "(sans titre)",
-        "Select contents:": "Sélectionner des contenus :",
-        "Drag items from this website, drop them in Renkan": "Glissez des éléments de ce site web vers Renkan",
-        "Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.": "Glissez ce bouton vers votre barre de favoris. Ensuite, depuis un site tiers, cliquez dessus pour activer 'Drag-to-Add' puis glissez des éléments de ce site vers Renkan"
-    }
-};
-
-/* Saves the Full JSON at each modification */
-
-Rkns.jsonIO = function(_renkan, _opts) {
-    var _proj = _renkan.project;
-    if (typeof _opts.http_method === "undefined") {
-        _opts.http_method = 'PUT';
-    }
-    var _load = function() {
-        _renkan.renderer.redrawActive = false;
-        Rkns.$.getJSON(_opts.url, function(_data) {
-            _proj.set(_data, {validate: true});
-            _renkan.renderer.redrawActive = true;
-            _renkan.renderer.autoScale();
-        });
-    };
-    var _save = function() {
-        var _data = _proj.toJSON();
-        if (!_renkan.read_only) {
-            Rkns.$.ajax({
-                type: _opts.http_method,
-                url: _opts.url,
-                contentType: "application/json",
-                data: JSON.stringify(_data),
-                success: function(data, textStatus, jqXHR) {
-                }
-            });
-        }
-
-    };
-    var _thrSave = Rkns._.throttle(
-        function() {
-            setTimeout(_save, 100);
-        }, 1000);
-    _proj.on("add:nodes add:edges add:users add:views", function(_model) {
-        _model.on("change remove", function(_model) {
-            _thrSave();
-        });
-        _thrSave();
-    });
-    _proj.on("change", function() {
-        _thrSave();
-    });
-
-    _load();
-};
-
-(function(Rkns) {
-"use strict";
-
-var _ = Rkns._;
-
-var Ldt = Rkns.Ldt = {};
-
-var Bin = Ldt.Bin = function(_renkan, _opts) {
-    if (_opts.ldt_type) {
-        var Resclass = Ldt[_opts.ldt_type+"Bin"];
-        if (Resclass) {
-            return new Resclass(_renkan, _opts);
-        }
-    }
-    console.error("No such LDT Bin Type");
-};
-
-var ProjectBin = Ldt.ProjectBin = Rkns.Utils.inherit(Rkns._BaseBin);
-
-ProjectBin.prototype.tagTemplate = _.template(
-    '<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(static_url+\'img/ldt-tag.png\') %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/search/?search=<%=encodedtitle%>&field=all" data-title="<%-title%>" data-description="Tag \'<%-title%>\'">' +
-    '<img class="Rk-Ldt-Tag-Icon" src="<%-static_url%>img/ldt-tag.png" /><h4><%=htitle%></h4><div class="Rk-Clear"></div></li>'
-);
-
-ProjectBin.prototype.annotationTemplate = _.template(
-    '<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(image) %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>">' +
-    '<img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class="Rk-Clear"></div></li>'
-);
-
-ProjectBin.prototype._init = function(_renkan, _opts) {
-    this.renkan = _renkan;
-    this.proj_id = _opts.project_id;
-    this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/";
-    this.title_$.html(_opts.title);
-    this.title_icon_$.addClass('Rk-Ldt-Title-Icon');
-    this.refresh();
-};
-
-ProjectBin.prototype.render = function(searchbase) {
-    var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
-    function highlight(_text) {
-        var _e = _(_text).escape();
-        return search.isempty ? _e : search.replace(_e, "<span class='searchmatch'>$1</span>");
-    }
-    function convertTC(_ms) {
-        function pad(_n) {
-            var _res = _n.toString();
-            while (_res.length < 2) {
-                _res = '0' + _res;
-            }
-            return _res;
-        }
-        var _totalSeconds = Math.abs(Math.floor(_ms/1000)),
-            _hours = Math.floor(_totalSeconds / 3600),
-            _minutes = (Math.floor(_totalSeconds / 60) % 60),
-            _seconds = _totalSeconds % 60,
-            _res = '';
-        if (_hours) {
-            _res += pad(_hours) + ':';
-        }
-        _res += pad(_minutes) + ':' + pad(_seconds);
-        return _res;
-    }
-
-    var _html = '<li><h3>Tags</h3></li>',
-        _projtitle = this.data.meta["dc:title"],
-        _this = this,
-        count = 0;
-    _this.title_$.text('LDT Project: "' + _projtitle + '"');
-    _(_this.data.tags).map(function(_tag) {
-        var _title = _tag.meta["dc:title"];
-        if (!search.isempty && !search.test(_title)) {
-            return;
-        }
-        count++;
-        _html += _this.tagTemplate({
-            ldt_platform: _this.ldt_platform,
-            title: _title,
-            htitle: highlight(_title),
-            encodedtitle : encodeURIComponent(_title),
-            static_url: _this.renkan.options.static_url
-        });
-    });
-    _html += '<li><h3>Annotations</h3></li>';
-    _(_this.data.annotations).map(function(_annotation) {
-        var _description = _annotation.content.description,
-            _title = _annotation.content.title.replace(_description,"");
-        if (!search.isempty && !search.test(_title) && !search.test(_description)) {
-            return;
-        }
-        count++;
-        var _duration = _annotation.end - _annotation.begin,
-            _img = (
-                (_annotation.content && _annotation.content.img && _annotation.content.img.src) ?
-                  _annotation.content.img.src :
-                  ( _duration ? _this.renkan.options.static_url+"img/ldt-segment.png" : _this.renkan.options.static_url+"img/ldt-point.png" )
-            );
-        _html += _this.annotationTemplate({
-            ldt_platform: _this.ldt_platform,
-            title: _title,
-            htitle: highlight(_title),
-            description: _description,
-            hdescription: highlight(_description),
-            start: convertTC(_annotation.begin),
-            end: convertTC(_annotation.end),
-            duration: convertTC(_duration),
-            mediaid: _annotation.media,
-            annotationid: _annotation.id,
-            image: _img,
-            static_url: _this.renkan.options.static_url
-        });
-    });
-
-    this.main_$.html(_html);
-    if (!search.isempty && count) {
-        this.count_$.text(count).show();
-    } else {
-        this.count_$.hide();
-    }
-    if (!search.isempty && !count) {
-        this.$.hide();
-    } else {
-        this.$.show();
-    }
-    this.renkan.resizeBins();
-};
-
-ProjectBin.prototype.refresh = function() {
-    var _this = this;
-    Rkns.$.ajax({
-        url: this.ldt_platform + 'ldtplatform/ldt/cljson/id/' + this.proj_id,
-        dataType: "jsonp",
-        success: function(_data) {
-            _this.data = _data;
-            _this.render();
-        }
-    });
-};
-
-var Search = Ldt.Search = function(_renkan, _opts) {
-    this.renkan = _renkan;
-    this.lang = _opts.lang || "en";
-};
-
-Search.prototype.getBgClass = function() {
-    return "Rk-Ldt-Icon";
-};
-
-Search.prototype.getSearchTitle = function() {
-    return this.renkan.translate("Lignes de Temps");
-};
-
-Search.prototype.search = function(_q) {
-    this.renkan.tabs.push(
-        new ResultsBin(this.renkan, {
-            search: _q
-        })
-    );
-};
-
-var ResultsBin = Ldt.ResultsBin = Rkns.Utils.inherit(Rkns._BaseBin);
-
-ResultsBin.prototype.segmentTemplate = _.template(
-    '<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(image) %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>">' +
-    '<img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class="Rk-Clear"></div></li>'
-);
-
-ResultsBin.prototype._init = function(_renkan, _opts) {
-    this.renkan = _renkan;
-    this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/";
-    this.max_results = _opts.max_results || 50;
-    this.search = _opts.search;
-    this.title_$.html('Lignes de Temps: "' + _opts.search + '"');
-    this.title_icon_$.addClass('Rk-Ldt-Title-Icon');
-    this.refresh();
-};
-
-ResultsBin.prototype.render = function(searchbase) {
-    if (!this.data) {
-        return;
-    }
-    var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
-    var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);
-    function highlight(_text) {
-        return highlightrx.replace(_(_text).escape(), "<span class='searchmatch'>$1</span>");
-    }
-    function convertTC(_ms) {
-        function pad(_n) {
-            var _res = _n.toString();
-            while (_res.length < 2) {
-                _res = '0' + _res;
-            }
-            return _res;
-        }
-        var _totalSeconds = Math.abs(Math.floor(_ms/1000)),
-            _hours = Math.floor(_totalSeconds / 3600),
-            _minutes = (Math.floor(_totalSeconds / 60) % 60),
-            _seconds = _totalSeconds % 60,
-            _res = '';
-        if (_hours) {
-            _res += pad(_hours) + ':';
-        }
-        _res += pad(_minutes) + ':' + pad(_seconds);
-        return _res;
-    }
-
-    var _html = '',
-        _this = this,
-        count = 0;
-    _(this.data.objects).each(function(_segment) {
-        var _description = _segment.abstract,
-            _title = _segment.title;
-        if (!search.isempty && !search.test(_title) && !search.test(_description)) {
-            return;
-        }
-        count++;
-        var _duration = _segment.duration,
-            _begin = _segment.start_ts,
-            _end = + _segment.duration + _begin,
-            _img = (
-                _duration ?
-                  _this.renkan.options.static_url + "img/ldt-segment.png" :
-                  _this.renkan.options.static_url + "img/ldt-point.png"
-            );
-        _html += _this.segmentTemplate({
-            ldt_platform: _this.ldt_platform,
-            title: _title,
-            htitle: highlight(_title),
-            description: _description,
-            hdescription: highlight(_description),
-            start: convertTC(_begin),
-            end: convertTC(_end),
-            duration: convertTC(_duration),
-            mediaid: _segment.iri_id,
-            //projectid: _segment.project_id,
-            //cuttingid: _segment.cutting_id,
-            annotationid: _segment.element_id,
-            image: _img
-        });
-    });
-
-    this.main_$.html(_html);
-    if (!search.isempty && count) {
-        this.count_$.text(count).show();
-    } else {
-        this.count_$.hide();
-    }
-    if (!search.isempty && !count) {
-        this.$.hide();
-    } else {
-        this.$.show();
-    }
-    this.renkan.resizeBins();
-};
-
-ResultsBin.prototype.refresh = function() {
-    var _this = this;
-    Rkns.$.ajax({
-        url: this.ldt_platform + 'ldtplatform/api/ldt/1.0/segments/search/',
-        data: {
-            format: "jsonp",
-            q: this.search,
-            limit: this.max_results
-        },
-        dataType: "jsonp",
-        success: function(_data) {
-            _this.data = _data;
-            _this.render();
-        }
-    });
-};
-
-})(window.Rkns);
-
-Rkns.ResourceList = {};
-
-Rkns.ResourceList.Bin = Rkns.Utils.inherit(Rkns._BaseBin);
-
-Rkns.ResourceList.Bin.prototype.resultTemplate = Rkns._.template(
-    '<li class="Rk-Bin-Item Rk-ResourceList-Item" draggable="true" data-uri="<%-url%>" ' +
-    'data-title="<%-title%>" data-description="<%-description%>" ' +
-    '<% if (image) { %>data-image="<%- Rkns.Utils.getFullURL(image) %>"<% } else { %>data-image=""<% } %> >' +
-    '<% if (image) { %><img class="Rk-ResourceList-Image" src="<%-image%>"/><% } %><h4 class="Rk-ResourceList-Title">' +
-    '<% if (url) { %><a href="<%-url%>" target="_blank"><% } %><%=htitle%><% if (url) { %></a><% } %></h4>' +
-    '<% if (description) { %><p class="Rk-ResourceList-Description"><%=hdescription%></p><% } %><% if (image) { %><div style="clear: both;"></div><% } %></li>'
-);
-
-Rkns.ResourceList.Bin.prototype._init = function(_renkan, _opts) {
-    this.renkan = _renkan;
-    this.title_$.html(_opts.title);
-    if (_opts.list) {
-        this.data = _opts.list;
-    }
-    this.refresh();
-};
-
-Rkns.ResourceList.Bin.prototype.render = function(searchbase) {
-    var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
-    function highlight(_text) {
-        var _e = _(_text).escape();
-        return search.isempty ? _e : search.replace(_e, "<span class='searchmatch'>$1</span>");
-    }
-    var _html = "",
-        _this = this,
-        count = 0;
-    Rkns._(this.data).each(function(_item) {
-        var _element;
-        if (typeof _item === "string") {
-            if (/^(https?:\/\/|www)/.test(_item)) {
-                _element = { url: _item };
-            } else {
-                _element = { title: _item.replace(/[:,]?\s?(https?:\/\/|www)[\d\w\/.&?=#%-_]+\s?/,'').trim() };
-                var _match = _item.match(/(https?:\/\/|www)[\d\w\/.&?=#%-_]+/);
-                if (_match) {
-                    _element.url = _match[0];
-                }
-                if (_element.title.length > 80) {
-                    _element.description = _element.title;
-                    _element.title = _element.title.replace(/^(.{30,60})\s.+$/,'$1…');
-                }
-            }
-        } else {
-            _element = _item;
-        }
-        var title = _element.title || (_element.url || "").replace(/^https?:\/\/(www\.)?/,'').replace(/^(.{40}).+$/,'$1…'),
-            url = _element.url || "",
-            description = _element.description || "",
-            image = _element.image || "";
-        if (url && !/^https?:\/\//.test(url)) {
-            url = 'http://' + url;
-        }
-        if (!search.isempty && !search.test(title) && !search.test(description)) {
-            return;
-        }
-        count++;
-        _html += _this.resultTemplate({
-            url: url,
-            title: title,
-            htitle: highlight(title),
-            image: image,
-            description: description,
-            hdescription: highlight(description),
-            static_url: _this.renkan.options.static_url
-        });
-    });
-    _this.main_$.html(_html);
-    if (!search.isempty && count) {
-        this.count_$.text(count).show();
-    } else {
-        this.count_$.hide();
-    }
-    if (!search.isempty && !count) {
-        this.$.hide();
-    } else {
-        this.$.show();
-    }
-    this.renkan.resizeBins();
-};
-
-Rkns.ResourceList.Bin.prototype.refresh = function() {
-    if (this.data) {
-        this.render();
-    }
-};
-
-Rkns.Wikipedia = {
-};
-
-Rkns.Wikipedia.Search = function(_renkan, _opts) {
-    this.renkan = _renkan;
-    this.lang = _opts.lang || "en";
-};
-
-Rkns.Wikipedia.Search.prototype.getBgClass = function() {
-    return "Rk-Wikipedia-Search-Icon Rk-Wikipedia-Lang-" + this.lang;
-};
-
-Rkns.Wikipedia.Search.prototype.getSearchTitle = function() {
-    var langs = {
-        "fr": "French",
-        "en": "English",
-        "ja": "Japanese"
-    };
-    if (langs[this.lang]) {
-        return this.renkan.translate("Wikipedia in ") + this.renkan.translate(langs[this.lang]);
-    } else {
-        return this.renkan.translate("Wikipedia") + " [" + this.lang + "]";
-    }
-};
-
-Rkns.Wikipedia.Search.prototype.search = function(_q) {
-    this.renkan.tabs.push(
-        new Rkns.Wikipedia.Bin(this.renkan, {
-            lang: this.lang,
-            search: _q
-        })
-    );
-};
-
-Rkns.Wikipedia.Bin = Rkns.Utils.inherit(Rkns._BaseBin);
-
-Rkns.Wikipedia.Bin.prototype.resultTemplate = Rkns._.template(
-    '<li class="Rk-Wikipedia-Result Rk-Bin-Item" draggable="true" data-uri="<%-url%>" ' +
-    'data-title="Wikipedia: <%-title%>" data-description="<%-description%>" data-image="<%- Rkns.Utils.getFullURL( static_url + \'img/wikipedia.png\' ) %>">' +
-    '<img class="Rk-Wikipedia-Icon" src="<%-static_url%>img/wikipedia.png"></div><h4 class="Rk-Wikipedia-Title"><a href="<%-url%>" target="_blank"><%=htitle%></a></h4>' +
-    '<p class="Rk-Wikipedia-Snippet"><%=hdescription%></p></li>'
-);
-
-Rkns.Wikipedia.Bin.prototype._init = function(_renkan, _opts) {
-    this.renkan = _renkan;
-    this.search = _opts.search;
-    this.lang = _opts.lang || "en";
-    this.title_icon_$.addClass('Rk-Wikipedia-Title-Icon Rk-Wikipedia-Lang-' + this.lang);
-    this.title_$.html(this.search).addClass("Rk-Wikipedia-Title");
-    this.refresh();
-};
-
-Rkns.Wikipedia.Bin.prototype.render = function(searchbase) {
-    var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
-    var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);
-    function highlight(_text) {
-        return highlightrx.replace(_(_text).escape(), "<span class='searchmatch'>$1</span>");
-    }
-    var _html = "",
-        _this = this,
-        count = 0;
-    Rkns._(this.data.query.search).each(function(_result) {
-        var title = _result.title,
-            url = "http://" + _this.lang + ".wikipedia.org/wiki/" + encodeURI(title.replace(/ /g,"_")),
-            description = Rkns.$('<div>').html(_result.snippet).text();
-        if (!search.isempty && !search.test(title) && !search.test(description)) {
-            return;
-        }
-        count++;
-        _html += _this.resultTemplate({
-            url: url,
-            title: title,
-            htitle: highlight(title),
-            description: description,
-            hdescription: highlight(description),
-            static_url: _this.renkan.options.static_url
-        });
-    });
-    _this.main_$.html(_html);
-    if (!search.isempty && count) {
-        this.count_$.text(count).show();
-    } else {
-        this.count_$.hide();
-    }
-    if (!search.isempty && !count) {
-        this.$.hide();
-    } else {
-        this.$.show();
-    }
-    this.renkan.resizeBins();
-};
-
-Rkns.Wikipedia.Bin.prototype.refresh = function() {
-    var _this = this;
-    Rkns.$.ajax({
-        url: "http://" + _this.lang + ".wikipedia.org/w/api.php?action=query&list=search&srsearch=" + encodeURIComponent(this.search) + "&format=json",
-        dataType: "jsonp",
-        success: function(_data) {
-            _this.data = _data;
-            _this.render();
-        }
-    });
-};
-
-
-define('renderer/baserepresentation',['jquery', 'underscore'], function ($, _) {
-    
-
-    /* Rkns.Renderer._BaseRepresentation Class */
-
-    /* In Renkan, a "Representation" is a sort of ViewModel (in the MVVM paradigm) and bridges the gap between
-     * models (written with Backbone.js) and the view (written with Paper.js)
-     * Renkan's representations all inherit from Rkns.Renderer._BaseRepresentation '*/
-
-    var _BaseRepresentation = function(_renderer, _model) {
-        if (typeof _renderer !== "undefined") {
-            this.renderer = _renderer;
-            this.renkan = _renderer.renkan;
-            this.project = _renderer.renkan.project;
-            this.options = _renderer.renkan.options;
-            this.model = _model;
-            if (this.model) {
-                var _this = this;
-                this._changeBinding = function() {
-                    _this.redraw();
-                };
-                this._removeBinding = function() {
-                    _renderer.removeRepresentation(_this);
-                    _(function() {
-                        _renderer.redraw();
-                    }).defer();
-                };
-                this._selectBinding = function() {
-                    _this.select();
-                };
-                this._unselectBinding = function() {
-                    _this.unselect();
-                };
-                this.model.on("change", this._changeBinding );
-                this.model.on("remove", this._removeBinding );
-                this.model.on("select", this._selectBinding );
-                this.model.on("unselect", this._unselectBinding );
-            }
-        }
-    };
-
-    /* Rkns.Renderer._BaseRepresentation Methods */
-
-    _(_BaseRepresentation.prototype).extend({
-        _super: function(_func) {
-            return _BaseRepresentation.prototype[_func].apply(this, Array.prototype.slice.call(arguments, 1));
-        },
-        redraw: function() {},
-        moveTo: function() {},
-        show: function() { return "chaud cacao"; },
-        hide: function() {},
-        select: function() {
-            if (this.model) {
-                this.model.trigger("selected");
-            }
-        },
-        unselect: function() {
-            if (this.model) {
-                this.model.trigger("unselected");
-            }
-        },
-        highlight: function() {},
-        unhighlight: function() {},
-        mousedown: function() {},
-        mouseup: function() {
-            if (this.model) {
-                this.model.trigger("clicked");
-            }
-        },
-        destroy: function() {
-            if (this.model) {
-                this.model.off("change", this._changeBinding );
-                this.model.off("remove", this._removeBinding );
-                this.model.off("select", this._selectBinding );
-                this.model.off("unselect", this._unselectBinding );
-            }
-        }
-    });
-
-    /* End of Rkns.Renderer._BaseRepresentation Class */
-
-    return _BaseRepresentation;
-
-});
-
-define('requtils',[], function ($, _) {
-    
-    return {
-        getUtils: function(){
-            return window.Rkns.Utils;
-        },
-        getRenderer: function(){
-            return window.Rkns.Renderer;
-        }
-    };
-
-});
-
-
-define('renderer/basebutton',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* Rkns.Renderer._BaseButton Class */
-
-    /* BaseButton is extended by contextual buttons that appear when hovering on nodes and edges */
-
-    var _BaseButton = Utils.inherit(BaseRepresentation);
-
-    _(_BaseButton.prototype).extend({
-        moveTo: function(_pos) {
-            this.sector.moveTo(_pos);
-        },
-        show: function() {
-            this.sector.show();
-        },
-        hide: function() {
-            this.sector.hide();
-        },
-        select: function() {
-            this.sector.select();
-        },
-        unselect: function(_newTarget) {
-            this.sector.unselect();
-            if (!_newTarget || (_newTarget !== this.source_representation && _newTarget.source_representation !== this.source_representation)) {
-                this.source_representation.unselect();
-            }
-        },
-        destroy: function() {
-            this.sector.destroy();
-        }
-    });
-
-    return _BaseButton;
-
-});
-
-
-
-define('renderer/noderepr',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* Rkns.Renderer.Node Class */
-
-    /* The representation for the node : A circle, with an image inside and a text label underneath.
-     * The circle and the image are drawn on canvas and managed by Paper.js.
-     * The text label is an HTML node, managed by jQuery. */
-
-    //var NodeRepr = Renderer.Node = Utils.inherit(Renderer._BaseRepresentation);
-    var NodeRepr = Utils.inherit(BaseRepresentation);
-
-    _(NodeRepr.prototype).extend({
-        _init: function() {
-            this.renderer.node_layer.activate();
-            this.type = "Node";
-            this.circle = new paper.Path.Circle([0, 0], 1);
-            this.circle.__representation = this;
-            if (this.options.show_node_circles) {
-                this.circle.strokeWidth = this.options.node_stroke_width;
-                this.h_ratio = 1;
-            } else {
-                this.h_ratio = 0;
-            }
-            this.title = $('<div class="Rk-Label">').appendTo(this.renderer.labels_$);
-            if (this.options.editor_mode) {
-                var Renderer = requtils.getRenderer();
-                this.normal_buttons = [
-                                       new Renderer.NodeEditButton(this.renderer, null),
-                                       new Renderer.NodeRemoveButton(this.renderer, null),
-                                       new Renderer.NodeLinkButton(this.renderer, null),
-                                       new Renderer.NodeEnlargeButton(this.renderer, null),
-                                       new Renderer.NodeShrinkButton(this.renderer, null)
-                                       ];
-                this.pending_delete_buttons = [
-                                               new Renderer.NodeRevertButton(this.renderer, null)
-                                               ];
-                this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons);
-                for (var i = 0; i < this.all_buttons.length; i++) {
-                    this.all_buttons[i].source_representation = this;
-                }
-                this.active_buttons = [];
-            } else {
-                this.active_buttons = this.all_buttons = [];
-            }
-            this.last_circle_radius = 1;
-
-            if (this.renderer.minimap) {
-                this.renderer.minimap.node_layer.activate();
-                this.minimap_circle = new paper.Path.Circle([0, 0], 1);
-                this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation;
-                this.renderer.minimap.node_group.addChild(this.minimap_circle);
-            }
-        },
-        redraw: function(_dontRedrawEdges) {
-            var _model_coords = new paper.Point(this.model.get("position")),
-            _baseRadius = this.options.node_size_base * Math.exp((this.model.get("size") || 0) * Utils._NODE_SIZE_STEP);
-            if (!this.is_dragging || !this.paper_coords) {
-                this.paper_coords = this.renderer.toPaperCoords(_model_coords);
-            }
-            this.circle_radius = _baseRadius * this.renderer.scale;
-            if (this.last_circle_radius !== this.circle_radius) {
-                this.all_buttons.forEach(function(b) {
-                    b.setSectorSize();
-                });
-                this.circle.scale(this.circle_radius / this.last_circle_radius);
-                if (this.node_image) {
-                    this.node_image.scale(this.circle_radius / this.last_circle_radius);
-                }
-            }
-            this.circle.position = this.paper_coords;
-            if (this.node_image) {
-                this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius));
-            }
-            this.last_circle_radius = this.circle_radius;
-
-            var old_act_btn = this.active_buttons;
-
-            var opacity = 1;
-            if (this.model.get("delete_scheduled")) {
-                opacity = 0.5;
-                this.active_buttons = this.pending_delete_buttons;
-                this.circle.dashArray = [2,2];
-            } else {
-                opacity = 1;
-                this.active_buttons = this.normal_buttons;
-                this.circle.dashArray = null;
-            }
-
-            if (this.selected && this.renderer.isEditable()) {
-                if (old_act_btn !== this.active_buttons) {
-                    old_act_btn.forEach(function(b) {
-                        b.hide();
-                    });
-                }
-                this.active_buttons.forEach(function(b) {
-                    b.show();
-                });
-            }
-
-            if (this.node_image) {
-                this.node_image.opacity = this.highlighted ? opacity * 0.5 : (opacity - 0.01);
-            }
-
-            this.circle.fillColor = this.highlighted ? this.options.highlighted_node_fill_color : this.options.node_fill_color;
-
-            this.circle.opacity = this.options.show_node_circles ? opacity : 0.01;
-
-            var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_nodes) || "";
-            _text = Utils.shortenText(_text, this.options.node_label_max_length);
-
-            if (typeof this.highlighted === "object") {
-                this.title.html(this.highlighted.replace(_(_text).escape(),'<span class="Rk-Highlighted">$1</span>'));
-            } else {
-                this.title.text(_text);
-            }
-
-            this.title.css({
-                left: this.paper_coords.x,
-                top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance,
-                opacity: opacity
-            });
-            var _color = this.model.get("color") || (this.model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color");
-            this.circle.strokeColor = _color;
-            var _pc = this.paper_coords;
-            this.all_buttons.forEach(function(b) {
-                b.moveTo(_pc);
-            });
-            var lastImage = this.img;
-            this.img = this.model.get("image");
-            if (this.img && this.img !== lastImage) {
-                this.showImage();
-            }
-            if (this.node_image && !this.img) {
-                this.node_image.remove();
-                delete this.node_image;
-            }
-
-            if (this.renderer.minimap) {
-                this.minimap_circle.fillColor = _color;
-                var minipos = this.renderer.toMinimapCoords(_model_coords),
-                miniradius = this.renderer.minimap.scale * _baseRadius,
-                minisize = new paper.Size([miniradius, miniradius]);
-                this.minimap_circle.fitBounds(minipos.subtract(minisize), minisize.multiply(2));
-            }
-
-            if (!_dontRedrawEdges) {
-                var _this = this;
-                _.each(
-                        this.project.get("edges").filter(
-                                function (ed) {
-                                    return ((ed.get("to") === _this.model) || (ed.get("from") === _this.model));
-                                }
-                        ),
-                        function(edge, index, list) {
-                            var repr = _this.renderer.getRepresentationByModel(edge);
-                            if (repr && typeof repr.from_representation !== "undefined" && typeof repr.from_representation.paper_coords !== "undefined" && typeof repr.to_representation !== "undefined" && typeof repr.to_representation.paper_coords !== "undefined") {
-                                repr.redraw();
-                            }
-                        }
-                );
-            }
-
-        },
-        showImage: function() {
-            var _image = null;
-            if (typeof this.renderer.image_cache[this.img] === "undefined") {
-                _image = new Image();
-                this.renderer.image_cache[this.img] = _image;
-                _image.src = this.img;
-            } else {
-                _image = this.renderer.image_cache[this.img];
-            }
-            if (_image.width) {
-                if (this.node_image) {
-                    this.node_image.remove();
-                }
-                this.renderer.node_layer.activate();
-                var width = _image.width,
-                height = _image.height,
-                clipPath = this.model.get("clip_path"),
-                hasClipPath = (typeof clipPath !== "undefined" && clipPath),
-                _clip = null,
-                baseRadius = null,
-                centerPoint = null;
-
-                if (hasClipPath) {
-                    _clip = new paper.Path();
-                    var instructions = clipPath.match(/[a-z][^a-z]+/gi) || [],
-                    lastCoords = [0,0],
-                    minX = Infinity,
-                    minY = Infinity,
-                    maxX = -Infinity,
-                    maxY = -Infinity;
-
-                    var transformCoords = function(tabc, relative) {
-                        var newCoords = tabc.slice(1).map(function(v, k) {
-                            var res = parseFloat(v),
-                            isY = k % 2;
-                            if (isY) {
-                                res = ( res - 0.5 ) * height;
-                            } else {
-                                res = ( res - 0.5 ) * width;
-                            }
-                            if (relative) {
-                                res += lastCoords[isY];
-                            }
-                            if (isY) {
-                                minY = Math.min(minY, res);
-                                maxY = Math.max(maxY, res);
-                            } else {
-                                minX = Math.min(minX, res);
-                                maxX = Math.max(maxX, res);
-                            }
-                            return res;
-                        });
-                        lastCoords = newCoords.slice(-2);
-                        return newCoords;
-                    };
-
-                    instructions.forEach(function(instr) {
-                        var coords = instr.match(/([a-z]|[0-9.-]+)/ig) || [""];
-                        switch(coords[0]) {
-                        case "M":
-                            _clip.moveTo(transformCoords(coords));
-                            break;
-                        case "m":
-                            _clip.moveTo(transformCoords(coords, true));
-                            break;
-                        case "L":
-                            _clip.lineTo(transformCoords(coords));
-                            break;
-                        case "l":
-                            _clip.lineTo(transformCoords(coords, true));
-                            break;
-                        case "C":
-                            _clip.cubicCurveTo(transformCoords(coords));
-                            break;
-                        case "c":
-                            _clip.cubicCurveTo(transformCoords(coords, true));
-                            break;
-                        case "Q":
-                            _clip.quadraticCurveTo(transformCoords(coords));
-                            break;
-                        case "q":
-                            _clip.quadraticCurveTo(transformCoords(coords, true));
-                            break;
-                        }
-                    });
-
-                    baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](maxX - minX, maxY - minY) / 2;
-                    centerPoint = new paper.Point((maxX + minX) / 2, (maxY + minY) / 2);
-                    if (!this.options.show_node_circles) {
-                        this.h_ratio = (maxY - minY) / (2 * baseRadius);
-                    }
-                } else {
-                    baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](width, height) / 2;
-                    centerPoint = new paper.Point(0,0);
-                    if (!this.options.show_node_circles) {
-                        this.h_ratio = height / (2 * baseRadius);
-                    }
-                }
-                var _raster = new paper.Raster(_image);
-                _raster.locked = true; // Disable mouse events on icon
-                if (hasClipPath) {
-                    _raster = new paper.Group(_clip, _raster);
-                    _raster.opacity = 0.99;
-                    /* This is a workaround to allow clipping at group level
-                     * If opacity was set to 1, paper.js would merge all clipping groups in one (known bug).
-                     */
-                    _raster.clipped = true;
-                    _clip.__representation = this;
-                }
-                if (this.options.clip_node_images) {
-                    var _circleClip = new paper.Path.Circle(centerPoint, baseRadius);
-                    _raster = new paper.Group(_circleClip, _raster);
-                    _raster.opacity = 0.99;
-                    _raster.clipped = true;
-                    _circleClip.__representation = this;
-                }
-                this.image_delta = centerPoint.divide(baseRadius);
-                this.node_image = _raster;
-                this.node_image.__representation = _this;
-                this.node_image.scale(this.circle_radius / baseRadius);
-                this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius));
-                this.redraw();
-                this.renderer.throttledPaperDraw();
-            } else {
-                var _this = this;
-                $(_image).on("load", function() {
-                    _this.showImage();
-                });
-            }
-        },
-        paperShift: function(_delta) {
-            if (this.options.editor_mode) {
-                if (!this.renkan.read_only) {
-                    this.is_dragging = true;
-                    this.paper_coords = this.paper_coords.add(_delta);
-                    this.redraw();
-                }
-            } else {
-                this.renderer.paperShift(_delta);
-            }
-        },
-        openEditor: function() {
-            this.renderer.removeRepresentationsOfType("editor");
-            var _editor = this.renderer.addRepresentation("NodeEditor",null);
-            _editor.source_representation = this;
-            _editor.draw();
-        },
-        select: function() {
-            this.selected = true;
-            this.circle.strokeWidth = this.options.selected_node_stroke_width;
-            if (this.renderer.isEditable()) {
-                this.active_buttons.forEach(function(b) {
-                    b.show();
-                });
-            }
-            var _uri = this.model.get("uri");
-            if (_uri) {
-                $('.Rk-Bin-Item').each(function() {
-                    var _el = $(this);
-                    if (_el.attr("data-uri") === _uri) {
-                        _el.addClass("selected");
-                    }
-                });
-            }
-            if (!this.options.editor_mode) {
-                this.openEditor();
-            }
-
-            if (this.renderer.minimap) {
-                this.minimap_circle.strokeWidth = this.options.minimap_highlight_weight;
-                this.minimap_circle.strokeColor = this.options.minimap_highlight_color;
-            }
-            this._super("select");
-        },
-        unselect: function(_newTarget) {
-            if (!_newTarget || _newTarget.source_representation !== this) {
-                this.selected = false;
-                this.all_buttons.forEach(function(b) {
-                    b.hide();
-                });
-                this.circle.strokeWidth = this.options.node_stroke_width;
-                $('.Rk-Bin-Item').removeClass("selected");
-                if (this.renderer.minimap) {
-                    this.minimap_circle.strokeColor = undefined;
-                }
-                this._super("unselect");
-            }
-        },
-        highlight: function(textToReplace) {
-            var hlvalue = textToReplace || true;
-            if (this.highlighted === hlvalue) {
-                return;
-            }
-            this.highlighted = hlvalue;
-            this.redraw();
-            this.renderer.throttledPaperDraw();
-        },
-        unhighlight: function() {
-            if (!this.highlighted) {
-                return;
-            }
-            this.highlighted = false;
-            this.redraw();
-            this.renderer.throttledPaperDraw();
-        },
-        saveCoords: function() {
-            var _coords = this.renderer.toModelCoords(this.paper_coords),
-            _data = {
-                position: {
-                    x: _coords.x,
-                    y: _coords.y
-                }
-            };
-            if (this.renderer.isEditable()) {
-                this.model.set(_data);
-            }
-        },
-        mousedown: function(_event, _isTouch) {
-            if (_isTouch) {
-                this.renderer.unselectAll();
-                this.select();
-            }
-        },
-        mouseup: function(_event, _isTouch) {
-            if (this.renderer.is_dragging && this.renderer.isEditable()) {
-                this.saveCoords();
-            } else {
-                if (!_isTouch && !this.model.get("delete_scheduled")) {
-                    this.openEditor();
-                }
-                this.model.trigger("clicked");
-            }
-            this.renderer.click_target = null;
-            this.renderer.is_dragging = false;
-            this.is_dragging = false;
-        },
-        destroy: function(_event) {
-            this._super("destroy");
-            this.all_buttons.forEach(function(b) {
-                b.destroy();
-            });
-            this.circle.remove();
-            this.title.remove();
-            if (this.renderer.minimap) {
-                this.minimap_circle.remove();
-            }
-            if (this.node_image) {
-                this.node_image.remove();
-            }
-        }
-    });
-
-    return NodeRepr;
-
-});
-
-
-define('renderer/edge',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* Edge Class Begin */
-
-    //var Edge = Renderer.Edge = Utils.inherit(Renderer._BaseRepresentation);
-    var Edge = Utils.inherit(BaseRepresentation);
-
-    _(Edge.prototype).extend({
-        _init: function() {
-            this.renderer.edge_layer.activate();
-            this.type = "Edge";
-            this.from_representation = this.renderer.getRepresentationByModel(this.model.get("from"));
-            this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to"));
-            this.bundle = this.renderer.addToBundles(this);
-            this.line = new paper.Path();
-            this.line.add([0,0],[0,0],[0,0]);
-            this.line.__representation = this;
-            this.line.strokeWidth = this.options.edge_stroke_width;
-            this.arrow = new paper.Path();
-            this.arrow.add(
-                    [ 0, 0 ],
-                    [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ],
-                    [ 0, this.options.edge_arrow_width ]
-            );
-            this.arrow.__representation = this;
-            this.text = $('<div class="Rk-Label Rk-Edge-Label">').appendTo(this.renderer.labels_$);
-            this.arrow_angle = 0;
-            if (this.options.editor_mode) {
-                var Renderer = requtils.getRenderer();
-                this.normal_buttons = [
-                                       new Renderer.EdgeEditButton(this.renderer, null),
-                                       new Renderer.EdgeRemoveButton(this.renderer, null)
-                                       ];
-                this.pending_delete_buttons = [
-                                               new Renderer.EdgeRevertButton(this.renderer, null)
-                                               ];
-                this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons);
-                for (var i = 0; i < this.all_buttons.length; i++) {
-                    this.all_buttons[i].source_representation = this;
-                }
-                this.active_buttons = [];
-            } else {
-                this.active_buttons = this.all_buttons = [];
-            }
-
-            if (this.renderer.minimap) {
-                this.renderer.minimap.edge_layer.activate();
-                this.minimap_line = new paper.Path();
-                this.minimap_line.add([0,0],[0,0]);
-                this.minimap_line.__representation = this.renderer.minimap.miniframe.__representation;
-                this.minimap_line.strokeWidth = 1;
-            }
-        },
-        redraw: function() {
-            var from = this.model.get("from"),
-            to = this.model.get("to");
-            if (!from || !to) {
-                return;
-            }
-            this.from_representation = this.renderer.getRepresentationByModel(from);
-            this.to_representation = this.renderer.getRepresentationByModel(to);
-            if (typeof this.from_representation === "undefined" || typeof this.to_representation === "undefined") {
-                return;
-            }
-            var _p0a = this.from_representation.paper_coords,
-            _p1a = this.to_representation.paper_coords,
-            _v = _p1a.subtract(_p0a),
-            _r = _v.length,
-            _u = _v.divide(_r),
-            _ortho = new paper.Point([- _u.y, _u.x]),
-            _group_pos = this.bundle.getPosition(this),
-            _delta = _ortho.multiply( this.options.edge_gap_in_bundles * _group_pos ),
-            _p0b = _p0a.add(_delta), /* Adding a 4 px difference */
-            _p1b = _p1a.add(_delta), /* to differentiate bundled links */
-            _a = _v.angle,
-            _textdelta = _ortho.multiply(this.options.edge_label_distance),
-            _handle = _v.divide(3),
-            _color = this.model.get("color") || this.model.get("color") || (this.model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"),
-            opacity = 1;
-
-            if (this.model.get("delete_scheduled") || this.from_representation.model.get("delete_scheduled") || this.to_representation.model.get("delete_scheduled")) {
-                opacity = 0.5;
-                this.line.dashArray = [2, 2];
-            } else {
-                opacity = 1;
-                this.line.dashArray = null;
-            }
-
-            var old_act_btn = this.active_buttons;
-
-            this.active_buttons = this.model.get("delete_scheduled") ? this.pending_delete_buttons : this.normal_buttons;
-
-            if (this.selected && this.renderer.isEditable() && old_act_btn !== this.active_buttons) {
-                old_act_btn.forEach(function(b) {
-                    b.hide();
-                });
-                this.active_buttons.forEach(function(b) {
-                    b.show();
-                });
-            }
-
-            this.paper_coords = _p0b.add(_p1b).divide(2);
-            this.line.strokeColor = _color;
-            this.line.opacity = opacity;
-            this.line.segments[0].point = _p0a;
-            this.line.segments[1].point = this.paper_coords;
-            this.line.segments[1].handleIn = _handle.multiply(-1);
-            this.line.segments[1].handleOut = _handle;
-            this.line.segments[2].point = _p1a;
-            this.arrow.rotate(_a - this.arrow_angle);
-            this.arrow.fillColor = _color;
-            this.arrow.opacity = opacity;
-            this.arrow.position = this.paper_coords;
-            this.arrow_angle = _a;
-            if (_a > 90) {
-                _a -= 180;
-                _textdelta = _textdelta.multiply(-1);
-            }
-            if (_a < -90) {
-                _a += 180;
-                _textdelta = _textdelta.multiply(-1);
-            }
-            var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_edges) || "";
-            _text = Utils.shortenText(_text, this.options.node_label_max_length);
-            this.text.text(_text);
-            var _textpos = this.paper_coords.add(_textdelta);
-            this.text.css({
-                left: _textpos.x,
-                top: _textpos.y,
-                transform: "rotate(" + _a + "deg)",
-                "-moz-transform": "rotate(" + _a + "deg)",
-                "-webkit-transform": "rotate(" + _a + "deg)",
-                opacity: opacity
-            });
-            this.text_angle = _a;
-
-            var _pc = this.paper_coords;
-            this.all_buttons.forEach(function(b) {
-                b.moveTo(_pc);
-            });
-
-            if (this.renderer.minimap) {
-                this.minimap_line.strokeColor = _color;
-                this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position")));
-                this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position")));
-            }
-        },
-        openEditor: function() {
-            this.renderer.removeRepresentationsOfType("editor");
-            var _editor = this.renderer.addRepresentation("EdgeEditor",null);
-            _editor.source_representation = this;
-            _editor.draw();
-        },
-        select: function() {
-            this.selected = true;
-            this.line.strokeWidth = this.options.selected_edge_stroke_width;
-            if (this.renderer.isEditable()) {
-                this.active_buttons.forEach(function(b) {
-                    b.show();
-                });
-            }
-            if (!this.options.editor_mode) {
-                this.openEditor();
-            }
-            this._super("select");
-        },
-        unselect: function(_newTarget) {
-            if (!_newTarget || _newTarget.source_representation !== this) {
-                this.selected = false;
-                if (this.options.editor_mode) {
-                    this.all_buttons.forEach(function(b) {
-                        b.hide();
-                    });
-                }
-                this.line.strokeWidth = this.options.edge_stroke_width;
-                this._super("unselect");
-            }
-        },
-        mousedown: function(_event, _isTouch) {
-            if (_isTouch) {
-                this.renderer.unselectAll();
-                this.select();
-            }
-        },
-        mouseup: function(_event, _isTouch) {
-            if (!this.renkan.read_only && this.renderer.is_dragging) {
-                this.from_representation.saveCoords();
-                this.to_representation.saveCoords();
-                this.from_representation.is_dragging = false;
-                this.to_representation.is_dragging = false;
-            } else {
-                if (!_isTouch) {
-                    this.openEditor();
-                }
-                this.model.trigger("clicked");
-            }
-            this.renderer.click_target = null;
-            this.renderer.is_dragging = false;
-        },
-        paperShift: function(_delta) {
-            if (this.options.editor_mode) {
-                if (!this.options.read_only) {
-                    this.from_representation.paperShift(_delta);
-                    this.to_representation.paperShift(_delta);
-                }
-            } else {
-                this.renderer.paperShift(_delta);
-            }
-        },
-        destroy: function() {
-            this._super("destroy");
-            this.line.remove();
-            this.arrow.remove();
-            this.text.remove();
-            if (this.renderer.minimap) {
-                this.minimap_line.remove();
-            }
-            this.all_buttons.forEach(function(b) {
-                b.destroy();
-            });
-            var _this = this;
-            this.bundle.edges = _(this.bundle.edges).reject(function(_edge) {
-                return _this === _edge;
-            });
-        }
-    });
-
-    return Edge;
-
-});
-
-
-
-define('renderer/tempedge',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* TempEdge Class Begin */
-
-    //var TempEdge = Renderer.TempEdge = Utils.inherit(Renderer._BaseRepresentation);
-    var TempEdge = Utils.inherit(BaseRepresentation);
-
-    _(TempEdge.prototype).extend({
-        _init: function() {
-            this.renderer.edge_layer.activate();
-            this.type = "Temp-edge";
-
-            var _color = (this.project.get("users").get(this.renkan.current_user) || Utils._USER_PLACEHOLDER(this.renkan)).get("color");
-            this.line = new paper.Path();
-            this.line.strokeColor = _color;
-            this.line.dashArray = [4, 2];
-            this.line.strokeWidth = this.options.selected_edge_stroke_width;
-            this.line.add([0,0],[0,0]);
-            this.line.__representation = this;
-            this.arrow = new paper.Path();
-            this.arrow.fillColor = _color;
-            this.arrow.add(
-                    [ 0, 0 ],
-                    [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ],
-                    [ 0, this.options.edge_arrow_width ]
-            );
-            this.arrow.__representation = this;
-            this.arrow_angle = 0;
-        },
-        redraw: function() {
-            var _p0 = this.from_representation.paper_coords,
-            _p1 = this.end_pos,
-            _a = _p1.subtract(_p0).angle,
-            _c = _p0.add(_p1).divide(2);
-            this.line.segments[0].point = _p0;
-            this.line.segments[1].point = _p1;
-            this.arrow.rotate(_a - this.arrow_angle);
-            this.arrow.position = _c;
-            this.arrow_angle = _a;
-        },
-        paperShift: function(_delta) {
-            if (!this.renderer.isEditable()) {
-                this.renderer.removeRepresentation(_this);
-                paper.view.draw();
-                return;
-            }
-            this.end_pos = this.end_pos.add(_delta);
-            var _hitResult = paper.project.hitTest(this.end_pos);
-            this.renderer.findTarget(_hitResult);
-            this.redraw();
-        },
-        mouseup: function(_event, _isTouch) {
-            var _hitResult = paper.project.hitTest(_event.point),
-            _model = this.from_representation.model,
-            _endDrag = true;
-            if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
-                var _target = _hitResult.item.__representation;
-                if (_target.type.substr(0,4) === "Node") {
-                    var _destmodel = _target.model || _target.source_representation.model;
-                    if (_model !== _destmodel) {
-                        var _data = {
-                                id: Utils.getUID('edge'),
-                                created_by: this.renkan.current_user,
-                                from: _model,
-                                to: _destmodel
-                        };
-                        if (this.renderer.isEditable()) {
-                            this.project.addEdge(_data);
-                        }
-                    }
-                }
-
-                if (_model === _target.model || (_target.source_representation && _target.source_representation.model === _model)) {
-                    _endDrag = false;
-                    this.renderer.is_dragging = true;
-                }
-            }
-            if (_endDrag) {
-                this.renderer.click_target = null;
-                this.renderer.is_dragging = false;
-                this.renderer.removeRepresentation(this);
-                paper.view.draw();
-            }
-        },
-        destroy: function() {
-            this.arrow.remove();
-            this.line.remove();
-        }
-    });
-
-    /* TempEdge Class End */
-
-    return TempEdge;
-
-});
-
-
-define('renderer/baseeditor',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* _BaseEditor Begin */
-    //var _BaseEditor = Renderer._BaseEditor = Utils.inherit(Renderer._BaseRepresentation);
-    var _BaseEditor = Utils.inherit(BaseRepresentation);
-
-    _(_BaseEditor.prototype).extend({
-        _init: function() {
-            this.renderer.buttons_layer.activate();
-            this.type = "editor";
-            this.editor_block = new paper.Path();
-            var _pts = _(_.range(8)).map(function() {return [0,0];});
-            this.editor_block.add.apply(this.editor_block, _pts);
-            this.editor_block.strokeWidth = this.options.tooltip_border_width;
-            this.editor_block.strokeColor = this.options.tooltip_border_color;
-            this.editor_block.opacity = 0.8;
-            this.editor_$ = $('<div>')
-            .appendTo(this.renderer.editor_$)
-            .css({
-                position: "absolute",
-                opacity: 0.8
-            })
-            .hide();
-        },
-        destroy: function() {
-            this.editor_block.remove();
-            this.editor_$.remove();
-        }
-    });
-
-    /* _BaseEditor End */
-
-    return _BaseEditor;
-
-});
-
-
-define('renderer/nodeeditor',['jquery', 'underscore', 'requtils', 'renderer/baseeditor'], function ($, _, requtils, BaseEditor) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* NodeEditor Begin */
-    //var NodeEditor = Renderer.NodeEditor = Utils.inherit(Renderer._BaseEditor);
-    var NodeEditor = Utils.inherit(BaseEditor);
-
-    _(NodeEditor.prototype).extend({
-        template: _.template(
-                '<h2><span class="Rk-CloseX">&times;</span><%-renkan.translate("Edit Node")%></span></h2>' +
-                '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-node.title%>"/></p>' +
-                '<% if (options.show_node_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-node.uri%>"/><a class="Rk-Edit-Goto" href="<%-node.uri%>" target="_blank"></a></p><% } %>' +
-                '<% if (options.show_node_editor_description) { %><p><label><%-renkan.translate("Description:")%></label><textarea class="Rk-Edit-Description"><%-node.description%></textarea></p><% } %>' +
-                '<% if (options.show_node_editor_size) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Size:")%></span><a href="#" class="Rk-Edit-Size-Down">-</a><span class="Rk-Edit-Size-Value"><%-node.size%></span><a href="#" class="Rk-Edit-Size-Up">+</a></p><% } %>' +
-                '<% if (options.show_node_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Node color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-node.color%>;"><span class="Rk-Edit-ColorTip"></span></span>' +
-                '<%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>' +
-                '<% if (options.show_node_editor_image) { %><div class="Rk-Edit-ImgWrap"><div class="Rk-Edit-ImgPreview"><img src="<%-node.image || node.image_placeholder%>" />' +
-                '<% if (node.clip_path) { %><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none"><path style="stroke-width: .02; stroke:red; fill-opacity:.3; fill:red;" d="<%- node.clip_path %>"/></svg><% }%>' +
-                '</div></div><p><label><%-renkan.translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p>' +
-                '<p><label><%-renkan.translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p><% } %>' +
-                '<% if (options.show_node_editor_creator && node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>'
-        ),
-        readOnlyTemplate: _.template(
-                '<h2><span class="Rk-CloseX">&times;</span><% if (options.show_node_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-node.color%>;"></span><% } %>' +
-                '<span class="Rk-Display-Title"><% if (node.uri) { %><a href="<%-node.uri%>" target="_blank"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2>' +
-                '<% if (node.uri && options.show_node_tooltip_uri) { %><p class="Rk-Display-URI"><a href="<%-node.uri%>" target="_blank"><%-node.short_uri%></a></p><% } %>' +
-                '<% if (options.show_node_tooltip_description) { %><p class="Rk-Display-Description"><%-node.description%></p><% } %>' +
-                '<% if (node.image && options.show_node_tooltip_image) { %><img class="Rk-Display-ImgPreview" src="<%-node.image%>" /><% } %>' +
-                '<% if (node.has_creator && options.show_node_tooltip_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>'
-        ),
-        draw: function() {
-            var _model = this.source_representation.model,
-            _created_by = _model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan),
-            _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ),
-            _image_placeholder = this.options.static_url + "img/image-placeholder.png",
-            _size = (_model.get("size") || 0);
-            this.editor_$
-            .html(_template({
-                node: {
-                    has_creator: !!_model.get("created_by"),
-                    title: _model.get("title"),
-                    uri: _model.get("uri"),
-                    short_uri:  Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
-                    description: _model.get("description"),
-                    image: _model.get("image") || "",
-                    image_placeholder: _image_placeholder,
-                    color: _model.get("color") || _created_by.get("color"),
-                    clip_path: _model.get("clip_path") || false,
-                    created_by_color: _created_by.get("color"),
-                    created_by_title: _created_by.get("title"),
-                    size: (_size > 0 ? "+" : "") + _size
-                },
-                renkan: this.renkan,
-                options: this.options,
-                shortenText: Utils.shortenText
-            }));
-            this.redraw();
-            var _this = this,
-            closeEditor = function() {
-                _this.renderer.removeRepresentation(_this);
-                paper.view.draw();
-            };
-
-            this.editor_$.find(".Rk-CloseX").click(closeEditor);
-
-            this.editor_$.find(".Rk-Edit-Goto").click(function() {
-                if (!_model.get("uri")) {
-                    return false;
-                }
-            });
-
-            if (this.renderer.isEditable()) {
-
-                var onFieldChange = _(function() {
-                    _(function() {
-                        if (_this.renderer.isEditable()) {
-                            var _data = {
-                                    title: _this.editor_$.find(".Rk-Edit-Title").val()
-                            };
-                            if (_this.options.show_node_editor_uri) {
-                                _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
-                                _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
-                            }
-                            if (_this.options.show_node_editor_image) {
-                                _data.image = _this.editor_$.find(".Rk-Edit-Image").val();
-                                _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder);
-                            }
-                            if (_this.options.show_node_editor_description) {
-                                _data.description = _this.editor_$.find(".Rk-Edit-Description").val();
-                            }
-                            _model.set(_data);
-                            _this.redraw();
-                        } else {
-                            closeEditor();
-                        }
-
-                    }).defer();
-                }).throttle(500);
-
-                this.editor_$.on("keyup", function(_e) {
-                    if (_e.keyCode === 27) {
-                        closeEditor();
-                    }
-                });
-
-                this.editor_$.find("input, textarea").on("change keyup paste", onFieldChange);
-
-                this.editor_$.find(".Rk-Edit-Image-File").change(function() {
-                    if (this.files.length) {
-                        var f = this.files[0],
-                        fr = new FileReader();
-                        if (f.type.substr(0,5) !== "image") {
-                            alert(_this.renkan.translate("This file is not an image"));
-                            return;
-                        }
-                        if (f.size > (_this.options.uploaded_image_max_kb * 1024)) {
-                            alert(_this.renkan.translate("Image size must be under ") + _this.options.uploaded_image_max_kb + _this.renkan.translate("KB"));
-                            return;
-                        }
-                        fr.onload = function(e) {
-                            _this.editor_$.find(".Rk-Edit-Image").val(e.target.result);
-                            onFieldChange();
-                        };
-                        fr.readAsDataURL(f);
-                    }
-                });
-                this.editor_$.find(".Rk-Edit-Title")[0].focus();
-
-                var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker");
-
-                this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(
-                        function(_e) {
-                            _e.preventDefault();
-                            _picker.show();
-                        },
-                        function(_e) {
-                            _e.preventDefault();
-                            _picker.hide();
-                        }
-                );
-
-                _picker.find("li").hover(
-                        function(_e) {
-                            _e.preventDefault();
-                            _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
-                        },
-                        function(_e) {
-                            _e.preventDefault();
-                            _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Utils._USER_PLACEHOLDER(_this.renkan)).get("color"));
-                        }
-                ).click(function(_e) {
-                    _e.preventDefault();
-                    if (_this.renderer.isEditable()) {
-                        _model.set("color", $(this).attr("data-color"));
-                        _picker.hide();
-                        paper.view.draw();
-                    } else {
-                        closeEditor();
-                    }
-                });
-
-                var shiftSize = function(n) {
-                    if (_this.renderer.isEditable()) {
-                        var _newsize = n+(_model.get("size") || 0);
-                        _this.editor_$.find(".Rk-Edit-Size-Value").text((_newsize > 0 ? "+" : "") + _newsize);
-                        _model.set("size", _newsize);
-                        paper.view.draw();
-                    } else {
-                        closeEditor();
-                    }
-                };
-
-                this.editor_$.find(".Rk-Edit-Size-Down").click(function() {
-                    shiftSize(-1);
-                    return false;
-                });
-                this.editor_$.find(".Rk-Edit-Size-Up").click(function() {
-                    shiftSize(1);
-                    return false;
-                });
-            } else {
-                if (typeof this.source_representation.highlighted === "object") {
-                    var titlehtml = this.source_representation.highlighted.replace(_(_model.get("title")).escape(),'<span class="Rk-Highlighted">$1</span>');
-                    this.editor_$.find(".Rk-Display-Title" + (_model.get("uri") ? " a" : "")).html(titlehtml);
-                    if (this.options.show_node_tooltip_description) {
-                        this.editor_$.find(".Rk-Display-Description").html(this.source_representation.highlighted.replace(_(_model.get("description")).escape(),'<span class="Rk-Highlighted">$1</span>'));
-                    }
-                }
-            }
-            this.editor_$.find("img").load(function() {
-                _this.redraw();
-            });
-        },
-        redraw: function() {
-            var _coords = this.source_representation.paper_coords;
-            Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$);
-            this.editor_$.show();
-            paper.view.draw();
-        }
-    });
-
-    /* NodeEditor End */
-
-    return NodeEditor;
-
-});
-
-
-define('renderer/edgeeditor',['jquery', 'underscore', 'requtils', 'renderer/baseeditor'], function ($, _, requtils, BaseEditor) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* EdgeEditor Begin */
-
-    //var EdgeEditor = Renderer.EdgeEditor = Utils.inherit(Renderer._BaseEditor);
-    var EdgeEditor = Utils.inherit(BaseEditor);
-
-    _(EdgeEditor.prototype).extend({
-        template: _.template(
-                '<h2><span class="Rk-CloseX">&times;</span><%-renkan.translate("Edit Edge")%></span></h2>' +
-                '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-edge.title%>"/></p>' +
-                '<% if (options.show_edge_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-edge.uri%>"/><a class="Rk-Edit-Goto" href="<%-edge.uri%>" target="_blank"></a></p>' +
-                '<% if (options.properties.length) { %><p><label><%-renkan.translate("Choose from vocabulary:")%></label><select class="Rk-Edit-Vocabulary">' +
-                '<% _(options.properties).each(function(ontology) { %><option class="Rk-Edit-Vocabulary-Class" value=""><%- renkan.translate(ontology.label) %></option>' +
-                '<% _(ontology.properties).each(function(property) { var uri = ontology["base-uri"] + property.uri; %><option class="Rk-Edit-Vocabulary-Property" value="<%- uri %>' +
-                '"<% if (uri === edge.uri) { %> selected<% } %>><%- renkan.translate(property.label) %></option>' +
-                '<% }) %><% }) %></select></p><% } } %>' +
-                '<% if (options.show_edge_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Edge color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-edge.color%>;"><span class="Rk-Edit-ColorTip"></span></span>' +
-                '<%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>' +
-                '<% if (options.show_edge_editor_direction) { %><p><span class="Rk-Edit-Direction"><%- renkan.translate("Change edge direction") %></span></p><% } %>' +
-                '<% if (options.show_edge_editor_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p>' +
-                '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %>' +
-                '<% if (options.show_edge_editor_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'
-        ),
-        readOnlyTemplate: _.template(
-                '<h2><span class="Rk-CloseX">&times;</span><% if (options.show_edge_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-edge.color%>;"></span><% } %>' +
-                '<span class="Rk-Display-Title"><% if (edge.uri) { %><a href="<%-edge.uri%>" target="_blank"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2>' +
-                '<% if (options.show_edge_tooltip_uri && edge.uri) { %><p class="Rk-Display-URI"><a href="<%-edge.uri%>" target="_blank"><%-edge.short_uri%></a></p><% } %>' +
-                '<p><%-edge.description%></p>' +
-                '<% if (options.show_edge_tooltip_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p>' +
-                '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %>' +
-                '<% if (options.show_edge_tooltip_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'
-        ),
-        draw: function() {
-            var _model = this.source_representation.model,
-            _from_model = _model.get("from"),
-            _to_model = _model.get("to"),
-            _created_by = _model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan),
-            _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate);
-            this.editor_$
-            .html(_template({
-                edge: {
-                    has_creator: !!_model.get("created_by"),
-                    title: _model.get("title"),
-                    uri: _model.get("uri"),
-                    short_uri:  Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
-                    description: _model.get("description"),
-                    color: _model.get("color") || _created_by.get("color"),
-                    from_title: _from_model.get("title"),
-                    to_title: _to_model.get("title"),
-                    from_color: _from_model.get("color") || (_from_model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"),
-                    to_color: _to_model.get("color") || (_to_model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"),
-                    created_by_color: _created_by.get("color"),
-                    created_by_title: _created_by.get("title")
-                },
-                renkan: this.renkan,
-                shortenText: Utils.shortenText,
-                options: this.options
-            }));
-            this.redraw();
-            var _this = this,
-            closeEditor = function() {
-                _this.renderer.removeRepresentation(_this);
-                paper.view.draw();
-            };
-            this.editor_$.find(".Rk-CloseX").click(closeEditor);
-            this.editor_$.find(".Rk-Edit-Goto").click(function() {
-                if (!_model.get("uri")) {
-                    return false;
-                }
-            });
-
-            if (this.renderer.isEditable()) {
-
-                var onFieldChange = _(function() {
-                    _(function() {
-                        if (_this.renderer.isEditable()) {
-                            var _data = {
-                                    title: _this.editor_$.find(".Rk-Edit-Title").val()
-                            };
-                            if (_this.options.show_edge_editor_uri) {
-                                _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
-                            }
-                            _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
-                            _model.set(_data);
-                            paper.view.draw();
-                        } else {
-                            closeEditor();
-                        }
-                    }).defer();
-                }).throttle(500);
-
-                this.editor_$.on("keyup", function(_e) {
-                    if (_e.keyCode === 27) {
-                        closeEditor();
-                    }
-                });
-
-                this.editor_$.find("input").on("keyup change paste", onFieldChange);
-
-                this.editor_$.find(".Rk-Edit-Vocabulary").change(function() {
-                    var e = $(this),
-                    v = e.val();
-                    if (v) {
-                        _this.editor_$.find(".Rk-Edit-Title").val(e.find(":selected").text());
-                        _this.editor_$.find(".Rk-Edit-URI").val(v);
-                        onFieldChange();
-                    }
-                });
-                this.editor_$.find(".Rk-Edit-Direction").click(function() {
-                    if (_this.renderer.isEditable()) {
-                        _model.set({
-                            from: _model.get("to"),
-                            to: _model.get("from")
-                        });
-                        _this.draw();
-                    } else {
-                        closeEditor();
-                    }
-                });
-
-                var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker");
-
-                this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(
-                        function(_e) {
-                            _e.preventDefault();
-                            _picker.show();
-                        },
-                        function(_e) {
-                            _e.preventDefault();
-                            _picker.hide();
-                        }
-                );
-
-                _picker.find("li").hover(
-                        function(_e) {
-                            _e.preventDefault();
-                            _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
-                        },
-                        function(_e) {
-                            _e.preventDefault();
-                            _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Utils._USER_PLACEHOLDER(_this.renkan)).get("color"));
-                        }
-                ).click(function(_e) {
-                    _e.preventDefault();
-                    if (_this.renderer.isEditable()) {
-                        _model.set("color", $(this).attr("data-color"));
-                        _picker.hide();
-                        paper.view.draw();
-                    } else {
-                        closeEditor();
-                    }
-                });
-            }
-        },
-        redraw: function() {
-            var _coords = this.source_representation.paper_coords;
-            Utils.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$);
-            this.editor_$.show();
-            paper.view.draw();
-        }
-    });
-
-    /* EdgeEditor End */
-
-    return EdgeEditor;
-
-});
-
-
-define('renderer/nodebutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {
-    
-    
-    var Utils = requtils.getUtils();
-
-    /* _NodeButton Begin */
-
-    //var _NodeButton = Renderer._NodeButton = Utils.inherit(Renderer._BaseButton);
-    var _NodeButton = Utils.inherit(BaseButton);
-
-    _(_NodeButton.prototype).extend({
-        setSectorSize: function() {
-            var sectorInner = this.source_representation.circle_radius;
-            if (sectorInner !== this.lastSectorInner) {
-                if (this.sector) {
-                    this.sector.destroy();
-                }
-                this.sector = this.renderer.drawSector(
-                        this, 1 + sectorInner,
-                        Utils._NODE_BUTTON_WIDTH + sectorInner,
-                        this.startAngle,
-                        this.endAngle,
-                        1,
-                        this.imageName,
-                        this.renkan.translate(this.text)
-                );
-                this.lastSectorInner = sectorInner;
-            }
-        }
-    });
-
-    /* _NodeButton End */
-
-    return _NodeButton;
-
-});
-
-
-define('renderer/nodeeditbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* NodeEditButton Begin */
-
-    //var NodeEditButton = Renderer.NodeEditButton = Utils.inherit(Renderer._NodeButton);
-    var NodeEditButton = Utils.inherit(NodeButton);
-
-    _(NodeEditButton.prototype).extend({
-        _init: function() {
-            this.type = "Node-edit-button";
-            this.lastSectorInner = 0;
-            this.startAngle = -135;
-            this.endAngle = -45;
-            this.imageName = "edit";
-            this.text = "Edit";
-        },
-        mouseup: function() {
-            if (!this.renderer.is_dragging) {
-                this.source_representation.openEditor();
-            }
-        }
-    });
-
-    /* NodeEditButton End */
-
-    return NodeEditButton;
-
-});
-
-
-define('renderer/noderemovebutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
-    
-    
-    var Utils = requtils.getUtils();
-
-    /* NodeRemoveButton Begin */
-
-    //var NodeRemoveButton = Renderer.NodeRemoveButton = Utils.inherit(Renderer._NodeButton);
-    var NodeRemoveButton = Utils.inherit(NodeButton);
-
-    _(NodeRemoveButton.prototype).extend({
-        _init: function() {
-            this.type = "Node-remove-button";
-            this.lastSectorInner = 0;
-            this.startAngle = 0;
-            this.endAngle = 90;
-            this.imageName = "remove";
-            this.text = "Remove";
-        },
-        mouseup: function() {
-            this.renderer.click_target = null;
-            this.renderer.is_dragging = false;
-            this.renderer.removeRepresentationsOfType("editor");
-            if (this.renderer.isEditable()) {
-                if (this.options.element_delete_delay) {
-                    var delid = Utils.getUID("delete");
-                    this.renderer.delete_list.push({
-                        id: delid,
-                        time: new Date().valueOf() + this.options.element_delete_delay
-                    });
-                    this.source_representation.model.set("delete_scheduled", delid);
-                } else {
-                    if (confirm(this.renkan.translate('Do you really wish to remove node ') + '"' + this.source_representation.model.get("title") + '"?')) {
-                        this.project.removeNode(this.source_representation.model);
-                    }
-                }
-            }
-        }
-    });
-
-    /* NodeRemoveButton End */
-
-    return NodeRemoveButton;
-
-});
-
-
-define('renderer/noderevertbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* NodeRevertButton Begin */
-
-    //var NodeRevertButton = Renderer.NodeRevertButton = Utils.inherit(Renderer._NodeButton);
-    var NodeRevertButton = Utils.inherit(NodeButton);
-
-    _(NodeRevertButton.prototype).extend({
-        _init: function() {
-            this.type = "Node-revert-button";
-            this.lastSectorInner = 0;
-            this.startAngle = -135;
-            this.endAngle = 135;
-            this.imageName = "revert";
-            this.text = "Cancel deletion";
-        },
-        mouseup: function() {
-            this.renderer.click_target = null;
-            this.renderer.is_dragging = false;
-            if (this.renderer.isEditable()) {
-                this.source_representation.model.unset("delete_scheduled");
-            }
-        }
-    });
-
-    /* NodeRevertButton End */
-
-    return NodeRevertButton;
-
-});
-
-
-define('renderer/nodelinkbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* NodeLinkButton Begin */
-
-    //var NodeLinkButton = Renderer.NodeLinkButton = Utils.inherit(Renderer._NodeButton);
-    var NodeLinkButton = Utils.inherit(NodeButton);
-
-    _(NodeLinkButton.prototype).extend({
-        _init: function() {
-            this.type = "Node-link-button";
-            this.lastSectorInner = 0;
-            this.startAngle = 90;
-            this.endAngle = 180;
-            this.imageName = "link";
-            this.text = "Link to another node";
-        },
-        mousedown: function(_event, _isTouch) {
-            if (this.renderer.isEditable()) {
-                var _off = this.renderer.canvas_$.offset(),
-                _point = new paper.Point([
-                                          _event.pageX - _off.left,
-                                          _event.pageY - _off.top
-                                          ]);
-                this.renderer.click_target = null;
-                this.renderer.removeRepresentationsOfType("editor");
-                this.renderer.addTempEdge(this.source_representation, _point);
-            }
-        }
-    });
-
-    /* NodeLinkButton End */
-
-    return NodeLinkButton;
-
-});
-
-
-
-define('renderer/nodeenlargebutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
-    
-    
-    var Utils = requtils.getUtils();
-
-    /* NodeEnlargeButton Begin */
-
-    //var NodeEnlargeButton = Renderer.NodeEnlargeButton = Utils.inherit(Renderer._NodeButton);
-    var NodeEnlargeButton = Utils.inherit(NodeButton);
-
-    _(NodeEnlargeButton.prototype).extend({
-        _init: function() {
-            this.type = "Node-enlarge-button";
-            this.lastSectorInner = 0;
-            this.startAngle = -45;
-            this.endAngle = 0;
-            this.imageName = "enlarge";
-            this.text = "Enlarge";
-        },
-        mouseup: function() {
-            var _newsize = 1 + (this.source_representation.model.get("size") || 0);
-            this.source_representation.model.set("size", _newsize);
-            this.source_representation.select();
-            this.select();
-            paper.view.draw();
-        }
-    });
-
-    /* NodeEnlargeButton End */
-
-    return NodeEnlargeButton;
-
-});
-
-
-define('renderer/nodeshrinkbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* NodeShrinkButton Begin */
-
-    //var NodeShrinkButton = Renderer.NodeShrinkButton = Utils.inherit(Renderer._NodeButton);
-    var NodeShrinkButton = Utils.inherit(NodeButton);
-
-    _(NodeShrinkButton.prototype).extend({
-        _init: function() {
-            this.type = "Node-shrink-button";
-            this.lastSectorInner = 0;
-            this.startAngle = -180;
-            this.endAngle = -135;
-            this.imageName = "shrink";
-            this.text = "Shrink";
-        },
-        mouseup: function() {
-            var _newsize = -1 + (this.source_representation.model.get("size") || 0);
-            this.source_representation.model.set("size", _newsize);
-            this.source_representation.select();
-            this.select();
-            paper.view.draw();
-        }
-    });
-
-    /* NodeShrinkButton End */
-
-    return NodeShrinkButton;
-
-});
-
-
-define('renderer/edgeeditbutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* EdgeEditButton Begin */
-
-    //var EdgeEditButton = Renderer.EdgeEditButton = Utils.inherit(Renderer._BaseButton);
-    var EdgeEditButton = Utils.inherit(BaseButton);
-
-    _(EdgeEditButton.prototype).extend({
-        _init: function() {
-            this.type = "Edge-edit-button";
-            this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -270, -90, 1, "edit", this.renkan.translate("Edit"));
-        },
-        mouseup: function() {
-            if (!this.renderer.is_dragging) {
-                this.source_representation.openEditor();
-            }
-        }
-    });
-
-    /* EdgeEditButton End */
-
-    return EdgeEditButton;
-
-});
-
-
-define('renderer/edgeremovebutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* EdgeRemoveButton Begin */
-
-    //var EdgeRemoveButton = Renderer.EdgeRemoveButton = Utils.inherit(Renderer._BaseButton);
-    var EdgeRemoveButton = Utils.inherit(BaseButton);
-
-    _(EdgeRemoveButton.prototype).extend({
-        _init: function() {
-            this.type = "Edge-remove-button";
-            this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -90, 90, 1, "remove", this.renkan.translate("Remove"));
-        },
-        mouseup: function() {
-            this.renderer.click_target = null;
-            this.renderer.is_dragging = false;
-            this.renderer.removeRepresentationsOfType("editor");
-            if (this.renderer.isEditable()) {
-                if (this.options.element_delete_delay) {
-                    var delid = Utils.getUID("delete");
-                    this.renderer.delete_list.push({
-                        id: delid,
-                        time: new Date().valueOf() + this.options.element_delete_delay
-                    });
-                    this.source_representation.model.set("delete_scheduled", delid);
-                } else {
-                    if (confirm(this.renkan.translate('Do you really wish to remove edge ') + '"' + this.source_representation.model.get("title") + '"?')) {
-                        this.project.removeEdge(this.source_representation.model);
-                    }
-                }
-            }
-        }
-    });
-
-    /* EdgeRemoveButton End */
-
-    return EdgeRemoveButton;
-
-});
-
-
-define('renderer/edgerevertbutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* EdgeRevertButton Begin */
-
-    //var EdgeRevertButton = Renderer.EdgeRevertButton = Utils.inherit(Renderer._BaseButton);
-    var EdgeRevertButton = Utils.inherit(BaseButton);
-
-    _(EdgeRevertButton.prototype).extend({
-        _init: function() {
-            this.type = "Edge-revert-button";
-            this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -135, 135, 1, "revert", this.renkan.translate("Cancel deletion"));
-        },
-        mouseup: function() {
-            this.renderer.click_target = null;
-            this.renderer.is_dragging = false;
-            if (this.renderer.isEditable()) {
-                this.source_representation.model.unset("delete_scheduled");
-            }
-        }
-    });
-
-    /* EdgeRevertButton End */
-
-    return EdgeRevertButton;
-
-});
-
-
-define('renderer/miniframe',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* MiniFrame Begin */
-
-    //var MiniFrame = Renderer.MiniFrame = Utils.inherit(Renderer._BaseRepresentation);
-    var MiniFrame = Utils.inherit(BaseRepresentation);
-
-    _(MiniFrame.prototype).extend({
-        paperShift: function(_delta) {
-            this.renderer.offset = this.renderer.offset.subtract(_delta.divide(this.renderer.minimap.scale).multiply(this.renderer.scale));
-            this.renderer.redraw();
-        },
-        mouseup: function(_delta) {
-            this.renderer.click_target = null;
-            this.renderer.is_dragging = false;
-        }
-    });
-
-    /* MiniFrame End */
-
-    return MiniFrame;
-
-});
-
-
-define('renderer/scene',['jquery', 'underscore', 'filesaver', 'requtils', 'renderer/miniframe'], function ($, _, filesaver, requtils, MiniFrame) {
-    
-
-    var Utils = requtils.getUtils();
-
-    /* Scene Begin */
-
-    var Scene = function(_renkan) {
-        this.renkan = _renkan;
-        this.$ = $(".Rk-Render");
-        this.representations = [];
-        this.$.html(this.template(_renkan));
-        this.onStatusChange();
-        this.canvas_$ = this.$.find(".Rk-Canvas");
-        this.labels_$ = this.$.find(".Rk-Labels");
-        this.editor_$ = this.$.find(".Rk-Editor");
-        this.notif_$ = this.$.find(".Rk-Notifications");
-        paper.setup(this.canvas_$[0]);
-        this.scale = 1;
-        this.initialScale = 1;
-        this.offset = paper.view.center;
-        this.totalScroll = 0;
-        this.mouse_down = false;
-        this.click_target = null;
-        this.selected_target = null;
-        this.edge_layer = new paper.Layer();
-        this.node_layer = new paper.Layer();
-        this.buttons_layer = new paper.Layer();
-        this.delete_list = [];
-        this.redrawActive = true;
-
-        if (_renkan.options.show_minimap) {
-            this.minimap = {
-                    background_layer: new paper.Layer(),
-                    edge_layer: new paper.Layer(),
-                    node_layer: new paper.Layer(),
-                    node_group: new paper.Group(),
-                    size: new paper.Size( _renkan.options.minimap_width, _renkan.options.minimap_height )
-            };
-
-            this.minimap.background_layer.activate();
-            this.minimap.topleft = paper.view.bounds.bottomRight.subtract(this.minimap.size);
-            this.minimap.rectangle = new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]), this.minimap.size.add([4,4]));
-            this.minimap.rectangle.fillColor = _renkan.options.minimap_background_color;
-            this.minimap.rectangle.strokeColor = _renkan.options.minimap_border_color;
-            this.minimap.rectangle.strokeWidth = 4;
-            this.minimap.offset = new paper.Point(this.minimap.size.divide(2));
-            this.minimap.scale = 0.1;
-
-            this.minimap.node_layer.activate();
-            this.minimap.cliprectangle = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size);
-            this.minimap.node_group.addChild(this.minimap.cliprectangle);
-            this.minimap.node_group.clipped = true;
-            this.minimap.miniframe = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size);
-            this.minimap.node_group.addChild(this.minimap.miniframe);
-            this.minimap.miniframe.fillColor = '#c0c0ff';
-            this.minimap.miniframe.opacity = 0.3;
-            this.minimap.miniframe.strokeColor = '#000080';
-            this.minimap.miniframe.strokeWidth = 3;
-            this.minimap.miniframe.__representation = new MiniFrame(this, null);
-        }
-
-        this.throttledPaperDraw = _(function() {
-            paper.view.draw();
-        }).throttle(100);
-
-        this.bundles = [];
-        this.click_mode = false;
-
-        var _this = this,
-        _allowScroll = true,
-        _originalScale = 1,
-        _zooming = false,
-        _lastTapX = 0,
-        _lastTapY = 0;
-
-        this.image_cache = {};
-        this.icon_cache = {};
-
-        ['edit', 'remove', 'link', 'enlarge', 'shrink', 'revert' ].forEach(function(imgname) {
-            var img = new Image();
-            img.src = _renkan.options.static_url + 'img/' + imgname + '.png';
-            _this.icon_cache[imgname] = img;
-        });
-
-        var throttledMouseMove = _.throttle(function(_event, _isTouch) {
-            _this.onMouseMove(_event, _isTouch);
-        }, Utils._MOUSEMOVE_RATE);
-
-        this.canvas_$.on({
-            mousedown: function(_event) {
-                _event.preventDefault();
-                _this.onMouseDown(_event, false);
-            },
-            mousemove: function(_event) {
-                _event.preventDefault();
-                throttledMouseMove(_event, false);
-            },
-            mouseup: function(_event) {
-                _event.preventDefault();
-                _this.onMouseUp(_event, false);
-            },
-            mousewheel: function(_event, _delta) {
-                if(_renkan.options.zoom_on_scroll) {
-                    _event.preventDefault();
-                    if (_allowScroll) {
-                        _this.onScroll(_event, _delta);
-                    }
-                }
-            },
-            touchstart: function(_event) {
-                _event.preventDefault();
-                var _touches = _event.originalEvent.touches[0];
-                if (
-                        _renkan.options.allow_double_click &&
-                        new Date() - _lastTap < Utils._DOUBLETAP_DELAY &&
-                        ( Math.pow(_lastTapX - _touches.pageX, 2) + Math.pow(_lastTapY - _touches.pageY, 2) < Utils._DOUBLETAP_DISTANCE )
-                ) {
-                    _lastTap = 0;
-                    _this.onDoubleClick(_touches);
-                } else {
-                    _lastTap = new Date();
-                    _lastTapX = _touches.pageX;
-                    _lastTapY = _touches.pageY;
-                    _originalScale = _this.scale;
-                    _zooming = false;
-                    _this.onMouseDown(_touches, true);
-                }
-            },
-            touchmove: function(_event) {
-                _event.preventDefault();
-                _lastTap = 0;
-                if (_event.originalEvent.touches.length === 1) {
-                    _this.onMouseMove(_event.originalEvent.touches[0], true);
-                } else {
-                    if (!_zooming) {
-                        _this.onMouseUp(_event.originalEvent.touches[0], true);
-                        _this.click_target = null;
-                        _this.is_dragging = false;
-                        _zooming = true;
-                    }
-                    if (_event.originalEvent.scale === "undefined") {
-                        return;
-                    }
-                    var _newScale = _event.originalEvent.scale * _originalScale,
-                    _scaleRatio = _newScale / _this.scale,
-                    _newOffset = new paper.Point([
-                                                  _this.canvas_$.width(),
-                                                  _this.canvas_$.height()
-                                                  ]).multiply( 0.5 * ( 1 - _scaleRatio ) ).add(_this.offset.multiply( _scaleRatio ));
-                    _this.setScale(_newScale, _newOffset);
-                }
-            },
-            touchend: function(_event) {
-                _event.preventDefault();
-                _this.onMouseUp(_event.originalEvent.changedTouches[0], true);
-            },
-            dblclick: function(_event) {
-                _event.preventDefault();
-                if (_renkan.options.allow_double_click) {
-                    _this.onDoubleClick(_event);
-                }
-            },
-            mouseleave: function(_event) {
-                _event.preventDefault();
-                _this.onMouseUp(_event, false);
-                _this.click_target = null;
-                _this.is_dragging = false;
-            },
-            dragover: function(_event) {
-                _event.preventDefault();
-            },
-            dragenter: function(_event) {
-                _event.preventDefault();
-                _allowScroll = false;
-            },
-            dragleave: function(_event) {
-                _event.preventDefault();
-                _allowScroll = true;
-            },
-            drop: function(_event) {
-                _event.preventDefault();
-                _allowScroll = true;
-                var res = {};
-                _(_event.originalEvent.dataTransfer.types).each(function(t) {
-                    try {
-                        res[t] = _event.originalEvent.dataTransfer.getData(t);
-                    } catch(e) {}
-                });
-                var text = _event.originalEvent.dataTransfer.getData("Text");
-                if (typeof text === "string") {
-                    switch(text[0]) {
-                    case "{":
-                    case "[":
-                        try {
-                            var data = JSON.parse(text);
-                            _(res).extend(data);
-                        }
-                        catch(e) {
-                            if (!res["text/plain"]) {
-                                res["text/plain"] = text;
-                            }
-                        }
-                        break;
-                    case "<":
-                        if (!res["text/html"]) {
-                            res["text/html"] = text;
-                        }
-                        break;
-                    default:
-                        if (!res["text/plain"]) {
-                            res["text/plain"] = text;
-                        }
-                    }
-                }
-                var url = _event.originalEvent.dataTransfer.getData("URL");
-                if (url && !res["text/uri-list"]) {
-                    res["text/uri-list"] = url;
-                }
-                _this.dropData(res, _event.originalEvent);
-            }
-        });
-
-        var bindClick = function(selector, fname) {
-            _this.$.find(selector).click(function(evt) {
-                _this[fname](evt);
-                return false;
-            });
-        };
-
-        bindClick(".Rk-ZoomOut", "zoomOut");
-        bindClick(".Rk-ZoomIn", "zoomIn");
-        bindClick(".Rk-ZoomFit", "autoScale");
-        this.$.find(".Rk-ZoomSave").click( function() {
-            // Save scale and offset point
-            _this.renkan.project.addView( { zoom_level:_this.scale, offset:_this.offset } );
-        });
-        this.$.find(".Rk-ZoomSetSaved").click( function() {
-            var view = _this.renkan.project.get("views").last();
-            if(view){
-                _this.setScale(view.get("zoom_level"), new paper.Point(view.get("offset")));
-            }
-        });
-        if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){
-            this.$.find(".Rk-ZoomSetSaved").show();
-        }
-        this.$.find(".Rk-CurrentUser").mouseenter(
-                function() { _this.$.find(".Rk-UserList").slideDown(); }
-        );
-        this.$.find(".Rk-Users").mouseleave(
-                function() { _this.$.find(".Rk-UserList").slideUp(); }
-        );
-        bindClick(".Rk-FullScreen-Button", "fullScreen");
-        bindClick(".Rk-AddNode-Button", "addNodeBtn");
-        bindClick(".Rk-AddEdge-Button", "addEdgeBtn");
-        bindClick(".Rk-Save-Button", "save");
-        bindClick(".Rk-Open-Button", "open");
-        bindClick(".Rk-Export-Button", "exportProject");
-        this.$.find(".Rk-Bookmarklet-Button")
-          /*jshint scripturl:true */
-          .attr("href","javascript:" + Utils._BOOKMARKLET_CODE(_renkan))
-          .click(function(){
-              _this.notif_$
-              .text(_renkan.translate("Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan."))
-              .fadeIn()
-              .delay(5000)
-              .fadeOut();
-              return false;
-          });
-        this.$.find(".Rk-TopBar-Button").mouseover(function() {
-            $(this).find(".Rk-TopBar-Tooltip").show();
-        }).mouseout(function() {
-            $(this).find(".Rk-TopBar-Tooltip").hide();
-        });
-        bindClick(".Rk-Fold-Bins", "foldBins");
-
-        paper.view.onResize = function(_event) {
-            // Because of paper bug which does not calculate the good height (and width a fortiori)
-            // We have to update manually the canvas's height
-            paper.view._viewSize.height =  _event.size.height = _this.canvas_$.parent().height();
-
-            if (_this.minimap) {
-                _this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size);
-                _this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4]));
-                _this.minimap.cliprectangle.fitBounds(_this.minimap.topleft, _this.minimap.size);
-            }
-            _this.redraw();
-        };
-
-        var _thRedraw = _.throttle(function() {
-            _this.redraw();
-        },50);
-
-        this.addRepresentations("Node", this.renkan.project.get("nodes"));
-        this.addRepresentations("Edge", this.renkan.project.get("edges"));
-        this.renkan.project.on("change:title", function() {
-            _this.$.find(".Rk-PadTitle").val(_renkan.project.get("title"));
-        });
-
-        this.$.find(".Rk-PadTitle").on("keyup input paste", function() {
-            _renkan.project.set({"title": $(this).val()});
-        });
-
-        var _thRedrawUsers = _.throttle(function() {
-            _this.redrawUsers();
-        }, 100);
-
-        _thRedrawUsers();
-
-        // register model events
-        this.renkan.project.on("add:users remove:users", _thRedrawUsers);
-
-        this.renkan.project.on("add:views remove:views", function(_node) {
-            if(_this.renkan.project.get('views').length > 0) {
-                _this.$.find(".Rk-ZoomSetSaved").show();
-            }
-            else {
-                _this.$.find(".Rk-ZoomSetSaved").hide();
-            }
-        });
-
-        this.renkan.project.on("add:nodes", function(_node) {
-            _this.addRepresentation("Node", _node);
-            _thRedraw();
-        });
-        this.renkan.project.on("add:edges", function(_edge) {
-            _this.addRepresentation("Edge", _edge);
-            _thRedraw();
-        });
-        this.renkan.project.on("change:title", function(_model, _title) {
-            var el = _this.$.find(".Rk-PadTitle");
-            if (el.is("input")) {
-                if (el.val() !== _title) {
-                    el.val(_title);
-                }
-            } else {
-                el.text(_title);
-            }
-        });
-
-        if (_renkan.options.size_bug_fix) {
-            var _delay = (
-                    typeof _renkan.options.size_bug_fix === "number" ?
-                        _renkan.options.size_bug_fix
-                                : 500
-            );
-            window.setTimeout(
-                    function() {
-                        _this.fixSize(true);
-                    },
-                    _delay
-            );
-        }
-
-        if (_renkan.options.force_resize) {
-            $(window).resize(function() {
-                _this.fixSize(false);
-            });
-        }
-
-        if (_renkan.options.show_user_list && _renkan.options.user_color_editable) {
-            var $cpwrapper = this.$.find(".Rk-Users .Rk-Edit-ColorPicker-Wrapper"),
-            $cplist = this.$.find(".Rk-Users .Rk-Edit-ColorPicker");
-
-            $cpwrapper.hover(
-                    function(_e) {
-                        if (_this.isEditable()) {
-                            _e.preventDefault();
-                            $cplist.show();
-                        }
-                    },
-                    function(_e) {
-                        _e.preventDefault();
-                        $cplist.hide();
-                    }
-            );
-
-            $cplist.find("li").mouseenter(
-                    function(_e) {
-                        if (_this.isEditable()) {
-                            _e.preventDefault();
-                            _this.$.find(".Rk-CurrentUser-Color").css("background", $(this).attr("data-color"));
-                        }
-                    }
-            );
-        }
-
-        if (_renkan.options.show_search_field) {
-
-            var lastval = '';
-
-            this.$.find(".Rk-GraphSearch-Field").on("keyup change paste input", function() {
-                var $this = $(this),
-                val = $this.val();
-                if (val === lastval) {
-                    return;
-                }
-                lastval = val;
-                if (val.length < 2) {
-                    _renkan.project.get("nodes").each(function(n) {
-                        _this.getRepresentationByModel(n).unhighlight();
-                    });
-                } else {
-                    var rxs = Utils.regexpFromTextOrArray(val);
-                    _renkan.project.get("nodes").each(function(n) {
-                        if (rxs.test(n.get("title")) || rxs.test(n.get("description"))) {
-                            _this.getRepresentationByModel(n).highlight(rxs);
-                        } else {
-                            _this.getRepresentationByModel(n).unhighlight();
-                        }
-                    });
-                }
-            });
-        }
-
-        this.redraw();
-
-        window.setInterval(function() {
-            var _now = new Date().valueOf();
-            _this.delete_list.forEach(function(d) {
-                if (_now >= d.time) {
-                    var el = _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id});
-                    if (el) {
-                        project.removeNode(el);
-                    }
-                    el = _renkan.project.get("edges").findWhere({"delete_scheduled":d.id});
-                    if (el) {
-                        project.removeEdge(el);
-                    }
-                }
-            });
-            _this.delete_list = _this.delete_list.filter(function(d) {
-                return _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id}) || _renkan.project.get("edges").findWhere({"delete_scheduled":d.id});
-            });
-        }, 500);
-
-        if (this.minimap) {
-            window.setInterval(function() {
-                _this.rescaleMinimap();
-            }, 2000);
-        }
-
-    };
-
-    _(Scene.prototype).extend({
-        template: _.template(
-                '<% if (options.show_top_bar) { %><div class="Rk-TopBar"><% if (!options.editor_mode) { %><h2 class="Rk-PadTitle"><%- project.get("title") || translate("Untitled project")%></h2>' +
-                '<% } else { %><input type="text" class="Rk-PadTitle" value="<%- project.get("title") || "" %>" placeholder="<%-translate("Untitled project")%>" /><% } %>' +
-                '<% if (options.show_user_list) { %><div class="Rk-Users"><div class="Rk-CurrentUser"><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-CurrentUser-Color"><% if (options.user_color_editable) { %><span class="Rk-Edit-ColorTip"></span><% } %></span>' +
-                '<% if (options.user_color_editable) { print(colorPicker) } %></div><span class="Rk-CurrentUser-Name">&lt;unknown user&gt;</span></div><ul class="Rk-UserList"></ul></div><% } %>' +
-                '<% if (options.home_button_url) {%><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Home-Button" href="<%- options.home_button_url %>"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents">' +
-                '<%- translate(options.home_button_title) %></div></div></a><% } %>' +
-                '<% if (options.show_fullscreen_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-FullScreen-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Full Screen")%></div></div></div><% } %>' +
-                '<% if (options.editor_mode) { %>' +
-                '<% if (options.show_addnode_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddNode-Button"><div class="Rk-TopBar-Tooltip">' +
-                '<div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Node")%></div></div></div><% } %>' +
-                '<% if (options.show_addedge_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddEdge-Button"><div class="Rk-TopBar-Tooltip">' +
-                '<div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Edge")%></div></div></div><% } %>' +
-                '<% if (options.show_export_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Export-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Download Project")%></div></div></div><% } %>' +
-                '<% if (options.show_save_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Save-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"> </div></div></div><% } %>' +
-                '<% if (options.show_open_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Open-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Open Project")%></div></div></div><% } %>' +
-                '<% if (options.show_bookmarklet) { %><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Bookmarklet-Button" href="#"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents">' +
-                '<%-translate("Renkan \'Drag-to-Add\' bookmarklet")%></div></div></a><% } %>' +
-                '<% } else { %>' +
-                '<% if (options.show_export_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Export-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Download Project")%></div></div></div><div class="Rk-TopBar-Separator"></div><% } %>' +
-                '<% };' +
-                'if (options.show_search_field) { %>' +
-                '<form action="#" class="Rk-GraphSearch-Form"><input type="search" class="Rk-GraphSearch-Field" placeholder="<%- translate("Search in graph") %>" /></form><div class="Rk-TopBar-Separator"></div><% } %></div><% } %>' +
-                '<div class="Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>">' +
-                '<div class="Rk-Labels"></div><canvas class="Rk-Canvas" resize></canvas><div class="Rk-Notifications"></div><div class="Rk-Editor">' +
-                '<% if (options.show_bins) { %><div class="Rk-Fold-Bins">&laquo;</div><% } %>' +
-                '<div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%-translate("Zoom In")%>"></div><div class="Rk-ZoomFit" title="<%-translate("Zoom Fit")%>"></div><div class="Rk-ZoomOut" title="<%-translate("Zoom Out")%>"></div>' +
-                '<% if (options.editor_mode) { %><div class="Rk-ZoomSave" title="<%-translate("Zoom Save")%>"></div><% } %>' +
-                '<% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %><div class="Rk-ZoomSetSaved" title="<%-translate("View saved zoom")%>"></div><% } %></div>' +
-                '</div></div>'
-        ),
-        fixSize: function(_autoscale) {
-            var w = this.$.width(),
-            h = this.$.height();
-            if (this.renkan.options.show_top_bar) {
-                h -= this.$.find(".Rk-TopBar").height();
-            }
-            this.canvas_$.attr({
-                width: w,
-                height: h
-            });
-
-            paper.view.viewSize = new paper.Size([w, h]);
-
-            if (_autoscale) {
-                // If _autoscale, we get the initial view (zoom+offset) set in the project datas.
-                if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){
-                    this.autoScale(this.renkan.project.get("views")[parseInt(this.renkan.options.default_view)]);
-                }
-                else{
-                    this.autoScale();
-                }
-            }
-        },
-        drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
-            var _options = this.renkan.options,
-            _startRads = _startAngle * Math.PI / 180,
-            _endRads = _endAngle * Math.PI / 180,
-            _img = this.icon_cache[_imgname],
-            _startdx = - Math.sin(_startRads),
-            _startdy = Math.cos(_startRads),
-            _startXIn = Math.cos(_startRads) * _inR + _padding * _startdx,
-            _startYIn = Math.sin(_startRads) * _inR + _padding * _startdy,
-            _startXOut = Math.cos(_startRads) * _outR + _padding * _startdx,
-            _startYOut = Math.sin(_startRads) * _outR + _padding * _startdy,
-            _enddx = - Math.sin(_endRads),
-            _enddy = Math.cos(_endRads),
-            _endXIn = Math.cos(_endRads) * _inR - _padding * _enddx,
-            _endYIn = Math.sin(_endRads) * _inR - _padding * _enddy,
-            _endXOut = Math.cos(_endRads) * _outR - _padding * _enddx,
-            _endYOut = Math.sin(_endRads) * _outR - _padding * _enddy,
-            _centerR = (_inR + _outR) / 2,
-            _centerRads = (_startRads + _endRads) / 2,
-            _centerX = Math.cos(_centerRads) * _centerR,
-            _centerY = Math.sin(_centerRads) * _centerR,
-            _centerXIn = Math.cos(_centerRads) * _inR,
-            _centerXOut = Math.cos(_centerRads) * _outR,
-            _centerYIn = Math.sin(_centerRads) * _inR,
-            _centerYOut = Math.sin(_centerRads) * _outR,
-            _textX = Math.cos(_centerRads) * (_outR + 3),
-            _textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2;
-            this.buttons_layer.activate();
-            var _path = new paper.Path();
-            _path.add([_startXIn, _startYIn]);
-            _path.arcTo([_centerXIn, _centerYIn], [_endXIn, _endYIn]);
-            _path.lineTo([_endXOut,  _endYOut]);
-            _path.arcTo([_centerXOut, _centerYOut], [_startXOut, _startYOut]);
-            _path.fillColor = _options.buttons_background;
-            _path.opacity = 0.5;
-            _path.closed = true;
-            _path.__representation = _repr;
-            var _text = new paper.PointText(_textX,_textY);
-            _text.characterStyle = {
-                    fontSize: _options.buttons_label_font_size,
-                    fillColor: _options.buttons_label_color
-            };
-            if (_textX > 2) {
-                _text.paragraphStyle.justification = 'left';
-            } else if (_textX < -2) {
-                _text.paragraphStyle.justification = 'right';
-            } else {
-                _text.paragraphStyle.justification = 'center';
-            }
-            _text.visible = false;
-            var _visible = false,
-            _restPos = new paper.Point(-200, -200),
-            _grp = new paper.Group([_path, _text]),
-            _delta = _grp.position,
-            _imgdelta = new paper.Point([_centerX, _centerY]),
-            _currentPos = new paper.Point(0,0);
-            _text.content = _caption;
-            _grp.visible = false;
-            _grp.position = _restPos;
-            var _res = {
-                    show: function() {
-                        _visible = true;
-                        _grp.position = _currentPos.add(_delta);
-                        _grp.visible = true;
-                    },
-                    moveTo: function(_point) {
-                        _currentPos = _point;
-                        if (_visible) {
-                            _grp.position = _point.add(_delta);
-                        }
-                    },
-                    hide: function() {
-                        _visible = false;
-                        _grp.visible = false;
-                        _grp.position = _restPos;
-                    },
-                    select: function() {
-                        _path.opacity = 0.8;
-                        _text.visible = true;
-                    },
-                    unselect: function() {
-                        _path.opacity = 0.5;
-                        _text.visible = false;
-                    },
-                    destroy: function() {
-                        _grp.remove();
-                    }
-            };
-            var showImage = function() {
-                var _raster = new paper.Raster(_img);
-                _raster.position = _imgdelta.add(_grp.position).subtract(_delta);
-                _raster.locked = true; // Disable mouse events on icon
-                _grp.addChild(_raster);
-            };
-            if (_img.width) {
-                showImage();
-            } else {
-                $(_img).on("load",showImage);
-            }
-
-            return _res;
-        },
-        addToBundles: function(_edgeRepr) {
-            var _bundle = _(this.bundles).find(function(_bundle) {
-                return (
-                        ( _bundle.from === _edgeRepr.from_representation && _bundle.to === _edgeRepr.to_representation ) ||
-                        ( _bundle.from === _edgeRepr.to_representation && _bundle.to === _edgeRepr.from_representation )
-                );
-            });
-            if (typeof _bundle !== "undefined") {
-                _bundle.edges.push(_edgeRepr);
-            } else {
-                _bundle = {
-                        from: _edgeRepr.from_representation,
-                        to: _edgeRepr.to_representation,
-                        edges: [ _edgeRepr ],
-                        getPosition: function(_er) {
-                            var _dir = (_er.from_representation === this.from) ? 1 : -1;
-                            return _dir * ( _(this.edges).indexOf(_er) - (this.edges.length - 1) / 2 );
-                        }
-                };
-                this.bundles.push(_bundle);
-            }
-            return _bundle;
-        },
-        isEditable: function() {
-            return (this.renkan.options.editor_mode && !this.renkan.read_only);
-        },
-        onStatusChange: function() {
-            var savebtn = this.$.find(".Rk-Save-Button"),
-            tip = savebtn.find(".Rk-TopBar-Tooltip-Contents");
-            if (this.renkan.read_only) {
-                savebtn.removeClass("disabled Rk-Save-Online").addClass("Rk-Save-ReadOnly");
-                tip.text(this.renkan.translate("Connection lost"));
-            } else {
-                if (this.renkan.options.snapshot_mode) {
-                    savebtn.removeClass("Rk-Save-ReadOnly Rk-Save-Online");
-                    tip.text(this.renkan.translate("Save Project"));
-                } else {
-                    savebtn.removeClass("disabled Rk-Save-ReadOnly").addClass("Rk-Save-Online");
-                    tip.text(this.renkan.translate("Auto-save enabled"));
-                }
-            }
-            this.redrawUsers();
-        },
-        setScale: function(_newScale, _offset) {
-            if ((_newScale/this.initialScale) > Utils._MIN_SCALE && (_newScale/this.initialScale) < Utils._MAX_SCALE) {
-                this.scale = _newScale;
-                if (_offset) {
-                    this.offset = _offset;
-                }
-                this.redraw();
-            }
-        },
-        autoScale: function(force_view) {
-            var nodes = this.renkan.project.get("nodes");
-            if (nodes.length > 1) {
-                var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
-                _yy = nodes.map(function(_node) { return _node.get("position").y; }),
-                _minx = Math.min.apply(Math, _xx),
-                _miny = Math.min.apply(Math, _yy),
-                _maxx = Math.max.apply(Math, _xx),
-                _maxy = Math.max.apply(Math, _yy);
-                var _scale = Math.min( (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny));
-                this.initialScale = _scale;
-                // Override calculated scale if asked
-                if((typeof force_view !== "undefined") && parseFloat(force_view.zoom_level)>0 && parseFloat(force_view.offset.x)>0 && parseFloat(force_view.offset.y)>0){
-                    this.setScale(parseFloat(force_view.zoom_level), new paper.Point(parseFloat(force_view.offset.x), parseFloat(force_view.offset.y)));
-                }
-                else{
-                    this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)));
-                }
-            }
-            if (nodes.length === 1) {
-                this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y])));
-            }
-        },
-        redrawMiniframe: function() {
-            var topleft = this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))),
-            bottomright = this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight));
-            this.minimap.miniframe.fitBounds(topleft, bottomright);
-        },
-        rescaleMinimap: function() {
-            var nodes = this.renkan.project.get("nodes");
-            if (nodes.length > 1) {
-                var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
-                _yy = nodes.map(function(_node) { return _node.get("position").y; }),
-                _minx = Math.min.apply(Math, _xx),
-                _miny = Math.min.apply(Math, _yy),
-                _maxx = Math.max.apply(Math, _xx),
-                _maxy = Math.max.apply(Math, _yy);
-                var _scale = Math.min(
-                        this.scale * 0.8 * this.renkan.options.minimap_width / paper.view.bounds.width,
-                        this.scale * 0.8 * this.renkan.options.minimap_height / paper.view.bounds.height,
-                        ( this.renkan.options.minimap_width - 2 * this.renkan.options.minimap_padding ) / (_maxx - _minx),
-                        ( this.renkan.options.minimap_height - 2 * this.renkan.options.minimap_padding ) / (_maxy - _miny)
-                );
-                this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale));
-                this.minimap.scale = _scale;
-            }
-            if (nodes.length === 1) {
-                this.minimap.scale = 0.1;
-                this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y]).multiply(this.minimap.scale));
-            }
-            this.redraw();
-        },
-        toPaperCoords: function(_point) {
-            return _point.multiply(this.scale).add(this.offset);
-        },
-        toMinimapCoords: function(_point) {
-            return _point.multiply(this.minimap.scale).add(this.minimap.offset).add(this.minimap.topleft);
-        },
-        toModelCoords: function(_point) {
-            return _point.subtract(this.offset).divide(this.scale);
-        },
-        addRepresentation: function(_type, _model) {
-            var RendererType = requtils.getRenderer()[_type];
-            var _repr = new RendererType(this, _model);
-            this.representations.push(_repr);
-            return _repr;
-        },
-        addRepresentations: function(_type, _collection) {
-            var _this = this;
-            _collection.forEach(function(_model) {
-                _this.addRepresentation(_type, _model);
-            });
-        },
-        userTemplate: _.template(
-                '<li class="Rk-User"><span class="Rk-UserColor" style="background:<%=background%>;"></span><%=name%></li>'
-        ),
-        redrawUsers: function() {
-            if (!this.renkan.options.show_user_list) {
-                return;
-            }
-            var allUsers = [].concat((this.renkan.project.current_user_list || {}).models || [], (this.renkan.project.get("users") || {}).models || []),
-            ulistHtml = '',
-            $userpanel = this.$.find(".Rk-Users"),
-            $name = $userpanel.find(".Rk-CurrentUser-Name"),
-            $cpitems = $userpanel.find(".Rk-Edit-ColorPicker li"),
-            $colorsquare = $userpanel.find(".Rk-CurrentUser-Color"),
-            _this = this;
-            $name.off("click").text(this.renkan.translate("<unknown user>"));
-            $cpitems.off("mouseleave click");
-            allUsers.forEach(function(_user) {
-                if (_user.get("_id") === _this.renkan.current_user) {
-                    $name.text(_user.get("title"));
-                    $colorsquare.css("background", _user.get("color"));
-                    if (_this.isEditable()) {
-
-                        if (_this.renkan.options.user_name_editable) {
-                            $name.click(function() {
-                                var $this = $(this),
-                                $input = $('<input>').val(_user.get("title")).blur(function() {
-                                    _user.set("title", $(this).val());
-                                    _this.redrawUsers();
-                                    _this.redraw();
-                                });
-                                $this.empty().html($input);
-                                $input.select();
-                            });
-                        }
-
-                        if (_this.renkan.options.user_color_editable) {
-                            $cpitems.click(
-                                    function(_e) {
-                                        _e.preventDefault();
-                                        if (_this.isEditable()) {
-                                            _user.set("color", $(this).attr("data-color"));
-                                        }
-                                        $(this).parent().hide();
-                                    }
-                            ).mouseleave(function() {
-                                $colorsquare.css("background", _user.get("color"));
-                            });
-                        }
-                    }
-
-                } else {
-                    ulistHtml += _this.userTemplate({
-                        name: _user.get("title"),
-                        background: _user.get("color")
-                    });
-                }
-            });
-            $userpanel.find(".Rk-UserList").html(ulistHtml);
-        },
-        removeRepresentation: function(_representation) {
-            _representation.destroy();
-            this.representations = _(this.representations).reject(
-                    function(_repr) {
-                        return _repr === _representation;
-                    }
-            );
-        },
-        getRepresentationByModel: function(_model) {
-            if (!_model) {
-                return undefined;
-            }
-            return _(this.representations).find(function(_repr) {
-                return _repr.model === _model;
-            });
-        },
-        removeRepresentationsOfType: function(_type) {
-            var _representations = _(this.representations).filter(function(_repr) {
-                return _repr.type === _type;
-            }),
-            _this = this;
-            _(_representations).each(function(_repr) {
-                _this.removeRepresentation(_repr);
-            });
-        },
-        highlightModel: function(_model) {
-            var _repr = this.getRepresentationByModel(_model);
-            if (_repr) {
-                _repr.highlight();
-            }
-        },
-        unhighlightAll: function(_model) {
-            _(this.representations).each(function(_repr) {
-                _repr.unhighlight();
-            });
-        },
-        unselectAll: function(_model) {
-            _(this.representations).each(function(_repr) {
-                _repr.unselect();
-            });
-        },
-        redraw: function() {
-            if(! this.redrawActive ) {
-                return;
-            }
-            _(this.representations).each(function(_representation) {
-                _representation.redraw(true);
-            });
-            if (this.minimap) {
-                this.redrawMiniframe();
-            }
-            paper.view.draw();
-        },
-        addTempEdge: function(_from, _point) {
-            var _tmpEdge = this.addRepresentation("TempEdge",null);
-            _tmpEdge.end_pos = _point;
-            _tmpEdge.from_representation = _from;
-            _tmpEdge.redraw();
-            this.click_target = _tmpEdge;
-        },
-        findTarget: function(_hitResult) {
-            if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
-                var _newTarget = _hitResult.item.__representation;
-                if (this.selected_target !== _hitResult.item.__representation) {
-                    if (this.selected_target) {
-                        this.selected_target.unselect(_newTarget);
-                    }
-                    _newTarget.select(this.selected_target);
-                    this.selected_target = _newTarget;
-                }
-            } else {
-                if (this.selected_target) {
-                    this.selected_target.unselect();
-                }
-                this.selected_target = null;
-            }
-        },
-        paperShift: function(_delta) {
-            this.offset = this.offset.add(_delta);
-            this.redraw();
-        },
-        onMouseMove: function(_event) {
-            var _off = this.canvas_$.offset(),
-            _point = new paper.Point([
-                                      _event.pageX - _off.left,
-                                      _event.pageY - _off.top
-                                      ]),
-                                      _delta = _point.subtract(this.last_point);
-            this.last_point = _point;
-            if (!this.is_dragging && this.mouse_down && _delta.length > Utils._MIN_DRAG_DISTANCE) {
-                this.is_dragging = true;
-            }
-            var _hitResult = paper.project.hitTest(_point);
-            if (this.is_dragging) {
-                if (this.click_target && typeof this.click_target.paperShift === "function") {
-                    this.click_target.paperShift(_delta);
-                } else {
-                    this.paperShift(_delta);
-                }
-            } else {
-                this.findTarget(_hitResult);
-            }
-            paper.view.draw();
-        },
-        onMouseDown: function(_event, _isTouch) {
-            var _off = this.canvas_$.offset(),
-            _point = new paper.Point([
-                                      _event.pageX - _off.left,
-                                      _event.pageY - _off.top
-                                      ]);
-            this.last_point = _point;
-            this.mouse_down = true;
-            if (!this.click_target || this.click_target.type !== "Temp-edge") {
-                this.removeRepresentationsOfType("editor");
-                this.is_dragging = false;
-                var _hitResult = paper.project.hitTest(_point);
-                if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
-                    this.click_target = _hitResult.item.__representation;
-                    this.click_target.mousedown(_event, _isTouch);
-                } else {
-                    this.click_target = null;
-                    if (this.isEditable() && this.click_mode === Utils._CLICKMODE_ADDNODE) {
-                        var _coords = this.toModelCoords(_point),
-                        _data = {
-                            id: Utils.getUID('node'),
-                            created_by: this.renkan.current_user,
-                            position: {
-                                x: _coords.x,
-                                y: _coords.y
-                            }
-                        };
-                        _node = this.renkan.project.addNode(_data);
-                        this.getRepresentationByModel(_node).openEditor();
-                    }
-                }
-            }
-            if (this.click_mode) {
-                if (this.isEditable() && this.click_mode === Utils._CLICKMODE_STARTEDGE && this.click_target && this.click_target.type === "Node") {
-                    this.removeRepresentationsOfType("editor");
-                    this.addTempEdge(this.click_target, _point);
-                    this.click_mode = Utils._CLICKMODE_ENDEDGE;
-                    this.notif_$.fadeOut(function() {
-                        $(this).html(this.renkan.translate("Click on a second node to complete the edge")).fadeIn();
-                    });
-                } else {
-                    this.notif_$.hide();
-                    this.click_mode = false;
-                }
-            }
-            paper.view.draw();
-        },
-        onMouseUp: function(_event, _isTouch) {
-            this.mouse_down = false;
-            if (this.click_target) {
-                var _off = this.canvas_$.offset();
-                this.click_target.mouseup(
-                        {
-                            point: new paper.Point([
-                                                    _event.pageX - _off.left,
-                                                    _event.pageY - _off.top
-                                                    ])
-                        },
-                        _isTouch
-                );
-            } else {
-                this.click_target = null;
-                this.is_dragging = false;
-                if (_isTouch) {
-                    this.unselectAll();
-                }
-            }
-            paper.view.draw();
-        },
-        onScroll: function(_event, _scrolldelta) {
-            this.totalScroll += _scrolldelta;
-            if (Math.abs(this.totalScroll) >= 1) {
-                var _off = this.canvas_$.offset(),
-                _delta = new paper.Point([
-                                          _event.pageX - _off.left,
-                                          _event.pageY - _off.top
-                                          ]).subtract(this.offset).multiply( Math.SQRT2 - 1 );
-                if (this.totalScroll > 0) {
-                    this.setScale( this.scale * Math.SQRT2, this.offset.subtract(_delta) );
-                } else {
-                    this.setScale( this.scale * Math.SQRT1_2, this.offset.add(_delta.divide(Math.SQRT2)));
-                }
-                this.totalScroll = 0;
-            }
-        },
-        onDoubleClick: function(_event) {
-            if (!this.isEditable()) {
-                return;
-            }
-            var _off = this.canvas_$.offset(),
-            _point = new paper.Point([
-                                      _event.pageX - _off.left,
-                                      _event.pageY - _off.top
-                                      ]);
-            var _hitResult = paper.project.hitTest(_point);
-            if (this.isEditable() && (!_hitResult || typeof _hitResult.item.__representation === "undefined")) {
-                var _coords = this.toModelCoords(_point),
-                _data = {
-                    id: Utils.getUID('node'),
-                    created_by: this.renkan.current_user,
-                    position: {
-                        x: _coords.x,
-                        y: _coords.y
-                    }
-                },
-                _node = this.renkan.project.addNode(_data);
-                this.getRepresentationByModel(_node).openEditor();
-            }
-            paper.view.draw();
-        },
-        defaultDropHandler: function(_data) {
-            var newNode = {};
-            var snippet = "";
-            switch(_data["text/x-iri-specific-site"]) {
-                case "twitter":
-                    snippet = $('<div>').html(_data["text/x-iri-selected-html"]);
-                    var tweetdiv = snippet.find(".tweet");
-                    newNode.title = this.renkan.translate("Tweet by ") + tweetdiv.attr("data-name");
-                    newNode.uri = "http://twitter.com/" + tweetdiv.attr("data-screen-name") + "/status/" + tweetdiv.attr("data-tweet-id");
-                    newNode.image = tweetdiv.find(".avatar").attr("src");
-                    newNode.description = tweetdiv.find(".js-tweet-text:first").text();
-                    break;
-                case "google":
-                    snippet = $('<div>').html(_data["text/x-iri-selected-html"]);
-                    newNode.title = snippet.find("h3:first").text().trim();
-                    newNode.uri = snippet.find("h3 a").attr("href");
-                    newNode.description = snippet.find(".st:first").text().trim();
-                    break;
-                default:
-                    if (_data["text/x-iri-source-uri"]) {
-                        newNode.uri = _data["text/x-iri-source-uri"];
-                    }
-            }
-            if (_data["text/plain"] || _data["text/x-iri-selected-text"]) {
-                newNode.description = (_data["text/plain"] || _data["text/x-iri-selected-text"]).replace(/[\s\n]+/gm,' ').trim();
-            }
-            if (_data["text/html"] || _data["text/x-iri-selected-html"]) {
-                snippet = $('<div>').html(_data["text/html"] || _data["text/x-iri-selected-html"]);
-                var _svgimgs = snippet.find("image");
-                if (_svgimgs.length) {
-                    newNode.image = _svgimgs.attr("xlink:href");
-                }
-                var _svgpaths = snippet.find("path");
-                if (_svgpaths.length) {
-                    newNode.clipPath = _svgpaths.attr("d");
-                }
-                var _imgs = snippet.find("img");
-                if (_imgs.length) {
-                    newNode.image = _imgs[0].src;
-                }
-                var _as = snippet.find("a");
-                if (_as.length) {
-                    newNode.uri = _as[0].href;
-                }
-                newNode.title = snippet.find("[title]").attr("title") || newNode.title;
-                newNode.description = snippet.text().replace(/[\s\n]+/gm,' ').trim();
-            }
-            if (_data["text/uri-list"]) {
-                newNode.uri = _data["text/uri-list"];
-            }
-            if (_data["text/x-moz-url"] && !newNode.title) {
-                newNode.title = (_data["text/x-moz-url"].split("\n")[1] || "").trim();
-                if (newNode.title === newNode.uri) {
-                    newNode.title = false;
-                }
-            }
-            if (_data["text/x-iri-source-title"] && !newNode.title) {
-                newNode.title = _data["text/x-iri-source-title"];
-            }
-            if (_data["text/html"] || _data["text/x-iri-selected-html"]) {
-                snippet = $('<div>').html(_data["text/html"] || _data["text/x-iri-selected-html"]);
-                newNode.image = snippet.find("[data-image]").attr("data-image") || newNode.image;
-                newNode.uri = snippet.find("[data-uri]").attr("data-uri") || newNode.uri;
-                newNode.title = snippet.find("[data-title]").attr("data-title") || newNode.title;
-                newNode.description = snippet.find("[data-description]").attr("data-description") || newNode.description;
-                newNode.clipPath = snippet.find("[data-clip-path]").attr("data-clip-path") || newNode.clipPath;
-            }
-
-            if (!newNode.title) {
-                newNode.title = this.renkan.translate("Dragged resource");
-            }
-            var fields = ["title", "description", "uri", "image"];
-            for (var i = 0; i < fields.length; i++) {
-                var f = fields[i];
-                if (_data["text/x-iri-" + f] || _data[f]) {
-                    newNode[f] = _data["text/x-iri-" + f] || _data[f];
-                }
-                if (newNode[f] === "none" || newNode[f] === "null") {
-                    newNode[f] = undefined;
-                }
-            }
-
-            if(typeof this.renkan.options.drop_enhancer === "function"){
-                newNode = this.renkan.options.drop_enhancer(newNode, _data);
-            }
-
-            return newNode;
-
-        },
-        dropData: function(_data, _event) {
-            if (!this.isEditable()) {
-                return;
-            }
-            if (_data["text/json"] || _data["application/json"]) {
-                try {
-                    var jsondata = JSON.parse(_data["text/json"] || _data["application/json"]);
-                    _(_data).extend(jsondata);
-                }
-                catch(e) {}
-            }
-
-            var newNode = (typeof this.renkan.options.drop_handler === "undefined")?this.defaultDropHandler(_data):this.renkan.options.drop_handler(_data);
-
-            var _off = this.canvas_$.offset(),
-            _point = new paper.Point([
-                                      _event.pageX - _off.left,
-                                      _event.pageY - _off.top
-                                      ]),
-                                      _coords = this.toModelCoords(_point),
-                                      _nodedata = {
-                id: Utils.getUID('node'),
-                created_by: this.renkan.current_user,
-                uri: newNode.uri || "",
-                title: newNode.title || "",
-                description: newNode.description || "",
-                image: newNode.image || "",
-                color: newNode.color || undefined,
-                clip_path: newNode.clipPath || undefined,
-                position: {
-                    x: _coords.x,
-                    y: _coords.y
-                }
-            };
-            var _node = this.renkan.project.addNode(_nodedata),
-            _repr = this.getRepresentationByModel(_node);
-            if (_event.type === "drop") {
-                _repr.openEditor();
-            }
-        },
-        fullScreen: function() {
-            var _isFull = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen,
-              _el = this.renkan.$[0],
-              _requestMethods = ["requestFullScreen","mozRequestFullScreen","webkitRequestFullScreen"],
-              _cancelMethods = ["cancelFullScreen","mozCancelFullScreen","webkitCancelFullScreen"],
-              i;
-            if (_isFull) {
-                for (i = 0; i < _cancelMethods.length; i++) {
-                    if (typeof document[_cancelMethods[i]] === "function") {
-                        document[_cancelMethods[i]]();
-                        break;
-                    }
-                }
-            } else {
-                for (i = 0; i < _requestMethods.length; i++) {
-                    if (typeof _el[_requestMethods[i]] === "function") {
-                        _el[_requestMethods[i]]();
-                        break;
-                    }
-                }
-            }
-        },
-        zoomOut: function() {
-            var _newScale = this.scale * Math.SQRT1_2,
-            _offset = new paper.Point([
-                                       this.canvas_$.width(),
-                                       this.canvas_$.height()
-                                       ]).multiply( 0.5 * ( 1 - Math.SQRT1_2 ) ).add(this.offset.multiply( Math.SQRT1_2 ));
-            this.setScale( _newScale, _offset );
-        },
-        zoomIn: function() {
-            var _newScale = this.scale * Math.SQRT2,
-            _offset = new paper.Point([
-                                       this.canvas_$.width(),
-                                       this.canvas_$.height()
-                                       ]).multiply( 0.5 * ( 1 - Math.SQRT2 ) ).add(this.offset.multiply( Math.SQRT2 ));
-            this.setScale( _newScale, _offset );
-        },
-        addNodeBtn: function() {
-            if (this.click_mode === Utils._CLICKMODE_ADDNODE) {
-                this.click_mode = false;
-                this.notif_$.hide();
-            } else {
-                this.click_mode = Utils._CLICKMODE_ADDNODE;
-                this.notif_$.text(this.renkan.translate("Click on the background canvas to add a node")).fadeIn();
-            }
-            return false;
-        },
-        addEdgeBtn: function() {
-            if (this.click_mode === Utils._CLICKMODE_STARTEDGE || this.click_mode === Utils._CLICKMODE_ENDEDGE) {
-                this.click_mode = false;
-                this.notif_$.hide();
-            } else {
-                this.click_mode = Utils._CLICKMODE_STARTEDGE;
-                this.notif_$.text(this.renkan.translate("Click on a first node to start the edge")).fadeIn();
-            }
-            return false;
-        },
-        exportProject: function() {
-          var projectJSON = this.renkan.project.toJSON(),
-              downloadLink = document.createElement("a"),
-              projectId = projectJSON.id,
-              fileNameToSaveAs = projectId + ".json";
-
-          // clean ids
-          delete projectJSON.id;
-          delete projectJSON._id;
-          delete projectJSON.space_id;
-
-          var objId;
-          var idsMap = {};
-
-          _.each(projectJSON.nodes, function(e,i,l) {
-            objId = e.id || e._id;
-            delete e._id;
-            delete e.id;
-            idsMap[objId] = e['@id'] = Utils.getUUID4();
-          });
-          _.each(projectJSON.edges, function(e,i,l) {
-            delete e._id;
-            delete e.id;
-            e.to = idsMap[e.to];
-            e.from = idsMap[e.from];
-          });
-          _.each(projectJSON.views, function(e,i,l) {
-            objId = e.id || e._id;
-            delete e._id;
-            delete e.id;
-          });
-          projectJSON.users = [];
-
-          var projectJSONStr = JSON.stringify(projectJSON, null, 2);
-          var blob = new Blob([projectJSONStr], {type: "application/json;charset=utf-8"});
-          filesaver(blob,fileNameToSaveAs);
-
-        },
-        foldBins: function() {
-            var foldBinsButton = this.$.find(".Rk-Fold-Bins"),
-            bins = this.renkan.$.find(".Rk-Bins");
-            var _this = this;
-            if (bins.offset().left < 0) {
-                bins.animate({left: 0},250);
-                this.$.animate({left: 300},250,function() {
-                    var w = _this.$.width();
-                    paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);
-                });
-                foldBinsButton.html("&laquo;");
-            } else {
-                bins.animate({left: -300},250);
-                this.$.animate({left: 0},250,function() {
-                    var w = _this.$.width();
-                    paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);
-                });
-                foldBinsButton.html("&raquo;");
-            }
-        },
-        save: function() { },
-        open: function() { }
-    });
-
-    /* Scene End */
-
-    return Scene;
-
-});
-
-
-//Load modules and use them
-if( typeof require.config === "function" ) {
-    require.config({
-        paths: {
-            'jquery': '../lib/jquery.min',
-            'underscore': '../lib/underscore-min',
-            'filesaver' : '../lib/FileSaver',
-            'requtils':'require-utils'
-        }
-    });
-}
-
-require(['renderer/baserepresentation',
-         'renderer/basebutton',
-         'renderer/noderepr',
-         'renderer/edge',
-         'renderer/tempedge',
-         'renderer/baseeditor',
-         'renderer/nodeeditor',
-         'renderer/edgeeditor',
-         'renderer/nodebutton',
-         'renderer/nodeeditbutton',
-         'renderer/noderemovebutton',
-         'renderer/noderevertbutton',
-         'renderer/nodelinkbutton',
-         'renderer/nodeenlargebutton',
-         'renderer/nodeshrinkbutton',
-         'renderer/edgeeditbutton',
-         'renderer/edgeremovebutton',
-         'renderer/edgerevertbutton',
-         'renderer/miniframe',
-         'renderer/scene'
-         ], function(BaseRepresentation, BaseButton, NodeRepr, Edge, TempEdge, BaseEditor, NodeEditor, EdgeEditor, NodeButton, NodeEditButton, NodeRemoveButton, NodeRevertButton, NodeLinkButton, NodeEnlargeButton, NodeShrinkButton, EdgeEditButton, EdgeRemoveButton, EdgeRevertButton, MiniFrame, Scene){
-
-    
-
-    var Rkns = window.Rkns;
-
-    if(typeof Rkns.Renderer === "undefined"){
-        Rkns.Renderer = {};
-    }
-    var Renderer = Rkns.Renderer;
-
-    Renderer._BaseRepresentation = BaseRepresentation;
-    Renderer._BaseButton = BaseButton;
-    Renderer.Node = NodeRepr;
-    Renderer.Edge = Edge;
-    Renderer.TempEdge = TempEdge;
-    Renderer._BaseEditor = BaseEditor;
-    Renderer.NodeEditor = NodeEditor;
-    Renderer.EdgeEditor = EdgeEditor;
-    Renderer._NodeButton = NodeButton;
-    Renderer.NodeEditButton = NodeEditButton;
-    Renderer.NodeRemoveButton = NodeRemoveButton;
-    Renderer.NodeRevertButton = NodeRevertButton;
-    Renderer.NodeLinkButton = NodeLinkButton;
-    Renderer.NodeEnlargeButton = NodeEnlargeButton;
-    Renderer.NodeShrinkButton = NodeShrinkButton;
-    Renderer.EdgeEditButton = EdgeEditButton;
-    Renderer.EdgeRemoveButton = EdgeRemoveButton;
-    Renderer.EdgeRevertButton = EdgeRevertButton;
-    Renderer.MiniFrame = MiniFrame;
-    Renderer.Scene = Scene;
-    
-    startRenkan();
-});
-
-define("main-renderer", function(){});
-
--- a/src/hdalab/static/hdalab/lib/renkan/renkan.min.js	Fri Jul 18 13:29:53 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*! 
- *    _____            _               
- *   |  __ \          | |              
- *   | |__) |___ _ __ | | ____ _ _ __  
- *   |  _  // _ \ '_ \| |/ / _` | '_ \ 
- *   | | \ \  __/ | | |   < (_| | | | |
- *   |_|  \_\___|_| |_|_|\_\__,_|_| |_|
- *
- *  Copyright 2012-2013 Institut de recherche et d'innovation 
- *  contributor(s) : Yves-Marie Haussonne, Raphael Velt, Samuel Huron
- *   
- *  contact@iri.centrepompidou.fr
- *  http://www.iri.centrepompidou.fr 
- *   
- *  This software is a computer program whose purpose is to show and add annotations on a video .
- *  This software is governed by the CeCILL-C license under French law and
- *  abiding by the rules of distribution of free software. You can  use, 
- *  modify and/ or redistribute the software under the terms of the CeCILL-C
- *  license as circulated by CEA, CNRS and INRIA at the following URL
- *  "http://www.cecill.info". 
- *  
- *  The fact that you are presently reading this means that you have had
- *  knowledge of the CeCILL-C license and that you accept its terms.
- */
-/*! renkan - v0.7.10 - Copyright © IRI 2014 */
-
-
-!function(a){"use strict";"object"!=typeof a.Rkns&&(a.Rkns={});var b=a.Rkns,c=b.$=a.jQuery,d=b._=a._;b.pickerColors=["#8f1919","#a80000","#d82626","#ff0000","#e87c7c","#ff6565","#f7d3d3","#fecccc","#8f5419","#a85400","#d87f26","#ff7f00","#e8b27c","#ffb265","#f7e5d3","#fee5cc","#8f8f19","#a8a800","#d8d826","#feff00","#e8e87c","#feff65","#f7f7d3","#fefecc","#198f19","#00a800","#26d826","#00ff00","#7ce87c","#65ff65","#d3f7d3","#ccfecc","#198f8f","#00a8a8","#26d8d8","#00feff","#7ce8e8","#65feff","#d3f7f7","#ccfefe","#19198f","#0000a8","#2626d8","#0000ff","#7c7ce8","#6565ff","#d3d3f7","#ccccfe","#8f198f","#a800a8","#d826d8","#ff00fe","#e87ce8","#ff65fe","#f7d3f7","#feccfe","#000000","#242424","#484848","#6d6d6d","#919191","#b6b6b6","#dadada","#ffffff"],b.__renkans=[];var e=b._BaseBin=function(a,c){if("undefined"!=typeof a){this.renkan=a,this.renkan.$.find(".Rk-Bin-Main").hide(),this.$=b.$("<li>").addClass("Rk-Bin").appendTo(a.$.find(".Rk-Bin-List")),this.title_icon_$=b.$("<span>").addClass("Rk-Bin-Title-Icon").appendTo(this.$);var d=this;b.$("<a>").attr({href:"#",title:a.translate("Close bin")}).addClass("Rk-Bin-Close").html("&times;").appendTo(this.$).click(function(){return d.destroy(),a.$.find(".Rk-Bin-Main:visible").length||a.$.find(".Rk-Bin-Main:last").slideDown(),a.resizeBins(),!1}),b.$("<a>").attr({href:"#",title:a.translate("Refresh bin")}).addClass("Rk-Bin-Refresh").appendTo(this.$).click(function(){return d.refresh(),!1}),this.count_$=b.$("<div>").addClass("Rk-Bin-Count").appendTo(this.$),this.title_$=b.$("<h2>").addClass("Rk-Bin-Title").appendTo(this.$),this.main_$=b.$("<div>").addClass("Rk-Bin-Main").appendTo(this.$).html('<h4 class="Rk-Bin-Loading">'+a.translate("Loading, please wait")+"</h4>"),this.title_$.html(c.title||"(new bin)"),this.renkan.resizeBins(),c.auto_refresh&&window.setInterval(function(){d.refresh()},c.auto_refresh)}};e.prototype.destroy=function(){this.$.detach(),this.renkan.resizeBins()};var f=b.Renkan=function(a){var e=this;if(b.__renkans.push(this),this.options=d.defaults(a,b.defaults),d(this.options.property_files).each(function(a){b.$.getJSON(a,function(a){e.options.properties=e.options.properties.concat(a)})}),this.read_only=this.options.read_only||!this.options.editor_mode,this.project=new b.Models.Project,"undefined"!=typeof this.options.user_id&&(this.current_user=this.options.user_id),this.$=b.$("#"+this.options.container),this.$.addClass("Rk-Main").html(this.template(this)),this.tabs=[],this.search_engines=[],this.current_user_list=new b.Models.UsersList,this.current_user_list.on("add remove",function(){this.renderer&&this.renderer.redrawUsers()}),this.colorPicker=function(){var a=d.template('<li data-color="<%=c%>" style="background: <%=c%>"></li>');return'<ul class="Rk-Edit-ColorPicker">'+b.pickerColors.map(function(b){return a({c:b})}).join("")+"</ul>"}(),this.options.show_editor&&(this.renderer=new b.Renderer.Scene(this)),this.options.search.length){var f=d.template('<li class="<%= className %>" data-key="<%= key %>"><%= title %></li>'),g=this.$.find(".Rk-Search-List"),h=this.$.find(".Rk-Web-Search-Input"),i=this.$.find(".Rk-Web-Search-Form");d(this.options.search).each(function(a){b[a.type]&&b[a.type].Search&&e.search_engines.push(new b[a.type].Search(e,a))}),g.html(d(this.search_engines).map(function(a,b){return f({key:b,title:a.getSearchTitle(),className:a.getBgClass()})}).join("")),g.find("li").click(function(){var a=b.$(this);e.setSearchEngine(a.attr("data-key")),i.submit()}),i.submit(function(){if(h.val()){var a=e.search_engine;a.search(h.val())}return!1}),this.$.find(".Rk-Search-Current").mouseenter(function(){g.slideDown()}),this.$.find(".Rk-Search-Select").mouseleave(function(){g.hide()}),this.setSearchEngine(0)}else this.$.find(".Rk-Web-Search-Form").detach();d(this.options.bins).each(function(a){b[a.type]&&b[a.type].Bin&&e.tabs.push(new b[a.type].Bin(e,a))});var j=!1;this.$.find(".Rk-Bins").on("click",".Rk-Bin-Title,.Rk-Bin-Title-Icon",function(){var a=b.$(this).siblings(".Rk-Bin-Main");a.is(":hidden")&&(e.$.find(".Rk-Bin-Main").slideUp(),a.slideDown())}),this.options.show_editor&&this.$.find(".Rk-Bins").on("mouseover",".Rk-Bin-Item",function(){var a=b.$(this);if(a&&c(a).attr("data-uri")){var f=e.project.get("nodes").where({uri:c(a).attr("data-uri")});d(f).each(function(a){e.renderer.highlightModel(a)})}}).mouseout(function(){e.renderer.unhighlightAll()}).on("mousemove",".Rk-Bin-Item",function(){try{this.dragDrop()}catch(a){}}).on("touchstart",".Rk-Bin-Item",function(){j=!1}).on("touchmove",".Rk-Bin-Item",function(a){a.preventDefault();var b=a.originalEvent.changedTouches[0],c=e.renderer.canvas_$.offset(),d=e.renderer.canvas_$.width(),f=e.renderer.canvas_$.height();if(b.pageX>=c.left&&b.pageX<c.left+d&&b.pageY>=c.top&&b.pageY<c.top+f)if(j)e.renderer.onMouseMove(b,!0);else{j=!0;var g=document.createElement("div");g.appendChild(this.cloneNode(!0)),e.renderer.dropData({"text/html":g.innerHTML},b),e.renderer.onMouseDown(b,!0)}}).on("touchend",".Rk-Bin-Item",function(a){j&&e.renderer.onMouseUp(a.originalEvent.changedTouches[0],!0),j=!1}).on("dragstart",".Rk-Bin-Item",function(a){var b=document.createElement("div");b.appendChild(this.cloneNode(!0));try{a.originalEvent.dataTransfer.setData("text/html",b.innerHTML)}catch(c){a.originalEvent.dataTransfer.setData("text",b.innerHTML)}}),b.$(window).resize(function(){e.resizeBins()});var k=!1,l="";this.$.find(".Rk-Bins-Search-Input").on("change keyup paste input",function(){var a=b.$(this).val();if(a!==l){var c=b.Utils.regexpFromTextOrArray(a.length>1?a:null);c.source!==k&&(k=c.source,d(e.tabs).each(function(a){a.render(c)}))}}),this.$.find(".Rk-Bins-Search-Form").submit(function(){return!1})};f.prototype.template=d.template('<% if (options.show_bins) { %><div class="Rk-Bins"><div class="Rk-Bins-Head"><h2 class="Rk-Bins-Title"><%- translate("Select contents:")%></h2><form class="Rk-Web-Search-Form Rk-Search-Form"><input class="Rk-Web-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search the Web") %>" /><div class="Rk-Search-Select"><div class="Rk-Search-Current"></div><ul class="Rk-Search-List"></ul></div><input type="submit" value="" class="Rk-Web-Search-Submit Rk-Search-Submit" title="<%- translate("Search the Web") %>" /></form><form class="Rk-Bins-Search-Form Rk-Search-Form"><input class="Rk-Bins-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search in Bins") %>" /><input type="submit" value="" class="Rk-Bins-Search-Submit Rk-Search-Submit" title="<%- translate("Search in Bins") %>" /></form></div><ul class="Rk-Bin-List"></ul></div><% } %><% if (options.show_editor) { %><div class="Rk-Render Rk-Render-<% if (options.show_bins) { %>Panel<% } else { %>Full<% } %>"></div><% } %>'),f.prototype.translate=function(a){return b.i18n[this.options.language]&&b.i18n[this.options.language][a]?b.i18n[this.options.language][a]:this.options.language.length>2&&b.i18n[this.options.language.substr(0,2)]&&b.i18n[this.options.language.substr(0,2)][a]?b.i18n[this.options.language.substr(0,2)][a]:a},f.prototype.onStatusChange=function(){this.renderer.onStatusChange()},f.prototype.setSearchEngine=function(a){this.search_engine=this.search_engines[a],this.$.find(".Rk-Search-Current").attr("class","Rk-Search-Current "+this.search_engine.getBgClass())},f.prototype.resizeBins=function(){var a=+this.$.find(".Rk-Bins-Head").outerHeight();this.$.find(".Rk-Bin-Title:visible").each(function(){a+=b.$(this).outerHeight()}),this.$.find(".Rk-Bin-Main").css({height:this.$.find(".Rk-Bins").height()-a})};var g=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"===a?b:3&b|8;return c.toString(16)})};b.Utils={getUUID4:g,getUID:function(){function a(a){return 10>a?"0"+a:a}var b=new Date,c=0,d=b.getUTCFullYear()+"-"+a(b.getUTCMonth()+1)+"-"+a(b.getUTCDate())+"-"+g();return function(a){for(var b=(++c).toString(16),e="undefined"==typeof a?"":a+"-";b.length<4;)b="0"+b;return e+d+"-"+b}}(),getFullURL:function(a){if("undefined"==typeof a||null==a)return"";if(/https?:\/\//.test(a))return a;var b=new Image;b.src=a;var c=b.src;return b.src=null,c},inherit:function(a,b){var c=function(){"function"==typeof b&&b.apply(this,Array.prototype.slice.call(arguments,0)),a.apply(this,Array.prototype.slice.call(arguments,0)),"function"!=typeof this._init||this._initialized||(this._init.apply(this,Array.prototype.slice.call(arguments,0)),this._initialized=!0)};return d(c.prototype).extend(a.prototype),c},regexpFromTextOrArray:function(){function a(a){function b(a){return function(b,c){a=a.replace(h[b],c)}}for(var e=a.toLowerCase().replace(g,""),i="",j=0;j<e.length;j++){j&&(i+=f+"*");var k=e[j];d(c).each(b(k)),i+=k}return i}function b(c){switch(typeof c){case"string":return a(c);case"object":var e="";return d(c).each(function(a){var c=b(a);c&&(e&&(e+="|"),e+=c)}),e}return""}var c=["[aáàâä]","[cç]","[eéèêë]","[iíìîï]","[oóòôö]","[uùûü]"],e=[String.fromCharCode(768),String.fromCharCode(769),String.fromCharCode(770),String.fromCharCode(771),String.fromCharCode(807),"{","}","(",")","[","]","【","】","、","・","‥","。","「","」","『","』","〜",":","!","?"," ",","," ",";","(",")",".","*","+","\\","?","|","{","}","[","]","^","#","/"],f="[\\"+e.join("\\")+"]",g=new RegExp(f,"gm"),h=d(c).map(function(a){return new RegExp(a)});return function(a){var c=b(a);if(c){var d=new RegExp(c,"im"),e=new RegExp("("+c+")","igm");return{isempty:!1,source:c,test:function(a){return d.test(a)},replace:function(a,b){return a.replace(e,b)}}}return{isempty:!0,source:"",test:function(){return!0},replace:function(){return text}}}}(),_MIN_DRAG_DISTANCE:2,_NODE_BUTTON_WIDTH:40,_EDGE_BUTTON_INNER:2,_EDGE_BUTTON_OUTER:40,_CLICKMODE_ADDNODE:1,_CLICKMODE_STARTEDGE:2,_CLICKMODE_ENDEDGE:3,_NODE_SIZE_STEP:Math.LN2/4,_MIN_SCALE:.05,_MAX_SCALE:20,_MOUSEMOVE_RATE:80,_DOUBLETAP_DELAY:800,_DOUBLETAP_DISTANCE:400,_USER_PLACEHOLDER:function(a){return{color:a.options.default_user_color,title:a.translate("(unknown user)"),get:function(a){return this[a]||!1}}},_BOOKMARKLET_CODE:function(a){return"(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='<p_style=\"position:fixed;top:0;right:0;font:bold_18px_sans-serif;color:#fff;background:#909;padding:10px;z-index:100000;\">"+a.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_")+"</p>'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\/\\/[^\\/]*twitter\\.com\\//,s:'.tweet',n:'twitter'},{r:/https?:\\/\\/[^\\/]*google\\.[^\\/]+\\//,s:'.g',n:'google'},{r:/https?:\\/\\/[^\\/]*lemonde\\.fr\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();"},shortenText:function(a,b){return a.length>b?a.substr(0,b)+"…":a},drawEditBox:function(a,b,c,d,e){e.css({width:a.tooltip_width-2*a.tooltip_padding});var f=e.outerHeight()+2*a.tooltip_padding,g=b.x<paper.view.center.x?1:-1,h=b.x+g*(d+a.tooltip_arrow_length),i=b.x+g*(d+a.tooltip_arrow_length+a.tooltip_width),j=b.y-f/2;j+f>paper.view.size.height-a.tooltip_margin&&(j=Math.max(paper.view.size.height-a.tooltip_margin,b.y+a.tooltip_arrow_width/2)-f),j<a.tooltip_margin&&(j=Math.min(a.tooltip_margin,b.y-a.tooltip_arrow_width/2));var k=j+f;return c.segments[0].point=c.segments[7].point=b.add([g*d,0]),c.segments[1].point.x=c.segments[2].point.x=c.segments[5].point.x=c.segments[6].point.x=h,c.segments[3].point.x=c.segments[4].point.x=i,c.segments[2].point.y=c.segments[3].point.y=j,c.segments[4].point.y=c.segments[5].point.y=k,c.segments[1].point.y=b.y-a.tooltip_arrow_width/2,c.segments[6].point.y=b.y+a.tooltip_arrow_width/2,c.closed=!0,c.fillColor=new paper.GradientColor(new paper.Gradient([a.tooltip_top_color,a.tooltip_bottom_color]),[0,j],[0,k]),e.css({left:a.tooltip_padding+Math.min(h,i),top:a.tooltip_padding+j}),c}}}(window),function(){"use strict";var a=this,b=a.Backbone,c=a.Rkns.Models={};c.getUID=function(a){var b="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"===a?b:3&b|8;return c.toString(16)});return"undefined"!=typeof a?a.type+"-"+b:b};{var d=b.RelationalModel.extend({idAttribute:"_id",constructor:function(a){"undefined"!=typeof a&&(a._id=a._id||a.id||c.getUID(this),a.title=a.title||"",a.description=a.description||"",a.uri=a.uri||"","function"==typeof this.prepare&&(a=this.prepare(a))),b.RelationalModel.prototype.constructor.call(this,a)},validate:function(){return this.type?void 0:"object has no type"},addReference:function(a,b,c,d,e){var f=c.get(d);a[b]="undefined"==typeof f&&"undefined"!=typeof e?e:f}}),e=c.User=d.extend({type:"user",prepare:function(a){return a.color=a.color||"#666666",a},toJSON:function(){return{_id:this.get("_id"),title:this.get("title"),uri:this.get("uri"),description:this.get("description"),color:this.get("color")}}}),f=c.Node=d.extend({type:"node",relations:[{type:b.HasOne,key:"created_by",relatedModel:e}],prepare:function(a){var b=a.project;return this.addReference(a,"created_by",b.get("users"),a.created_by,b.current_user),a.description=a.description||"",a},toJSON:function(){return{_id:this.get("_id"),title:this.get("title"),uri:this.get("uri"),description:this.get("description"),position:this.get("position"),image:this.get("image"),color:this.get("color"),created_by:this.get("created_by")?this.get("created_by").get("_id"):null,size:this.get("size"),clip_path:this.get("clip_path")}}}),g=c.Edge=d.extend({type:"edge",relations:[{type:b.HasOne,key:"created_by",relatedModel:e},{type:b.HasOne,key:"from",relatedModel:f},{type:b.HasOne,key:"to",relatedModel:f}],prepare:function(a){var b=a.project;return this.addReference(a,"created_by",b.get("users"),a.created_by,b.current_user),this.addReference(a,"from",b.get("nodes"),a.from),this.addReference(a,"to",b.get("nodes"),a.to),a},toJSON:function(){return{_id:this.get("_id"),title:this.get("title"),uri:this.get("uri"),description:this.get("description"),from:this.get("from")?this.get("from").get("_id"):null,to:this.get("to")?this.get("to").get("_id"):null,color:this.get("color"),created_by:this.get("created_by")?this.get("created_by").get("_id"):null}}}),h=c.View=d.extend({type:"view",relations:[{type:b.HasOne,key:"created_by",relatedModel:e}],prepare:function(a){var b=a.project;if(this.addReference(a,"created_by",b.get("users"),a.created_by,b.current_user),a.description=a.description||"","undefined"!=typeof a.offset){var c={};Array.isArray(a.offset)?(c.x=a.offset[0],c.y=a.offset.length>1?a.offset[1]:a.offset[0]):null!=a.offset.x&&(c.x=a.offset.x,c.y=a.offset.y),a.offset=c}return a},toJSON:function(){return{_id:this.get("_id"),zoom_level:this.get("zoom_level"),offset:this.get("offset"),title:this.get("title"),description:this.get("description"),created_by:this.get("created_by")?this.get("created_by").get("_id"):null}}}),i=(c.Project=d.extend({type:"project",relations:[{type:b.HasMany,key:"users",relatedModel:e,reverseRelation:{key:"project",includeInJSON:"_id"}},{type:b.HasMany,key:"nodes",relatedModel:f,reverseRelation:{key:"project",includeInJSON:"_id"}},{type:b.HasMany,key:"edges",relatedModel:g,reverseRelation:{key:"project",includeInJSON:"_id"}},{type:b.HasMany,key:"views",relatedModel:h,reverseRelation:{key:"project",includeInJSON:"_id"}}],addUser:function(a,b){a.project=this;var c=e.findOrCreate(a);return this.get("users").push(c,b),c},addNode:function(a,b){a.project=this;var c=f.findOrCreate(a);return this.get("nodes").push(c,b),c},addEdge:function(a,b){a.project=this;var c=g.findOrCreate(a);return this.get("edges").push(c,b),c},addView:function(a,b){a.project=this;var c=h.findOrCreate(a);return this.get("views").push(c,b),c},removeNode:function(a){this.get("nodes").remove(a)},removeEdge:function(a){this.get("edges").remove(a)},validate:function(a){var b=this;_([].concat(a.users,a.nodes,a.edges,a.views)).each(function(a){a&&(a.project=b)})},initialize:function(){var a=this;this.on("remove:nodes",function(b){a.get("edges").remove(a.get("edges").filter(function(a){return a.get("from")===b||a.get("to")===b}))})}}),c.RosterUser=b.Model.extend({type:"roster_user",idAttribute:"_id",constructor:function(a){"undefined"!=typeof a&&(a._id=a._id||a.id||c.getUID(this),a.title=a.title||"(untitled "+this.type+")",a.description=a.description||"",a.uri=a.uri||"",a.project=a.project||null,a.site_id=a.site_id||0,"function"==typeof this.prepare&&(a=this.prepare(a))),b.Model.prototype.constructor.call(this,a)},validate:function(){return this.type?void 0:"object has no type"},prepare:function(a){return a.color=a.color||"#666666",a},toJSON:function(){return{_id:this.get("_id"),title:this.get("title"),uri:this.get("uri"),description:this.get("description"),color:this.get("color"),project:null!=this.get("project")?this.get("project").get("id"):null,site_id:this.get("site_id")}}}));c.UsersList=b.Collection.extend({model:i})}}.call(window),Rkns.defaults={language:navigator.language||navigator.userLanguage||"en",container:"renkan",search:[],bins:[],static_url:"",show_bins:!0,properties:[],show_editor:!0,read_only:!1,editor_mode:!0,snapshot_mode:!1,show_top_bar:!0,default_user_color:"#303030",size_bug_fix:!0,force_resize:!1,allow_double_click:!0,zoom_on_scroll:!0,element_delete_delay:0,autoscale_padding:50,default_view:!1,show_search_field:!0,show_user_list:!0,user_name_editable:!0,user_color_editable:!0,show_save_button:!0,show_export_button:!0,show_open_button:!1,show_addnode_button:!0,show_addedge_button:!0,show_bookmarklet:!0,show_fullscreen_button:!0,home_button_url:!1,home_button_title:"Home",show_minimap:!0,minimap_width:160,minimap_height:120,minimap_padding:20,minimap_background_color:"#ffffff",minimap_border_color:"#cccccc",minimap_highlight_color:"#ffff00",minimap_highlight_weight:5,buttons_background:"#202020",buttons_label_color:"#c000c0",buttons_label_font_size:9,show_node_circles:!0,clip_node_images:!0,node_images_fill_mode:!1,node_size_base:25,node_stroke_width:2,selected_node_stroke_width:4,node_fill_color:"#ffffff",highlighted_node_fill_color:"#ffff00",node_label_distance:5,node_label_max_length:60,label_untitled_nodes:"(untitled)",edge_stroke_width:2,selected_edge_stroke_width:4,edge_label_distance:0,edge_label_max_length:20,edge_arrow_length:18,edge_arrow_width:12,edge_gap_in_bundles:12,label_untitled_edges:"",tooltip_width:275,tooltip_padding:10,tooltip_margin:15,tooltip_arrow_length:20,tooltip_arrow_width:40,tooltip_top_color:"#f0f0f0",tooltip_bottom_color:"#d0d0d0",tooltip_border_color:"#808080",tooltip_border_width:1,show_node_editor_uri:!0,show_node_editor_description:!0,show_node_editor_size:!0,show_node_editor_color:!0,show_node_editor_image:!0,show_node_editor_creator:!0,uploaded_image_max_kb:500,show_node_tooltip_uri:!0,show_node_tooltip_description:!0,show_node_tooltip_color:!0,show_node_tooltip_image:!0,show_node_tooltip_creator:!0,show_edge_editor_uri:!0,show_edge_editor_color:!0,show_edge_editor_direction:!0,show_edge_editor_nodes:!0,show_edge_editor_creator:!0,show_edge_tooltip_uri:!0,show_edge_tooltip_color:!0,show_edge_tooltip_nodes:!0,show_edge_tooltip_creator:!0},Rkns.i18n={fr:{"Edit Node":"Édition d’un nœud","Edit Edge":"Édition d’un lien","Title:":"Titre :","URI:":"URI :","Description:":"Description :","From:":"De :","To:":"Vers :",Image:"Image","Image URL:":"URL d'Image","Choose Image File:":"Choisir un fichier image","Full Screen":"Mode plein écran","Add Node":"Ajouter un nœud","Add Edge":"Ajouter un lien","Save Project":"Enregistrer le projet","Open Project":"Ouvrir un projet","Auto-save enabled":"Enregistrement automatique activé","Connection lost":"Connexion perdue","Created by:":"Créé par :","Zoom In":"Agrandir l’échelle","Zoom Out":"Rapetisser l’échelle",Edit:"Éditer",Remove:"Supprimer","Cancel deletion":"Annuler la suppression","Link to another node":"Créer un lien",Enlarge:"Agrandir",Shrink:"Rétrécir","Click on the background canvas to add a node":"Cliquer sur le fond du graphe pour rajouter un nœud","Click on a first node to start the edge":"Cliquer sur un premier nœud pour commencer le lien","Click on a second node to complete the edge":"Cliquer sur un second nœud pour terminer le lien",Wikipedia:"Wikipédia","Wikipedia in ":"Wikipédia en ",French:"Français",English:"Anglais",Japanese:"Japonais","Untitled project":"Projet sans titre","Lignes de Temps":"Lignes de Temps","Loading, please wait":"Chargement en cours, merci de patienter","Edge color:":"Couleur :","Node color:":"Couleur :","Choose color":"Choisir une couleur","Change edge direction":"Changer le sens du lien","Do you really wish to remove node ":"Voulez-vous réellement supprimer le nœud ","Do you really wish to remove edge ":"Voulez-vous réellement supprimer le lien ","This file is not an image":"Ce fichier n'est pas une image","Image size must be under ":"L'image doit peser moins de ","Size:":"Taille :",KB:"ko","Choose from vocabulary:":"Choisir dans un vocabulaire :","SKOS Documentation properties":"SKOS: Propriétés documentaires","has note":"a pour note","has example":"a pour exemple","has definition":"a pour définition","SKOS Semantic relations":"SKOS: Relations sémantiques","has broader":"a pour concept plus large","has narrower":"a pour concept plus étroit","has related":"a pour concept apparenté","Dublin Core Metadata":"Métadonnées Dublin Core","has contributor":"a pour contributeur",covers:"couvre","created by":"créé par","has date":"a pour date","published by":"édité par","has source":"a pour source","has subject":"a pour sujet","Dragged resource":"Ressource glisée-déposée","Search the Web":"Rechercher en ligne","Search in Bins":"Rechercher dans les chutiers","Close bin":"Fermer le chutier","Refresh bin":"Rafraîchir le chutier","(untitled)":"(sans titre)","Select contents:":"Sélectionner des contenus :","Drag items from this website, drop them in Renkan":"Glissez des éléments de ce site web vers Renkan","Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.":"Glissez ce bouton vers votre barre de favoris. Ensuite, depuis un site tiers, cliquez dessus pour activer 'Drag-to-Add' puis glissez des éléments de ce site vers Renkan"}},Rkns.jsonIO=function(a,b){var c=a.project;"undefined"==typeof b.http_method&&(b.http_method="PUT");var d=function(){a.renderer.redrawActive=!1,Rkns.$.getJSON(b.url,function(b){c.set(b,{validate:!0}),a.renderer.redrawActive=!0,a.renderer.autoScale()})},e=function(){var d=c.toJSON();a.read_only||Rkns.$.ajax({type:b.http_method,url:b.url,contentType:"application/json",data:JSON.stringify(d),success:function(){}})},f=Rkns._.throttle(function(){setTimeout(e,100)},1e3);c.on("add:nodes add:edges add:users add:views",function(a){a.on("change remove",function(){f()}),f()}),c.on("change",function(){f()}),d()},function(a){"use strict";var b=a._,c=a.Ldt={},d=(c.Bin=function(a,b){if(b.ldt_type){var d=c[b.ldt_type+"Bin"];if(d)return new d(a,b)}console.error("No such LDT Bin Type")},c.ProjectBin=a.Utils.inherit(a._BaseBin));d.prototype.tagTemplate=b.template('<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(static_url+\'img/ldt-tag.png\') %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/search/?search=<%=encodedtitle%>&field=all" data-title="<%-title%>" data-description="Tag \'<%-title%>\'"><img class="Rk-Ldt-Tag-Icon" src="<%-static_url%>img/ldt-tag.png" /><h4><%=htitle%></h4><div class="Rk-Clear"></div></li>'),d.prototype.annotationTemplate=b.template('<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(image) %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>"><img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class="Rk-Clear"></div></li>'),d.prototype._init=function(a,b){this.renkan=a,this.proj_id=b.project_id,this.ldt_platform=b.ldt_platform||"http://ldt.iri.centrepompidou.fr/",this.title_$.html(b.title),this.title_icon_$.addClass("Rk-Ldt-Title-Icon"),this.refresh()},d.prototype.render=function(c){function d(a){var c=b(a).escape();return f.isempty?c:f.replace(c,"<span class='searchmatch'>$1</span>")}function e(a){function b(a){for(var b=a.toString();b.length<2;)b="0"+b;return b}var c=Math.abs(Math.floor(a/1e3)),d=Math.floor(c/3600),e=Math.floor(c/60)%60,f=c%60,g="";return d&&(g+=b(d)+":"),g+=b(e)+":"+b(f)}var f=c||a.Utils.regexpFromTextOrArray(),g="<li><h3>Tags</h3></li>",h=this.data.meta["dc:title"],i=this,j=0;i.title_$.text('LDT Project: "'+h+'"'),b(i.data.tags).map(function(a){var b=a.meta["dc:title"];(f.isempty||f.test(b))&&(j++,g+=i.tagTemplate({ldt_platform:i.ldt_platform,title:b,htitle:d(b),encodedtitle:encodeURIComponent(b),static_url:i.renkan.options.static_url}))}),g+="<li><h3>Annotations</h3></li>",b(i.data.annotations).map(function(a){var b=a.content.description,c=a.content.title.replace(b,"");if(f.isempty||f.test(c)||f.test(b)){j++;var h=a.end-a.begin,k=a.content&&a.content.img&&a.content.img.src?a.content.img.src:h?i.renkan.options.static_url+"img/ldt-segment.png":i.renkan.options.static_url+"img/ldt-point.png";g+=i.annotationTemplate({ldt_platform:i.ldt_platform,title:c,htitle:d(c),description:b,hdescription:d(b),start:e(a.begin),end:e(a.end),duration:e(h),mediaid:a.media,annotationid:a.id,image:k,static_url:i.renkan.options.static_url})}}),this.main_$.html(g),!f.isempty&&j?this.count_$.text(j).show():this.count_$.hide(),f.isempty||j?this.$.show():this.$.hide(),this.renkan.resizeBins()},d.prototype.refresh=function(){var b=this;a.$.ajax({url:this.ldt_platform+"ldtplatform/ldt/cljson/id/"+this.proj_id,dataType:"jsonp",success:function(a){b.data=a,b.render()}})};var e=c.Search=function(a,b){this.renkan=a,this.lang=b.lang||"en"};e.prototype.getBgClass=function(){return"Rk-Ldt-Icon"},e.prototype.getSearchTitle=function(){return this.renkan.translate("Lignes de Temps")},e.prototype.search=function(a){this.renkan.tabs.push(new f(this.renkan,{search:a}))};var f=c.ResultsBin=a.Utils.inherit(a._BaseBin);f.prototype.segmentTemplate=b.template('<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(image) %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>"><img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class="Rk-Clear"></div></li>'),f.prototype._init=function(a,b){this.renkan=a,this.ldt_platform=b.ldt_platform||"http://ldt.iri.centrepompidou.fr/",this.max_results=b.max_results||50,this.search=b.search,this.title_$.html('Lignes de Temps: "'+b.search+'"'),this.title_icon_$.addClass("Rk-Ldt-Title-Icon"),this.refresh()},f.prototype.render=function(c){function d(a){return g.replace(b(a).escape(),"<span class='searchmatch'>$1</span>")}function e(a){function b(a){for(var b=a.toString();b.length<2;)b="0"+b;return b}var c=Math.abs(Math.floor(a/1e3)),d=Math.floor(c/3600),e=Math.floor(c/60)%60,f=c%60,g="";return d&&(g+=b(d)+":"),g+=b(e)+":"+b(f)}if(this.data){var f=c||a.Utils.regexpFromTextOrArray(),g=f.isempty?a.Utils.regexpFromTextOrArray(this.search):f,h="",i=this,j=0;b(this.data.objects).each(function(a){var b=a.abstract,c=a.title;if(f.isempty||f.test(c)||f.test(b)){j++;var g=a.duration,k=a.start_ts,l=+a.duration+k,m=g?i.renkan.options.static_url+"img/ldt-segment.png":i.renkan.options.static_url+"img/ldt-point.png";h+=i.segmentTemplate({ldt_platform:i.ldt_platform,title:c,htitle:d(c),description:b,hdescription:d(b),start:e(k),end:e(l),duration:e(g),mediaid:a.iri_id,annotationid:a.element_id,image:m})}}),this.main_$.html(h),!f.isempty&&j?this.count_$.text(j).show():this.count_$.hide(),f.isempty||j?this.$.show():this.$.hide(),this.renkan.resizeBins()}},f.prototype.refresh=function(){var b=this;a.$.ajax({url:this.ldt_platform+"ldtplatform/api/ldt/1.0/segments/search/",data:{format:"jsonp",q:this.search,limit:this.max_results},dataType:"jsonp",success:function(a){b.data=a,b.render()}})}}(window.Rkns),Rkns.ResourceList={},Rkns.ResourceList.Bin=Rkns.Utils.inherit(Rkns._BaseBin),Rkns.ResourceList.Bin.prototype.resultTemplate=Rkns._.template('<li class="Rk-Bin-Item Rk-ResourceList-Item" draggable="true" data-uri="<%-url%>" data-title="<%-title%>" data-description="<%-description%>" <% if (image) { %>data-image="<%- Rkns.Utils.getFullURL(image) %>"<% } else { %>data-image=""<% } %> ><% if (image) { %><img class="Rk-ResourceList-Image" src="<%-image%>"/><% } %><h4 class="Rk-ResourceList-Title"><% if (url) { %><a href="<%-url%>" target="_blank"><% } %><%=htitle%><% if (url) { %></a><% } %></h4><% if (description) { %><p class="Rk-ResourceList-Description"><%=hdescription%></p><% } %><% if (image) { %><div style="clear: both;"></div><% } %></li>'),Rkns.ResourceList.Bin.prototype._init=function(a,b){this.renkan=a,this.title_$.html(b.title),b.list&&(this.data=b.list),this.refresh()},Rkns.ResourceList.Bin.prototype.render=function(a){function b(a){var b=_(a).escape();return c.isempty?b:c.replace(b,"<span class='searchmatch'>$1</span>")}var c=a||Rkns.Utils.regexpFromTextOrArray(),d="",e=this,f=0;Rkns._(this.data).each(function(a){var g;if("string"==typeof a)if(/^(https?:\/\/|www)/.test(a))g={url:a};else{g={title:a.replace(/[:,]?\s?(https?:\/\/|www)[\d\w\/.&?=#%-_]+\s?/,"").trim()};var h=a.match(/(https?:\/\/|www)[\d\w\/.&?=#%-_]+/);h&&(g.url=h[0]),g.title.length>80&&(g.description=g.title,g.title=g.title.replace(/^(.{30,60})\s.+$/,"$1…"))}else g=a;var i=g.title||(g.url||"").replace(/^https?:\/\/(www\.)?/,"").replace(/^(.{40}).+$/,"$1…"),j=g.url||"",k=g.description||"",l=g.image||"";j&&!/^https?:\/\//.test(j)&&(j="http://"+j),(c.isempty||c.test(i)||c.test(k))&&(f++,d+=e.resultTemplate({url:j,title:i,htitle:b(i),image:l,description:k,hdescription:b(k),static_url:e.renkan.options.static_url}))}),e.main_$.html(d),!c.isempty&&f?this.count_$.text(f).show():this.count_$.hide(),c.isempty||f?this.$.show():this.$.hide(),this.renkan.resizeBins()},Rkns.ResourceList.Bin.prototype.refresh=function(){this.data&&this.render()},Rkns.Wikipedia={},Rkns.Wikipedia.Search=function(a,b){this.renkan=a,this.lang=b.lang||"en"},Rkns.Wikipedia.Search.prototype.getBgClass=function(){return"Rk-Wikipedia-Search-Icon Rk-Wikipedia-Lang-"+this.lang},Rkns.Wikipedia.Search.prototype.getSearchTitle=function(){var a={fr:"French",en:"English",ja:"Japanese"};return a[this.lang]?this.renkan.translate("Wikipedia in ")+this.renkan.translate(a[this.lang]):this.renkan.translate("Wikipedia")+" ["+this.lang+"]"},Rkns.Wikipedia.Search.prototype.search=function(a){this.renkan.tabs.push(new Rkns.Wikipedia.Bin(this.renkan,{lang:this.lang,search:a}))},Rkns.Wikipedia.Bin=Rkns.Utils.inherit(Rkns._BaseBin),Rkns.Wikipedia.Bin.prototype.resultTemplate=Rkns._.template('<li class="Rk-Wikipedia-Result Rk-Bin-Item" draggable="true" data-uri="<%-url%>" data-title="Wikipedia: <%-title%>" data-description="<%-description%>" data-image="<%- Rkns.Utils.getFullURL( static_url + \'img/wikipedia.png\' ) %>"><img class="Rk-Wikipedia-Icon" src="<%-static_url%>img/wikipedia.png"></div><h4 class="Rk-Wikipedia-Title"><a href="<%-url%>" target="_blank"><%=htitle%></a></h4><p class="Rk-Wikipedia-Snippet"><%=hdescription%></p></li>'),Rkns.Wikipedia.Bin.prototype._init=function(a,b){this.renkan=a,this.search=b.search,this.lang=b.lang||"en",this.title_icon_$.addClass("Rk-Wikipedia-Title-Icon Rk-Wikipedia-Lang-"+this.lang),this.title_$.html(this.search).addClass("Rk-Wikipedia-Title"),this.refresh()
-},Rkns.Wikipedia.Bin.prototype.render=function(a){function b(a){return d.replace(_(a).escape(),"<span class='searchmatch'>$1</span>")}var c=a||Rkns.Utils.regexpFromTextOrArray(),d=c.isempty?Rkns.Utils.regexpFromTextOrArray(this.search):c,e="",f=this,g=0;Rkns._(this.data.query.search).each(function(a){var d=a.title,h="http://"+f.lang+".wikipedia.org/wiki/"+encodeURI(d.replace(/ /g,"_")),i=Rkns.$("<div>").html(a.snippet).text();(c.isempty||c.test(d)||c.test(i))&&(g++,e+=f.resultTemplate({url:h,title:d,htitle:b(d),description:i,hdescription:b(i),static_url:f.renkan.options.static_url}))}),f.main_$.html(e),!c.isempty&&g?this.count_$.text(g).show():this.count_$.hide(),c.isempty||g?this.$.show():this.$.hide(),this.renkan.resizeBins()},Rkns.Wikipedia.Bin.prototype.refresh=function(){var a=this;Rkns.$.ajax({url:"http://"+a.lang+".wikipedia.org/w/api.php?action=query&list=search&srsearch="+encodeURIComponent(this.search)+"&format=json",dataType:"jsonp",success:function(b){a.data=b,a.render()}})},define("renderer/baserepresentation",["jquery","underscore"],function(a,b){var c=function(a,c){if("undefined"!=typeof a&&(this.renderer=a,this.renkan=a.renkan,this.project=a.renkan.project,this.options=a.renkan.options,this.model=c,this.model)){var d=this;this._changeBinding=function(){d.redraw()},this._removeBinding=function(){a.removeRepresentation(d),b(function(){a.redraw()}).defer()},this._selectBinding=function(){d.select()},this._unselectBinding=function(){d.unselect()},this.model.on("change",this._changeBinding),this.model.on("remove",this._removeBinding),this.model.on("select",this._selectBinding),this.model.on("unselect",this._unselectBinding)}};return b(c.prototype).extend({_super:function(a){return c.prototype[a].apply(this,Array.prototype.slice.call(arguments,1))},redraw:function(){},moveTo:function(){},show:function(){return"chaud cacao"},hide:function(){},select:function(){this.model&&this.model.trigger("selected")},unselect:function(){this.model&&this.model.trigger("unselected")},highlight:function(){},unhighlight:function(){},mousedown:function(){},mouseup:function(){this.model&&this.model.trigger("clicked")},destroy:function(){this.model&&(this.model.off("change",this._changeBinding),this.model.off("remove",this._removeBinding),this.model.off("select",this._selectBinding),this.model.off("unselect",this._unselectBinding))}}),c}),define("requtils",[],function(){return{getUtils:function(){return window.Rkns.Utils},getRenderer:function(){return window.Rkns.Renderer}}}),define("renderer/basebutton",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({moveTo:function(a){this.sector.moveTo(a)},show:function(){this.sector.show()},hide:function(){this.sector.hide()},select:function(){this.sector.select()},unselect:function(a){this.sector.unselect(),(!a||a!==this.source_representation&&a.source_representation!==this.source_representation)&&this.source_representation.unselect()},destroy:function(){this.sector.destroy()}}),f}),define("renderer/noderepr",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){if(this.renderer.node_layer.activate(),this.type="Node",this.circle=new paper.Path.Circle([0,0],1),this.circle.__representation=this,this.options.show_node_circles?(this.circle.strokeWidth=this.options.node_stroke_width,this.h_ratio=1):this.h_ratio=0,this.title=a('<div class="Rk-Label">').appendTo(this.renderer.labels_$),this.options.editor_mode){var b=c.getRenderer();this.normal_buttons=[new b.NodeEditButton(this.renderer,null),new b.NodeRemoveButton(this.renderer,null),new b.NodeLinkButton(this.renderer,null),new b.NodeEnlargeButton(this.renderer,null),new b.NodeShrinkButton(this.renderer,null)],this.pending_delete_buttons=[new b.NodeRevertButton(this.renderer,null)],this.all_buttons=this.normal_buttons.concat(this.pending_delete_buttons);for(var d=0;d<this.all_buttons.length;d++)this.all_buttons[d].source_representation=this;this.active_buttons=[]}else this.active_buttons=this.all_buttons=[];this.last_circle_radius=1,this.renderer.minimap&&(this.renderer.minimap.node_layer.activate(),this.minimap_circle=new paper.Path.Circle([0,0],1),this.minimap_circle.__representation=this.renderer.minimap.miniframe.__representation,this.renderer.minimap.node_group.addChild(this.minimap_circle))},redraw:function(a){var c=new paper.Point(this.model.get("position")),d=this.options.node_size_base*Math.exp((this.model.get("size")||0)*e._NODE_SIZE_STEP);this.is_dragging&&this.paper_coords||(this.paper_coords=this.renderer.toPaperCoords(c)),this.circle_radius=d*this.renderer.scale,this.last_circle_radius!==this.circle_radius&&(this.all_buttons.forEach(function(a){a.setSectorSize()}),this.circle.scale(this.circle_radius/this.last_circle_radius),this.node_image&&this.node_image.scale(this.circle_radius/this.last_circle_radius)),this.circle.position=this.paper_coords,this.node_image&&(this.node_image.position=this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius))),this.last_circle_radius=this.circle_radius;var f=this.active_buttons,g=1;this.model.get("delete_scheduled")?(g=.5,this.active_buttons=this.pending_delete_buttons,this.circle.dashArray=[2,2]):(g=1,this.active_buttons=this.normal_buttons,this.circle.dashArray=null),this.selected&&this.renderer.isEditable()&&(f!==this.active_buttons&&f.forEach(function(a){a.hide()}),this.active_buttons.forEach(function(a){a.show()})),this.node_image&&(this.node_image.opacity=this.highlighted?.5*g:g-.01),this.circle.fillColor=this.highlighted?this.options.highlighted_node_fill_color:this.options.node_fill_color,this.circle.opacity=this.options.show_node_circles?g:.01;var h=this.model.get("title")||this.renkan.translate(this.options.label_untitled_nodes)||"";h=e.shortenText(h,this.options.node_label_max_length),"object"==typeof this.highlighted?this.title.html(this.highlighted.replace(b(h).escape(),'<span class="Rk-Highlighted">$1</span>')):this.title.text(h),this.title.css({left:this.paper_coords.x,top:this.paper_coords.y+this.circle_radius*this.h_ratio+this.options.node_label_distance,opacity:g});var i=this.model.get("color")||(this.model.get("created_by")||e._USER_PLACEHOLDER(this.renkan)).get("color");this.circle.strokeColor=i;var j=this.paper_coords;this.all_buttons.forEach(function(a){a.moveTo(j)});var k=this.img;if(this.img=this.model.get("image"),this.img&&this.img!==k&&this.showImage(),this.node_image&&!this.img&&(this.node_image.remove(),delete this.node_image),this.renderer.minimap){this.minimap_circle.fillColor=i;var l=this.renderer.toMinimapCoords(c),m=this.renderer.minimap.scale*d,n=new paper.Size([m,m]);this.minimap_circle.fitBounds(l.subtract(n),n.multiply(2))}if(!a){var o=this;b.each(this.project.get("edges").filter(function(a){return a.get("to")===o.model||a.get("from")===o.model}),function(a){var b=o.renderer.getRepresentationByModel(a);b&&"undefined"!=typeof b.from_representation&&"undefined"!=typeof b.from_representation.paper_coords&&"undefined"!=typeof b.to_representation&&"undefined"!=typeof b.to_representation.paper_coords&&b.redraw()})}},showImage:function(){var b=null;if("undefined"==typeof this.renderer.image_cache[this.img]?(b=new Image,this.renderer.image_cache[this.img]=b,b.src=this.img):b=this.renderer.image_cache[this.img],b.width){this.node_image&&this.node_image.remove(),this.renderer.node_layer.activate();var c=b.width,d=b.height,e=this.model.get("clip_path"),f="undefined"!=typeof e&&e,g=null,h=null,i=null;if(f){g=new paper.Path;var j=e.match(/[a-z][^a-z]+/gi)||[],k=[0,0],l=1/0,m=1/0,n=-1/0,o=-1/0,p=function(a,b){var e=a.slice(1).map(function(a,e){var f=parseFloat(a),g=e%2;return f=g?(f-.5)*d:(f-.5)*c,b&&(f+=k[g]),g?(m=Math.min(m,f),o=Math.max(o,f)):(l=Math.min(l,f),n=Math.max(n,f)),f});return k=e.slice(-2),e};j.forEach(function(a){var b=a.match(/([a-z]|[0-9.-]+)/gi)||[""];switch(b[0]){case"M":g.moveTo(p(b));break;case"m":g.moveTo(p(b,!0));break;case"L":g.lineTo(p(b));break;case"l":g.lineTo(p(b,!0));break;case"C":g.cubicCurveTo(p(b));break;case"c":g.cubicCurveTo(p(b,!0));break;case"Q":g.quadraticCurveTo(p(b));break;case"q":g.quadraticCurveTo(p(b,!0))}}),h=Math[this.options.node_images_fill_mode?"min":"max"](n-l,o-m)/2,i=new paper.Point((n+l)/2,(o+m)/2),this.options.show_node_circles||(this.h_ratio=(o-m)/(2*h))}else h=Math[this.options.node_images_fill_mode?"min":"max"](c,d)/2,i=new paper.Point(0,0),this.options.show_node_circles||(this.h_ratio=d/(2*h));var q=new paper.Raster(b);if(q.locked=!0,f&&(q=new paper.Group(g,q),q.opacity=.99,q.clipped=!0,g.__representation=this),this.options.clip_node_images){var r=new paper.Path.Circle(i,h);q=new paper.Group(r,q),q.opacity=.99,q.clipped=!0,r.__representation=this}this.image_delta=i.divide(h),this.node_image=q,this.node_image.__representation=s,this.node_image.scale(this.circle_radius/h),this.node_image.position=this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius)),this.redraw(),this.renderer.throttledPaperDraw()}else{var s=this;a(b).on("load",function(){s.showImage()})}},paperShift:function(a){this.options.editor_mode?this.renkan.read_only||(this.is_dragging=!0,this.paper_coords=this.paper_coords.add(a),this.redraw()):this.renderer.paperShift(a)},openEditor:function(){this.renderer.removeRepresentationsOfType("editor");var a=this.renderer.addRepresentation("NodeEditor",null);a.source_representation=this,a.draw()},select:function(){this.selected=!0,this.circle.strokeWidth=this.options.selected_node_stroke_width,this.renderer.isEditable()&&this.active_buttons.forEach(function(a){a.show()});var b=this.model.get("uri");b&&a(".Rk-Bin-Item").each(function(){var c=a(this);c.attr("data-uri")===b&&c.addClass("selected")}),this.options.editor_mode||this.openEditor(),this.renderer.minimap&&(this.minimap_circle.strokeWidth=this.options.minimap_highlight_weight,this.minimap_circle.strokeColor=this.options.minimap_highlight_color),this._super("select")},unselect:function(b){b&&b.source_representation===this||(this.selected=!1,this.all_buttons.forEach(function(a){a.hide()}),this.circle.strokeWidth=this.options.node_stroke_width,a(".Rk-Bin-Item").removeClass("selected"),this.renderer.minimap&&(this.minimap_circle.strokeColor=void 0),this._super("unselect"))},highlight:function(a){var b=a||!0;this.highlighted!==b&&(this.highlighted=b,this.redraw(),this.renderer.throttledPaperDraw())},unhighlight:function(){this.highlighted&&(this.highlighted=!1,this.redraw(),this.renderer.throttledPaperDraw())},saveCoords:function(){var a=this.renderer.toModelCoords(this.paper_coords),b={position:{x:a.x,y:a.y}};this.renderer.isEditable()&&this.model.set(b)},mousedown:function(a,b){b&&(this.renderer.unselectAll(),this.select())},mouseup:function(a,b){this.renderer.is_dragging&&this.renderer.isEditable()?this.saveCoords():(b||this.model.get("delete_scheduled")||this.openEditor(),this.model.trigger("clicked")),this.renderer.click_target=null,this.renderer.is_dragging=!1,this.is_dragging=!1},destroy:function(){this._super("destroy"),this.all_buttons.forEach(function(a){a.destroy()}),this.circle.remove(),this.title.remove(),this.renderer.minimap&&this.minimap_circle.remove(),this.node_image&&this.node_image.remove()}}),f}),define("renderer/edge",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){if(this.renderer.edge_layer.activate(),this.type="Edge",this.from_representation=this.renderer.getRepresentationByModel(this.model.get("from")),this.to_representation=this.renderer.getRepresentationByModel(this.model.get("to")),this.bundle=this.renderer.addToBundles(this),this.line=new paper.Path,this.line.add([0,0],[0,0],[0,0]),this.line.__representation=this,this.line.strokeWidth=this.options.edge_stroke_width,this.arrow=new paper.Path,this.arrow.add([0,0],[this.options.edge_arrow_length,this.options.edge_arrow_width/2],[0,this.options.edge_arrow_width]),this.arrow.__representation=this,this.text=a('<div class="Rk-Label Rk-Edge-Label">').appendTo(this.renderer.labels_$),this.arrow_angle=0,this.options.editor_mode){var b=c.getRenderer();this.normal_buttons=[new b.EdgeEditButton(this.renderer,null),new b.EdgeRemoveButton(this.renderer,null)],this.pending_delete_buttons=[new b.EdgeRevertButton(this.renderer,null)],this.all_buttons=this.normal_buttons.concat(this.pending_delete_buttons);for(var d=0;d<this.all_buttons.length;d++)this.all_buttons[d].source_representation=this;this.active_buttons=[]}else this.active_buttons=this.all_buttons=[];this.renderer.minimap&&(this.renderer.minimap.edge_layer.activate(),this.minimap_line=new paper.Path,this.minimap_line.add([0,0],[0,0]),this.minimap_line.__representation=this.renderer.minimap.miniframe.__representation,this.minimap_line.strokeWidth=1)},redraw:function(){var a=this.model.get("from"),b=this.model.get("to");if(a&&b&&(this.from_representation=this.renderer.getRepresentationByModel(a),this.to_representation=this.renderer.getRepresentationByModel(b),"undefined"!=typeof this.from_representation&&"undefined"!=typeof this.to_representation)){var c=this.from_representation.paper_coords,d=this.to_representation.paper_coords,f=d.subtract(c),g=f.length,h=f.divide(g),i=new paper.Point([-h.y,h.x]),j=this.bundle.getPosition(this),k=i.multiply(this.options.edge_gap_in_bundles*j),l=c.add(k),m=d.add(k),n=f.angle,o=i.multiply(this.options.edge_label_distance),p=f.divide(3),q=this.model.get("color")||this.model.get("color")||(this.model.get("created_by")||e._USER_PLACEHOLDER(this.renkan)).get("color"),r=1;this.model.get("delete_scheduled")||this.from_representation.model.get("delete_scheduled")||this.to_representation.model.get("delete_scheduled")?(r=.5,this.line.dashArray=[2,2]):(r=1,this.line.dashArray=null);var s=this.active_buttons;this.active_buttons=this.model.get("delete_scheduled")?this.pending_delete_buttons:this.normal_buttons,this.selected&&this.renderer.isEditable()&&s!==this.active_buttons&&(s.forEach(function(a){a.hide()}),this.active_buttons.forEach(function(a){a.show()})),this.paper_coords=l.add(m).divide(2),this.line.strokeColor=q,this.line.opacity=r,this.line.segments[0].point=c,this.line.segments[1].point=this.paper_coords,this.line.segments[1].handleIn=p.multiply(-1),this.line.segments[1].handleOut=p,this.line.segments[2].point=d,this.arrow.rotate(n-this.arrow_angle),this.arrow.fillColor=q,this.arrow.opacity=r,this.arrow.position=this.paper_coords,this.arrow_angle=n,n>90&&(n-=180,o=o.multiply(-1)),-90>n&&(n+=180,o=o.multiply(-1));var t=this.model.get("title")||this.renkan.translate(this.options.label_untitled_edges)||"";t=e.shortenText(t,this.options.node_label_max_length),this.text.text(t);var u=this.paper_coords.add(o);this.text.css({left:u.x,top:u.y,transform:"rotate("+n+"deg)","-moz-transform":"rotate("+n+"deg)","-webkit-transform":"rotate("+n+"deg)",opacity:r}),this.text_angle=n;var v=this.paper_coords;this.all_buttons.forEach(function(a){a.moveTo(v)}),this.renderer.minimap&&(this.minimap_line.strokeColor=q,this.minimap_line.segments[0].point=this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position"))),this.minimap_line.segments[1].point=this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position"))))}},openEditor:function(){this.renderer.removeRepresentationsOfType("editor");var a=this.renderer.addRepresentation("EdgeEditor",null);a.source_representation=this,a.draw()},select:function(){this.selected=!0,this.line.strokeWidth=this.options.selected_edge_stroke_width,this.renderer.isEditable()&&this.active_buttons.forEach(function(a){a.show()}),this.options.editor_mode||this.openEditor(),this._super("select")},unselect:function(a){a&&a.source_representation===this||(this.selected=!1,this.options.editor_mode&&this.all_buttons.forEach(function(a){a.hide()}),this.line.strokeWidth=this.options.edge_stroke_width,this._super("unselect"))},mousedown:function(a,b){b&&(this.renderer.unselectAll(),this.select())},mouseup:function(a,b){!this.renkan.read_only&&this.renderer.is_dragging?(this.from_representation.saveCoords(),this.to_representation.saveCoords(),this.from_representation.is_dragging=!1,this.to_representation.is_dragging=!1):(b||this.openEditor(),this.model.trigger("clicked")),this.renderer.click_target=null,this.renderer.is_dragging=!1},paperShift:function(a){this.options.editor_mode?this.options.read_only||(this.from_representation.paperShift(a),this.to_representation.paperShift(a)):this.renderer.paperShift(a)},destroy:function(){this._super("destroy"),this.line.remove(),this.arrow.remove(),this.text.remove(),this.renderer.minimap&&this.minimap_line.remove(),this.all_buttons.forEach(function(a){a.destroy()});var a=this;this.bundle.edges=b(this.bundle.edges).reject(function(b){return a===b})}}),f}),define("renderer/tempedge",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.renderer.edge_layer.activate(),this.type="Temp-edge";var a=(this.project.get("users").get(this.renkan.current_user)||e._USER_PLACEHOLDER(this.renkan)).get("color");this.line=new paper.Path,this.line.strokeColor=a,this.line.dashArray=[4,2],this.line.strokeWidth=this.options.selected_edge_stroke_width,this.line.add([0,0],[0,0]),this.line.__representation=this,this.arrow=new paper.Path,this.arrow.fillColor=a,this.arrow.add([0,0],[this.options.edge_arrow_length,this.options.edge_arrow_width/2],[0,this.options.edge_arrow_width]),this.arrow.__representation=this,this.arrow_angle=0},redraw:function(){var a=this.from_representation.paper_coords,b=this.end_pos,c=b.subtract(a).angle,d=a.add(b).divide(2);this.line.segments[0].point=a,this.line.segments[1].point=b,this.arrow.rotate(c-this.arrow_angle),this.arrow.position=d,this.arrow_angle=c},paperShift:function(a){if(!this.renderer.isEditable())return this.renderer.removeRepresentation(_this),void paper.view.draw();this.end_pos=this.end_pos.add(a);var b=paper.project.hitTest(this.end_pos);this.renderer.findTarget(b),this.redraw()},mouseup:function(a){var b=paper.project.hitTest(a.point),c=this.from_representation.model,d=!0;if(b&&"undefined"!=typeof b.item.__representation){var f=b.item.__representation;if("Node"===f.type.substr(0,4)){var g=f.model||f.source_representation.model;if(c!==g){var h={id:e.getUID("edge"),created_by:this.renkan.current_user,from:c,to:g};this.renderer.isEditable()&&this.project.addEdge(h)}}(c===f.model||f.source_representation&&f.source_representation.model===c)&&(d=!1,this.renderer.is_dragging=!0)}d&&(this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.removeRepresentation(this),paper.view.draw())},destroy:function(){this.arrow.remove(),this.line.remove()}}),f}),define("renderer/baseeditor",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.renderer.buttons_layer.activate(),this.type="editor",this.editor_block=new paper.Path;var c=b(b.range(8)).map(function(){return[0,0]});this.editor_block.add.apply(this.editor_block,c),this.editor_block.strokeWidth=this.options.tooltip_border_width,this.editor_block.strokeColor=this.options.tooltip_border_color,this.editor_block.opacity=.8,this.editor_$=a("<div>").appendTo(this.renderer.editor_$).css({position:"absolute",opacity:.8}).hide()},destroy:function(){this.editor_block.remove(),this.editor_$.remove()}}),f}),define("renderer/nodeeditor",["jquery","underscore","requtils","renderer/baseeditor"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({template:b.template('<h2><span class="Rk-CloseX">&times;</span><%-renkan.translate("Edit Node")%></span></h2><p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-node.title%>"/></p><% if (options.show_node_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-node.uri%>"/><a class="Rk-Edit-Goto" href="<%-node.uri%>" target="_blank"></a></p><% } %><% if (options.show_node_editor_description) { %><p><label><%-renkan.translate("Description:")%></label><textarea class="Rk-Edit-Description"><%-node.description%></textarea></p><% } %><% if (options.show_node_editor_size) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Size:")%></span><a href="#" class="Rk-Edit-Size-Down">-</a><span class="Rk-Edit-Size-Value"><%-node.size%></span><a href="#" class="Rk-Edit-Size-Up">+</a></p><% } %><% if (options.show_node_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Node color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-node.color%>;"><span class="Rk-Edit-ColorTip"></span></span><%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %><% if (options.show_node_editor_image) { %><div class="Rk-Edit-ImgWrap"><div class="Rk-Edit-ImgPreview"><img src="<%-node.image || node.image_placeholder%>" /><% if (node.clip_path) { %><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none"><path style="stroke-width: .02; stroke:red; fill-opacity:.3; fill:red;" d="<%- node.clip_path %>"/></svg><% }%></div></div><p><label><%-renkan.translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p><p><label><%-renkan.translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p><% } %><% if (options.show_node_editor_creator && node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>'),readOnlyTemplate:b.template('<h2><span class="Rk-CloseX">&times;</span><% if (options.show_node_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-node.color%>;"></span><% } %><span class="Rk-Display-Title"><% if (node.uri) { %><a href="<%-node.uri%>" target="_blank"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2><% if (node.uri && options.show_node_tooltip_uri) { %><p class="Rk-Display-URI"><a href="<%-node.uri%>" target="_blank"><%-node.short_uri%></a></p><% } %><% if (options.show_node_tooltip_description) { %><p class="Rk-Display-Description"><%-node.description%></p><% } %><% if (node.image && options.show_node_tooltip_image) { %><img class="Rk-Display-ImgPreview" src="<%-node.image%>" /><% } %><% if (node.has_creator && options.show_node_tooltip_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>'),draw:function(){var c=this.source_representation.model,d=c.get("created_by")||e._USER_PLACEHOLDER(this.renkan),f=this.renderer.isEditable()?this.template:this.readOnlyTemplate,g=this.options.static_url+"img/image-placeholder.png",h=c.get("size")||0;this.editor_$.html(f({node:{has_creator:!!c.get("created_by"),title:c.get("title"),uri:c.get("uri"),short_uri:e.shortenText((c.get("uri")||"").replace(/^(https?:\/\/)?(www\.)?/,"").replace(/\/$/,""),40),description:c.get("description"),image:c.get("image")||"",image_placeholder:g,color:c.get("color")||d.get("color"),clip_path:c.get("clip_path")||!1,created_by_color:d.get("color"),created_by_title:d.get("title"),size:(h>0?"+":"")+h},renkan:this.renkan,options:this.options,shortenText:e.shortenText})),this.redraw();var i=this,j=function(){i.renderer.removeRepresentation(i),paper.view.draw()};if(this.editor_$.find(".Rk-CloseX").click(j),this.editor_$.find(".Rk-Edit-Goto").click(function(){return c.get("uri")?void 0:!1}),this.renderer.isEditable()){var k=b(function(){b(function(){if(i.renderer.isEditable()){var a={title:i.editor_$.find(".Rk-Edit-Title").val()};i.options.show_node_editor_uri&&(a.uri=i.editor_$.find(".Rk-Edit-URI").val(),i.editor_$.find(".Rk-Edit-Goto").attr("href",a.uri||"#")),i.options.show_node_editor_image&&(a.image=i.editor_$.find(".Rk-Edit-Image").val(),i.editor_$.find(".Rk-Edit-ImgPreview").attr("src",a.image||g)),i.options.show_node_editor_description&&(a.description=i.editor_$.find(".Rk-Edit-Description").val()),c.set(a),i.redraw()}else j()}).defer()}).throttle(500);this.editor_$.on("keyup",function(a){27===a.keyCode&&j()}),this.editor_$.find("input, textarea").on("change keyup paste",k),this.editor_$.find(".Rk-Edit-Image-File").change(function(){if(this.files.length){var a=this.files[0],b=new FileReader;if("image"!==a.type.substr(0,5))return void alert(i.renkan.translate("This file is not an image"));if(a.size>1024*i.options.uploaded_image_max_kb)return void alert(i.renkan.translate("Image size must be under ")+i.options.uploaded_image_max_kb+i.renkan.translate("KB"));b.onload=function(a){i.editor_$.find(".Rk-Edit-Image").val(a.target.result),k()},b.readAsDataURL(a)}}),this.editor_$.find(".Rk-Edit-Title")[0].focus();var l=i.editor_$.find(".Rk-Edit-ColorPicker");this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(function(a){a.preventDefault(),l.show()},function(a){a.preventDefault(),l.hide()}),l.find("li").hover(function(b){b.preventDefault(),i.editor_$.find(".Rk-Edit-Color").css("background",a(this).attr("data-color"))},function(a){a.preventDefault(),i.editor_$.find(".Rk-Edit-Color").css("background",c.get("color")||(c.get("created_by")||e._USER_PLACEHOLDER(i.renkan)).get("color"))}).click(function(b){b.preventDefault(),i.renderer.isEditable()?(c.set("color",a(this).attr("data-color")),l.hide(),paper.view.draw()):j()});var m=function(a){if(i.renderer.isEditable()){var b=a+(c.get("size")||0);i.editor_$.find(".Rk-Edit-Size-Value").text((b>0?"+":"")+b),c.set("size",b),paper.view.draw()}else j()};this.editor_$.find(".Rk-Edit-Size-Down").click(function(){return m(-1),!1}),this.editor_$.find(".Rk-Edit-Size-Up").click(function(){return m(1),!1})}else if("object"==typeof this.source_representation.highlighted){var n=this.source_representation.highlighted.replace(b(c.get("title")).escape(),'<span class="Rk-Highlighted">$1</span>');this.editor_$.find(".Rk-Display-Title"+(c.get("uri")?" a":"")).html(n),this.options.show_node_tooltip_description&&this.editor_$.find(".Rk-Display-Description").html(this.source_representation.highlighted.replace(b(c.get("description")).escape(),'<span class="Rk-Highlighted">$1</span>'))}this.editor_$.find("img").load(function(){i.redraw()})},redraw:function(){var a=this.source_representation.paper_coords;e.drawEditBox(this.options,a,this.editor_block,.75*this.source_representation.circle_radius,this.editor_$),this.editor_$.show(),paper.view.draw()}}),f}),define("renderer/edgeeditor",["jquery","underscore","requtils","renderer/baseeditor"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({template:b.template('<h2><span class="Rk-CloseX">&times;</span><%-renkan.translate("Edit Edge")%></span></h2><p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-edge.title%>"/></p><% if (options.show_edge_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-edge.uri%>"/><a class="Rk-Edit-Goto" href="<%-edge.uri%>" target="_blank"></a></p><% if (options.properties.length) { %><p><label><%-renkan.translate("Choose from vocabulary:")%></label><select class="Rk-Edit-Vocabulary"><% _(options.properties).each(function(ontology) { %><option class="Rk-Edit-Vocabulary-Class" value=""><%- renkan.translate(ontology.label) %></option><% _(ontology.properties).each(function(property) { var uri = ontology["base-uri"] + property.uri; %><option class="Rk-Edit-Vocabulary-Property" value="<%- uri %>"<% if (uri === edge.uri) { %> selected<% } %>><%- renkan.translate(property.label) %></option><% }) %><% }) %></select></p><% } } %><% if (options.show_edge_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Edge color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-edge.color%>;"><span class="Rk-Edit-ColorTip"></span></span><%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %><% if (options.show_edge_editor_direction) { %><p><span class="Rk-Edit-Direction"><%- renkan.translate("Change edge direction") %></span></p><% } %><% if (options.show_edge_editor_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p><p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %><% if (options.show_edge_editor_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'),readOnlyTemplate:b.template('<h2><span class="Rk-CloseX">&times;</span><% if (options.show_edge_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-edge.color%>;"></span><% } %><span class="Rk-Display-Title"><% if (edge.uri) { %><a href="<%-edge.uri%>" target="_blank"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2><% if (options.show_edge_tooltip_uri && edge.uri) { %><p class="Rk-Display-URI"><a href="<%-edge.uri%>" target="_blank"><%-edge.short_uri%></a></p><% } %><p><%-edge.description%></p><% if (options.show_edge_tooltip_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p><p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %><% if (options.show_edge_tooltip_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'),draw:function(){var c=this.source_representation.model,d=c.get("from"),f=c.get("to"),g=c.get("created_by")||e._USER_PLACEHOLDER(this.renkan),h=this.renderer.isEditable()?this.template:this.readOnlyTemplate;this.editor_$.html(h({edge:{has_creator:!!c.get("created_by"),title:c.get("title"),uri:c.get("uri"),short_uri:e.shortenText((c.get("uri")||"").replace(/^(https?:\/\/)?(www\.)?/,"").replace(/\/$/,""),40),description:c.get("description"),color:c.get("color")||g.get("color"),from_title:d.get("title"),to_title:f.get("title"),from_color:d.get("color")||(d.get("created_by")||e._USER_PLACEHOLDER(this.renkan)).get("color"),to_color:f.get("color")||(f.get("created_by")||e._USER_PLACEHOLDER(this.renkan)).get("color"),created_by_color:g.get("color"),created_by_title:g.get("title")},renkan:this.renkan,shortenText:e.shortenText,options:this.options})),this.redraw();var i=this,j=function(){i.renderer.removeRepresentation(i),paper.view.draw()};if(this.editor_$.find(".Rk-CloseX").click(j),this.editor_$.find(".Rk-Edit-Goto").click(function(){return c.get("uri")?void 0:!1}),this.renderer.isEditable()){var k=b(function(){b(function(){if(i.renderer.isEditable()){var a={title:i.editor_$.find(".Rk-Edit-Title").val()};i.options.show_edge_editor_uri&&(a.uri=i.editor_$.find(".Rk-Edit-URI").val()),i.editor_$.find(".Rk-Edit-Goto").attr("href",a.uri||"#"),c.set(a),paper.view.draw()
-}else j()}).defer()}).throttle(500);this.editor_$.on("keyup",function(a){27===a.keyCode&&j()}),this.editor_$.find("input").on("keyup change paste",k),this.editor_$.find(".Rk-Edit-Vocabulary").change(function(){var b=a(this),c=b.val();c&&(i.editor_$.find(".Rk-Edit-Title").val(b.find(":selected").text()),i.editor_$.find(".Rk-Edit-URI").val(c),k())}),this.editor_$.find(".Rk-Edit-Direction").click(function(){i.renderer.isEditable()?(c.set({from:c.get("to"),to:c.get("from")}),i.draw()):j()});var l=i.editor_$.find(".Rk-Edit-ColorPicker");this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(function(a){a.preventDefault(),l.show()},function(a){a.preventDefault(),l.hide()}),l.find("li").hover(function(b){b.preventDefault(),i.editor_$.find(".Rk-Edit-Color").css("background",a(this).attr("data-color"))},function(a){a.preventDefault(),i.editor_$.find(".Rk-Edit-Color").css("background",c.get("color")||(c.get("created_by")||e._USER_PLACEHOLDER(i.renkan)).get("color"))}).click(function(b){b.preventDefault(),i.renderer.isEditable()?(c.set("color",a(this).attr("data-color")),l.hide(),paper.view.draw()):j()})}},redraw:function(){var a=this.source_representation.paper_coords;e.drawEditBox(this.options,a,this.editor_block,5,this.editor_$),this.editor_$.show(),paper.view.draw()}}),f}),define("renderer/nodebutton",["jquery","underscore","requtils","renderer/basebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({setSectorSize:function(){var a=this.source_representation.circle_radius;a!==this.lastSectorInner&&(this.sector&&this.sector.destroy(),this.sector=this.renderer.drawSector(this,1+a,e._NODE_BUTTON_WIDTH+a,this.startAngle,this.endAngle,1,this.imageName,this.renkan.translate(this.text)),this.lastSectorInner=a)}}),f}),define("renderer/nodeeditbutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-edit-button",this.lastSectorInner=0,this.startAngle=-135,this.endAngle=-45,this.imageName="edit",this.text="Edit"},mouseup:function(){this.renderer.is_dragging||this.source_representation.openEditor()}}),f}),define("renderer/noderemovebutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-remove-button",this.lastSectorInner=0,this.startAngle=0,this.endAngle=90,this.imageName="remove",this.text="Remove"},mouseup:function(){if(this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.removeRepresentationsOfType("editor"),this.renderer.isEditable())if(this.options.element_delete_delay){var a=e.getUID("delete");this.renderer.delete_list.push({id:a,time:(new Date).valueOf()+this.options.element_delete_delay}),this.source_representation.model.set("delete_scheduled",a)}else confirm(this.renkan.translate("Do you really wish to remove node ")+'"'+this.source_representation.model.get("title")+'"?')&&this.project.removeNode(this.source_representation.model)}}),f}),define("renderer/noderevertbutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-revert-button",this.lastSectorInner=0,this.startAngle=-135,this.endAngle=135,this.imageName="revert",this.text="Cancel deletion"},mouseup:function(){this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.isEditable()&&this.source_representation.model.unset("delete_scheduled")}}),f}),define("renderer/nodelinkbutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-link-button",this.lastSectorInner=0,this.startAngle=90,this.endAngle=180,this.imageName="link",this.text="Link to another node"},mousedown:function(a){if(this.renderer.isEditable()){var b=this.renderer.canvas_$.offset(),c=new paper.Point([a.pageX-b.left,a.pageY-b.top]);this.renderer.click_target=null,this.renderer.removeRepresentationsOfType("editor"),this.renderer.addTempEdge(this.source_representation,c)}}}),f}),define("renderer/nodeenlargebutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-enlarge-button",this.lastSectorInner=0,this.startAngle=-45,this.endAngle=0,this.imageName="enlarge",this.text="Enlarge"},mouseup:function(){var a=1+(this.source_representation.model.get("size")||0);this.source_representation.model.set("size",a),this.source_representation.select(),this.select(),paper.view.draw()}}),f}),define("renderer/nodeshrinkbutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-shrink-button",this.lastSectorInner=0,this.startAngle=-180,this.endAngle=-135,this.imageName="shrink",this.text="Shrink"},mouseup:function(){var a=-1+(this.source_representation.model.get("size")||0);this.source_representation.model.set("size",a),this.source_representation.select(),this.select(),paper.view.draw()}}),f}),define("renderer/edgeeditbutton",["jquery","underscore","requtils","renderer/basebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Edge-edit-button",this.sector=this.renderer.drawSector(this,e._EDGE_BUTTON_INNER,e._EDGE_BUTTON_OUTER,-270,-90,1,"edit",this.renkan.translate("Edit"))},mouseup:function(){this.renderer.is_dragging||this.source_representation.openEditor()}}),f}),define("renderer/edgeremovebutton",["jquery","underscore","requtils","renderer/basebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Edge-remove-button",this.sector=this.renderer.drawSector(this,e._EDGE_BUTTON_INNER,e._EDGE_BUTTON_OUTER,-90,90,1,"remove",this.renkan.translate("Remove"))},mouseup:function(){if(this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.removeRepresentationsOfType("editor"),this.renderer.isEditable())if(this.options.element_delete_delay){var a=e.getUID("delete");this.renderer.delete_list.push({id:a,time:(new Date).valueOf()+this.options.element_delete_delay}),this.source_representation.model.set("delete_scheduled",a)}else confirm(this.renkan.translate("Do you really wish to remove edge ")+'"'+this.source_representation.model.get("title")+'"?')&&this.project.removeEdge(this.source_representation.model)}}),f}),define("renderer/edgerevertbutton",["jquery","underscore","requtils","renderer/basebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Edge-revert-button",this.sector=this.renderer.drawSector(this,e._EDGE_BUTTON_INNER,e._EDGE_BUTTON_OUTER,-135,135,1,"revert",this.renkan.translate("Cancel deletion"))},mouseup:function(){this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.isEditable()&&this.source_representation.model.unset("delete_scheduled")}}),f}),define("renderer/miniframe",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({paperShift:function(a){this.renderer.offset=this.renderer.offset.subtract(a.divide(this.renderer.minimap.scale).multiply(this.renderer.scale)),this.renderer.redraw()},mouseup:function(){this.renderer.click_target=null,this.renderer.is_dragging=!1}}),f}),define("renderer/scene",["jquery","underscore","filesaver","requtils","renderer/miniframe"],function(a,b,c,d,e){var f=d.getUtils(),g=function(c){this.renkan=c,this.$=a(".Rk-Render"),this.representations=[],this.$.html(this.template(c)),this.onStatusChange(),this.canvas_$=this.$.find(".Rk-Canvas"),this.labels_$=this.$.find(".Rk-Labels"),this.editor_$=this.$.find(".Rk-Editor"),this.notif_$=this.$.find(".Rk-Notifications"),paper.setup(this.canvas_$[0]),this.scale=1,this.initialScale=1,this.offset=paper.view.center,this.totalScroll=0,this.mouse_down=!1,this.click_target=null,this.selected_target=null,this.edge_layer=new paper.Layer,this.node_layer=new paper.Layer,this.buttons_layer=new paper.Layer,this.delete_list=[],this.redrawActive=!0,c.options.show_minimap&&(this.minimap={background_layer:new paper.Layer,edge_layer:new paper.Layer,node_layer:new paper.Layer,node_group:new paper.Group,size:new paper.Size(c.options.minimap_width,c.options.minimap_height)},this.minimap.background_layer.activate(),this.minimap.topleft=paper.view.bounds.bottomRight.subtract(this.minimap.size),this.minimap.rectangle=new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]),this.minimap.size.add([4,4])),this.minimap.rectangle.fillColor=c.options.minimap_background_color,this.minimap.rectangle.strokeColor=c.options.minimap_border_color,this.minimap.rectangle.strokeWidth=4,this.minimap.offset=new paper.Point(this.minimap.size.divide(2)),this.minimap.scale=.1,this.minimap.node_layer.activate(),this.minimap.cliprectangle=new paper.Path.Rectangle(this.minimap.topleft,this.minimap.size),this.minimap.node_group.addChild(this.minimap.cliprectangle),this.minimap.node_group.clipped=!0,this.minimap.miniframe=new paper.Path.Rectangle(this.minimap.topleft,this.minimap.size),this.minimap.node_group.addChild(this.minimap.miniframe),this.minimap.miniframe.fillColor="#c0c0ff",this.minimap.miniframe.opacity=.3,this.minimap.miniframe.strokeColor="#000080",this.minimap.miniframe.strokeWidth=3,this.minimap.miniframe.__representation=new e(this,null)),this.throttledPaperDraw=b(function(){paper.view.draw()}).throttle(100),this.bundles=[],this.click_mode=!1;var d=this,g=!0,h=1,i=!1,j=0,k=0;this.image_cache={},this.icon_cache={},["edit","remove","link","enlarge","shrink","revert"].forEach(function(a){var b=new Image;b.src=c.options.static_url+"img/"+a+".png",d.icon_cache[a]=b});var l=b.throttle(function(a,b){d.onMouseMove(a,b)},f._MOUSEMOVE_RATE);this.canvas_$.on({mousedown:function(a){a.preventDefault(),d.onMouseDown(a,!1)},mousemove:function(a){a.preventDefault(),l(a,!1)},mouseup:function(a){a.preventDefault(),d.onMouseUp(a,!1)},mousewheel:function(a,b){c.options.zoom_on_scroll&&(a.preventDefault(),g&&d.onScroll(a,b))},touchstart:function(a){a.preventDefault();var b=a.originalEvent.touches[0];c.options.allow_double_click&&new Date-_lastTap<f._DOUBLETAP_DELAY&&Math.pow(j-b.pageX,2)+Math.pow(k-b.pageY,2)<f._DOUBLETAP_DISTANCE?(_lastTap=0,d.onDoubleClick(b)):(_lastTap=new Date,j=b.pageX,k=b.pageY,h=d.scale,i=!1,d.onMouseDown(b,!0))},touchmove:function(a){if(a.preventDefault(),_lastTap=0,1===a.originalEvent.touches.length)d.onMouseMove(a.originalEvent.touches[0],!0);else{if(i||(d.onMouseUp(a.originalEvent.touches[0],!0),d.click_target=null,d.is_dragging=!1,i=!0),"undefined"===a.originalEvent.scale)return;var b=a.originalEvent.scale*h,c=b/d.scale,e=new paper.Point([d.canvas_$.width(),d.canvas_$.height()]).multiply(.5*(1-c)).add(d.offset.multiply(c));d.setScale(b,e)}},touchend:function(a){a.preventDefault(),d.onMouseUp(a.originalEvent.changedTouches[0],!0)},dblclick:function(a){a.preventDefault(),c.options.allow_double_click&&d.onDoubleClick(a)},mouseleave:function(a){a.preventDefault(),d.onMouseUp(a,!1),d.click_target=null,d.is_dragging=!1},dragover:function(a){a.preventDefault()},dragenter:function(a){a.preventDefault(),g=!1},dragleave:function(a){a.preventDefault(),g=!0},drop:function(a){a.preventDefault(),g=!0;var c={};b(a.originalEvent.dataTransfer.types).each(function(b){try{c[b]=a.originalEvent.dataTransfer.getData(b)}catch(d){}});var e=a.originalEvent.dataTransfer.getData("Text");if("string"==typeof e)switch(e[0]){case"{":case"[":try{var f=JSON.parse(e);b(c).extend(f)}catch(h){c["text/plain"]||(c["text/plain"]=e)}break;case"<":c["text/html"]||(c["text/html"]=e);break;default:c["text/plain"]||(c["text/plain"]=e)}var i=a.originalEvent.dataTransfer.getData("URL");i&&!c["text/uri-list"]&&(c["text/uri-list"]=i),d.dropData(c,a.originalEvent)}});var m=function(a,b){d.$.find(a).click(function(a){return d[b](a),!1})};m(".Rk-ZoomOut","zoomOut"),m(".Rk-ZoomIn","zoomIn"),m(".Rk-ZoomFit","autoScale"),this.$.find(".Rk-ZoomSave").click(function(){d.renkan.project.addView({zoom_level:d.scale,offset:d.offset})}),this.$.find(".Rk-ZoomSetSaved").click(function(){var a=d.renkan.project.get("views").last();a&&d.setScale(a.get("zoom_level"),new paper.Point(a.get("offset")))}),this.renkan.read_only&&!isNaN(parseInt(this.renkan.options.default_view))&&this.$.find(".Rk-ZoomSetSaved").show(),this.$.find(".Rk-CurrentUser").mouseenter(function(){d.$.find(".Rk-UserList").slideDown()}),this.$.find(".Rk-Users").mouseleave(function(){d.$.find(".Rk-UserList").slideUp()}),m(".Rk-FullScreen-Button","fullScreen"),m(".Rk-AddNode-Button","addNodeBtn"),m(".Rk-AddEdge-Button","addEdgeBtn"),m(".Rk-Save-Button","save"),m(".Rk-Open-Button","open"),m(".Rk-Export-Button","exportProject"),this.$.find(".Rk-Bookmarklet-Button").attr("href","javascript:"+f._BOOKMARKLET_CODE(c)).click(function(){return d.notif_$.text(c.translate("Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.")).fadeIn().delay(5e3).fadeOut(),!1}),this.$.find(".Rk-TopBar-Button").mouseover(function(){a(this).find(".Rk-TopBar-Tooltip").show()}).mouseout(function(){a(this).find(".Rk-TopBar-Tooltip").hide()}),m(".Rk-Fold-Bins","foldBins"),paper.view.onResize=function(a){paper.view._viewSize.height=a.size.height=d.canvas_$.parent().height(),d.minimap&&(d.minimap.topleft=paper.view.bounds.bottomRight.subtract(d.minimap.size),d.minimap.rectangle.fitBounds(d.minimap.topleft.subtract([2,2]),d.minimap.size.add([4,4])),d.minimap.cliprectangle.fitBounds(d.minimap.topleft,d.minimap.size)),d.redraw()};var n=b.throttle(function(){d.redraw()},50);this.addRepresentations("Node",this.renkan.project.get("nodes")),this.addRepresentations("Edge",this.renkan.project.get("edges")),this.renkan.project.on("change:title",function(){d.$.find(".Rk-PadTitle").val(c.project.get("title"))}),this.$.find(".Rk-PadTitle").on("keyup input paste",function(){c.project.set({title:a(this).val()})});var o=b.throttle(function(){d.redrawUsers()},100);if(o(),this.renkan.project.on("add:users remove:users",o),this.renkan.project.on("add:views remove:views",function(){d.renkan.project.get("views").length>0?d.$.find(".Rk-ZoomSetSaved").show():d.$.find(".Rk-ZoomSetSaved").hide()}),this.renkan.project.on("add:nodes",function(a){d.addRepresentation("Node",a),n()}),this.renkan.project.on("add:edges",function(a){d.addRepresentation("Edge",a),n()}),this.renkan.project.on("change:title",function(a,b){var c=d.$.find(".Rk-PadTitle");c.is("input")?c.val()!==b&&c.val(b):c.text(b)}),c.options.size_bug_fix){var p="number"==typeof c.options.size_bug_fix?c.options.size_bug_fix:500;window.setTimeout(function(){d.fixSize(!0)},p)}if(c.options.force_resize&&a(window).resize(function(){d.fixSize(!1)}),c.options.show_user_list&&c.options.user_color_editable){var q=this.$.find(".Rk-Users .Rk-Edit-ColorPicker-Wrapper"),r=this.$.find(".Rk-Users .Rk-Edit-ColorPicker");q.hover(function(a){d.isEditable()&&(a.preventDefault(),r.show())},function(a){a.preventDefault(),r.hide()}),r.find("li").mouseenter(function(b){d.isEditable()&&(b.preventDefault(),d.$.find(".Rk-CurrentUser-Color").css("background",a(this).attr("data-color")))})}if(c.options.show_search_field){var s="";this.$.find(".Rk-GraphSearch-Field").on("keyup change paste input",function(){var b=a(this),e=b.val();if(e!==s)if(s=e,e.length<2)c.project.get("nodes").each(function(a){d.getRepresentationByModel(a).unhighlight()});else{var g=f.regexpFromTextOrArray(e);c.project.get("nodes").each(function(a){g.test(a.get("title"))||g.test(a.get("description"))?d.getRepresentationByModel(a).highlight(g):d.getRepresentationByModel(a).unhighlight()})}})}this.redraw(),window.setInterval(function(){var a=(new Date).valueOf();d.delete_list.forEach(function(b){if(a>=b.time){var d=c.project.get("nodes").findWhere({delete_scheduled:b.id});d&&project.removeNode(d),d=c.project.get("edges").findWhere({delete_scheduled:b.id}),d&&project.removeEdge(d)}}),d.delete_list=d.delete_list.filter(function(a){return c.project.get("nodes").findWhere({delete_scheduled:a.id})||c.project.get("edges").findWhere({delete_scheduled:a.id})})},500),this.minimap&&window.setInterval(function(){d.rescaleMinimap()},2e3)};return b(g.prototype).extend({template:b.template('<% if (options.show_top_bar) { %><div class="Rk-TopBar"><% if (!options.editor_mode) { %><h2 class="Rk-PadTitle"><%- project.get("title") || translate("Untitled project")%></h2><% } else { %><input type="text" class="Rk-PadTitle" value="<%- project.get("title") || "" %>" placeholder="<%-translate("Untitled project")%>" /><% } %><% if (options.show_user_list) { %><div class="Rk-Users"><div class="Rk-CurrentUser"><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-CurrentUser-Color"><% if (options.user_color_editable) { %><span class="Rk-Edit-ColorTip"></span><% } %></span><% if (options.user_color_editable) { print(colorPicker) } %></div><span class="Rk-CurrentUser-Name">&lt;unknown user&gt;</span></div><ul class="Rk-UserList"></ul></div><% } %><% if (options.home_button_url) {%><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Home-Button" href="<%- options.home_button_url %>"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%- translate(options.home_button_title) %></div></div></a><% } %><% if (options.show_fullscreen_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-FullScreen-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Full Screen")%></div></div></div><% } %><% if (options.editor_mode) { %><% if (options.show_addnode_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddNode-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Node")%></div></div></div><% } %><% if (options.show_addedge_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddEdge-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Edge")%></div></div></div><% } %><% if (options.show_export_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Export-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Download Project")%></div></div></div><% } %><% if (options.show_save_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Save-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"> </div></div></div><% } %><% if (options.show_open_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Open-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Open Project")%></div></div></div><% } %><% if (options.show_bookmarklet) { %><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Bookmarklet-Button" href="#"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Renkan \'Drag-to-Add\' bookmarklet")%></div></div></a><% } %><% } else { %><% if (options.show_export_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Export-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Download Project")%></div></div></div><div class="Rk-TopBar-Separator"></div><% } %><% };if (options.show_search_field) { %><form action="#" class="Rk-GraphSearch-Form"><input type="search" class="Rk-GraphSearch-Field" placeholder="<%- translate("Search in graph") %>" /></form><div class="Rk-TopBar-Separator"></div><% } %></div><% } %><div class="Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>"><div class="Rk-Labels"></div><canvas class="Rk-Canvas" resize></canvas><div class="Rk-Notifications"></div><div class="Rk-Editor"><% if (options.show_bins) { %><div class="Rk-Fold-Bins">&laquo;</div><% } %><div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%-translate("Zoom In")%>"></div><div class="Rk-ZoomFit" title="<%-translate("Zoom Fit")%>"></div><div class="Rk-ZoomOut" title="<%-translate("Zoom Out")%>"></div><% if (options.editor_mode) { %><div class="Rk-ZoomSave" title="<%-translate("Zoom Save")%>"></div><% } %><% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %><div class="Rk-ZoomSetSaved" title="<%-translate("View saved zoom")%>"></div><% } %></div></div></div>'),fixSize:function(a){var b=this.$.width(),c=this.$.height();this.renkan.options.show_top_bar&&(c-=this.$.find(".Rk-TopBar").height()),this.canvas_$.attr({width:b,height:c}),paper.view.viewSize=new paper.Size([b,c]),a&&(this.renkan.read_only&&!isNaN(parseInt(this.renkan.options.default_view))?this.autoScale(this.renkan.project.get("views")[parseInt(this.renkan.options.default_view)]):this.autoScale())},drawSector:function(b,c,d,e,f,g,h,i){var j=this.renkan.options,k=e*Math.PI/180,l=f*Math.PI/180,m=this.icon_cache[h],n=-Math.sin(k),o=Math.cos(k),p=Math.cos(k)*c+g*n,q=Math.sin(k)*c+g*o,r=Math.cos(k)*d+g*n,s=Math.sin(k)*d+g*o,t=-Math.sin(l),u=Math.cos(l),v=Math.cos(l)*c-g*t,w=Math.sin(l)*c-g*u,x=Math.cos(l)*d-g*t,y=Math.sin(l)*d-g*u,z=(c+d)/2,A=(k+l)/2,B=Math.cos(A)*z,C=Math.sin(A)*z,D=Math.cos(A)*c,E=Math.cos(A)*d,F=Math.sin(A)*c,G=Math.sin(A)*d,H=Math.cos(A)*(d+3),I=Math.sin(A)*(d+j.buttons_label_font_size)+j.buttons_label_font_size/2;this.buttons_layer.activate();var J=new paper.Path;J.add([p,q]),J.arcTo([D,F],[v,w]),J.lineTo([x,y]),J.arcTo([E,G],[r,s]),J.fillColor=j.buttons_background,J.opacity=.5,J.closed=!0,J.__representation=b;var K=new paper.PointText(H,I);K.characterStyle={fontSize:j.buttons_label_font_size,fillColor:j.buttons_label_color},K.paragraphStyle.justification=H>2?"left":-2>H?"right":"center",K.visible=!1;var L=!1,M=new paper.Point(-200,-200),N=new paper.Group([J,K]),O=N.position,P=new paper.Point([B,C]),Q=new paper.Point(0,0);K.content=i,N.visible=!1,N.position=M;var R={show:function(){L=!0,N.position=Q.add(O),N.visible=!0},moveTo:function(a){Q=a,L&&(N.position=a.add(O))},hide:function(){L=!1,N.visible=!1,N.position=M},select:function(){J.opacity=.8,K.visible=!0},unselect:function(){J.opacity=.5,K.visible=!1},destroy:function(){N.remove()}},S=function(){var a=new paper.Raster(m);a.position=P.add(N.position).subtract(O),a.locked=!0,N.addChild(a)};return m.width?S():a(m).on("load",S),R},addToBundles:function(a){var c=b(this.bundles).find(function(b){return b.from===a.from_representation&&b.to===a.to_representation||b.from===a.to_representation&&b.to===a.from_representation});return"undefined"!=typeof c?c.edges.push(a):(c={from:a.from_representation,to:a.to_representation,edges:[a],getPosition:function(a){var c=a.from_representation===this.from?1:-1;return c*(b(this.edges).indexOf(a)-(this.edges.length-1)/2)}},this.bundles.push(c)),c},isEditable:function(){return this.renkan.options.editor_mode&&!this.renkan.read_only},onStatusChange:function(){var a=this.$.find(".Rk-Save-Button"),b=a.find(".Rk-TopBar-Tooltip-Contents");this.renkan.read_only?(a.removeClass("disabled Rk-Save-Online").addClass("Rk-Save-ReadOnly"),b.text(this.renkan.translate("Connection lost"))):this.renkan.options.snapshot_mode?(a.removeClass("Rk-Save-ReadOnly Rk-Save-Online"),b.text(this.renkan.translate("Save Project"))):(a.removeClass("disabled Rk-Save-ReadOnly").addClass("Rk-Save-Online"),b.text(this.renkan.translate("Auto-save enabled"))),this.redrawUsers()},setScale:function(a,b){a/this.initialScale>f._MIN_SCALE&&a/this.initialScale<f._MAX_SCALE&&(this.scale=a,b&&(this.offset=b),this.redraw())},autoScale:function(a){var b=this.renkan.project.get("nodes");if(b.length>1){var c=b.map(function(a){return a.get("position").x}),d=b.map(function(a){return a.get("position").y}),e=Math.min.apply(Math,c),f=Math.min.apply(Math,d),g=Math.max.apply(Math,c),h=Math.max.apply(Math,d),i=Math.min((paper.view.size.width-2*this.renkan.options.autoscale_padding)/(g-e),(paper.view.size.height-2*this.renkan.options.autoscale_padding)/(h-f));this.initialScale=i,"undefined"!=typeof a&&parseFloat(a.zoom_level)>0&&parseFloat(a.offset.x)>0&&parseFloat(a.offset.y)>0?this.setScale(parseFloat(a.zoom_level),new paper.Point(parseFloat(a.offset.x),parseFloat(a.offset.y))):this.setScale(i,paper.view.center.subtract(new paper.Point([(g+e)/2,(h+f)/2]).multiply(i)))}1===b.length&&this.setScale(1,paper.view.center.subtract(new paper.Point([b.at(0).get("position").x,b.at(0).get("position").y])))},redrawMiniframe:function(){var a=this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))),b=this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight));this.minimap.miniframe.fitBounds(a,b)},rescaleMinimap:function(){var a=this.renkan.project.get("nodes");if(a.length>1){var b=a.map(function(a){return a.get("position").x}),c=a.map(function(a){return a.get("position").y}),d=Math.min.apply(Math,b),e=Math.min.apply(Math,c),f=Math.max.apply(Math,b),g=Math.max.apply(Math,c),h=Math.min(.8*this.scale*this.renkan.options.minimap_width/paper.view.bounds.width,.8*this.scale*this.renkan.options.minimap_height/paper.view.bounds.height,(this.renkan.options.minimap_width-2*this.renkan.options.minimap_padding)/(f-d),(this.renkan.options.minimap_height-2*this.renkan.options.minimap_padding)/(g-e));this.minimap.offset=this.minimap.size.divide(2).subtract(new paper.Point([(f+d)/2,(g+e)/2]).multiply(h)),this.minimap.scale=h}1===a.length&&(this.minimap.scale=.1,this.minimap.offset=this.minimap.size.divide(2).subtract(new paper.Point([a.at(0).get("position").x,a.at(0).get("position").y]).multiply(this.minimap.scale))),this.redraw()},toPaperCoords:function(a){return a.multiply(this.scale).add(this.offset)},toMinimapCoords:function(a){return a.multiply(this.minimap.scale).add(this.minimap.offset).add(this.minimap.topleft)},toModelCoords:function(a){return a.subtract(this.offset).divide(this.scale)},addRepresentation:function(a,b){var c=d.getRenderer()[a],e=new c(this,b);return this.representations.push(e),e},addRepresentations:function(a,b){var c=this;b.forEach(function(b){c.addRepresentation(a,b)})},userTemplate:b.template('<li class="Rk-User"><span class="Rk-UserColor" style="background:<%=background%>;"></span><%=name%></li>'),redrawUsers:function(){if(this.renkan.options.show_user_list){var b=[].concat((this.renkan.project.current_user_list||{}).models||[],(this.renkan.project.get("users")||{}).models||[]),c="",d=this.$.find(".Rk-Users"),e=d.find(".Rk-CurrentUser-Name"),f=d.find(".Rk-Edit-ColorPicker li"),g=d.find(".Rk-CurrentUser-Color"),h=this;e.off("click").text(this.renkan.translate("<unknown user>")),f.off("mouseleave click"),b.forEach(function(b){b.get("_id")===h.renkan.current_user?(e.text(b.get("title")),g.css("background",b.get("color")),h.isEditable()&&(h.renkan.options.user_name_editable&&e.click(function(){var c=a(this),d=a("<input>").val(b.get("title")).blur(function(){b.set("title",a(this).val()),h.redrawUsers(),h.redraw()});c.empty().html(d),d.select()}),h.renkan.options.user_color_editable&&f.click(function(c){c.preventDefault(),h.isEditable()&&b.set("color",a(this).attr("data-color")),a(this).parent().hide()}).mouseleave(function(){g.css("background",b.get("color"))}))):c+=h.userTemplate({name:b.get("title"),background:b.get("color")})}),d.find(".Rk-UserList").html(c)}},removeRepresentation:function(a){a.destroy(),this.representations=b(this.representations).reject(function(b){return b===a})},getRepresentationByModel:function(a){return a?b(this.representations).find(function(b){return b.model===a}):void 0},removeRepresentationsOfType:function(a){var c=b(this.representations).filter(function(b){return b.type===a}),d=this;b(c).each(function(a){d.removeRepresentation(a)})},highlightModel:function(a){var b=this.getRepresentationByModel(a);b&&b.highlight()},unhighlightAll:function(){b(this.representations).each(function(a){a.unhighlight()})},unselectAll:function(){b(this.representations).each(function(a){a.unselect()})},redraw:function(){this.redrawActive&&(b(this.representations).each(function(a){a.redraw(!0)}),this.minimap&&this.redrawMiniframe(),paper.view.draw())},addTempEdge:function(a,b){var c=this.addRepresentation("TempEdge",null);c.end_pos=b,c.from_representation=a,c.redraw(),this.click_target=c},findTarget:function(a){if(a&&"undefined"!=typeof a.item.__representation){var b=a.item.__representation;this.selected_target!==a.item.__representation&&(this.selected_target&&this.selected_target.unselect(b),b.select(this.selected_target),this.selected_target=b)}else this.selected_target&&this.selected_target.unselect(),this.selected_target=null},paperShift:function(a){this.offset=this.offset.add(a),this.redraw()},onMouseMove:function(a){var b=this.canvas_$.offset(),c=new paper.Point([a.pageX-b.left,a.pageY-b.top]),d=c.subtract(this.last_point);this.last_point=c,!this.is_dragging&&this.mouse_down&&d.length>f._MIN_DRAG_DISTANCE&&(this.is_dragging=!0);var e=paper.project.hitTest(c);this.is_dragging?this.click_target&&"function"==typeof this.click_target.paperShift?this.click_target.paperShift(d):this.paperShift(d):this.findTarget(e),paper.view.draw()},onMouseDown:function(b,c){var d=this.canvas_$.offset(),e=new paper.Point([b.pageX-d.left,b.pageY-d.top]);if(this.last_point=e,this.mouse_down=!0,!this.click_target||"Temp-edge"!==this.click_target.type){this.removeRepresentationsOfType("editor"),this.is_dragging=!1;var g=paper.project.hitTest(e);if(g&&"undefined"!=typeof g.item.__representation)this.click_target=g.item.__representation,this.click_target.mousedown(b,c);else if(this.click_target=null,this.isEditable()&&this.click_mode===f._CLICKMODE_ADDNODE){var h=this.toModelCoords(e),i={id:f.getUID("node"),created_by:this.renkan.current_user,position:{x:h.x,y:h.y}};_node=this.renkan.project.addNode(i),this.getRepresentationByModel(_node).openEditor()}}this.click_mode&&(this.isEditable()&&this.click_mode===f._CLICKMODE_STARTEDGE&&this.click_target&&"Node"===this.click_target.type?(this.removeRepresentationsOfType("editor"),this.addTempEdge(this.click_target,e),this.click_mode=f._CLICKMODE_ENDEDGE,this.notif_$.fadeOut(function(){a(this).html(this.renkan.translate("Click on a second node to complete the edge")).fadeIn()})):(this.notif_$.hide(),this.click_mode=!1)),paper.view.draw()},onMouseUp:function(a,b){if(this.mouse_down=!1,this.click_target){var c=this.canvas_$.offset();this.click_target.mouseup({point:new paper.Point([a.pageX-c.left,a.pageY-c.top])},b)}else this.click_target=null,this.is_dragging=!1,b&&this.unselectAll();paper.view.draw()},onScroll:function(a,b){if(this.totalScroll+=b,Math.abs(this.totalScroll)>=1){var c=this.canvas_$.offset(),d=new paper.Point([a.pageX-c.left,a.pageY-c.top]).subtract(this.offset).multiply(Math.SQRT2-1);this.totalScroll>0?this.setScale(this.scale*Math.SQRT2,this.offset.subtract(d)):this.setScale(this.scale*Math.SQRT1_2,this.offset.add(d.divide(Math.SQRT2))),this.totalScroll=0}},onDoubleClick:function(a){if(this.isEditable()){var b=this.canvas_$.offset(),c=new paper.Point([a.pageX-b.left,a.pageY-b.top]),d=paper.project.hitTest(c);if(this.isEditable()&&(!d||"undefined"==typeof d.item.__representation)){var e=this.toModelCoords(c),g={id:f.getUID("node"),created_by:this.renkan.current_user,position:{x:e.x,y:e.y}},h=this.renkan.project.addNode(g);this.getRepresentationByModel(h).openEditor()}paper.view.draw()}},defaultDropHandler:function(b){var c={},d="";switch(b["text/x-iri-specific-site"]){case"twitter":d=a("<div>").html(b["text/x-iri-selected-html"]);var e=d.find(".tweet");c.title=this.renkan.translate("Tweet by ")+e.attr("data-name"),c.uri="http://twitter.com/"+e.attr("data-screen-name")+"/status/"+e.attr("data-tweet-id"),c.image=e.find(".avatar").attr("src"),c.description=e.find(".js-tweet-text:first").text();
-break;case"google":d=a("<div>").html(b["text/x-iri-selected-html"]),c.title=d.find("h3:first").text().trim(),c.uri=d.find("h3 a").attr("href"),c.description=d.find(".st:first").text().trim();break;default:b["text/x-iri-source-uri"]&&(c.uri=b["text/x-iri-source-uri"])}if((b["text/plain"]||b["text/x-iri-selected-text"])&&(c.description=(b["text/plain"]||b["text/x-iri-selected-text"]).replace(/[\s\n]+/gm," ").trim()),b["text/html"]||b["text/x-iri-selected-html"]){d=a("<div>").html(b["text/html"]||b["text/x-iri-selected-html"]);var f=d.find("image");f.length&&(c.image=f.attr("xlink:href"));var g=d.find("path");g.length&&(c.clipPath=g.attr("d"));var h=d.find("img");h.length&&(c.image=h[0].src);var i=d.find("a");i.length&&(c.uri=i[0].href),c.title=d.find("[title]").attr("title")||c.title,c.description=d.text().replace(/[\s\n]+/gm," ").trim()}b["text/uri-list"]&&(c.uri=b["text/uri-list"]),b["text/x-moz-url"]&&!c.title&&(c.title=(b["text/x-moz-url"].split("\n")[1]||"").trim(),c.title===c.uri&&(c.title=!1)),b["text/x-iri-source-title"]&&!c.title&&(c.title=b["text/x-iri-source-title"]),(b["text/html"]||b["text/x-iri-selected-html"])&&(d=a("<div>").html(b["text/html"]||b["text/x-iri-selected-html"]),c.image=d.find("[data-image]").attr("data-image")||c.image,c.uri=d.find("[data-uri]").attr("data-uri")||c.uri,c.title=d.find("[data-title]").attr("data-title")||c.title,c.description=d.find("[data-description]").attr("data-description")||c.description,c.clipPath=d.find("[data-clip-path]").attr("data-clip-path")||c.clipPath),c.title||(c.title=this.renkan.translate("Dragged resource"));for(var j=["title","description","uri","image"],k=0;k<j.length;k++){var l=j[k];(b["text/x-iri-"+l]||b[l])&&(c[l]=b["text/x-iri-"+l]||b[l]),("none"===c[l]||"null"===c[l])&&(c[l]=void 0)}return"function"==typeof this.renkan.options.drop_enhancer&&(c=this.renkan.options.drop_enhancer(c,b)),c},dropData:function(a,c){if(this.isEditable()){if(a["text/json"]||a["application/json"])try{var d=JSON.parse(a["text/json"]||a["application/json"]);b(a).extend(d)}catch(e){}var g="undefined"==typeof this.renkan.options.drop_handler?this.defaultDropHandler(a):this.renkan.options.drop_handler(a),h=this.canvas_$.offset(),i=new paper.Point([c.pageX-h.left,c.pageY-h.top]),j=this.toModelCoords(i),k={id:f.getUID("node"),created_by:this.renkan.current_user,uri:g.uri||"",title:g.title||"",description:g.description||"",image:g.image||"",color:g.color||void 0,clip_path:g.clipPath||void 0,position:{x:j.x,y:j.y}},l=this.renkan.project.addNode(k),m=this.getRepresentationByModel(l);"drop"===c.type&&m.openEditor()}},fullScreen:function(){var a,b=document.fullScreen||document.mozFullScreen||document.webkitIsFullScreen,c=this.renkan.$[0],d=["requestFullScreen","mozRequestFullScreen","webkitRequestFullScreen"],e=["cancelFullScreen","mozCancelFullScreen","webkitCancelFullScreen"];if(b){for(a=0;a<e.length;a++)if("function"==typeof document[e[a]]){document[e[a]]();break}}else for(a=0;a<d.length;a++)if("function"==typeof c[d[a]]){c[d[a]]();break}},zoomOut:function(){var a=this.scale*Math.SQRT1_2,b=new paper.Point([this.canvas_$.width(),this.canvas_$.height()]).multiply(.5*(1-Math.SQRT1_2)).add(this.offset.multiply(Math.SQRT1_2));this.setScale(a,b)},zoomIn:function(){var a=this.scale*Math.SQRT2,b=new paper.Point([this.canvas_$.width(),this.canvas_$.height()]).multiply(.5*(1-Math.SQRT2)).add(this.offset.multiply(Math.SQRT2));this.setScale(a,b)},addNodeBtn:function(){return this.click_mode===f._CLICKMODE_ADDNODE?(this.click_mode=!1,this.notif_$.hide()):(this.click_mode=f._CLICKMODE_ADDNODE,this.notif_$.text(this.renkan.translate("Click on the background canvas to add a node")).fadeIn()),!1},addEdgeBtn:function(){return this.click_mode===f._CLICKMODE_STARTEDGE||this.click_mode===f._CLICKMODE_ENDEDGE?(this.click_mode=!1,this.notif_$.hide()):(this.click_mode=f._CLICKMODE_STARTEDGE,this.notif_$.text(this.renkan.translate("Click on a first node to start the edge")).fadeIn()),!1},exportProject:function(){var a=this.renkan.project.toJSON(),d=(document.createElement("a"),a.id),e=d+".json";delete a.id,delete a._id,delete a.space_id;var g,h={};b.each(a.nodes,function(a){g=a.id||a._id,delete a._id,delete a.id,h[g]=a["@id"]=f.getUUID4()}),b.each(a.edges,function(a){delete a._id,delete a.id,a.to=h[a.to],a.from=h[a.from]}),b.each(a.views,function(a){g=a.id||a._id,delete a._id,delete a.id}),a.users=[];var i=JSON.stringify(a,null,2),j=new Blob([i],{type:"application/json;charset=utf-8"});c(j,e)},foldBins:function(){var a=this.$.find(".Rk-Fold-Bins"),b=this.renkan.$.find(".Rk-Bins"),c=this;b.offset().left<0?(b.animate({left:0},250),this.$.animate({left:300},250,function(){var a=c.$.width();paper.view.viewSize=new paper.Size([a,c.canvas_$.height()])}),a.html("&laquo;")):(b.animate({left:-300},250),this.$.animate({left:0},250,function(){var a=c.$.width();paper.view.viewSize=new paper.Size([a,c.canvas_$.height()])}),a.html("&raquo;"))},save:function(){},open:function(){}}),g}),"function"==typeof require.config&&require.config({paths:{jquery:"../lib/jquery.min",underscore:"../lib/underscore-min",filesaver:"../lib/FileSaver",requtils:"require-utils"}}),require(["renderer/baserepresentation","renderer/basebutton","renderer/noderepr","renderer/edge","renderer/tempedge","renderer/baseeditor","renderer/nodeeditor","renderer/edgeeditor","renderer/nodebutton","renderer/nodeeditbutton","renderer/noderemovebutton","renderer/noderevertbutton","renderer/nodelinkbutton","renderer/nodeenlargebutton","renderer/nodeshrinkbutton","renderer/edgeeditbutton","renderer/edgeremovebutton","renderer/edgerevertbutton","renderer/miniframe","renderer/scene"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t){var u=window.Rkns;"undefined"==typeof u.Renderer&&(u.Renderer={});var v=u.Renderer;v._BaseRepresentation=a,v._BaseButton=b,v.Node=c,v.Edge=d,v.TempEdge=e,v._BaseEditor=f,v.NodeEditor=g,v.EdgeEditor=h,v._NodeButton=i,v.NodeEditButton=j,v.NodeRemoveButton=k,v.NodeRevertButton=l,v.NodeLinkButton=m,v.NodeEnlargeButton=n,v.NodeShrinkButton=o,v.EdgeEditButton=p,v.EdgeRemoveButton=q,v.EdgeRevertButton=r,v.MiniFrame=s,v.Scene=t,startRenkan()}),define("main-renderer",function(){});
-//# sourceMappingURL=renkan.min.map
\ No newline at end of file
--- a/src/hdalab/static/hdalab/lib/renkan/renkan.min.map	Fri Jul 18 13:29:53 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-{"version":3,"file":"renkan.min.js","sources":["../../js/main.js","../../js/models.js","../../js/defaults.js","../../js/i18n.js","../../js/full-json.js","../../js/ldtjson-bin.js","../../js/list-bin.js","../../js/wikipedia-bin.js","paper-renderer.js"],"names":["root","Rkns","$","jQuery","_","pickerColors","__renkans","_BaseBin","_renkan","_opts","this","renkan","find","hide","addClass","appendTo","title_icon_$","_this","attr","href","title","translate","html","click","destroy","length","slideDown","resizeBins","refresh","count_$","title_$","main_$","auto_refresh","window","setInterval","prototype","detach","Renkan","push","options","defaults","property_files","each","f","getJSON","data","properties","concat","read_only","editor_mode","project","Models","Project","user_id","current_user","container","template","tabs","search_engines","current_user_list","UsersList","on","renderer","redrawUsers","colorPicker","_tmpl","map","c","join","show_editor","Renderer","Scene","search","_select","_input","_form","_search","type","Search","_key","key","getSearchTitle","className","getBgClass","_el","setSearchEngine","submit","val","search_engine","mouseenter","mouseleave","bins","_bin","Bin","elementDropped","_mainDiv","siblings","is","slideUp","_t","_models","get","where","uri","_model","highlightModel","mouseout","unhighlightAll","dragDrop","err","e","preventDefault","touch","originalEvent","changedTouches","off","canvas_$","offset","w","width","h","height","pageX","left","pageY","top","onMouseMove","div","document","createElement","appendChild","cloneNode","dropData","text/html","innerHTML","onMouseDown","onMouseUp","dataTransfer","setData","resize","lastsearch","lastval","Utils","regexpFromTextOrArray","source","tab","render","_text","i18n","language","substr","onStatusChange","_d","outerHeight","css","getUUID4","replace","r","Math","random","v","toString","getUID","pad","n","Date","ID_AUTO_INCREMENT","ID_BASE","getUTCFullYear","getUTCMonth","getUTCDate","_base","_n","_uidbase","getFullURL","url","test","img","Image","src","res","inherit","_baseClass","_callbefore","_class","apply","Array","slice","call","arguments","_init","_initialized","extend","replaceText","makeReplaceFunc","l","k","charsrx","txt","toLowerCase","remrx","j","remsrc","charsub","getSource","inp","removeChars","String","fromCharCode","RegExp","_textOrArray","testrx","replacerx","isempty","_replace","text","_MIN_DRAG_DISTANCE","_NODE_BUTTON_WIDTH","_EDGE_BUTTON_INNER","_EDGE_BUTTON_OUTER","_CLICKMODE_ADDNODE","_CLICKMODE_STARTEDGE","_CLICKMODE_ENDEDGE","_NODE_SIZE_STEP","LN2","_MIN_SCALE","_MAX_SCALE","_MOUSEMOVE_RATE","_DOUBLETAP_DELAY","_DOUBLETAP_DISTANCE","_USER_PLACEHOLDER","color","default_user_color","_BOOKMARKLET_CODE","shortenText","_maxlength","drawEditBox","_options","_coords","_path","_xmargin","_selector","tooltip_width","tooltip_padding","_height","_isLeft","x","paper","view","center","_left","tooltip_arrow_length","_right","_top","y","size","tooltip_margin","max","tooltip_arrow_width","min","_bottom","segments","point","add","closed","fillColor","GradientColor","Gradient","tooltip_top_color","tooltip_bottom_color","Backbone","obj","guid","RenkanModel","RelationalModel","idAttribute","constructor","_id","id","description","prepare","validate","addReference","_propName","_list","_default","_element","User","toJSON","Node","relations","HasOne","relatedModel","created_by","position","image","clip_path","Edge","from","to","View","isArray","zoom_level","RosterUser","HasMany","reverseRelation","includeInJSON","addUser","_props","_user","findOrCreate","addNode","_node","addEdge","_edge","addView","_view","removeNode","remove","removeEdge","_project","users","nodes","edges","views","_item","initialize","filter","Model","site_id","Collection","model","navigator","userLanguage","static_url","show_bins","snapshot_mode","show_top_bar","size_bug_fix","force_resize","allow_double_click","zoom_on_scroll","element_delete_delay","autoscale_padding","default_view","show_search_field","show_user_list","user_name_editable","user_color_editable","show_save_button","show_export_button","show_open_button","show_addnode_button","show_addedge_button","show_bookmarklet","show_fullscreen_button","home_button_url","home_button_title","show_minimap","minimap_width","minimap_height","minimap_padding","minimap_background_color","minimap_border_color","minimap_highlight_color","minimap_highlight_weight","buttons_background","buttons_label_color","buttons_label_font_size","show_node_circles","clip_node_images","node_images_fill_mode","node_size_base","node_stroke_width","selected_node_stroke_width","node_fill_color","highlighted_node_fill_color","node_label_distance","node_label_max_length","label_untitled_nodes","edge_stroke_width","selected_edge_stroke_width","edge_label_distance","edge_label_max_length","edge_arrow_length","edge_arrow_width","edge_gap_in_bundles","label_untitled_edges","tooltip_border_color","tooltip_border_width","show_node_editor_uri","show_node_editor_description","show_node_editor_size","show_node_editor_color","show_node_editor_image","show_node_editor_creator","uploaded_image_max_kb","show_node_tooltip_uri","show_node_tooltip_description","show_node_tooltip_color","show_node_tooltip_image","show_node_tooltip_creator","show_edge_editor_uri","show_edge_editor_color","show_edge_editor_direction","show_edge_editor_nodes","show_edge_editor_creator","show_edge_tooltip_uri","show_edge_tooltip_color","show_edge_tooltip_nodes","show_edge_tooltip_creator","fr","Edit Node","Edit Edge","Title:","URI:","Description:","From:","To:","Image URL:","Choose Image File:","Full Screen","Add Node","Add Edge","Save Project","Open Project","Auto-save enabled","Connection lost","Created by:","Zoom In","Zoom Out","Edit","Remove","Cancel deletion","Link to another node","Enlarge","Shrink","Click on the background canvas to add a node","Click on a first node to start the edge","Click on a second node to complete the edge","Wikipedia","Wikipedia in ","French","English","Japanese","Untitled project","Lignes de Temps","Loading, please wait","Edge color:","Node color:","Choose color","Change edge direction","Do you really wish to remove node ","Do you really wish to remove edge ","This file is not an image","Image size must be under ","Size:","KB","Choose from vocabulary:","SKOS Documentation properties","has note","has example","has definition","SKOS Semantic relations","has broader","has narrower","has related","Dublin Core Metadata","has contributor","covers","created by","has date","published by","has source","has subject","Dragged resource","Search the Web","Search in Bins","Close bin","Refresh bin","(untitled)","Select contents:","Drag items from this website, drop them in Renkan","Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.","jsonIO","_proj","http_method","_load","redrawActive","_data","set","autoScale","_save","ajax","contentType","JSON","stringify","success","_thrSave","throttle","setTimeout","Ldt","ProjectBin","ldt_type","Resclass","console","error","tagTemplate","annotationTemplate","proj_id","project_id","ldt_platform","searchbase","highlight","_e","escape","convertTC","_ms","_res","_totalSeconds","abs","floor","_hours","_minutes","_seconds","_html","_projtitle","meta","count","tags","_tag","_title","htitle","encodedtitle","encodeURIComponent","annotations","_annotation","_description","content","_duration","end","begin","_img","hdescription","start","duration","mediaid","media","annotationid","show","dataType","lang","_q","ResultsBin","segmentTemplate","max_results","highlightrx","objects","_segment","abstract","_begin","start_ts","_end","iri_id","element_id","format","q","limit","ResourceList","resultTemplate","list","trim","_match","match","langs","en","ja","query","_result","encodeURI","snippet","define","_BaseRepresentation","_renderer","_changeBinding","redraw","_removeBinding","removeRepresentation","defer","_selectBinding","select","_unselectBinding","unselect","_super","_func","moveTo","trigger","unhighlight","mousedown","mouseup","getUtils","getRenderer","requtils","BaseRepresentation","_BaseButton","_pos","sector","_newTarget","source_representation","NodeRepr","node_layer","activate","circle","Path","Circle","__representation","strokeWidth","h_ratio","labels_$","normal_buttons","NodeEditButton","NodeRemoveButton","NodeLinkButton","NodeEnlargeButton","NodeShrinkButton","pending_delete_buttons","NodeRevertButton","all_buttons","i","active_buttons","last_circle_radius","minimap","minimap_circle","miniframe","node_group","addChild","_dontRedrawEdges","_model_coords","Point","_baseRadius","exp","is_dragging","paper_coords","toPaperCoords","circle_radius","scale","forEach","b","setSectorSize","node_image","subtract","image_delta","multiply","old_act_btn","opacity","dashArray","selected","isEditable","highlighted","_color","strokeColor","_pc","lastImage","showImage","minipos","toMinimapCoords","miniradius","minisize","Size","fitBounds","ed","edge","repr","getRepresentationByModel","from_representation","to_representation","_image","image_cache","clipPath","hasClipPath","_clip","baseRadius","centerPoint","instructions","lastCoords","minX","Infinity","minY","maxX","maxY","transformCoords","tabc","relative","newCoords","parseFloat","isY","instr","coords","lineTo","cubicCurveTo","quadraticCurveTo","_raster","Raster","locked","Group","clipped","_circleClip","divide","throttledPaperDraw","paperShift","_delta","openEditor","removeRepresentationsOfType","_editor","addRepresentation","draw","_uri","removeClass","undefined","textToReplace","hlvalue","saveCoords","toModelCoords","_event","_isTouch","unselectAll","click_target","edge_layer","bundle","addToBundles","line","arrow","arrow_angle","EdgeEditButton","EdgeRemoveButton","EdgeRevertButton","minimap_line","_p0a","_p1a","_v","_r","_u","_ortho","_group_pos","getPosition","_p0b","_p1b","_a","angle","_textdelta","_handle","handleIn","handleOut","rotate","_textpos","transform","-moz-transform","-webkit-transform","text_angle","reject","TempEdge","_p0","_p1","end_pos","_c","_hitResult","hitTest","findTarget","_endDrag","item","_target","_destmodel","_BaseEditor","buttons_layer","editor_block","_pts","range","editor_$","BaseEditor","NodeEditor","readOnlyTemplate","_created_by","_template","_image_placeholder","_size","node","has_creator","short_uri","image_placeholder","created_by_color","created_by_title","closeEditor","onFieldChange","keyCode","change","files","FileReader","alert","onload","target","result","readAsDataURL","focus","_picker","hover","shiftSize","_newsize","titlehtml","load","EdgeEditor","_from_model","_to_model","from_title","to_title","from_color","to_color","BaseButton","_NodeButton","sectorInner","lastSectorInner","drawSector","startAngle","endAngle","imageName","NodeButton","delid","delete_list","time","valueOf","confirm","unset","_off","_point","addTempEdge","MiniFrame","filesaver","representations","notif_$","setup","initialScale","totalScroll","mouse_down","selected_target","Layer","background_layer","topleft","bounds","bottomRight","rectangle","Rectangle","cliprectangle","bundles","click_mode","_allowScroll","_originalScale","_zooming","_lastTapX","_lastTapY","icon_cache","imgname","throttledMouseMove","mousemove","mousewheel","onScroll","touchstart","_touches","touches","_lastTap","pow","onDoubleClick","touchmove","_newScale","_scaleRatio","_newOffset","setScale","touchend","dblclick","dragover","dragenter","dragleave","drop","types","t","getData","parse","bindClick","selector","fname","evt","last","isNaN","parseInt","fadeIn","delay","fadeOut","mouseover","onResize","_viewSize","parent","_thRedraw","addRepresentations","_thRedrawUsers","el","_delay","fixSize","$cpwrapper","$cplist","$this","rxs","_now","d","findWhere","delete_scheduled","rescaleMinimap","_autoscale","viewSize","_repr","_inR","_outR","_startAngle","_endAngle","_padding","_imgname","_caption","_startRads","PI","_endRads","_startdx","sin","_startdy","cos","_startXIn","_startYIn","_startXOut","_startYOut","_enddx","_enddy","_endXIn","_endYIn","_endXOut","_endYOut","_centerR","_centerRads","_centerX","_centerY","_centerXIn","_centerXOut","_centerYIn","_centerYOut","_textX","_textY","arcTo","PointText","characterStyle","fontSize","paragraphStyle","justification","visible","_visible","_restPos","_grp","_imgdelta","_currentPos","_edgeRepr","_bundle","_er","_dir","indexOf","savebtn","tip","_offset","force_view","_xx","_yy","_minx","_miny","_maxx","_maxy","_scale","at","redrawMiniframe","bottomright","_type","RendererType","_collection","userTemplate","allUsers","models","ulistHtml","$userpanel","$name","$cpitems","$colorsquare","$input","blur","empty","name","background","_representation","_representations","_from","_tmpEdge","last_point","_scrolldelta","SQRT2","SQRT1_2","defaultDropHandler","newNode","tweetdiv","_svgimgs","_svgpaths","_imgs","_as","split","fields","drop_enhancer","jsondata","drop_handler","_nodedata","fullScreen","_isFull","mozFullScreen","webkitIsFullScreen","_requestMethods","_cancelMethods","zoomOut","zoomIn","addNodeBtn","addEdgeBtn","exportProject","projectJSON","projectId","fileNameToSaveAs","space_id","objId","idsMap","projectJSONStr","blob","Blob","foldBins","foldBinsButton","animate","save","open","require","config","paths","jquery","underscore","startRenkan"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;CAGA,SAAUA,GAEV,YAEyB,iBAAdA,GAAKC,OACZD,EAAKC,QAGT,IAAIA,GAAOD,EAAKC,KACZC,EAAID,EAAKC,EAAIF,EAAKG,OAClBC,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OhC,IAEU,oBAAlBA,GAAKqE,WACXrE,EAAKqE,YAET,IAAIA,GAAWrE,EAAKqE,QAEpBA,GAASggB,oBAAsBqB,EAC/BrhB,EAASshB,YAAcoN,EACvB1uB,EAAS2N,KAAOgU,EAChB3hB,EAASmO,KAAOA,EAChBnO,EAASkrB,SAAWA,EACpBlrB,EAAS8rB,YAAcM,EACvBpsB,EAASqsB,WAAaA,EACtBrsB,EAASmuB,WAAaA,EACtBnuB,EAAS2uB,YAAcO,EACvBlvB,EAASsiB,eAAiBA,EAC1BtiB,EAASuiB,iBAAmBA,EAC5BviB,EAAS4iB,iBAAmBA,EAC5B5iB,EAASwiB,eAAiBA,EAC1BxiB,EAASyiB,kBAAoBA,EAC7BziB,EAAS0iB,iBAAmBA,EAC5B1iB,EAASupB,eAAiBA,EAC1BvpB,EAASwpB,iBAAmBA,EAC5BxpB,EAASypB,iBAAmBA,EAC5BzpB,EAAS4vB,UAAYA,EACrB5vB,EAASC,MAAQA,EAEjBk9B,gBAGJpd,OAAO,gBAAiB","sourcesContent":["\n/* Declaring the Renkan Namespace Rkns and Default values */\n\n(function(root) {\n\n\"use strict\";\n\nif (typeof root.Rkns !== \"object\") {\n    root.Rkns = {};\n}\n\nvar Rkns = root.Rkns;\nvar $ = Rkns.$ = root.jQuery;\nvar _ = Rkns._ = root._;\n\nRkns.pickerColors = [\"#8f1919\", \"#a80000\", \"#d82626\", \"#ff0000\", \"#e87c7c\", \"#ff6565\", \"#f7d3d3\", \"#fecccc\",\n    \"#8f5419\", \"#a85400\", \"#d87f26\", \"#ff7f00\", \"#e8b27c\", \"#ffb265\", \"#f7e5d3\", \"#fee5cc\",\n    \"#8f8f19\", \"#a8a800\", \"#d8d826\", \"#feff00\", \"#e8e87c\", \"#feff65\", \"#f7f7d3\", \"#fefecc\",\n    \"#198f19\", \"#00a800\", \"#26d826\", \"#00ff00\", \"#7ce87c\", \"#65ff65\", \"#d3f7d3\", \"#ccfecc\",\n    \"#198f8f\", \"#00a8a8\", \"#26d8d8\", \"#00feff\", \"#7ce8e8\", \"#65feff\", \"#d3f7f7\", \"#ccfefe\",\n    \"#19198f\", \"#0000a8\", \"#2626d8\", \"#0000ff\", \"#7c7ce8\", \"#6565ff\", \"#d3d3f7\", \"#ccccfe\",\n    \"#8f198f\", \"#a800a8\", \"#d826d8\", \"#ff00fe\", \"#e87ce8\", \"#ff65fe\", \"#f7d3f7\", \"#feccfe\",\n    \"#000000\", \"#242424\", \"#484848\", \"#6d6d6d\", \"#919191\", \"#b6b6b6\", \"#dadada\", \"#ffffff\"];\n\nRkns.__renkans = [];\n\nvar _BaseBin = Rkns._BaseBin = function(_renkan, _opts) {\n    if (typeof _renkan !== \"undefined\") {\n        this.renkan = _renkan;\n        this.renkan.$.find(\".Rk-Bin-Main\").hide();\n        this.$ = Rkns.$('<li>')\n            .addClass(\"Rk-Bin\")\n            .appendTo(_renkan.$.find(\".Rk-Bin-List\"));\n        this.title_icon_$ = Rkns.$('<span>')\n            .addClass(\"Rk-Bin-Title-Icon\")\n            .appendTo(this.$);\n\n        var _this = this;\n\n        Rkns.$('<a>')\n            .attr({\n                href: \"#\",\n                title: _renkan.translate(\"Close bin\")\n            })\n            .addClass(\"Rk-Bin-Close\")\n            .html('&times;')\n            .appendTo(this.$)\n            .click(function() {\n                _this.destroy();\n                if (!_renkan.$.find(\".Rk-Bin-Main:visible\").length) {\n                    _renkan.$.find(\".Rk-Bin-Main:last\").slideDown();\n                }\n                _renkan.resizeBins();\n                return false;\n            });\n        Rkns.$('<a>')\n            .attr({\n                href: \"#\",\n                title: _renkan.translate(\"Refresh bin\")\n            })\n            .addClass(\"Rk-Bin-Refresh\")\n            .appendTo(this.$)\n            .click(function() {\n                _this.refresh();\n                return false;\n            });\n        this.count_$ = Rkns.$('<div>')\n            .addClass(\"Rk-Bin-Count\")\n            .appendTo(this.$);\n        this.title_$ = Rkns.$('<h2>')\n            .addClass(\"Rk-Bin-Title\")\n            .appendTo(this.$);\n        this.main_$ = Rkns.$('<div>')\n            .addClass(\"Rk-Bin-Main\")\n            .appendTo(this.$)\n            .html('<h4 class=\"Rk-Bin-Loading\">' + _renkan.translate(\"Loading, please wait\") + '</h4>');\n        this.title_$.html(_opts.title || '(new bin)');\n        this.renkan.resizeBins();\n\n        if (_opts.auto_refresh) {\n            window.setInterval(function() {\n                _this.refresh();\n            },_opts.auto_refresh);\n        }\n    }\n};\n\n_BaseBin.prototype.destroy = function() {\n    this.$.detach();\n    this.renkan.resizeBins();\n};\n\n/* Point of entry */\n\nvar Renkan = Rkns.Renkan = function(_opts) {\n    var _this = this;\n\n    Rkns.__renkans.push(this);\n\n    this.options = _.defaults(_opts, Rkns.defaults);\n\n    _(this.options.property_files).each(function(f) {\n        Rkns.$.getJSON(f, function(data) {\n            _this.options.properties = _this.options.properties.concat(data);\n        });\n    });\n\n    this.read_only = this.options.read_only || !this.options.editor_mode;\n\n    this.project = new Rkns.Models.Project();\n\n    if (typeof this.options.user_id !== \"undefined\") {\n        this.current_user = this.options.user_id;\n    }\n    this.$ = Rkns.$(\"#\" + this.options.container);\n    this.$\n        .addClass(\"Rk-Main\")\n        .html(this.template(this));\n\n    this.tabs = [];\n    this.search_engines = [];\n\n    this.current_user_list = new Rkns.Models.UsersList();\n\n    this.current_user_list.on(\"add remove\", function() {\n        if (this.renderer) {\n            this.renderer.redrawUsers();\n        }\n    });\n\n    this.colorPicker = (function() {\n        var _tmpl = _.template('<li data-color=\"<%=c%>\" style=\"background: <%=c%>\"></li>');\n        return '<ul class=\"Rk-Edit-ColorPicker\">' + Rkns.pickerColors.map(function(c) { return _tmpl({c:c});}).join(\"\") + '</ul>';\n    })();\n\n    if (this.options.show_editor) {\n        this.renderer = new Rkns.Renderer.Scene(this);\n    }\n\n    if (!this.options.search.length) {\n        this.$.find(\".Rk-Web-Search-Form\").detach();\n    } else {\n        var _tmpl = _.template('<li class=\"<%= className %>\" data-key=\"<%= key %>\"><%= title %></li>'),\n            _select = this.$.find(\".Rk-Search-List\"),\n            _input = this.$.find(\".Rk-Web-Search-Input\"),\n            _form = this.$.find(\".Rk-Web-Search-Form\");\n        _(this.options.search).each(function(_search, _key) {\n            if (Rkns[_search.type] && Rkns[_search.type].Search) {\n                _this.search_engines.push(new Rkns[_search.type].Search(_this, _search));\n            }\n        });\n        _select.html(\n            _(this.search_engines).map(function(_search, _key) {\n                return _tmpl({\n                    key: _key,\n                    title: _search.getSearchTitle(),\n                    className: _search.getBgClass()\n                });\n            }).join(\"\")\n        );\n        _select.find(\"li\").click(function() {\n            var _el = Rkns.$(this);\n            _this.setSearchEngine(_el.attr(\"data-key\"));\n            _form.submit();\n        });\n        _form.submit(function() {\n            if (_input.val()) {\n                var _search = _this.search_engine;\n                _search.search(_input.val());\n            }\n            return false;\n        });\n        this.$.find(\".Rk-Search-Current\").mouseenter(\n            function() { _select.slideDown(); }\n        );\n        this.$.find(\".Rk-Search-Select\").mouseleave(\n            function() { _select.hide(); }\n        );\n        this.setSearchEngine(0);\n    }\n    _(this.options.bins).each(function(_bin) {\n        if (Rkns[_bin.type] && Rkns[_bin.type].Bin) {\n            _this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin));\n        }\n    });\n\n    var elementDropped = false;\n\n    this.$.find(\".Rk-Bins\")\n        .on(\"click\",\".Rk-Bin-Title,.Rk-Bin-Title-Icon\", function() {\n            var _mainDiv = Rkns.$(this).siblings(\".Rk-Bin-Main\");\n            if (_mainDiv.is(\":hidden\")) {\n                _this.$.find(\".Rk-Bin-Main\").slideUp();\n                _mainDiv.slideDown();\n            }\n        });\n\n    if (this.options.show_editor) {\n\n        this.$.find(\".Rk-Bins\").on(\"mouseover\", \".Rk-Bin-Item\", function(_e) {\n            var _t = Rkns.$(this);\n            if (_t && $(_t).attr(\"data-uri\")) {\n                var _models = _this.project.get(\"nodes\").where({\n                    uri: $(_t).attr(\"data-uri\")\n                });\n                _(_models).each(function(_model) {\n                    _this.renderer.highlightModel(_model);\n                });\n            }\n        }).mouseout(function() {\n            _this.renderer.unhighlightAll();\n        }).on(\"mousemove\", \".Rk-Bin-Item\", function(e) {\n            try {\n                this.dragDrop();\n            }\n            catch(err) {}\n        }).on(\"touchstart\", \".Rk-Bin-Item\", function(e) {\n            elementDropped = false;\n        }).on(\"touchmove\", \".Rk-Bin-Item\", function(e) {\n            e.preventDefault();\n            var touch = e.originalEvent.changedTouches[0],\n                off = _this.renderer.canvas_$.offset(),\n                w = _this.renderer.canvas_$.width(),\n                h = _this.renderer.canvas_$.height();\n            if (touch.pageX >= off.left && touch.pageX < (off.left + w) && touch.pageY >= off.top && touch.pageY < (off.top + h)) {\n                if (elementDropped) {\n                    _this.renderer.onMouseMove(touch, true);\n                } else {\n                    elementDropped = true;\n                    var div = document.createElement('div');\n                    div.appendChild(this.cloneNode(true));\n                    _this.renderer.dropData({\"text/html\": div.innerHTML}, touch);\n                    _this.renderer.onMouseDown(touch, true);\n                }\n            }\n        }).on(\"touchend\", \".Rk-Bin-Item\", function(e) {\n            if (elementDropped) {\n                _this.renderer.onMouseUp(e.originalEvent.changedTouches[0], true);\n            }\n            elementDropped = false;\n        }).on(\"dragstart\", \".Rk-Bin-Item\", function(e) {\n            var div = document.createElement('div');\n            div.appendChild(this.cloneNode(true));\n            try {\n                e.originalEvent.dataTransfer.setData(\"text/html\",div.innerHTML);\n            }\n            catch(err) {\n                e.originalEvent.dataTransfer.setData(\"text\",div.innerHTML);\n            }\n        });\n\n    }\n\n    Rkns.$(window).resize(function() {\n        _this.resizeBins();\n    });\n\n    var lastsearch = false, lastval = '';\n\n    this.$.find(\".Rk-Bins-Search-Input\").on(\"change keyup paste input\", function() {\n        var val = Rkns.$(this).val();\n        if (val === lastval) {\n            return;\n        }\n        var search = Rkns.Utils.regexpFromTextOrArray(val.length > 1 ? val: null);\n        if (search.source === lastsearch) {\n            return;\n        }\n        lastsearch = search.source;\n        _(_this.tabs).each(function(tab) {\n            tab.render(search);\n        });\n\n    });\n    this.$.find(\".Rk-Bins-Search-Form\").submit(function() {\n        return false;\n    });\n\n};\n\nRenkan.prototype.template = _.template(\n    '<% if (options.show_bins) { %><div class=\"Rk-Bins\"><div class=\"Rk-Bins-Head\"><h2 class=\"Rk-Bins-Title\"><%- translate(\"Select contents:\")%></h2>' +\n    '<form class=\"Rk-Web-Search-Form Rk-Search-Form\"><input class=\"Rk-Web-Search-Input Rk-Search-Input\" type=\"search\" placeholder=\"<%- translate(\"Search the Web\") %>\" />' +\n    '<div class=\"Rk-Search-Select\"><div class=\"Rk-Search-Current\"></div><ul class=\"Rk-Search-List\"></ul></div>' +\n    '<input type=\"submit\" value=\"\" class=\"Rk-Web-Search-Submit Rk-Search-Submit\" title=\"<%- translate(\"Search the Web\") %>\" /></form>' +\n    '<form class=\"Rk-Bins-Search-Form Rk-Search-Form\"><input class=\"Rk-Bins-Search-Input Rk-Search-Input\" type=\"search\" placeholder=\"<%- translate(\"Search in Bins\") %>\" />' +\n    '<input type=\"submit\" value=\"\" class=\"Rk-Bins-Search-Submit Rk-Search-Submit\" title=\"<%- translate(\"Search in Bins\") %>\" /></form></div>' +\n    '<ul class=\"Rk-Bin-List\"></ul></div><% } %>' +\n    '<% if (options.show_editor) { %><div class=\"Rk-Render Rk-Render-<% if (options.show_bins) { %>Panel<% } else { %>Full<% } %>\"></div><% } %>'\n);\n\nRenkan.prototype.translate = function(_text) {\n    if (Rkns.i18n[this.options.language] && Rkns.i18n[this.options.language][_text]) {\n        return Rkns.i18n[this.options.language][_text];\n    }\n    if (this.options.language.length > 2 && Rkns.i18n[this.options.language.substr(0,2)] && Rkns.i18n[this.options.language.substr(0,2)][_text]) {\n        return Rkns.i18n[this.options.language.substr(0,2)][_text];\n    }\n    return _text;\n};\n\nRenkan.prototype.onStatusChange = function() {\n    this.renderer.onStatusChange();\n};\n\nRenkan.prototype.setSearchEngine = function(_key) {\n    this.search_engine = this.search_engines[_key];\n    this.$.find(\".Rk-Search-Current\").attr(\"class\",\"Rk-Search-Current \" + this.search_engine.getBgClass());\n};\n\nRenkan.prototype.resizeBins = function() {\n    var _d = + this.$.find(\".Rk-Bins-Head\").outerHeight();\n    this.$.find(\".Rk-Bin-Title:visible\").each(function() {\n        _d += Rkns.$(this).outerHeight();\n    });\n    this.$.find(\".Rk-Bin-Main\").css({\n        height: this.$.find(\".Rk-Bins\").height() - _d\n    });\n};\n\n/* Utility functions */\nvar getUUID4 = function() {\n    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n        var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);\n        return v.toString(16);\n    });\n};\n\nRkns.Utils = {\n    getUUID4 : getUUID4,\n    getUID : (function() {\n        function pad(n){\n            return n<10 ? '0'+n : n;\n        }\n        var _d = new Date(),\n            ID_AUTO_INCREMENT = 0,\n            ID_BASE = _d.getUTCFullYear() + '-' +\n              pad(_d.getUTCMonth()+1) + '-' +\n              pad(_d.getUTCDate()) + '-' +\n              getUUID4();\n        return function(_base) {\n            var _n = (++ID_AUTO_INCREMENT).toString(16),\n                _uidbase = (typeof _base === \"undefined\" ? \"\" : _base + \"-\" );\n            while (_n.length < 4) { _n = '0' + _n; }\n            return _uidbase + ID_BASE + '-' + _n;\n        };\n    })(),\n    getFullURL : function(url) {\n\n        if(typeof(url) === 'undefined' || url == null ) {\n            return \"\";\n        }\n        if(/https?:\\/\\//.test(url)) {\n            return url;\n        }\n        var img = new Image();\n        img.src = url;\n        var res = img.src;\n        img.src = null;\n        return res;\n\n    },\n    inherit : function(_baseClass, _callbefore) {\n\n        var _class = function(_arg) {\n            if (typeof _callbefore === \"function\") {\n                _callbefore.apply(this, Array.prototype.slice.call(arguments, 0));\n            }\n            _baseClass.apply(this, Array.prototype.slice.call(arguments, 0));\n            if (typeof this._init === \"function\" && !this._initialized) {\n                this._init.apply(this, Array.prototype.slice.call(arguments, 0));\n                this._initialized = true;\n            }\n        };\n        _(_class.prototype).extend(_baseClass.prototype);\n\n        return _class;\n\n    },\n    regexpFromTextOrArray: (function() {\n        var charsub = [\n                '[aáàâä]',\n                '[cç]',\n                '[eéèêë]',\n                '[iíìîï]',\n                '[oóòôö]',\n                '[uùûü]'\n            ],\n            removeChars = [\n                String.fromCharCode(768), String.fromCharCode(769), String.fromCharCode(770), String.fromCharCode(771), String.fromCharCode(807),\n                \"{\", \"}\", \"(\", \")\", \"[\", \"]\", \"【\", \"】\", \"、\", \"・\", \"‥\", \"。\", \"「\", \"」\", \"『\", \"』\", \"〜\", \":\", \"!\", \"?\", \" \",\n                \",\", \" \", \";\", \"(\", \")\", \".\", \"*\", \"+\", \"\\\\\", \"?\", \"|\", \"{\", \"}\", \"[\", \"]\", \"^\", \"#\", \"/\"\n            ],\n            remsrc = \"[\\\\\" + removeChars.join(\"\\\\\") + \"]\",\n            remrx = new RegExp(remsrc, \"gm\"),\n            charsrx = _(charsub).map(function(c) {\n                return new RegExp(c);\n            });\n\n        function replaceText(_text) {\n            var txt = _text.toLowerCase().replace(remrx,\"\"), src = \"\";\n            function makeReplaceFunc(l) {\n              return function(k,v) {\n                l = l.replace(charsrx[k], v);\n              };\n            }\n            for (var j = 0; j < txt.length; j++) {\n                if (j) {\n                    src += remsrc + \"*\";\n                }\n                var l = txt[j];\n                _(charsub).each(makeReplaceFunc(l));\n                src += l;\n            }\n            return src;\n        }\n\n        function getSource(inp) {\n            switch (typeof inp) {\n                case \"string\":\n                    return replaceText(inp);\n                case \"object\":\n                    var src = '';\n                    _(inp).each(function(v) {\n                        var res = getSource(v);\n                        if (res) {\n                            if (src) {\n                                src += '|';\n                            }\n                            src += res;\n                        }\n                    });\n                    return src;\n            }\n            return '';\n        }\n\n        return function(_textOrArray) {\n            var source = getSource(_textOrArray);\n            if (source) {\n                var testrx = new RegExp( source, \"im\"),\n                    replacerx = new RegExp( '(' + source + ')', \"igm\");\n                return {\n                    isempty: false,\n                    source: source,\n                    test: function(_t) { return testrx.test(_t); },\n                    replace: function(_text, _replace) { return _text.replace(replacerx, _replace); }\n                };\n            } else {\n                return {\n                    isempty: true,\n                    source: '',\n                    test: function() { return true; },\n                    replace: function(_text) { return text; }\n                };\n            }\n        };\n    })(),\n    /* The minimum distance (in pixels) the mouse has to move to consider an element was dragged */\n    _MIN_DRAG_DISTANCE: 2,\n    /* Distance between the inner and outer radius of buttons that appear when hovering on a node */\n    _NODE_BUTTON_WIDTH: 40,\n\n    _EDGE_BUTTON_INNER: 2,\n    _EDGE_BUTTON_OUTER: 40,\n    /* Constants used to know if a specific action is to be performed when clicking on the canvas */\n    _CLICKMODE_ADDNODE: 1,\n    _CLICKMODE_STARTEDGE: 2,\n    _CLICKMODE_ENDEDGE: 3,\n    /* Node size step: Used to calculate the size change when clicking the +/- buttons */\n    _NODE_SIZE_STEP: Math.LN2/4,\n    _MIN_SCALE: 1/20,\n    _MAX_SCALE: 20,\n    _MOUSEMOVE_RATE: 80,\n    _DOUBLETAP_DELAY: 800,\n    /* Maximum distance in pixels (squared, to reduce calculations)\n     * between two taps when double-tapping on a touch terminal */\n    _DOUBLETAP_DISTANCE: 20*20,\n    /* A placeholder so a default colour is displayed when a node has a null value for its user property */\n    _USER_PLACEHOLDER: function(_renkan) {\n        return {\n            color: _renkan.options.default_user_color,\n            title: _renkan.translate(\"(unknown user)\"),\n            get: function(attr) {\n                return this[attr] || false;\n            }\n        };\n    },\n    /* The code for the \"Drag and Add Bookmarklet\", slightly minified and with whitespaces removed, though\n     * it doesn't seem that it's still a requirement in newer browsers (i.e. the ones compatibles with canvas drawing)\n     */\n    _BOOKMARKLET_CODE: function(_renkan) {\n        return \"(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='<p_style=\\\"position:fixed;top:0;right:0;font:bold_18px_sans-serif;color:#fff;background:#909;padding:10px;z-index:100000;\\\">\" +\n        _renkan.translate(\"Drag items from this website, drop them in Renkan\").replace(/ /g,\"_\") +\n        \"</p>'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\\\/\\\\/[^\\\\/]*twitter\\\\.com\\\\//,s:'.tweet',n:'twitter'},{r:/https?:\\\\/\\\\/[^\\\\/]*google\\\\.[^\\\\/]+\\\\//,s:'.g',n:'google'},{r:/https?:\\\\/\\\\/[^\\\\/]*lemonde\\\\.fr\\\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();\";\n    },\n    /* Shortens text to the required length then adds ellipsis */\n    shortenText: function(_text, _maxlength) {\n        return (_text.length > _maxlength ? (_text.substr(0,_maxlength) + '…') : _text);\n    },\n    /* Drawing an edit box with an arrow and positioning the edit box according to the position of the node/edge being edited\n     * Called by Rkns.Renderer.NodeEditor and Rkns.Renderer.EdgeEditor */\n    drawEditBox: function(_options, _coords, _path, _xmargin, _selector) {\n        _selector.css({\n            width: ( _options.tooltip_width - 2* _options.tooltip_padding )\n        });\n        var _height = _selector.outerHeight() + 2* _options.tooltip_padding,\n        _isLeft = (_coords.x < paper.view.center.x ? 1 : -1),\n        _left = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length ),\n        _right = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length + _options.tooltip_width ),\n        _top = _coords.y - _height / 2;\n        if (_top + _height > (paper.view.size.height - _options.tooltip_margin)) {\n            _top = Math.max( paper.view.size.height - _options.tooltip_margin, _coords.y + _options.tooltip_arrow_width / 2 ) - _height;\n        }\n        if (_top < _options.tooltip_margin) {\n            _top = Math.min( _options.tooltip_margin, _coords.y - _options.tooltip_arrow_width / 2 );\n        }\n        var _bottom = _top + _height;\n        /* jshint laxbreak:true */\n        _path.segments[0].point\n          = _path.segments[7].point\n          = _coords.add([_isLeft * _xmargin, 0]);\n        _path.segments[1].point.x\n          = _path.segments[2].point.x\n          = _path.segments[5].point.x\n          = _path.segments[6].point.x\n          = _left;\n        _path.segments[3].point.x\n          = _path.segments[4].point.x\n          = _right;\n        _path.segments[2].point.y\n          = _path.segments[3].point.y\n          = _top;\n        _path.segments[4].point.y\n          = _path.segments[5].point.y\n          = _bottom;\n        _path.segments[1].point.y = _coords.y - _options.tooltip_arrow_width / 2;\n        _path.segments[6].point.y = _coords.y + _options.tooltip_arrow_width / 2;\n        _path.closed = true;\n        _path.fillColor = new paper.GradientColor(new paper.Gradient([_options.tooltip_top_color, _options.tooltip_bottom_color]), [0,_top], [0, _bottom]);\n        _selector.css({\n            left: (_options.tooltip_padding + Math.min(_left, _right)),\n            top: (_options.tooltip_padding + _top)\n        });\n        return _path;\n    }\n};\n})(window);\n\n/* END main.js */\n","(function() {\n    \"use strict\";\n    var root = this;\n\n    var Backbone = root.Backbone;\n\n    var Models = root.Rkns.Models = {};\n\n\n    Models.getUID = function(obj) {\n        var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n            var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);\n            return v.toString(16);\n        });\n        if(typeof obj !== 'undefined') {\n            return obj.type + \"-\" + guid;\n        }\n        else {\n            return guid;\n        }\n    };\n\n\n    var RenkanModel = Backbone.RelationalModel.extend({\n        idAttribute : \"_id\",\n        constructor: function(options) {\n\n            if (typeof options !== \"undefined\") {\n                options._id = options._id || options.id || Models.getUID(this);\n                options.title = options.title || \"\";\n                options.description = options.description || \"\";\n                options.uri = options.uri || \"\";\n\n                if(typeof this.prepare === \"function\") {\n                    options = this.prepare(options);\n                }\n            }\n            Backbone.RelationalModel.prototype.constructor.call(this, options);\n        },\n        validate: function() {\n            if(!this.type) {\n                return \"object has no type\";\n            }\n        },\n        addReference : function(_options, _propName, _list, _id, _default) {\n            var _element = _list.get(_id);\n            if (typeof _element === \"undefined\" && typeof _default !== \"undefined\") {\n                _options[_propName ] = _default;\n            }\n            else {\n                _options[_propName ] = _element;\n            }\n        }\n    });\n\n    // USER\n    var User = Models.User = RenkanModel.extend({\n        type: \"user\",\n        prepare: function(options) {\n            options.color = options.color || \"#666666\";\n            return options;\n        },\n        toJSON: function() {\n            return {\n                _id: this.get(\"_id\"),\n                title: this.get(\"title\"),\n                uri: this.get(\"uri\"),\n                description: this.get(\"description\"),\n                color: this.get(\"color\")\n            };\n        }\n    });\n\n    // NODE\n    var Node = Models.Node = RenkanModel.extend({\n        type: \"node\",\n        relations: [{\n            type: Backbone.HasOne,\n            key: \"created_by\",\n            relatedModel: User\n        }],\n        prepare: function(options) {\n            var project = options.project;\n            this.addReference(options, \"created_by\", project.get(\"users\"), options.created_by, project.current_user);\n            options.description = options.description || \"\";\n            return options;\n        },\n        toJSON: function() {\n            return {\n                _id: this.get(\"_id\"),\n                title: this.get(\"title\"),\n                uri: this.get(\"uri\"),\n                description: this.get(\"description\"),\n                position: this.get(\"position\"),\n                image: this.get(\"image\"),\n                color: this.get(\"color\"),\n                created_by: this.get(\"created_by\") ? this.get(\"created_by\").get(\"_id\") : null,\n                size: this.get(\"size\"),\n                clip_path: this.get(\"clip_path\")\n            };\n        }\n    });\n\n    // EDGE\n    var Edge = Models.Edge = RenkanModel.extend({\n        type: \"edge\",\n        relations: [\n          {\n            type: Backbone.HasOne,\n            key: \"created_by\",\n            relatedModel: User\n          },\n          {\n            type: Backbone.HasOne,\n            key: \"from\",\n            relatedModel: Node\n          },\n          {\n            type: Backbone.HasOne,\n            key: \"to\",\n            relatedModel: Node\n          }\n        ],\n        prepare: function(options) {\n            var project = options.project;\n            this.addReference(options, \"created_by\", project.get(\"users\"), options.created_by, project.current_user);\n            this.addReference(options, \"from\", project.get(\"nodes\"), options.from);\n            this.addReference(options, \"to\", project.get(\"nodes\"), options.to);\n            return options;\n        },\n        toJSON: function() {\n            return {\n                _id: this.get(\"_id\"),\n                title: this.get(\"title\"),\n                uri: this.get(\"uri\"),\n                description: this.get(\"description\"),\n                from: this.get(\"from\") ? this.get(\"from\").get(\"_id\") : null,\n                to: this.get(\"to\") ? this.get(\"to\").get(\"_id\") : null,\n                color: this.get(\"color\"),\n                created_by: this.get(\"created_by\") ? this.get(\"created_by\").get(\"_id\") : null\n            };\n        }\n    });\n\n    // View\n    var View = Models.View = RenkanModel.extend({\n        type: \"view\",\n        relations: [\n            {\n                type: Backbone.HasOne,\n                key: \"created_by\",\n                relatedModel: User\n            }\n        ],\n        prepare: function(options) {\n            var project = options.project;\n            this.addReference(options, \"created_by\", project.get(\"users\"), options.created_by, project.current_user);\n            options.description = options.description || \"\";\n            if(typeof options.offset !== \"undefined\") {\n                var offset = {};\n                if (Array.isArray(options.offset)) {\n                  offset.x = options.offset[0];\n                  offset.y = options.offset.length > 1 ? options.offset[1] : options.offset[0];\n                }\n                else if (options.offset.x != null) {\n                  offset.x = options.offset.x;\n                  offset.y = options.offset.y;\n                }\n                options.offset = offset;\n            }\n            return options;\n        },\n        toJSON: function() {\n            return {\n                _id: this.get(\"_id\"),\n                zoom_level: this.get(\"zoom_level\"),\n                offset: this.get(\"offset\"),\n                title: this.get(\"title\"),\n                description: this.get(\"description\"),\n                created_by: this.get(\"created_by\") ? this.get(\"created_by\").get(\"_id\") : null\n                // Don't need project id\n            };\n        }\n    });\n\n    // PROJECT\n    var Project = Models.Project = RenkanModel.extend({\n        type: \"project\",\n        relations: [\n          {\n            type: Backbone.HasMany,\n            key: \"users\",\n            relatedModel: User,\n            reverseRelation: {\n                key: 'project',\n                includeInJSON: '_id'\n            }\n          },\n          {\n            type: Backbone.HasMany,\n            key: \"nodes\",\n            relatedModel: Node,\n            reverseRelation: {\n                key: 'project',\n                includeInJSON: '_id'\n            }\n          },\n          {\n            type: Backbone.HasMany,\n            key: \"edges\",\n            relatedModel: Edge,\n            reverseRelation: {\n                key: 'project',\n                includeInJSON: '_id'\n            }\n          },\n          {\n            type: Backbone.HasMany,\n            key: \"views\",\n            relatedModel: View,\n            reverseRelation: {\n                key: 'project',\n                includeInJSON: '_id'\n            }\n          }\n        ],\n        addUser: function(_props, _options) {\n            _props.project = this;\n            var _user = User.findOrCreate(_props);\n            this.get(\"users\").push(_user, _options);\n            return _user;\n        },\n        addNode: function(_props, _options) {\n            _props.project = this;\n            var _node = Node.findOrCreate(_props);\n            this.get(\"nodes\").push(_node, _options);\n            return _node;\n        },\n        addEdge: function(_props, _options) {\n            _props.project = this;\n            var _edge = Edge.findOrCreate(_props);\n            this.get(\"edges\").push(_edge, _options);\n            return _edge;\n        },\n        addView: function(_props, _options) {\n            _props.project = this;\n            // TODO: check if need to replace with create only\n            var _view = View.findOrCreate(_props);\n            // TODO: Should we remember only one view?\n            this.get(\"views\").push(_view, _options);\n            return _view;\n        },\n        removeNode: function(_model) {\n            this.get(\"nodes\").remove(_model);\n        },\n        removeEdge: function(_model) {\n            this.get(\"edges\").remove(_model);\n        },\n        validate: function(options) {\n            var _project = this;\n            _([].concat(options.users, options.nodes, options.edges, options.views)).each(function(_item) {\n                if(_item) {\n                    _item.project = _project;\n                }\n            });\n        },\n        // Add event handler to remove edges when a node is removed\n        initialize: function() {\n            var _this = this;\n            this.on(\"remove:nodes\", function(_node) {\n                _this.get(\"edges\").remove(\n                    _this.get(\"edges\").filter(function(_edge) {\n                        return _edge.get(\"from\") === _node || _edge.get(\"to\") === _node;\n                    })\n                );\n            });\n        }\n    });\n\n    var RosterUser = Models.RosterUser = Backbone.Model.extend({\n        type: \"roster_user\",\n        idAttribute : \"_id\",\n\n        constructor: function(options) {\n\n            if (typeof options !== \"undefined\") {\n                options._id = options._id || options.id || Models.getUID(this);\n                options.title = options.title || \"(untitled \" + this.type + \")\";\n                options.description = options.description || \"\";\n                options.uri = options.uri || \"\";\n                options.project = options.project || null;\n                options.site_id = options.site_id || 0;\n\n                if(typeof this.prepare === \"function\") {\n                    options = this.prepare(options);\n                }\n            }\n            Backbone.Model.prototype.constructor.call(this, options);\n        },\n\n        validate: function() {\n            if(!this.type) {\n                return \"object has no type\";\n            }\n        },\n\n        prepare: function(options) {\n            options.color = options.color || \"#666666\";\n            return options;\n        },\n\n        toJSON: function() {\n            return {\n                _id: this.get(\"_id\"),\n                title: this.get(\"title\"),\n                uri: this.get(\"uri\"),\n                description: this.get(\"description\"),\n                color: this.get(\"color\"),\n                project: (this.get(\"project\") != null)?this.get(\"project\").get(\"id\"):null,\n                site_id: this.get(\"site_id\")\n            };\n        }\n    });\n\n    var UsersList = Models.UsersList = Backbone.Collection.extend({\n        model: RosterUser\n    });\n\n\n}).call(window);\n","Rkns.defaults = {\n\n    language: (navigator.language || navigator.userLanguage || \"en\"),\n        /* GUI Language */\n    container: \"renkan\",\n        /* GUI Container DOM element ID */\n    search: [],\n        /* List of Search Engines */\n    bins: [],\n           /* List of Bins */\n    static_url: \"\",\n        /* URL for static resources */\n    show_bins: true,\n        /* Show bins in left column */\n    properties: [],\n        /* Semantic properties for edges */\n    show_editor: true,\n        /* Show the graph editor... Setting this to \"false\" only shows the bins part ! */\n    read_only: false,\n        /* Allows editing of renkan without changing the rest of the GUI. Can be switched on/off on the fly to block/enable editing */\n    editor_mode: true,\n        /* Switch for Publish/Edit GUI. If editor_mode is false, read_only will be true.  */\n    snapshot_mode: false,\n        /* In snapshot mode, clicking on the floppy will save a snapshot. Otherwise, it will show the connection status */\n    show_top_bar: true,\n        /* Show the top bar, (title, buttons, users) */\n    default_user_color: \"#303030\",\n    size_bug_fix: true,\n        /* Resize the canvas after load (fixes a bug on iPad and FF Mac) */\n    force_resize: false,\n    allow_double_click: true,\n        /* Allows Double Click to create a node on an empty background */\n    zoom_on_scroll: true,\n        /* Allows to use the scrollwheel to zoom */\n    element_delete_delay: 0,\n        /* Delay between clicking on the bin on an element and really deleting it\n           Set to 0 for delete confirm */\n    autoscale_padding: 50,\n    default_view: false,\n\t/* Allows to load default view (zoom+offset) at start on read_only mode, instead of autoScale. default_view has to be an integer 0,1,2... */\n\n    /* TOP BAR BUTTONS */\n    show_search_field: true,\n    show_user_list: true,\n    user_name_editable: true,\n    user_color_editable: true,\n    show_save_button: true,\n    show_export_button: true,\n    show_open_button: false,\n    show_addnode_button: true,\n    show_addedge_button: true,\n    show_bookmarklet: true,\n    show_fullscreen_button: true,\n    home_button_url: false,\n    home_button_title: \"Home\",\n\n    /* MINI-MAP OPTIONS */\n\n    show_minimap: true,\n        /* Show a small map at the bottom right */\n    minimap_width: 160,\n    minimap_height: 120,\n    minimap_padding: 20,\n    minimap_background_color: \"#ffffff\",\n    minimap_border_color: \"#cccccc\",\n    minimap_highlight_color: \"#ffff00\",\n    minimap_highlight_weight: 5,\n\n    /* EDGE/NODE COMMON OPTIONS */\n\n    buttons_background: \"#202020\",\n    buttons_label_color: \"#c000c0\",\n    buttons_label_font_size: 9,\n\n    /* NODE DISPLAY OPTIONS */\n\n    show_node_circles: true,\n        /* Show circles for nodes */\n    clip_node_images: true,\n        /* Constraint node images to circles */\n    node_images_fill_mode: false,\n        /* Set to false for \"letterboxing\" (height/width of node adapted to show full image)\n           Set to true for \"crop\" (adapted to fill circle) */\n    node_size_base: 25,\n    node_stroke_width: 2,\n    selected_node_stroke_width: 4,\n    node_fill_color: \"#ffffff\",\n    highlighted_node_fill_color: \"#ffff00\",\n    node_label_distance: 5,\n        /* Vertical distance between node and label */\n    node_label_max_length: 60,\n        /* Maximum displayed text length */\n    label_untitled_nodes: \"(untitled)\",\n        /* Label to display on untitled nodes */\n\n    /* EDGE DISPLAY OPTIONS */\n\n    edge_stroke_width: 2,\n    selected_edge_stroke_width: 4,\n    edge_label_distance: 0,\n    edge_label_max_length: 20,\n    edge_arrow_length: 18,\n    edge_arrow_width: 12,\n    edge_gap_in_bundles: 12,\n    label_untitled_edges: \"\",\n\n    /* CONTEXTUAL DISPLAY (TOOLTIP OR EDITOR) OPTIONS */\n\n    tooltip_width: 275,\n    tooltip_padding: 10,\n    tooltip_margin: 15,\n    tooltip_arrow_length : 20,\n    tooltip_arrow_width : 40,\n    tooltip_top_color: \"#f0f0f0\",\n    tooltip_bottom_color: \"#d0d0d0\",\n    tooltip_border_color: \"#808080\",\n    tooltip_border_width: 1,\n\n    /* NODE EDITOR OPTIONS */\n\n    show_node_editor_uri: true,\n    show_node_editor_description: true,\n    show_node_editor_size: true,\n    show_node_editor_color: true,\n    show_node_editor_image: true,\n    show_node_editor_creator: true,\n    uploaded_image_max_kb: 500,\n\n    /* NODE TOOLTIP OPTIONS */\n\n    show_node_tooltip_uri: true,\n    show_node_tooltip_description: true,\n    show_node_tooltip_color: true,\n    show_node_tooltip_image: true,\n    show_node_tooltip_creator: true,\n\n    /* EDGE EDITOR OPTIONS */\n\n    show_edge_editor_uri: true,\n    show_edge_editor_color: true,\n    show_edge_editor_direction: true,\n    show_edge_editor_nodes: true,\n    show_edge_editor_creator: true,\n\n    /* EDGE TOOLTIP OPTIONS */\n\n    show_edge_tooltip_uri: true,\n    show_edge_tooltip_color: true,\n    show_edge_tooltip_nodes: true,\n    show_edge_tooltip_creator: true\n\n    /* */\n\n};\n","Rkns.i18n = {\n    fr: {\n        \"Edit Node\": \"Édition d’un nœud\",\n        \"Edit Edge\": \"Édition d’un lien\",\n        \"Title:\": \"Titre :\",\n        \"URI:\": \"URI :\",\n        \"Description:\": \"Description :\",\n        \"From:\": \"De :\",\n        \"To:\": \"Vers :\",\n        \"Image\": \"Image\",\n        \"Image URL:\": \"URL d'Image\",\n        \"Choose Image File:\": \"Choisir un fichier image\",\n        \"Full Screen\": \"Mode plein écran\",\n        \"Add Node\": \"Ajouter un nœud\",\n        \"Add Edge\": \"Ajouter un lien\",\n        \"Save Project\": \"Enregistrer le projet\",\n        \"Open Project\": \"Ouvrir un projet\",\n        \"Auto-save enabled\": \"Enregistrement automatique activé\",\n        \"Connection lost\": \"Connexion perdue\",\n        \"Created by:\": \"Créé par :\",\n        \"Zoom In\": \"Agrandir l’échelle\",\n        \"Zoom Out\": \"Rapetisser l’échelle\",\n        \"Edit\": \"Éditer\",\n        \"Remove\": \"Supprimer\",\n        \"Cancel deletion\": \"Annuler la suppression\",\n        \"Link to another node\": \"Créer un lien\",\n        \"Enlarge\": \"Agrandir\",\n        \"Shrink\": \"Rétrécir\",\n        \"Click on the background canvas to add a node\": \"Cliquer sur le fond du graphe pour rajouter un nœud\",\n        \"Click on a first node to start the edge\": \"Cliquer sur un premier nœud pour commencer le lien\",\n        \"Click on a second node to complete the edge\": \"Cliquer sur un second nœud pour terminer le lien\",\n        \"Wikipedia\": \"Wikipédia\",\n        \"Wikipedia in \": \"Wikipédia en \",\n        \"French\": \"Français\",\n        \"English\": \"Anglais\",\n        \"Japanese\": \"Japonais\",\n        \"Untitled project\": \"Projet sans titre\",\n        \"Lignes de Temps\": \"Lignes de Temps\",\n        \"Loading, please wait\": \"Chargement en cours, merci de patienter\",\n        \"Edge color:\": \"Couleur :\",\n        \"Node color:\": \"Couleur :\",\n        \"Choose color\": \"Choisir une couleur\",\n        \"Change edge direction\": \"Changer le sens du lien\",\n        \"Do you really wish to remove node \": \"Voulez-vous réellement supprimer le nœud \",\n        \"Do you really wish to remove edge \": \"Voulez-vous réellement supprimer le lien \",\n        \"This file is not an image\": \"Ce fichier n'est pas une image\",\n        \"Image size must be under \": \"L'image doit peser moins de \",\n        \"Size:\": \"Taille :\",\n        \"KB\": \"ko\",\n        \"Choose from vocabulary:\": \"Choisir dans un vocabulaire :\",\n        \"SKOS Documentation properties\": \"SKOS: Propriétés documentaires\",\n        \"has note\": \"a pour note\",\n        \"has example\": \"a pour exemple\",\n        \"has definition\": \"a pour définition\",\n        \"SKOS Semantic relations\": \"SKOS: Relations sémantiques\",\n        \"has broader\": \"a pour concept plus large\",\n        \"has narrower\": \"a pour concept plus étroit\",\n        \"has related\": \"a pour concept apparenté\",\n        \"Dublin Core Metadata\": \"Métadonnées Dublin Core\",\n        \"has contributor\": \"a pour contributeur\",\n        \"covers\": \"couvre\",\n        \"created by\": \"créé par\",\n        \"has date\": \"a pour date\",\n        \"published by\": \"édité par\",\n        \"has source\": \"a pour source\",\n        \"has subject\": \"a pour sujet\",\n        \"Dragged resource\": \"Ressource glisée-déposée\",\n        \"Search the Web\": \"Rechercher en ligne\",\n        \"Search in Bins\": \"Rechercher dans les chutiers\",\n        \"Close bin\": \"Fermer le chutier\",\n        \"Refresh bin\": \"Rafraîchir le chutier\",\n        \"(untitled)\": \"(sans titre)\",\n        \"Select contents:\": \"Sélectionner des contenus :\",\n        \"Drag items from this website, drop them in Renkan\": \"Glissez des éléments de ce site web vers Renkan\",\n        \"Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.\": \"Glissez ce bouton vers votre barre de favoris. Ensuite, depuis un site tiers, cliquez dessus pour activer 'Drag-to-Add' puis glissez des éléments de ce site vers Renkan\"\n    }\n};\n","/* Saves the Full JSON at each modification */\n\nRkns.jsonIO = function(_renkan, _opts) {\n    var _proj = _renkan.project;\n    if (typeof _opts.http_method === \"undefined\") {\n        _opts.http_method = 'PUT';\n    }\n    var _load = function() {\n        _renkan.renderer.redrawActive = false;\n        Rkns.$.getJSON(_opts.url, function(_data) {\n            _proj.set(_data, {validate: true});\n            _renkan.renderer.redrawActive = true;\n            _renkan.renderer.autoScale();\n        });\n    };\n    var _save = function() {\n        var _data = _proj.toJSON();\n        if (!_renkan.read_only) {\n            Rkns.$.ajax({\n                type: _opts.http_method,\n                url: _opts.url,\n                contentType: \"application/json\",\n                data: JSON.stringify(_data),\n                success: function(data, textStatus, jqXHR) {\n                }\n            });\n        }\n\n    };\n    var _thrSave = Rkns._.throttle(\n        function() {\n            setTimeout(_save, 100);\n        }, 1000);\n    _proj.on(\"add:nodes add:edges add:users add:views\", function(_model) {\n        _model.on(\"change remove\", function(_model) {\n            _thrSave();\n        });\n        _thrSave();\n    });\n    _proj.on(\"change\", function() {\n        _thrSave();\n    });\n\n    _load();\n};\n","(function(Rkns) {\n\"use strict\";\n\nvar _ = Rkns._;\n\nvar Ldt = Rkns.Ldt = {};\n\nvar Bin = Ldt.Bin = function(_renkan, _opts) {\n    if (_opts.ldt_type) {\n        var Resclass = Ldt[_opts.ldt_type+\"Bin\"];\n        if (Resclass) {\n            return new Resclass(_renkan, _opts);\n        }\n    }\n    console.error(\"No such LDT Bin Type\");\n};\n\nvar ProjectBin = Ldt.ProjectBin = Rkns.Utils.inherit(Rkns._BaseBin);\n\nProjectBin.prototype.tagTemplate = _.template(\n    '<li class=\"Rk-Bin-Item\" draggable=\"true\" data-image=\"<%- Rkns.Utils.getFullURL(static_url+\\'img/ldt-tag.png\\') %>\" data-uri=\"<%=ldt_platform%>ldtplatform/ldt/front/search/?search=<%=encodedtitle%>&field=all\" data-title=\"<%-title%>\" data-description=\"Tag \\'<%-title%>\\'\">' +\n    '<img class=\"Rk-Ldt-Tag-Icon\" src=\"<%-static_url%>img/ldt-tag.png\" /><h4><%=htitle%></h4><div class=\"Rk-Clear\"></div></li>'\n);\n\nProjectBin.prototype.annotationTemplate = _.template(\n    '<li class=\"Rk-Bin-Item\" draggable=\"true\" data-image=\"<%- Rkns.Utils.getFullURL(image) %>\" data-uri=\"<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>\" data-title=\"<%-title%>\" data-description=\"<%-description%>\">' +\n    '<img class=\"Rk-Ldt-Annotation-Icon\" src=\"<%=image%>\"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class=\"Rk-Clear\"></div></li>'\n);\n\nProjectBin.prototype._init = function(_renkan, _opts) {\n    this.renkan = _renkan;\n    this.proj_id = _opts.project_id;\n    this.ldt_platform = _opts.ldt_platform || \"http://ldt.iri.centrepompidou.fr/\";\n    this.title_$.html(_opts.title);\n    this.title_icon_$.addClass('Rk-Ldt-Title-Icon');\n    this.refresh();\n};\n\nProjectBin.prototype.render = function(searchbase) {\n    var search = searchbase || Rkns.Utils.regexpFromTextOrArray();\n    function highlight(_text) {\n        var _e = _(_text).escape();\n        return search.isempty ? _e : search.replace(_e, \"<span class='searchmatch'>$1</span>\");\n    }\n    function convertTC(_ms) {\n        function pad(_n) {\n            var _res = _n.toString();\n            while (_res.length < 2) {\n                _res = '0' + _res;\n            }\n            return _res;\n        }\n        var _totalSeconds = Math.abs(Math.floor(_ms/1000)),\n            _hours = Math.floor(_totalSeconds / 3600),\n            _minutes = (Math.floor(_totalSeconds / 60) % 60),\n            _seconds = _totalSeconds % 60,\n            _res = '';\n        if (_hours) {\n            _res += pad(_hours) + ':';\n        }\n        _res += pad(_minutes) + ':' + pad(_seconds);\n        return _res;\n    }\n\n    var _html = '<li><h3>Tags</h3></li>',\n        _projtitle = this.data.meta[\"dc:title\"],\n        _this = this,\n        count = 0;\n    _this.title_$.text('LDT Project: \"' + _projtitle + '\"');\n    _(_this.data.tags).map(function(_tag) {\n        var _title = _tag.meta[\"dc:title\"];\n        if (!search.isempty && !search.test(_title)) {\n            return;\n        }\n        count++;\n        _html += _this.tagTemplate({\n            ldt_platform: _this.ldt_platform,\n            title: _title,\n            htitle: highlight(_title),\n            encodedtitle : encodeURIComponent(_title),\n            static_url: _this.renkan.options.static_url\n        });\n    });\n    _html += '<li><h3>Annotations</h3></li>';\n    _(_this.data.annotations).map(function(_annotation) {\n        var _description = _annotation.content.description,\n            _title = _annotation.content.title.replace(_description,\"\");\n        if (!search.isempty && !search.test(_title) && !search.test(_description)) {\n            return;\n        }\n        count++;\n        var _duration = _annotation.end - _annotation.begin,\n            _img = (\n                (_annotation.content && _annotation.content.img && _annotation.content.img.src) ?\n                  _annotation.content.img.src :\n                  ( _duration ? _this.renkan.options.static_url+\"img/ldt-segment.png\" : _this.renkan.options.static_url+\"img/ldt-point.png\" )\n            );\n        _html += _this.annotationTemplate({\n            ldt_platform: _this.ldt_platform,\n            title: _title,\n            htitle: highlight(_title),\n            description: _description,\n            hdescription: highlight(_description),\n            start: convertTC(_annotation.begin),\n            end: convertTC(_annotation.end),\n            duration: convertTC(_duration),\n            mediaid: _annotation.media,\n            annotationid: _annotation.id,\n            image: _img,\n            static_url: _this.renkan.options.static_url\n        });\n    });\n\n    this.main_$.html(_html);\n    if (!search.isempty && count) {\n        this.count_$.text(count).show();\n    } else {\n        this.count_$.hide();\n    }\n    if (!search.isempty && !count) {\n        this.$.hide();\n    } else {\n        this.$.show();\n    }\n    this.renkan.resizeBins();\n};\n\nProjectBin.prototype.refresh = function() {\n    var _this = this;\n    Rkns.$.ajax({\n        url: this.ldt_platform + 'ldtplatform/ldt/cljson/id/' + this.proj_id,\n        dataType: \"jsonp\",\n        success: function(_data) {\n            _this.data = _data;\n            _this.render();\n        }\n    });\n};\n\nvar Search = Ldt.Search = function(_renkan, _opts) {\n    this.renkan = _renkan;\n    this.lang = _opts.lang || \"en\";\n};\n\nSearch.prototype.getBgClass = function() {\n    return \"Rk-Ldt-Icon\";\n};\n\nSearch.prototype.getSearchTitle = function() {\n    return this.renkan.translate(\"Lignes de Temps\");\n};\n\nSearch.prototype.search = function(_q) {\n    this.renkan.tabs.push(\n        new ResultsBin(this.renkan, {\n            search: _q\n        })\n    );\n};\n\nvar ResultsBin = Ldt.ResultsBin = Rkns.Utils.inherit(Rkns._BaseBin);\n\nResultsBin.prototype.segmentTemplate = _.template(\n    '<li class=\"Rk-Bin-Item\" draggable=\"true\" data-image=\"<%- Rkns.Utils.getFullURL(image) %>\" data-uri=\"<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>\" data-title=\"<%-title%>\" data-description=\"<%-description%>\">' +\n    '<img class=\"Rk-Ldt-Annotation-Icon\" src=\"<%=image%>\"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class=\"Rk-Clear\"></div></li>'\n);\n\nResultsBin.prototype._init = function(_renkan, _opts) {\n    this.renkan = _renkan;\n    this.ldt_platform = _opts.ldt_platform || \"http://ldt.iri.centrepompidou.fr/\";\n    this.max_results = _opts.max_results || 50;\n    this.search = _opts.search;\n    this.title_$.html('Lignes de Temps: \"' + _opts.search + '\"');\n    this.title_icon_$.addClass('Rk-Ldt-Title-Icon');\n    this.refresh();\n};\n\nResultsBin.prototype.render = function(searchbase) {\n    if (!this.data) {\n        return;\n    }\n    var search = searchbase || Rkns.Utils.regexpFromTextOrArray();\n    var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);\n    function highlight(_text) {\n        return highlightrx.replace(_(_text).escape(), \"<span class='searchmatch'>$1</span>\");\n    }\n    function convertTC(_ms) {\n        function pad(_n) {\n            var _res = _n.toString();\n            while (_res.length < 2) {\n                _res = '0' + _res;\n            }\n            return _res;\n        }\n        var _totalSeconds = Math.abs(Math.floor(_ms/1000)),\n            _hours = Math.floor(_totalSeconds / 3600),\n            _minutes = (Math.floor(_totalSeconds / 60) % 60),\n            _seconds = _totalSeconds % 60,\n            _res = '';\n        if (_hours) {\n            _res += pad(_hours) + ':';\n        }\n        _res += pad(_minutes) + ':' + pad(_seconds);\n        return _res;\n    }\n\n    var _html = '',\n        _this = this,\n        count = 0;\n    _(this.data.objects).each(function(_segment) {\n        var _description = _segment.abstract,\n            _title = _segment.title;\n        if (!search.isempty && !search.test(_title) && !search.test(_description)) {\n            return;\n        }\n        count++;\n        var _duration = _segment.duration,\n            _begin = _segment.start_ts,\n            _end = + _segment.duration + _begin,\n            _img = (\n                _duration ?\n                  _this.renkan.options.static_url + \"img/ldt-segment.png\" :\n                  _this.renkan.options.static_url + \"img/ldt-point.png\"\n            );\n        _html += _this.segmentTemplate({\n            ldt_platform: _this.ldt_platform,\n            title: _title,\n            htitle: highlight(_title),\n            description: _description,\n            hdescription: highlight(_description),\n            start: convertTC(_begin),\n            end: convertTC(_end),\n            duration: convertTC(_duration),\n            mediaid: _segment.iri_id,\n            //projectid: _segment.project_id,\n            //cuttingid: _segment.cutting_id,\n            annotationid: _segment.element_id,\n            image: _img\n        });\n    });\n\n    this.main_$.html(_html);\n    if (!search.isempty && count) {\n        this.count_$.text(count).show();\n    } else {\n        this.count_$.hide();\n    }\n    if (!search.isempty && !count) {\n        this.$.hide();\n    } else {\n        this.$.show();\n    }\n    this.renkan.resizeBins();\n};\n\nResultsBin.prototype.refresh = function() {\n    var _this = this;\n    Rkns.$.ajax({\n        url: this.ldt_platform + 'ldtplatform/api/ldt/1.0/segments/search/',\n        data: {\n            format: \"jsonp\",\n            q: this.search,\n            limit: this.max_results\n        },\n        dataType: \"jsonp\",\n        success: function(_data) {\n            _this.data = _data;\n            _this.render();\n        }\n    });\n};\n\n})(window.Rkns);\n","Rkns.ResourceList = {};\n\nRkns.ResourceList.Bin = Rkns.Utils.inherit(Rkns._BaseBin);\n\nRkns.ResourceList.Bin.prototype.resultTemplate = Rkns._.template(\n    '<li class=\"Rk-Bin-Item Rk-ResourceList-Item\" draggable=\"true\" data-uri=\"<%-url%>\" ' +\n    'data-title=\"<%-title%>\" data-description=\"<%-description%>\" ' +\n    '<% if (image) { %>data-image=\"<%- Rkns.Utils.getFullURL(image) %>\"<% } else { %>data-image=\"\"<% } %> >' +\n    '<% if (image) { %><img class=\"Rk-ResourceList-Image\" src=\"<%-image%>\"/><% } %><h4 class=\"Rk-ResourceList-Title\">' +\n    '<% if (url) { %><a href=\"<%-url%>\" target=\"_blank\"><% } %><%=htitle%><% if (url) { %></a><% } %></h4>' +\n    '<% if (description) { %><p class=\"Rk-ResourceList-Description\"><%=hdescription%></p><% } %><% if (image) { %><div style=\"clear: both;\"></div><% } %></li>'\n);\n\nRkns.ResourceList.Bin.prototype._init = function(_renkan, _opts) {\n    this.renkan = _renkan;\n    this.title_$.html(_opts.title);\n    if (_opts.list) {\n        this.data = _opts.list;\n    }\n    this.refresh();\n};\n\nRkns.ResourceList.Bin.prototype.render = function(searchbase) {\n    var search = searchbase || Rkns.Utils.regexpFromTextOrArray();\n    function highlight(_text) {\n        var _e = _(_text).escape();\n        return search.isempty ? _e : search.replace(_e, \"<span class='searchmatch'>$1</span>\");\n    }\n    var _html = \"\",\n        _this = this,\n        count = 0;\n    Rkns._(this.data).each(function(_item) {\n        var _element;\n        if (typeof _item === \"string\") {\n            if (/^(https?:\\/\\/|www)/.test(_item)) {\n                _element = { url: _item };\n            } else {\n                _element = { title: _item.replace(/[:,]?\\s?(https?:\\/\\/|www)[\\d\\w\\/.&?=#%-_]+\\s?/,'').trim() };\n                var _match = _item.match(/(https?:\\/\\/|www)[\\d\\w\\/.&?=#%-_]+/);\n                if (_match) {\n                    _element.url = _match[0];\n                }\n                if (_element.title.length > 80) {\n                    _element.description = _element.title;\n                    _element.title = _element.title.replace(/^(.{30,60})\\s.+$/,'$1…');\n                }\n            }\n        } else {\n            _element = _item;\n        }\n        var title = _element.title || (_element.url || \"\").replace(/^https?:\\/\\/(www\\.)?/,'').replace(/^(.{40}).+$/,'$1…'),\n            url = _element.url || \"\",\n            description = _element.description || \"\",\n            image = _element.image || \"\";\n        if (url && !/^https?:\\/\\//.test(url)) {\n            url = 'http://' + url;\n        }\n        if (!search.isempty && !search.test(title) && !search.test(description)) {\n            return;\n        }\n        count++;\n        _html += _this.resultTemplate({\n            url: url,\n            title: title,\n            htitle: highlight(title),\n            image: image,\n            description: description,\n            hdescription: highlight(description),\n            static_url: _this.renkan.options.static_url\n        });\n    });\n    _this.main_$.html(_html);\n    if (!search.isempty && count) {\n        this.count_$.text(count).show();\n    } else {\n        this.count_$.hide();\n    }\n    if (!search.isempty && !count) {\n        this.$.hide();\n    } else {\n        this.$.show();\n    }\n    this.renkan.resizeBins();\n};\n\nRkns.ResourceList.Bin.prototype.refresh = function() {\n    if (this.data) {\n        this.render();\n    }\n};\n","Rkns.Wikipedia = {\n};\n\nRkns.Wikipedia.Search = function(_renkan, _opts) {\n    this.renkan = _renkan;\n    this.lang = _opts.lang || \"en\";\n};\n\nRkns.Wikipedia.Search.prototype.getBgClass = function() {\n    return \"Rk-Wikipedia-Search-Icon Rk-Wikipedia-Lang-\" + this.lang;\n};\n\nRkns.Wikipedia.Search.prototype.getSearchTitle = function() {\n    var langs = {\n        \"fr\": \"French\",\n        \"en\": \"English\",\n        \"ja\": \"Japanese\"\n    };\n    if (langs[this.lang]) {\n        return this.renkan.translate(\"Wikipedia in \") + this.renkan.translate(langs[this.lang]);\n    } else {\n        return this.renkan.translate(\"Wikipedia\") + \" [\" + this.lang + \"]\";\n    }\n};\n\nRkns.Wikipedia.Search.prototype.search = function(_q) {\n    this.renkan.tabs.push(\n        new Rkns.Wikipedia.Bin(this.renkan, {\n            lang: this.lang,\n            search: _q\n        })\n    );\n};\n\nRkns.Wikipedia.Bin = Rkns.Utils.inherit(Rkns._BaseBin);\n\nRkns.Wikipedia.Bin.prototype.resultTemplate = Rkns._.template(\n    '<li class=\"Rk-Wikipedia-Result Rk-Bin-Item\" draggable=\"true\" data-uri=\"<%-url%>\" ' +\n    'data-title=\"Wikipedia: <%-title%>\" data-description=\"<%-description%>\" data-image=\"<%- Rkns.Utils.getFullURL( static_url + \\'img/wikipedia.png\\' ) %>\">' +\n    '<img class=\"Rk-Wikipedia-Icon\" src=\"<%-static_url%>img/wikipedia.png\"></div><h4 class=\"Rk-Wikipedia-Title\"><a href=\"<%-url%>\" target=\"_blank\"><%=htitle%></a></h4>' +\n    '<p class=\"Rk-Wikipedia-Snippet\"><%=hdescription%></p></li>'\n);\n\nRkns.Wikipedia.Bin.prototype._init = function(_renkan, _opts) {\n    this.renkan = _renkan;\n    this.search = _opts.search;\n    this.lang = _opts.lang || \"en\";\n    this.title_icon_$.addClass('Rk-Wikipedia-Title-Icon Rk-Wikipedia-Lang-' + this.lang);\n    this.title_$.html(this.search).addClass(\"Rk-Wikipedia-Title\");\n    this.refresh();\n};\n\nRkns.Wikipedia.Bin.prototype.render = function(searchbase) {\n    var search = searchbase || Rkns.Utils.regexpFromTextOrArray();\n    var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);\n    function highlight(_text) {\n        return highlightrx.replace(_(_text).escape(), \"<span class='searchmatch'>$1</span>\");\n    }\n    var _html = \"\",\n        _this = this,\n        count = 0;\n    Rkns._(this.data.query.search).each(function(_result) {\n        var title = _result.title,\n            url = \"http://\" + _this.lang + \".wikipedia.org/wiki/\" + encodeURI(title.replace(/ /g,\"_\")),\n            description = Rkns.$('<div>').html(_result.snippet).text();\n        if (!search.isempty && !search.test(title) && !search.test(description)) {\n            return;\n        }\n        count++;\n        _html += _this.resultTemplate({\n            url: url,\n            title: title,\n            htitle: highlight(title),\n            description: description,\n            hdescription: highlight(description),\n            static_url: _this.renkan.options.static_url\n        });\n    });\n    _this.main_$.html(_html);\n    if (!search.isempty && count) {\n        this.count_$.text(count).show();\n    } else {\n        this.count_$.hide();\n    }\n    if (!search.isempty && !count) {\n        this.$.hide();\n    } else {\n        this.$.show();\n    }\n    this.renkan.resizeBins();\n};\n\nRkns.Wikipedia.Bin.prototype.refresh = function() {\n    var _this = this;\n    Rkns.$.ajax({\n        url: \"http://\" + _this.lang + \".wikipedia.org/w/api.php?action=query&list=search&srsearch=\" + encodeURIComponent(this.search) + \"&format=json\",\n        dataType: \"jsonp\",\n        success: function(_data) {\n            _this.data = _data;\n            _this.render();\n        }\n    });\n};\n","\ndefine('renderer/baserepresentation',['jquery', 'underscore'], function ($, _) {\n    \n\n    /* Rkns.Renderer._BaseRepresentation Class */\n\n    /* In Renkan, a \"Representation\" is a sort of ViewModel (in the MVVM paradigm) and bridges the gap between\n     * models (written with Backbone.js) and the view (written with Paper.js)\n     * Renkan's representations all inherit from Rkns.Renderer._BaseRepresentation '*/\n\n    var _BaseRepresentation = function(_renderer, _model) {\n        if (typeof _renderer !== \"undefined\") {\n            this.renderer = _renderer;\n            this.renkan = _renderer.renkan;\n            this.project = _renderer.renkan.project;\n            this.options = _renderer.renkan.options;\n            this.model = _model;\n            if (this.model) {\n                var _this = this;\n                this._changeBinding = function() {\n                    _this.redraw();\n                };\n                this._removeBinding = function() {\n                    _renderer.removeRepresentation(_this);\n                    _(function() {\n                        _renderer.redraw();\n                    }).defer();\n                };\n                this._selectBinding = function() {\n                    _this.select();\n                };\n                this._unselectBinding = function() {\n                    _this.unselect();\n                };\n                this.model.on(\"change\", this._changeBinding );\n                this.model.on(\"remove\", this._removeBinding );\n                this.model.on(\"select\", this._selectBinding );\n                this.model.on(\"unselect\", this._unselectBinding );\n            }\n        }\n    };\n\n    /* Rkns.Renderer._BaseRepresentation Methods */\n\n    _(_BaseRepresentation.prototype).extend({\n        _super: function(_func) {\n            return _BaseRepresentation.prototype[_func].apply(this, Array.prototype.slice.call(arguments, 1));\n        },\n        redraw: function() {},\n        moveTo: function() {},\n        show: function() { return \"chaud cacao\"; },\n        hide: function() {},\n        select: function() {\n            if (this.model) {\n                this.model.trigger(\"selected\");\n            }\n        },\n        unselect: function() {\n            if (this.model) {\n                this.model.trigger(\"unselected\");\n            }\n        },\n        highlight: function() {},\n        unhighlight: function() {},\n        mousedown: function() {},\n        mouseup: function() {\n            if (this.model) {\n                this.model.trigger(\"clicked\");\n            }\n        },\n        destroy: function() {\n            if (this.model) {\n                this.model.off(\"change\", this._changeBinding );\n                this.model.off(\"remove\", this._removeBinding );\n                this.model.off(\"select\", this._selectBinding );\n                this.model.off(\"unselect\", this._unselectBinding );\n            }\n        }\n    });\n\n    /* End of Rkns.Renderer._BaseRepresentation Class */\n\n    return _BaseRepresentation;\n\n});\n\ndefine('requtils',[], function ($, _) {\n    \n    return {\n        getUtils: function(){\n            return window.Rkns.Utils;\n        },\n        getRenderer: function(){\n            return window.Rkns.Renderer;\n        }\n    };\n\n});\n\n\ndefine('renderer/basebutton',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* Rkns.Renderer._BaseButton Class */\n\n    /* BaseButton is extended by contextual buttons that appear when hovering on nodes and edges */\n\n    var _BaseButton = Utils.inherit(BaseRepresentation);\n\n    _(_BaseButton.prototype).extend({\n        moveTo: function(_pos) {\n            this.sector.moveTo(_pos);\n        },\n        show: function() {\n            this.sector.show();\n        },\n        hide: function() {\n            this.sector.hide();\n        },\n        select: function() {\n            this.sector.select();\n        },\n        unselect: function(_newTarget) {\n            this.sector.unselect();\n            if (!_newTarget || (_newTarget !== this.source_representation && _newTarget.source_representation !== this.source_representation)) {\n                this.source_representation.unselect();\n            }\n        },\n        destroy: function() {\n            this.sector.destroy();\n        }\n    });\n\n    return _BaseButton;\n\n});\n\n\n\ndefine('renderer/noderepr',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* Rkns.Renderer.Node Class */\n\n    /* The representation for the node : A circle, with an image inside and a text label underneath.\n     * The circle and the image are drawn on canvas and managed by Paper.js.\n     * The text label is an HTML node, managed by jQuery. */\n\n    //var NodeRepr = Renderer.Node = Utils.inherit(Renderer._BaseRepresentation);\n    var NodeRepr = Utils.inherit(BaseRepresentation);\n\n    _(NodeRepr.prototype).extend({\n        _init: function() {\n            this.renderer.node_layer.activate();\n            this.type = \"Node\";\n            this.circle = new paper.Path.Circle([0, 0], 1);\n            this.circle.__representation = this;\n            if (this.options.show_node_circles) {\n                this.circle.strokeWidth = this.options.node_stroke_width;\n                this.h_ratio = 1;\n            } else {\n                this.h_ratio = 0;\n            }\n            this.title = $('<div class=\"Rk-Label\">').appendTo(this.renderer.labels_$);\n            if (this.options.editor_mode) {\n                var Renderer = requtils.getRenderer();\n                this.normal_buttons = [\n                                       new Renderer.NodeEditButton(this.renderer, null),\n                                       new Renderer.NodeRemoveButton(this.renderer, null),\n                                       new Renderer.NodeLinkButton(this.renderer, null),\n                                       new Renderer.NodeEnlargeButton(this.renderer, null),\n                                       new Renderer.NodeShrinkButton(this.renderer, null)\n                                       ];\n                this.pending_delete_buttons = [\n                                               new Renderer.NodeRevertButton(this.renderer, null)\n                                               ];\n                this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons);\n                for (var i = 0; i < this.all_buttons.length; i++) {\n                    this.all_buttons[i].source_representation = this;\n                }\n                this.active_buttons = [];\n            } else {\n                this.active_buttons = this.all_buttons = [];\n            }\n            this.last_circle_radius = 1;\n\n            if (this.renderer.minimap) {\n                this.renderer.minimap.node_layer.activate();\n                this.minimap_circle = new paper.Path.Circle([0, 0], 1);\n                this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation;\n                this.renderer.minimap.node_group.addChild(this.minimap_circle);\n            }\n        },\n        redraw: function(_dontRedrawEdges) {\n            var _model_coords = new paper.Point(this.model.get(\"position\")),\n            _baseRadius = this.options.node_size_base * Math.exp((this.model.get(\"size\") || 0) * Utils._NODE_SIZE_STEP);\n            if (!this.is_dragging || !this.paper_coords) {\n                this.paper_coords = this.renderer.toPaperCoords(_model_coords);\n            }\n            this.circle_radius = _baseRadius * this.renderer.scale;\n            if (this.last_circle_radius !== this.circle_radius) {\n                this.all_buttons.forEach(function(b) {\n                    b.setSectorSize();\n                });\n                this.circle.scale(this.circle_radius / this.last_circle_radius);\n                if (this.node_image) {\n                    this.node_image.scale(this.circle_radius / this.last_circle_radius);\n                }\n            }\n            this.circle.position = this.paper_coords;\n            if (this.node_image) {\n                this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius));\n            }\n            this.last_circle_radius = this.circle_radius;\n\n            var old_act_btn = this.active_buttons;\n\n            var opacity = 1;\n            if (this.model.get(\"delete_scheduled\")) {\n                opacity = 0.5;\n                this.active_buttons = this.pending_delete_buttons;\n                this.circle.dashArray = [2,2];\n            } else {\n                opacity = 1;\n                this.active_buttons = this.normal_buttons;\n                this.circle.dashArray = null;\n            }\n\n            if (this.selected && this.renderer.isEditable()) {\n                if (old_act_btn !== this.active_buttons) {\n                    old_act_btn.forEach(function(b) {\n                        b.hide();\n                    });\n                }\n                this.active_buttons.forEach(function(b) {\n                    b.show();\n                });\n            }\n\n            if (this.node_image) {\n                this.node_image.opacity = this.highlighted ? opacity * 0.5 : (opacity - 0.01);\n            }\n\n            this.circle.fillColor = this.highlighted ? this.options.highlighted_node_fill_color : this.options.node_fill_color;\n\n            this.circle.opacity = this.options.show_node_circles ? opacity : 0.01;\n\n            var _text = this.model.get(\"title\") || this.renkan.translate(this.options.label_untitled_nodes) || \"\";\n            _text = Utils.shortenText(_text, this.options.node_label_max_length);\n\n            if (typeof this.highlighted === \"object\") {\n                this.title.html(this.highlighted.replace(_(_text).escape(),'<span class=\"Rk-Highlighted\">$1</span>'));\n            } else {\n                this.title.text(_text);\n            }\n\n            this.title.css({\n                left: this.paper_coords.x,\n                top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance,\n                opacity: opacity\n            });\n            var _color = this.model.get(\"color\") || (this.model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\");\n            this.circle.strokeColor = _color;\n            var _pc = this.paper_coords;\n            this.all_buttons.forEach(function(b) {\n                b.moveTo(_pc);\n            });\n            var lastImage = this.img;\n            this.img = this.model.get(\"image\");\n            if (this.img && this.img !== lastImage) {\n                this.showImage();\n            }\n            if (this.node_image && !this.img) {\n                this.node_image.remove();\n                delete this.node_image;\n            }\n\n            if (this.renderer.minimap) {\n                this.minimap_circle.fillColor = _color;\n                var minipos = this.renderer.toMinimapCoords(_model_coords),\n                miniradius = this.renderer.minimap.scale * _baseRadius,\n                minisize = new paper.Size([miniradius, miniradius]);\n                this.minimap_circle.fitBounds(minipos.subtract(minisize), minisize.multiply(2));\n            }\n\n            if (!_dontRedrawEdges) {\n                var _this = this;\n                _.each(\n                        this.project.get(\"edges\").filter(\n                                function (ed) {\n                                    return ((ed.get(\"to\") === _this.model) || (ed.get(\"from\") === _this.model));\n                                }\n                        ),\n                        function(edge, index, list) {\n                            var repr = _this.renderer.getRepresentationByModel(edge);\n                            if (repr && typeof repr.from_representation !== \"undefined\" && typeof repr.from_representation.paper_coords !== \"undefined\" && typeof repr.to_representation !== \"undefined\" && typeof repr.to_representation.paper_coords !== \"undefined\") {\n                                repr.redraw();\n                            }\n                        }\n                );\n            }\n\n        },\n        showImage: function() {\n            var _image = null;\n            if (typeof this.renderer.image_cache[this.img] === \"undefined\") {\n                _image = new Image();\n                this.renderer.image_cache[this.img] = _image;\n                _image.src = this.img;\n            } else {\n                _image = this.renderer.image_cache[this.img];\n            }\n            if (_image.width) {\n                if (this.node_image) {\n                    this.node_image.remove();\n                }\n                this.renderer.node_layer.activate();\n                var width = _image.width,\n                height = _image.height,\n                clipPath = this.model.get(\"clip_path\"),\n                hasClipPath = (typeof clipPath !== \"undefined\" && clipPath),\n                _clip = null,\n                baseRadius = null,\n                centerPoint = null;\n\n                if (hasClipPath) {\n                    _clip = new paper.Path();\n                    var instructions = clipPath.match(/[a-z][^a-z]+/gi) || [],\n                    lastCoords = [0,0],\n                    minX = Infinity,\n                    minY = Infinity,\n                    maxX = -Infinity,\n                    maxY = -Infinity;\n\n                    var transformCoords = function(tabc, relative) {\n                        var newCoords = tabc.slice(1).map(function(v, k) {\n                            var res = parseFloat(v),\n                            isY = k % 2;\n                            if (isY) {\n                                res = ( res - 0.5 ) * height;\n                            } else {\n                                res = ( res - 0.5 ) * width;\n                            }\n                            if (relative) {\n                                res += lastCoords[isY];\n                            }\n                            if (isY) {\n                                minY = Math.min(minY, res);\n                                maxY = Math.max(maxY, res);\n                            } else {\n                                minX = Math.min(minX, res);\n                                maxX = Math.max(maxX, res);\n                            }\n                            return res;\n                        });\n                        lastCoords = newCoords.slice(-2);\n                        return newCoords;\n                    };\n\n                    instructions.forEach(function(instr) {\n                        var coords = instr.match(/([a-z]|[0-9.-]+)/ig) || [\"\"];\n                        switch(coords[0]) {\n                        case \"M\":\n                            _clip.moveTo(transformCoords(coords));\n                            break;\n                        case \"m\":\n                            _clip.moveTo(transformCoords(coords, true));\n                            break;\n                        case \"L\":\n                            _clip.lineTo(transformCoords(coords));\n                            break;\n                        case \"l\":\n                            _clip.lineTo(transformCoords(coords, true));\n                            break;\n                        case \"C\":\n                            _clip.cubicCurveTo(transformCoords(coords));\n                            break;\n                        case \"c\":\n                            _clip.cubicCurveTo(transformCoords(coords, true));\n                            break;\n                        case \"Q\":\n                            _clip.quadraticCurveTo(transformCoords(coords));\n                            break;\n                        case \"q\":\n                            _clip.quadraticCurveTo(transformCoords(coords, true));\n                            break;\n                        }\n                    });\n\n                    baseRadius = Math[this.options.node_images_fill_mode ? \"min\" : \"max\"](maxX - minX, maxY - minY) / 2;\n                    centerPoint = new paper.Point((maxX + minX) / 2, (maxY + minY) / 2);\n                    if (!this.options.show_node_circles) {\n                        this.h_ratio = (maxY - minY) / (2 * baseRadius);\n                    }\n                } else {\n                    baseRadius = Math[this.options.node_images_fill_mode ? \"min\" : \"max\"](width, height) / 2;\n                    centerPoint = new paper.Point(0,0);\n                    if (!this.options.show_node_circles) {\n                        this.h_ratio = height / (2 * baseRadius);\n                    }\n                }\n                var _raster = new paper.Raster(_image);\n                _raster.locked = true; // Disable mouse events on icon\n                if (hasClipPath) {\n                    _raster = new paper.Group(_clip, _raster);\n                    _raster.opacity = 0.99;\n                    /* This is a workaround to allow clipping at group level\n                     * If opacity was set to 1, paper.js would merge all clipping groups in one (known bug).\n                     */\n                    _raster.clipped = true;\n                    _clip.__representation = this;\n                }\n                if (this.options.clip_node_images) {\n                    var _circleClip = new paper.Path.Circle(centerPoint, baseRadius);\n                    _raster = new paper.Group(_circleClip, _raster);\n                    _raster.opacity = 0.99;\n                    _raster.clipped = true;\n                    _circleClip.__representation = this;\n                }\n                this.image_delta = centerPoint.divide(baseRadius);\n                this.node_image = _raster;\n                this.node_image.__representation = _this;\n                this.node_image.scale(this.circle_radius / baseRadius);\n                this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius));\n                this.redraw();\n                this.renderer.throttledPaperDraw();\n            } else {\n                var _this = this;\n                $(_image).on(\"load\", function() {\n                    _this.showImage();\n                });\n            }\n        },\n        paperShift: function(_delta) {\n            if (this.options.editor_mode) {\n                if (!this.renkan.read_only) {\n                    this.is_dragging = true;\n                    this.paper_coords = this.paper_coords.add(_delta);\n                    this.redraw();\n                }\n            } else {\n                this.renderer.paperShift(_delta);\n            }\n        },\n        openEditor: function() {\n            this.renderer.removeRepresentationsOfType(\"editor\");\n            var _editor = this.renderer.addRepresentation(\"NodeEditor\",null);\n            _editor.source_representation = this;\n            _editor.draw();\n        },\n        select: function() {\n            this.selected = true;\n            this.circle.strokeWidth = this.options.selected_node_stroke_width;\n            if (this.renderer.isEditable()) {\n                this.active_buttons.forEach(function(b) {\n                    b.show();\n                });\n            }\n            var _uri = this.model.get(\"uri\");\n            if (_uri) {\n                $('.Rk-Bin-Item').each(function() {\n                    var _el = $(this);\n                    if (_el.attr(\"data-uri\") === _uri) {\n                        _el.addClass(\"selected\");\n                    }\n                });\n            }\n            if (!this.options.editor_mode) {\n                this.openEditor();\n            }\n\n            if (this.renderer.minimap) {\n                this.minimap_circle.strokeWidth = this.options.minimap_highlight_weight;\n                this.minimap_circle.strokeColor = this.options.minimap_highlight_color;\n            }\n            this._super(\"select\");\n        },\n        unselect: function(_newTarget) {\n            if (!_newTarget || _newTarget.source_representation !== this) {\n                this.selected = false;\n                this.all_buttons.forEach(function(b) {\n                    b.hide();\n                });\n                this.circle.strokeWidth = this.options.node_stroke_width;\n                $('.Rk-Bin-Item').removeClass(\"selected\");\n                if (this.renderer.minimap) {\n                    this.minimap_circle.strokeColor = undefined;\n                }\n                this._super(\"unselect\");\n            }\n        },\n        highlight: function(textToReplace) {\n            var hlvalue = textToReplace || true;\n            if (this.highlighted === hlvalue) {\n                return;\n            }\n            this.highlighted = hlvalue;\n            this.redraw();\n            this.renderer.throttledPaperDraw();\n        },\n        unhighlight: function() {\n            if (!this.highlighted) {\n                return;\n            }\n            this.highlighted = false;\n            this.redraw();\n            this.renderer.throttledPaperDraw();\n        },\n        saveCoords: function() {\n            var _coords = this.renderer.toModelCoords(this.paper_coords),\n            _data = {\n                position: {\n                    x: _coords.x,\n                    y: _coords.y\n                }\n            };\n            if (this.renderer.isEditable()) {\n                this.model.set(_data);\n            }\n        },\n        mousedown: function(_event, _isTouch) {\n            if (_isTouch) {\n                this.renderer.unselectAll();\n                this.select();\n            }\n        },\n        mouseup: function(_event, _isTouch) {\n            if (this.renderer.is_dragging && this.renderer.isEditable()) {\n                this.saveCoords();\n            } else {\n                if (!_isTouch && !this.model.get(\"delete_scheduled\")) {\n                    this.openEditor();\n                }\n                this.model.trigger(\"clicked\");\n            }\n            this.renderer.click_target = null;\n            this.renderer.is_dragging = false;\n            this.is_dragging = false;\n        },\n        destroy: function(_event) {\n            this._super(\"destroy\");\n            this.all_buttons.forEach(function(b) {\n                b.destroy();\n            });\n            this.circle.remove();\n            this.title.remove();\n            if (this.renderer.minimap) {\n                this.minimap_circle.remove();\n            }\n            if (this.node_image) {\n                this.node_image.remove();\n            }\n        }\n    });\n\n    return NodeRepr;\n\n});\n\n\ndefine('renderer/edge',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* Edge Class Begin */\n\n    //var Edge = Renderer.Edge = Utils.inherit(Renderer._BaseRepresentation);\n    var Edge = Utils.inherit(BaseRepresentation);\n\n    _(Edge.prototype).extend({\n        _init: function() {\n            this.renderer.edge_layer.activate();\n            this.type = \"Edge\";\n            this.from_representation = this.renderer.getRepresentationByModel(this.model.get(\"from\"));\n            this.to_representation = this.renderer.getRepresentationByModel(this.model.get(\"to\"));\n            this.bundle = this.renderer.addToBundles(this);\n            this.line = new paper.Path();\n            this.line.add([0,0],[0,0],[0,0]);\n            this.line.__representation = this;\n            this.line.strokeWidth = this.options.edge_stroke_width;\n            this.arrow = new paper.Path();\n            this.arrow.add(\n                    [ 0, 0 ],\n                    [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ],\n                    [ 0, this.options.edge_arrow_width ]\n            );\n            this.arrow.__representation = this;\n            this.text = $('<div class=\"Rk-Label Rk-Edge-Label\">').appendTo(this.renderer.labels_$);\n            this.arrow_angle = 0;\n            if (this.options.editor_mode) {\n                var Renderer = requtils.getRenderer();\n                this.normal_buttons = [\n                                       new Renderer.EdgeEditButton(this.renderer, null),\n                                       new Renderer.EdgeRemoveButton(this.renderer, null)\n                                       ];\n                this.pending_delete_buttons = [\n                                               new Renderer.EdgeRevertButton(this.renderer, null)\n                                               ];\n                this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons);\n                for (var i = 0; i < this.all_buttons.length; i++) {\n                    this.all_buttons[i].source_representation = this;\n                }\n                this.active_buttons = [];\n            } else {\n                this.active_buttons = this.all_buttons = [];\n            }\n\n            if (this.renderer.minimap) {\n                this.renderer.minimap.edge_layer.activate();\n                this.minimap_line = new paper.Path();\n                this.minimap_line.add([0,0],[0,0]);\n                this.minimap_line.__representation = this.renderer.minimap.miniframe.__representation;\n                this.minimap_line.strokeWidth = 1;\n            }\n        },\n        redraw: function() {\n            var from = this.model.get(\"from\"),\n            to = this.model.get(\"to\");\n            if (!from || !to) {\n                return;\n            }\n            this.from_representation = this.renderer.getRepresentationByModel(from);\n            this.to_representation = this.renderer.getRepresentationByModel(to);\n            if (typeof this.from_representation === \"undefined\" || typeof this.to_representation === \"undefined\") {\n                return;\n            }\n            var _p0a = this.from_representation.paper_coords,\n            _p1a = this.to_representation.paper_coords,\n            _v = _p1a.subtract(_p0a),\n            _r = _v.length,\n            _u = _v.divide(_r),\n            _ortho = new paper.Point([- _u.y, _u.x]),\n            _group_pos = this.bundle.getPosition(this),\n            _delta = _ortho.multiply( this.options.edge_gap_in_bundles * _group_pos ),\n            _p0b = _p0a.add(_delta), /* Adding a 4 px difference */\n            _p1b = _p1a.add(_delta), /* to differentiate bundled links */\n            _a = _v.angle,\n            _textdelta = _ortho.multiply(this.options.edge_label_distance),\n            _handle = _v.divide(3),\n            _color = this.model.get(\"color\") || this.model.get(\"color\") || (this.model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\"),\n            opacity = 1;\n\n            if (this.model.get(\"delete_scheduled\") || this.from_representation.model.get(\"delete_scheduled\") || this.to_representation.model.get(\"delete_scheduled\")) {\n                opacity = 0.5;\n                this.line.dashArray = [2, 2];\n            } else {\n                opacity = 1;\n                this.line.dashArray = null;\n            }\n\n            var old_act_btn = this.active_buttons;\n\n            this.active_buttons = this.model.get(\"delete_scheduled\") ? this.pending_delete_buttons : this.normal_buttons;\n\n            if (this.selected && this.renderer.isEditable() && old_act_btn !== this.active_buttons) {\n                old_act_btn.forEach(function(b) {\n                    b.hide();\n                });\n                this.active_buttons.forEach(function(b) {\n                    b.show();\n                });\n            }\n\n            this.paper_coords = _p0b.add(_p1b).divide(2);\n            this.line.strokeColor = _color;\n            this.line.opacity = opacity;\n            this.line.segments[0].point = _p0a;\n            this.line.segments[1].point = this.paper_coords;\n            this.line.segments[1].handleIn = _handle.multiply(-1);\n            this.line.segments[1].handleOut = _handle;\n            this.line.segments[2].point = _p1a;\n            this.arrow.rotate(_a - this.arrow_angle);\n            this.arrow.fillColor = _color;\n            this.arrow.opacity = opacity;\n            this.arrow.position = this.paper_coords;\n            this.arrow_angle = _a;\n            if (_a > 90) {\n                _a -= 180;\n                _textdelta = _textdelta.multiply(-1);\n            }\n            if (_a < -90) {\n                _a += 180;\n                _textdelta = _textdelta.multiply(-1);\n            }\n            var _text = this.model.get(\"title\") || this.renkan.translate(this.options.label_untitled_edges) || \"\";\n            _text = Utils.shortenText(_text, this.options.node_label_max_length);\n            this.text.text(_text);\n            var _textpos = this.paper_coords.add(_textdelta);\n            this.text.css({\n                left: _textpos.x,\n                top: _textpos.y,\n                transform: \"rotate(\" + _a + \"deg)\",\n                \"-moz-transform\": \"rotate(\" + _a + \"deg)\",\n                \"-webkit-transform\": \"rotate(\" + _a + \"deg)\",\n                opacity: opacity\n            });\n            this.text_angle = _a;\n\n            var _pc = this.paper_coords;\n            this.all_buttons.forEach(function(b) {\n                b.moveTo(_pc);\n            });\n\n            if (this.renderer.minimap) {\n                this.minimap_line.strokeColor = _color;\n                this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get(\"position\")));\n                this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get(\"position\")));\n            }\n        },\n        openEditor: function() {\n            this.renderer.removeRepresentationsOfType(\"editor\");\n            var _editor = this.renderer.addRepresentation(\"EdgeEditor\",null);\n            _editor.source_representation = this;\n            _editor.draw();\n        },\n        select: function() {\n            this.selected = true;\n            this.line.strokeWidth = this.options.selected_edge_stroke_width;\n            if (this.renderer.isEditable()) {\n                this.active_buttons.forEach(function(b) {\n                    b.show();\n                });\n            }\n            if (!this.options.editor_mode) {\n                this.openEditor();\n            }\n            this._super(\"select\");\n        },\n        unselect: function(_newTarget) {\n            if (!_newTarget || _newTarget.source_representation !== this) {\n                this.selected = false;\n                if (this.options.editor_mode) {\n                    this.all_buttons.forEach(function(b) {\n                        b.hide();\n                    });\n                }\n                this.line.strokeWidth = this.options.edge_stroke_width;\n                this._super(\"unselect\");\n            }\n        },\n        mousedown: function(_event, _isTouch) {\n            if (_isTouch) {\n                this.renderer.unselectAll();\n                this.select();\n            }\n        },\n        mouseup: function(_event, _isTouch) {\n            if (!this.renkan.read_only && this.renderer.is_dragging) {\n                this.from_representation.saveCoords();\n                this.to_representation.saveCoords();\n                this.from_representation.is_dragging = false;\n                this.to_representation.is_dragging = false;\n            } else {\n                if (!_isTouch) {\n                    this.openEditor();\n                }\n                this.model.trigger(\"clicked\");\n            }\n            this.renderer.click_target = null;\n            this.renderer.is_dragging = false;\n        },\n        paperShift: function(_delta) {\n            if (this.options.editor_mode) {\n                if (!this.options.read_only) {\n                    this.from_representation.paperShift(_delta);\n                    this.to_representation.paperShift(_delta);\n                }\n            } else {\n                this.renderer.paperShift(_delta);\n            }\n        },\n        destroy: function() {\n            this._super(\"destroy\");\n            this.line.remove();\n            this.arrow.remove();\n            this.text.remove();\n            if (this.renderer.minimap) {\n                this.minimap_line.remove();\n            }\n            this.all_buttons.forEach(function(b) {\n                b.destroy();\n            });\n            var _this = this;\n            this.bundle.edges = _(this.bundle.edges).reject(function(_edge) {\n                return _this === _edge;\n            });\n        }\n    });\n\n    return Edge;\n\n});\n\n\n\ndefine('renderer/tempedge',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* TempEdge Class Begin */\n\n    //var TempEdge = Renderer.TempEdge = Utils.inherit(Renderer._BaseRepresentation);\n    var TempEdge = Utils.inherit(BaseRepresentation);\n\n    _(TempEdge.prototype).extend({\n        _init: function() {\n            this.renderer.edge_layer.activate();\n            this.type = \"Temp-edge\";\n\n            var _color = (this.project.get(\"users\").get(this.renkan.current_user) || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\");\n            this.line = new paper.Path();\n            this.line.strokeColor = _color;\n            this.line.dashArray = [4, 2];\n            this.line.strokeWidth = this.options.selected_edge_stroke_width;\n            this.line.add([0,0],[0,0]);\n            this.line.__representation = this;\n            this.arrow = new paper.Path();\n            this.arrow.fillColor = _color;\n            this.arrow.add(\n                    [ 0, 0 ],\n                    [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ],\n                    [ 0, this.options.edge_arrow_width ]\n            );\n            this.arrow.__representation = this;\n            this.arrow_angle = 0;\n        },\n        redraw: function() {\n            var _p0 = this.from_representation.paper_coords,\n            _p1 = this.end_pos,\n            _a = _p1.subtract(_p0).angle,\n            _c = _p0.add(_p1).divide(2);\n            this.line.segments[0].point = _p0;\n            this.line.segments[1].point = _p1;\n            this.arrow.rotate(_a - this.arrow_angle);\n            this.arrow.position = _c;\n            this.arrow_angle = _a;\n        },\n        paperShift: function(_delta) {\n            if (!this.renderer.isEditable()) {\n                this.renderer.removeRepresentation(_this);\n                paper.view.draw();\n                return;\n            }\n            this.end_pos = this.end_pos.add(_delta);\n            var _hitResult = paper.project.hitTest(this.end_pos);\n            this.renderer.findTarget(_hitResult);\n            this.redraw();\n        },\n        mouseup: function(_event, _isTouch) {\n            var _hitResult = paper.project.hitTest(_event.point),\n            _model = this.from_representation.model,\n            _endDrag = true;\n            if (_hitResult && typeof _hitResult.item.__representation !== \"undefined\") {\n                var _target = _hitResult.item.__representation;\n                if (_target.type.substr(0,4) === \"Node\") {\n                    var _destmodel = _target.model || _target.source_representation.model;\n                    if (_model !== _destmodel) {\n                        var _data = {\n                                id: Utils.getUID('edge'),\n                                created_by: this.renkan.current_user,\n                                from: _model,\n                                to: _destmodel\n                        };\n                        if (this.renderer.isEditable()) {\n                            this.project.addEdge(_data);\n                        }\n                    }\n                }\n\n                if (_model === _target.model || (_target.source_representation && _target.source_representation.model === _model)) {\n                    _endDrag = false;\n                    this.renderer.is_dragging = true;\n                }\n            }\n            if (_endDrag) {\n                this.renderer.click_target = null;\n                this.renderer.is_dragging = false;\n                this.renderer.removeRepresentation(this);\n                paper.view.draw();\n            }\n        },\n        destroy: function() {\n            this.arrow.remove();\n            this.line.remove();\n        }\n    });\n\n    /* TempEdge Class End */\n\n    return TempEdge;\n\n});\n\n\ndefine('renderer/baseeditor',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* _BaseEditor Begin */\n    //var _BaseEditor = Renderer._BaseEditor = Utils.inherit(Renderer._BaseRepresentation);\n    var _BaseEditor = Utils.inherit(BaseRepresentation);\n\n    _(_BaseEditor.prototype).extend({\n        _init: function() {\n            this.renderer.buttons_layer.activate();\n            this.type = \"editor\";\n            this.editor_block = new paper.Path();\n            var _pts = _(_.range(8)).map(function() {return [0,0];});\n            this.editor_block.add.apply(this.editor_block, _pts);\n            this.editor_block.strokeWidth = this.options.tooltip_border_width;\n            this.editor_block.strokeColor = this.options.tooltip_border_color;\n            this.editor_block.opacity = 0.8;\n            this.editor_$ = $('<div>')\n            .appendTo(this.renderer.editor_$)\n            .css({\n                position: \"absolute\",\n                opacity: 0.8\n            })\n            .hide();\n        },\n        destroy: function() {\n            this.editor_block.remove();\n            this.editor_$.remove();\n        }\n    });\n\n    /* _BaseEditor End */\n\n    return _BaseEditor;\n\n});\n\n\ndefine('renderer/nodeeditor',['jquery', 'underscore', 'requtils', 'renderer/baseeditor'], function ($, _, requtils, BaseEditor) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* NodeEditor Begin */\n    //var NodeEditor = Renderer.NodeEditor = Utils.inherit(Renderer._BaseEditor);\n    var NodeEditor = Utils.inherit(BaseEditor);\n\n    _(NodeEditor.prototype).extend({\n        template: _.template(\n                '<h2><span class=\"Rk-CloseX\">&times;</span><%-renkan.translate(\"Edit Node\")%></span></h2>' +\n                '<p><label><%-renkan.translate(\"Title:\")%></label><input class=\"Rk-Edit-Title\" type=\"text\" value=\"<%-node.title%>\"/></p>' +\n                '<% if (options.show_node_editor_uri) { %><p><label><%-renkan.translate(\"URI:\")%></label><input class=\"Rk-Edit-URI\" type=\"text\" value=\"<%-node.uri%>\"/><a class=\"Rk-Edit-Goto\" href=\"<%-node.uri%>\" target=\"_blank\"></a></p><% } %>' +\n                '<% if (options.show_node_editor_description) { %><p><label><%-renkan.translate(\"Description:\")%></label><textarea class=\"Rk-Edit-Description\"><%-node.description%></textarea></p><% } %>' +\n                '<% if (options.show_node_editor_size) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Size:\")%></span><a href=\"#\" class=\"Rk-Edit-Size-Down\">-</a><span class=\"Rk-Edit-Size-Value\"><%-node.size%></span><a href=\"#\" class=\"Rk-Edit-Size-Up\">+</a></p><% } %>' +\n                '<% if (options.show_node_editor_color) { %><div class=\"Rk-Editor-p\"><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Node color:\")%></span><div class=\"Rk-Edit-ColorPicker-Wrapper\"><span class=\"Rk-Edit-Color\" style=\"background:<%-node.color%>;\"><span class=\"Rk-Edit-ColorTip\"></span></span>' +\n                '<%= renkan.colorPicker %><span class=\"Rk-Edit-ColorPicker-Text\"><%- renkan.translate(\"Choose color\") %></span></div></div><% } %>' +\n                '<% if (options.show_node_editor_image) { %><div class=\"Rk-Edit-ImgWrap\"><div class=\"Rk-Edit-ImgPreview\"><img src=\"<%-node.image || node.image_placeholder%>\" />' +\n                '<% if (node.clip_path) { %><svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewbox=\"0 0 1 1\" preserveAspectRatio=\"none\"><path style=\"stroke-width: .02; stroke:red; fill-opacity:.3; fill:red;\" d=\"<%- node.clip_path %>\"/></svg><% }%>' +\n                '</div></div><p><label><%-renkan.translate(\"Image URL:\")%></label><input class=\"Rk-Edit-Image\" type=\"text\" value=\"<%-node.image%>\"/></p>' +\n                '<p><label><%-renkan.translate(\"Choose Image File:\")%></label><input class=\"Rk-Edit-Image-File\" type=\"file\" accept=\"image/*\"/></p><% } %>' +\n                '<% if (options.show_node_editor_creator && node.has_creator) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Created by:\")%></span> <span class=\"Rk-UserColor\" style=\"background:<%-node.created_by_color%>;\"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>'\n        ),\n        readOnlyTemplate: _.template(\n                '<h2><span class=\"Rk-CloseX\">&times;</span><% if (options.show_node_tooltip_color) { %><span class=\"Rk-UserColor\" style=\"background:<%-node.color%>;\"></span><% } %>' +\n                '<span class=\"Rk-Display-Title\"><% if (node.uri) { %><a href=\"<%-node.uri%>\" target=\"_blank\"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2>' +\n                '<% if (node.uri && options.show_node_tooltip_uri) { %><p class=\"Rk-Display-URI\"><a href=\"<%-node.uri%>\" target=\"_blank\"><%-node.short_uri%></a></p><% } %>' +\n                '<% if (options.show_node_tooltip_description) { %><p class=\"Rk-Display-Description\"><%-node.description%></p><% } %>' +\n                '<% if (node.image && options.show_node_tooltip_image) { %><img class=\"Rk-Display-ImgPreview\" src=\"<%-node.image%>\" /><% } %>' +\n                '<% if (node.has_creator && options.show_node_tooltip_creator) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Created by:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-node.created_by_color%>;\"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>'\n        ),\n        draw: function() {\n            var _model = this.source_representation.model,\n            _created_by = _model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan),\n            _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ),\n            _image_placeholder = this.options.static_url + \"img/image-placeholder.png\",\n            _size = (_model.get(\"size\") || 0);\n            this.editor_$\n            .html(_template({\n                node: {\n                    has_creator: !!_model.get(\"created_by\"),\n                    title: _model.get(\"title\"),\n                    uri: _model.get(\"uri\"),\n                    short_uri:  Utils.shortenText((_model.get(\"uri\") || \"\").replace(/^(https?:\\/\\/)?(www\\.)?/,'').replace(/\\/$/,''),40),\n                    description: _model.get(\"description\"),\n                    image: _model.get(\"image\") || \"\",\n                    image_placeholder: _image_placeholder,\n                    color: _model.get(\"color\") || _created_by.get(\"color\"),\n                    clip_path: _model.get(\"clip_path\") || false,\n                    created_by_color: _created_by.get(\"color\"),\n                    created_by_title: _created_by.get(\"title\"),\n                    size: (_size > 0 ? \"+\" : \"\") + _size\n                },\n                renkan: this.renkan,\n                options: this.options,\n                shortenText: Utils.shortenText\n            }));\n            this.redraw();\n            var _this = this,\n            closeEditor = function() {\n                _this.renderer.removeRepresentation(_this);\n                paper.view.draw();\n            };\n\n            this.editor_$.find(\".Rk-CloseX\").click(closeEditor);\n\n            this.editor_$.find(\".Rk-Edit-Goto\").click(function() {\n                if (!_model.get(\"uri\")) {\n                    return false;\n                }\n            });\n\n            if (this.renderer.isEditable()) {\n\n                var onFieldChange = _(function() {\n                    _(function() {\n                        if (_this.renderer.isEditable()) {\n                            var _data = {\n                                    title: _this.editor_$.find(\".Rk-Edit-Title\").val()\n                            };\n                            if (_this.options.show_node_editor_uri) {\n                                _data.uri = _this.editor_$.find(\".Rk-Edit-URI\").val();\n                                _this.editor_$.find(\".Rk-Edit-Goto\").attr(\"href\",_data.uri || \"#\");\n                            }\n                            if (_this.options.show_node_editor_image) {\n                                _data.image = _this.editor_$.find(\".Rk-Edit-Image\").val();\n                                _this.editor_$.find(\".Rk-Edit-ImgPreview\").attr(\"src\", _data.image || _image_placeholder);\n                            }\n                            if (_this.options.show_node_editor_description) {\n                                _data.description = _this.editor_$.find(\".Rk-Edit-Description\").val();\n                            }\n                            _model.set(_data);\n                            _this.redraw();\n                        } else {\n                            closeEditor();\n                        }\n\n                    }).defer();\n                }).throttle(500);\n\n                this.editor_$.on(\"keyup\", function(_e) {\n                    if (_e.keyCode === 27) {\n                        closeEditor();\n                    }\n                });\n\n                this.editor_$.find(\"input, textarea\").on(\"change keyup paste\", onFieldChange);\n\n                this.editor_$.find(\".Rk-Edit-Image-File\").change(function() {\n                    if (this.files.length) {\n                        var f = this.files[0],\n                        fr = new FileReader();\n                        if (f.type.substr(0,5) !== \"image\") {\n                            alert(_this.renkan.translate(\"This file is not an image\"));\n                            return;\n                        }\n                        if (f.size > (_this.options.uploaded_image_max_kb * 1024)) {\n                            alert(_this.renkan.translate(\"Image size must be under \") + _this.options.uploaded_image_max_kb + _this.renkan.translate(\"KB\"));\n                            return;\n                        }\n                        fr.onload = function(e) {\n                            _this.editor_$.find(\".Rk-Edit-Image\").val(e.target.result);\n                            onFieldChange();\n                        };\n                        fr.readAsDataURL(f);\n                    }\n                });\n                this.editor_$.find(\".Rk-Edit-Title\")[0].focus();\n\n                var _picker = _this.editor_$.find(\".Rk-Edit-ColorPicker\");\n\n                this.editor_$.find(\".Rk-Edit-ColorPicker-Wrapper\").hover(\n                        function(_e) {\n                            _e.preventDefault();\n                            _picker.show();\n                        },\n                        function(_e) {\n                            _e.preventDefault();\n                            _picker.hide();\n                        }\n                );\n\n                _picker.find(\"li\").hover(\n                        function(_e) {\n                            _e.preventDefault();\n                            _this.editor_$.find(\".Rk-Edit-Color\").css(\"background\", $(this).attr(\"data-color\"));\n                        },\n                        function(_e) {\n                            _e.preventDefault();\n                            _this.editor_$.find(\".Rk-Edit-Color\").css(\"background\", _model.get(\"color\") || (_model.get(\"created_by\") || Utils._USER_PLACEHOLDER(_this.renkan)).get(\"color\"));\n                        }\n                ).click(function(_e) {\n                    _e.preventDefault();\n                    if (_this.renderer.isEditable()) {\n                        _model.set(\"color\", $(this).attr(\"data-color\"));\n                        _picker.hide();\n                        paper.view.draw();\n                    } else {\n                        closeEditor();\n                    }\n                });\n\n                var shiftSize = function(n) {\n                    if (_this.renderer.isEditable()) {\n                        var _newsize = n+(_model.get(\"size\") || 0);\n                        _this.editor_$.find(\".Rk-Edit-Size-Value\").text((_newsize > 0 ? \"+\" : \"\") + _newsize);\n                        _model.set(\"size\", _newsize);\n                        paper.view.draw();\n                    } else {\n                        closeEditor();\n                    }\n                };\n\n                this.editor_$.find(\".Rk-Edit-Size-Down\").click(function() {\n                    shiftSize(-1);\n                    return false;\n                });\n                this.editor_$.find(\".Rk-Edit-Size-Up\").click(function() {\n                    shiftSize(1);\n                    return false;\n                });\n            } else {\n                if (typeof this.source_representation.highlighted === \"object\") {\n                    var titlehtml = this.source_representation.highlighted.replace(_(_model.get(\"title\")).escape(),'<span class=\"Rk-Highlighted\">$1</span>');\n                    this.editor_$.find(\".Rk-Display-Title\" + (_model.get(\"uri\") ? \" a\" : \"\")).html(titlehtml);\n                    if (this.options.show_node_tooltip_description) {\n                        this.editor_$.find(\".Rk-Display-Description\").html(this.source_representation.highlighted.replace(_(_model.get(\"description\")).escape(),'<span class=\"Rk-Highlighted\">$1</span>'));\n                    }\n                }\n            }\n            this.editor_$.find(\"img\").load(function() {\n                _this.redraw();\n            });\n        },\n        redraw: function() {\n            var _coords = this.source_representation.paper_coords;\n            Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$);\n            this.editor_$.show();\n            paper.view.draw();\n        }\n    });\n\n    /* NodeEditor End */\n\n    return NodeEditor;\n\n});\n\n\ndefine('renderer/edgeeditor',['jquery', 'underscore', 'requtils', 'renderer/baseeditor'], function ($, _, requtils, BaseEditor) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* EdgeEditor Begin */\n\n    //var EdgeEditor = Renderer.EdgeEditor = Utils.inherit(Renderer._BaseEditor);\n    var EdgeEditor = Utils.inherit(BaseEditor);\n\n    _(EdgeEditor.prototype).extend({\n        template: _.template(\n                '<h2><span class=\"Rk-CloseX\">&times;</span><%-renkan.translate(\"Edit Edge\")%></span></h2>' +\n                '<p><label><%-renkan.translate(\"Title:\")%></label><input class=\"Rk-Edit-Title\" type=\"text\" value=\"<%-edge.title%>\"/></p>' +\n                '<% if (options.show_edge_editor_uri) { %><p><label><%-renkan.translate(\"URI:\")%></label><input class=\"Rk-Edit-URI\" type=\"text\" value=\"<%-edge.uri%>\"/><a class=\"Rk-Edit-Goto\" href=\"<%-edge.uri%>\" target=\"_blank\"></a></p>' +\n                '<% if (options.properties.length) { %><p><label><%-renkan.translate(\"Choose from vocabulary:\")%></label><select class=\"Rk-Edit-Vocabulary\">' +\n                '<% _(options.properties).each(function(ontology) { %><option class=\"Rk-Edit-Vocabulary-Class\" value=\"\"><%- renkan.translate(ontology.label) %></option>' +\n                '<% _(ontology.properties).each(function(property) { var uri = ontology[\"base-uri\"] + property.uri; %><option class=\"Rk-Edit-Vocabulary-Property\" value=\"<%- uri %>' +\n                '\"<% if (uri === edge.uri) { %> selected<% } %>><%- renkan.translate(property.label) %></option>' +\n                '<% }) %><% }) %></select></p><% } } %>' +\n                '<% if (options.show_edge_editor_color) { %><div class=\"Rk-Editor-p\"><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Edge color:\")%></span><div class=\"Rk-Edit-ColorPicker-Wrapper\"><span class=\"Rk-Edit-Color\" style=\"background:<%-edge.color%>;\"><span class=\"Rk-Edit-ColorTip\"></span></span>' +\n                '<%= renkan.colorPicker %><span class=\"Rk-Edit-ColorPicker-Text\"><%- renkan.translate(\"Choose color\") %></span></div></div><% } %>' +\n                '<% if (options.show_edge_editor_direction) { %><p><span class=\"Rk-Edit-Direction\"><%- renkan.translate(\"Change edge direction\") %></span></p><% } %>' +\n                '<% if (options.show_edge_editor_nodes) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"From:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.from_color%>;\"></span><%- shortenText(edge.from_title, 25) %></p>' +\n                '<p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"To:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.to_color%>;\"></span><%- shortenText(edge.to_title, 25) %></p><% } %>' +\n                '<% if (options.show_edge_editor_creator && edge.has_creator) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Created by:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.created_by_color%>;\"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'\n        ),\n        readOnlyTemplate: _.template(\n                '<h2><span class=\"Rk-CloseX\">&times;</span><% if (options.show_edge_tooltip_color) { %><span class=\"Rk-UserColor\" style=\"background:<%-edge.color%>;\"></span><% } %>' +\n                '<span class=\"Rk-Display-Title\"><% if (edge.uri) { %><a href=\"<%-edge.uri%>\" target=\"_blank\"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2>' +\n                '<% if (options.show_edge_tooltip_uri && edge.uri) { %><p class=\"Rk-Display-URI\"><a href=\"<%-edge.uri%>\" target=\"_blank\"><%-edge.short_uri%></a></p><% } %>' +\n                '<p><%-edge.description%></p>' +\n                '<% if (options.show_edge_tooltip_nodes) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"From:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.from_color%>;\"></span><%- shortenText(edge.from_title, 25) %></p>' +\n                '<p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"To:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.to_color%>;\"></span><%- shortenText(edge.to_title, 25) %></p><% } %>' +\n                '<% if (options.show_edge_tooltip_creator && edge.has_creator) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Created by:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.created_by_color%>;\"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'\n        ),\n        draw: function() {\n            var _model = this.source_representation.model,\n            _from_model = _model.get(\"from\"),\n            _to_model = _model.get(\"to\"),\n            _created_by = _model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan),\n            _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate);\n            this.editor_$\n            .html(_template({\n                edge: {\n                    has_creator: !!_model.get(\"created_by\"),\n                    title: _model.get(\"title\"),\n                    uri: _model.get(\"uri\"),\n                    short_uri:  Utils.shortenText((_model.get(\"uri\") || \"\").replace(/^(https?:\\/\\/)?(www\\.)?/,'').replace(/\\/$/,''),40),\n                    description: _model.get(\"description\"),\n                    color: _model.get(\"color\") || _created_by.get(\"color\"),\n                    from_title: _from_model.get(\"title\"),\n                    to_title: _to_model.get(\"title\"),\n                    from_color: _from_model.get(\"color\") || (_from_model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\"),\n                    to_color: _to_model.get(\"color\") || (_to_model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\"),\n                    created_by_color: _created_by.get(\"color\"),\n                    created_by_title: _created_by.get(\"title\")\n                },\n                renkan: this.renkan,\n                shortenText: Utils.shortenText,\n                options: this.options\n            }));\n            this.redraw();\n            var _this = this,\n            closeEditor = function() {\n                _this.renderer.removeRepresentation(_this);\n                paper.view.draw();\n            };\n            this.editor_$.find(\".Rk-CloseX\").click(closeEditor);\n            this.editor_$.find(\".Rk-Edit-Goto\").click(function() {\n                if (!_model.get(\"uri\")) {\n                    return false;\n                }\n            });\n\n            if (this.renderer.isEditable()) {\n\n                var onFieldChange = _(function() {\n                    _(function() {\n                        if (_this.renderer.isEditable()) {\n                            var _data = {\n                                    title: _this.editor_$.find(\".Rk-Edit-Title\").val()\n                            };\n                            if (_this.options.show_edge_editor_uri) {\n                                _data.uri = _this.editor_$.find(\".Rk-Edit-URI\").val();\n                            }\n                            _this.editor_$.find(\".Rk-Edit-Goto\").attr(\"href\",_data.uri || \"#\");\n                            _model.set(_data);\n                            paper.view.draw();\n                        } else {\n                            closeEditor();\n                        }\n                    }).defer();\n                }).throttle(500);\n\n                this.editor_$.on(\"keyup\", function(_e) {\n                    if (_e.keyCode === 27) {\n                        closeEditor();\n                    }\n                });\n\n                this.editor_$.find(\"input\").on(\"keyup change paste\", onFieldChange);\n\n                this.editor_$.find(\".Rk-Edit-Vocabulary\").change(function() {\n                    var e = $(this),\n                    v = e.val();\n                    if (v) {\n                        _this.editor_$.find(\".Rk-Edit-Title\").val(e.find(\":selected\").text());\n                        _this.editor_$.find(\".Rk-Edit-URI\").val(v);\n                        onFieldChange();\n                    }\n                });\n                this.editor_$.find(\".Rk-Edit-Direction\").click(function() {\n                    if (_this.renderer.isEditable()) {\n                        _model.set({\n                            from: _model.get(\"to\"),\n                            to: _model.get(\"from\")\n                        });\n                        _this.draw();\n                    } else {\n                        closeEditor();\n                    }\n                });\n\n                var _picker = _this.editor_$.find(\".Rk-Edit-ColorPicker\");\n\n                this.editor_$.find(\".Rk-Edit-ColorPicker-Wrapper\").hover(\n                        function(_e) {\n                            _e.preventDefault();\n                            _picker.show();\n                        },\n                        function(_e) {\n                            _e.preventDefault();\n                            _picker.hide();\n                        }\n                );\n\n                _picker.find(\"li\").hover(\n                        function(_e) {\n                            _e.preventDefault();\n                            _this.editor_$.find(\".Rk-Edit-Color\").css(\"background\", $(this).attr(\"data-color\"));\n                        },\n                        function(_e) {\n                            _e.preventDefault();\n                            _this.editor_$.find(\".Rk-Edit-Color\").css(\"background\", _model.get(\"color\") || (_model.get(\"created_by\") || Utils._USER_PLACEHOLDER(_this.renkan)).get(\"color\"));\n                        }\n                ).click(function(_e) {\n                    _e.preventDefault();\n                    if (_this.renderer.isEditable()) {\n                        _model.set(\"color\", $(this).attr(\"data-color\"));\n                        _picker.hide();\n                        paper.view.draw();\n                    } else {\n                        closeEditor();\n                    }\n                });\n            }\n        },\n        redraw: function() {\n            var _coords = this.source_representation.paper_coords;\n            Utils.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$);\n            this.editor_$.show();\n            paper.view.draw();\n        }\n    });\n\n    /* EdgeEditor End */\n\n    return EdgeEditor;\n\n});\n\n\ndefine('renderer/nodebutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {\n    \n    \n    var Utils = requtils.getUtils();\n\n    /* _NodeButton Begin */\n\n    //var _NodeButton = Renderer._NodeButton = Utils.inherit(Renderer._BaseButton);\n    var _NodeButton = Utils.inherit(BaseButton);\n\n    _(_NodeButton.prototype).extend({\n        setSectorSize: function() {\n            var sectorInner = this.source_representation.circle_radius;\n            if (sectorInner !== this.lastSectorInner) {\n                if (this.sector) {\n                    this.sector.destroy();\n                }\n                this.sector = this.renderer.drawSector(\n                        this, 1 + sectorInner,\n                        Utils._NODE_BUTTON_WIDTH + sectorInner,\n                        this.startAngle,\n                        this.endAngle,\n                        1,\n                        this.imageName,\n                        this.renkan.translate(this.text)\n                );\n                this.lastSectorInner = sectorInner;\n            }\n        }\n    });\n\n    /* _NodeButton End */\n\n    return _NodeButton;\n\n});\n\n\ndefine('renderer/nodeeditbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* NodeEditButton Begin */\n\n    //var NodeEditButton = Renderer.NodeEditButton = Utils.inherit(Renderer._NodeButton);\n    var NodeEditButton = Utils.inherit(NodeButton);\n\n    _(NodeEditButton.prototype).extend({\n        _init: function() {\n            this.type = \"Node-edit-button\";\n            this.lastSectorInner = 0;\n            this.startAngle = -135;\n            this.endAngle = -45;\n            this.imageName = \"edit\";\n            this.text = \"Edit\";\n        },\n        mouseup: function() {\n            if (!this.renderer.is_dragging) {\n                this.source_representation.openEditor();\n            }\n        }\n    });\n\n    /* NodeEditButton End */\n\n    return NodeEditButton;\n\n});\n\n\ndefine('renderer/noderemovebutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n    \n    \n    var Utils = requtils.getUtils();\n\n    /* NodeRemoveButton Begin */\n\n    //var NodeRemoveButton = Renderer.NodeRemoveButton = Utils.inherit(Renderer._NodeButton);\n    var NodeRemoveButton = Utils.inherit(NodeButton);\n\n    _(NodeRemoveButton.prototype).extend({\n        _init: function() {\n            this.type = \"Node-remove-button\";\n            this.lastSectorInner = 0;\n            this.startAngle = 0;\n            this.endAngle = 90;\n            this.imageName = \"remove\";\n            this.text = \"Remove\";\n        },\n        mouseup: function() {\n            this.renderer.click_target = null;\n            this.renderer.is_dragging = false;\n            this.renderer.removeRepresentationsOfType(\"editor\");\n            if (this.renderer.isEditable()) {\n                if (this.options.element_delete_delay) {\n                    var delid = Utils.getUID(\"delete\");\n                    this.renderer.delete_list.push({\n                        id: delid,\n                        time: new Date().valueOf() + this.options.element_delete_delay\n                    });\n                    this.source_representation.model.set(\"delete_scheduled\", delid);\n                } else {\n                    if (confirm(this.renkan.translate('Do you really wish to remove node ') + '\"' + this.source_representation.model.get(\"title\") + '\"?')) {\n                        this.project.removeNode(this.source_representation.model);\n                    }\n                }\n            }\n        }\n    });\n\n    /* NodeRemoveButton End */\n\n    return NodeRemoveButton;\n\n});\n\n\ndefine('renderer/noderevertbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* NodeRevertButton Begin */\n\n    //var NodeRevertButton = Renderer.NodeRevertButton = Utils.inherit(Renderer._NodeButton);\n    var NodeRevertButton = Utils.inherit(NodeButton);\n\n    _(NodeRevertButton.prototype).extend({\n        _init: function() {\n            this.type = \"Node-revert-button\";\n            this.lastSectorInner = 0;\n            this.startAngle = -135;\n            this.endAngle = 135;\n            this.imageName = \"revert\";\n            this.text = \"Cancel deletion\";\n        },\n        mouseup: function() {\n            this.renderer.click_target = null;\n            this.renderer.is_dragging = false;\n            if (this.renderer.isEditable()) {\n                this.source_representation.model.unset(\"delete_scheduled\");\n            }\n        }\n    });\n\n    /* NodeRevertButton End */\n\n    return NodeRevertButton;\n\n});\n\n\ndefine('renderer/nodelinkbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* NodeLinkButton Begin */\n\n    //var NodeLinkButton = Renderer.NodeLinkButton = Utils.inherit(Renderer._NodeButton);\n    var NodeLinkButton = Utils.inherit(NodeButton);\n\n    _(NodeLinkButton.prototype).extend({\n        _init: function() {\n            this.type = \"Node-link-button\";\n            this.lastSectorInner = 0;\n            this.startAngle = 90;\n            this.endAngle = 180;\n            this.imageName = \"link\";\n            this.text = \"Link to another node\";\n        },\n        mousedown: function(_event, _isTouch) {\n            if (this.renderer.isEditable()) {\n                var _off = this.renderer.canvas_$.offset(),\n                _point = new paper.Point([\n                                          _event.pageX - _off.left,\n                                          _event.pageY - _off.top\n                                          ]);\n                this.renderer.click_target = null;\n                this.renderer.removeRepresentationsOfType(\"editor\");\n                this.renderer.addTempEdge(this.source_representation, _point);\n            }\n        }\n    });\n\n    /* NodeLinkButton End */\n\n    return NodeLinkButton;\n\n});\n\n\n\ndefine('renderer/nodeenlargebutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n    \n    \n    var Utils = requtils.getUtils();\n\n    /* NodeEnlargeButton Begin */\n\n    //var NodeEnlargeButton = Renderer.NodeEnlargeButton = Utils.inherit(Renderer._NodeButton);\n    var NodeEnlargeButton = Utils.inherit(NodeButton);\n\n    _(NodeEnlargeButton.prototype).extend({\n        _init: function() {\n            this.type = \"Node-enlarge-button\";\n            this.lastSectorInner = 0;\n            this.startAngle = -45;\n            this.endAngle = 0;\n            this.imageName = \"enlarge\";\n            this.text = \"Enlarge\";\n        },\n        mouseup: function() {\n            var _newsize = 1 + (this.source_representation.model.get(\"size\") || 0);\n            this.source_representation.model.set(\"size\", _newsize);\n            this.source_representation.select();\n            this.select();\n            paper.view.draw();\n        }\n    });\n\n    /* NodeEnlargeButton End */\n\n    return NodeEnlargeButton;\n\n});\n\n\ndefine('renderer/nodeshrinkbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* NodeShrinkButton Begin */\n\n    //var NodeShrinkButton = Renderer.NodeShrinkButton = Utils.inherit(Renderer._NodeButton);\n    var NodeShrinkButton = Utils.inherit(NodeButton);\n\n    _(NodeShrinkButton.prototype).extend({\n        _init: function() {\n            this.type = \"Node-shrink-button\";\n            this.lastSectorInner = 0;\n            this.startAngle = -180;\n            this.endAngle = -135;\n            this.imageName = \"shrink\";\n            this.text = \"Shrink\";\n        },\n        mouseup: function() {\n            var _newsize = -1 + (this.source_representation.model.get(\"size\") || 0);\n            this.source_representation.model.set(\"size\", _newsize);\n            this.source_representation.select();\n            this.select();\n            paper.view.draw();\n        }\n    });\n\n    /* NodeShrinkButton End */\n\n    return NodeShrinkButton;\n\n});\n\n\ndefine('renderer/edgeeditbutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* EdgeEditButton Begin */\n\n    //var EdgeEditButton = Renderer.EdgeEditButton = Utils.inherit(Renderer._BaseButton);\n    var EdgeEditButton = Utils.inherit(BaseButton);\n\n    _(EdgeEditButton.prototype).extend({\n        _init: function() {\n            this.type = \"Edge-edit-button\";\n            this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -270, -90, 1, \"edit\", this.renkan.translate(\"Edit\"));\n        },\n        mouseup: function() {\n            if (!this.renderer.is_dragging) {\n                this.source_representation.openEditor();\n            }\n        }\n    });\n\n    /* EdgeEditButton End */\n\n    return EdgeEditButton;\n\n});\n\n\ndefine('renderer/edgeremovebutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* EdgeRemoveButton Begin */\n\n    //var EdgeRemoveButton = Renderer.EdgeRemoveButton = Utils.inherit(Renderer._BaseButton);\n    var EdgeRemoveButton = Utils.inherit(BaseButton);\n\n    _(EdgeRemoveButton.prototype).extend({\n        _init: function() {\n            this.type = \"Edge-remove-button\";\n            this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -90, 90, 1, \"remove\", this.renkan.translate(\"Remove\"));\n        },\n        mouseup: function() {\n            this.renderer.click_target = null;\n            this.renderer.is_dragging = false;\n            this.renderer.removeRepresentationsOfType(\"editor\");\n            if (this.renderer.isEditable()) {\n                if (this.options.element_delete_delay) {\n                    var delid = Utils.getUID(\"delete\");\n                    this.renderer.delete_list.push({\n                        id: delid,\n                        time: new Date().valueOf() + this.options.element_delete_delay\n                    });\n                    this.source_representation.model.set(\"delete_scheduled\", delid);\n                } else {\n                    if (confirm(this.renkan.translate('Do you really wish to remove edge ') + '\"' + this.source_representation.model.get(\"title\") + '\"?')) {\n                        this.project.removeEdge(this.source_representation.model);\n                    }\n                }\n            }\n        }\n    });\n\n    /* EdgeRemoveButton End */\n\n    return EdgeRemoveButton;\n\n});\n\n\ndefine('renderer/edgerevertbutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* EdgeRevertButton Begin */\n\n    //var EdgeRevertButton = Renderer.EdgeRevertButton = Utils.inherit(Renderer._BaseButton);\n    var EdgeRevertButton = Utils.inherit(BaseButton);\n\n    _(EdgeRevertButton.prototype).extend({\n        _init: function() {\n            this.type = \"Edge-revert-button\";\n            this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -135, 135, 1, \"revert\", this.renkan.translate(\"Cancel deletion\"));\n        },\n        mouseup: function() {\n            this.renderer.click_target = null;\n            this.renderer.is_dragging = false;\n            if (this.renderer.isEditable()) {\n                this.source_representation.model.unset(\"delete_scheduled\");\n            }\n        }\n    });\n\n    /* EdgeRevertButton End */\n\n    return EdgeRevertButton;\n\n});\n\n\ndefine('renderer/miniframe',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* MiniFrame Begin */\n\n    //var MiniFrame = Renderer.MiniFrame = Utils.inherit(Renderer._BaseRepresentation);\n    var MiniFrame = Utils.inherit(BaseRepresentation);\n\n    _(MiniFrame.prototype).extend({\n        paperShift: function(_delta) {\n            this.renderer.offset = this.renderer.offset.subtract(_delta.divide(this.renderer.minimap.scale).multiply(this.renderer.scale));\n            this.renderer.redraw();\n        },\n        mouseup: function(_delta) {\n            this.renderer.click_target = null;\n            this.renderer.is_dragging = false;\n        }\n    });\n\n    /* MiniFrame End */\n\n    return MiniFrame;\n\n});\n\n\ndefine('renderer/scene',['jquery', 'underscore', 'filesaver', 'requtils', 'renderer/miniframe'], function ($, _, filesaver, requtils, MiniFrame) {\n    \n\n    var Utils = requtils.getUtils();\n\n    /* Scene Begin */\n\n    var Scene = function(_renkan) {\n        this.renkan = _renkan;\n        this.$ = $(\".Rk-Render\");\n        this.representations = [];\n        this.$.html(this.template(_renkan));\n        this.onStatusChange();\n        this.canvas_$ = this.$.find(\".Rk-Canvas\");\n        this.labels_$ = this.$.find(\".Rk-Labels\");\n        this.editor_$ = this.$.find(\".Rk-Editor\");\n        this.notif_$ = this.$.find(\".Rk-Notifications\");\n        paper.setup(this.canvas_$[0]);\n        this.scale = 1;\n        this.initialScale = 1;\n        this.offset = paper.view.center;\n        this.totalScroll = 0;\n        this.mouse_down = false;\n        this.click_target = null;\n        this.selected_target = null;\n        this.edge_layer = new paper.Layer();\n        this.node_layer = new paper.Layer();\n        this.buttons_layer = new paper.Layer();\n        this.delete_list = [];\n        this.redrawActive = true;\n\n        if (_renkan.options.show_minimap) {\n            this.minimap = {\n                    background_layer: new paper.Layer(),\n                    edge_layer: new paper.Layer(),\n                    node_layer: new paper.Layer(),\n                    node_group: new paper.Group(),\n                    size: new paper.Size( _renkan.options.minimap_width, _renkan.options.minimap_height )\n            };\n\n            this.minimap.background_layer.activate();\n            this.minimap.topleft = paper.view.bounds.bottomRight.subtract(this.minimap.size);\n            this.minimap.rectangle = new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]), this.minimap.size.add([4,4]));\n            this.minimap.rectangle.fillColor = _renkan.options.minimap_background_color;\n            this.minimap.rectangle.strokeColor = _renkan.options.minimap_border_color;\n            this.minimap.rectangle.strokeWidth = 4;\n            this.minimap.offset = new paper.Point(this.minimap.size.divide(2));\n            this.minimap.scale = 0.1;\n\n            this.minimap.node_layer.activate();\n            this.minimap.cliprectangle = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size);\n            this.minimap.node_group.addChild(this.minimap.cliprectangle);\n            this.minimap.node_group.clipped = true;\n            this.minimap.miniframe = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size);\n            this.minimap.node_group.addChild(this.minimap.miniframe);\n            this.minimap.miniframe.fillColor = '#c0c0ff';\n            this.minimap.miniframe.opacity = 0.3;\n            this.minimap.miniframe.strokeColor = '#000080';\n            this.minimap.miniframe.strokeWidth = 3;\n            this.minimap.miniframe.__representation = new MiniFrame(this, null);\n        }\n\n        this.throttledPaperDraw = _(function() {\n            paper.view.draw();\n        }).throttle(100);\n\n        this.bundles = [];\n        this.click_mode = false;\n\n        var _this = this,\n        _allowScroll = true,\n        _originalScale = 1,\n        _zooming = false,\n        _lastTapX = 0,\n        _lastTapY = 0;\n\n        this.image_cache = {};\n        this.icon_cache = {};\n\n        ['edit', 'remove', 'link', 'enlarge', 'shrink', 'revert' ].forEach(function(imgname) {\n            var img = new Image();\n            img.src = _renkan.options.static_url + 'img/' + imgname + '.png';\n            _this.icon_cache[imgname] = img;\n        });\n\n        var throttledMouseMove = _.throttle(function(_event, _isTouch) {\n            _this.onMouseMove(_event, _isTouch);\n        }, Utils._MOUSEMOVE_RATE);\n\n        this.canvas_$.on({\n            mousedown: function(_event) {\n                _event.preventDefault();\n                _this.onMouseDown(_event, false);\n            },\n            mousemove: function(_event) {\n                _event.preventDefault();\n                throttledMouseMove(_event, false);\n            },\n            mouseup: function(_event) {\n                _event.preventDefault();\n                _this.onMouseUp(_event, false);\n            },\n            mousewheel: function(_event, _delta) {\n                if(_renkan.options.zoom_on_scroll) {\n                    _event.preventDefault();\n                    if (_allowScroll) {\n                        _this.onScroll(_event, _delta);\n                    }\n                }\n            },\n            touchstart: function(_event) {\n                _event.preventDefault();\n                var _touches = _event.originalEvent.touches[0];\n                if (\n                        _renkan.options.allow_double_click &&\n                        new Date() - _lastTap < Utils._DOUBLETAP_DELAY &&\n                        ( Math.pow(_lastTapX - _touches.pageX, 2) + Math.pow(_lastTapY - _touches.pageY, 2) < Utils._DOUBLETAP_DISTANCE )\n                ) {\n                    _lastTap = 0;\n                    _this.onDoubleClick(_touches);\n                } else {\n                    _lastTap = new Date();\n                    _lastTapX = _touches.pageX;\n                    _lastTapY = _touches.pageY;\n                    _originalScale = _this.scale;\n                    _zooming = false;\n                    _this.onMouseDown(_touches, true);\n                }\n            },\n            touchmove: function(_event) {\n                _event.preventDefault();\n                _lastTap = 0;\n                if (_event.originalEvent.touches.length === 1) {\n                    _this.onMouseMove(_event.originalEvent.touches[0], true);\n                } else {\n                    if (!_zooming) {\n                        _this.onMouseUp(_event.originalEvent.touches[0], true);\n                        _this.click_target = null;\n                        _this.is_dragging = false;\n                        _zooming = true;\n                    }\n                    if (_event.originalEvent.scale === \"undefined\") {\n                        return;\n                    }\n                    var _newScale = _event.originalEvent.scale * _originalScale,\n                    _scaleRatio = _newScale / _this.scale,\n                    _newOffset = new paper.Point([\n                                                  _this.canvas_$.width(),\n                                                  _this.canvas_$.height()\n                                                  ]).multiply( 0.5 * ( 1 - _scaleRatio ) ).add(_this.offset.multiply( _scaleRatio ));\n                    _this.setScale(_newScale, _newOffset);\n                }\n            },\n            touchend: function(_event) {\n                _event.preventDefault();\n                _this.onMouseUp(_event.originalEvent.changedTouches[0], true);\n            },\n            dblclick: function(_event) {\n                _event.preventDefault();\n                if (_renkan.options.allow_double_click) {\n                    _this.onDoubleClick(_event);\n                }\n            },\n            mouseleave: function(_event) {\n                _event.preventDefault();\n                _this.onMouseUp(_event, false);\n                _this.click_target = null;\n                _this.is_dragging = false;\n            },\n            dragover: function(_event) {\n                _event.preventDefault();\n            },\n            dragenter: function(_event) {\n                _event.preventDefault();\n                _allowScroll = false;\n            },\n            dragleave: function(_event) {\n                _event.preventDefault();\n                _allowScroll = true;\n            },\n            drop: function(_event) {\n                _event.preventDefault();\n                _allowScroll = true;\n                var res = {};\n                _(_event.originalEvent.dataTransfer.types).each(function(t) {\n                    try {\n                        res[t] = _event.originalEvent.dataTransfer.getData(t);\n                    } catch(e) {}\n                });\n                var text = _event.originalEvent.dataTransfer.getData(\"Text\");\n                if (typeof text === \"string\") {\n                    switch(text[0]) {\n                    case \"{\":\n                    case \"[\":\n                        try {\n                            var data = JSON.parse(text);\n                            _(res).extend(data);\n                        }\n                        catch(e) {\n                            if (!res[\"text/plain\"]) {\n                                res[\"text/plain\"] = text;\n                            }\n                        }\n                        break;\n                    case \"<\":\n                        if (!res[\"text/html\"]) {\n                            res[\"text/html\"] = text;\n                        }\n                        break;\n                    default:\n                        if (!res[\"text/plain\"]) {\n                            res[\"text/plain\"] = text;\n                        }\n                    }\n                }\n                var url = _event.originalEvent.dataTransfer.getData(\"URL\");\n                if (url && !res[\"text/uri-list\"]) {\n                    res[\"text/uri-list\"] = url;\n                }\n                _this.dropData(res, _event.originalEvent);\n            }\n        });\n\n        var bindClick = function(selector, fname) {\n            _this.$.find(selector).click(function(evt) {\n                _this[fname](evt);\n                return false;\n            });\n        };\n\n        bindClick(\".Rk-ZoomOut\", \"zoomOut\");\n        bindClick(\".Rk-ZoomIn\", \"zoomIn\");\n        bindClick(\".Rk-ZoomFit\", \"autoScale\");\n        this.$.find(\".Rk-ZoomSave\").click( function() {\n            // Save scale and offset point\n            _this.renkan.project.addView( { zoom_level:_this.scale, offset:_this.offset } );\n        });\n        this.$.find(\".Rk-ZoomSetSaved\").click( function() {\n            var view = _this.renkan.project.get(\"views\").last();\n            if(view){\n                _this.setScale(view.get(\"zoom_level\"), new paper.Point(view.get(\"offset\")));\n            }\n        });\n        if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){\n            this.$.find(\".Rk-ZoomSetSaved\").show();\n        }\n        this.$.find(\".Rk-CurrentUser\").mouseenter(\n                function() { _this.$.find(\".Rk-UserList\").slideDown(); }\n        );\n        this.$.find(\".Rk-Users\").mouseleave(\n                function() { _this.$.find(\".Rk-UserList\").slideUp(); }\n        );\n        bindClick(\".Rk-FullScreen-Button\", \"fullScreen\");\n        bindClick(\".Rk-AddNode-Button\", \"addNodeBtn\");\n        bindClick(\".Rk-AddEdge-Button\", \"addEdgeBtn\");\n        bindClick(\".Rk-Save-Button\", \"save\");\n        bindClick(\".Rk-Open-Button\", \"open\");\n        bindClick(\".Rk-Export-Button\", \"exportProject\");\n        this.$.find(\".Rk-Bookmarklet-Button\")\n          /*jshint scripturl:true */\n          .attr(\"href\",\"javascript:\" + Utils._BOOKMARKLET_CODE(_renkan))\n          .click(function(){\n              _this.notif_$\n              .text(_renkan.translate(\"Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.\"))\n              .fadeIn()\n              .delay(5000)\n              .fadeOut();\n              return false;\n          });\n        this.$.find(\".Rk-TopBar-Button\").mouseover(function() {\n            $(this).find(\".Rk-TopBar-Tooltip\").show();\n        }).mouseout(function() {\n            $(this).find(\".Rk-TopBar-Tooltip\").hide();\n        });\n        bindClick(\".Rk-Fold-Bins\", \"foldBins\");\n\n        paper.view.onResize = function(_event) {\n            // Because of paper bug which does not calculate the good height (and width a fortiori)\n            // We have to update manually the canvas's height\n            paper.view._viewSize.height =  _event.size.height = _this.canvas_$.parent().height();\n\n            if (_this.minimap) {\n                _this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size);\n                _this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4]));\n                _this.minimap.cliprectangle.fitBounds(_this.minimap.topleft, _this.minimap.size);\n            }\n            _this.redraw();\n        };\n\n        var _thRedraw = _.throttle(function() {\n            _this.redraw();\n        },50);\n\n        this.addRepresentations(\"Node\", this.renkan.project.get(\"nodes\"));\n        this.addRepresentations(\"Edge\", this.renkan.project.get(\"edges\"));\n        this.renkan.project.on(\"change:title\", function() {\n            _this.$.find(\".Rk-PadTitle\").val(_renkan.project.get(\"title\"));\n        });\n\n        this.$.find(\".Rk-PadTitle\").on(\"keyup input paste\", function() {\n            _renkan.project.set({\"title\": $(this).val()});\n        });\n\n        var _thRedrawUsers = _.throttle(function() {\n            _this.redrawUsers();\n        }, 100);\n\n        _thRedrawUsers();\n\n        // register model events\n        this.renkan.project.on(\"add:users remove:users\", _thRedrawUsers);\n\n        this.renkan.project.on(\"add:views remove:views\", function(_node) {\n            if(_this.renkan.project.get('views').length > 0) {\n                _this.$.find(\".Rk-ZoomSetSaved\").show();\n            }\n            else {\n                _this.$.find(\".Rk-ZoomSetSaved\").hide();\n            }\n        });\n\n        this.renkan.project.on(\"add:nodes\", function(_node) {\n            _this.addRepresentation(\"Node\", _node);\n            _thRedraw();\n        });\n        this.renkan.project.on(\"add:edges\", function(_edge) {\n            _this.addRepresentation(\"Edge\", _edge);\n            _thRedraw();\n        });\n        this.renkan.project.on(\"change:title\", function(_model, _title) {\n            var el = _this.$.find(\".Rk-PadTitle\");\n            if (el.is(\"input\")) {\n                if (el.val() !== _title) {\n                    el.val(_title);\n                }\n            } else {\n                el.text(_title);\n            }\n        });\n\n        if (_renkan.options.size_bug_fix) {\n            var _delay = (\n                    typeof _renkan.options.size_bug_fix === \"number\" ?\n                        _renkan.options.size_bug_fix\n                                : 500\n            );\n            window.setTimeout(\n                    function() {\n                        _this.fixSize(true);\n                    },\n                    _delay\n            );\n        }\n\n        if (_renkan.options.force_resize) {\n            $(window).resize(function() {\n                _this.fixSize(false);\n            });\n        }\n\n        if (_renkan.options.show_user_list && _renkan.options.user_color_editable) {\n            var $cpwrapper = this.$.find(\".Rk-Users .Rk-Edit-ColorPicker-Wrapper\"),\n            $cplist = this.$.find(\".Rk-Users .Rk-Edit-ColorPicker\");\n\n            $cpwrapper.hover(\n                    function(_e) {\n                        if (_this.isEditable()) {\n                            _e.preventDefault();\n                            $cplist.show();\n                        }\n                    },\n                    function(_e) {\n                        _e.preventDefault();\n                        $cplist.hide();\n                    }\n            );\n\n            $cplist.find(\"li\").mouseenter(\n                    function(_e) {\n                        if (_this.isEditable()) {\n                            _e.preventDefault();\n                            _this.$.find(\".Rk-CurrentUser-Color\").css(\"background\", $(this).attr(\"data-color\"));\n                        }\n                    }\n            );\n        }\n\n        if (_renkan.options.show_search_field) {\n\n            var lastval = '';\n\n            this.$.find(\".Rk-GraphSearch-Field\").on(\"keyup change paste input\", function() {\n                var $this = $(this),\n                val = $this.val();\n                if (val === lastval) {\n                    return;\n                }\n                lastval = val;\n                if (val.length < 2) {\n                    _renkan.project.get(\"nodes\").each(function(n) {\n                        _this.getRepresentationByModel(n).unhighlight();\n                    });\n                } else {\n                    var rxs = Utils.regexpFromTextOrArray(val);\n                    _renkan.project.get(\"nodes\").each(function(n) {\n                        if (rxs.test(n.get(\"title\")) || rxs.test(n.get(\"description\"))) {\n                            _this.getRepresentationByModel(n).highlight(rxs);\n                        } else {\n                            _this.getRepresentationByModel(n).unhighlight();\n                        }\n                    });\n                }\n            });\n        }\n\n        this.redraw();\n\n        window.setInterval(function() {\n            var _now = new Date().valueOf();\n            _this.delete_list.forEach(function(d) {\n                if (_now >= d.time) {\n                    var el = _renkan.project.get(\"nodes\").findWhere({\"delete_scheduled\":d.id});\n                    if (el) {\n                        project.removeNode(el);\n                    }\n                    el = _renkan.project.get(\"edges\").findWhere({\"delete_scheduled\":d.id});\n                    if (el) {\n                        project.removeEdge(el);\n                    }\n                }\n            });\n            _this.delete_list = _this.delete_list.filter(function(d) {\n                return _renkan.project.get(\"nodes\").findWhere({\"delete_scheduled\":d.id}) || _renkan.project.get(\"edges\").findWhere({\"delete_scheduled\":d.id});\n            });\n        }, 500);\n\n        if (this.minimap) {\n            window.setInterval(function() {\n                _this.rescaleMinimap();\n            }, 2000);\n        }\n\n    };\n\n    _(Scene.prototype).extend({\n        template: _.template(\n                '<% if (options.show_top_bar) { %><div class=\"Rk-TopBar\"><% if (!options.editor_mode) { %><h2 class=\"Rk-PadTitle\"><%- project.get(\"title\") || translate(\"Untitled project\")%></h2>' +\n                '<% } else { %><input type=\"text\" class=\"Rk-PadTitle\" value=\"<%- project.get(\"title\") || \"\" %>\" placeholder=\"<%-translate(\"Untitled project\")%>\" /><% } %>' +\n                '<% if (options.show_user_list) { %><div class=\"Rk-Users\"><div class=\"Rk-CurrentUser\"><div class=\"Rk-Edit-ColorPicker-Wrapper\"><span class=\"Rk-CurrentUser-Color\"><% if (options.user_color_editable) { %><span class=\"Rk-Edit-ColorTip\"></span><% } %></span>' +\n                '<% if (options.user_color_editable) { print(colorPicker) } %></div><span class=\"Rk-CurrentUser-Name\">&lt;unknown user&gt;</span></div><ul class=\"Rk-UserList\"></ul></div><% } %>' +\n                '<% if (options.home_button_url) {%><div class=\"Rk-TopBar-Separator\"></div><a class=\"Rk-TopBar-Button Rk-Home-Button\" href=\"<%- options.home_button_url %>\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\">' +\n                '<%- translate(options.home_button_title) %></div></div></a><% } %>' +\n                '<% if (options.show_fullscreen_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-FullScreen-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Full Screen\")%></div></div></div><% } %>' +\n                '<% if (options.editor_mode) { %>' +\n                '<% if (options.show_addnode_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-AddNode-Button\"><div class=\"Rk-TopBar-Tooltip\">' +\n                '<div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Add Node\")%></div></div></div><% } %>' +\n                '<% if (options.show_addedge_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-AddEdge-Button\"><div class=\"Rk-TopBar-Tooltip\">' +\n                '<div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Add Edge\")%></div></div></div><% } %>' +\n                '<% if (options.show_export_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-Export-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Download Project\")%></div></div></div><% } %>' +\n                '<% if (options.show_save_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-Save-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"> </div></div></div><% } %>' +\n                '<% if (options.show_open_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-Open-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Open Project\")%></div></div></div><% } %>' +\n                '<% if (options.show_bookmarklet) { %><div class=\"Rk-TopBar-Separator\"></div><a class=\"Rk-TopBar-Button Rk-Bookmarklet-Button\" href=\"#\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\">' +\n                '<%-translate(\"Renkan \\'Drag-to-Add\\' bookmarklet\")%></div></div></a><% } %>' +\n                '<% } else { %>' +\n                '<% if (options.show_export_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-Export-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Download Project\")%></div></div></div><div class=\"Rk-TopBar-Separator\"></div><% } %>' +\n                '<% };' +\n                'if (options.show_search_field) { %>' +\n                '<form action=\"#\" class=\"Rk-GraphSearch-Form\"><input type=\"search\" class=\"Rk-GraphSearch-Field\" placeholder=\"<%- translate(\"Search in graph\") %>\" /></form><div class=\"Rk-TopBar-Separator\"></div><% } %></div><% } %>' +\n                '<div class=\"Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>\">' +\n                '<div class=\"Rk-Labels\"></div><canvas class=\"Rk-Canvas\" resize></canvas><div class=\"Rk-Notifications\"></div><div class=\"Rk-Editor\">' +\n                '<% if (options.show_bins) { %><div class=\"Rk-Fold-Bins\">&laquo;</div><% } %>' +\n                '<div class=\"Rk-ZoomButtons\"><div class=\"Rk-ZoomIn\" title=\"<%-translate(\"Zoom In\")%>\"></div><div class=\"Rk-ZoomFit\" title=\"<%-translate(\"Zoom Fit\")%>\"></div><div class=\"Rk-ZoomOut\" title=\"<%-translate(\"Zoom Out\")%>\"></div>' +\n                '<% if (options.editor_mode) { %><div class=\"Rk-ZoomSave\" title=\"<%-translate(\"Zoom Save\")%>\"></div><% } %>' +\n                '<% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %><div class=\"Rk-ZoomSetSaved\" title=\"<%-translate(\"View saved zoom\")%>\"></div><% } %></div>' +\n                '</div></div>'\n        ),\n        fixSize: function(_autoscale) {\n            var w = this.$.width(),\n            h = this.$.height();\n            if (this.renkan.options.show_top_bar) {\n                h -= this.$.find(\".Rk-TopBar\").height();\n            }\n            this.canvas_$.attr({\n                width: w,\n                height: h\n            });\n\n            paper.view.viewSize = new paper.Size([w, h]);\n\n            if (_autoscale) {\n                // If _autoscale, we get the initial view (zoom+offset) set in the project datas.\n                if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){\n                    this.autoScale(this.renkan.project.get(\"views\")[parseInt(this.renkan.options.default_view)]);\n                }\n                else{\n                    this.autoScale();\n                }\n            }\n        },\n        drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {\n            var _options = this.renkan.options,\n            _startRads = _startAngle * Math.PI / 180,\n            _endRads = _endAngle * Math.PI / 180,\n            _img = this.icon_cache[_imgname],\n            _startdx = - Math.sin(_startRads),\n            _startdy = Math.cos(_startRads),\n            _startXIn = Math.cos(_startRads) * _inR + _padding * _startdx,\n            _startYIn = Math.sin(_startRads) * _inR + _padding * _startdy,\n            _startXOut = Math.cos(_startRads) * _outR + _padding * _startdx,\n            _startYOut = Math.sin(_startRads) * _outR + _padding * _startdy,\n            _enddx = - Math.sin(_endRads),\n            _enddy = Math.cos(_endRads),\n            _endXIn = Math.cos(_endRads) * _inR - _padding * _enddx,\n            _endYIn = Math.sin(_endRads) * _inR - _padding * _enddy,\n            _endXOut = Math.cos(_endRads) * _outR - _padding * _enddx,\n            _endYOut = Math.sin(_endRads) * _outR - _padding * _enddy,\n            _centerR = (_inR + _outR) / 2,\n            _centerRads = (_startRads + _endRads) / 2,\n            _centerX = Math.cos(_centerRads) * _centerR,\n            _centerY = Math.sin(_centerRads) * _centerR,\n            _centerXIn = Math.cos(_centerRads) * _inR,\n            _centerXOut = Math.cos(_centerRads) * _outR,\n            _centerYIn = Math.sin(_centerRads) * _inR,\n            _centerYOut = Math.sin(_centerRads) * _outR,\n            _textX = Math.cos(_centerRads) * (_outR + 3),\n            _textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2;\n            this.buttons_layer.activate();\n            var _path = new paper.Path();\n            _path.add([_startXIn, _startYIn]);\n            _path.arcTo([_centerXIn, _centerYIn], [_endXIn, _endYIn]);\n            _path.lineTo([_endXOut,  _endYOut]);\n            _path.arcTo([_centerXOut, _centerYOut], [_startXOut, _startYOut]);\n            _path.fillColor = _options.buttons_background;\n            _path.opacity = 0.5;\n            _path.closed = true;\n            _path.__representation = _repr;\n            var _text = new paper.PointText(_textX,_textY);\n            _text.characterStyle = {\n                    fontSize: _options.buttons_label_font_size,\n                    fillColor: _options.buttons_label_color\n            };\n            if (_textX > 2) {\n                _text.paragraphStyle.justification = 'left';\n            } else if (_textX < -2) {\n                _text.paragraphStyle.justification = 'right';\n            } else {\n                _text.paragraphStyle.justification = 'center';\n            }\n            _text.visible = false;\n            var _visible = false,\n            _restPos = new paper.Point(-200, -200),\n            _grp = new paper.Group([_path, _text]),\n            _delta = _grp.position,\n            _imgdelta = new paper.Point([_centerX, _centerY]),\n            _currentPos = new paper.Point(0,0);\n            _text.content = _caption;\n            _grp.visible = false;\n            _grp.position = _restPos;\n            var _res = {\n                    show: function() {\n                        _visible = true;\n                        _grp.position = _currentPos.add(_delta);\n                        _grp.visible = true;\n                    },\n                    moveTo: function(_point) {\n                        _currentPos = _point;\n                        if (_visible) {\n                            _grp.position = _point.add(_delta);\n                        }\n                    },\n                    hide: function() {\n                        _visible = false;\n                        _grp.visible = false;\n                        _grp.position = _restPos;\n                    },\n                    select: function() {\n                        _path.opacity = 0.8;\n                        _text.visible = true;\n                    },\n                    unselect: function() {\n                        _path.opacity = 0.5;\n                        _text.visible = false;\n                    },\n                    destroy: function() {\n                        _grp.remove();\n                    }\n            };\n            var showImage = function() {\n                var _raster = new paper.Raster(_img);\n                _raster.position = _imgdelta.add(_grp.position).subtract(_delta);\n                _raster.locked = true; // Disable mouse events on icon\n                _grp.addChild(_raster);\n            };\n            if (_img.width) {\n                showImage();\n            } else {\n                $(_img).on(\"load\",showImage);\n            }\n\n            return _res;\n        },\n        addToBundles: function(_edgeRepr) {\n            var _bundle = _(this.bundles).find(function(_bundle) {\n                return (\n                        ( _bundle.from === _edgeRepr.from_representation && _bundle.to === _edgeRepr.to_representation ) ||\n                        ( _bundle.from === _edgeRepr.to_representation && _bundle.to === _edgeRepr.from_representation )\n                );\n            });\n            if (typeof _bundle !== \"undefined\") {\n                _bundle.edges.push(_edgeRepr);\n            } else {\n                _bundle = {\n                        from: _edgeRepr.from_representation,\n                        to: _edgeRepr.to_representation,\n                        edges: [ _edgeRepr ],\n                        getPosition: function(_er) {\n                            var _dir = (_er.from_representation === this.from) ? 1 : -1;\n                            return _dir * ( _(this.edges).indexOf(_er) - (this.edges.length - 1) / 2 );\n                        }\n                };\n                this.bundles.push(_bundle);\n            }\n            return _bundle;\n        },\n        isEditable: function() {\n            return (this.renkan.options.editor_mode && !this.renkan.read_only);\n        },\n        onStatusChange: function() {\n            var savebtn = this.$.find(\".Rk-Save-Button\"),\n            tip = savebtn.find(\".Rk-TopBar-Tooltip-Contents\");\n            if (this.renkan.read_only) {\n                savebtn.removeClass(\"disabled Rk-Save-Online\").addClass(\"Rk-Save-ReadOnly\");\n                tip.text(this.renkan.translate(\"Connection lost\"));\n            } else {\n                if (this.renkan.options.snapshot_mode) {\n                    savebtn.removeClass(\"Rk-Save-ReadOnly Rk-Save-Online\");\n                    tip.text(this.renkan.translate(\"Save Project\"));\n                } else {\n                    savebtn.removeClass(\"disabled Rk-Save-ReadOnly\").addClass(\"Rk-Save-Online\");\n                    tip.text(this.renkan.translate(\"Auto-save enabled\"));\n                }\n            }\n            this.redrawUsers();\n        },\n        setScale: function(_newScale, _offset) {\n            if ((_newScale/this.initialScale) > Utils._MIN_SCALE && (_newScale/this.initialScale) < Utils._MAX_SCALE) {\n                this.scale = _newScale;\n                if (_offset) {\n                    this.offset = _offset;\n                }\n                this.redraw();\n            }\n        },\n        autoScale: function(force_view) {\n            var nodes = this.renkan.project.get(\"nodes\");\n            if (nodes.length > 1) {\n                var _xx = nodes.map(function(_node) { return _node.get(\"position\").x; }),\n                _yy = nodes.map(function(_node) { return _node.get(\"position\").y; }),\n                _minx = Math.min.apply(Math, _xx),\n                _miny = Math.min.apply(Math, _yy),\n                _maxx = Math.max.apply(Math, _xx),\n                _maxy = Math.max.apply(Math, _yy);\n                var _scale = Math.min( (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny));\n                this.initialScale = _scale;\n                // Override calculated scale if asked\n                if((typeof force_view !== \"undefined\") && parseFloat(force_view.zoom_level)>0 && parseFloat(force_view.offset.x)>0 && parseFloat(force_view.offset.y)>0){\n                    this.setScale(parseFloat(force_view.zoom_level), new paper.Point(parseFloat(force_view.offset.x), parseFloat(force_view.offset.y)));\n                }\n                else{\n                    this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)));\n                }\n            }\n            if (nodes.length === 1) {\n                this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get(\"position\").x, nodes.at(0).get(\"position\").y])));\n            }\n        },\n        redrawMiniframe: function() {\n            var topleft = this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))),\n            bottomright = this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight));\n            this.minimap.miniframe.fitBounds(topleft, bottomright);\n        },\n        rescaleMinimap: function() {\n            var nodes = this.renkan.project.get(\"nodes\");\n            if (nodes.length > 1) {\n                var _xx = nodes.map(function(_node) { return _node.get(\"position\").x; }),\n                _yy = nodes.map(function(_node) { return _node.get(\"position\").y; }),\n                _minx = Math.min.apply(Math, _xx),\n                _miny = Math.min.apply(Math, _yy),\n                _maxx = Math.max.apply(Math, _xx),\n                _maxy = Math.max.apply(Math, _yy);\n                var _scale = Math.min(\n                        this.scale * 0.8 * this.renkan.options.minimap_width / paper.view.bounds.width,\n                        this.scale * 0.8 * this.renkan.options.minimap_height / paper.view.bounds.height,\n                        ( this.renkan.options.minimap_width - 2 * this.renkan.options.minimap_padding ) / (_maxx - _minx),\n                        ( this.renkan.options.minimap_height - 2 * this.renkan.options.minimap_padding ) / (_maxy - _miny)\n                );\n                this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale));\n                this.minimap.scale = _scale;\n            }\n            if (nodes.length === 1) {\n                this.minimap.scale = 0.1;\n                this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([nodes.at(0).get(\"position\").x, nodes.at(0).get(\"position\").y]).multiply(this.minimap.scale));\n            }\n            this.redraw();\n        },\n        toPaperCoords: function(_point) {\n            return _point.multiply(this.scale).add(this.offset);\n        },\n        toMinimapCoords: function(_point) {\n            return _point.multiply(this.minimap.scale).add(this.minimap.offset).add(this.minimap.topleft);\n        },\n        toModelCoords: function(_point) {\n            return _point.subtract(this.offset).divide(this.scale);\n        },\n        addRepresentation: function(_type, _model) {\n            var RendererType = requtils.getRenderer()[_type];\n            var _repr = new RendererType(this, _model);\n            this.representations.push(_repr);\n            return _repr;\n        },\n        addRepresentations: function(_type, _collection) {\n            var _this = this;\n            _collection.forEach(function(_model) {\n                _this.addRepresentation(_type, _model);\n            });\n        },\n        userTemplate: _.template(\n                '<li class=\"Rk-User\"><span class=\"Rk-UserColor\" style=\"background:<%=background%>;\"></span><%=name%></li>'\n        ),\n        redrawUsers: function() {\n            if (!this.renkan.options.show_user_list) {\n                return;\n            }\n            var allUsers = [].concat((this.renkan.project.current_user_list || {}).models || [], (this.renkan.project.get(\"users\") || {}).models || []),\n            ulistHtml = '',\n            $userpanel = this.$.find(\".Rk-Users\"),\n            $name = $userpanel.find(\".Rk-CurrentUser-Name\"),\n            $cpitems = $userpanel.find(\".Rk-Edit-ColorPicker li\"),\n            $colorsquare = $userpanel.find(\".Rk-CurrentUser-Color\"),\n            _this = this;\n            $name.off(\"click\").text(this.renkan.translate(\"<unknown user>\"));\n            $cpitems.off(\"mouseleave click\");\n            allUsers.forEach(function(_user) {\n                if (_user.get(\"_id\") === _this.renkan.current_user) {\n                    $name.text(_user.get(\"title\"));\n                    $colorsquare.css(\"background\", _user.get(\"color\"));\n                    if (_this.isEditable()) {\n\n                        if (_this.renkan.options.user_name_editable) {\n                            $name.click(function() {\n                                var $this = $(this),\n                                $input = $('<input>').val(_user.get(\"title\")).blur(function() {\n                                    _user.set(\"title\", $(this).val());\n                                    _this.redrawUsers();\n                                    _this.redraw();\n                                });\n                                $this.empty().html($input);\n                                $input.select();\n                            });\n                        }\n\n                        if (_this.renkan.options.user_color_editable) {\n                            $cpitems.click(\n                                    function(_e) {\n                                        _e.preventDefault();\n                                        if (_this.isEditable()) {\n                                            _user.set(\"color\", $(this).attr(\"data-color\"));\n                                        }\n                                        $(this).parent().hide();\n                                    }\n                            ).mouseleave(function() {\n                                $colorsquare.css(\"background\", _user.get(\"color\"));\n                            });\n                        }\n                    }\n\n                } else {\n                    ulistHtml += _this.userTemplate({\n                        name: _user.get(\"title\"),\n                        background: _user.get(\"color\")\n                    });\n                }\n            });\n            $userpanel.find(\".Rk-UserList\").html(ulistHtml);\n        },\n        removeRepresentation: function(_representation) {\n            _representation.destroy();\n            this.representations = _(this.representations).reject(\n                    function(_repr) {\n                        return _repr === _representation;\n                    }\n            );\n        },\n        getRepresentationByModel: function(_model) {\n            if (!_model) {\n                return undefined;\n            }\n            return _(this.representations).find(function(_repr) {\n                return _repr.model === _model;\n            });\n        },\n        removeRepresentationsOfType: function(_type) {\n            var _representations = _(this.representations).filter(function(_repr) {\n                return _repr.type === _type;\n            }),\n            _this = this;\n            _(_representations).each(function(_repr) {\n                _this.removeRepresentation(_repr);\n            });\n        },\n        highlightModel: function(_model) {\n            var _repr = this.getRepresentationByModel(_model);\n            if (_repr) {\n                _repr.highlight();\n            }\n        },\n        unhighlightAll: function(_model) {\n            _(this.representations).each(function(_repr) {\n                _repr.unhighlight();\n            });\n        },\n        unselectAll: function(_model) {\n            _(this.representations).each(function(_repr) {\n                _repr.unselect();\n            });\n        },\n        redraw: function() {\n            if(! this.redrawActive ) {\n                return;\n            }\n            _(this.representations).each(function(_representation) {\n                _representation.redraw(true);\n            });\n            if (this.minimap) {\n                this.redrawMiniframe();\n            }\n            paper.view.draw();\n        },\n        addTempEdge: function(_from, _point) {\n            var _tmpEdge = this.addRepresentation(\"TempEdge\",null);\n            _tmpEdge.end_pos = _point;\n            _tmpEdge.from_representation = _from;\n            _tmpEdge.redraw();\n            this.click_target = _tmpEdge;\n        },\n        findTarget: function(_hitResult) {\n            if (_hitResult && typeof _hitResult.item.__representation !== \"undefined\") {\n                var _newTarget = _hitResult.item.__representation;\n                if (this.selected_target !== _hitResult.item.__representation) {\n                    if (this.selected_target) {\n                        this.selected_target.unselect(_newTarget);\n                    }\n                    _newTarget.select(this.selected_target);\n                    this.selected_target = _newTarget;\n                }\n            } else {\n                if (this.selected_target) {\n                    this.selected_target.unselect();\n                }\n                this.selected_target = null;\n            }\n        },\n        paperShift: function(_delta) {\n            this.offset = this.offset.add(_delta);\n            this.redraw();\n        },\n        onMouseMove: function(_event) {\n            var _off = this.canvas_$.offset(),\n            _point = new paper.Point([\n                                      _event.pageX - _off.left,\n                                      _event.pageY - _off.top\n                                      ]),\n                                      _delta = _point.subtract(this.last_point);\n            this.last_point = _point;\n            if (!this.is_dragging && this.mouse_down && _delta.length > Utils._MIN_DRAG_DISTANCE) {\n                this.is_dragging = true;\n            }\n            var _hitResult = paper.project.hitTest(_point);\n            if (this.is_dragging) {\n                if (this.click_target && typeof this.click_target.paperShift === \"function\") {\n                    this.click_target.paperShift(_delta);\n                } else {\n                    this.paperShift(_delta);\n                }\n            } else {\n                this.findTarget(_hitResult);\n            }\n            paper.view.draw();\n        },\n        onMouseDown: function(_event, _isTouch) {\n            var _off = this.canvas_$.offset(),\n            _point = new paper.Point([\n                                      _event.pageX - _off.left,\n                                      _event.pageY - _off.top\n                                      ]);\n            this.last_point = _point;\n            this.mouse_down = true;\n            if (!this.click_target || this.click_target.type !== \"Temp-edge\") {\n                this.removeRepresentationsOfType(\"editor\");\n                this.is_dragging = false;\n                var _hitResult = paper.project.hitTest(_point);\n                if (_hitResult && typeof _hitResult.item.__representation !== \"undefined\") {\n                    this.click_target = _hitResult.item.__representation;\n                    this.click_target.mousedown(_event, _isTouch);\n                } else {\n                    this.click_target = null;\n                    if (this.isEditable() && this.click_mode === Utils._CLICKMODE_ADDNODE) {\n                        var _coords = this.toModelCoords(_point),\n                        _data = {\n                            id: Utils.getUID('node'),\n                            created_by: this.renkan.current_user,\n                            position: {\n                                x: _coords.x,\n                                y: _coords.y\n                            }\n                        };\n                        _node = this.renkan.project.addNode(_data);\n                        this.getRepresentationByModel(_node).openEditor();\n                    }\n                }\n            }\n            if (this.click_mode) {\n                if (this.isEditable() && this.click_mode === Utils._CLICKMODE_STARTEDGE && this.click_target && this.click_target.type === \"Node\") {\n                    this.removeRepresentationsOfType(\"editor\");\n                    this.addTempEdge(this.click_target, _point);\n                    this.click_mode = Utils._CLICKMODE_ENDEDGE;\n                    this.notif_$.fadeOut(function() {\n                        $(this).html(this.renkan.translate(\"Click on a second node to complete the edge\")).fadeIn();\n                    });\n                } else {\n                    this.notif_$.hide();\n                    this.click_mode = false;\n                }\n            }\n            paper.view.draw();\n        },\n        onMouseUp: function(_event, _isTouch) {\n            this.mouse_down = false;\n            if (this.click_target) {\n                var _off = this.canvas_$.offset();\n                this.click_target.mouseup(\n                        {\n                            point: new paper.Point([\n                                                    _event.pageX - _off.left,\n                                                    _event.pageY - _off.top\n                                                    ])\n                        },\n                        _isTouch\n                );\n            } else {\n                this.click_target = null;\n                this.is_dragging = false;\n                if (_isTouch) {\n                    this.unselectAll();\n                }\n            }\n            paper.view.draw();\n        },\n        onScroll: function(_event, _scrolldelta) {\n            this.totalScroll += _scrolldelta;\n            if (Math.abs(this.totalScroll) >= 1) {\n                var _off = this.canvas_$.offset(),\n                _delta = new paper.Point([\n                                          _event.pageX - _off.left,\n                                          _event.pageY - _off.top\n                                          ]).subtract(this.offset).multiply( Math.SQRT2 - 1 );\n                if (this.totalScroll > 0) {\n                    this.setScale( this.scale * Math.SQRT2, this.offset.subtract(_delta) );\n                } else {\n                    this.setScale( this.scale * Math.SQRT1_2, this.offset.add(_delta.divide(Math.SQRT2)));\n                }\n                this.totalScroll = 0;\n            }\n        },\n        onDoubleClick: function(_event) {\n            if (!this.isEditable()) {\n                return;\n            }\n            var _off = this.canvas_$.offset(),\n            _point = new paper.Point([\n                                      _event.pageX - _off.left,\n                                      _event.pageY - _off.top\n                                      ]);\n            var _hitResult = paper.project.hitTest(_point);\n            if (this.isEditable() && (!_hitResult || typeof _hitResult.item.__representation === \"undefined\")) {\n                var _coords = this.toModelCoords(_point),\n                _data = {\n                    id: Utils.getUID('node'),\n                    created_by: this.renkan.current_user,\n                    position: {\n                        x: _coords.x,\n                        y: _coords.y\n                    }\n                },\n                _node = this.renkan.project.addNode(_data);\n                this.getRepresentationByModel(_node).openEditor();\n            }\n            paper.view.draw();\n        },\n        defaultDropHandler: function(_data) {\n            var newNode = {};\n            var snippet = \"\";\n            switch(_data[\"text/x-iri-specific-site\"]) {\n                case \"twitter\":\n                    snippet = $('<div>').html(_data[\"text/x-iri-selected-html\"]);\n                    var tweetdiv = snippet.find(\".tweet\");\n                    newNode.title = this.renkan.translate(\"Tweet by \") + tweetdiv.attr(\"data-name\");\n                    newNode.uri = \"http://twitter.com/\" + tweetdiv.attr(\"data-screen-name\") + \"/status/\" + tweetdiv.attr(\"data-tweet-id\");\n                    newNode.image = tweetdiv.find(\".avatar\").attr(\"src\");\n                    newNode.description = tweetdiv.find(\".js-tweet-text:first\").text();\n                    break;\n                case \"google\":\n                    snippet = $('<div>').html(_data[\"text/x-iri-selected-html\"]);\n                    newNode.title = snippet.find(\"h3:first\").text().trim();\n                    newNode.uri = snippet.find(\"h3 a\").attr(\"href\");\n                    newNode.description = snippet.find(\".st:first\").text().trim();\n                    break;\n                default:\n                    if (_data[\"text/x-iri-source-uri\"]) {\n                        newNode.uri = _data[\"text/x-iri-source-uri\"];\n                    }\n            }\n            if (_data[\"text/plain\"] || _data[\"text/x-iri-selected-text\"]) {\n                newNode.description = (_data[\"text/plain\"] || _data[\"text/x-iri-selected-text\"]).replace(/[\\s\\n]+/gm,' ').trim();\n            }\n            if (_data[\"text/html\"] || _data[\"text/x-iri-selected-html\"]) {\n                snippet = $('<div>').html(_data[\"text/html\"] || _data[\"text/x-iri-selected-html\"]);\n                var _svgimgs = snippet.find(\"image\");\n                if (_svgimgs.length) {\n                    newNode.image = _svgimgs.attr(\"xlink:href\");\n                }\n                var _svgpaths = snippet.find(\"path\");\n                if (_svgpaths.length) {\n                    newNode.clipPath = _svgpaths.attr(\"d\");\n                }\n                var _imgs = snippet.find(\"img\");\n                if (_imgs.length) {\n                    newNode.image = _imgs[0].src;\n                }\n                var _as = snippet.find(\"a\");\n                if (_as.length) {\n                    newNode.uri = _as[0].href;\n                }\n                newNode.title = snippet.find(\"[title]\").attr(\"title\") || newNode.title;\n                newNode.description = snippet.text().replace(/[\\s\\n]+/gm,' ').trim();\n            }\n            if (_data[\"text/uri-list\"]) {\n                newNode.uri = _data[\"text/uri-list\"];\n            }\n            if (_data[\"text/x-moz-url\"] && !newNode.title) {\n                newNode.title = (_data[\"text/x-moz-url\"].split(\"\\n\")[1] || \"\").trim();\n                if (newNode.title === newNode.uri) {\n                    newNode.title = false;\n                }\n            }\n            if (_data[\"text/x-iri-source-title\"] && !newNode.title) {\n                newNode.title = _data[\"text/x-iri-source-title\"];\n            }\n            if (_data[\"text/html\"] || _data[\"text/x-iri-selected-html\"]) {\n                snippet = $('<div>').html(_data[\"text/html\"] || _data[\"text/x-iri-selected-html\"]);\n                newNode.image = snippet.find(\"[data-image]\").attr(\"data-image\") || newNode.image;\n                newNode.uri = snippet.find(\"[data-uri]\").attr(\"data-uri\") || newNode.uri;\n                newNode.title = snippet.find(\"[data-title]\").attr(\"data-title\") || newNode.title;\n                newNode.description = snippet.find(\"[data-description]\").attr(\"data-description\") || newNode.description;\n                newNode.clipPath = snippet.find(\"[data-clip-path]\").attr(\"data-clip-path\") || newNode.clipPath;\n            }\n\n            if (!newNode.title) {\n                newNode.title = this.renkan.translate(\"Dragged resource\");\n            }\n            var fields = [\"title\", \"description\", \"uri\", \"image\"];\n            for (var i = 0; i < fields.length; i++) {\n                var f = fields[i];\n                if (_data[\"text/x-iri-\" + f] || _data[f]) {\n                    newNode[f] = _data[\"text/x-iri-\" + f] || _data[f];\n                }\n                if (newNode[f] === \"none\" || newNode[f] === \"null\") {\n                    newNode[f] = undefined;\n                }\n            }\n\n            if(typeof this.renkan.options.drop_enhancer === \"function\"){\n                newNode = this.renkan.options.drop_enhancer(newNode, _data);\n            }\n\n            return newNode;\n\n        },\n        dropData: function(_data, _event) {\n            if (!this.isEditable()) {\n                return;\n            }\n            if (_data[\"text/json\"] || _data[\"application/json\"]) {\n                try {\n                    var jsondata = JSON.parse(_data[\"text/json\"] || _data[\"application/json\"]);\n                    _(_data).extend(jsondata);\n                }\n                catch(e) {}\n            }\n\n            var newNode = (typeof this.renkan.options.drop_handler === \"undefined\")?this.defaultDropHandler(_data):this.renkan.options.drop_handler(_data);\n\n            var _off = this.canvas_$.offset(),\n            _point = new paper.Point([\n                                      _event.pageX - _off.left,\n                                      _event.pageY - _off.top\n                                      ]),\n                                      _coords = this.toModelCoords(_point),\n                                      _nodedata = {\n                id: Utils.getUID('node'),\n                created_by: this.renkan.current_user,\n                uri: newNode.uri || \"\",\n                title: newNode.title || \"\",\n                description: newNode.description || \"\",\n                image: newNode.image || \"\",\n                color: newNode.color || undefined,\n                clip_path: newNode.clipPath || undefined,\n                position: {\n                    x: _coords.x,\n                    y: _coords.y\n                }\n            };\n            var _node = this.renkan.project.addNode(_nodedata),\n            _repr = this.getRepresentationByModel(_node);\n            if (_event.type === \"drop\") {\n                _repr.openEditor();\n            }\n        },\n        fullScreen: function() {\n            var _isFull = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen,\n              _el = this.renkan.$[0],\n              _requestMethods = [\"requestFullScreen\",\"mozRequestFullScreen\",\"webkitRequestFullScreen\"],\n              _cancelMethods = [\"cancelFullScreen\",\"mozCancelFullScreen\",\"webkitCancelFullScreen\"],\n              i;\n            if (_isFull) {\n                for (i = 0; i < _cancelMethods.length; i++) {\n                    if (typeof document[_cancelMethods[i]] === \"function\") {\n                        document[_cancelMethods[i]]();\n                        break;\n                    }\n                }\n            } else {\n                for (i = 0; i < _requestMethods.length; i++) {\n                    if (typeof _el[_requestMethods[i]] === \"function\") {\n                        _el[_requestMethods[i]]();\n                        break;\n                    }\n                }\n            }\n        },\n        zoomOut: function() {\n            var _newScale = this.scale * Math.SQRT1_2,\n            _offset = new paper.Point([\n                                       this.canvas_$.width(),\n                                       this.canvas_$.height()\n                                       ]).multiply( 0.5 * ( 1 - Math.SQRT1_2 ) ).add(this.offset.multiply( Math.SQRT1_2 ));\n            this.setScale( _newScale, _offset );\n        },\n        zoomIn: function() {\n            var _newScale = this.scale * Math.SQRT2,\n            _offset = new paper.Point([\n                                       this.canvas_$.width(),\n                                       this.canvas_$.height()\n                                       ]).multiply( 0.5 * ( 1 - Math.SQRT2 ) ).add(this.offset.multiply( Math.SQRT2 ));\n            this.setScale( _newScale, _offset );\n        },\n        addNodeBtn: function() {\n            if (this.click_mode === Utils._CLICKMODE_ADDNODE) {\n                this.click_mode = false;\n                this.notif_$.hide();\n            } else {\n                this.click_mode = Utils._CLICKMODE_ADDNODE;\n                this.notif_$.text(this.renkan.translate(\"Click on the background canvas to add a node\")).fadeIn();\n            }\n            return false;\n        },\n        addEdgeBtn: function() {\n            if (this.click_mode === Utils._CLICKMODE_STARTEDGE || this.click_mode === Utils._CLICKMODE_ENDEDGE) {\n                this.click_mode = false;\n                this.notif_$.hide();\n            } else {\n                this.click_mode = Utils._CLICKMODE_STARTEDGE;\n                this.notif_$.text(this.renkan.translate(\"Click on a first node to start the edge\")).fadeIn();\n            }\n            return false;\n        },\n        exportProject: function() {\n          var projectJSON = this.renkan.project.toJSON(),\n              downloadLink = document.createElement(\"a\"),\n              projectId = projectJSON.id,\n              fileNameToSaveAs = projectId + \".json\";\n\n          // clean ids\n          delete projectJSON.id;\n          delete projectJSON._id;\n          delete projectJSON.space_id;\n\n          var objId;\n          var idsMap = {};\n\n          _.each(projectJSON.nodes, function(e,i,l) {\n            objId = e.id || e._id;\n            delete e._id;\n            delete e.id;\n            idsMap[objId] = e['@id'] = Utils.getUUID4();\n          });\n          _.each(projectJSON.edges, function(e,i,l) {\n            delete e._id;\n            delete e.id;\n            e.to = idsMap[e.to];\n            e.from = idsMap[e.from];\n          });\n          _.each(projectJSON.views, function(e,i,l) {\n            objId = e.id || e._id;\n            delete e._id;\n            delete e.id;\n          });\n          projectJSON.users = [];\n\n          var projectJSONStr = JSON.stringify(projectJSON, null, 2);\n          var blob = new Blob([projectJSONStr], {type: \"application/json;charset=utf-8\"});\n          filesaver(blob,fileNameToSaveAs);\n\n        },\n        foldBins: function() {\n            var foldBinsButton = this.$.find(\".Rk-Fold-Bins\"),\n            bins = this.renkan.$.find(\".Rk-Bins\");\n            var _this = this;\n            if (bins.offset().left < 0) {\n                bins.animate({left: 0},250);\n                this.$.animate({left: 300},250,function() {\n                    var w = _this.$.width();\n                    paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);\n                });\n                foldBinsButton.html(\"&laquo;\");\n            } else {\n                bins.animate({left: -300},250);\n                this.$.animate({left: 0},250,function() {\n                    var w = _this.$.width();\n                    paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);\n                });\n                foldBinsButton.html(\"&raquo;\");\n            }\n        },\n        save: function() { },\n        open: function() { }\n    });\n\n    /* Scene End */\n\n    return Scene;\n\n});\n\n\n//Load modules and use them\nif( typeof require.config === \"function\" ) {\n    require.config({\n        paths: {\n            'jquery':'../lib/jquery.min',\n            'underscore':'../lib/underscore-min',\n            'filesaver' :'../lib/FileSaver',\n            'requtils':'require-utils'\n        }\n    });\n}\n\nrequire(['renderer/baserepresentation',\n         'renderer/basebutton',\n         'renderer/noderepr',\n         'renderer/edge',\n         'renderer/tempedge',\n         'renderer/baseeditor',\n         'renderer/nodeeditor',\n         'renderer/edgeeditor',\n         'renderer/nodebutton',\n         'renderer/nodeeditbutton',\n         'renderer/noderemovebutton',\n         'renderer/noderevertbutton',\n         'renderer/nodelinkbutton',\n         'renderer/nodeenlargebutton',\n         'renderer/nodeshrinkbutton',\n         'renderer/edgeeditbutton',\n         'renderer/edgeremovebutton',\n         'renderer/edgerevertbutton',\n         'renderer/miniframe',\n         'renderer/scene'\n         ], function(BaseRepresentation, BaseButton, NodeRepr, Edge, TempEdge, BaseEditor, NodeEditor, EdgeEditor, NodeButton, NodeEditButton, NodeRemoveButton, NodeRevertButton, NodeLinkButton, NodeEnlargeButton, NodeShrinkButton, EdgeEditButton, EdgeRemoveButton, EdgeRevertButton, MiniFrame, Scene){\n\n    \n\n    var Rkns = window.Rkns;\n\n    if(typeof Rkns.Renderer === \"undefined\"){\n        Rkns.Renderer = {};\n    }\n    var Renderer = Rkns.Renderer;\n\n    Renderer._BaseRepresentation = BaseRepresentation;\n    Renderer._BaseButton = BaseButton;\n    Renderer.Node = NodeRepr;\n    Renderer.Edge = Edge;\n    Renderer.TempEdge = TempEdge;\n    Renderer._BaseEditor = BaseEditor;\n    Renderer.NodeEditor = NodeEditor;\n    Renderer.EdgeEditor = EdgeEditor;\n    Renderer._NodeButton = NodeButton;\n    Renderer.NodeEditButton = NodeEditButton;\n    Renderer.NodeRemoveButton = NodeRemoveButton;\n    Renderer.NodeRevertButton = NodeRevertButton;\n    Renderer.NodeLinkButton = NodeLinkButton;\n    Renderer.NodeEnlargeButton = NodeEnlargeButton;\n    Renderer.NodeShrinkButton = NodeShrinkButton;\n    Renderer.EdgeEditButton = EdgeEditButton;\n    Renderer.EdgeRemoveButton = EdgeRemoveButton;\n    Renderer.EdgeRevertButton = EdgeRevertButton;\n    Renderer.MiniFrame = MiniFrame;\n    Renderer.Scene = Scene;\n    \n    startRenkan();\n});\n\ndefine(\"main-renderer\", function(){});\n\n"]}
\ No newline at end of file
--- a/src/hdalab/static/hdalab/lib/require.js	Fri Jul 18 13:29:53 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- RequireJS 2.1.11 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
- Available via the MIT or new BSD license.
- see: http://github.com/jrburke/requirejs for details
-*/
-var requirejs,require,define;
-(function(ca){function G(b){return"[object Function]"===M.call(b)}function H(b){return"[object Array]"===M.call(b)}function v(b,c){if(b){var d;for(d=0;d<b.length&&(!b[d]||!c(b[d],d,b));d+=1);}}function U(b,c){if(b){var d;for(d=b.length-1;-1<d&&(!b[d]||!c(b[d],d,b));d-=1);}}function s(b,c){return ga.call(b,c)}function j(b,c){return s(b,c)&&b[c]}function B(b,c){for(var d in b)if(s(b,d)&&c(b[d],d))break}function V(b,c,d,g){c&&B(c,function(c,h){if(d||!s(b,h))g&&"object"===typeof c&&c&&!H(c)&&!G(c)&&!(c instanceof
-RegExp)?(b[h]||(b[h]={}),V(b[h],c,d,g)):b[h]=c});return b}function t(b,c){return function(){return c.apply(b,arguments)}}function da(b){throw b;}function ea(b){if(!b)return b;var c=ca;v(b.split("."),function(b){c=c[b]});return c}function C(b,c,d,g){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=g;d&&(c.originalError=d);return c}function ha(b){function c(a,e,b){var f,n,c,d,g,h,i,I=e&&e.split("/");n=I;var m=l.map,k=m&&m["*"];if(a&&"."===a.charAt(0))if(e){n=
-I.slice(0,I.length-1);a=a.split("/");e=a.length-1;l.nodeIdCompat&&R.test(a[e])&&(a[e]=a[e].replace(R,""));n=a=n.concat(a);d=n.length;for(e=0;e<d;e++)if(c=n[e],"."===c)n.splice(e,1),e-=1;else if(".."===c)if(1===e&&(".."===n[2]||".."===n[0]))break;else 0<e&&(n.splice(e-1,2),e-=2);a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if(b&&m&&(I||k)){n=a.split("/");e=n.length;a:for(;0<e;e-=1){d=n.slice(0,e).join("/");if(I)for(c=I.length;0<c;c-=1)if(b=j(m,I.slice(0,c).join("/")))if(b=j(b,d)){f=b;
-g=e;break a}!h&&(k&&j(k,d))&&(h=j(k,d),i=e)}!f&&h&&(f=h,g=i);f&&(n.splice(0,g,f),a=n.join("/"))}return(f=j(l.pkgs,a))?f:a}function d(a){z&&v(document.getElementsByTagName("script"),function(e){if(e.getAttribute("data-requiremodule")===a&&e.getAttribute("data-requirecontext")===i.contextName)return e.parentNode.removeChild(e),!0})}function g(a){var e=j(l.paths,a);if(e&&H(e)&&1<e.length)return e.shift(),i.require.undef(a),i.require([a]),!0}function u(a){var e,b=a?a.indexOf("!"):-1;-1<b&&(e=a.substring(0,
-b),a=a.substring(b+1,a.length));return[e,a]}function m(a,e,b,f){var n,d,g=null,h=e?e.name:null,l=a,m=!0,k="";a||(m=!1,a="_@r"+(M+=1));a=u(a);g=a[0];a=a[1];g&&(g=c(g,h,f),d=j(p,g));a&&(g?k=d&&d.normalize?d.normalize(a,function(a){return c(a,h,f)}):c(a,h,f):(k=c(a,h,f),a=u(k),g=a[0],k=a[1],b=!0,n=i.nameToUrl(k)));b=g&&!d&&!b?"_unnormalized"+(Q+=1):"";return{prefix:g,name:k,parentMap:e,unnormalized:!!b,url:n,originalName:l,isDefine:m,id:(g?g+"!"+k:k)+b}}function q(a){var e=a.id,b=j(k,e);b||(b=k[e]=new i.Module(a));
-return b}function r(a,e,b){var f=a.id,n=j(k,f);if(s(p,f)&&(!n||n.defineEmitComplete))"defined"===e&&b(p[f]);else if(n=q(a),n.error&&"error"===e)b(n.error);else n.on(e,b)}function w(a,e){var b=a.requireModules,f=!1;if(e)e(a);else if(v(b,function(e){if(e=j(k,e))e.error=a,e.events.error&&(f=!0,e.emit("error",a))}),!f)h.onError(a)}function x(){S.length&&(ia.apply(A,[A.length,0].concat(S)),S=[])}function y(a){delete k[a];delete W[a]}function F(a,e,b){var f=a.map.id;a.error?a.emit("error",a.error):(e[f]=
-!0,v(a.depMaps,function(f,c){var d=f.id,g=j(k,d);g&&(!a.depMatched[c]&&!b[d])&&(j(e,d)?(a.defineDep(c,p[d]),a.check()):F(g,e,b))}),b[f]=!0)}function D(){var a,e,b=(a=1E3*l.waitSeconds)&&i.startTime+a<(new Date).getTime(),f=[],c=[],h=!1,k=!0;if(!X){X=!0;B(W,function(a){var i=a.map,m=i.id;if(a.enabled&&(i.isDefine||c.push(a),!a.error))if(!a.inited&&b)g(m)?h=e=!0:(f.push(m),d(m));else if(!a.inited&&(a.fetched&&i.isDefine)&&(h=!0,!i.prefix))return k=!1});if(b&&f.length)return a=C("timeout","Load timeout for modules: "+
-f,null,f),a.contextName=i.contextName,w(a);k&&v(c,function(a){F(a,{},{})});if((!b||e)&&h)if((z||fa)&&!Y)Y=setTimeout(function(){Y=0;D()},50);X=!1}}function E(a){s(p,a[0])||q(m(a[0],null,!0)).init(a[1],a[2])}function K(a){var a=a.currentTarget||a.srcElement,e=i.onScriptLoad;a.detachEvent&&!Z?a.detachEvent("onreadystatechange",e):a.removeEventListener("load",e,!1);e=i.onScriptError;(!a.detachEvent||Z)&&a.removeEventListener("error",e,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function L(){var a;
-for(x();A.length;){a=A.shift();if(null===a[0])return w(C("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));E(a)}}var X,$,i,N,Y,l={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},k={},W={},aa={},A=[],p={},T={},ba={},M=1,Q=1;N={require:function(a){return a.require?a.require:a.require=i.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?p[a.map.id]=a.exports:a.exports=p[a.map.id]={}},module:function(a){return a.module?
-a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){return j(l.config,a.map.id)||{}},exports:a.exports||(a.exports={})}}};$=function(a){this.events=j(aa,a.id)||{};this.map=a;this.shim=j(l.shim,a.id);this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};$.prototype={init:function(a,e,b,f){f=f||{};if(!this.inited){this.factory=e;if(b)this.on("error",b);else this.events.error&&(b=t(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=
-b;this.inited=!0;this.ignore=f.ignore;f.enabled||this.enabled?this.enable():this.check()}},defineDep:function(a,e){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=e)},fetch:function(){if(!this.fetched){this.fetched=!0;i.startTime=(new Date).getTime();var a=this.map;if(this.shim)i.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],t(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=
-this.map.url;T[a]||(T[a]=!0,i.load(this.map.id,a))},check:function(){if(this.enabled&&!this.enabling){var a,e,b=this.map.id;e=this.depExports;var f=this.exports,c=this.factory;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(1>this.depCount&&!this.defined){if(G(c)){if(this.events.error&&this.map.isDefine||h.onError!==da)try{f=i.execCb(b,c,e,f)}catch(d){a=d}else f=i.execCb(b,c,e,f);this.map.isDefine&&void 0===f&&((e=this.module)?f=e.exports:this.usingExports&&
-(f=this.exports));if(a)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:null,a.requireType=this.map.isDefine?"define":"require",w(this.error=a)}else f=c;this.exports=f;if(this.map.isDefine&&!this.ignore&&(p[b]=f,h.onResourceLoad))h.onResourceLoad(i,this.map,this.depMaps);y(b);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else this.fetch()}},callPlugin:function(){var a=
-this.map,b=a.id,d=m(a.prefix);this.depMaps.push(d);r(d,"defined",t(this,function(f){var d,g;g=j(ba,this.map.id);var J=this.map.name,u=this.map.parentMap?this.map.parentMap.name:null,p=i.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(f.normalize&&(J=f.normalize(J,function(a){return c(a,u,!0)})||""),f=m(a.prefix+"!"+J,this.map.parentMap),r(f,"defined",t(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),g=j(k,f.id)){this.depMaps.push(f);
-if(this.events.error)g.on("error",t(this,function(a){this.emit("error",a)}));g.enable()}}else g?(this.map.url=i.nameToUrl(g),this.load()):(d=t(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),d.error=t(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];B(k,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&y(a.map.id)});w(a)}),d.fromText=t(this,function(f,c){var g=a.name,J=m(g),k=O;c&&(f=c);k&&(O=!1);q(J);s(l.config,b)&&(l.config[g]=l.config[b]);try{h.exec(f)}catch(j){return w(C("fromtexteval",
-"fromText eval for "+b+" failed: "+j,j,[b]))}k&&(O=!0);this.depMaps.push(J);i.completeLoad(g);p([g],d)}),f.load(a.name,p,d,l))}));i.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){W[this.map.id]=this;this.enabling=this.enabled=!0;v(this.depMaps,t(this,function(a,b){var c,f;if("string"===typeof a){a=m(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=j(N,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;r(a,"defined",t(this,function(a){this.defineDep(b,
-a);this.check()}));this.errback&&r(a,"error",t(this,this.errback))}c=a.id;f=k[c];!s(N,c)&&(f&&!f.enabled)&&i.enable(a,this)}));B(this.pluginMaps,t(this,function(a){var b=j(k,a.id);b&&!b.enabled&&i.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){v(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};i={config:l,contextName:b,registry:k,defined:p,urlFetched:T,defQueue:A,Module:$,makeModuleMap:m,
-nextTick:h.nextTick,onError:w,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=l.shim,c={paths:!0,bundles:!0,config:!0,map:!0};B(a,function(a,b){c[b]?(l[b]||(l[b]={}),V(l[b],a,!0,!0)):l[b]=a});a.bundles&&B(a.bundles,function(a,b){v(a,function(a){a!==b&&(ba[a]=b)})});a.shim&&(B(a.shim,function(a,c){H(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=i.makeShimExports(a);b[c]=a}),l.shim=b);a.packages&&v(a.packages,function(a){var b,
-a="string"===typeof a?{name:a}:a;b=a.name;a.location&&(l.paths[b]=a.location);l.pkgs[b]=a.name+"/"+(a.main||"main").replace(ja,"").replace(R,"")});B(k,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=m(b))});if(a.deps||a.callback)i.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(ca,arguments));return b||a.exports&&ea(a.exports)}},makeRequire:function(a,e){function g(f,c,d){var j,l;e.enableBuildCallback&&(c&&G(c))&&(c.__requireJsBuild=
-!0);if("string"===typeof f){if(G(c))return w(C("requireargs","Invalid require call"),d);if(a&&s(N,f))return N[f](k[a.id]);if(h.get)return h.get(i,f,a,g);j=m(f,a,!1,!0);j=j.id;return!s(p,j)?w(C("notloaded",'Module name "'+j+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):p[j]}L();i.nextTick(function(){L();l=q(m(null,a));l.skipMap=e.skipMap;l.init(f,c,d,{enabled:!0});D()});return g}e=e||{};V(g,{isBrowser:z,toUrl:function(b){var e,d=b.lastIndexOf("."),g=b.split("/")[0];if(-1!==
-d&&(!("."===g||".."===g)||1<d))e=b.substring(d,b.length),b=b.substring(0,d);return i.nameToUrl(c(b,a&&a.id,!0),e,!0)},defined:function(b){return s(p,m(b,a,!1,!0).id)},specified:function(b){b=m(b,a,!1,!0).id;return s(p,b)||s(k,b)}});a||(g.undef=function(b){x();var c=m(b,a,!0),e=j(k,b);d(b);delete p[b];delete T[c.url];delete aa[b];U(A,function(a,c){a[0]===b&&A.splice(c,1)});e&&(e.events.defined&&(aa[b]=e.events),y(b))});return g},enable:function(a){j(k,a.id)&&q(a).enable()},completeLoad:function(a){var b,
-c,f=j(l.shim,a)||{},d=f.exports;for(x();A.length;){c=A.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}else c[0]===a&&(b=!0);E(c)}c=j(k,a);if(!b&&!s(p,a)&&c&&!c.inited){if(l.enforceDefine&&(!d||!ea(d)))return g(a)?void 0:w(C("nodefine","No define call for "+a,null,[a]));E([a,f.deps||[],f.exportsFn])}D()},nameToUrl:function(a,b,c){var f,d,g;(f=j(l.pkgs,a))&&(a=f);if(f=j(ba,a))return i.nameToUrl(f,b,c);if(h.jsExtRegExp.test(a))f=a+(b||"");else{f=l.paths;a=a.split("/");for(d=a.length;0<d;d-=1)if(g=a.slice(0,
-d).join("/"),g=j(f,g)){H(g)&&(g=g[0]);a.splice(0,d,g);break}f=a.join("/");f+=b||(/^data\:|\?/.test(f)||c?"":".js");f=("/"===f.charAt(0)||f.match(/^[\w\+\.\-]+:/)?"":l.baseUrl)+f}return l.urlArgs?f+((-1===f.indexOf("?")?"?":"&")+l.urlArgs):f},load:function(a,b){h.load(i,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if("load"===a.type||ka.test((a.currentTarget||a.srcElement).readyState))P=null,a=K(a),i.completeLoad(a.id)},onScriptError:function(a){var b=K(a);if(!g(b.id))return w(C("scripterror",
-"Script error for: "+b.id,a,[b.id]))}};i.require=i.makeRequire();return i}var h,x,y,D,K,E,P,L,q,Q,la=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ma=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,R=/\.js$/,ja=/^\.\//;x=Object.prototype;var M=x.toString,ga=x.hasOwnProperty,ia=Array.prototype.splice,z=!!("undefined"!==typeof window&&"undefined"!==typeof navigator&&window.document),fa=!z&&"undefined"!==typeof importScripts,ka=z&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,
-Z="undefined"!==typeof opera&&"[object Opera]"===opera.toString(),F={},r={},S=[],O=!1;if("undefined"===typeof define){if("undefined"!==typeof requirejs){if(G(requirejs))return;r=requirejs;requirejs=void 0}"undefined"!==typeof require&&!G(require)&&(r=require,require=void 0);h=requirejs=function(b,c,d,g){var u,m="_";!H(b)&&"string"!==typeof b&&(u=b,H(c)?(b=c,c=d,d=g):b=[]);u&&u.context&&(m=u.context);(g=j(F,m))||(g=F[m]=h.s.newContext(m));u&&g.configure(u);return g.require(b,c,d)};h.config=function(b){return h(b)};
-h.nextTick="undefined"!==typeof setTimeout?function(b){setTimeout(b,4)}:function(b){b()};require||(require=h);h.version="2.1.11";h.jsExtRegExp=/^\/|:|\?|\.js$/;h.isBrowser=z;x=h.s={contexts:F,newContext:ha};h({});v(["toUrl","undef","defined","specified"],function(b){h[b]=function(){var c=F._;return c.require[b].apply(c,arguments)}});if(z&&(y=x.head=document.getElementsByTagName("head")[0],D=document.getElementsByTagName("base")[0]))y=x.head=D.parentNode;h.onError=da;h.createNode=function(b){var c=
-b.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");c.type=b.scriptType||"text/javascript";c.charset="utf-8";c.async=!0;return c};h.load=function(b,c,d){var g=b&&b.config||{};if(z)return g=h.createNode(g,c,d),g.setAttribute("data-requirecontext",b.contextName),g.setAttribute("data-requiremodule",c),g.attachEvent&&!(g.attachEvent.toString&&0>g.attachEvent.toString().indexOf("[native code"))&&!Z?(O=!0,g.attachEvent("onreadystatechange",b.onScriptLoad)):
-(g.addEventListener("load",b.onScriptLoad,!1),g.addEventListener("error",b.onScriptError,!1)),g.src=d,L=g,D?y.insertBefore(g,D):y.appendChild(g),L=null,g;if(fa)try{importScripts(d),b.completeLoad(c)}catch(j){b.onError(C("importscripts","importScripts failed for "+c+" at "+d,j,[c]))}};z&&!r.skipDataMain&&U(document.getElementsByTagName("script"),function(b){y||(y=b.parentNode);if(K=b.getAttribute("data-main"))return q=K,r.baseUrl||(E=q.split("/"),q=E.pop(),Q=E.length?E.join("/")+"/":"./",r.baseUrl=
-Q),q=q.replace(R,""),h.jsExtRegExp.test(q)&&(q=K),r.deps=r.deps?r.deps.concat(q):[q],!0});define=function(b,c,d){var g,h;"string"!==typeof b&&(d=c,c=b,b=null);H(c)||(d=c,c=null);!c&&G(d)&&(c=[],d.length&&(d.toString().replace(la,"").replace(ma,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c)));if(O){if(!(g=L))P&&"interactive"===P.readyState||U(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return P=b}),g=P;g&&(b||
-(b=g.getAttribute("data-requiremodule")),h=F[g.getAttribute("data-requirecontext")])}(h?h.defQueue:S).push([b,c,d])};define.amd={jQuery:!0};h.exec=function(b){return eval(b)};h(r)}})(this);
--- a/src/hdalab/static/hdalab/lib/underscore-min.js	Fri Jul 18 13:29:53 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-//     Underscore.js 1.6.0
-//     http://underscorejs.org
-//     (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
-//     Underscore may be freely distributed under the MIT license.
-(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,w=Object.keys,_=i.bind,j=function(n){return n instanceof j?n:this instanceof j?void(this._wrapped=n):new j(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=j),exports._=j):n._=j,j.VERSION="1.6.0";var A=j.each=j.forEach=function(n,t,e){if(null==n)return n;if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a=j.keys(n),u=0,i=a.length;i>u;u++)if(t.call(e,n[a[u]],a[u],n)===r)return;return n};j.map=j.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e.push(t.call(r,n,u,i))}),e)};var O="Reduce of empty array with no initial value";j.reduce=j.foldl=j.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=j.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},j.reduceRight=j.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=j.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=j.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},j.find=j.detect=function(n,t,r){var e;return k(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},j.filter=j.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&e.push(n)}),e)},j.reject=function(n,t,r){return j.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},j.every=j.all=function(n,t,e){t||(t=j.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var k=j.some=j.any=function(n,t,e){t||(t=j.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};j.contains=j.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:k(n,function(n){return n===t})},j.invoke=function(n,t){var r=o.call(arguments,2),e=j.isFunction(t);return j.map(n,function(n){return(e?t:n[t]).apply(n,r)})},j.pluck=function(n,t){return j.map(n,j.property(t))},j.where=function(n,t){return j.filter(n,j.matches(t))},j.findWhere=function(n,t){return j.find(n,j.matches(t))},j.max=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);var e=-1/0,u=-1/0;return A(n,function(n,i,a){var o=t?t.call(r,n,i,a):n;o>u&&(e=n,u=o)}),e},j.min=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);var e=1/0,u=1/0;return A(n,function(n,i,a){var o=t?t.call(r,n,i,a):n;u>o&&(e=n,u=o)}),e},j.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=j.random(r++),e[r-1]=e[t],e[t]=n}),e},j.sample=function(n,t,r){return null==t||r?(n.length!==+n.length&&(n=j.values(n)),n[j.random(n.length-1)]):j.shuffle(n).slice(0,Math.max(0,t))};var E=function(n){return null==n?j.identity:j.isFunction(n)?n:j.property(n)};j.sortBy=function(n,t,r){return t=E(t),j.pluck(j.map(n,function(n,e,u){return{value:n,index:e,criteria:t.call(r,n,e,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=E(r),A(t,function(i,a){var o=r.call(e,i,a,t);n(u,o,i)}),u}};j.groupBy=F(function(n,t,r){j.has(n,t)?n[t].push(r):n[t]=[r]}),j.indexBy=F(function(n,t,r){n[t]=r}),j.countBy=F(function(n,t){j.has(n,t)?n[t]++:n[t]=1}),j.sortedIndex=function(n,t,r,e){r=E(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;r.call(e,n[o])<u?i=o+1:a=o}return i},j.toArray=function(n){return n?j.isArray(n)?o.call(n):n.length===+n.length?j.map(n,j.identity):j.values(n):[]},j.size=function(n){return null==n?0:n.length===+n.length?n.length:j.keys(n).length},j.first=j.head=j.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:0>t?[]:o.call(n,0,t)},j.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},j.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},j.rest=j.tail=j.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},j.compact=function(n){return j.filter(n,j.identity)};var M=function(n,t,r){return t&&j.every(n,j.isArray)?c.apply(r,n):(A(n,function(n){j.isArray(n)||j.isArguments(n)?t?a.apply(r,n):M(n,t,r):r.push(n)}),r)};j.flatten=function(n,t){return M(n,t,[])},j.without=function(n){return j.difference(n,o.call(arguments,1))},j.partition=function(n,t){var r=[],e=[];return A(n,function(n){(t(n)?r:e).push(n)}),[r,e]},j.uniq=j.unique=function(n,t,r,e){j.isFunction(t)&&(e=r,r=t,t=!1);var u=r?j.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:j.contains(a,r))||(a.push(r),i.push(n[e]))}),i},j.union=function(){return j.uniq(j.flatten(arguments,!0))},j.intersection=function(n){var t=o.call(arguments,1);return j.filter(j.uniq(n),function(n){return j.every(t,function(t){return j.contains(t,n)})})},j.difference=function(n){var t=c.apply(e,o.call(arguments,1));return j.filter(n,function(n){return!j.contains(t,n)})},j.zip=function(){for(var n=j.max(j.pluck(arguments,"length").concat(0)),t=new Array(n),r=0;n>r;r++)t[r]=j.pluck(arguments,""+r);return t},j.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},j.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=j.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},j.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},j.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=new Array(e);e>u;)i[u++]=n,n+=r;return i};var R=function(){};j.bind=function(n,t){var r,e;if(_&&n.bind===_)return _.apply(n,o.call(arguments,1));if(!j.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));R.prototype=n.prototype;var u=new R;R.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},j.partial=function(n){var t=o.call(arguments,1);return function(){for(var r=0,e=t.slice(),u=0,i=e.length;i>u;u++)e[u]===j&&(e[u]=arguments[r++]);for(;r<arguments.length;)e.push(arguments[r++]);return n.apply(this,e)}},j.bindAll=function(n){var t=o.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return A(t,function(t){n[t]=j.bind(n[t],n)}),n},j.memoize=function(n,t){var r={};return t||(t=j.identity),function(){var e=t.apply(this,arguments);return j.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},j.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},j.defer=function(n){return j.delay.apply(j,[n,1].concat(o.call(arguments,1)))},j.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var c=function(){o=r.leading===!1?0:j.now(),a=null,i=n.apply(e,u),e=u=null};return function(){var l=j.now();o||r.leading!==!1||(o=l);var f=t-(l-o);return e=this,u=arguments,0>=f?(clearTimeout(a),a=null,o=l,i=n.apply(e,u),e=u=null):a||r.trailing===!1||(a=setTimeout(c,f)),i}},j.debounce=function(n,t,r){var e,u,i,a,o,c=function(){var l=j.now()-a;t>l?e=setTimeout(c,t-l):(e=null,r||(o=n.apply(i,u),i=u=null))};return function(){i=this,u=arguments,a=j.now();var l=r&&!e;return e||(e=setTimeout(c,t)),l&&(o=n.apply(i,u),i=u=null),o}},j.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},j.wrap=function(n,t){return j.partial(t,n)},j.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},j.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},j.keys=function(n){if(!j.isObject(n))return[];if(w)return w(n);var t=[];for(var r in n)j.has(n,r)&&t.push(r);return t},j.values=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},j.pairs=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},j.invert=function(n){for(var t={},r=j.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},j.functions=j.methods=function(n){var t=[];for(var r in n)j.isFunction(n[r])&&t.push(r);return t.sort()},j.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},j.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},j.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)j.contains(r,u)||(t[u]=n[u]);return t},j.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]===void 0&&(n[r]=t[r])}),n},j.clone=function(n){return j.isObject(n)?j.isArray(n)?n.slice():j.extend({},n):n},j.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof j&&(n=n._wrapped),t instanceof j&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;var a=n.constructor,o=t.constructor;if(a!==o&&!(j.isFunction(a)&&a instanceof a&&j.isFunction(o)&&o instanceof o)&&"constructor"in n&&"constructor"in t)return!1;r.push(n),e.push(t);var c=0,f=!0;if("[object Array]"==u){if(c=n.length,f=c==t.length)for(;c--&&(f=S(n[c],t[c],r,e)););}else{for(var s in n)if(j.has(n,s)&&(c++,!(f=j.has(t,s)&&S(n[s],t[s],r,e))))break;if(f){for(s in t)if(j.has(t,s)&&!c--)break;f=!c}}return r.pop(),e.pop(),f};j.isEqual=function(n,t){return S(n,t,[],[])},j.isEmpty=function(n){if(null==n)return!0;if(j.isArray(n)||j.isString(n))return 0===n.length;for(var t in n)if(j.has(n,t))return!1;return!0},j.isElement=function(n){return!(!n||1!==n.nodeType)},j.isArray=x||function(n){return"[object Array]"==l.call(n)},j.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){j["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),j.isArguments(arguments)||(j.isArguments=function(n){return!(!n||!j.has(n,"callee"))}),"function"!=typeof/./&&(j.isFunction=function(n){return"function"==typeof n}),j.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},j.isNaN=function(n){return j.isNumber(n)&&n!=+n},j.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},j.isNull=function(n){return null===n},j.isUndefined=function(n){return n===void 0},j.has=function(n,t){return f.call(n,t)},j.noConflict=function(){return n._=t,this},j.identity=function(n){return n},j.constant=function(n){return function(){return n}},j.property=function(n){return function(t){return t[n]}},j.matches=function(n){return function(t){if(t===n)return!0;for(var r in n)if(n[r]!==t[r])return!1;return!0}},j.times=function(n,t,r){for(var e=Array(Math.max(0,n)),u=0;n>u;u++)e[u]=t.call(r,u);return e},j.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},j.now=Date.now||function(){return(new Date).getTime()};var T={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}};T.unescape=j.invert(T.escape);var I={escape:new RegExp("["+j.keys(T.escape).join("")+"]","g"),unescape:new RegExp("("+j.keys(T.unescape).join("|")+")","g")};j.each(["escape","unescape"],function(n){j[n]=function(t){return null==t?"":(""+t).replace(I[n],function(t){return T[n][t]})}}),j.result=function(n,t){if(null==n)return void 0;var r=n[t];return j.isFunction(r)?r.call(n):r},j.mixin=function(n){A(j.functions(n),function(t){var r=j[t]=n[t];j.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(j,n))}})};var N=0;j.uniqueId=function(n){var t=++N+"";return n?n+t:t},j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n","	":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;j.template=function(n,t,r){var e;r=j.defaults({},r,j.templateSettings);var u=new RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=new Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,j);var c=function(n){return e.call(this,n,j)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},j.chain=function(n){return j(n).chain()};var z=function(n){return this._chain?j(n).chain():n};j.mixin(j),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];j.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];j.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),j.extend(j.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),"function"==typeof define&&define.amd&&define("underscore",[],function(){return j})}).call(this);
-//# sourceMappingURL=underscore-min.map
\ No newline at end of file
--- a/src/hdalab/templates/profile_home.html	Fri Jul 18 13:29:53 2014 +0200
+++ b/src/hdalab/templates/profile_home.html	Mon Jul 21 16:07:00 2014 +0200
@@ -21,19 +21,22 @@
     <h2>Votre profil</h2>
     <p>Vos renkans : </p>
     <table>
-        <tr class="border_bottom"><th>Nom</th><th>Date de modification</th><th>Preview</th><th>Actions</th></tr>
-      {% for r in renkan_list %}
+        <tr class="border_bottom"><th>Nom</th><th>Date de modification</th><th>Preview</th><th>Statut</th><th>Actions</th></tr>
+      {% for hr in renkan_list %}
+       {% with hr.renkan as r %}
         <tr class="border_bottom">
             <td>{{ r.title }} ({{ r.id }})</td>
             <td>{{ r.modification_date|date:"Y-m-d H:i" }}</td>
             <td>{% thumbnail r.image 100x100 as thumb %}<img src="{{ thumb.url }}" width="{{ thumb.width }}" height="{{ thumb.height }}" /></td>
+            <td>{{ hr.state }}</td>
             <td>
                 <a title="Edit renkan" href="{% url 'renkan_edit' %}?rk_id={{ r.rk_id }}" class="renkan-basic-action"><span class="ui-icon ui-icon-pencil"></span></a>
                 <a title="View renkan" href="{% url 'renkan_view' %}?rk_id={{ r.rk_id }}" class="renkan-basic-action"><span class="ui-icon ui-icon-eye"></span></a>
-                <a title="Copy renkan" href="{% url 'renkan_copy' rk_id=r.rk_id %}" class="renkan-basic-action" onclick="return confirm('{% trans "Are you sure you want to copy this renkan ?" %}');" ><span class="ui-icon ui-icon-copy"></span></a>
-                <a title="Remove renkan" href="{% url 'renkan_delete' rk_id=r.rk_id %}" class="renkan-basic-action" onclick="return confirm('{% trans "Are you sure you want to delete this renkan ? You cannot undo this action." %}');" ><span class="ui-icon ui-icon-trash"></span></a>
+                <a title="Copy renkan" href="{% url 'renkan_copy' rk_id=r.rk_id %}?next={% url 'profile_home' %}" class="renkan-basic-action" onclick="return confirm('{% trans "Are you sure you want to copy this renkan ?" %}');" ><span class="ui-icon ui-icon-copy"></span></a>
+                <a title="Remove renkan" href="{% url 'renkan_delete' rk_id=r.rk_id %}?next={% url 'profile_home' %}" class="renkan-basic-action" onclick="return confirm('{% trans "Are you sure you want to delete this renkan ? You cannot undo this action." %}');" ><span class="ui-icon ui-icon-trash"></span></a>
             </td>
         </tr>
+       {% endwith %}
       {% endfor %}
     </table>
     <p>Gestion du mot de passe : <a href="{% url 'auth_password_change' %}">modification</a></p>
--- a/src/hdalab/templates/renkan_edit.html	Fri Jul 18 13:29:53 2014 +0200
+++ b/src/hdalab/templates/renkan_edit.html	Mon Jul 21 16:07:00 2014 +0200
@@ -6,7 +6,7 @@
 {% block css_import %}
 {{block.super}}
         <link rel="stylesheet" type="text/css" href="{% static 'hdalab/css/additionnal_renkan.css' %}" />
-        <link rel="stylesheet" type="text/css" href="{% static 'hdalab/lib/renkan/css/renkan.css' %}" />
+        <link rel="stylesheet" type="text/css" href="{% static 'renkanmanager/lib/renkan/css/renkan.css' %}" />
         <style type="text/css">
         .rnk-wrapper, .rnk-container{
             width: 100%;
@@ -26,23 +26,23 @@
 
 {% block js_import %}
 {{block.super}}
-        <script src="{% static 'hdalab/lib/jquery.mousewheel.min.js' %}"></script>
-        <script src="{% static 'hdalab/lib/underscore-min.js' %}"></script>
-        <script src="{% static 'hdalab/lib/backbone.js' %}"></script>
-        <script src="{% static 'hdalab/lib/backbone-relational.js' %}"></script>
-        <script src="{% static 'hdalab/lib/paper.js' %}"></script>
+        <script src="{% static 'renkanmanager/lib/jquery.mousewheel.min.js' %}"></script>
+        <script src="{% static 'renkanmanager/lib/underscore-min.js' %}"></script>
+        <script src="{% static 'renkanmanager/lib/backbone.js' %}"></script>
+        <script src="{% static 'renkanmanager/lib/backbone-relational.js' %}"></script>
+        <script src="{% static 'renkanmanager/lib/paper.js' %}"></script>
         <script type="text/javascript">
             var require = {
-                baseUrl: "{% static 'hdalab/lib/' %}"
+                baseUrl: "{% static 'renkanmanager/lib/' %}"
             };
         </script>
-        <script src="{% static 'hdalab/lib/require.js' %}"></script>
-        <script src="{% static 'hdalab/lib/renkan/renkan.js' %}"></script>
+        <script src="{% static 'renkanmanager/lib/require.js' %}"></script>
+        <script src="{% static 'renkanmanager/lib/renkan/renkan.js' %}"></script>
         <script type="text/javascript">
         
             function startRenkan(){
                 var _renkan = new Rkns.Renkan({
-                    static_url : "{% static 'hdalab/lib/renkan/' %}",
+                    static_url : "{% static 'renkanmanager/lib/renkan/' %}",
                     search: [
                         {
                             type: "Ldt"
--- a/src/hdalab/templates/renkan_view.html	Fri Jul 18 13:29:53 2014 +0200
+++ b/src/hdalab/templates/renkan_view.html	Mon Jul 21 16:07:00 2014 +0200
@@ -6,7 +6,7 @@
 {% block css_import %}
 {{block.super}}
         <link rel="stylesheet" type="text/css" href="{% static 'hdalab/css/additionnal_renkan.css' %}" />
-        <link rel="stylesheet" type="text/css" href="{% static 'hdalab/lib/renkan/css/renkan.css' %}" />
+        <link rel="stylesheet" type="text/css" href="{% static 'renkanmanager/lib/renkan/css/renkan.css' %}" />
         <style type="text/css">
         .rnk-wrapper, .rnk-container{
             width: 100%;
@@ -26,23 +26,23 @@
 
 {% block js_import %}
 {{block.super}}
-        <script src="{% static 'hdalab/lib/jquery.mousewheel.min.js' %}"></script>
-        <script src="{% static 'hdalab/lib/underscore-min.js' %}"></script>
-        <script src="{% static 'hdalab/lib/backbone.js' %}"></script>
-        <script src="{% static 'hdalab/lib/backbone-relational.js' %}"></script>
-        <script src="{% static 'hdalab/lib/paper.js' %}"></script>
+        <script src="{% static 'renkanmanager/lib/jquery.mousewheel.min.js' %}"></script>
+        <script src="{% static 'renkanmanager/lib/underscore-min.js' %}"></script>
+        <script src="{% static 'renkanmanager/lib/backbone.js' %}"></script>
+        <script src="{% static 'renkanmanager/lib/backbone-relational.js' %}"></script>
+        <script src="{% static 'renkanmanager/lib/paper.js' %}"></script>
         <script type="text/javascript">
             var require = {
-                baseUrl: "{% static 'hdalab/lib/' %}"
+                baseUrl: "{% static 'renkanmanager/lib/' %}"
             };
         </script>
-        <script src="{% static 'hdalab/lib/require.js' %}"></script>
-        <script src="{% static 'hdalab/lib/renkan/renkan.js' %}"></script>
+        <script src="{% static 'renkanmanager/lib/require.js' %}"></script>
+        <script src="{% static 'renkanmanager/lib/renkan/renkan.js' %}"></script>
         <script type="text/javascript">
         
             function startRenkan(){
                 var _renkan = new Rkns.Renkan({
-                    static_url : "{% static 'hdalab/lib/renkan/' %}",
+                    static_url : "{% static 'renkanmanager/lib/renkan/' %}",
                     editor_mode: false,
                     show_bins: false,
                     language: "fr"
--- a/src/hdalab/urls.py	Fri Jul 18 13:29:53 2014 +0200
+++ b/src/hdalab/urls.py	Mon Jul 21 16:07:00 2014 +0200
@@ -1,9 +1,8 @@
 # -*- coding: utf-8 -*-
 from django.conf.urls import patterns, include, url
 from django.views.generic import TemplateView
-from hdalab.views.renkan import RenkanGetPut, RenkanCopy, RenkanDelete,\
-    RenkanEdit
-from hdalab.views.profile import ProfileHome
+from renkanmanager.views import RenkanCopy, RenkanDelete
+from hdalab.views.profile import ProfileHome, RenkanEdit, HdalabRenkanGetPut
 
 # Uncomment the next two lines to enable the admin:
 # from django.contrib import admin
@@ -32,7 +31,7 @@
     url(r'^notice/(?P<hda_id>[\w-]+)$', 'hdalab.views.pages.datasheet', name='notice'),
     
     url(r'^renkan/edit/$', RenkanEdit.as_view(), name='renkan_edit'),
-    url(r'^renkan/getput/$', RenkanGetPut.as_view(), name='renkan_get_put'),
+    url(r'^renkan/getput/$', HdalabRenkanGetPut.as_view(), name='renkan_get_put'),
     url(r'^renkan/view/$', TemplateView.as_view(template_name="renkan_view.html"), name='renkan_view'),
     url(r'^renkan/copy/(?P<rk_id>.*)$', RenkanCopy.as_view(), name='renkan_copy'),
     url(r'^renkan/delete/(?P<rk_id>.*)$', RenkanDelete.as_view(), name='renkan_delete'),
--- a/src/hdalab/views/pages.py	Fri Jul 18 13:29:53 2014 +0200
+++ b/src/hdalab/views/pages.py	Mon Jul 21 16:07:00 2014 +0200
@@ -1,10 +1,9 @@
 # -*- coding: utf-8 -*-
 
-from django.shortcuts import render_to_response, redirect
+from django.shortcuts import render_to_response
 from django.template import RequestContext
 from hdabo.models import Datasheet, TaggedSheet
 import re
-import django.utils.simplejson as json
 
 def datasheet(request, hda_id=None):
     MAX_TAG = 15
--- a/src/hdalab/views/profile.py	Fri Jul 18 13:29:53 2014 +0200
+++ b/src/hdalab/views/profile.py	Mon Jul 21 16:07:00 2014 +0200
@@ -5,12 +5,22 @@
 @author: tc
 '''
 from datetime import datetime
-from django.conf import settings
+from django.db.models import Q
+from django.http import HttpResponse
+from django.shortcuts import get_object_or_404
+from django.views.decorators.csrf import csrf_exempt
 from django.views.generic import TemplateView
-from hdalab.models.renkan import Renkan
+from hdabo.models import Tag
+from hdalab.views.ajax import filter_generic
+from renkanmanager.models import Renkan
+from renkanmanager.utils import LineNodePlacer
+from renkanmanager.views import RenkanGetPut
+import json
 import uuid
 
+
 import logging
+from hdalab.models.renkan import HdalabRenkan
 logger = logging.getLogger(__name__)
 
 
@@ -21,24 +31,169 @@
     def get_context_data(self, **kwargs):
         context = super(ProfileHome, self).get_context_data(**kwargs)
         
-#        now = datetime.utcnow().isoformat()
-         
+#         now = datetime.utcnow().isoformat()
+#         
 #         rk = Renkan()
 #         rk.rk_id = unicode(uuid.uuid1())
 #         rk.owner = self.request.user
 #         rk.content = '{"parrot":"dead"}'
 #         rk.title = now
 #         rk.save()
+#         hr = HdalabRenkan()
+#         hr.renkan = rk
+#         from random import randrange
+#         hr.state = randrange(4) + 1
+#         hr.save()
         
-        context['renkan_list'] = Renkan.objects.filter(owner=self.request.user).order_by("-modification_date")
+        
+        context['renkan_list'] = HdalabRenkan.objects.filter(renkan__owner=self.request.user).order_by("-renkan__modification_date")
         
-        #now = datetime.utcnow()
-        #context['renkan_list'] = [
-        #    {"id":"a", "title":"title Renkan 1", "modification_date":now, "thumbnail":"http://icons.iconarchive.com/icons/visualpharm/ios7v2/256/Charts-Mind-map-icon.png"}, 
-        #    {"id":"b", "title":"2 title Renkan 2", "modification_date":now, "thumbnail":"http://a5.mzstatic.com/us/r30/Purple4/v4/ec/6f/d1/ec6fd10f-f295-eed7-d94f-3d9da39efc64/icon_256.png"}
-        #]
+        return context
+
+
+
+class RenkanEdit(TemplateView):
+    
+    template_name="renkan_edit.html"
+    
+    def get_context_data(self, **kwargs):
+        context = super(RenkanEdit, self).get_context_data(**kwargs)
+        # If a renkan id is set
+        rk_id = self.request.GET.get("rk_id", "")
+        if rk_id!="":
+            rk = get_object_or_404(Renkan, rk_id=rk_id)
+            if rk.owner!=self.request.user:
+                raise Exception("You are not allowed to edit this renkan")
         
         return context
 
+
+
+class HdalabRenkanGetPut(RenkanGetPut):
+    
+    @csrf_exempt
+    def dispatch(self, *args, **kwargs):
+        return super(HdalabRenkanGetPut, self).dispatch(*args, **kwargs)
+    
+    def get(self, request):
         
+        # If a renkan id is set
+        rk_id = request.GET.get("rk_id", "")
+        if rk_id!="":
+            rk = get_object_or_404(Renkan, rk_id=rk_id)
+            return HttpResponse(rk.content, content_type="application/json")
+        
+        # Otherwise we build the datas    
+        now = datetime.now().strftime("%Y-%m-%d %H:%M")
+        
+        content = {
+          "id": unicode(uuid.uuid1()),
+          "title": "Renkan généré " + now,
+          "description": "(empty description)",
+          "created": now,
+          "updated": now,
+          "nodes": [],
+          "edges": [],
+          "views": [],
+          "users": [],
+        }
+        
+        # Get tags and countries
+        labels = request.GET.get("label", "").split(",")
+        countries = request.GET.get("country", "").split(",")
+        # Tags arrive with french label, countries with dbpedia uri
+        label_list = [t for t in labels if t!=""]
+        country_list = [c for c in countries if c!=""]
+        all_tags = Tag.objects.filter( Q(label__in=label_list) | Q(dbpedia_uri__in=country_list) ).select_related("dbpedia_fields")
+        
+        # Get datasheets from ajax filter search
+        filter_output = filter_generic(request.GET.get('lang',request.LANGUAGE_CODE), None, ",".join(label_list), ",".join(country_list))
+        filter_output = json.loads(filter_output)
+        #logger.debug("COUCOU")
+        #logger.debug(json.dumps(filter_output, indent=2))
+        #return HttpResponse(json.dumps(filter_output, indent=2), content_type="application/json")
+        
+        # Prepare other tags
+        related_tags = []
+        all_labels = [t.label for t in all_tags]
+        related_tags_dict = {}
+        for c in filter_output["contents"]:
+            c["id"] = unicode(uuid.uuid1())
+            related_tags_dict[c["id"]] = []
+            for t in c["tags"]:
+                if t["label"] not in all_labels and t["order"]<6:
+                    thumbnail_url = ""
+                    for tt in filter_output["tags"]:
+                        if tt["label"]==t["label"]:
+                            thumbnail_url = tt["thumbnail"]
+                    related_tags.append({"label": t["label"], "thumbnail":thumbnail_url, "id":t["id"]})
+                    all_labels.append(t["label"])
+                    related_tags_dict[c["id"]].append(t["id"])
+        #return HttpResponse(json.dumps({"t":related_tags_label}, indent=2), content_type="application/json")
+        
+        # Prepare Node placer :
+        np = LineNodePlacer()
+        np.init({"tags": (1, len(all_tags)), "datasheet": (2, len(filter_output["contents"])), "related": (3, len(related_tags))})
+        
+        project_id = unicode(uuid.uuid1())
+        
+        for t in all_tags:
+            content["nodes"].append({
+              "id": unicode(uuid.uuid1()),
+              "title": t.label,
+              "description": t.dbpedia_uri,
+              "uri": t.dbpedia_uri,
+              "position": np.get_place("tags"),
+              "image": t.dbpedia_fields.thumbnail if hasattr(t, 'dbpedia_fields') and t.dbpedia_fields and t.dbpedia_fields.thumbnail else None,
+              "size": 0,
+              "project_id": project_id,
+              "color": None,
+              #"created_by": "roster_user-84fe909f-ba37-48e6-a25f-9d2f129a95b7"
+            })
+        
+        for c in filter_output["contents"]:
+            content["nodes"].append({
+              "id": c["id"],
+              "title": c["title"],
+              "description": c["description"],
+              "uri": c["url"],
+              "position": np.get_place("datasheet"),
+              "image": None,
+              "size": 0,
+              "project_id": project_id,
+              "color": "#FF0033",
+              #"created_by": "roster_user-84fe909f-ba37-48e6-a25f-9d2f129a95b7"
+            })
+        
+        for t in related_tags:
+            content["nodes"].append({
+              "id": t["id"],
+              "title": t["label"],
+              "description": "",
+              "uri": "",
+              "position": np.get_place("related"),
+              "image": t["thumbnail"],
+              "size": 0,
+              "project_id": project_id,
+              "color": "#00FF33",
+              #"created_by": "roster_user-84fe909f-ba37-48e6-a25f-9d2f129a95b7"
+            })
+        
+        for c_id in related_tags_dict:
+            for tag_id in related_tags_dict[c_id]:
+                content["edges"].append({
+                    "id": unicode(uuid.uuid1()),
+                    "title": "",
+                    "description": "",
+                    "uri": "",
+                    "color": None,
+                    "from": c_id,
+                    "to": tag_id,
+                    "project_id": project_id,
+                    #"created_by": "de68xf75y6hs5rgjhgghxbm217xk"
+                })
+        
+        return HttpResponse(json.dumps(content), content_type="application/json")
+
+
     
\ No newline at end of file
--- a/src/hdalab/views/renkan.py	Fri Jul 18 13:29:53 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,216 +0,0 @@
-# -*- coding: utf-8 -*-
-'''
-Created on Jul 01, 2014
-
-@author: tc
-'''
-from datetime import datetime
-from django.core.urlresolvers import reverse
-from django.db.models import Q
-from django.http.response import HttpResponse, HttpResponseBadRequest
-from django.shortcuts import get_object_or_404, redirect
-from django.views.decorators.csrf import csrf_exempt
-from django.views.generic import TemplateView, View
-from hdabo.models import Tag
-from hdalab.models.renkan import Renkan
-from hdalab.utils import LineNodePlacer
-from hdalab.views.ajax import filter_generic
-import json
-import uuid
-
-import logging
-logger = logging.getLogger(__name__)
-
-
-class RenkanEdit(TemplateView):
-    
-    template_name="renkan_edit.html"
-    
-    def get_context_data(self, **kwargs):
-        context = super(RenkanEdit, self).get_context_data(**kwargs)
-        # If a renkan id is set
-        rk_id = self.request.GET.get("rk_id", "")
-        if rk_id!="":
-            rk = get_object_or_404(Renkan, rk_id=rk_id)
-            if rk.owner!=self.request.user:
-                raise Exception("You are not allowed to edit this renkan")
-        
-        return context
-            
-
-
-class RenkanGetPut(View):
-    
-    @csrf_exempt
-    def dispatch(self, *args, **kwargs):
-        return super(RenkanGetPut, self).dispatch(*args, **kwargs)
-    
-    def get(self, request):
-        
-        # If a renkan id is set
-        rk_id = request.GET.get("rk_id", "")
-        if rk_id!="":
-            rk = get_object_or_404(Renkan, rk_id=rk_id)
-            return HttpResponse(rk.content, content_type="application/json")
-        
-        # Otherwise we build the datas    
-        now = datetime.now().strftime("%Y-%m-%d %H:%M")
-        
-        content = {
-          "id": unicode(uuid.uuid1()),
-          "title": "Renkan généré " + now,
-          "description": "(empty description)",
-          "created": now,
-          "updated": now,
-          "nodes": [],
-          "edges": [],
-          "views": [],
-          "users": [],
-        }
-        
-        # Get tags and countries
-        labels = request.GET.get("label", "").split(",")
-        countries = request.GET.get("country", "").split(",")
-        # Tags arrive with french label, countries with dbpedia uri
-        label_list = [t for t in labels if t!=""]
-        country_list = [c for c in countries if c!=""]
-        all_tags = Tag.objects.filter( Q(label__in=label_list) | Q(dbpedia_uri__in=country_list) ).select_related("dbpedia_fields")
-        
-        # Get datasheets from ajax filter search
-        filter_output = filter_generic(request.GET.get('lang',request.LANGUAGE_CODE), None, ",".join(label_list), ",".join(country_list))
-        filter_output = json.loads(filter_output)
-        #logger.debug("COUCOU")
-        #logger.debug(json.dumps(filter_output, indent=2))
-        #return HttpResponse(json.dumps(filter_output, indent=2), content_type="application/json")
-        
-        # Prepare other tags
-        related_tags = []
-        all_labels = [t.label for t in all_tags]
-        related_tags_dict = {}
-        for c in filter_output["contents"]:
-            c["id"] = unicode(uuid.uuid1())
-            related_tags_dict[c["id"]] = []
-            for t in c["tags"]:
-                if t["label"] not in all_labels and t["order"]<6:
-                    thumbnail_url = ""
-                    for tt in filter_output["tags"]:
-                        if tt["label"]==t["label"]:
-                            thumbnail_url = tt["thumbnail"]
-                    related_tags.append({"label": t["label"], "thumbnail":thumbnail_url, "id":t["id"]})
-                    all_labels.append(t["label"])
-                    related_tags_dict[c["id"]].append(t["id"])
-        #return HttpResponse(json.dumps({"t":related_tags_label}, indent=2), content_type="application/json")
-        
-        # Prepare Node placer :
-        np = LineNodePlacer()
-        np.init({"tags": (1, len(all_tags)), "datasheet": (2, len(filter_output["contents"])), "related": (3, len(related_tags))})
-        
-        project_id = unicode(uuid.uuid1())
-        
-        for t in all_tags:
-            content["nodes"].append({
-              "id": unicode(uuid.uuid1()),
-              "title": t.label,
-              "description": t.dbpedia_uri,
-              "uri": t.dbpedia_uri,
-              "position": np.get_place("tags"),
-              "image": t.dbpedia_fields.thumbnail if hasattr(t, 'dbpedia_fields') and t.dbpedia_fields and t.dbpedia_fields.thumbnail else None,
-              "size": 0,
-              "project_id": project_id,
-              "color": None,
-              #"created_by": "roster_user-84fe909f-ba37-48e6-a25f-9d2f129a95b7"
-            })
-        
-        for c in filter_output["contents"]:
-            content["nodes"].append({
-              "id": c["id"],
-              "title": c["title"],
-              "description": c["description"],
-              "uri": c["url"],
-              "position": np.get_place("datasheet"),
-              "image": None,
-              "size": 0,
-              "project_id": project_id,
-              "color": "#FF0033",
-              #"created_by": "roster_user-84fe909f-ba37-48e6-a25f-9d2f129a95b7"
-            })
-        
-        for t in related_tags:
-            content["nodes"].append({
-              "id": t["id"],
-              "title": t["label"],
-              "description": "",
-              "uri": "",
-              "position": np.get_place("related"),
-              "image": t["thumbnail"],
-              "size": 0,
-              "project_id": project_id,
-              "color": "#00FF33",
-              #"created_by": "roster_user-84fe909f-ba37-48e6-a25f-9d2f129a95b7"
-            })
-        
-        for c_id in related_tags_dict:
-            for tag_id in related_tags_dict[c_id]:
-                content["edges"].append({
-                    "id": unicode(uuid.uuid1()),
-                    "title": "",
-                    "description": "",
-                    "uri": "",
-                    "color": None,
-                    "from": c_id,
-                    "to": tag_id,
-                    "project_id": project_id,
-                    #"created_by": "de68xf75y6hs5rgjhgghxbm217xk"
-                })
-        
-        return HttpResponse(json.dumps(content), content_type="application/json")
-    
-    
-    def put(self, request):
-        
-        rk_id = request.GET.get("rk_id", "")
-        #data = json.loads(request.body)
-        #logger.debug(data["edges"])
-        #logger.debug(data["nodes"])
-        if rk_id!="":
-            rk = get_object_or_404(Renkan, rk_id=rk_id)
-            if rk.owner!=request.user:
-                return HttpResponseBadRequest("You are not allowed to edit this renkan")
-            rk.content = request.body
-            data = json.loads(request.body)
-            if "title" in data:
-                rk.title = data["title"]
-            rk.save()
-            
-        return HttpResponse("OK")
-
-
-
-
-
-class RenkanCopy(View):
-    
-    def get(self, request, rk_id):
-        old_rk = get_object_or_404(Renkan, rk_id=rk_id)
-        rk = Renkan()
-        rk.rk_id = unicode(uuid.uuid1())
-        rk.owner = request.user
-        rk.content = old_rk.content
-        rk.title = old_rk.title + " (copy)"
-        rk.save()
-        return redirect(reverse('profile_home'))
-
-
-
-
-
-class RenkanDelete(View):
-    
-    def get(self, request, rk_id):
-        rk = get_object_or_404(Renkan, rk_id=rk_id)
-        if rk.owner==request.user:
-            rk.delete()
-            return redirect(reverse('profile_home'))
-        else:
-            return HttpResponseBadRequest("You are not allowed to remove this renkan")
-    
\ No newline at end of file