Created
April 3, 2010 21:20
-
-
Save jashkenas/354860 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
dojo.provide 'cdoc.mixins.search' | |
dojo.require "dijit.form.ValidationTextBox" | |
dojo.require "dijit.layout.BorderContainer" | |
dojo.require "dijit.layout.ContentPane" | |
dojo.require "dojo.data.ItemFileReadStore" | |
dojo.require "cdoc.string.quicksilver" | |
dojo.declare "cdoc.mixins.search", [dijit.layout.BorderContainer], { | |
title: "Mixins" | |
design: 'headline' | |
gutters: true | |
store: null | |
abbreviation: '' | |
matches: [] | |
mixinImages: { | |
'Compass Core': "/docs/images/compass_icon.png" | |
'Blueprint': "/docs/images/blueprint_icon.png" | |
} | |
constructor: (options) -> | |
dojo.mixin this, options | |
_escapeHTML: (str) -> | |
div: document.createElement 'div' | |
text: document.createTextNode str | |
div.appendChild text | |
div.innerHTML | |
_nukeList: -> | |
this.matches: [] | |
dojo.empty this.resultList | |
_score: (item) -> | |
name: this.store.getValue item, 'name' | |
score: cdoc.string.quicksilver name.toLowerCase(), this.abbreviation.toLowerCase() | |
if score > 0 | |
pathname: this.store.getValue item, 'pathname' | |
signature: this._escapeHTML this.store.getValue item, 'signature' | |
framework: this._escapeHTML this.store.getValue item, 'framework' | |
stylesheet: this._escapeHTML this.store.getValue item, 'stylesheet' | |
line_item: dojo.create 'li', { | |
'data-framework': framework | |
'data-name': name | |
'data-signature': signature | |
'data-score': score | |
'data-stylesheet': stylesheet | |
} | |
link: dojo.create 'a', {href: pathname}, line_item | |
src: this.mixinImages[framework] or this._blankGif | |
dojo.create 'img', {src: src.toString(), alt: ''}, link | |
dojo.create 'span', {innerHTML: signature}, link | |
this.matches.push line_item | |
} |
This file contains hidden or 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(){ | |
dojo.provide('cdoc.mixins.search'); | |
dojo.require("dijit.form.ValidationTextBox"); | |
dojo.require("dijit.layout.BorderContainer"); | |
dojo.require("dijit.layout.ContentPane"); | |
dojo.require("dojo.data.ItemFileReadStore"); | |
dojo.require("cdoc.string.quicksilver"); | |
dojo.declare("cdoc.mixins.search", [dijit.layout.BorderContainer], { | |
title: "Mixins", | |
design: 'headline', | |
gutters: true, | |
store: null, | |
abbreviation: '', | |
matches: [], | |
mixinImages: { | |
'Compass Core': "/docs/images/compass_icon.png", | |
'Blueprint': "/docs/images/blueprint_icon.png" | |
}, | |
constructor: function constructor(options) { | |
return dojo.mixin(this, options); | |
}, | |
_escapeHTML: function _escapeHTML(str) { | |
var div, text; | |
div = document.createElement('div'); | |
text = document.createTextNode(str); | |
div.appendChild(text); | |
return div.innerHTML; | |
}, | |
_nukeList: function _nukeList() { | |
this.matches = []; | |
return dojo.empty(this.resultList); | |
}, | |
_score: function _score(item) { | |
var framework, line_item, link, name, pathname, score, signature, src, stylesheet; | |
name = this.store.getValue(item, 'name'); | |
score = cdoc.string.quicksilver(name.toLowerCase(), this.abbreviation.toLowerCase()); | |
if (score > 0) { | |
pathname = this.store.getValue(item, 'pathname'); | |
signature = this._escapeHTML(this.store.getValue(item, 'signature')); | |
framework = this._escapeHTML(this.store.getValue(item, 'framework')); | |
stylesheet = this._escapeHTML(this.store.getValue(item, 'stylesheet')); | |
line_item = dojo.create('li', { | |
'data-framework': framework, | |
'data-name': name, | |
'data-signature': signature, | |
'data-score': score, | |
'data-stylesheet': stylesheet | |
}); | |
link = dojo.create('a', { | |
href: pathname | |
}, line_item); | |
src = this.mixinImages[framework] || this._blankGif; | |
dojo.create('img', { | |
src: src.toString(), | |
alt: '' | |
}, link); | |
dojo.create('span', { | |
innerHTML: signature | |
}, link); | |
return this.matches.push(line_item); | |
} | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment