.xmlview {
height: 100%;
}
+
+.view-overlay {
+ z-index: 1000;
+ background: #FFF;
+ opacity: 0.8;
+ text-align: center;
+ text-valign: center;
+}
+
+.view-overlay p {
+ display: block;
+ position: relative;
+ top: auto;
+ bottom: auto;
+ height: 40px;
+}
\ No newline at end of file
},
getXML: function(callback) {
+ $(this).trigger('modelxmlfreeze');
if (!this.data) {
this.getData(this.getXML);
} else {
this.modelChanged();
$(this).trigger('modelxmlchanged');
}
+ $(this).trigger('modelxmlunfreeze');
},
modelChanged: function() {
-/*global Class render_template panels */
-var HTMLView = Class.extend({
+/*global View render_template panels */
+var HTMLView = View.extend({
element: null,
model: null,
template: 'html-view-template',
},
dispose: function() {
-
+ this._super();
}
});
-/*globals Class render_template panels*/
+/*globals View render_template panels*/
-var PanelContainerView = Class.extend({
+var PanelContainerView = View.extend({
element: null,
model: null,
template: 'panel-container-view-template',
dispose: function() {
$('select', this.element.get(0)).unbind('change.panel-container-view');
+ this._super();
}
});
-/*globals Class*/
+/*globals View*/
// Split view inspired by jQuery Splitter Plugin http://methvin.com/splitter/
-var SplitView = Class.extend({
+var SplitView = View.extend({
splitbarClass: 'splitview-splitbar',
activeClass: 'splitview-active',
overlayClass: 'splitview-overlay',
dispose: function() {
this.splitter.unbind('mousedown.splitview');
+ this._super();
}
});
--- /dev/null
+/*globals Class render_template*/
+var View = Class.extend({
+ element: null,
+ model: null,
+ template: null,
+ overlayClass: 'view-overlay',
+ overlay: null,
+
+ init: function(element, model, template) {
+ this.element = $(element);
+ this.model = model;
+ this.template = template || this.template;
+
+ if (this.template) {
+ this.element.html(render_template(this.template, {}));
+ }
+ },
+
+ frozen: function() {
+ return !!this.overlay;
+ },
+
+ freeze: function(message) {
+ this.overlay = this.overlay
+ || $('<div><div>' + message + '</div></div>')
+ .addClass(this.overlayClass)
+ .css({
+ position: 'absolute',
+ width: this.element.width(),
+ height: this.element.height(),
+ top: this.element.position().top,
+ left: this.element.position().left
+ })
+ .appendTo(this.element.parent());
+
+ this.overlay.children('div').css({
+ position: 'relative',
+ top: this.overlay.height() / 2 - 20
+ });
+ },
+
+ unfreeze: function() {
+ if (this.frozen()) {
+ this.overlay.remove();
+ this.overlay = null;
+ }
+ },
+
+ dispose: function() {
+ this.unfreeze();
+ this.element.contents().remove();
+ }
+});
-/*global Class CodeMirror render_template panels */
-var XMLView = Class.extend({
+/*global View CodeMirror render_template panels */
+var XMLView = View.extend({
element: null,
model: null,
template: 'xml-view-template',
this.template = template || this.template;
this.element.html(render_template(this.template, {}));
- var self = this;
+ $(this.model)
+ .bind('modelxmlfreeze.xmlview',
+ function() { this.freeze('Ładowanie danych z serwera...'); }.bind(this))
+ .bind('modelxmlunfreeze.xmlview',
+ this.unfreeze.bind(this));
+
+ this.freeze('Ładowanie edytora...');
this.editor = new CodeMirror($('.xmlview', this.element).get(0), {
parserfile: 'parsexml.js',
path: "/static/js/lib/codemirror/",
stylesheet: "/static/css/xmlcolors.css",
parserConfig: {useHTMLKludges: false},
+ textWrapping: false,
+ tabMode: 'spaces',
+ indentUnit: 0,
// onChange: function() {
// self.fireEvent('contentChanged');
// },
$(editor.frame).css({width: '100%', height: '100%'});
this.editor.setCode(this.model.xml);
$(this.model).bind('modelxmlchanged.xmlview', this.codeChanged.bind(this));
+ this.unfreeze();
this.model.getXML();
// editor.grabKeys(
// $.fbind(self, self.hotkeyPressed),
codeChanged: function() {
console.log('setCode:', this.editor, this.model);
this.editor.setCode(this.model.xml);
+ this.unfreeze();
},
dispose: function() {
- $(this.model).unbind('modelxmlchanged.xmlview');
+ $(this.model)
+ .unbind('modelxmlchanged.xmlview')
+ .unbind('modelxmlfreeze.xmlview')
+ .unbind('modelxmlunfreeze.xmlview');
$(this.editor.frame).remove();
+ this._super();
}
});
<script src="{{STATIC_URL}}js/lib/jquery.json.js" type="text/javascript" charset="utf-8"></script>
<script src="{{STATIC_URL}}js/lib/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
<script src="{{STATIC_URL}}js/lib/jquery.modal.js" type="text/javascript" charset="utf-8"></script>
+
+ {# App and views #}
<script src="{{STATIC_URL}}js/app.js" type="text/javascript" charset="utf-8"></script>
+ <script src="{{STATIC_URL}}js/views/view.js" type="text/javascript" charset="utf-8"></script>
<script src="{{STATIC_URL}}js/views/split.js" type="text/javascript" charset="utf-8"></script>
<script src="{{STATIC_URL}}js/views/xml.js" type="text/javascript" charset="utf-8"></script>
<script src="{{STATIC_URL}}js/views/html.js" type="text/javascript" charset="utf-8"></script>
<script src="{{STATIC_URL}}js/views/panel_container.js" type="text/javascript" charset="utf-8"></script>
+
<script src="{{STATIC_URL}}js/editor.js" type="text/javascript" charset="utf-8"></script>
<script src="{{STATIC_URL}}js/editor.ui.js" type="text/javascript" charset="utf-8"></script>