This commit is contained in:
Kate Hudson 2014-03-17 18:04:17 -04:00
Родитель b2e4540d49
Коммит c023d492a0
15 изменённых файлов: 1335 добавлений и 211 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -1 +1,2 @@
bower_components/
node_modules/

77
Gruntfile.js Normal file
Просмотреть файл

@ -0,0 +1,77 @@
module.exports = function(grunt) {
grunt.initConfig({
convert: {
strings: {
src: 'latest/weblitmap.json',
dest: 'latest/'
}
}
});
grunt.registerMultiTask('convert', 'Convert map to locale files', function() {
var path = require('path');
function specToTransifex(json) {
var output = {};
// Add title
output[json.titleKey] = json.title;
json.literacies.forEach(function(item) {
// Check duplicate keys
if (output[item.key]) {
grunt.fail.fatal('There was a duplicate key found in ' + f + ', ' + item.key + ' cannot be both "' + output[item.key] + '" and "' + item.term + '"');
}
output[item.key] = item.term;
output[item.key + json.descriptionSuffix] = item.description;
if (item.deprecates.length) {
item.deprecates.forEach(function(alternate) {
output[alternate] = item.term;
output[alternate + json.descriptionSuffix] = item.description;
});
}
});
return output;
}
this.files.forEach(function(file) {
var contents = file.src.filter(function(filepath) {
// Remove nonexistent files (it's up to you to filter or warn here).
if (!grunt.file.exists(filepath)) {
grunt.log.warn('Source file "' + filepath + '" not found.');
return false;
} else {
return true;
}
}).forEach(function(filepath) {
var json = grunt.file.readJSON(filepath);
var transifex = specToTransifex(json);
var archiveDir = 'archive/' + json.version + '/';
// Write transifex file
var transifexFileName = 'strings/' + path.basename(filepath, '.json') + '_strings_default' + '.json';
grunt.file.write(file.dest + transifexFileName, JSON.stringify(transifex, null, ' '));
grunt.log.writeln('File "' + file.dest + transifexFileName + '" created.');
// Archive
// Copy main file to archive
var specFileName = path.basename(filepath, '.json') + '.json';
grunt.file.write(archiveDir + specFileName, JSON.stringify(json, null, ' '));
grunt.log.writeln('File "' + archiveDir + specFileName + '" created.');
grunt.file.write(archiveDir + transifexFileName, JSON.stringify(transifex, null, ' '));
grunt.log.writeln('File "' + archiveDir + transifexFileName + '" created.');
});
});
});
grunt.registerTask('build', ['convert']);
};

11
README.md Normal file
Просмотреть файл

@ -0,0 +1,11 @@
# Web Literacy Map Keys
Maps 'key' tags to strings for tagging the Web Literacy standard.
### Creating a new version
1. Only edit the file `weblitmap.json` in the `latest/` directory. Make sure you update the version number.
2. Run `grunt build` - this will create a transfiex file in `latest/strings/`, as well as a folder including the version in the `archive` folder.
3. Tag your release with `npm version <version>` and `git push <remote> master --tags
### Usage

Просмотреть файл

@ -0,0 +1,31 @@
{
"WBLIT-MAP": "Web Literacy Map",
"WBLIT-0": "Navigation",
"WBLIT-0_desc": "Using software tools to browse the web",
"WBLIT-1": "Web Mechanics",
"WBLIT-1_desc": "Understanding the web ecosystem",
"WBLIT-2": "Search",
"WBLIT-2_desc": "Locating information, people and resources via the web",
"WBLIT-3": "Credibility",
"WBLIT-3_desc": "Critically evaluating information found on the web",
"WBLIT-4": "Security",
"WBLIT-4_desc": "Keeping systems, identities, and content safe",
"WBLIT-5": "Composing for the Web",
"WBLIT-5_desc": "Creating and curating content for the web",
"WBLIT-6": "Remixing",
"WBLIT-6_desc": "Modifying existing web resources to create something new",
"WBLIT-7": "Design and Accessibility",
"WBLIT-7_desc": "Creating universally effective communications through web resources",
"WBLIT-8": "Coding/Scripting",
"WBLIT-8_desc": "Creating interactive experiences on the web",
"WBLIT-9": "Infrastructure",
"WBLIT-9_desc": "Understanding the Internet stack",
"WBLIT-10": "Sharing and Collaborating",
"WBLIT-10_desc": "Jointly creating and providing access to web resources",
"WBLIT-11": "Community Participation",
"WBLIT-11_desc": "Getting involved in web communities and understanding their practices",
"WBLIT-12": "Privacy",
"WBLIT-12_desc": "Examining the consequences of sharing data online",
"WBLIT-13": "Open Practices",
"WBLIT-13_desc": "Helping to keep the web democratic and universally accessible"
}

Просмотреть файл

@ -0,0 +1,92 @@
{
"title": "Web Literacy Map",
"titleKey": "WBLIT-MAP",
"version": "1.1.0",
"descriptionSuffix": "_desc",
"literacies": [
{
"term": "Navigation",
"description": "Using software tools to browse the Web",
"key": "WBLIT-0",
"deprecates": []
},
{
"term": "Web Mechanics",
"description": "Understanding the Web ecosystem",
"key": "WBLIT-1",
"deprecates": []
},
{
"term": "Search",
"description": "Locating information, people and resources via the Web",
"key": "WBLIT-2",
"deprecates": []
},
{
"term": "Credibility",
"description": "Critically evaluating information found on the Web",
"key": "WBLIT-3",
"deprecates": []
},
{
"term": "Security",
"description": "Keeping systems, identities, and content safe",
"key": "WBLIT-4",
"deprecates": []
},
{
"term": "Composing for the Web",
"description": "Creating and curating content for the Web",
"key": "WBLIT-5",
"deprecates": []
},
{
"term": "Remixing",
"description": "Modifying existing Web resources to create something new",
"key": "WBLIT-6",
"deprecates": []
},
{
"term": "Design and Accessibility",
"description": "Creating universally effective communications through Web resources",
"key": "WBLIT-7",
"deprecates": []
},
{
"term": "Coding/Scripting",
"description": "Creating interactive experiences on the Web",
"key": "WBLIT-8",
"deprecates": []
},
{
"term": "Infrastructure",
"description": "Understanding the Internet stack",
"key": "WBLIT-9",
"deprecates": []
},
{
"term": "Sharing and Collaborating",
"description": "Creating and providing access to Web resources",
"key": "WBLIT-10",
"deprecates": []
},
{
"term": "Community Participation",
"description": "Getting involved in web communities and understanding their practices",
"key": "WBLIT-11",
"deprecates": []
},
{
"term": "Privacy",
"description": "Examining the consequences of sharing data online",
"key": "WBLIT-12",
"deprecates": []
},
{
"term": "Open Practices",
"description": "Helping to keep the Web democratic and universally accessible",
"key": "WBLIT-13",
"deprecates": []
}
]
}

Просмотреть файл

@ -0,0 +1,33 @@
{
"WBLIT-MAP": "Web Literacy Map",
"WBLIT-0": "Navigation",
"WBLIT-0_desc": "Using software tools to browse the Web",
"WBLIT-1": "Web Mechanics",
"WBLIT-1_desc": "Understanding the Web ecosystem",
"WBLIT-2": "Search",
"WBLIT-2_desc": "Locating information, people and resources via the Web",
"WBLIT-3": "Credibility",
"WBLIT-3_desc": "Critically evaluating information found on the Web",
"WBLIT-4": "Security",
"WBLIT-4_desc": "Keeping systems, identities, and content safe",
"WBLIT-5": "Composing for the Web",
"WBLIT-5_desc": "Creating and curating content for the Web",
"WBLIT-6": "Remixing",
"WBLIT-6_desc": "Modifying existing Web resources to create something new",
"WBLIT-7": "Design and Accessibility",
"WBLIT-7_desc": "Creating universally effective communications through Web resources",
"WBLIT-8": "Coding/Scripting",
"WBLIT-8_desc": "Creating interactive experiences on the Web",
"WBLIT-9": "Infrastructure",
"WBLIT-9_desc": "Understanding the Internet stack",
"WBLIT-10": "Sharing",
"WBLIT-10_desc": "Providing access to Web resources",
"WBLIT-14": "Collaborating",
"WBLIT-14_desc": "Creating Web resources with others",
"WBLIT-11": "Community Participation",
"WBLIT-11_desc": "Getting involved in web communities and understanding their practices",
"WBLIT-12": "Privacy",
"WBLIT-12_desc": "Examining the consequences of sharing data online",
"WBLIT-13": "Open Practices",
"WBLIT-13_desc": "Helping to keep the Web democratic and universally accessible"
}

Просмотреть файл

@ -0,0 +1,98 @@
{
"title": "Web Literacy Map",
"titleKey": "WBLIT-MAP",
"version": "1.1.0",
"descriptionSuffix": "_desc",
"literacies": [
{
"term": "Navigation",
"description": "Using software tools to browse the Web",
"key": "WBLIT-0",
"deprecates": []
},
{
"term": "Web Mechanics",
"description": "Understanding the Web ecosystem",
"key": "WBLIT-1",
"deprecates": []
},
{
"term": "Search",
"description": "Locating information, people and resources via the Web",
"key": "WBLIT-2",
"deprecates": []
},
{
"term": "Credibility",
"description": "Critically evaluating information found on the Web",
"key": "WBLIT-3",
"deprecates": []
},
{
"term": "Security",
"description": "Keeping systems, identities, and content safe",
"key": "WBLIT-4",
"deprecates": []
},
{
"term": "Composing for the Web",
"description": "Creating and curating content for the Web",
"key": "WBLIT-5",
"deprecates": []
},
{
"term": "Remixing",
"description": "Modifying existing Web resources to create something new",
"key": "WBLIT-6",
"deprecates": []
},
{
"term": "Design and Accessibility",
"description": "Creating universally effective communications through Web resources",
"key": "WBLIT-7",
"deprecates": []
},
{
"term": "Coding/Scripting",
"description": "Creating interactive experiences on the Web",
"key": "WBLIT-8",
"deprecates": []
},
{
"term": "Infrastructure",
"description": "Understanding the Internet stack",
"key": "WBLIT-9",
"deprecates": []
},
{
"term": "Sharing",
"description": "Providing access to Web resources",
"key": "WBLIT-10",
"deprecates": []
},
{
"term": "Collaborating",
"description": "Creating Web resources with others",
"key": "WBLIT-14",
"deprecates": []
},
{
"term": "Community Participation",
"description": "Getting involved in web communities and understanding their practices",
"key": "WBLIT-11",
"deprecates": []
},
{
"term": "Privacy",
"description": "Examining the consequences of sharing data online",
"key": "WBLIT-12",
"deprecates": []
},
{
"term": "Open Practices",
"description": "Helping to keep the Web democratic and universally accessible",
"key": "WBLIT-13",
"deprecates": []
}
]
}

Просмотреть файл

@ -5,8 +5,5 @@
"authors": [
"Kate Hudson <k88hudson@gmail.com>"
],
"license": "MIT",
"dependencies": {
"devbridge-autocomplete": "1.2.9"
}
"license": "MIT"
}

823
example/autocomplete.js Normal file
Просмотреть файл

@ -0,0 +1,823 @@
/**
* Ajax Autocomplete for jQuery, version 1.2.9
* (c) 2013 Tomas Kirda
*
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
*
*/
/*jslint browser: true, white: true, plusplus: true */
/*global define, window, document, jQuery */
// Expose plugin as an AMD module if AMD loader is present:
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
'use strict';
var
utils = (function () {
return {
escapeRegExChars: function (value) {
return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
},
createNode: function (containerClass) {
var div = document.createElement('div');
div.className = containerClass;
div.style.position = 'absolute';
div.style.display = 'none';
return div;
}
};
}()),
keys = {
ESC: 27,
TAB: 9,
RETURN: 13,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40
};
function Autocomplete(el, options) {
var noop = function () { },
that = this,
defaults = {
autoSelectFirst: false,
appendTo: 'body',
serviceUrl: null,
lookup: null,
onSelect: null,
width: 'auto',
minChars: 1,
maxHeight: 300,
deferRequestBy: 0,
params: {},
formatResult: Autocomplete.formatResult,
delimiter: null,
zIndex: 9999,
type: 'GET',
noCache: false,
onSearchStart: noop,
onSearchComplete: noop,
onSearchError: noop,
containerClass: 'autocomplete-suggestions',
tabDisabled: false,
dataType: 'text',
currentRequest: null,
triggerSelectOnValidInput: true,
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
},
paramName: 'query',
transformResult: function (response) {
return typeof response === 'string' ? $.parseJSON(response) : response;
}
};
// Shared variables:
that.element = el;
that.el = $(el);
that.suggestions = [];
that.badQueries = [];
that.selectedIndex = -1;
that.currentValue = that.element.value;
that.intervalId = 0;
that.cachedResponse = {};
that.onChangeInterval = null;
that.onChange = null;
that.isLocal = false;
that.suggestionsContainer = null;
that.options = $.extend({}, defaults, options);
that.classes = {
selected: 'autocomplete-selected',
suggestion: 'autocomplete-suggestion'
};
that.hint = null;
that.hintValue = '';
that.selection = null;
// Initialize and set options:
that.initialize();
that.setOptions(options);
}
Autocomplete.utils = utils;
$.Autocomplete = Autocomplete;
Autocomplete.formatResult = function (suggestion, currentValue) {
var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
return suggestion.value.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
};
Autocomplete.prototype = {
killerFn: null,
initialize: function () {
var that = this,
suggestionSelector = '.' + that.classes.suggestion,
selected = that.classes.selected,
options = that.options,
container;
// Remove autocomplete attribute to prevent native suggestions:
that.element.setAttribute('autocomplete', 'off');
that.killerFn = function (e) {
if ($(e.target).closest('.' + that.options.containerClass).length === 0) {
that.killSuggestions();
that.disableKillerFn();
}
};
that.suggestionsContainer = Autocomplete.utils.createNode(options.containerClass);
container = $(that.suggestionsContainer);
container.appendTo(options.appendTo);
// Only set width if it was provided:
if (options.width !== 'auto') {
container.width(options.width);
}
// Listen for mouse over event on suggestions list:
container.on('mouseover.autocomplete', suggestionSelector, function () {
that.activate($(this).data('index'));
});
// Deselect active element when mouse leaves suggestions container:
container.on('mouseout.autocomplete', function () {
that.selectedIndex = -1;
container.children('.' + selected).removeClass(selected);
});
// Listen for click event on suggestions list:
container.on('click.autocomplete', suggestionSelector, function () {
that.select($(this).data('index'));
});
that.fixPosition();
that.fixPositionCapture = function () {
if (that.visible) {
that.fixPosition();
}
};
$(window).on('resize.autocomplete', that.fixPositionCapture);
that.el.on('keydown.autocomplete', function (e) { that.onKeyPress(e); });
that.el.on('keyup.autocomplete', function (e) { that.onKeyUp(e); });
that.el.on('blur.autocomplete', function () { that.onBlur(); });
that.el.on('focus.autocomplete', function () { that.onFocus(); });
that.el.on('change.autocomplete', function (e) { that.onKeyUp(e); });
},
onFocus: function () {
var that = this;
that.fixPosition();
if (that.options.minChars <= that.el.val().length) {
that.onValueChange();
}
},
onBlur: function () {
this.enableKillerFn();
},
setOptions: function (suppliedOptions) {
var that = this,
options = that.options;
$.extend(options, suppliedOptions);
that.isLocal = $.isArray(options.lookup);
if (that.isLocal) {
options.lookup = that.verifySuggestionsFormat(options.lookup);
}
// Adjust height, width and z-index:
$(that.suggestionsContainer).css({
'max-height': options.maxHeight + 'px',
'width': options.width + 'px',
'z-index': options.zIndex
});
},
clearCache: function () {
this.cachedResponse = {};
this.badQueries = [];
},
clear: function () {
this.clearCache();
this.currentValue = '';
this.suggestions = [];
},
disable: function () {
var that = this;
that.disabled = true;
if (that.currentRequest) {
that.currentRequest.abort();
}
},
enable: function () {
this.disabled = false;
},
fixPosition: function () {
var that = this,
offset,
styles;
// Don't adjsut position if custom container has been specified:
if (that.options.appendTo !== 'body') {
return;
}
offset = that.el.offset();
styles = {
top: (offset.top + that.el.outerHeight()) + 'px',
left: offset.left + 'px'
};
if (that.options.width === 'auto') {
styles.width = (that.el.outerWidth() - 2) + 'px';
}
$(that.suggestionsContainer).css(styles);
},
enableKillerFn: function () {
var that = this;
$(document).on('click.autocomplete', that.killerFn);
},
disableKillerFn: function () {
var that = this;
$(document).off('click.autocomplete', that.killerFn);
},
killSuggestions: function () {
var that = this;
that.stopKillSuggestions();
that.intervalId = window.setInterval(function () {
that.hide();
that.stopKillSuggestions();
}, 50);
},
stopKillSuggestions: function () {
window.clearInterval(this.intervalId);
},
isCursorAtEnd: function () {
var that = this,
valLength = that.el.val().length,
selectionStart = that.element.selectionStart,
range;
if (typeof selectionStart === 'number') {
return selectionStart === valLength;
}
if (document.selection) {
range = document.selection.createRange();
range.moveStart('character', -valLength);
return valLength === range.text.length;
}
return true;
},
onKeyPress: function (e) {
var that = this;
// If suggestions are hidden and user presses arrow down, display suggestions:
if (!that.disabled && !that.visible && e.which === keys.DOWN && that.currentValue) {
that.suggest();
return;
}
if (that.disabled || !that.visible) {
return;
}
switch (e.which) {
case keys.ESC:
that.el.val(that.currentValue);
that.hide();
break;
case keys.RIGHT:
if (that.hint && that.options.onHint && that.isCursorAtEnd()) {
that.selectHint();
break;
}
return;
case keys.TAB:
if (that.hint && that.options.onHint) {
that.selectHint();
return;
}
// Fall through to RETURN
case keys.RETURN:
if (that.selectedIndex === -1) {
that.hide();
return;
}
that.select(that.selectedIndex);
if (e.which === keys.TAB && that.options.tabDisabled === false) {
return;
}
break;
case keys.UP:
that.moveUp();
break;
case keys.DOWN:
that.moveDown();
break;
default:
return;
}
// Cancel event if function did not return:
e.stopImmediatePropagation();
e.preventDefault();
},
onKeyUp: function (e) {
var that = this;
if (that.disabled) {
return;
}
switch (e.which) {
case keys.UP:
case keys.DOWN:
return;
}
clearInterval(that.onChangeInterval);
if (that.currentValue !== that.el.val()) {
that.findBestHint();
if (that.options.deferRequestBy > 0) {
// Defer lookup in case when value changes very quickly:
that.onChangeInterval = setInterval(function () {
that.onValueChange();
}, that.options.deferRequestBy);
} else {
that.onValueChange();
}
}
},
onValueChange: function () {
var that = this,
options = that.options,
value = that.el.val(),
query = that.getQuery(value),
index;
if (that.selection) {
that.selection = null;
(options.onInvalidateSelection || $.noop).call(that.element);
}
clearInterval(that.onChangeInterval);
that.currentValue = value;
that.selectedIndex = -1;
// Check existing suggestion for the match before proceeding:
if (options.triggerSelectOnValidInput) {
index = that.findSuggestionIndex(query);
if (index !== -1) {
that.select(index);
return;
}
}
if (query.length < options.minChars) {
that.hide();
} else {
that.getSuggestions(query);
}
},
findSuggestionIndex: function (query) {
var that = this,
index = -1,
queryLowerCase = query.toLowerCase();
$.each(that.suggestions, function (i, suggestion) {
if (suggestion.value.toLowerCase() === queryLowerCase) {
index = i;
return false;
}
});
return index;
},
getQuery: function (value) {
var delimiter = this.options.delimiter,
parts;
if (!delimiter) {
return value;
}
parts = value.split(delimiter);
return $.trim(parts[parts.length - 1]);
},
getSuggestionsLocal: function (query) {
var that = this,
options = that.options,
queryLowerCase = query.toLowerCase(),
filter = options.lookupFilter,
limit = parseInt(options.lookupLimit, 10),
data;
data = {
suggestions: $.grep(options.lookup, function (suggestion) {
return filter(suggestion, query, queryLowerCase);
})
};
if (limit && data.suggestions.length > limit) {
data.suggestions = data.suggestions.slice(0, limit);
}
return data;
},
getSuggestions: function (q) {
var response,
that = this,
options = that.options,
serviceUrl = options.serviceUrl,
data,
cacheKey;
options.params[options.paramName] = q;
data = options.ignoreParams ? null : options.params;
if (that.isLocal) {
response = that.getSuggestionsLocal(q);
} else {
if ($.isFunction(serviceUrl)) {
serviceUrl = serviceUrl.call(that.element, q);
}
cacheKey = serviceUrl + '?' + $.param(data || {});
response = that.cachedResponse[cacheKey];
}
if (response && $.isArray(response.suggestions)) {
that.suggestions = response.suggestions;
that.suggest();
} else if (!that.isBadQuery(q)) {
if (options.onSearchStart.call(that.element, options.params) === false) {
return;
}
if (that.currentRequest) {
that.currentRequest.abort();
}
that.currentRequest = $.ajax({
url: serviceUrl,
data: data,
type: options.type,
dataType: options.dataType
}).done(function (data) {
that.currentRequest = null;
that.processResponse(data, q, cacheKey);
options.onSearchComplete.call(that.element, q);
}).fail(function (jqXHR, textStatus, errorThrown) {
options.onSearchError.call(that.element, q, jqXHR, textStatus, errorThrown);
});
}
},
isBadQuery: function (q) {
var badQueries = this.badQueries,
i = badQueries.length;
while (i--) {
if (q.indexOf(badQueries[i]) === 0) {
return true;
}
}
return false;
},
hide: function () {
var that = this;
that.visible = false;
that.selectedIndex = -1;
$(that.suggestionsContainer).hide();
that.signalHint(null);
},
suggest: function () {
if (this.suggestions.length === 0) {
this.hide();
return;
}
var that = this,
options = that.options,
formatResult = options.formatResult,
value = that.getQuery(that.currentValue),
className = that.classes.suggestion,
classSelected = that.classes.selected,
container = $(that.suggestionsContainer),
beforeRender = options.beforeRender,
html = '',
index,
width;
if (options.triggerSelectOnValidInput) {
index = that.findSuggestionIndex(value);
if (index !== -1) {
that.select(index);
return;
}
}
// Build suggestions inner HTML:
$.each(that.suggestions, function (i, suggestion) {
html += '<div class="' + className + '" data-index="' + i + '">' + formatResult(suggestion, value) + '</div>';
});
// If width is auto, adjust width before displaying suggestions,
// because if instance was created before input had width, it will be zero.
// Also it adjusts if input width has changed.
// -2px to account for suggestions border.
if (options.width === 'auto') {
width = that.el.outerWidth() - 2;
container.width(width > 0 ? width : 300);
}
container.html(html);
// Select first value by default:
if (options.autoSelectFirst) {
that.selectedIndex = 0;
container.children().first().addClass(classSelected);
}
if ($.isFunction(beforeRender)) {
beforeRender.call(that.element, container);
}
container.show();
that.visible = true;
that.findBestHint();
},
findBestHint: function () {
var that = this,
value = that.el.val().toLowerCase(),
bestMatch = null;
if (!value) {
return;
}
$.each(that.suggestions, function (i, suggestion) {
var foundMatch = suggestion.value.toLowerCase().indexOf(value) === 0;
if (foundMatch) {
bestMatch = suggestion;
}
return !foundMatch;
});
that.signalHint(bestMatch);
},
signalHint: function (suggestion) {
var hintValue = '',
that = this;
if (suggestion) {
hintValue = that.currentValue + suggestion.value.substr(that.currentValue.length);
}
if (that.hintValue !== hintValue) {
that.hintValue = hintValue;
that.hint = suggestion;
(this.options.onHint || $.noop)(hintValue);
}
},
verifySuggestionsFormat: function (suggestions) {
// If suggestions is string array, convert them to supported format:
if (suggestions.length && typeof suggestions[0] === 'string') {
return $.map(suggestions, function (value) {
return { value: value, data: null };
});
}
return suggestions;
},
processResponse: function (response, originalQuery, cacheKey) {
var that = this,
options = that.options,
result = options.transformResult(response, originalQuery);
result.suggestions = that.verifySuggestionsFormat(result.suggestions);
// Cache results if cache is not disabled:
if (!options.noCache) {
that.cachedResponse[cacheKey] = result;
if (result.suggestions.length === 0) {
that.badQueries.push(cacheKey);
}
}
// Return if originalQuery is not matching current query:
if (originalQuery !== that.getQuery(that.currentValue)) {
return;
}
that.suggestions = result.suggestions;
that.suggest();
},
activate: function (index) {
var that = this,
activeItem,
selected = that.classes.selected,
container = $(that.suggestionsContainer),
children = container.children();
container.children('.' + selected).removeClass(selected);
that.selectedIndex = index;
if (that.selectedIndex !== -1 && children.length > that.selectedIndex) {
activeItem = children.get(that.selectedIndex);
$(activeItem).addClass(selected);
return activeItem;
}
return null;
},
selectHint: function () {
var that = this,
i = $.inArray(that.hint, that.suggestions);
that.select(i);
},
select: function (i) {
var that = this;
that.hide();
that.onSelect(i);
},
moveUp: function () {
var that = this;
if (that.selectedIndex === -1) {
return;
}
if (that.selectedIndex === 0) {
$(that.suggestionsContainer).children().first().removeClass(that.classes.selected);
that.selectedIndex = -1;
that.el.val(that.currentValue);
that.findBestHint();
return;
}
that.adjustScroll(that.selectedIndex - 1);
},
moveDown: function () {
var that = this;
if (that.selectedIndex === (that.suggestions.length - 1)) {
return;
}
that.adjustScroll(that.selectedIndex + 1);
},
adjustScroll: function (index) {
var that = this,
activeItem = that.activate(index),
offsetTop,
upperBound,
lowerBound,
heightDelta = 25;
if (!activeItem) {
return;
}
offsetTop = activeItem.offsetTop;
upperBound = $(that.suggestionsContainer).scrollTop();
lowerBound = upperBound + that.options.maxHeight - heightDelta;
if (offsetTop < upperBound) {
$(that.suggestionsContainer).scrollTop(offsetTop);
} else if (offsetTop > lowerBound) {
$(that.suggestionsContainer).scrollTop(offsetTop - that.options.maxHeight + heightDelta);
}
that.el.val(that.getValue(that.suggestions[index].value));
that.signalHint(null);
},
onSelect: function (index) {
var that = this,
onSelectCallback = that.options.onSelect,
suggestion = that.suggestions[index];
that.currentValue = that.getValue(suggestion.value);
that.el.val(that.currentValue);
that.signalHint(null);
that.suggestions = [];
that.selection = suggestion;
if ($.isFunction(onSelectCallback)) {
onSelectCallback.call(that.element, suggestion);
}
},
getValue: function (value) {
var that = this,
delimiter = that.options.delimiter,
currentValue,
parts;
if (!delimiter) {
return value;
}
currentValue = that.currentValue;
parts = currentValue.split(delimiter);
if (parts.length === 1) {
return value;
}
return currentValue.substr(0, currentValue.length - parts[parts.length - 1].length) + value;
},
dispose: function () {
var that = this;
that.el.off('.autocomplete').removeData('autocomplete');
that.disableKillerFn();
$(window).off('resize.autocomplete', that.fixPositionCapture);
$(that.suggestionsContainer).remove();
}
};
// Create chainable jQuery plugin:
$.fn.autocomplete = function (options, args) {
var dataKey = 'autocomplete';
// If function invoked without argument return
// instance of the first matched element:
if (arguments.length === 0) {
return this.first().data(dataKey);
}
return this.each(function () {
var inputElement = $(this),
instance = inputElement.data(dataKey);
if (typeof options === 'string') {
if (instance && typeof instance[options] === 'function') {
instance[options](args);
}
} else {
// If instance already exists, destroy it:
if (instance && instance.dispose) {
instance.dispose();
}
instance = new Autocomplete(this, options);
inputElement.data(dataKey, instance);
}
});
};
}));

Просмотреть файл

@ -16,10 +16,12 @@
float: left;
width: 250px;
margin-right: 5px;
margin-bottom: 5px;
}
.auto-tag {
float: left;
margin-right: 5px;
margin-bottom: 5px;
}
</style>
@ -40,7 +42,7 @@
<div class="tag-input-wrapper">
<div class="input-group">
<input class="form-control" id="tagger">
<div class="input-group-btn">
<!-- <div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
@ -49,7 +51,7 @@
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
</div> -->
</div>
</div>
</div>
@ -59,16 +61,17 @@
<script src="https://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="bower_components/devbridge-autocomplete/dist/jquery.autocomplete.js"></script>
<script src="autocomplete.js"></script>
<script>
var name = 'weblitmap_1.0_';
var suggestions = [];
var strings = {};
$('#tagger').autocomplete({
lookup: suggestions,
onSelect: function(suggestion) {
$('#tag').append('<a class="btn btn-primary auto-tag">' + suggestion.value + '</a>');
$('#tag').append('<a class="btn btn-primary auto-tag" data-tag="' + suggestion.data.tags[0] + '">' + suggestion.value + '</a>');
$('#tagger').val('');
suggestions = $.grep(suggestions, function(item) {
return item.value !== suggestion.value;
@ -80,17 +83,22 @@
});
function loadJSON(e) {
console.log(e);
$.getJSON(name + (this.value || 'en-US') + '.json', function(data) {
$.getJSON(name + (this.value || 'en-US') + '.json', function(data) {
strings = {};
suggestions = data.map(function(item, i) {
item.tags.forEach(function(tag) {
strings[tag] = item.term;
});
return {
value: item.term,
data: item
};
});
console.log(suggestions);
$('#tag .auto-tag').each(function(i, el) {
$(el).html(strings[el.getAttribute('data-tag')]);
});
$('#tagger').autocomplete().setOptions({
lookup: suggestions

Просмотреть файл

@ -0,0 +1,33 @@
{
"WBLIT-MAP": "Web Literacy Map",
"WBLIT-0": "Navigation",
"WBLIT-0_desc": "Using software tools to browse the Web",
"WBLIT-1": "Web Mechanics",
"WBLIT-1_desc": "Understanding the Web ecosystem",
"WBLIT-2": "Search",
"WBLIT-2_desc": "Locating information, people and resources via the Web",
"WBLIT-3": "Credibility",
"WBLIT-3_desc": "Critically evaluating information found on the Web",
"WBLIT-4": "Security",
"WBLIT-4_desc": "Keeping systems, identities, and content safe",
"WBLIT-5": "Composing for the Web",
"WBLIT-5_desc": "Creating and curating content for the Web",
"WBLIT-6": "Remixing",
"WBLIT-6_desc": "Modifying existing Web resources to create something new",
"WBLIT-7": "Design and Accessibility",
"WBLIT-7_desc": "Creating universally effective communications through Web resources",
"WBLIT-8": "Coding/Scripting",
"WBLIT-8_desc": "Creating interactive experiences on the Web",
"WBLIT-9": "Infrastructure",
"WBLIT-9_desc": "Understanding the Internet stack",
"WBLIT-10": "Sharing",
"WBLIT-10_desc": "Providing access to Web resources",
"WBLIT-14": "Collaborating",
"WBLIT-14_desc": "Creating Web resources with others",
"WBLIT-11": "Community Participation",
"WBLIT-11_desc": "Getting involved in web communities and understanding their practices",
"WBLIT-12": "Privacy",
"WBLIT-12_desc": "Examining the consequences of sharing data online",
"WBLIT-13": "Open Practices",
"WBLIT-13_desc": "Helping to keep the Web democratic and universally accessible"
}

98
latest/weblitmap.json Normal file
Просмотреть файл

@ -0,0 +1,98 @@
{
"title": "Web Literacy Map",
"titleKey": "WBLIT-MAP",
"version": "1.1.0",
"descriptionSuffix": "_desc",
"literacies": [
{
"term": "Navigation",
"description": "Using software tools to browse the Web",
"key": "WBLIT-0",
"deprecates": []
},
{
"term": "Web Mechanics",
"description": "Understanding the Web ecosystem",
"key": "WBLIT-1",
"deprecates": []
},
{
"term": "Search",
"description": "Locating information, people and resources via the Web",
"key": "WBLIT-2",
"deprecates": []
},
{
"term": "Credibility",
"description": "Critically evaluating information found on the Web",
"key": "WBLIT-3",
"deprecates": []
},
{
"term": "Security",
"description": "Keeping systems, identities, and content safe",
"key": "WBLIT-4",
"deprecates": []
},
{
"term": "Composing for the Web",
"description": "Creating and curating content for the Web",
"key": "WBLIT-5",
"deprecates": []
},
{
"term": "Remixing",
"description": "Modifying existing Web resources to create something new",
"key": "WBLIT-6",
"deprecates": []
},
{
"term": "Design and Accessibility",
"description": "Creating universally effective communications through Web resources",
"key": "WBLIT-7",
"deprecates": []
},
{
"term": "Coding/Scripting",
"description": "Creating interactive experiences on the Web",
"key": "WBLIT-8",
"deprecates": []
},
{
"term": "Infrastructure",
"description": "Understanding the Internet stack",
"key": "WBLIT-9",
"deprecates": []
},
{
"term": "Sharing",
"description": "Providing access to Web resources",
"key": "WBLIT-10",
"deprecates": []
},
{
"term": "Collaborating",
"description": "Creating Web resources with others",
"key": "WBLIT-14",
"deprecates": []
},
{
"term": "Community Participation",
"description": "Getting involved in web communities and understanding their practices",
"key": "WBLIT-11",
"deprecates": []
},
{
"term": "Privacy",
"description": "Examining the consequences of sharing data online",
"key": "WBLIT-12",
"deprecates": []
},
{
"term": "Open Practices",
"description": "Helping to keep the Web democratic and universally accessible",
"key": "WBLIT-13",
"deprecates": []
}
]
}

22
package.json Normal file
Просмотреть файл

@ -0,0 +1,22 @@
{
"name": "weblit-keys",
"version": "0.0.0",
"description": "",
"main": "Gruntfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git://github.com/k88hudson/weblit-keys.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/k88hudson/weblit-keys/issues"
},
"homepage": "https://github.com/k88hudson/weblit-keys",
"dependencies": {
"grunt": "~0.4.4"
}
}

Просмотреть файл

@ -1,100 +0,0 @@
[
{
"term": "Navigation",
"description": "Using software tools to browse the web",
"tags": [
"WBLIT-0"
]
},
{
"term": "Web Mechanics",
"description": "Understanding the web ecosystem",
"tags": [
"WBLIT-1"
]
},
{
"term": "Search",
"description": "Locating information, people and resources via the web",
"tags": [
"WBLIT-2"
]
},
{
"term": "Credibility",
"description": "Critically evaluating information found on the web",
"tags": [
"WBLIT-3"
]
},
{
"term": "Security",
"description": "Keeping systems, identities, and content safe",
"tags": [
"WBLIT-4"
]
},
{
"term": "Composing for the Web",
"description": "Creating and curating content for the web",
"tags": [
"WBLIT-5"
]
},
{
"term": "Remixing",
"description": "Modifying existing web resources to create something new",
"tags": [
"WBLIT-6"
]
},
{
"term": "Design and Accessibility",
"description": "Creating universally effective communications through web resources",
"tags": [
"WBLIT-7"
]
},
{
"term": "Coding/Scripting",
"description": "Creating interactive experiences on the web",
"tags": [
"WBLIT-8"
]
},
{
"term": "Infrastructure",
"description": "Understanding the Internet stack",
"tags": [
"WBLIT-9"
]
},
{
"term": "Sharing and Collaborating",
"description": "Jointly creating and providing access to web resources",
"tags": [
"WBLIT-10"
]
},
{
"term": "Community Participation",
"description": "Getting involved in web communities and understanding their practices",
"tags": [
"WBLIT-11"
]
},
{
"term": "Privacy",
"description": "Examining the consequences of sharing data online",
"tags": [
"WBLIT-12"
]
},
{
"term": "Open Practices",
"description": "Helping to keep the web democratic and universally accessible",
"tags": [
"WBLIT-13"
]
}
]

Просмотреть файл

@ -1,100 +0,0 @@
[
{
"term": "Navigation",
"description": "Utiliser des outils logiciels pour naviguer sur le Web",
"tags": [
"WBLIT-0"
]
},
{
"term": "Mécanismes du web",
"description": "Comprendre lécosystème du web",
"tags": [
"WBLIT-1"
]
},
{
"term": "Recherche",
"description": "Trouver de linformation, des gens et des ressources via le web",
"tags": [
"WBLIT-2"
]
},
{
"term": "Crédibilité",
"description": "Évaluer avec esprit critique les informations trouvées sur le web",
"tags": [
"WBLIT-3"
]
},
{
"term": "Sécurité",
"description": "Sassurer de la sûreté des systèmes, des identités et du contenu",
"tags": [
"WBLIT-4"
]
},
{
"term": "Composer pour le web",
"description": "Créer et maintenir du contenu en ligne",
"tags": [
"WBLIT-5"
]
},
{
"term": "Remixer",
"description": "Modifier des ressources en ligne existantes pour créer de nouvelles choses",
"tags": [
"WBLIT-6"
]
},
{
"term": "Design et accessibilité",
"description": "Créer des communications universellement efficaces grâce à des ressources web",
"tags": [
"WBLIT-7"
]
},
{
"term": "Coder et scripter",
"description": "Créer des expériences interactives sur le web",
"tags": [
"WBLIT-8"
]
},
{
"term": "Infrastructure",
"description": "Créer des expériences interactives sur le web",
"tags": [
"WBLIT-9"
]
},
{
"term": "Partager et collaborer",
"description": "Créer et publier ensemble des ressources web",
"tags": [
"WBLIT-10"
]
},
{
"term": "Participation communautaire",
"description": "Rejoindre des communautés en ligne et comprendre leurs usages",
"tags": [
"WBLIT-11"
]
},
{
"term": "Vie privée",
"description": "Considérer les conséquences du partage de données en ligne",
"tags": [
"WBLIT-12"
]
},
{
"term": "Pratiques ouvertes",
"description": "Contribuer à garder le Web démocratique et accessible universellement",
"tags": [
"WBLIT-13"
]
}
]