Commit 92c12a2c authored by Marcel's avatar Marcel
Browse files

Miscellaneous small improvements.

parent 5250a8d1
......@@ -92,6 +92,7 @@ var DummyContent = ExtensionContentFull.extend({
},
getContent: function() {
var _this = this;
return this.nodes.content = $('<div />')
.addClass('dummy-full-body')
.css('background-color', this.config.backgroundColor)
......
......@@ -108,9 +108,9 @@ class FileSystem(object):
suggestions = []
source, filter = None, None
# does the path exist?
if os.path.exists(os.path.expanduser(path)):
if os.path.exists(os.path.expanduser(os.path.expandvars(path))):
# dir case
if os.path.isdir(os.path.expanduser(path)):
if os.path.isdir(os.path.expanduser(os.path.expandvars(path))):
if path.endswith('/'):
source = path
else:
......@@ -122,7 +122,7 @@ class FileSystem(object):
else:
# try to estimate source and filter
head, tail = os.path.split(path)
if os.path.isdir(os.path.expanduser(head)):
if os.path.isdir(os.path.expanduser(os.path.expandvars(head))):
source = head
filter = tail
......@@ -130,7 +130,7 @@ class FileSystem(object):
if not source:
return suggestions
files = os.listdir(os.path.expanduser(source))
files = os.listdir(os.path.expanduser(os.path.expandvars(source)))
# resort?
if append_hidden:
files = sorted(files, cmp=file_compare, key=str.lower)
......@@ -139,7 +139,7 @@ class FileSystem(object):
if filter and not file.startswith(filter):
continue
suggestion = os.path.join(source, file)
if not suggestion.endswith('/') and os.path.isdir(os.path.expanduser(suggestion)):
if not suggestion.endswith('/') and os.path.isdir(os.path.expanduser(os.path.expandvars(suggestion))):
suggestion += '/'
suggestions.append(suggestion)
......
......@@ -185,7 +185,7 @@
}
.extension-menu-dropzone-used {
box-shadow: inset -1px 0px 1px rgba(30, 30, 30, 0.3);
box-shadow: inset -1px 0px 0px rgba(30, 30, 30, 0.3);
}
.extension-menu-shorthand-button {
......@@ -211,3 +211,20 @@
.extension-menu-shorthand-button-inner {
text-align: center;
}
.extension-loader {
position: absolute;
height: 100%;
width: 100%;
display: none;
}
.extension-loader-inner {
display: table-cell;
vertical-align: middle;
text-align: center;
color: #3383bb;
font-family: 'Trebuchet MS', Helvetica, Arial, sans-serif;
font-size: 16px;
font-weight: bold;
}
......@@ -26,9 +26,9 @@
.pathbar-display-button {
position: absolute;
top: 1px;
left: 0px;
left: 4px;
height: 20px;
width: 56px;
width: 52px;
font-family: 'Trebuchet MS', Helvetica, Arial, sans-serif;
font-size: 13px;
font-weight: normal;
......@@ -100,17 +100,17 @@
padding: 1px 6px 2px 6px;
border-radius: 5px;
text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.8);
background-image: linear-gradient(top, #3383bb 0%, black 300%);
background-image: -webkit-linear-gradient(top, #3383bb 0%, black 300%);
background-image: -moz-linear-gradient(top, #3383bb 0%, black 300%);
background-image: -o-linear-gradient(top, #3383bb 0%, black 300%);
background-image: linear-gradient(top, #3383bb 0%, black 400%);
background-image: -webkit-linear-gradient(top, #3383bb 0%, black 400%);
background-image: -moz-linear-gradient(top, #3383bb 0%, black 400%);
background-image: -o-linear-gradient(top, #3383bb 0%, black 400%);
}
.pathbar-input-loader-filelabel-true {
background-image: linear-gradient(top, green 0%, black 300%);
background-image: -webkit-linear-gradient(top, green 0%, black 300%);
background-image: -moz-linear-gradient(top, green 0%, black 300%);
background-image: -o-linear-gradient(top, green 0%, black 300%);
background-image: linear-gradient(top, green 0%, black 400%);
background-image: -webkit-linear-gradient(top, green 0%, black 400%);
background-image: -moz-linear-gradient(top, green 0%, black 400%);
background-image: -o-linear-gradient(top, green 0%, black 400%);
}
.pathbar-input-loader-filelabel-false {
......
......@@ -14,11 +14,6 @@ var Messenger = Class.extend({
init: function(config) {
// attributes
this.settings = {
defaultContext: 'global',
defaultType: 'info',
notificationFx: {duration: 50, easing: 'linear'}
};
this.defaultConfig = {
notificationDuration: {
descr: 'The duration a notification is shown',
......@@ -39,6 +34,11 @@ var Messenger = Class.extend({
value: 'info'
}
};
this.settings = {
defaultContext: 'global',
defaultType: 'info',
notificationFx: {duration: 50, easing: 'linear'}
};
this.workflow = {};
this.config = $.Helpers.createConfig(config, this.defaultConfig);
this.stacks = {};
......@@ -90,6 +90,8 @@ var Messenger = Class.extend({
if ($.isFunction(callback)) {
callback();
}
// call the msgPushTopic
$.Topic('msg.pushed').publish(data);
return this;
},
......@@ -152,7 +154,7 @@ var Messenger = Class.extend({
},
createDialog: function(type, data) {
switch(type) {
switch(type.toLowerCase()) {
case 'error':
return this.createError(data);
case 'confirm':
......@@ -286,23 +288,56 @@ var Messenger = Class.extend({
return this.template(data);
},
error: function(text, callback) {
this.push({type: 'error', content: text, callback: callback});
info: function(data) {
var defaultData = {
type: 'info',
content: 'Info',
callback: function(){}
};
if(typeof(data) == 'string') {
data = {content: data};
}
this.push($.extend(true, defaultData, data));
return this;
},
info: function(text, callback) {
this.push({type: 'info', content: text, callback: callback});
error: function(data) {
var defaultData = {
type: 'error',
content: 'Error',
callback: function(){}
};
if(typeof(data) == 'string') {
data = {content: data};
}
this.push($.extend(true, defaultData, data));
return this;
},
confirm: function(text, callback) {
this.push({type: 'confirm', content: text, callback: callback});
confirm: function(data) {
var defaultData = {
type: 'confirm',
content: 'Confirm',
callback: function(){}
};
if(typeof(data) == 'string') {
data = {content: data};
}
this.push($.extend(true, defaultData, data));
return this;
},
prompt: function(text, callback, preselection) {
this.push({type: 'prompt', text: text, callback: callback, preselection: preselection});
prompt: function(data) {
var defaultData = {
type: 'prompt',
text: 'Prompt',
callback: function(){},
preselection: null
}
if(typeof(data) == 'string') {
data = {text: data};
}
this.push($.extend(true, defaultData, data));
return this;
},
......@@ -451,6 +486,9 @@ var Messenger = Class.extend({
$.Topic('msg').subscribe(function() {
return _this.push.apply(_this, arguments);
});
$.Topic('msg.fetch').subscribe(function() {
return _this.fetch.apply(_this, arguments);
});
$.Topic('msg.info').subscribe(function() {
return _this.info.apply(_this, arguments);
});
......
......@@ -11,6 +11,7 @@ var CommandPalette = VispaModule.extend({
this._super(vispa, 'commandPalette', this.defaultConfig, config);
// attributes
this.preferenceSettings = {priority: 6};
this.settings = {
shortcut: 'ctrl+shift+p',
headerOffset: 50,
......
var ExtensionManager = VispaModule.extend({
init: function(vispa, config, extensionConfig) {
this.defaultConfig = {};
this.defaultConfig = {
reuseInstances: {
desc: 'When creating a new instance, use an existing one if they have the same identifier (i.e. path, etc)?',
type: 'boolean',
value: true
}
};
this._super(vispa, 'extensionManager', this.defaultConfig, config);
// attributes
this.preferenceSettings = {priority: 10};
this.settings = {
argSeparator: ':'
};
......@@ -28,6 +35,11 @@ var ExtensionManager = VispaModule.extend({
return this;
},
applyConfig: function() {
// reuseInstances => dynamic
return this;
},
getExtension: function(extension) {
if(typeof(extension) == 'string') {
if(this.extensionStore[extension]) {
......@@ -182,7 +194,7 @@ var ExtensionManager = VispaModule.extend({
return false;
}
});
if(targetInstance) {
if(targetInstance && this.config.reuseInstances) {
// show it
this.showInstance(targetInstance, byUrl);
return this;
......@@ -280,9 +292,15 @@ var ExtensionManager = VispaModule.extend({
$.each(instance.menuEntries, function(i, entry) {
addDragClass(entry);
});
// add a $.Shortcuts object, named by the id
instance.shortcuts = $.Shortcuts(instance._id);
this.vispa.extensionView.addFullInstance(instance);
// create the view
var viewData = this.vispa.extensionView.addFullInstance(instance);
// store the view data in the instance
instance._viewData = viewData;
}
return this;
},
......@@ -369,6 +387,9 @@ var ExtensionManager = VispaModule.extend({
// call afterShow
instance.afterShow();
// fetch messages for the context <instance._id>
$.Topic('msg.fetch').publish(instance._id);
}
return this;
},
......@@ -446,14 +467,10 @@ var ExtensionManager = VispaModule.extend({
// create a new instance
var args = [extension, factory, null, true].concat(_this.splitArgs(value));
_this.createInstance.apply(_this, args);
} else {//if(!factory._instances[key]) {
} else {
var args = [extension, factory, obj.number, true].concat(_this.splitArgs(value));
_this.createInstance.apply(_this, args);
}/* else {
// the instance exists, pass 'value' to it
console.log("pass", value, "to instance with id", key);//TODO
_this.showInstance(key, true);
}*/
}
hit = true;
});
if(!hit) {
......@@ -689,6 +706,12 @@ var ExtensionManager = VispaModule.extend({
return this.vispa.urlHandler.dynamic('extensions', name, method);
},
fetchMessages: function() {
// current full instance
$.Topic('msg.fetch').publish(this.vispa.extensionView.workflow.currentFullInstance);
return this;
},
setupTopics: function() {
var _this = this;
$.Topic('extman.register').subscribe(function() {
......@@ -697,6 +720,9 @@ var ExtensionManager = VispaModule.extend({
$.Topic('extman.cfg.submit').subscribe(function() {
return _this.submitPreferences.apply(_this, arguments);
});
$.Topic('msg.pushed').subscribe(function() {
return _this.fetchMessages.apply(_this, arguments);
});
return this;
}
});
......@@ -788,6 +814,7 @@ var ExtensionContentBase = Class.extend({
this._number = null;
this._id = null;
this._identifier = identifier;
this._viewData = null;
// public attributes
this.logger = null;
this.config = config;
......@@ -845,6 +872,17 @@ var ExtensionContentBase = Class.extend({
getContent: function() {
return '';
},
setLoading: function(state) {
if(this._viewData && this._viewData.content) {
if(state) {
$(this._viewData.loader).css('display', 'table');
} else {
$(this._viewData.loader).hide();
}
}
return this;
}
});
......
......@@ -525,6 +525,20 @@ var ExtensionView = VispaModule.extend({
return dropZone.get(0);
},
makeLoader: function(instance, target) {
// there may be a distinction between instance types if necessary
var loaderImg = $('<img />').attr('src', this.vispa.urlHandler.dynamic('static/img/maingui/loader2.gif'));
var loaderText = $('<span />').html('Loading<br /><br />');
var loaderInner = $('<div />')
.addClass('extension-loader-inner')
.append(loaderText, loaderImg);
var loader = $('<div />')
.addClass('extension-loader ui-widget-overlay')
.append(loaderInner)
.appendTo(target);
return loader.get(0);
},
addFullInstance: function(instance) {
if (this.instances[instance._id]) {
return this;
......@@ -532,10 +546,9 @@ var ExtensionView = VispaModule.extend({
// setup the view for that instance
var data = this.setupFullInstance(instance);
this.instances[instance._id] = $.extend(true, {
return this.instances[instance._id] = $.extend(true, {
instance: instance
}, data);
return this;
},
setupFullInstance: function(instance) {
......@@ -548,10 +561,12 @@ var ExtensionView = VispaModule.extend({
.get(0);
var badge = this.addBadge(instance);
var menu = this.addExtensionMenu(instance);
var loader = this.makeLoader(instance, content);
return {
content: content,
badge: badge,
menu: menu
menu: menu,
loader: loader
};
},
......
......@@ -17,7 +17,7 @@ var PathBar = VispaModule.extend({
this._super(vispa, 'pathBar', this.defaultConfig, config);
// attributes
this.preferenceSettings = {priority: 3, entryOrder: ['nSuggestions']};
this.preferenceSettings = {priority: 8, entryOrder: ['nSuggestions']};
this.settings = {
shortcut: 'ctrl+shift+g',
checkDelay: 1000,
......
......@@ -11,7 +11,7 @@ var PreferenceView = VispaModule.extend({
this._super(vispa, 'preferenceView', this.defaultConfig, config);
// attributes
this.preferenceSettings = {priority: 5};
this.preferenceSettings = {priority: 4};
this.settings = {
shortcut: 'ctrl+p',
dialogHeight: 360,
......
......@@ -24,7 +24,7 @@ var View = VispaModule.extend({
this._super(vispa, 'view', this.defaultConfig, config);
// attributes
this.preferenceSettings = {priority: 10, entryOrder: ['sidebarAlignment', 'sidebarWidth', 'headerHeight']};
this.preferenceSettings = {priority: 12, entryOrder: ['sidebarAlignment', 'sidebarWidth', 'headerHeight']};
this.settings = {
headerMinHeight: 60,
headerMaxHeight: 120,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment