+ modelStateChanged: function(property, value)
+ {
+ var self = $(this);
+
+ if (value == 'synced' || value == 'dirty') {
+ this.unfreeze();
+ } else if (value == 'unsynced') {
+ this.freeze('Niezsynchronizowany...');
+ } else if (value == 'loading') {
+ this.freeze('Ćadowanie...');
+ } else if (value == 'saving') {
+ this.freeze('Zapisywanie...');
+ } else if (value == 'error') {
+ this.freeze(this.model.get('error'));
+ $('.xml-editor-ref', this.overlay).click(
+ function(event) {
+ console.log("Sending scroll rq.", this);
+ try {
+ var href = $(this).attr('href').split('-');
+ var line = parseInt(href[1]);
+ var column = parseInt(href[2]);
+
+ $(document).trigger('xml-scroll-request', {line:line, column:column});
+ } catch(e) {
+ console.log(e);
+ }
+
+ return false;
+ });
+ }
+ },
+
+ render: function() {
+ this.element.unbind('click');
+
+ if(this.$printLink) this.$printLink.unbind();
+ this._super();
+ this.$printLink = $('.html-print-link', this.element);
+
+ var base = this.$printLink.attr('ui:baseref');
+ this.$printLink.attr('href', base + "?revision=" + this.model.get('revision'));
+
+ this.element.bind('click', this.itemClicked.bind(this));
+ },
+
+ reload: function() {
+ this.model.load(true);
+ },
+
+ dispose: function() {
+ this.model.removeObserver(this);
+ this._super();
+ },
+
+ itemClicked: function(event)
+ {
+ var self = this;
+
+ console.log('click:', event, event.ctrlKey, event.target);
+ var editableContent = null;
+ var $e = $(event.target);
+
+ var n = 0;
+
+ while( ($e[0] != this.element[0]) && !($e.attr('wl2o:editable'))
+ && n < 50)
+ {
+ // console.log($e, $e.parent(), this.element);
+ $e = $e.parent();
+ n += 1;
+ }
+
+ if(!$e.attr('wl2o:editable'))
+ return true;