Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/core/Prefab.js
Show First 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | buildTokenizer : function(config) { | ||||
var typeahead = new JX.Typeahead( | var typeahead = new JX.Typeahead( | ||||
root, | root, | ||||
JX.DOM.find(root, 'input', 'tokenizer-input')); | JX.DOM.find(root, 'input', 'tokenizer-input')); | ||||
typeahead.setDatasource(datasource); | typeahead.setDatasource(datasource); | ||||
var tokenizer = new JX.Tokenizer(root); | var tokenizer = new JX.Tokenizer(root); | ||||
tokenizer.setTypeahead(typeahead); | tokenizer.setTypeahead(typeahead); | ||||
tokenizer.setRenderTokenCallback(function(value, key) { | tokenizer.setRenderTokenCallback(function(value, key, container) { | ||||
var result = datasource.getResult(key); | var result = datasource.getResult(key); | ||||
var icon; | var icon; | ||||
var type; | |||||
if (result) { | if (result) { | ||||
icon = result.icon; | icon = result.icon; | ||||
value = result.displayName; | value = result.displayName; | ||||
type = result.tokenType; | |||||
} else { | } else { | ||||
icon = config.icons[key]; | icon = config.icons[key]; | ||||
type = config.types[key]; | |||||
} | } | ||||
if (icon) { | if (icon) { | ||||
icon = JX.Prefab._renderIcon(icon); | icon = JX.Prefab._renderIcon(icon); | ||||
} | } | ||||
// TODO: Maybe we should render these closed tags in grey? Figure out | if (type) { | ||||
// how we're going to use color. | JX.DOM.alterClass(container, 'jx-tokenizer-token-' + type, true); | ||||
} | |||||
return [icon, value]; | return [icon, value]; | ||||
}); | }); | ||||
if (config.placeholder) { | if (config.placeholder) { | ||||
tokenizer.setPlaceholder(config.placeholder); | tokenizer.setPlaceholder(config.placeholder); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | transformDatasourceResults: function(fields) { | ||||
id: fields[2], | id: fields[2], | ||||
priority: fields[3], | priority: fields[3], | ||||
priorityType: fields[7], | priorityType: fields[7], | ||||
imageURI: fields[6], | imageURI: fields[6], | ||||
icon: icon, | icon: icon, | ||||
closed: closed, | closed: closed, | ||||
type: fields[5], | type: fields[5], | ||||
sprite: fields[10], | sprite: fields[10], | ||||
unique: fields[11] || false | tokenType: fields[11], | ||||
unique: fields[12] || false | |||||
}; | }; | ||||
}, | }, | ||||
_renderIcon: function(icon) { | _renderIcon: function(icon) { | ||||
return JX.$N( | return JX.$N( | ||||
'span', | 'span', | ||||
{className: 'phui-icon-view phui-font-fa ' + icon}); | {className: 'phui-icon-view phui-font-fa ' + icon}); | ||||
} | } | ||||
} | } | ||||
}); | }); |