X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FClientJS.pm;h=ada199efa2714ec67ae6545d5a998644159abed5;hb=3d96d9f069b5512659ae077695ffdc4d11f20a32;hp=0e18d732bce17ba9a6ac66987cec2d570df43a35;hpb=824f9ddf5ac3c5d8f46fa8a3bcd49456aa9f0e22;p=kivitendo-erp.git diff --git a/SL/ClientJS.pm b/SL/ClientJS.pm index 0e18d732b..ada199efa 100644 --- a/SL/ClientJS.pm +++ b/SL/ClientJS.pm @@ -75,10 +75,10 @@ my %supported_methods = ( off => 3, one => 3, - # ## jqModal plugin ## + # ## jQuery UI dialog plugin ## pattern: $().dialog('') # Closing and removing the popup - jqmClose => 1, # $().jqmClose() + 'dialog:close' => 1, # ## jstree plugin ## pattern: $.jstree._reference($()).() @@ -132,10 +132,10 @@ sub action { croak "Unsupported jQuery action: $method" unless defined $num_args; croak "Parameter count mismatch for $method(actual: " . scalar(@args) . " wanted: $num_args)" if scalar(@args) != $num_args; - if ($num_args) { - # Force flattening from SL::Presenter::EscapedText: "" . $... - $args[0] = "" . $args[0]; - $args[0] =~ s/^\s+//; + foreach my $idx (0..$num_args - 1) { + # Force flattening from SL::Presenter::EscapedText and trim leading whitespace for scalars + $args[$idx] = "" . $args[$idx] if ref($args[$idx]) eq 'SL::Presenter::EscapedText'; + $args[$idx] =~ s/^\s+// if !ref($args[$idx]); } push @{ $self->_actions }, [ $method, @args ]; @@ -185,6 +185,12 @@ sub jstree { return $self; } +sub dialog { + my ($self) = @_; + $self->{_prefix} = 'dialog:'; + return $self; +} + sub flash { my ($self, $type, @messages) = @_; @@ -262,6 +268,9 @@ Now some Perl code: $js->jstree->rename_node('#tb-' . $text_block->id, $text_block->title) ->jstree->select_node('#tb-' . $text_block->id); + # Close a popup opened by kivi.popup_dialog(): + $js->dialog->close('#jqueryui_popup_dialog'); + # Finally render the JSON response: $self->render($js); @@ -324,6 +333,14 @@ to the following: $controller->render(\$self->to_json, { type => 'json' }); +=item C + +Tells C<$self> that the next action is to be called on a jQuery UI +dialog instance, e.g. one opened by C. For +example: + + $js->dialog->close('#jqueryui_popup_dialog'); + =item C Tells C<$self> that the next action is to be called on a jstree