mirror of
https://github.com/google/pebble.git
synced 2025-06-04 09:13:12 +00:00
Import the pebble dev site into devsite/
This commit is contained in:
parent
3b92768480
commit
527858cf4c
1359 changed files with 265431 additions and 0 deletions
76
devsite/source/assets/js/examples.js
Normal file
76
devsite/source/assets/js/examples.js
Normal file
|
@ -0,0 +1,76 @@
|
|||
/**
|
||||
* Copyright 2025 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var exampleFilters = {};
|
||||
|
||||
$('.js-examples-tag').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var $tag = $(this);
|
||||
var $filters = $tag.parents('.examples__filters');
|
||||
|
||||
if ($tag.hasClass('js-selected-tag')) {
|
||||
$tag.removeClass('js-selected-tag');
|
||||
$tag.removeClass('selected');
|
||||
$filters.removeClass('examples__filters--selected');
|
||||
|
||||
exampleFilters[$filters.data('filter-type')] = null;
|
||||
updateExamples();
|
||||
}
|
||||
else {
|
||||
var $selectedTag = $filters.find('.js-selected-tag');
|
||||
$selectedTag.removeClass('js-selected-tag');
|
||||
$selectedTag.removeClass('selected');
|
||||
|
||||
$tag.addClass('js-selected-tag');
|
||||
$tag.addClass('selected');
|
||||
$filters.addClass('examples__filters--selected');
|
||||
|
||||
exampleFilters[$filters.data('filter-type')] = $tag.text();
|
||||
updateExamples();
|
||||
}
|
||||
});
|
||||
|
||||
function updateExamples() {
|
||||
$('.js-example').each(function (index, elem) {
|
||||
var $example = $(elem);
|
||||
var tags = $example.data('tags').split('|');
|
||||
var languages = $example.data('languages').split('|');
|
||||
var hardwarePlatforms = $example.data('hardware-platforms').split('|');
|
||||
|
||||
if (exampleFilters['tags'] && tags.indexOf(exampleFilters['tags']) === -1) {
|
||||
$example.hide();
|
||||
return;
|
||||
}
|
||||
if (exampleFilters['languages'] && languages.indexOf(exampleFilters['languages']) === -1) {
|
||||
$example.hide();
|
||||
return;
|
||||
}
|
||||
if (exampleFilters['hardware-platforms'] && hardwarePlatforms.indexOf(exampleFilters['hardware-platforms']) === -1) {
|
||||
$example.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
$example.show();
|
||||
});
|
||||
|
||||
if ($('.js-example:visible').length > 0) {
|
||||
$('.js-no-examples').hide();
|
||||
}
|
||||
else {
|
||||
$('.js-no-examples').show();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue