X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/755cace721087441becc6e1f22a3e1eed5bbec32..ddfd0025304ea7087fdd2a4e06893a6f998b9f19:/project/static/js/views/button_toolbar.js?ds=sidebyside diff --git a/project/static/js/views/button_toolbar.js b/project/static/js/views/button_toolbar.js index 71bfa975..7f039985 100644 --- a/project/static/js/views/button_toolbar.js +++ b/project/static/js/views/button_toolbar.js @@ -39,22 +39,34 @@ var ButtonToolbarView = View.extend({ $(self.element).trigger('resize'); }); - $('.buttontoolbarview-button', this.element).bind('click.buttontoolbarview', function(event) { - var groupIndex = parseInt($(this).attr('ui:groupindex'), 10); - var buttonIndex = parseInt($(this).attr('ui:buttonindex'), 10); - var button = self.get('buttons')[groupIndex].buttons[buttonIndex]; - var scriptletId = button.scriptlet_id; - var params = eval('(' + button.params + ')'); // To nie powinno być potrzebne + $('.buttontoolbarview-button', this.element). + bind('click.buttontoolbarview', this.buttonPressed.bind(this) ); + + $(this.element).trigger('resize'); + }, + + buttonPressed: function(event) + { + var self = this; + var target = event.target; + + var groupIndex = parseInt($(target).attr('ui:groupindex'), 10); + var buttonIndex = parseInt($(target).attr('ui:buttonindex'), 10); + var button = this.get('buttons')[groupIndex].buttons[buttonIndex]; + var scriptletId = button.scriptlet_id; + var params = eval('(' + button.params + ')'); // To nie powinno być potrzebne - console.log('Executing', scriptletId, 'with params', params); - try { + console.log('Executing', scriptletId, 'with params', params); + try { + self.parent.freeze('Wykonuję akcję...'); + setTimeout(function() { scriptletCenter.scriptlets[scriptletId](self.parent, params); - } catch(e) { - console.log("Scriptlet", scriptletId, "failed."); - } - }); - - $(this.element).trigger('resize'); + self.parent.unfreeze(); + }, 10); + } catch(e) { + console.log("Scriptlet", scriptletId, "failed.", e); + } + }, dispose: function() {