Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed pagination buttons

  • Loading branch information...
commit 1f3928131701247c8f759fb7118bca43c8f51bcf 1 parent 3a1f8bd
@overra authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 extension/popup.js
View
12 extension/popup.js
@@ -6,7 +6,8 @@ var raw_url = 'https://raw.github.com/subtlepatterns/SubtlePatterns/master/',
target_div = document.getElementById('target'),
patterns,
page,
- selected;
+ selected,
+ pageMax;
function loadPatterns() {
@@ -21,6 +22,12 @@ function loadPatterns() {
else {
prev_btn.removeAttribute('disabled');
}
+ if (page==pageMax) {
+ next_btn.setAttribute('disabled', 'disabled');
+ }
+ else {
+ next_btn.removeAttribute('disabled');
+ }
while (patterns_div.hasChildNodes()) {
patterns_div.removeChild(patterns_div.firstChild);
@@ -39,7 +46,7 @@ function loadPatterns() {
name_div.innerText = this.getAttribute('data-name');
};
pattern.onmouseout = function() {
- name_div.innerText = selected.getAttribute('data-name')||'';
+ name_div.innerText = (selected)?selected.getAttribute('data-name'):'';
};
pattern.onclick = function() {
if (selected) {
@@ -70,5 +77,6 @@ next_btn.onclick = function() {
chrome.extension.sendMessage('getPatterns', function(p) {
patterns = p.patterns;
page = p.page;
+ pageMax = Math.floor(patterns.length / 12);
loadPatterns();
});
Please sign in to comment.
Something went wrong with that request. Please try again.