Skip to content

Commit

Permalink
BUGFIX: Fix error notification on files (fixes: 7295)
Browse files Browse the repository at this point in the history
Add title text to all status messages
Make room for the error message details by expanding the name area in
the file details
Fix up changes status to work with selects
  • Loading branch information
adrexia committed May 11, 2012
1 parent 7f4c6e3 commit 9844328
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 17 deletions.
8 changes: 4 additions & 4 deletions css/AssetUploadField.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 28 additions & 8 deletions javascript/UploadField.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,26 @@
var disabled;
var iframe = editform.find('iframe');
var inputs = iframe.contents().find('.ss-uploadfield-edit-iframe input');
var ulSelects =iframe.contents().find('.ss-uploadfield-edit-iframe .chzn-drop ul.chzn-results');

for(var i=0;i<inputs.length;i++){
$(inputs[i]).change(function(){
editform.removeClass('edited');
editform.addClass('edited');
});
}

}
for(var i=0;i<ulSelects.length;i++){
var current= $(ulSelects[i]).find('li.result-selected');
$(ulSelects[i]).children('li').click(function(){
if(this !== current[0]){
editform.removeClass('edited');
editform.addClass('edited');
}
});
}


if (editform.hasClass('loading')) {
// TODO Display loading indication, and register an event to toggle edit form
} else {
Expand Down Expand Up @@ -339,11 +353,13 @@
toggleEditForm: function() {
var itemInfo = this.prev('.ss-uploadfield-item-info'), status = itemInfo.find('.ss-uploadfield-item-status');
var iframe = this.find('iframe').contents(), saved=iframe.find('#Form_EditForm_error');

var text="";

if(this.height() === 0) {
text = "Editing...";
this.fitHeight();
itemInfo.find('.toggle-details-icon').addClass('opened');
status.removeClass('ui-state-success-text').removeClass('ui-state-warning-text').text("Editing...");
status.removeClass('ui-state-success-text').removeClass('ui-state-warning-text');
iframe.find('#Form_EditForm_action_doEdit').click(function(){
itemInfo.find('label .name').text(iframe.find('#Name input').val());
});
Expand All @@ -352,22 +368,26 @@
}

} else {
this.height(0);
this.height(0);
itemInfo.find('.toggle-details-icon').removeClass('opened');
$('div.ss-upload .fileOverview .ss-uploadfield-item-edit-all').removeClass('opened').find('.toggle-details-icon').removeClass('opened');
if(!this.hasClass('edited')){
status.addClass('ui-state-success-text').text(ss.i18n._t('UploadField.NOCHANGES', 'No Changes'));
text = ss.i18n._t('UploadField.NOCHANGES', 'No Changes')
status.addClass('ui-state-success-text');
}else{
if(saved.hasClass('good')){
text = ss.i18n._t('UploadField.CHANGESSAVED', 'Changes Saved')
this.removeClass('edited').parent('.ss-uploadfield-item').removeClass('ui-state-warning');
status.addClass('ui-state-success-text').text(ss.i18n._t('UploadField.CHANGESSAVED', 'Changes Saved'));
status.addClass('ui-state-success-text');
}else{
text = ss.i18n._t('UploadField.UNSAVEDCHANGES', 'Unsaved Changes')
this.parent('.ss-uploadfield-item').addClass('ui-state-warning');
status.addClass('ui-state-warning-text').text(ss.i18n._t('UploadField.UNSAVEDCHANGES', 'Unsaved Changes'));
}
status.addClass('ui-state-warning-text');
}
}
saved.removeClass('good').hide();
}
status.attr('title',text).text(text);
}
});
$('div.ss-upload .ss-uploadfield-item-editform iframe').entwine({
Expand Down
6 changes: 3 additions & 3 deletions javascript/UploadField_downloadtemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ window.tmpl.cache['ss-uploadfield-downloadtemplate'] = tmpl(
'</span></div>' +
'<div class="ss-uploadfield-item-info">' +
'<label class="ss-uploadfield-item-name">' +
'<span class="name">{%=file.name%}</span> ' +
'<span class="name" title="{%=file.name%}">{%=file.name%}</span> ' +
'{% if (!file.error) { %}' +
'<div class="ss-uploadfield-item-status ui-state-success-text">Uploaded</div>' +
'<div class="ss-uploadfield-item-status ui-state-success-text" title="Uploaded">Uploaded</div>' +
'{% } else { %}' +
'<div class="ss-uploadfield-item-status ui-state-error-text">{%=o.options.errorMessages[file.error].substring(0,25) || file.error.substring(0,25)%}</div>' +
'<div class="ss-uploadfield-item-status ui-state-error-text" title="{%=o.options.errorMessages[file.error] || file.error%}">{%=o.options.errorMessages[file.error] || file.error%}</div>' +
'{% } %}' +
'<div class="clear"><!-- --></div>' +
'</label>' +
Expand Down
5 changes: 3 additions & 2 deletions javascript/UploadField_uploadtemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ window.tmpl.cache['ss-uploadfield-uploadtemplate'] = tmpl(
'<div class="ss-uploadfield-item-preview preview"><span></span></div>' +
'<div class="ss-uploadfield-item-info">' +
'<label class="ss-uploadfield-item-name">' +
'<span class="name">{% if (file.name) { %}{%=file.name%}{% } else { %}' + ss.i18n._t('UploadField.NOFILENAME', 'Untitled') + '{% } %}</span> ' +
'<span class="name" title="{% if (file.name) { %}{%=file.name%}{% } else { %}' + ss.i18n._t('UploadField.NOFILENAME', 'Untitled') + '{% } %}">' +
'{% if (file.name) { %}{%=file.name%}{% } else { %}' + ss.i18n._t('UploadField.NOFILENAME', 'Untitled') + '{% } %}</span> ' +
'{% if (!file.error) { %}' +
'<div class="ss-uploadfield-item-status">0%</div>' +
'{% } else { %}' +
'<div class="ss-uploadfield-item-status ui-state-error-text">{%=o.options.errorMessages[file.error].substring(0,25) || file.error.substring(0,25)%}</div>' +
'<div class="ss-uploadfield-item-status ui-state-error-text" title="{%=o.options.errorMessages[file.error] || file.error%}">{%=o.options.errorMessages[file.error] || file.error%}</div>' +
'{% } %}' +
'<div class="clear"><!-- --></div>' +
'</label>' +
Expand Down
6 changes: 6 additions & 0 deletions scss/AssetUploadField.scss
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ body.cms.ss-uploadfield-edit-iframe {
}
.ui-state-error .ss-uploadfield-item-info {
background-color: #c11f1d;
padding-right:110px;
@include background-image(linear-gradient(top, #c11f1d 0%,#bf1d1b 4%,#b71b1c 8%,#b61e1d 15%,#b11d1d 27%,#ab1d1c 31%,#a51b1b 42%,#9f1b19 46%,#9f1b19 50%,#991c1a 54%,#971a18 58%,#911b1b 62%,#911b1b 65%,#7e1816 88%,#771919 92%,#731817 100%));
.ss-uploadfield-item-name{
width:100%;
cursor:default;
background: darken($color-button-disabled,20%); //for browsers that don't support rgba
background: rgba(darken($color-button-disabled, 15%),0.9);
Expand Down Expand Up @@ -153,12 +155,16 @@ body.cms.ss-uploadfield-edit-iframe {
@include hide-text-overflow;
}
.ss-uploadfield-item-status {
position:relative;
float: right;
padding: 0 0 0 5px;
max-width:30%;
@include hide-text-overflow;
text-shadow: 0px 1px 0px rgba(#fff, 0.5);
&.ui-state-error-text {
max-width:70%;
position:absolute;
right:5px;
text-shadow: 0px 1px 0px rgba(#fff, 0.6);
color: darken($color-button-destructive, 10%);
}
Expand Down

0 comments on commit 9844328

Please sign in to comment.