Skip to content
Snippets Groups Projects
Commit ee3eb3bb authored by Your Name's avatar Your Name
Browse files

paginaging

parent 381fbcae
Branches
No related tags found
No related merge requests found
Copyright 2012, Flavius Matis
http://flaviusmatis.github.com/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
A simple jQuery pagination plugin and 3 CSS themes.
[Read Full Documentation](http://flaviusmatis.github.com/simplePagination.js/)
\ No newline at end of file
File added
......@@ -16,7 +16,7 @@ def main():
session.execute("open Holzschnitt")
merke = []
for i in range(1,5):
for i in range(1,10):
url = session.query("declare namespace lido=\"http://www.lido-schema.org\"; for $x in (/root/object[position() =" + str(i) +" ]/bildLink/text()) return $x" ).execute()
actor = session.query("declare namespace lido=\"http://www.lido-schema.org\"; for $x in (/root/object[position() =" + str(i) +" ]/descriptiveMetadata/actor/text()) return $x" ).execute()
title = session.query("declare namespace lido=\"http://www.lido-schema.org\"; for $x in (/root/object[position() =" + str(i) +" ]/descriptiveMetadata/objectIdentificationWrap/title/text()) return $x" ).execute()
......@@ -46,7 +46,7 @@ def search():
return render_template('index.html', objects = merke, searchBool = False, text = '')
text = request.form['holzschnitte']
#suche nach Künstler:
#suche nach Kuenstler:
#query = session.query("declare namespace lido=\"http://www.lido-schema.org\"; for $x in (/root/object[descriptiveMetadata/actor[contains(text(), " + text + ")]]) return $x")
merke = []
urlQuery = session.query("declare namespace lido=\"http://www.lido-schema.org\"; for $x in (/root/object[descriptiveMetadata/actor[contains(text(),'" + text + "')]]/bildLink/text()) return $x")
......
{
"name": "simplePagination.js",
"version": "0.0.3",
"homepage": "https://github.com/flaviusmatis/simplePagination.js",
"authors": [
"Flavius Matis <flavius@fdbk.me>"
],
"description": "A simple jQuery pagination plugin with 3 CSS themes.",
"main": "jquery.simplePagination.js",
"keywords": [
"jquery",
"pagination"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
/**
* simplePagination.js v1.6
* A simple jQuery pagination plugin.
* http://flaviusmatis.github.com/simplePagination.js/
*
* Copyright 2012, Flavius Matis
* Released under the MIT license.
* http://flaviusmatis.github.com/license.html
*/
(function($){
var methods = {
init: function(options) {
var o = $.extend({
items: 1,
itemsOnPage: 1,
pages: 0,
displayedPages: 5,
edges: 2,
currentPage: 0,
useAnchors: true,
hrefTextPrefix: '#page-',
hrefTextSuffix: '',
prevText: 'Prev',
nextText: 'Next',
ellipseText: '&hellip;',
ellipsePageSet: true,
cssStyle: 'light-theme',
listStyle: '',
labelMap: [],
selectOnClick: true,
nextAtFront: false,
invertPageOrder: false,
useStartEdge : true,
useEndEdge : true,
onPageClick: function(pageNumber, event) {
// Callback triggered when a page is clicked
// Page number is given as an optional parameter
},
onInit: function() {
// Callback triggered immediately after initialization
}
}, options || {});
var self = this;
o.pages = o.pages ? o.pages : Math.ceil(o.items / o.itemsOnPage) ? Math.ceil(o.items / o.itemsOnPage) : 1;
if (o.currentPage)
o.currentPage = o.currentPage - 1;
else
o.currentPage = !o.invertPageOrder ? 0 : o.pages - 1;
o.halfDisplayed = o.displayedPages / 2;
this.each(function() {
self.addClass(o.cssStyle + ' simple-pagination').data('pagination', o);
methods._draw.call(self);
});
o.onInit();
return this;
},
selectPage: function(page) {
methods._selectPage.call(this, page - 1);
return this;
},
prevPage: function() {
var o = this.data('pagination');
if (!o.invertPageOrder) {
if (o.currentPage > 0) {
methods._selectPage.call(this, o.currentPage - 1);
}
} else {
if (o.currentPage < o.pages - 1) {
methods._selectPage.call(this, o.currentPage + 1);
}
}
return this;
},
nextPage: function() {
var o = this.data('pagination');
if (!o.invertPageOrder) {
if (o.currentPage < o.pages - 1) {
methods._selectPage.call(this, o.currentPage + 1);
}
} else {
if (o.currentPage > 0) {
methods._selectPage.call(this, o.currentPage - 1);
}
}
return this;
},
getPagesCount: function() {
return this.data('pagination').pages;
},
setPagesCount: function(count) {
this.data('pagination').pages = count;
},
getCurrentPage: function () {
return this.data('pagination').currentPage + 1;
},
destroy: function(){
this.empty();
return this;
},
drawPage: function (page) {
var o = this.data('pagination');
o.currentPage = page - 1;
this.data('pagination', o);
methods._draw.call(this);
return this;
},
redraw: function(){
methods._draw.call(this);
return this;
},
disable: function(){
var o = this.data('pagination');
o.disabled = true;
this.data('pagination', o);
methods._draw.call(this);
return this;
},
enable: function(){
var o = this.data('pagination');
o.disabled = false;
this.data('pagination', o);
methods._draw.call(this);
return this;
},
updateItems: function (newItems) {
var o = this.data('pagination');
o.items = newItems;
o.pages = methods._getPages(o);
this.data('pagination', o);
methods._draw.call(this);
},
updateItemsOnPage: function (itemsOnPage) {
var o = this.data('pagination');
o.itemsOnPage = itemsOnPage;
o.pages = methods._getPages(o);
this.data('pagination', o);
methods._selectPage.call(this, 0);
return this;
},
getItemsOnPage: function() {
return this.data('pagination').itemsOnPage;
},
_draw: function() {
var o = this.data('pagination'),
interval = methods._getInterval(o),
i,
tagName;
methods.destroy.call(this);
tagName = (typeof this.prop === 'function') ? this.prop('tagName') : this.attr('tagName');
var $panel = tagName === 'UL' ? this : $('<ul' + (o.listStyle ? ' class="' + o.listStyle + '"' : '') + '></ul>').appendTo(this);
// Generate Prev link
if (o.prevText) {
methods._appendItem.call(this, !o.invertPageOrder ? o.currentPage - 1 : o.currentPage + 1, {text: o.prevText, classes: 'prev'});
}
// Generate Next link (if option set for at front)
if (o.nextText && o.nextAtFront) {
methods._appendItem.call(this, !o.invertPageOrder ? o.currentPage + 1 : o.currentPage - 1, {text: o.nextText, classes: 'next'});
}
// Generate start edges
if (!o.invertPageOrder) {
if (interval.start > 0 && o.edges > 0) {
if(o.useStartEdge) {
var end = Math.min(o.edges, interval.start);
for (i = 0; i < end; i++) {
methods._appendItem.call(this, i);
}
}
if (o.edges < interval.start && (interval.start - o.edges != 1)) {
$panel.append('<li class="disabled"><span class="ellipse">' + o.ellipseText + '</span></li>');
} else if (interval.start - o.edges == 1) {
methods._appendItem.call(this, o.edges);
}
}
} else {
if (interval.end < o.pages && o.edges > 0) {
if(o.useStartEdge) {
var begin = Math.max(o.pages - o.edges, interval.end);
for (i = o.pages - 1; i >= begin; i--) {
methods._appendItem.call(this, i);
}
}
if (o.pages - o.edges > interval.end && (o.pages - o.edges - interval.end != 1)) {
$panel.append('<li class="disabled"><span class="ellipse">' + o.ellipseText + '</span></li>');
} else if (o.pages - o.edges - interval.end == 1) {
methods._appendItem.call(this, interval.end);
}
}
}
// Generate interval links
if (!o.invertPageOrder) {
for (i = interval.start; i < interval.end; i++) {
methods._appendItem.call(this, i);
}
} else {
for (i = interval.end - 1; i >= interval.start; i--) {
methods._appendItem.call(this, i);
}
}
// Generate end edges
if (!o.invertPageOrder) {
if (interval.end < o.pages && o.edges > 0) {
if (o.pages - o.edges > interval.end && (o.pages - o.edges - interval.end != 1)) {
$panel.append('<li class="disabled"><span class="ellipse">' + o.ellipseText + '</span></li>');
} else if (o.pages - o.edges - interval.end == 1) {
methods._appendItem.call(this, interval.end);
}
if(o.useEndEdge) {
var begin = Math.max(o.pages - o.edges, interval.end);
for (i = begin; i < o.pages; i++) {
methods._appendItem.call(this, i);
}
}
}
} else {
if (interval.start > 0 && o.edges > 0) {
if (o.edges < interval.start && (interval.start - o.edges != 1)) {
$panel.append('<li class="disabled"><span class="ellipse">' + o.ellipseText + '</span></li>');
} else if (interval.start - o.edges == 1) {
methods._appendItem.call(this, o.edges);
}
if(o.useEndEdge) {
var end = Math.min(o.edges, interval.start);
for (i = end - 1; i >= 0; i--) {
methods._appendItem.call(this, i);
}
}
}
}
// Generate Next link (unless option is set for at front)
if (o.nextText && !o.nextAtFront) {
methods._appendItem.call(this, !o.invertPageOrder ? o.currentPage + 1 : o.currentPage - 1, {text: o.nextText, classes: 'next'});
}
if (o.ellipsePageSet && !o.disabled) {
methods._ellipseClick.call(this, $panel);
}
},
_getPages: function(o) {
var pages = Math.ceil(o.items / o.itemsOnPage);
return pages || 1;
},
_getInterval: function(o) {
return {
start: Math.ceil(o.currentPage > o.halfDisplayed ? Math.max(Math.min(o.currentPage - o.halfDisplayed, (o.pages - o.displayedPages)), 0) : 0),
end: Math.ceil(o.currentPage > o.halfDisplayed ? Math.min(o.currentPage + o.halfDisplayed, o.pages) : Math.min(o.displayedPages, o.pages))
};
},
_appendItem: function(pageIndex, opts) {
var self = this, options, $link, o = self.data('pagination'), $linkWrapper = $('<li></li>'), $ul = self.find('ul');
pageIndex = pageIndex < 0 ? 0 : (pageIndex < o.pages ? pageIndex : o.pages - 1);
options = {
text: pageIndex + 1,
classes: ''
};
if (o.labelMap.length && o.labelMap[pageIndex]) {
options.text = o.labelMap[pageIndex];
}
options = $.extend(options, opts || {});
if (pageIndex == o.currentPage || o.disabled) {
if (o.disabled || options.classes === 'prev' || options.classes === 'next') {
$linkWrapper.addClass('disabled');
} else {
$linkWrapper.addClass('active');
}
$link = $('<span class="current">' + (options.text) + '</span>');
} else {
if (o.useAnchors) {
$link = $('<a href="' + o.hrefTextPrefix + (pageIndex + 1) + o.hrefTextSuffix + '" class="page-link">' + (options.text) + '</a>');
} else {
$link = $('<span >' + (options.text) + '</span>');
}
$link.click(function(event){
return methods._selectPage.call(self, pageIndex, event);
});
}
if (options.classes) {
$link.addClass(options.classes);
}
$linkWrapper.append($link);
if ($ul.length) {
$ul.append($linkWrapper);
} else {
self.append($linkWrapper);
}
},
_selectPage: function(pageIndex, event) {
var o = this.data('pagination');
o.currentPage = pageIndex;
if (o.selectOnClick) {
methods._draw.call(this);
}
return o.onPageClick(pageIndex + 1, event);
},
_ellipseClick: function($panel) {
var self = this,
o = this.data('pagination'),
$ellip = $panel.find('.ellipse');
$ellip.addClass('clickable').parent().removeClass('disabled');
$ellip.click(function(event) {
if (!o.disable) {
var $this = $(this),
val = (parseInt($this.parent().prev().text(), 10) || 0) + 1;
$this
.html('<input type="number" min="1" max="' + o.pages + '" step="1" value="' + val + '">')
.find('input')
.focus()
.click(function(event) {
// prevent input number arrows from bubbling a click event on $ellip
event.stopPropagation();
})
.keyup(function(event) {
var val = $(this).val();
if (event.which === 13 && val !== '') {
// enter to accept
if ((val>0)&&(val<=o.pages))
methods._selectPage.call(self, val - 1);
} else if (event.which === 27) {
// escape to cancel
$ellip.empty().html(o.ellipseText);
}
})
.bind('blur', function(event) {
var val = $(this).val();
if (val !== '') {
methods._selectPage.call(self, val - 1);
}
$ellip.empty().html(o.ellipseText);
return false;
});
}
return false;
});
}
};
$.fn.pagination = function(method) {
// Method calling logic
if (methods[method] && method.charAt(0) != '_') {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist on jQuery.pagination');
}
};
})(jQuery);
/**
* CSS themes for simplePagination.js
* Author: Flavius Matis - http://flaviusmatis.github.com/
* URL: https://github.com/flaviusmatis/simplePagination.js
*/
ul.simple-pagination {
list-style: none;
}
.simple-pagination {
display: block;
overflow: hidden;
padding: 0 5px 5px 0;
margin: 0;
}
.simple-pagination ul {
list-style: none;
padding: 0;
margin: 0;
}
.simple-pagination li {
list-style: none;
padding: 0;
margin: 0;
float: left;
}
span.ellipse.clickable {
cursor: pointer;
}
.ellipse input {
width: 3em;
}
/*------------------------------------*\
Compact Theme Styles
\*------------------------------------*/
.compact-theme span {
cursor:pointer;
}
.compact-theme a, .compact-theme span {
float: left;
color: #333;
font-size:14px;
line-height:24px;
font-weight: normal;
text-align: center;
border: 1px solid #AAA;
border-left: none;
min-width: 14px;
padding: 0 7px;
box-shadow: 2px 2px 2px rgba(0,0,0,0.2);
background: #efefef; /* Old browsers */
background: -moz-linear-gradient(top, #ffffff 0%, #efefef 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#efefef)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#efefef 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#efefef 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#efefef 100%); /* IE10+ */
background: linear-gradient(top, #ffffff 0%,#efefef 100%); /* W3C */
}
.compact-theme a:hover, .compact-theme li:not(.disabled):not(.active) span:hover {
text-decoration: none;
background: #efefef; /* Old browsers */
background: -moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#efefef), color-stop(100%,#bbbbbb)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #efefef 0%,#bbbbbb 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #efefef 0%,#bbbbbb 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #efefef 0%,#bbbbbb 100%); /* IE10+ */
background: linear-gradient(top, #efefef 0%,#bbbbbb 100%); /* W3C */
}
.compact-theme li:first-child a, .compact-theme li:first-child span {
border-left: 1px solid #AAA;
border-radius: 3px 0 0 3px;
}
.compact-theme li:last-child a, .compact-theme li:last-child span {
border-radius: 0 3px 3px 0;
}
.compact-theme .current {
background: #bbbbbb; /* Old browsers */
background: -moz-linear-gradient(top, #bbbbbb 0%, #efefef 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#bbbbbb), color-stop(100%,#efefef)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #bbbbbb 0%,#efefef 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #bbbbbb 0%,#efefef 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #bbbbbb 0%,#efefef 100%); /* IE10+ */
background: linear-gradient(top, #bbbbbb 0%,#efefef 100%); /* W3C */
cursor: default;
}
.compact-theme .ellipse {
background: #EAEAEA;
padding: 0 10px;
cursor: default;
}
/*------------------------------------*\
Light Theme Styles
\*------------------------------------*/
.light-theme span {
cursor:pointer;
}
.light-theme a, .light-theme span {
float: left;
color: #666;
font-size:14px;
line-height:24px;
font-weight: normal;
text-align: center;
border: 1px solid #BBB;
min-width: 14px;
padding: 0 7px;
margin: 0 5px 0 0;
border-radius: 3px;
box-shadow: 0 1px 2px rgba(0,0,0,0.2);
background: #efefef; /* Old browsers */
background: -moz-linear-gradient(top, #ffffff 0%, #efefef 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#efefef)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#efefef 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#efefef 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#efefef 100%); /* IE10+ */
background: linear-gradient(top, #ffffff 0%,#efefef 100%); /* W3C */
}
.light-theme a:hover, .light-theme li:not(.disabled):not(.active) span:hover {
text-decoration: none;
background: #FCFCFC;
}
.light-theme .current {
background: #666;
color: #FFF;
border-color: #444;
box-shadow: 0 1px 0 rgba(255,255,255,1), 0 0 2px rgba(0, 0, 0, 0.3) inset;
cursor: default;
}
.light-theme .ellipse {
background: none;
border: none;
border-radius: 0;
box-shadow: none;
font-weight: bold;
cursor: default;
}
/*------------------------------------*\
Dark Theme Styles
\*------------------------------------*/
.dark-theme span {
cursor:pointer;
}
.dark-theme a, .dark-theme span {
float: left;
color: #CCC;
font-size:14px;
line-height:24px;
font-weight: normal;
text-align: center;
border: 1px solid #222;
min-width: 14px;
padding: 0 7px;
margin: 0 5px 0 0;
border-radius: 3px;
box-shadow: 0 1px 2px rgba(0,0,0,0.2);
background: #555; /* Old browsers */
background: -moz-linear-gradient(top, #555 0%, #333 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#555), color-stop(100%,#333)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #555 0%,#333 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #555 0%,#333 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #555 0%,#333 100%); /* IE10+ */
background: linear-gradient(top, #555 0%,#333 100%); /* W3C */
}
.dark-theme a:hover, .dark-theme li:not(.disabled):not(.active) span:hover {
text-decoration: none;
background: #444;
}
.dark-theme .current {
background: #222;
color: #FFF;
border-color: #000;
box-shadow: 0 1px 0 rgba(255,255,255,0.2), 0 0 1px 1px rgba(0, 0, 0, 0.1) inset;
cursor: default;
}
.dark-theme .ellipse {
background: none;
border: none;
border-radius: 0;
box-shadow: none;
font-weight: bold;
cursor: default;
}
......@@ -222,6 +222,220 @@ figure:hover figcaption {
}
.pagination a {
color: black;
float: left;
padding: 8px 16px;
text-decoration: none;
transition: background-color .3s;
}
.pagination a.active {
background-color: #4CAF50;
color: white;
}
.pagination a:hover:not(.active) {background-color: #ddd;}
ul.simple-pagination {
list-style: none;
}
.simple-pagination {
display: block;
overflow: hidden;
padding: 0 5px 5px 0;
margin: 0;
}
.simple-pagination ul {
list-style: none;
padding: 0;
margin: 0;
}
.simple-pagination li {
list-style: none;
padding: 0;
margin: 0;
float: left;
}
span.ellipse.clickable {
cursor: pointer;
}
.ellipse input {
width: 3em;
}
/*------------------------------------*\
Compact Theme Styles
\*------------------------------------*/
.compact-theme span {
cursor:pointer;
}
.compact-theme a, .compact-theme span {
float: left;
color: #333;
font-size:14px;
line-height:24px;
font-weight: normal;
text-align: center;
border: 1px solid #AAA;
border-left: none;
min-width: 14px;
padding: 0 7px;
box-shadow: 2px 2px 2px rgba(0,0,0,0.2);
background: #efefef; /* Old browsers */
background: -moz-linear-gradient(top, #ffffff 0%, #efefef 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#efefef)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#efefef 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#efefef 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#efefef 100%); /* IE10+ */
background: linear-gradient(top, #ffffff 0%,#efefef 100%); /* W3C */
}
.compact-theme a:hover, .compact-theme li:not(.disabled):not(.active) span:hover {
text-decoration: none;
background: #efefef; /* Old browsers */
background: -moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#efefef), color-stop(100%,#bbbbbb)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #efefef 0%,#bbbbbb 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #efefef 0%,#bbbbbb 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #efefef 0%,#bbbbbb 100%); /* IE10+ */
background: linear-gradient(top, #efefef 0%,#bbbbbb 100%); /* W3C */
}
.compact-theme li:first-child a, .compact-theme li:first-child span {
border-left: 1px solid #AAA;
border-radius: 3px 0 0 3px;
}
.compact-theme li:last-child a, .compact-theme li:last-child span {
border-radius: 0 3px 3px 0;
}
.compact-theme .current {
background: #bbbbbb; /* Old browsers */
background: -moz-linear-gradient(top, #bbbbbb 0%, #efefef 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#bbbbbb), color-stop(100%,#efefef)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #bbbbbb 0%,#efefef 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #bbbbbb 0%,#efefef 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #bbbbbb 0%,#efefef 100%); /* IE10+ */
background: linear-gradient(top, #bbbbbb 0%,#efefef 100%); /* W3C */
cursor: default;
}
.compact-theme .ellipse {
background: #EAEAEA;
padding: 0 10px;
cursor: default;
}
/*------------------------------------*\
Light Theme Styles
\*------------------------------------*/
.light-theme span {
cursor:pointer;
}
.light-theme a, .light-theme span {
float: left;
color: #666;
font-size:14px;
line-height:24px;
font-weight: normal;
text-align: center;
border: 1px solid #BBB;
min-width: 14px;
padding: 0 7px;
margin: 0 5px 0 0;
border-radius: 3px;
box-shadow: 0 1px 2px rgba(0,0,0,0.2);
background: #efefef; /* Old browsers */
background: -moz-linear-gradient(top, #ffffff 0%, #efefef 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#efefef)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#efefef 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#efefef 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#efefef 100%); /* IE10+ */
background: linear-gradient(top, #ffffff 0%,#efefef 100%); /* W3C */
}
.light-theme a:hover, .light-theme li:not(.disabled):not(.active) span:hover {
text-decoration: none;
background: #FCFCFC;
}
.light-theme .current {
background: #666;
color: #FFF;
border-color: #444;
box-shadow: 0 1px 0 rgba(255,255,255,1), 0 0 2px rgba(0, 0, 0, 0.3) inset;
cursor: default;
}
.light-theme .ellipse {
background: none;
border: none;
border-radius: 0;
box-shadow: none;
font-weight: bold;
cursor: default;
}
/*------------------------------------*\
Dark Theme Styles
\*------------------------------------*/
.dark-theme span {
cursor:pointer;
}
.dark-theme a, .dark-theme span {
float: left;
color: #CCC;
font-size:14px;
line-height:24px;
font-weight: normal;
text-align: center;
border: 1px solid #222;
min-width: 14px;
padding: 0 7px;
margin: 0 5px 0 0;
border-radius: 3px;
box-shadow: 0 1px 2px rgba(0,0,0,0.2);
background: #555; /* Old browsers */
background: -moz-linear-gradient(top, #555 0%, #333 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#555), color-stop(100%,#333)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #555 0%,#333 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #555 0%,#333 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #555 0%,#333 100%); /* IE10+ */
background: linear-gradient(top, #555 0%,#333 100%); /* W3C */
}
.dark-theme a:hover, .dark-theme li:not(.disabled):not(.active) span:hover {
text-decoration: none;
background: #444;
}
.dark-theme .current {
background: #222;
color: #FFF;
border-color: #000;
box-shadow: 0 1px 0 rgba(255,255,255,0.2), 0 0 1px 1px rgba(0, 0, 0, 0.1) inset;
cursor: default;
}
.dark-theme .ellipse {
background: none;
border: none;
border-radius: 0;
box-shadow: none;
font-weight: bold;
cursor: default;
}
@media only screen and (max-width: 800px) {
body {
width: 100%;
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Spec Runner</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.3.1/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.3.1/jasmine.css">
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine-html.js"></script>
<script type="text/javascript" src="lib/jquery.min.js"></script>
<!-- include source files here... -->
<script type="text/javascript" src="../jquery.simplePagination.js"></script>
<script type="text/javascript" src="spec/SpecHelper.js"></script>
<script type="text/javascript" src="spec/SimplePaginationSpec.js"></script>
<script type="text/javascript">
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
})();
</script>
</head>
<body>
</body>
</html>
Copyright (c) 2008-2011 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This diff is collapsed.
body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
#HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
#HTMLReporter a { text-decoration: none; }
#HTMLReporter a:hover { text-decoration: underline; }
#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; }
#HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; }
#HTMLReporter #jasmine_content { position: fixed; right: 100%; }
#HTMLReporter .version { color: #aaaaaa; }
#HTMLReporter .banner { margin-top: 14px; }
#HTMLReporter .duration { color: #aaaaaa; float: right; }
#HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; }
#HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
#HTMLReporter .symbolSummary li.passed { font-size: 14px; }
#HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; }
#HTMLReporter .symbolSummary li.failed { line-height: 9px; }
#HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
#HTMLReporter .symbolSummary li.skipped { font-size: 14px; }
#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
#HTMLReporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
#HTMLReporter .runningAlert { background-color: #666666; }
#HTMLReporter .skippedAlert { background-color: #aaaaaa; }
#HTMLReporter .skippedAlert:first-child { background-color: #333333; }
#HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; }
#HTMLReporter .passingAlert { background-color: #a6b779; }
#HTMLReporter .passingAlert:first-child { background-color: #5e7d00; }
#HTMLReporter .failingAlert { background-color: #cf867e; }
#HTMLReporter .failingAlert:first-child { background-color: #b03911; }
#HTMLReporter .results { margin-top: 14px; }
#HTMLReporter #details { display: none; }
#HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; }
#HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
#HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
#HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
#HTMLReporter.showDetails .summary { display: none; }
#HTMLReporter.showDetails #details { display: block; }
#HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
#HTMLReporter .summary { margin-top: 14px; }
#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; }
#HTMLReporter .summary .specSummary.passed a { color: #5e7d00; }
#HTMLReporter .summary .specSummary.failed a { color: #b03911; }
#HTMLReporter .description + .suite { margin-top: 0; }
#HTMLReporter .suite { margin-top: 14px; }
#HTMLReporter .suite a { color: #333333; }
#HTMLReporter #details .specDetail { margin-bottom: 28px; }
#HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; }
#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
#HTMLReporter .resultMessage span.result { display: block; }
#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
#TrivialReporter .runner.running { background-color: yellow; }
#TrivialReporter .options { text-align: right; font-size: .8em; }
#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
#TrivialReporter .suite .suite { margin: 5px; }
#TrivialReporter .suite.passed { background-color: #dfd; }
#TrivialReporter .suite.failed { background-color: #fdd; }
#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
#TrivialReporter .spec.skipped { background-color: #bbb; }
#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
#TrivialReporter .passed { background-color: #cfc; display: none; }
#TrivialReporter .failed { background-color: #fbb; }
#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
#TrivialReporter .resultMessage .mismatch { color: black; }
#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
This diff is collapsed.
This diff is collapsed.
describe('SimplePagination', function() {
it('adds pagination elements to an empty container', function() {
expect(pager).toBePaged();
})
describe('#destroy', function() {
it('visually destroys the pager', function() {
pager.pagination('destroy');
expect(pager).not.toBePaged();
})
})
describe('#redraw', function() {
it('recreates a destroyed pager', function() {
pager.pagination('destroy');
pager.pagination('redraw');
expect(pager).toBePaged();
})
})
describe('#disable', function() {
it('disables the pager', function() {
pager.pagination('disable');
expect(pager).toBeDisabled();
})
})
describe('#enable', function() {
it('enables a disabled pager', function() {
pager.pagination('disable');
pager.pagination('enable');
expect(pager).not.toBeDisabled();
})
})
describe('#getPagesCount', function() {
it('return the number of pages', function() {
expect(pager.pagination('getPagesCount')).toBe(pageCount);
})
})
describe('#selectPage', function() {
it('changes to the specified page', function() {
var expectedPage = pageCount;
pager.pagination('selectPage', expectedPage);
expect(pager).toBeOnPage(expectedPage);
})
})
describe('#getCurrentPage', function() {
it('returns the current page number', function() {
expect(pager.pagination('getCurrentPage')).toBe(1);
var expectedPage = pageCount;
pager.pagination('selectPage', expectedPage);
expect(pager.pagination('getCurrentPage')).toBe(expectedPage);
})
})
describe('#prevPage', function() {
it('pages to the previous page', function() {
pager.pagination('selectPage', pageCount);
var expectedPage = pager.pagination('getCurrentPage') - 1;
pager.pagination('prevPage');
expect(pager).toBeOnPage(expectedPage);
})
it('does not go to page 0', function() {
var expectedPage = pager.pagination('getCurrentPage');
pager.pagination('prevPage');
expect(pager).toBeOnPage(expectedPage);
})
})
describe('#nextPage', function() {
it('does not page past the last', function() {
var expectedPage = pageCount;
pager.pagination('selectPage', pageCount);
pager.pagination('nextPage');
expect(pager).toBeOnPage(expectedPage);
})
it('pages to the next page', function() {
var expectedPage = pager.pagination('getCurrentPage') + 1;
pager.pagination('nextPage');
expect(pager).toBeOnPage(expectedPage);
})
})
describe('#updateItems', function() {
it('updates the number of pages', function() {
var updatedItems = Math.round(items / 2);
var expectedPageCount = (updatedItems/itemsOnPage);
pager.pagination('updateItems', updatedItems);
expect(pager.pagination('getPagesCount')).toBe(expectedPageCount);
})
})
describe('#updateItemsOnPage', function() {
it('updates the number of pages', function() {
var updatedItemsOnPage = Math.round(itemsOnPage / 2);
var expectedPageCount = (items/updatedItemsOnPage);
pager.pagination('updateItemsOnPage', updatedItemsOnPage);
expect(pager.pagination('getPagesCount')).toBe(expectedPageCount);
})
})
describe('invertPageOrder Option', function() {
var invertedPager;
beforeEach(function() {
$('<div id="inverted_pager" class="pager"></div>').appendTo('body').pagination({
items: items,
itemsOnPage: itemsOnPage,
invertPageOrder: true
});
invertedPager = $('#inverted_pager');
})
it('moves the highest page number to the front of the list', function() {
var expectedPage = pageCount;
expect(invertedPager).toBeOnPage(expectedPage);
})
describe('#nextPage', function() {
it('pages to the next page', function() {
invertedPager.pagination('selectPage', pageCount );
var expectedPage = invertedPager.pagination('getCurrentPage') - 1;
invertedPager.pagination('nextPage');
expect(invertedPager).toBeOnPage(expectedPage);
})
})
describe('#prevPage', function() {
it('pages to the previous page', function() {
invertedPager.pagination('selectPage', 1);
var expectedPage = invertedPager.pagination('getCurrentPage') + 1;
invertedPager.pagination('prevPage');
expect(invertedPager).toBeOnPage(expectedPage);
})
})
})
describe('use Edge Options', function() {
var edgePager;
it('use startEdge or endEdge by option useStartEdge, useEndEdge', function() {
})
describe('#default useStartEdge & useEndEdge', function() {
beforeEach(function() {
$('<div id="edge_pager" class="pager"></div>').appendTo('body').pagination({
items: items,
itemsOnPage: itemsOnPage
})
edgePager = $('#edge_pager');
})
it('pages should same text when select 1 page', function() {
edgePager.pagination('selectPage', 1);
expect(edgePager).toBeSameTextValues(['Prev', '1', '2', '3', '4', '5', '\u2026', '9', '10', 'Next']);
})
it('pages should same text when select last page', function() {
edgePager.pagination('selectPage', pageCount);
expect(edgePager).toBeSameTextValues(['Prev', '1', '2', '\u2026', '6', '7', '8', '9', '10', 'Next']);
})
})
describe('#not useStartEdge & not useEndEdge', function() {
beforeEach(function() {
$('<div id="edge_pager" class="pager"></div>').appendTo('body').pagination({
items: items,
itemsOnPage: itemsOnPage,
useStartEdge:false,
useEndEdge:false
})
edgePager = $('#edge_pager');
})
it('pages should same text when select 1 page', function() {
edgePager.pagination('selectPage', 1);
expect(edgePager).toBeSameTextValues(['Prev', '1', '2', '3', '4', '5', '\u2026', 'Next']);
})
it('pages should same text when select last page', function() {
edgePager.pagination('selectPage', pageCount);
expect(edgePager).toBeSameTextValues(['Prev', '\u2026', '6', '7', '8', '9', '10', 'Next']);
})
})
describe('#invertPageOrder with default useStartEdge & useEndEdge', function() {
beforeEach(function() {
$('<div id="edge_pager" class="pager"></div>').appendTo('body').pagination({
items: items,
itemsOnPage: itemsOnPage,
invertPageOrder:true
})
edgePager = $('#edge_pager');
})
it('pages should same text when select 1 page', function() {
edgePager.pagination('selectPage', 1);
expect(edgePager).toBeSameTextValues(['Prev', '10', '9', '\u2026', '5', '4', '3', '2', '1', 'Next']);
})
it('pages should same text when select last page', function() {
edgePager.pagination('selectPage', pageCount);
expect(edgePager).toBeSameTextValues(['Prev', '10', '9', '8', '7', '6', '\u2026', '2', '1', 'Next']);
})
})
describe('#invertPageOrder with not useStartEdge & not useEndEdge', function() {
beforeEach(function() {
$('<div id="edge_pager" class="pager"></div>').appendTo('body').pagination({
items: items,
itemsOnPage: itemsOnPage,
useStartEdge:false,
useEndEdge:false,
invertPageOrder:true
})
edgePager = $('#edge_pager');
})
it('pages should same text when select 1 page', function() {
edgePager.pagination('selectPage', 1);
expect(edgePager).toBeSameTextValues(['Prev', '\u2026', '5', '4', '3', '2', '1', 'Next']);
})
it('pages should same text when select last page', function() {
edgePager.pagination('selectPage', pageCount);
expect(edgePager).toBeSameTextValues(['Prev', '10', '9', '8', '7', '6', '\u2026', 'Next']);
})
})
})
});
var pager;
var items = 100;
var itemsOnPage = 10;
var pageCount = items/itemsOnPage;
beforeEach(function() {
$('<div id="pager" class="pager"></div>').appendTo('body').pagination({
items: items,
itemsOnPage: itemsOnPage
});
pager = $('#pager');
this.addMatchers({
toBePaged: function() {
return ( this.actual.hasClass('simple-pagination') &&
this.actual.find('li').length > 0 );
},
toBeOnPage: function(expected_page) {
actual_page = this.actual.find('li.active span').not('.prev').not('.next').html();
return actual_page == expected_page;
},
toBeDisabled: function() {
return this.actual.find('li').length == this.actual.find('li.disabled').length;
},
toBeSameTextValues:function(expected_pages){
var pages = this.actual.find('li >').map(function(){ return $(this).text()}).get();
return expected_pages.join(',') === pages.join(',');
}
});
});
afterEach(function () {
$('.pager').remove();
});
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment