Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Fix session and editor handling of focus mode, fixes #97
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Sep 18, 2012
1 parent 8b64bc7 commit 39a6e8e
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 42 deletions.
4 changes: 2 additions & 2 deletions examples/create-min.js

Large diffs are not rendered by default.

46 changes: 26 additions & 20 deletions examples/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@
this._setEditButtonState(state);
},

setToolbar: function (state) {
this.options.toolbar = state;
this.element.midgardToolbar('setDisplay', state);
},

showNotification: function (options) {
if (this.element.midgardNotifications) {
return this.element.midgardNotifications('create', options);
Expand Down Expand Up @@ -230,7 +235,7 @@

var toolbarID = this.options.storagePrefix + 'Midgard.create.toolbar';
if (window.sessionStorage.getItem(toolbarID)) {
this._setOption('toolbar', window.sessionStorage.getItem(toolbarID));
this.setToolbar(window.sessionStorage.getItem(toolbarID));
}

var stateID = this.options.storagePrefix + 'Midgard.create.state';
Expand Down Expand Up @@ -298,10 +303,10 @@
_enableToolbar: function () {
var widget = this;
this.element.bind('midgardtoolbarstatechange', function (event, options) {
widget.setToolbar(options.display);
if (window.sessionStorage) {
window.sessionStorage.setItem(widget.options.storagePrefix + 'Midgard.create.toolbar', options.display);
}
widget._setOption('toolbar', options.display);
});

this.element.midgardToolbar({
Expand All @@ -314,7 +319,7 @@
this._setOption('state', 'edit');
var widget = this;
var editableOptions = {
toolbarState: widget.options.display,
toolbarState: widget.options.toolbar,
disabled: false,
vie: widget.vie,
widgets: widget.options.editorWidgets,
Expand Down Expand Up @@ -883,6 +888,7 @@
var editorWidget = this._editorWidget(editorName);

data.editorOptions = this._editorOptions(editorName);
data.toolbarState = this.options.toolbarState;
data.disabled = false;

if (typeof jQuery(data.element)[editorWidget] !== 'function') {
Expand Down Expand Up @@ -1118,12 +1124,14 @@
});
this.options.disabled = false;
},

disable: function () {
jQuery(this.element).hallo({
editable: false
});
this.options.disabled = true;
},

_initialize: function () {
jQuery(this.element).hallo(this.getHalloOptions());
var self = this;
Expand Down Expand Up @@ -2703,19 +2711,12 @@
var widget = this;
jQuery('.create-ui-toggle', this.element).click(function () {
if (widget.options.display === 'full') {
widget.hide();
widget.options.display = 'minimized';
widget.setDisplay('minimized');
} else {
widget.show();
widget.options.display = 'full';
widget.setDisplay('full');
}
widget._trigger('statechange', null, widget.options);
});

this._setDisplay(this.options.display);

widget = this;

jQuery(this.element).bind('midgardcreatestatechange', function (event, options) {
if (options.state == 'browse') {
widget._clearWorkflows();
Expand All @@ -2739,17 +2740,22 @@
});
},

_setOption: function (key, value) {
if (key === 'display') {
this._setDisplay(value);
}
this.options[key] = value;
_init: function () {
this.setDisplay(this.options.display);
},

_setDisplay: function (value) {
setDisplay: function (value) {
if (value === this.options.display) {
return;
}
if (value === 'minimized') {
jQuery('div.create-ui-toolbar-wrapper').hide();
}
this.hide();
this.options.display = 'minimized';
} else {
this.show();
this.options.display = 'full';
}
this._trigger('statechange', null, this.options);
},

hide: function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
});
this.options.disabled = false;
},

disable: function () {
jQuery(this.element).hallo({
editable: false
});
this.options.disabled = true;
},

_initialize: function () {
jQuery(this.element).hallo(this.getHalloOptions());
var self = this;
Expand Down
11 changes: 8 additions & 3 deletions src/jquery.Midgard.midgardCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@
this._setEditButtonState(state);
},

setToolbar: function (state) {
this.options.toolbar = state;
this.element.midgardToolbar('setDisplay', state);
},

showNotification: function (options) {
if (this.element.midgardNotifications) {
return this.element.midgardNotifications('create', options);
Expand Down Expand Up @@ -230,7 +235,7 @@

var toolbarID = this.options.storagePrefix + 'Midgard.create.toolbar';
if (window.sessionStorage.getItem(toolbarID)) {
this._setOption('toolbar', window.sessionStorage.getItem(toolbarID));
this.setToolbar(window.sessionStorage.getItem(toolbarID));
}

var stateID = this.options.storagePrefix + 'Midgard.create.state';
Expand Down Expand Up @@ -298,10 +303,10 @@
_enableToolbar: function () {
var widget = this;
this.element.bind('midgardtoolbarstatechange', function (event, options) {
widget.setToolbar(options.display);
if (window.sessionStorage) {
window.sessionStorage.setItem(widget.options.storagePrefix + 'Midgard.create.toolbar', options.display);
}
widget._setOption('toolbar', options.display);
});

this.element.midgardToolbar({
Expand All @@ -314,7 +319,7 @@
this._setOption('state', 'edit');
var widget = this;
var editableOptions = {
toolbarState: widget.options.display,
toolbarState: widget.options.toolbar,
disabled: false,
vie: widget.vie,
widgets: widget.options.editorWidgets,
Expand Down
1 change: 1 addition & 0 deletions src/jquery.Midgard.midgardEditable.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
var editorWidget = this._editorWidget(editorName);

data.editorOptions = this._editorOptions(editorName);
data.toolbarState = this.options.toolbarState;
data.disabled = false;

if (typeof jQuery(data.element)[editorWidget] !== 'function') {
Expand Down
32 changes: 15 additions & 17 deletions src/jquery.Midgard.midgardToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,12 @@
var widget = this;
jQuery('.create-ui-toggle', this.element).click(function () {
if (widget.options.display === 'full') {
widget.hide();
widget.options.display = 'minimized';
widget.setDisplay('minimized');
} else {
widget.show();
widget.options.display = 'full';
widget.setDisplay('full');
}
widget._trigger('statechange', null, widget.options);
});

this._setDisplay(this.options.display);

widget = this;

jQuery(this.element).bind('midgardcreatestatechange', function (event, options) {
if (options.state == 'browse') {
widget._clearWorkflows();
Expand All @@ -62,17 +55,22 @@
});
},

_setOption: function (key, value) {
if (key === 'display') {
this._setDisplay(value);
}
this.options[key] = value;
_init: function () {
this.setDisplay(this.options.display);
},

_setDisplay: function (value) {
setDisplay: function (value) {
if (value === this.options.display) {
return;
}
if (value === 'minimized') {
jQuery('div.create-ui-toolbar-wrapper').hide();
}
this.hide();
this.options.display = 'minimized';
} else {
this.show();
this.options.display = 'full';
}
this._trigger('statechange', null, this.options);
},

hide: function () {
Expand Down

0 comments on commit 39a6e8e

Please sign in to comment.