minimumInputLength: 1,
formatResult: CRM.utils.formatSelect2Result,
formatSelection: function(row) {
- return row.label;
+ return (row.prefix !== undefined ? row.prefix + ' ' : '') + row.label + (row.suffix !== undefined ? ' ' + row.suffix : '');
},
escapeMarkup: function (m) {return m;},
initSelection: function($el, callback) {
});
};
+ $.fn.crmAjaxTable = function() {
+ return $(this).each(function() {
+ //Declare the defaults for DataTables
+ var defaults = {
+ "processing": true,
+ "serverSide": true,
+ "dom": '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
+ "pageLength": 25,
+ "drawCallback": function(settings) {
+ //Add data attributes to cells
+ $('thead th', settings.nTable).each( function( index ) {
+ $.each(this.attributes, function() {
+ if(this.name.match("^cell-")) {
+ var cellAttr = this.name.substring(5);
+ var cellValue = this.value
+ $('tbody tr', settings.nTable).each( function() {
+ $('td:eq('+ index +')', this).attr( cellAttr, cellValue );
+ });
+ }
+ });
+ });
+ //Reload table after draw
+ $(settings.nTable).trigger('crmLoad');
+ }
+ };
+ //Include any table specific data
+ var settings = $.extend(true, defaults, $(this).data('table'));
+ //Make the DataTables call
+ $(this).DataTable(settings);
+ });
+ };
+
CRM.utils.formatSelect2Result = function (row) {
var markup = '<div class="crm-select2-row">';
if (row.image !== undefined) {
else if (row.icon_class) {
markup += '<div class="crm-select2-icon"><div class="crm-icon ' + row.icon_class + '-icon"></div></div>';
}
- markup += '<div><div class="crm-select2-row-label '+(row.label_class || '')+'">' + row.label + '</div>';
- markup += '<div class="crm-select2-row-description">';
+ markup += '<div><div class="crm-select2-row-label '+(row.label_class || '')+'">' +
+ (row.prefix !== undefined ? row.prefix + ' ' : '') + row.label + (row.suffix !== undefined ? ' ' + row.suffix : '') +
+ '</div>' +
+ '<div class="crm-select2-row-description">';
$.each(row.description || [], function(k, text) {
markup += '<p>' + text + '</p>';
});
}
})
.find('input.select-row:checked').parents('tr').addClass('crm-row-selected');
+ $('table.crm-sortable', e.target).DataTable();
+ $('table.crm-ajax-table', e.target).crmAjaxTable();
if ($("input:radio[name=radio_ts]").size() == 1) {
$("input:radio[name=radio_ts]").prop("checked", true);
}
$().crmtooltip();
});
- /**
- * @deprecated
- */
- $.fn.crmAccordions = function () {
- CRM.console('warn', 'Warning: $.crmAccordions was called. This function is deprecated and should not be used.');
- };
+
/**
* Collapse or expand an accordion
* @param speed