Commit 15946063 authored by Kjetil Thuen's avatar Kjetil Thuen

Fixed some scrolling issues. Improved documentation

parent b8c7489b
......@@ -31,20 +31,20 @@ ListEntryInfo can be included in your project using Bower by mentioning [The Lis
To enrich a html list with the EntryInfo functionallity, call the plugin like any other jQuery plugin:
```
$("#my-list").listEntryInfo(arguments-object)
$("#my-list").listEntryInfo({parameters})
```
The arguments object is a javascript object containing several optional arguments to modify the behaviour of the plugin. They are:
The parameters object is a javascript object containing several optional parameters to modify the behaviour of the plugin. They are:
* `extendedInfoFunc`: The function to be called when a list entry has focus. The function should take a DOM id, build some html and then somehow manipulate the DOM. For convenience, a function, `defaultPopulateRevealDivFunc` that populates the revealDiv with a given string and then slides it into view is provided. The default function just puts the given id into the DOM element:
* `extendedInfoFunc`: The function to be called when a list entry has focus. The function should take a DOM id, build some html and then somehow manipulate the DOM. For convenience, a function that populates the revealDiv with a given string and then slides it into view is passed as the second argument. If you do not want to alter the DOM yourself, you need to call this function with the html snippet you want displayed. The default function just puts the given id into the DOM element:
```
function(id){defaultPopulateRevealDivFunc("<strong>" + id + "</strong>");}
function(id, displayCallbackFunc){displayCallbackFunc("<p><strong>" + id + "</strong> selected.</p>");}
```
* `selectedClass`: The class to append to the selected list element. For styling. The default value is "listEntryInfoSelected".
* `sightScopeId`: The DOM id of the target area. The element must be created by the plugin. If and element with the given id already exists, the plugin initialisation will fail silently. The default value is "listSightScope".
* `sightScopeId`: The DOM id of the scope area. The element must be created by the plugin. If an element with the given id already exists, the plugin initialisation will fail silently. The default value is "listSightScope".
* `itemInfoDivId`: The DOM id of the div holding the extended info. The element will be created if it does not already exist. If you use your own element you can place it wherever you want. If the plugin determines that it needs to create the element, it will create a DIV right after the target area. The element will be hidden and shown depending on whether a list element is focused or not. The default value is "selectedEntryItemInfo".
......
......@@ -28,7 +28,7 @@
/*
#listPeekTargetArea and #listPeakRevealArea are the default ids for
the target and info divs. If needed, you can pass other ids in the
arguments object
parameter object
*/
#listSightScope {
background-color: rgba(0,0,0,1);
......@@ -177,7 +177,7 @@
element (name), and the default function for populating a DOM element with
the computed information (displayFunc).
*/
var display_philosopher_article = function (name, displayFunc) {
var display_philosopher_article = function (name, displayCallbackFunc) {
var article;
$.getJSON("http://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exintro=1&callback=?", {titles:name}, function(data) {
......@@ -194,7 +194,7 @@
article="<p>No article found on " + name + "</p>";
}
displayFunc(article);
displayCallbackFunc(article);
});
}
......
......@@ -17,7 +17,7 @@
sightScopeId: "listSightScope",
itemInfoDivId: "selectedEntryItemInfo",
timeout: 100,
extendedInfoFunc: function(id){defaultPopulateRevealDivFunc("<strong>" + id + "</strong>");}
extendedInfoFunc: function(id){defaultPopulateRevealDivFunc("<p><strong>" + id + "</strong> selected</p>");}
}, options );
peekedList = this;
......@@ -92,9 +92,7 @@
var defaultPopulateRevealDivFunc = function (content) {
if (content !== null) {
$('#' + settings.itemInfoDivId).html(content);
$('#' + settings.itemInfoDivId).slideDown('fast', function() {
scrollListenersEnabled = true;
});
$('#' + settings.itemInfoDivId).slideDown('fast');
}
};
......@@ -117,17 +115,19 @@
var listTop = listElem.offset().top;
var scrollVal = listTop - tarTop - marginDiff;
$('body').animate({scrollTop: scrollVal}, 'fast');
$('body').animate({scrollTop: scrollVal}, 'fast', function() {
scrollInProgress = false;
scrollListenersEnabled = true;
});
settings.extendedInfoFunc(listElem.attr('id'), defaultPopulateRevealDivFunc);
scrollInProgress = false;
};
var setSelectedElement = function (element, asap) {
if (!element) {
element = peekedList.children('li:first-child').get();
}
if (element) {
var listElem = $(element).closest('li');
if (listElem.is("LI") && listElem !== focusedListElement) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment