j 查询字体IconPicker v3.1.1

j 查询字体IconPicker 是一个小(4.05KB gzipped) j 查询插件, 允许您在管理表格中包含一个优雅的图标拾取器, 其中包含分类, 搜索和页标 。 图标列表可以手动加载 SELECT 字段,一个 Array 或者说 Object 图标或直接取自 Fontello config.json 或爱克月 selection.json 文档。 转到 官方插件页面 用于实例和文件.
字体Icon Picker 键 ưμ㼯a 支持 j 查询 1.12.4 结束 3.3.0。 。 。 .
最初开发于 micc83/fontIconPicker (英语) 现在又分开了 组织 为了更好的合作.

安装
与国家预防机制/也门
字体IconPicker已经通过国家预防机制发布。 所以你可以使用国家防范机制安装或下载 释放。 。 。 .
npm install [email protected] @fonticonpicker/fonticonpicker --save
现在使用网页包或浏览器.
const jQuery = require( 'jquery' );
const fip = require( '@fonticonpicker/fonticonpicker' )( jQuery );
jQuery( '.selector' ).fontIconPicker( {
// Options
} );
全球 script / CDN 支持
您可以将字体IconPicker依赖性直接放入您的 html 与 <script>
财务报告和审定财务报表 <link> 标签。 转到 字体 IconPicker 释放 并下载
fontIconPicker.zip 来自最新资产的文件。 它将包含所有脚本和
用于生产的样式.
您也可以使用来自 unpkg.com (英语)。 。 。 .
<!-- styles -->
<!-- base | always include -->
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@fonticonpicker/fonticonpicker/dist/css/base/jquery.fonticonpicker.min.css">
<!-- default grey-theme -->
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@fonticonpicker/fonticonpicker/dist/css/themes/grey-theme/jquery.fonticonpicker.grey.min.css">
<!-- optional themes | no need to include default theme -->
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@fonticonpicker/fonticonpicker/dist/css/themes/bootstrap-theme/jquery.fonticonpicker.bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@fonticonpicker/fonticonpicker/dist/css/themes/dark-grey-theme/jquery.fonticonpicker.darkgrey.min.css">
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@fonticonpicker/fonticonpicker/dist/css/themes/inverted-theme/jquery.fonticonpicker.inverted.min.css">
<!-- scripts -->
<script type="text/javascript" src="https://unpkg.com/@fonticonpicker/fonticonpicker/dist/js/jquery.fonticonpicker.min.js"></script>
使用ES6模块
如果你想用的话 ES6 模块,然后必须手动初始化.
import jQuery from 'jquery';
import initFontIconPicker from '@fonticonpicker/fonticonpicker';
// Initiate the jQuery plugin
initFontIconPicker( jQuery );
jQuery( '.selector' ).fontIconPicker( {
// Options
} );
现在,唯一可行的 正确启动 fontIconPicker 结束
滚出j是直接通过 j 查询在 initFontIconPicker 函数。 若为
你知道更好的方法, 随意建议.
如何运作
只要包括 jQuery 的副本,字体 IconPickers 脚本,字体 IconPickers 主题和您的字体图标. 现在,你可以触发它在一个 SELECT 或者说 INPUT[type="text"] 键.
包含 Java 脚本
<!-- jQuery -->
<script type="text/javascript" src="jquery-1.12.4.min.js"></script>
<!-- fontIconPicker JS -->
<script type="text/javascript" src="js/jquery.fonticonpicker.min.js"></script>
包含 CSS
<!-- fontIconPicker core CSS -->
<link rel="stylesheet" type="text/css" href="css/base/jquery.fonticonpicker.min.css" />
<!-- required default theme -->
<link rel="stylesheet" type="text/css" href="css/themes/grey-theme/jquery.fonticonpicker.grey.min.css" />
<!-- optional themes -->
<link rel="stylesheet" type="text/css" href="css/themes/dark-grey-theme/jquery.fonticonpicker.darkgrey.min.css" />
<link rel="stylesheet" type="text/css" href="css/themes/bootstrap-theme/jquery.fonticonpicker.bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="css/themes/inverted-theme/jquery.fonticonpicker.inverted.min.css" />
包含字体图标
<!-- Font -->
<link rel="stylesheet" type="text/css" href="fontello-7275ca86/css/fontello.css" />
<link rel="stylesheet" type="text/css" href="icomoon/icomoon.css" />
以 j 查询初始化
最后给字体IconPicker打电话 SELECT 或者说 INPUT[type="text"] 键.
<!-- SELECT element -->
<select id="myselect" name="myselect" class="myselect">
<option value="">No icon</option>
<option>icon-user</option>
<option>icon-search</option>
<option>icon-right-dir</option>
<option>icon-star</option>
<option>icon-cancel</option>
<option>icon-help-circled</option>
<option>icon-info-circled</option>
<option>icon-eye</option>
<option>icon-tag</option>
<option>icon-bookmark</option>
<option>icon-heart</option>
<option>icon-thumbs-down-alt</option>
<option>icon-upload-cloud</option>
<option>icon-phone-squared</option>
<option>icon-cog</option>
<option>icon-wrench</option>
<option>icon-volume-down</option>
<option>icon-down-dir</option>
<option>icon-up-dir</option>
<option>icon-left-dir</option>
<option>icon-thumbs-up-alt</option>
</select>
<!-- JavaScript -->
<script type="text/javascript">
// Make sure to fire only when the DOM is ready
jQuery(document).ready(function($) {
$('#myselect').fontIconPicker(); // Load with default options
});
</script>
<!-- INPUT element -->
<input type="text" name="mytext" id="mytext" />
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#mytext').fontIconPicker({
source: ['icon-heart', 'icon-search', 'icon-user', 'icon-tag', 'icon-help'],
emptyIcon: false,
hasSearch: false
});
});
</script>
插件选项
以下是字体IconPicker选项:
var $picker = $('.picker').fontIconPicker({
theme : 'fip-grey', // The CSS theme to use with this fontIconPicker. You can set different themes on multiple elements on the same page
source : false, // Icons source (array|false|object)
emptyIcon : true, // Empty icon should be shown?
emptyIconValue : '', // The value of the empty icon, change if you select has something else, say "none"
autoClose : true, // Whether or not to close the FIP automatically when clicked outside
iconsPerPage : 20, // Number of icons per page
hasSearch : true, // Is search enabled?
searchSource : false, // Give a manual search values. If using attributes then for proper search feature we also need to pass icon names under the same order of source
appendTo : 'self', // Where to append the selector popup. You can pass string selectors or jQuery objects
useAttribute : false, // Whether to use attribute selector for printing icons
attributeName : 'data-icon', // HTML Attribute name
convertToHex : true, // Whether or not to convert to hexadecimal for attribute value. If true then please pass decimal integer value to the source (or as value="" attribute of the select field)
allCategoryText : 'From all categories', // The text for the select all category option
unCategorizedText : 'Uncategorized', // The text for the select uncategorized option
iconGenerator : null, // Icon Generator function. Passes, item, flipBoxTitle and index
windowDebounceDelay: 150, // Debounce delay while fixing position on windowResize
searchPlaceholder : 'Search Icons' // Placeholder for the search input
});
插件 APIs
字体IconPicker提供3个公共API来操纵图标取取器.
设置Icon () String 新Icon (英语)
使用这种方法在程序上设置图标 .
$picker.setIcon( 'fa fa-arrow-down' );
设置Icons () Array|Object {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}新针头, Array|Object 图标搜索
使用这种方法来动态地改变苍蝇上的图标. newIcons 财务报告和审定财务报表 iconSearch (可选)数据类型与 source 财务报告和审定财务报表 searchSource 选项.
$picker.setIcons(['icon-one', 'icon-two']);
$picker.setIcons(['icon-one', 'icon-two'], ['Icon one will be searched by this', 'Icon two will be searched by this']);
设置Page () String|Number 页: 1
使用这种方法在fip弹出中程序设定 pagination 。 这个 在打开状态和关闭状态之间持续,直到用户手动更改了页码.
$picker.setPage( 2 );
$picker.setPage( 'first' );
$picker.setPage( 'last' );
方法接受数字,只有两个特殊的字符串.
- 数字对应从1开始的页码.
first将会将页码设置为第一页.last将设置页码为最后一页.
销毁 Picker ()
用此来去掉图标取取器并恢复原始元素.
$picker.destroyPicker();
刷新选择( T) Object|Boolean 新选项 )
从 DOM 或通过选项刷新图标拾取器 。 当DOM在调用毁灭方法或更改选项值后被更改或重新初始化时有用.
$picker.refreshPicker({
theme: 'fip-bootstrap',
hasSearch: false
});
重新定位选择器( )
取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取 如果 DOM 已更改并下拉, 请使用此功能 打开。 或者,如果你的拾取器 在一个滚动容器.
var picker = $('.myselect').fontIconPicker();
$('.mycontainer').on( 'scroll', function() {
picker.repositionPicker();
} );
备选方案和API将在2008年1月1日至12月31日期间进行详细讨论 项目页面。 。 。 .
本地演示的重要注释
仅在本地加载演示时 : 在Firefox字体IconPicker图标中,由于CORS,不会正确显示. 出于同样的原因,"从Fontello JSON config文件中获取的Load图标"在Chrome或IE 10上将无法工作. 如果您需要做一些本地测试, 您可以冒着风险禁用严格的 起源 政策 .
使用捆绑 浏览器同步 用于运行演示的服务器。 见 设置 学习如何.
浏览器兼容性
j 查询图标Picker已成功测试于:Firefox(对接)、Safari(对接)、Chrome(对接)、IE8+和Opera(对接).
j 查询兼容性
jQuery 1.12.4 已定为 peerDependencies 输入 package.json我们有
测试 1.x 财务报告和审定财务报表 3.x 树枝。 jQuery 迁移不会产生任何错误
使用时 3.x。 。 。 .
发展环境
如果你想作出贡献,请记住一些事情.
- 任何代码都不应该产生ESLint和Stylelint的任何错误. 我们检查错误 如果它真的产生任何错误,它将被否决.
- 所有新的联署文件代码都应有单位或整合测试,并带有笑话.
设置
首先确保节点QQv8被安装. 然后复制仓库
git clone [email protected]:fontIconPicker/fontIconPicker.git
运行
cd fontIconPicker
npm install
npm install -g npx
这将安装所有依赖。 您不需要安装 jquery 就是这样
定义于 devDependencies。 。 。 .
现在编辑文件 src 需要的时候,请跑
npx gulp serve
这将服务于您的浏览器中的实时更改 。 打开它 http://localhost:3000。 。 。 .
编码标准
- 所有附加模块均应入内
src/js/modules单位测试__tests__/unit。 。 。 . - 写联署材料 ES6 标准。 。 。 . 这个 实值 学习的好地方 将会与贝贝尔一起编译.
- 不直接写入 CSS 文件 。 写入 常设委员会它会
当
npx gulp serve正在运行. - 如果您正在写一个主题, 请在第一个框中包含
demo/index.html。 。 。 . - 如果您正在写入一个选项或 API,请在单独的框中包含
demo/index.html。 。 。 . - 联合来文的所有新特征都应有单位/整合和/或e2e测试。 我们用 锡压 用于e2e测试和 欢笑 用于单位/整合测试.
自动接钩
当你跑的时候 npm install 这是第一次, 嘘 设置了几根钩子 具体来说
做两件事.
- 检查是否正确 发送消息。 。 。 .
- 内嵌运行
js财务报告和审定财务报表scss用于在按下前避免出错的文件.
持续整合( CI)
此外,我们运行测试服 每推 法语科。 。 。 .
让它跑来跑去
npm run test
当地在你的机器。 它会插入所有文件并运行 jest 测试.
正在本地测试
字体IconPicker有两套测试.
单位和整合测试 欢笑
npx jest
末端测试用 锡压
npx cypress open
然后从应用程序中进行测试。 或者说
npx cypress run
从无头浏览器运行终端测试. 你没必要 担心设置测试环境 因为它是自动处理的 以 锡压。 。 。 .
可用的 Gulp 命令
default- 构建所有脚本/样式并放入dist文件夹.build- 和默认一样.lint- 把CSS和JS的档案都记录下来.lint:script- 把JS的档案都记录下来.lint:style- 打开所有SCSS文件.
fonts- 复制字体文件到dist目录.serve- 构建文件,init浏览器同步并监视文件以创建dev env.
用 npx。 。 。 .
贷项
j 查询字体IconPicker 由 亚历山德罗·比诺伊特 打开 洗手间。 。 可以使用 问题跟踪器 用于报告错误或特性请求.
特别感谢迷你MAC为这个想法,Zeno Rocha为jQuery插件锅炉板,Dave Gandy & KayaMoon为美丽的图标集,Elliot Condon为惊人的高级自定义场WordPress插件.