- Organize resources into sections
- More detailed sections (perhaps sections & subsections)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Backbone Collection View | |
* | |
* A light-weight approach to display filetered data from collection by assigning rules, without changing original models, | |
* which works just like CollectionView in other languages (ie: Java, WPF and AS3). | |
* | |
* Usage: | |
* | |
* 1. Filter by single field: | |
* this.wineList.filterView( {Country:'France'}} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
grunt.loadNpmTasks('grunt-requirejs'); | |
grunt.initConfig({ | |
requirejs: { | |
std: { | |
options: { | |
almond: true, | |
baseUrl: "lib", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- demo | |
- http://cl.ly/image/2s0W0z1X3g2q | |
- spec | |
- show tooltip after mouseover the button for 300ms | |
- if mouseout within 300ms, don't show tooltip | |
- hide tooltip when mouseout the button | |
- hide tooltip after 1000ms | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fsm = StateMachine.create({ | |
initial: 'hungry', | |
events: [ | |
{ name: 'eat', from: 'hungry', to: 'satisfied', action: 'foo' }, | |
{ name: 'eat', from: 'satisfied', to: 'full', action: 'bar' }, | |
{ name: 'eat', from: 'full', to: 'sick', action: 'coo' }, | |
{ name: 'rest', from: ['hungry', 'satisfied', 'full', 'sick'], to: 'hungry', action: 'doo' }, | |
]}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (window) { | |
var StateMachine = { | |
//--------------------------------------------------------------------------- | |
VERSION: "2.2.0", | |
//--------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param useRGB Boolean, true for rgba format, false will return color in hex format | |
* @param randomAlpha Boolean, when using rgba format, decide whether to randomnize alpha value too | |
*/ | |
function getRandomColor( useRGB, randomAlpha ){ | |
if( useRGB ){ | |
return "rgba("+ | |
Math.floor(Math.random()*256)+","+ | |
Math.floor(Math.random()*256)+","+ | |
Math.floor(Math.random()*256)+","+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I tried to pause the script, then enter following command in the console: | |
document.getElementById('foo') | |
The weird part is, sometimes it will show the object state, but some times it will just show the <div> tag, seems it's the result of toString() ? | |
Is there a way to always get object state in the console ? | |
Screen cap here: http://cl.ly/image/0V1a1p3t0e12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.extend({ | |
getQueryString: function ( urlString, key) { | |
function parseParams() { | |
var params = {}, | |
e, | |
a = /\+/g, // Regex for replacing addition symbol with a space | |
r = /([^&=]+)=?([^&]*)/g, | |
d = function (s) { return decodeURIComponent(s.replace(a, " ")); }, | |
q = urlString; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $foo = this.$('#foo').popover( o ); | |
// 調整 popover 的 arrow 位置指向 label 中央 | |
$foo.on('shown', function( evt ){ | |
// 取得文字 label 的中間位置 | |
var rect = $foo[0].getBoundingClientRect(); | |
var targetPos = rect.left + rect.width/2; | |
// 找到 arrow 元件 |