Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing auto rendering functionality #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletions dist/js/sth-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
function SthOverlay() {

var _$overlay = null;
var FADE_ANIMATION_TIME = 500;

/**
* Constructor.
Expand Down Expand Up @@ -40,20 +41,17 @@
* Shows the overlay.
*/
function show() {
_$overlay.fadeIn(500);
_$overlay.fadeIn(FADE_ANIMATION_TIME);
}

/**
* Hides the overlay.
*/
function hide() {
_$overlay.fadeOut(500);
_$overlay.fadeOut(FADE_ANIMATION_TIME);
}

return {
show: show,
hide: hide
};
return { show: show, hide: hide };
}

window.SthOverlay = window.SthOverlay || SthOverlay;
Expand Down Expand Up @@ -185,15 +183,11 @@
/**
* Add an item.
*/
function _addItem(item, autoRender) {
autoRender = autoRender || true;

function _addItem(item) {
var text = item.text;
var $listItem = $('<div class="sth-select-item">' + text + '</div>');
$listItem.data('item', item);

if (autoRender) _$content.append($listItem);

_$content.append($listItem);
return $listItem;
}

Expand All @@ -203,14 +197,13 @@
function _renderList(caseSensitive) {
_clear();

var rerenderOnEachItem = false;
var $listItems = $([]);
var textFilter = _formatText(caseSensitive, _$filter.val());

_items.forEach(function (item) {
var text = _formatText(caseSensitive, item.text);
if (text.indexOf(textFilter) != -1) {
var $listItem = _addItem(item, rerenderOnEachItem);
if (~text.indexOf(textFilter)) {
var $listItem = _addItem(item);
$listItems = $listItems.add($listItem);
}
});
Expand Down Expand Up @@ -263,11 +256,7 @@
/**
* Public available methods.
*/
return {
show: show,
hide: hide,
onSelect: onSelect
};
return { show: show, hide: hide, onSelect: onSelect };
}

window.SthSelect = window.SthSelect || {};
Expand Down
10 changes: 4 additions & 6 deletions src/js/_overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
function SthOverlay(){

var _$overlay = null;
const FADE_ANIMATION_TIME = 500;

/**
* Constructor.
Expand Down Expand Up @@ -39,20 +40,17 @@
* Shows the overlay.
*/
function show(){
_$overlay.fadeIn(500);
_$overlay.fadeIn(FADE_ANIMATION_TIME);
}

/**
* Hides the overlay.
*/
function hide(){
_$overlay.fadeOut(500);
_$overlay.fadeOut(FADE_ANIMATION_TIME);
}

return {
show: show,
hide: hide
};
return { show, hide };
}

window.SthOverlay = window.SthOverlay || SthOverlay;
Expand Down
20 changes: 5 additions & 15 deletions src/js/_popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,11 @@
/**
* Add an item.
*/
function _addItem(item, autoRender){
autoRender = autoRender || true;

function _addItem(item){
let text = item.text;
let $listItem = $('<div class="sth-select-item">' + text + '</div>');
$listItem.data('item', item);

if( autoRender )
_$content.append( $listItem );

_$content.append($listItem);
return $listItem;
}

Expand All @@ -154,14 +149,13 @@
function _renderList(caseSensitive){
_clear();

let rerenderOnEachItem = false;
let $listItems = $([]);
const textFilter = _formatText(caseSensitive, _$filter.val())

_items.forEach( item => {
const text = _formatText(caseSensitive, item.text)
if(text.indexOf(textFilter) != -1){
let $listItem = _addItem(item, rerenderOnEachItem);
if(~text.indexOf(textFilter)){
let $listItem = _addItem(item);
$listItems = $listItems.add( $listItem );
}
});
Expand Down Expand Up @@ -214,11 +208,7 @@
/**
* Public available methods.
*/
return {
show: show,
hide: hide,
onSelect: onSelect
};
return { show, hide, onSelect };
}

window.SthSelect = window.SthSelect || {};
Expand Down