backbone已经更新到1.1.2,在这里总结一下 我还一直用的1.0的版本,更新确实出现了一些问题 1.1.0 Backbone Views no longer automatically attach options passed to the constructor as this.opti Read More
posted @ 2014-04-16 14:07 break_happy Views(615) Comments(0) Diggs(0) Edit
目录结构原main.js// RequireJS配置requirejs.config({ baseUrl: '../js',//js文件载入基路径 //enforceDefine: true,//enforceDefine用来强制模块使用define定义,否则可能会报No define call for ...之类错误 paths: { ctrl: './models', libs:"./lib", 'jquery':"./lib/jquery", "backbone":"./ Read More
posted @ 2014-01-07 02:24 break_happy Views(7242) Comments(0) Diggs(0) Edit
var extend = function(protoProps, staticProps) { var parent = this; var child; if (protoProps && _.has(protoProps, 'constructor')) { c... Read More
posted @ 2013-12-31 10:31 break_happy Views(531) Comments(0) Diggs(0) Edit
dips(device independent pixels,设备独立像素)与屏幕密度有关。dips可以用来辅助区分视网膜设备还是非视网膜设备。window.devicePixelRatio是设备上物理像素和设备独立像素(device-independent pixels (dips))的比例: window.devicePixelRatio = 物理像素 / dips当页面设置了<meta name="viewport" content="width=device-width">时候,document.documentElement.cli Read More
posted @ 2013-05-29 03:09 break_happy Views(391) Comments(0) Diggs(0) Edit
document.execCommand()2D-Position允许通过拖曳移动绝对定位的对象。AbsolutePosition设定元素的position属性为“absolute”(绝对)。BackColor设置或获取当前选中区的背景颜色。BlockDirLTR目前尚未支持。BlockDirRTL目前尚未支持。Bold切换当前选中区的粗体显示与否。BrowseMode目前尚未支持。Copy将当前选中区复制到剪贴板。CreateBookmark创建一个书签锚或获取当前选中区或插入点的书签锚的名称。CreateLink在当前选中区上插入超级链接,或显示一个对话框允许用户指定要为当前选中区插入的超 Read More
posted @ 2013-03-26 22:08 break_happy Views(1948) Comments(0) Diggs(0) Edit
seajs使用jquery插件。方法一,将js插件cmd模块化(define封装成seajs模块,返回匿名函数,包含插件的源码)。/** * Created with JetBrains PhpStorm. * User: duph * Date: 13-3-11 * Time: 上午9:24 * To change this template use File | Settings | File Templates. */define(function(require,exports,moudles){ return function(jquery){ (functi... Read More
posted @ 2013-03-11 12:08 break_happy Views(15400) Comments(0) Diggs(0) Edit
为了让一组float:left属性的dom对象自动缩放,且同一行的的dom对象高度一致(类似3列结构),以内容最长的一列高度为标准。 var resize_height = { init:function (class_name, callback) { var ary = [] $(class_name).each(function (index, element) { var height = $(this)[0].scrollHeight ary.push(heig... Read More
posted @ 2013-03-06 17:05 break_happy Views(457) Comments(0) Diggs(0) Edit
var get_urlparm={ int:function(parm_url){ if(parm_url){ this.url=parm_url } else{ this.url=window.location.href } this.get_obj() }, get_obj:function(){ var url=this.url var paraString =url.subst... Read More
posted @ 2013-02-28 10:15 break_happy Views(228) Comments(0) Diggs(0) Edit
window.settimeout 闭包回调 function for1(ary, calback) { for (var i = 0; i 3) { window.clearTimeout(Go) return false; } console.log(ary[i]) i++ var Go = window.setTimeout(arguments.callee, 1000) }()) } window.... Read More
posted @ 2013-01-08 11:25 break_happy Views(916) Comments(0) Diggs(0) Edit
玩下,nodejs,对js的认识更深了。/** * Created with JetBrains WebStorm. * User: duph * Date: 12-12-25 * Time: 下午4:02 * To change this template use File | Settings | File Templates. */var http = require("http")/*http核心模块*/var fs = require("fs")/*fs核心模块*/var url = require("url")/*url核 Read More
posted @ 2012-12-27 14:40 break_happy Views(442) Comments(0) Diggs(0) Edit
元字符. 匹配除了换行符以外的任意字符\w 匹配字母或数字或下划线或汉字等 [a-z0-9A-Z_] (只考虑英文的话效果一样)\d 表示数字的意思,相反,\D表示非数字限定符:* 重复零次或多次+ 重复一次或多次? 重复一次或多次{n} 重复n次{n,} 重复n次或更多次{n,m} 重复n到m次空白:\f匹配换页符,\n匹配换行符,\r匹配回车,\t匹配制表符,\v匹配垂直制表符。\s匹配单个空格,等同于[\f\n\r\t\v]字符集合[abc] 表示a或者b或者c中的任意一个字符^[a-zA-Z0-9] 匹配已数字字母开头的字符串一般 来说,当“^”出现在 “[]”内时就被视... Read More
posted @ 2012-10-09 13:24 break_happy Views(4093) Comments(0) Diggs(1) Edit
$(function () { var input_type = { init:function ($obj) { this.name = $obj.html().split("") this.length = this.name.length; this.i = 0; }, pri:function () { var $this... Read More
posted @ 2012-09-21 14:08 break_happy Views(3483) Comments(3) Diggs(0) Edit
var _change = { ary0:["零", "一", "二", "三", "四", "五", "六", "七", "八", "九"], ary1:["", "十", "百", "千"], ary2:["", ... Read More
posted @ 2012-09-20 13:18 break_happy Views(16991) Comments(4) Diggs(0) Edit
window.location.hostname ;window.location.pathname;方法:通过window.location.pathname获得浏览器URL的路径部分。得到路径的第一个字段。[].indexOf || (Array.prototype.indexOf = function(v){ for(var i = this.length; i-- && this[i] !== v;); return i; });//ie不支持indexof扩展一下 var url={ ary1:["index.html","... Read More
posted @ 2012-09-19 19:27 break_happy Views(408) Comments(0) Diggs(0) Edit
Array.sort()方法是用来对数组项进行排序的,默认情况下是进行升序排列。sort()方法可以接受一个 方法为参数。sort()排序时每次比较两个数组项都回执行这个参数,并把两个比较的数组项作为参数传递给这个函数。当函数返回值为1的时候就交换两个数组项的顺序,否则就不交换。 var p = [5, 2, 3, 1, 7, 5, 6, 9, 6, 0]; function down(a, b) { return (a < b) ? 1 : -1 } p.sort(down) ... Read More
posted @ 2012-08-03 09:34 break_happy Views(33945) Comments(0) Diggs(0) Edit
队列允许一个元素来异步的访问一连串的动作,而不终止程序执行。queue 将函数加入、插入匹配元素的队列dequeue 执行匹配元素的队列queue( [ queueName ], newQueue )queueName一个含有队列名的字符串。默认是"Fx",标准的动画队列。newQueue一个替换当前函数列队内容的数组。queue( [ queueName ], callback( next ) )queueName一个含有队列名的字符串。默认是fx,标准的动画队列。callback( next )添加到列队的新函数。所以:当只传入一个参数时, 它返回并指向第一个匹配元素的 Read More
posted @ 2012-07-31 12:52 break_happy Views(5388) Comments(0) Diggs(0) Edit
网上的资料很多,关于闭包,原型链,面向对象之内的。本人也有一点自己的总结。关于this:this 的值取决于 function 被调用的方式,一共有四种,如果一个 function 是一个对象的属性,该 funtion 被调用的时候,this 的值是这个对象。如果 function 调用的表达式包含句点(.)或是 [],this 的值是句点(.)或是 [] 之前的对象。如myObj.func 和myObj["func"] 中,func 被调用时的 this 是myObj。如果一个 function 不是作为一个对象的属性,那么该 function 被调用的时候,this 的 Read More
posted @ 2012-07-18 09:16 break_happy Views(4291) Comments(3) Diggs(1) Edit
js var Drag = (function () { var $this; function drag() { this.ini.apply(this, arguments); } drag.prototype = { ini:function (inside, outside) { $this = this ... Read More
posted @ 2012-06-12 20:25 break_happy Views(350) Comments(0) Diggs(0) Edit
柱状图 Read More
posted @ 2012-06-01 15:45 break_happy Views(139) Comments(0) Diggs(0) Edit
js var TAB = function () { var $this function tab() { this.init.apply(this, arguments); } tab.prototype = { init:function (obj_li, tab_div) { $this = this $this.obj = obj_li $this.div = tab_div }, ... Read More
posted @ 2012-05-29 10:28 break_happy Views(278) Comments(0) Diggs(0) Edit