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 HAS_EXPANDING_BOX_BUG = (function(){ | |
var el = document.createElement('div'), | |
isBuggy = false; | |
el.style.height = '1px'; | |
document.body.appendChild(el); | |
isBuggy = (el.offsetHeight > 1); | |
document.body.removeChild(el); | |
el = null; | |
return isBuggy; | |
})(); |
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
javascript: /* removes annoying footer and body scrollbars, cleans-up the chat transcript, and notifies via sound when a new message arrives when in the background */ | |
$('footer_container').style.display='none'; | |
$$('body')[0].style.overflow='hidden'; | |
var ss1=document.styleSheets[0]; | |
ss1.addRule('.chat_transcript_info', 'opacity:0;-webkit-transition:opacity 0.5s ease 0.5s;'); | |
ss1.addRule('#chat_transcript:hover .chat_transcript_info', 'opacity:1;'); | |
ss1.addRule('.small_channel_img', 'display:none;'); | |
var soundCont = document.body.appendChild(document.createElement('div')); | |
soundCont.innerHTML = '<embed src="http://unscriptable.com/home/sounds/button-9.mp3" autostart=false width=0 height=0 id="msgSound" enablejavascript="true">'; | |
window._startBlinkTitle = window.startBlinkTitle; |
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
// original (http://html5shiv.googlecode.com/svn/trunk/html5.js) | |
(function(){if(!/*@cc_on!@*/0)return;var e = "abbr,article,aside,audio,canvas,datalist,details,figure,figcaption,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,summary,time,video".split(','),i=e.length;while(i--){document.createElement(e[i])}})() | |
// kangax version (29 characters less, yay!) | |
/*@cc_on(function(e,i){i=e.length;while(i--)document.createElement(e[i])})("abbr,article,aside,audio,canvas,datalist,details,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','))@*/ |
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
$.each(itemList, function (which) { | |
// if dev passed an array | |
if ($.isArray(itemList)) | |
// use the 2nd arg as item name (1st arg is array index) | |
which = arguments[1]; | |
// check if we've already initialized this item | |
var already = doneMap[which]; | |
if (!already) |
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
My comment on nettuts+ that didn't get approved (I wonder why) http://bit.ly/bwb18i | |
It seems that this post started out with good intentions: How to show junior javascript programmers how to use the Firebug profiling commands. However, due to crappy jQuery advice, turned into an illustration of web programming anti-patterns (aka “Programming No-nos”). | |
I have to agree with James (of course), and would add the following: | |
———- | |
Premature optimization. | |
Do not try to second-guess the framework (jQuery, prototype, dojo, etc.) unless you’ve already got a performance problem. The people who build those frameworks have done an excellent job and have designed them to work well in most situations. |
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
cujo.js equivalent (in-browser): | |
file: myApp.view.LoginPanel.html | |
<div class="myapp-view-loginpanel"> | |
<span data-attach="greeting">${display.greeting}</span> | |
<a data-attach="action" href="{$config.loginUrl}">{$display.loginAction}</a> | |
</div> | |
logout version extends login version (inheritance defined in myApp.view.LogoutPanel.js: |
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
attributeMap: { | |
seconds: { | |
data: "seconds", | |
type: "no-dom" | |
}, | |
displaySeconds: { | |
source: "seconds", | |
deriver: "_displaySeconds", | |
type: "no-dom" | |
} |
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 init () { | |
// find widgets by id: | |
var myStandby = dijit.byId('basicStandby1'), | |
myForm = dijit.byId('myForm'); | |
// i don't think you need this line, but i haven't studied the BasicStandby widget | |
//document.body.appendChild(myStandby.domNode); | |
dojo.connect(myForm, 'onSubmit', function() { | |
myStandby.show(); | |
}); |
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
// result sets (two identical queries) | |
var rs1, rs2; | |
//items to watch (two instances of same model data) | |
var item1, item2; | |
dojo.when(store.query({}), function (results) { | |
rs1 = results; | |
item1 = results[0]; | |
// item1.get('prop') == 'foo' |
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 createObject (ctor, args) { | |
function F () { | |
ctor.apply(this, args); | |
} | |
F.prototype = ctor.prototype; | |
F.prototype.constructor = ctor; // IE might need this | |
return new F(); | |
} | |
// quick test: |
OlderNewer