10
09/2014
js code 笔记
分析 这段代码
!function ($) { // 执行匿名函数(返回 true)
$(function(){ //jQuery dom ready
.....
})
}(window.jQuery)
$('section [href^=#]').click(function (e) {
e.preventDefault()
})
书签不要跳
$('.bs-docs-sidenav').affix({
offset: {
top: function () { return $window.width() <= 980 ? 290 : 210 }//为啥不直接写呢
, bottom: 270
}
})
affix 锁定两头
window.prettyPrint && prettyPrint()如果有 prettyPrint 执行 ---
$('.add-on :checkbox').on('click', function () {
var $this = $(this)
, method = $this.attr('checked') ? 'addClass' : 'removeClass'
$(this).parents('.add-on')[method]('active')
})
check 点上时 method 是 addClass,所以
$(this).parents('.add-on')[method]('active')
这时候是
$(this).parents('.add-on').addClass('active')
if ($('#gridSystem').length) {
$('#gridSystem').tooltip({
selector: '.show-grid > div'
, title: function () { return $(this).width() + 'px' }
})
}
tooltips
$('.popover-test').popover()
$("a[rel=popover]")
.popover()
.click(function(e) {
e.preventDefault()
})
a rel="popover" 的不触发链接
---
$('#fat-btn')
.click(function () {
var btn = $(this)
btn.button('loading')
setTimeout(function () {
btn.button('reset')
}, 3000)
})
没看懂
$('#components.download .toggle-all').on('click', function (e) {
e.preventDefault()
inputsComponent.attr('checked', !inputsComponent.is(':checked'))
})
var css = $("#components.download input:checked")
.map(function () { return this.value })
.toArray()
, js = $("#plugins.download input:checked")
.map(function () { return this.value })
.toArray()
$("#variables.download input")
.each(function () {
$(this).val() && (vars[ $(this).prev().text() ] = $(this).val())
})
$.ajax({
type: 'POST'
, url: /\?dev/.test(window.location) ? 'http://localhost:3000' : 'http://bootstrap.herokuapp.com'
, dataType: 'jsonpi'
, params: {
js: js
, css: css
, vars: vars
, img: img
}
})