Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG Make UI widget destroys more consistent to avoid exceptions. #3286

Merged
merged 1 commit into from
Jul 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions admin/javascript/LeftAndMain.FieldHelp.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
$(".cms .field.cms-description-tooltip").entwine({
onmatch: function() {
this._super();

var descriptionEl = this.find('.description'), inputEl, tooltipEl;
if(descriptionEl.length) {
this
Expand All @@ -19,8 +21,8 @@
.tooltip({content: descriptionEl.html()});
descriptionEl.remove();
}
}
});
},
});

$(".cms .field.cms-description-tooltip :input").entwine({
onfocusin: function(e) {
Expand Down
3 changes: 2 additions & 1 deletion admin/javascript/LeftAndMain.Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,8 @@
});

$('.cms-edit-form').entwine({
onadd: function() {
onadd: function() {
this._super();
$('.cms-preview')._initialiseFromContent();
}
});
Expand Down
4 changes: 2 additions & 2 deletions admin/javascript/LeftAndMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,8 @@ jQuery.noConflict();
setTimeout(function() {
form.clickedButton = null;
}, 10);
}
});
}
});

this.redraw();
this._super();
Expand Down
2 changes: 1 addition & 1 deletion admin/javascript/MemberDatetimeOptionsetField.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function($) {
$.entwine('ss', function($){

$('.memberdatetimeoptionset').entwine({
onmatch: function() {
this.find('.description .toggle-content').hide();
Expand Down
24 changes: 13 additions & 11 deletions javascript/GridField.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

reload: function(ajaxOpts, successCallback) {
var self = this, form = this.closest('form'),
var self = this, form = this.closest('form'),
focusedElName = this.find(':input:focus').attr('name'), // Save focused element for restoring after refresh
data = form.find(':input').serializeArray();

Expand All @@ -23,7 +23,7 @@
ajaxOpts.data = window.location.search.replace(/^\?/, '') + '&' + $.param(ajaxOpts.data);
}

// For browsers which do not support history.pushState like IE9, ss framework uses hash to track
// For browsers which do not support history.pushState like IE9, ss framework uses hash to track
// the current location for PJAX, so for them we pass the query string stored in the hash instead
if(!window.history || !window.history.pushState){
if(window.location.hash && window.location.hash.indexOf('?') != -1){
Expand All @@ -48,15 +48,15 @@
// multiple relationships via keyboard.
if(focusedElName) self.find(':input[name="' + focusedElName + '"]').focus();

// Update filter
// Update filter
if(self.find('.filter-header').length) {
var content;
if(ajaxOpts.data[0].filter=="show") {
content = '<span class="non-sortable"></span>';
self.addClass('show-filter').find('.filter-header').show();
self.addClass('show-filter').find('.filter-header').show();
} else {
content = '<button name="showFilter" class="ss-gridfield-button-filter trigger"></button>';
self.removeClass('show-filter').find('.filter-header').hide();
self.removeClass('show-filter').find('.filter-header').hide();
}

self.find('.sortable-header th:last').html(content);
Expand Down Expand Up @@ -104,7 +104,7 @@


$('.ss-gridfield :button[name=showFilter]').entwine({
onclick: function(e) {
onclick: function(e) {
$('.filter-header')
.show('slow') // animate visibility
.find(':input:first').focus(); // focus first search field
Expand Down Expand Up @@ -198,11 +198,13 @@

$('.ss-gridfield-print-iframe').entwine({
onmatch: function(){
this._super();

this.hide().bind('load', function() {
this.focus();
var ifWin = this.contentWindow || this;
ifWin.print();
});;
});
},
onunmatch: function() {
this._super();
Expand Down Expand Up @@ -268,15 +270,15 @@
}
});
$('.ss-gridfield[data-selectable] .ss-gridfield-items').entwine({
onmatch: function() {
onadd: function() {
this._super();

// TODO Limit to single selection
this.selectable();
},
onunmatch: function() {
onremove: function() {
this._super();
this.selectable('destroy');
if (this.data('selectable')) this.selectable('destroy');
}
});

Expand Down
1 change: 1 addition & 0 deletions javascript/HtmlEditorField.js
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;

$('form.htmleditorfield-form.htmleditorfield-mediaform input.remoteurl').entwine({
onadd: function() {
this._super();
this.validate();
},

Expand Down
4 changes: 2 additions & 2 deletions javascript/TabSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
this._super();
},
onremove: function() {
if(this.data('uiTabs')) this.tabs('destroy');
if(this.data('tabs')) this.tabs('destroy');
this._super();
},
redrawTabs: function() {
Expand All @@ -32,7 +32,7 @@
if(!matches) return;
$(this).attr('href', document.location.href.replace(/#.*/, '') + matches[0]);
});
}
}
});
});
})(jQuery);
7 changes: 4 additions & 3 deletions javascript/ToggleCompositeField.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
$.entwine('ss', function($){
$('.ss-toggle').entwine({
onadd: function() {
this._super();

this.accordion({
collapsible: true,
active: (this.hasClass("ss-toggle-start-closed")) ? false : 0
});

this._super();
},
onremove: function() {
this.accordion('destroy');
if (this.data('accordion')) this.accordion('destroy');
this._super();
},

getTabSet: function() {
Expand Down
2 changes: 2 additions & 0 deletions javascript/TreeDropdownField.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,13 @@

$('.TreeDropdownField input[type=hidden]').entwine({
onadd: function() {
this._super();
this.bind('change.TreeDropdownField', function() {
$(this).getField().updateTitle();
});
},
onremove: function() {
this._super();
this.unbind('.TreeDropdownField');
}
});
Expand Down
24 changes: 15 additions & 9 deletions javascript/UploadField.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,11 @@
}
});
$('div.ss-upload .ss-uploadfield-files .ss-uploadfield-item').entwine({
onmatch: function() {
onadd: function() {
this._super();
this.closest('.ss-upload').find('.ss-uploadfield-addfile').addClass('borderTop');
},
onunmatch: function() {
onremove: function() {
$('.ss-uploadfield-files:not(:has(.ss-uploadfield-item))').closest('.ss-upload').find('.ss-uploadfield-addfile').removeClass('borderTop');
this._super();
}
Expand Down Expand Up @@ -365,19 +365,25 @@
if(config.changeDetection) {
this.closest('form').trigger('dirty');
}
fileupload._trigger('destroy', e, {
context: item,
url: this.data('href'),
type: 'get',
dataType: fileupload.options.dataType
});

if (fileupload) {
fileupload._trigger('destroy', e, {
context: item,
url: this.data('href'),
type: 'get',
dataType: fileupload.options.dataType
});
}
}
} else {
// Removed files will be applied to object on save
if(config.changeDetection) {
this.closest('form').trigger('dirty');
}
fileupload._trigger('destroy', e, {context: item});

if (fileupload) {
fileupload._trigger('destroy', e, {context: item});
}
}

e.preventDefault(); // Avoid a form submit
Expand Down