Search
10/30/2009
css - in the same line
http://chunghe.googlecode.com/svn/trunk/experiment/css.experiment/same.line.htm
<div class="meta">This article is public</div>
<div class="date">published on 2009.10.10</div>
<div class="navigate">
<a class="prev"></a>
<a class="next"></a>
</div>
meta{ float:left }
date{float:left}
now .navigate is the same line with meta and date.
.navigate{text-align:right} the all elements same line now
標籤: CSS
closure
YAHOO = {};
YAHOO.BasePanel = (function (id, config) {
var panel;
return {
build: function () {
if (panel) {
console.log('panel!');
}
panel = {'hello':'world'}
}
}
})();
YAHOO.BasePanel.build();
YAHOO.BasePanel.build();
10/26/2009
jslint - Require parens around immediate invocations
JavaScript: immediate function invocation syntax
ere is a JSLint option, one of The Good Parts in fact, that "[requires] parens around immediate invocations," meaning that the construction
(function () {
// ...
})();
would instead need to be written as
(function () {
// ...
}());
My question is this -- can anyone explain why this second form might be considered better? Is it more resilient? Less error-prone? What advantage does it have over the first form?
From Douglass Crockfords own PPT on the issue: (search for "require parens")
Makes more clearly the distinction between function values and the values of functions.
So, basically, he feels it makes more clear the distinction between function values, and the values of functions. So, it's an stylistic matter, not really a substantive difference in the code itself.
10/20/2009
10/18/2009
Nicholas C. Zakas — Scalable JavaScript Application Architecture
Nicholas C. Zakas — Scalable JavaScript Application Architecture
Sandbox Jobs
• Consistency
– Interface must be dependable
• Security
– Determine which parts of the framework a module
can access
• Communication
– Translate module requests into core actions
The application core manages modules
The application core tells a module when
it should initialize and when it should shutdown
Application Core Jobs
Manage module lifecycle
– Tell modules when to start and stop doing their job
• Enable inter-module communication
– Allow loose coupling between modules that are
related to one another
• General error handling
– Detect, trap, and report errors in the system
• Be extensible
– The first three jobs are not enough!
Ideally, only the application core has any idea what base library is being used
tight coupling
TimelineFilter = {
changeFilter: function (filter) {
Timeline.applyFilter(filter);
}
};
StatusPoster = {
postStatus: function (status) {
Timeline.post(status);
}
};
Timeline = {
applyFilter: function (filter) {
//implementation
},
post: function (status) {
//implementation
}
};loose coupling
Core.register("timeline-filter", function (sandbox) {
return {
changeFilter: function (filter) {
sandbox.notify({
type: "timeline-filter-change",
data: filter
});
}
};
});
Core.register("status-poster", function (sandbox) {
return {
postStatus: function (statusText) {
sandbox.notify({
type: "new-status",
data: statusText
});
}
};
});When modules are loosely coupled,
removing a module doesn't break the others
No direct access to another module = no breaking should the module disappear
10/15/2009
location
<protocol>//<host>[:<port>]/<pathname>[<hash>][<search>]
location.hostname和location.host有什么区别呢 - JavaScript & VBScript & DHTML 脚本技术讨论版
host 包含端口号,=host:port(当然是有端口号的时候);
hostname 不包含端口号;
10/13/2009
fireEvent
obj.fireEvent = function(el, E) {
if (document.createEvent) {
var ev = document.createEvent('Events');
ev.initEvent(E, true, true);
el.dispatchEvent(ev);
} else if (el.fireEvent) {
el.fireEvent('on'+E);
}
}
訂閱:
文章 (Atom)