-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show error-view instead of yellow notification on content loading errors
- Loading branch information
1 parent
f8bb1a2
commit 52fd506
Showing
8 changed files
with
164 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class=""> | ||
{{#if icon}}<div class="{{icon}}"></div>{{/if}} | ||
<h2>{{{ text }}}</h2> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* @author Christoph Wurst <christoph@winzerhof-wurst.at> | ||
* | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
define(function(require) { | ||
'use strict'; | ||
|
||
var smileys = [ | ||
':-(', | ||
':-/', | ||
':-\\', | ||
':-|', | ||
':\'-(', | ||
':\'-/', | ||
':\'-\\', | ||
':\'-|' | ||
]; | ||
|
||
function getRandomSmiley() { | ||
return smileys[Math.floor(Math.random() * smileys.length)] | ||
} | ||
|
||
/** | ||
* @param {Folder} folder | ||
* @returns {string} | ||
*/ | ||
function getRandomFolderErrorMessage(folder) { | ||
var folderName = folder.get('name'); | ||
var rawTexts = [ | ||
t('mail', 'Could not load {tag}{name}{endtag}', { | ||
name: folderName | ||
}), | ||
t('mail', 'We couldn’t load {tag}{name}{endtag}', { | ||
name: folderName | ||
}), | ||
t('mail', 'There was a problem loading {tag}{name}{endtag}', { | ||
name: folderName | ||
}) | ||
]; | ||
var texts = _.map(rawTexts, function(text) { | ||
return text.replace('{tag}', '<strong>').replace('{endtag}', '</strong>'); | ||
}); | ||
var text = texts[Math.floor(Math.random() * texts.length)] | ||
return text + ' ' + getRandomSmiley(); | ||
} | ||
|
||
/** | ||
* @returns {string} | ||
*/ | ||
function getRandomMessageErrorMessage() { | ||
var rawTexts = [ | ||
t('mail', 'We couldn’t load your message'), | ||
t('mail', 'Unable to load the desired message'), | ||
t('mail', 'There was a problem loading the message') | ||
]; | ||
var texts = _.map(rawTexts, function(text) { | ||
return text.replace('{tag}', '<strong>').replace('{endtag}', '</strong>'); | ||
}); | ||
var text = texts[Math.floor(Math.random() * texts.length)] | ||
return text + ' ' + getRandomSmiley(); | ||
} | ||
|
||
return { | ||
getRandomFolderErrorMessage: getRandomFolderErrorMessage, | ||
getRandomMessageErrorMessage: getRandomMessageErrorMessage | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* @author Christoph Wurst <christoph@winzerhof-wurst.at> | ||
* | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
define(function(require) { | ||
'use strict'; | ||
|
||
var Handlebars = require('handlebars'); | ||
var Marionette = require('marionette'); | ||
var ErrorTemplate = require('text!templates/error.html'); | ||
|
||
var ErrorView = Marionette.ItemView.extend({ | ||
id: 'emptycontent', | ||
className: 'container', | ||
template: Handlebars.compile(ErrorTemplate), | ||
templateHelpers: function() { | ||
return { | ||
text: this.text, | ||
icon: this.icon | ||
}; | ||
}, | ||
initialize: function(options) { | ||
this.text = options.text || t('mail', 'An unknown error occurred'); | ||
this.icon = options.icon || 'icon-mail'; | ||
} | ||
}); | ||
|
||
return ErrorView; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters