From aee236a32f67f410f2555fd7116fb606f7e8fe3a Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 18 Nov 2013 12:03:19 +0100 Subject: [PATCH] Refactor: init_tabwidgets() in kivi-Namespace verschoben --- js/common.js | 19 ------------------- js/kivi.js | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/js/common.js b/js/common.js index d961814bc..916011503 100644 --- a/js/common.js +++ b/js/common.js @@ -150,25 +150,6 @@ function focus_by_name(name){ } $(document).ready(function () { - // initialize all jQuery UI tab elements: - $(".tabwidget").each(function(idx, element) { - var $element = $(element); - var tabsParams = {}; - - var elementId = $element.attr('id'); - if( elementId ) { - var cookieName = 'jquery_ui_tab_'+ elementId; - - tabsParams.active = $.cookie(cookieName); - tabsParams.activate = function(event, ui) { - var i = ui.newTab.parent().children().index(ui.newTab); - $.cookie(cookieName, i); - }; - } - - $element.tabs(tabsParams); - }); - $('input').focus(function(){ if (focussable(this)) window.focused_element = this; }); diff --git a/js/kivi.js b/js/kivi.js index bdae4c42c..68a5e4131 100644 --- a/js/kivi.js +++ b/js/kivi.js @@ -27,6 +27,23 @@ namespace("kivi", function(ns) { ns._locale = locale; }; + ns.init_tabwidget = function(element) { + var $element = $(element); + var tabsParams = {}; + var elementId = $element.attr('id'); + + if (elementId) { + var cookieName = 'jquery_ui_tab_'+ elementId; + tabsParams.active = $.cookie(cookieName); + tabsParams.activate = function(event, ui) { + var i = ui.newTab.parent().children().index(ui.newTab); + $.cookie(cookieName, i); + }; + } + + $element.tabs(tabsParams); + }; + ns.reinit_widgets = function() { ns.run_once_for('.datepicker', 'datepicker', function(elt) { $(elt).datepicker(); @@ -44,6 +61,8 @@ namespace("kivi", function(ns) { ns.run_once_for('.tooltip', 'tooltip', function(elt) { $(elt).tooltip(); }); + + ns.run_once_for('.tabwidget', 'tabwidget', kivi.init_tabwidget); }; ns.submit_ajax_form = function(url, form_selector, additional_data) { -- 2.20.1