var panelRoot = $('#panels');
self.rootDiv = panelRoot;
- // Set panel widths from options.panelRatios
- if (self.options && self.options.panelRatios) {
+ // Set panel widths from options.panels
+ if (self.options && self.options.panels) {
var totalWidth = 0;
$('.panel-wrap', panelRoot).each(function(index) {
- var panelWidth = self.options.panelRatios[index] * panelRoot.width();
+ var panelWidth = self.options.panels[index].ratio * panelRoot.width();
if ($(this).hasClass('last-panel')) {
$(this).css({
left: totalWidth,
});
totalWidth += panelWidth;
}
+ $('.panel-toolbar select', this).val(
+ $('.panel-toolbar option[name=' + self.options.panels[index].name + ']', this).attr('value')
+ )
});
}
$('#panels > *.panel-wrap').each(function() {
var panelWrap = $(this);
$.log('wrap: ', panelWrap);
- panelWrap.data('ctrl', new Panel(panelWrap)); // attach controllers to wraps
-
+ panel = new Panel(panelWrap);
+ panelWrap.data('ctrl', panel); // attach controllers to wraps
+ panel.load($('.panel-toolbar select', panelWrap).val());
+
$('.panel-toolbar select', panelWrap).change(function() {
- panelWrap.data('ctrl').load( $(this).val() );
+ var url = $(this).val();
+ panelWrap.data('ctrl').load(url);
+ var panels = [];
+ $('.panel-wrap', panelRoot).not('.panel-content-overlay').each(function(index) {
+ panels.push({
+ name: $('.panel-toolbar option:selected', this).attr('name'),
+ ratio: $(this).width() / panelRoot.width()
+ })
+ });
+ self.options.panels = panels;
+ $.log($.toJSON(self.options));
+ $.cookie('options', $.toJSON(self.options), { expires: 7, path: '/'});
});
});
-
+
$('#toolbar-button-save').click( function (event, data) { self.saveToBranch(); } );
panelRoot.bind('stopResize', function() {
- var panelRatios = [];
- $('.panel-wrap', panelRoot).each(function() {
- panelRatios.push($(this).width() / panelRoot.width());
+ var panels = [];
+ $('.panel-wrap', panelRoot).not('.panel-content-overlay').each(function() {
+ panels.push({
+ name: $('.panel-toolbar option:selected', this).attr('name'),
+ ratio: $(this).width() / panelRoot.width()
+ })
});
- self.options.panelRatios = panelRatios;
+ self.options.panels = panels;
$.log($.toJSON(self.options));
$.cookie('options', $.toJSON(self.options), { expires: 7, path: '/'});
});
Editor.prototype.loadConfig = function() {
// Load options from cookie
- var cookie = $.cookie('options')
- if (cookie) {
+ try {
+ var cookie = $.cookie('options');
this.options = $.secureEvalJSON(cookie);
- } else {
- // Default options
- this.options = {panelRatios: [0.5, 0.5]}
+ } catch (e) {
+ this.options = {
+ panels: [
+ {name: 'htmleditor', ratio: 0.5},
+ {name: 'gallery', ratio: 0.5}
+ ]
+ }
}
+ $.log(this.options);
}
Editor.prototype.saveToBranch = function() {
<div id="left-panel-toolbar" class="panel-toolbar">
<label for="select-left-panel">Lewy panel:</label>
<select name="select-left-panel" id="select-left-panel">
- <option value="{% url xmleditor_panel hash %}">Edytor XML</option>
- <option value="{% url htmleditor_panel hash %}">Edytor HTML</option>
- <option value="{% url gallery_panel hash %}">Galeria skanów</option>
- <option value="{% url dceditor_panel hash %}">Edytor DublinCore</option>
+ <option value="{% url xmleditor_panel hash %}" name="xmleditor">Edytor XML</option>
+ <option value="{% url htmleditor_panel hash %}" name="htmleditor">Edytor HTML</option>
+ <option value="{% url gallery_panel hash %}" name="gallery">Galeria skanów</option>
+ <option value="{% url dceditor_panel hash %}" name="dceditor">Edytor DublinCore</option>
</select>
<strong class="change-notification" style="display: none">Widok nieaktualny!</strong>
</div>
<div id="right-panel-toolbar" class="panel-toolbar">
<label for="select-right-panel">Prawy panel:</label>
<select name="select-right-panel" id="select-right-panel">
- <option value="{% url xmleditor_panel hash %}">Edytor XML</option>
- <option value="{% url htmleditor_panel hash %}">Edytor HTML</option>
- <option value="{% url gallery_panel hash %}">Galeria skanów</option>
- <option value="{% url dceditor_panel hash %}">Edytor DublinCore</option>
+ <option value="{% url xmleditor_panel hash %}" name="xmleditor">Edytor XML</option>
+ <option value="{% url htmleditor_panel hash %}" name="htmleditor">Edytor HTML</option>
+ <option value="{% url gallery_panel hash %}" name="gallery">Galeria skanów</option>
+ <option value="{% url dceditor_panel hash %}" name="dceditor">Edytor DublinCore</option>
</select>
<strong class="change-notification" style="display: none">Widok nieaktualny!</strong>
</div>