Skip to content

Commit

Permalink
Merge pull request #25 from sheadawson/master
Browse files Browse the repository at this point in the history
Commits for 1.1.2
  • Loading branch information
sheadawson committed Jul 6, 2015
2 parents ea3dd47 + a2b7870 commit 23bd2e4
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions javascript/quickaddnew.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,25 @@ jQuery.entwine("quickaddnew", function($) {
URL: null,
onmatch: function() {
var self = this;


//Check to see if quickaddnew has been bound to this field before, sometimes jQuery plugins like Select2
//will trigger a binding a second time that we don't want.
if($(this).parents().children('.quickaddnew-button').length > 0) {
return;
}
// create add new button
var button = $("<button />")
.addClass()
.text(ss.i18n._t('QUICKADDNEW.AddNew'))
.attr('href', '#')
.addClass("quickaddnew-button ss-ui-button ss-ui-button-small")
.appendTo(self.parents('div:first'));

// create dialog
var dialog = $("<div />")
.addClass("quickaddnew-dialog")
.appendTo(self.parents('div:first'));

.appendTo(self.parents('div:first'));
this.setDialog(dialog);

// set URL
Expand Down Expand Up @@ -87,12 +92,16 @@ jQuery.entwine("quickaddnew", function($) {

showDialog: function(url) {
var dlg = this.getDialog();

dlg.empty().dialog("open").parent().addClass("loading");

dlg.load(this.getURL(), function(){
dlg.parent().removeClass("loading");
});
// Check to see we have a dialog, other jquery plugins like Select2 can get bound to by accident
if (dlg !== null) {
dlg.empty().dialog("open").parent().addClass("loading");

dlg.load(this.getURL(), function(){
dlg.parent().removeClass("loading");
// set focus to first input element
dlg.find('form :input:visible:enabled:first').focus();
});
}
}
});
});
Expand Down

0 comments on commit 23bd2e4

Please sign in to comment.