1 namespace("kivi", function(ns) {
4 ns.t8 = function(text, params) {
5 var text = ns._locale[text] || text;
7 if( Object.prototype.toString.call( params ) === '[object Array]' ) {
8 var len = params.length;
10 for(var i=0; i<len; ++i) {
12 var value = params[i];
13 text = text.split("#"+ key).join(value);
16 else if( typeof params == 'object' ) {
17 for(var key in params) {
18 var value = params[key];
19 text = text.split("#{"+ key +"}").join(value);
26 ns.setupLocale = function(locale) {
30 ns.reinit_widgets = function() {
31 $('.datepicker').each(function() {
36 $('input.part_autocomplete').each(function(idx, elt){
37 kivi.PartPicker($(elt));
41 // Return a function object by its name (a string). Works both with
42 // global functions (e.g. "check_right_date_format") and those in
43 // namespaces (e.g. "kivi.t8").
44 // Returns null if the object is not found.
45 ns.get_function_by_name = function(name) {
46 var parts = name.match("(.+)\\.([^\\.]+)$");
49 return namespace(parts[1])[ parts[2] ];
52 // Open a modal jQuery UI popup dialog. The content is loaded via AJAX.
55 // - id: dialog DIV ID (optional; defaults to 'jqueryui_popup_dialog')
56 // - url, data, type: passed as the first three arguments to the $.ajax() call
57 // - dialog: an optional object of options passed to the $.dialog() call
58 ns.popup_dialog = function(params) {
61 params = params || { };
62 var id = params.id || 'jqueryui_popup_dialog';
63 var dialog_params = $.extend(
64 { // kivitendo default parameters:
69 // User supplied options:
71 { // Options that must not be changed:
72 close: function(event, ui) { dialog.remove(); }
77 dialog = $('<div style="display:none" class="loading" id="' + id + '"></div>').appendTo('body');
78 dialog.dialog(dialog_params);
84 success: function(new_html) {
85 dialog.html(new_html);
86 dialog.removeClass('loading');
94 kivi = namespace('kivi');