rails 项目中 使用 jquery ui

Usage

in your Gemfile, add:

<code class="ruby"><span class="id identifier rubyid_gem">gem</span> <span class="tstring" style="color:#36a7;"><span class="tstring_beg">'</span><span class="tstring_content">jquery-ui-rails</span><span class="tstring_end">'</span></span>
</code>

Require Everything

To require all jQuery UI modules, add the following to your application.js:

<code class="javascript">//= require jquery.ui.all
</code>

Also add the jQuery UI CSS to your application.css:

<code class="css">/*
 *= require jquery.ui.all
 */
</code>

All images required by jQuery UI are automatically served through the asset pipeline, so you are good to go! For example, this code will add a datepicker:

<code class="javascript">$(function() {
  $('.datepicker').datepicker();
});
</code>

Require Specific Modules

The jQuery UI code weighs 51KB (minified + gzipped) and takes a while to execute, so for production apps it's recommended to only include the modules that your application actually uses. Dependencies are automatically resolved. Simply pick one or more modules from the asset list below.

For example, if you only need the datepicker module, add this to your application.js:

<code class="javascript">//= require jquery.ui.datepicker
</code>

In your application.css, require the corresponding CSS module:

<code class="css">/*
 *= require jquery.ui.datepicker
 */
</code>

JavaScript Assets

UI Core

<code class="javascript">//= require jquery.ui.core
//= require jquery.ui.widget
//= require jquery.ui.mouse
//= require jquery.ui.position
</code>

You usually do not need to require these directly, as they are pulled in by the other JavaScript modules as needed.

Interactions

<code class="javascript">//= require jquery.ui.draggable
//= require jquery.ui.droppable
//= require jquery.ui.resizable
//= require jquery.ui.selectable
//= require jquery.ui.sortable
</code>

For jquery.ui.resizable and jquery.ui.selectable, remember to require their matching CSS files in your application.css as well.

Widgets

<code class="javascript">//= require jquery.ui.accordion
//= require jquery.ui.autocomplete
//= require jquery.ui.button
//= require jquery.ui.datepicker
//= require jquery.ui.dialog
//= require jquery.ui.menu
//= require jquery.ui.progressbar
//= require jquery.ui.slider
//= require jquery.ui.spinner
//= require jquery.ui.tabs
//= require jquery.ui.tooltip
</code>

For all of these, remember to require their matching CSS files in your application.css as well.

I18n

Datepicker has optional i18n modules for non-US locales, named jquery.ui.datepicker-xx[-YY] (list), for example:

<code class="javascript">//= require jquery.ui.datepicker
//= require jquery.ui.datepicker-pt-BR
</code>

Note that you still need to include the main datepicker module. It is not required automatically for performance reasons.

Effects

<code class="javascript">//= require jquery.ui.effect.all
//= require jquery.ui.effect
//= require jquery.ui.effect-blind
//= require jquery.ui.effect-bounce
//= require jquery.ui.effect-clip
//= require jquery.ui.effect-drop
//= require jquery.ui.effect-explode
//= require jquery.ui.effect-fade
//= require jquery.ui.effect-fold
//= require jquery.ui.effect-highlight
//= require jquery.ui.effect-pulsate
//= require jquery.ui.effect-scale
//= require jquery.ui.effect-shake
//= require jquery.ui.effect-slide
//= require jquery.ui.effect-transfer
</code>

Stylesheet Assets

UI Core

<code class="css">/*
 *= require jquery.ui.core
 *= require jquery.ui.theme
 */
</code>

You might want to require these if you do not use any of the following modules, but still want jQuery UI's basic theming CSS. Otherwise they are automatically pulled in as dependencies.

Interactions

<code class="css">/*
 *= require jquery.ui.resizable
 *= require jquery.ui.selectable
 */
</code>

Widgets

<code class="css">/*
 *= require jquery.ui.accordion
 *= require jquery.ui.autocomplete
 *= require jquery.ui.button
 *= require jquery.ui.datepicker
 *= require jquery.ui.dialog
 *= require jquery.ui.menu
 *= require jquery.ui.progressbar
 *= require jquery.ui.slider
 *= require jquery.ui.spinner
 *= require jquery.ui.tabs
 *= require jquery.ui.tooltip
 */
</code>

Contributing

Bug Reports

For bugs in jQuery UI itself, head to the jQuery UI Development Center.

For bugs in this gem distribution, use the GitHub issue tracker.

Setup

The jquery-ui-rails gem should work in Ruby 1.8.7 apps. To run the rake tasks, you need Ruby 1.9 however.

<code class="bash">git clone git://github.com/joliss/jquery-ui-rails.git
cd jquery-ui-rails
git submodule update --init
bundle install
bundle exec rake # rebuild assets
</code>

Most of the code lives in the Rakefile. Pull requests are more than welcome!

Hacking jQuery UI

The jquery-ui-rails repository is contributor-friendly and has a git submodule containing the official jquery-ui repo. This way it's easy to hack the jQuery UI code:

<code class="bash">cd jquery-ui
git checkout master  # or 1-8-stable
... hack-hack-hack ...
bundle exec rake  # rebuild assets based on your changes
</code>

Assuming your app's Gemfile points at your jquery-ui-rails checkout (gem 'jquery-ui-rails', :path => '~/path/to/jquery-ui-rails'), all you need to do now is refresh your browser, and your changes to jQuery UI are live in your Rails application.

You can send pull requests to the jquery-ui GitHub project straight out of your submodule. See also their Getting Involved guide.

Testing

As a smoke test, a testapp application is available in the repository, which displays a check mark and a datepicker to make sure the assets load correctly:

<code class="bash">cd testapp
bundle install
rails server
</code>

Now point your browser at http://localhost:3000/.

Limitations

  • Only the base theme (Smoothness) is included. Once it becomes possible to generate all theme files from the jQuery UI sources, we can package all the other themes in the ThemeRoller gallery.

    Perhaps we can also add helper tasks to help developers generate assets for their own custom themes or for third-party themes (like Selene).

    If you still want a different theme right now, you could probably download a custom theme and require the theme CSS after requiring any other jQuery UI CSS files you need, making sure to serve up the theme images correctly. (This is arguably cumbersome, not officially supported by this gem, and adds 1 KB overhead as both the base theme and the custom theme are served up.)

  • The jquery.ui.all.js file is named jquery-ui.js in the official distribution. We should follow their naming. But jquery-rails provides a jquery-ui.js asset as well, so until that is removed from the jquery-rails gem (see issue #46), we cannot distribute jquery-ui.js without risking conflicts.

    To reduce confusion, as long as there is no jquery-ui.js, we also do not distribute the official jquery-ui-i18n.js and jquery-ui.css. The latter is available as jquery.ui.all.css however.

印刷电路板(PCB)作为电子元件的关键支撑体,在电子设备中扮演着不可或缺的角色,其市场发展态势备受关注。QYResearch 的调研数据为我们揭示了该市场的全景:2024 年,全球印刷电路板市场规模约达 782.9 亿美元,而展望 2031 年,这一数字有望攀升至 1012.7 亿美元,在 2025 - 2031 期间,年复合增长率(CAGR)预计保持在 3.8%。然而,当前美国 2025 年关税框架的潜在变动,已然在全球市场掀起波澜,对印刷电路板市场的竞争格局、区域经济协同以及供应链体系产生着深远影响。 一、印刷电路板基础概述 印刷电路板,又被称作印制电路板或印刷线路板,常见英文缩写为 PCB(Printed circuit board)或 PWB(Printed wire board)。其内部存在金属导体,承担着连接电子元器件线路的重任。传统电路板主要运用印刷蚀刻阻剂的工艺,以此构建电路的线路与图面,这也是其名称的由来。在现代电子技术领域,PCB 通过电子印刷术制造而成,它成功搭建起电子元器件之间的电气连接桥梁,成为各类电子设备的核心组件。无论是体积小巧的智能穿戴设备,还是大型的服务器系统,只要其中配备集成电路等电子元件,PCB 必然 “参与其中”。 二、市场规模增长引擎 (一)中国主导地位凸显 中国在全球印刷电路板市场中占据着举足轻重的地位。据预测,2025 年中国市场规模有望达到 4333.21 亿元,在全球市场的占比将超过 50%。这一卓越成绩的背后,人工智能(AI)与新能源汽车产业功不可没,二者已成为驱动中国 PCB 市场增长的核心动力。以 AI 产业为例,随着 AI 技术的迅猛发展,对算力的需求呈爆发式增长,这使得 AI 服务器的市场需求大幅提升。而每台 AI 服务器中 PCB 的价值量可达 5000 元,预计到 2025 年,全球 AI 服务器相关的 PC
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值