Skip to content

Commit

Permalink
feature:2847 Display additional info for API methods fields
Browse files Browse the repository at this point in the history
git-svn-id: http://piwigo.org/svn/trunk@20750 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
mistic100 committed Feb 13, 2013
1 parent 9687732 commit 98f08b3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/ws_core.inc.php
Expand Up @@ -572,6 +572,10 @@ static function ws_getMethodDetails($params, &$service)
{
$param_data['defaultValue'] = $options['default'];
}
if (isset($options['info']))
{
$param_data['info'] = $options['info'];
}
$res['params'][] = $param_data;
}
return $res;
Expand Down
16 changes: 15 additions & 1 deletion tools/ws.htm
Expand Up @@ -4,7 +4,9 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Piwigo web API (web-services) explorer</title>

<link rel="stylesheet" type="text/css" href="http://cdn.jsdelivr.net/tiptip/1.3/tipTip.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/tiptip/1.3/jquery.tipTip.minified.js"></script>

<style type="text/css">
/* BEGIN CSS RESET
Expand Down Expand Up @@ -92,6 +94,9 @@
}
a.button:hover {color:#E5FF00;}

.methodInfo {float:right;display:inline-block;width:16px;height:16px;font-size:12px;line-height:16px;background:#555;border-radius:8px;font-family:"Times New Roman",sans-serif;font-style:italic;font-weight:bold;text-align:center;color:#fff;}
.methodInfo:hover {border:none;text-shadow:none;background:#888;cursor:pointer;color:#fff;}

#iframeWrapper {width:100%;height:300px;padding:3px 3px 20px 3px;background:#F9F9F9;border:1px solid #cdcdcd;overflow:hidden;position:relative;}
iframe {width:100%;height:100%;background:#fff;}
</style>
Expand Down Expand Up @@ -408,14 +413,15 @@ <h3>Result</h3>
var isOptional = method.params[i].optional;
var acceptArray = method.params[i].acceptArray;
var defaultValue = method.params[i].defaultValue == null ? '' : method.params[i].defaultValue;
var info = method.params[i].info == null ? '' : '<a class="methodInfo" title="'+ method.params[i].info + '">i</a>';

// if an array is direclty printed, the delimiter is a comma where we use a pipe
if (typeof defaultValue == 'object') {
defaultValue = defaultValue.join('|');
}

methodParams+= '<tr>'+
'<td>'+ method.params[i].name +'</td>'+
'<td>'+ method.params[i].name + info +'</td>'+
'<td class="mini">'+ (isOptional ? '?':'*') + (acceptArray ? ' []':'') +'</td>'+
'<td class="input"><input type="text" class="methodParameterValue" data-id="'+ i +'" value="'+ defaultValue +'"></td>'+
'<td class="mini"><input type="checkbox" class="methodParameterSend" data-id="'+ i +'" '+ (isOptional ? '':'checked="checked"') +'></td>'+
Expand All @@ -435,6 +441,14 @@ <h3>Result</h3>
$("input.methodParameterValue").change(function() {
$("input.methodParameterSend[data-id='"+ $(this).data('id') +"']").attr('checked', 'checked');
});

// tiptip
$(".methodInfo").tipTip({
activation:"click",
maxWidth:"300px",
defaultPosition:"right",
delay:0
});
}

// invoke method
Expand Down

0 comments on commit 98f08b3

Please sign in to comment.