Skip to content

Commit

Permalink
More changes to support Font Awesome 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegKi committed Jul 1, 2018
1 parent 188b418 commit 0ca9988
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 15 deletions.
53 changes: 48 additions & 5 deletions js/grid.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Dual licensed under the MIT and GPL licenses
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
* Date: 2018-04-21
* Date: 2018-07-01
*/
//jsHint options
/*jshint eqnull:true */
Expand Down Expand Up @@ -531,10 +531,15 @@
leaf: "fa-dot-circle-o",
plusLtr: "fa-lg fa-caret-right",
plusRtl: "fa-lg fa-caret-left"
},
checkbox: {
checkedClasses: "fa-check-square-o",
checked: "fa-check-square-o fa-lg",
unchecked: "fa-square-o fa-lg"
}
},
fontAwesomeSVG: {
common: "fas", //"fa"
fontAwesome5: {
//common: "fas", //"fa"
pager: {
common: "fa-fw",
first: "fa-step-backward",
Expand Down Expand Up @@ -603,8 +608,34 @@
leaf: "fa-dot-circle",
plusLtr: "fa-lg fa-caret-right",
plusRtl: "fa-lg fa-caret-left"
},
checkbox: {
ignoreParents: true,
checkedClasses: "fa-check-square",
checked: "far fa-check-square fa-lg",
unchecked: "far fa-square fa-lg"
}
},
fontAwesomeBrands: {
baseIconSet: "fontAwesome5",
common: "fab"
},
fontAwesomeLight: {
baseIconSet: "fontAwesome5",
common: "fal"
},
fontAwesomeRegular: {
baseIconSet: "fontAwesome5",
common: "far"
},
fontAwesomeSolid: {
baseIconSet: "fontAwesome5",
common: "fas"
},
fontAwesomeSVG: {
baseIconSet: "fontAwesome5",
common: "fas"
},
glyph: {
common: "glyphicon",
pager: {
Expand Down Expand Up @@ -675,6 +706,11 @@
leaf: "glyphicon-record", // glyphicon-unchecked
plusLtr: "glyphicon-triangle-right",
plusRtl: "glyphicon-triangle-left"
},
checkbox: {
checkedClasses: "glyphicon-check",
checked: "glyphicon-check",
unchecked: "glyphicon-unchecked"
}
}
},
Expand Down Expand Up @@ -6371,7 +6407,7 @@
if (!$t || !$t.p) { return ""; }

var p = $t.p, iconSet = jgrid.icons[p.iconSet],
getIcon = function (basePath, path) {
getIcon = function (basePath, path, alternativeRoot) {
var pathParts = path.split("."), root, n = pathParts.length, part, i, classes = [];
basePath = typeof basePath === "string" ? jgrid.icons[basePath] : basePath;
if (basePath == null) {
Expand All @@ -6380,12 +6416,19 @@
root = basePath;
if (root.common) {
classes.push(root.common);
} else if (alternativeRoot && alternativeRoot.common) {
classes.push(alternativeRoot.common);
}
for (i = 0; i < n; i++) {
part = pathParts[i];
if (!part) {
break;
}
if (i + 1 === n && root.ignoreParents) {
// the final level
// Verify that ignoreParents mode is set on the level
classes = []; // reset array of classes
}
root = root[part];
if (root === undefined) {
if (part === "common") { break; }
Expand All @@ -6407,7 +6450,7 @@
}
var classes = getIcon(p.iconSet, path);
if (classes === "" && iconSet.baseIconSet != null) {
classes = getIcon(iconSet.baseIconSet, path);
classes = getIcon(iconSet.baseIconSet, path, jgrid.icons[p.iconSet]);
}
return classes || "";
},
Expand Down
19 changes: 9 additions & 10 deletions js/jquery.fmatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,13 @@
disabled = jgrid.formatter.checkbox.disabled;
}

if (disabled === true && base.isInCommonIconClass.call(this, "fa")) {
checkedClasses = checkedClasses || "fa fa-check-square-o fa-lg";
checked = buildCheckbox(checkedClasses);
unchecked = buildCheckbox(uncheckedClasses || "fa fa-square-o fa-lg");
} else if (disabled === true && base.isInCommonIconClass.call(this, "glyphicon")) {
checkedClasses = checkedClasses || "glyphicon glyphicon-check";
checked = buildCheckbox(checkedClasses);
unchecked = buildCheckbox(uncheckedClasses || "glyphicon glyphicon-unchecked");
var checkedIcon = base.getIconRes.call(this, "checkbox.checked"),
checkedIconClasses = base.getIconRes.call(this, "checkbox.checkedClasses"),
uncheckedIcon = base.getIconRes.call(this, "checkbox.unchecked");
if (disabled === true && (checkedClasses || uncheckedClasses || checkedIcon || uncheckedIcon)) {
checked = buildCheckbox(checkedClasses || checkedIcon);
unchecked = buildCheckbox(uncheckedClasses || uncheckedIcon);
checkedClasses = checkedIconClasses ? checkedIconClasses : checkedClasses || checkedIcon;
} else {
checkedClasses = "";
title += disabled === true ? " disabled='disabled'" : "";
Expand Down Expand Up @@ -362,7 +361,7 @@
$elem = $(elem);

return (checkboxOptions.checkedClasses ?
jgrid.hasAllClasses($elem.children("i"), checkboxOptions.checkedClasses) :
jgrid.hasAllClasses($elem.children("i,svg"), checkboxOptions.checkedClasses) :
$elem.children("input").is(":checked")) ?
checkboxOptions.yes :
checkboxOptions.no;
Expand Down Expand Up @@ -842,7 +841,7 @@
var $self = $(this), p = this.p, cm = p.colModel[iCol],
wrapperClassName = p.autoResizing.wrapperClassName,
hoverClass = $self.jqGrid("getGuiStyles", "states.hover"),
iRow, rows = this.rows, nRows = rows.length, row,
iRow, rows = this.rows, fbRows = this.grid.fbRows, nRows = rows.length, row,
showHideEditDelete = (function (cmName) {
return function (show, tr) {
var maxfrozen = 0, $actionsDiv, colModel = p.colModel, len = colModel.length, i, iCol = p.iColByName[cmName];
Expand Down
16 changes: 16 additions & 0 deletions ts/free-jqgrid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,23 +377,27 @@ declare namespace FreeJqGrid {
common?: string; // "ui-icon",
pager?: {
common?: string;
ignoreParents?: boolean;
first?: string; // "ui-icon-seek-first",
prev?: string; // "ui-icon-seek-prev",
next?: string; // "ui-icon-seek-next",
last?: string; // "ui-icon-seek-end"
};
sort?: {
common?: string;
ignoreParents?: boolean;
asc?: string; // "ui-icon-triangle-1-n",
desc?: string; // "ui-icon-triangle-1-s"
};
gridMinimize?: {
common?: string;
ignoreParents?: boolean;
visible?: string; // "ui-icon-circle-triangle-n",
hidden?: string; // "ui-icon-circle-triangle-s"
};
nav?: {
common?: string;
ignoreParents?: boolean;
edit?: string; // "ui-icon-pencil",
add?: string; // "ui-icon-plus",
del?: string; // "ui-icon-trash",
Expand All @@ -406,13 +410,15 @@ declare namespace FreeJqGrid {
};
actions?: {
common?: string; // string;
ignoreParents?: boolean;
edit?: string; // "ui-icon-pencil",
del?: string; // "ui-icon-trash",
save?: string; // "ui-icon-disk",
cancel?: string; // "ui-icon-cancel"
};
form?: {
common?: string;
ignoreParents?: boolean;
close?: string; // "ui-icon-closethick",
prev?: string; // "ui-icon-triangle-1-w",
next?: string; // "ui-icon-triangle-1-e",
Expand All @@ -424,29 +430,39 @@ declare namespace FreeJqGrid {
};
search?: {
common?: string;
ignoreParents?: boolean;
search?: string; // "ui-icon-search",
reset?: string; // "ui-icon-arrowreturnthick-1-w",
query?: string; // "ui-icon-comment"
};
subgrid?: {
common?: string;
ignoreParents?: boolean;
plus?: string; // "ui-icon-plus",
minus?: string; // "ui-icon-minus",
openLtr?: string; // "ui-icon-carat-1-sw",
openRtl?: string; // "ui-icon-carat-1-se"
};
grouping?: {
common?: string; // string;
ignoreParents?: boolean;
plus?: string; // "ui-icon-circlesmall-plus",
minus?: string; // "ui-icon-circlesmall-minus"
};
treeGrid?: {
common?: string;
ignoreParents?: boolean;
minus?: string; // "ui-icon-triangle-1-s",
leaf?: string; // "ui-icon-radio-off",
plusLtr?: string; // "ui-icon-triangle-1-e",
plusRtl?: string; // "ui-icon-triangle-1-w"
};
checkbox ?: {
ignoreParents?: boolean;
checkedClasses?: string; // "fa-check-square-o",
checked?: string; // "fa-check-square-o fa-lg",
unchecked?: string; // "fa-square-o fa-lg"
};
}
interface GuiStyleInfo {
baseGuiStyle?: string;
Expand Down

0 comments on commit 0ca9988

Please sign in to comment.