Skip to content

Commit

Permalink
Dev: some button testings
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac authored and lacrioque committed Nov 11, 2016
1 parent fc7b00c commit ef932a8
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
15 changes: 15 additions & 0 deletions application/controllers/admin/questiongroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,21 @@ public function getGroupExplorerDatas($surveyid, $langage)
$aDatas[$count]["key"] = $aGroup->gid; // The key is used by fancy tree to build the node id.
$aDatas[$count]["title"] = $aGroup->sanitized_group_name; // The title will be shown as text
$aDatas[$count]["folder"] = true; // Means it's a node with children
$aDatas[$count]['buttonlinks'] = array(
array(
'title' => gT('Add a question to this group'),
'url' => 'someurl',
'icon' => 'glyphicon glyphicon-plus-sign',
'toggle' => 'tooltip',

),
array(
'title' => 'test',
'url' => 'someurlTEST',
'icon' => 'glyphicon glyphicon-trash',
'cssclasses' => 'btn btn-xs btn-danger',
),
);

$countQ = 1;
$aDatasQ = array(); // The indexed array that will contain questions
Expand Down
63 changes: 63 additions & 0 deletions scripts/admin/jquery.fancytree.bstooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,69 @@
$("span.fancytree-title", node.span).tooltip(options);
}

if (node.data.buttonlinks)
{
//console.log(node.data.buttons);
$.each( node.data.buttonlinks, function( key, button ){
//console.log(button);

var buttonHtml = '<a href="'+button.url+'" role="button"';

if (button.cssclasses)
{
buttonHtml += ' class="'+button.cssclasses+'"';
}
else
{
buttonHtml += ' class="btn btn-xs btn-default" ';
}

if (button.toggle)
{
buttonHtml += ' data-toggle="'+button.toggle+'"';
}

if (button.placement)
{
buttonHtml += ' data-placement="'+button.placement+'"';
}

if (button.title)
{
buttonHtml += ' title="'+button.title+'"';
}

buttonHtml += '>';

if (button.icon)
{
buttonHtml += '<span class="'+button.icon+'"></span>';
}

if (button.buttontext)
{
buttonHtml += button.buttontext;
}

buttonHtml += '</a>';

var $elButton = $(buttonHtml)

$("span.fancytree-title", node.span).append(' ').append( $elButton );

if (button.toggle=='tooltip')
{
$elButton.tooltip();
}

if (button.toggle=='popover')
{
$elButton.popover();
}

} );
}

}
});
}(jQuery));

0 comments on commit ef932a8

Please sign in to comment.