| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- HybridAuth.utils.getMenu = function (actions, grid, selected) {
- var menu = [];
- var cls, icon, title, action;
- var has_delete = false;
- for (var i in actions) {
- if (!actions.hasOwnProperty(i)) {
- continue;
- }
- var a = actions[i];
- if (!a['menu']) {
- if (a == '-') {
- menu.push('-');
- }
- continue;
- }
- else if (menu.length > 0 && !has_delete && (/^remove/i.test(a['action']) || /^delete/i.test(a['action']))) {
- menu.push('-');
- has_delete = true;
- }
- if (selected.length > 1) {
- if (!a['multiple']) {
- continue;
- }
- else if (typeof(a['multiple']) == 'string') {
- a['title'] = a['multiple'];
- }
- }
- icon = a['icon'] ? a['icon'] : '';
- if (typeof(a['cls']) == 'object') {
- if (typeof(a['cls']['menu']) != 'undefined') {
- icon += ' ' + a['cls']['menu'];
- }
- }
- else {
- cls = a['cls'] ? a['cls'] : '';
- }
- title = a['title'] ? a['title'] : a['title'];
- action = a['action'] ? grid[a['action']] : '';
- menu.push({
- handler: action,
- text: String.format(
- '<span class="{0}"><i class="x-menu-item-icon {1}"></i>{2}</span>',
- cls, icon, title
- ),
- scope: grid
- });
- }
- return menu;
- };
- HybridAuth.utils.renderActions = function (value, props, row) {
- var res = [];
- var cls, icon, title, action, item;
- for (var i in row.data.actions) {
- if (!row.data.actions.hasOwnProperty(i)) {
- continue;
- }
- var a = row.data.actions[i];
- if (!a['button']) {
- continue;
- }
- icon = a['icon'] ? a['icon'] : '';
- if (typeof(a['cls']) == 'object') {
- if (typeof(a['cls']['button']) != 'undefined') {
- icon += ' ' + a['cls']['button'];
- }
- }
- else {
- cls = a['cls'] ? a['cls'] : '';
- }
- action = a['action'] ? a['action'] : '';
- title = a['title'] ? a['title'] : '';
- item = String.format(
- '<li class="{0}"><button class="btn btn-default {1}" action="{2}" title="{3}"></button></li>',
- cls, icon, action, title
- );
- res.push(item);
- }
- return String.format(
- '<ul class="ha-row-actions">{0}</ul>',
- res.join('')
- );
- };
|