X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/3cff6e4a3f7e7acceacbc621f9196204b508121e..4d106a6318aa0c508a93acb9e2a6fb146ed177ba:/redakcja/static/js/wiki/toolbar.js diff --git a/redakcja/static/js/wiki/toolbar.js b/redakcja/static/js/wiki/toolbar.js index 8a35aa5b..3eafdae6 100644 --- a/redakcja/static/js/wiki/toolbar.js +++ b/redakcja/static/js/wiki/toolbar.js @@ -2,59 +2,59 @@ * Toolbar plugin. */ (function($) { - + $.fn.toolbarize = function(options) { var $toolbar = $(this); var $container = $('.button_group_container', $toolbar); - - $('.button_group button', $toolbar).click(function(event){ + + $('.button_group button', $toolbar).click(function(event){ event.preventDefault(); - + var params = eval("(" + $(this).attr('data-ui-action-params') + ")"); - + scriptletCenter.callInteractive({ action: $(this).attr('data-ui-action'), context: options.actionContext, extra: params }); }); - + $toolbar.children().filter('select').change(function(event){ - var slug = $(this).val(); + var slug = $(this).val(); $container.scrollLeft(0); - $('*[data-group]').hide().filter('[data-group=' + slug + ']').show(); + $('*[data-group]').hide().filter('[data-group=' + slug + ']').show(); }).change(); - + $('button.next', $toolbar).click(function() { - var $current_group = $('.button_group:visible', $toolbar); - var scroll = $container.scrollLeft(); - + var $current_group = $('.button_group:visible', $toolbar); + var scroll = $container.scrollLeft(); + var $hidden = $("li", $current_group).filter(function() { return ($(this).position().left + $(this).outerWidth()) > $container.width(); - }).first(); - + }).first(); + if($hidden.length > 0) { - scroll = $hidden.position().left + scroll + $hidden.outerWidth() - $container.width() + 1; + scroll = $hidden.position().left + scroll + $hidden.outerWidth() - $container.width() + 1; $container.scrollLeft(scroll); }; }); - + $('button.prev', $toolbar).click(function() { - var $current_group = $('.button_group:visible', $toolbar); + var $current_group = $('.button_group:visible', $toolbar); var scroll = $container.scrollLeft(); - - /* first not visible element is: */ + + /* first not visible element is: */ var $hidden = $("li", $current_group).filter(function() { return $(this).position().left < 0; }).last(); - + if( $hidden.length > 0) { - scroll = scroll + $hidden.position().left; + scroll = scroll + $hidden.position().left; $container.scrollLeft(scroll); }; }); - - }; - + + }; + })(jQuery); \ No newline at end of file