# HG changeset patch
# User robcast
# Date 1331137650 -3600
# Node ID 7c401c168a9520b357860e51560c9cf4a0c9a8ff
# Parent ff19b9e936d30e11f033ca801a76c03f2b153932# Parent 01ea28b6fe11cfb21d9cbc76b7f66e52569d7f50
Merge with 01ea28b6fe11cfb21d9cbc76b7f66e52569d7f50
diff -r ff19b9e936d3 -r 7c401c168a95 webapp/src/main/webapp/jquery/digilib.html
--- a/webapp/src/main/webapp/jquery/digilib.html Wed Mar 07 17:25:52 2012 +0100
+++ b/webapp/src/main/webapp/jquery/digilib.html Wed Mar 07 17:27:30 2012 +0100
@@ -17,7 +17,7 @@
-
+
diff -r ff19b9e936d3 -r 7c401c168a95 webapp/src/main/webapp/jquery/jquery.digilib.sliders.js
--- a/webapp/src/main/webapp/jquery/jquery.digilib.sliders.js Wed Mar 07 17:25:52 2012 +0100
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.sliders.js Wed Mar 07 17:27:30 2012 +0100
@@ -85,9 +85,6 @@
sliderRotate : function (data) {
var $elem = data.$elem;
var $panel = fn.setupPanel(data);
- if ($panel == null) {
- return;
- };
var opts = { 'start' : parseFloat(data.settings.rot) };
var $slider = fn.setupSlider(data, 'rot', opts);
var ok = function(d) {
@@ -105,9 +102,6 @@
sliderBrightness : function (data) {
var $elem = data.$elem;
var $panel = fn.setupPanel(data);
- if ($panel == null) {
- return;
- };
var opts = { 'start' : parseFloat(data.settings.brgt) };
var $slider = fn.setupSlider(data, 'brgt', opts);
var ok = function(d) {
@@ -115,7 +109,6 @@
digilib.actions.brightness(d, brgt);
};
$panel.data['ok'] = ok;
- $panel.fadeIn();
$panel.prepend($slider);
fn.centerOnScreen(data, $panel);
$slider.slider('show');
@@ -125,9 +118,6 @@
sliderContrast : function (data) {
var $elem = data.$elem;
var $panel = fn.setupPanel(data);
- if ($panel == null) {
- return;
- };
var opts = { 'start' : parseFloat(data.settings.cont) };
var $slider = fn.setupSlider(data, 'cont', opts);
var ok = function(d) {
@@ -142,42 +132,6 @@
}
};
- var init_ = function (options) {
- // make a slider from each element
- return this.each(function() {
- var $this = $(this);
- // var settings = data.settings;
- var settings = $.extend( defaults, options);
- console.debug('new slider: ', $this, ' settings:', settings);
- $this.data('digilib', digilibdata);
- var data = $this.data('settings');
- if (!data) {
- settings.cssclass = digilibdata.cssPrefix+'slider';
- $this.data('settings', settings);
- $this.addClass(settings.cssclass);
- var $handle = $('
');
- var $label = $(''
- +settings.label+': '+settings.start+'
');
- var $min = $(''+settings.min+'
');
- var $max = $(''+settings.max+'
');
- $this.append($handle);
- $this.append($label);
- $this.append($min);
- $this.append($max);
- $.extend(settings, {
- '$handle' : $handle,
- '$label' : $label,
- '$min' : $min,
- '$max' : $max,
- 'diff' : settings.max - settings.min,
- 'vertical' : settings.direction == 'y',
- 'val' : settings.start,
- 'handlerect' : geom.rectangle(0, 0, settings.handlesize, settings.handlesize)
- });
- }
- });
- };
-
var getval = function (data) {
// returns the slider value
var $this = this;
@@ -295,6 +249,7 @@
var setButtonAction = function(buttons, buttonName, action) {
var button = buttons[buttonName];
if (button == null) {
+ // normally this means that jquery.digilib.buttons.js was not loaded
console.log('could not attach slider action ' + action
+ ', button ' + buttonName + ' not available' );
return;
@@ -331,35 +286,28 @@
console.debug('initialising sliders plugin. data:', data);
var settings = data.settings;
var $data = $(data);
- // install event handler
- $data.bind('setup', handleSetup);
+ // we do setup at runtime
+ // $data.bind('setup', handleSetup);
};
- var handleSetup = function (evt) {
- console.debug("sliders: handleSetup");
- var data = this;
- var settings = data.settings;
- };
-
-
/** creates the HTML structure for a panel div
*/
var setupPanel = function (data) {
var $elem = data.$elem;
var panelClass = data.settings.cssPrefix + 'panel';
var $panel = $elem.find('.' + panelClass);
- // remove panel if it exists already
- if ($panel.length > 0) {
- $panel.fadeOut(function() {
- $panel.remove();
- });
- return null;
- }
- $panel = $('');
- $panel.addClass(panelClass);
+ if ($panel.length == 0) {
+ // new panel
+ $panel = $('');
+ $panel.addClass(panelClass);
+ $elem.append($panel);
+ $panel.fadeIn();
+ } else {
+ // panel exists, so empty it
+ $panel.empty();
+ }
var $okcancel = setupOkCancel(data);
$panel.append($okcancel);
- $elem.append($panel);
return $panel;
};
@@ -368,16 +316,43 @@
var setupSlider = function (data, paramname, opts) {
var id = "slider-" + paramname;
var $div = $('#' + id);
- if ($div.length == 0) {
- // slider not yet created
- $div = $('');
- var options = sliders[paramname];
- if (opts != null) {
- $.extend(options, opts);
- }
- $div.attr('id', id);
- // $div.slider(options);
+ if ($div.length > 0) {
+ return $div;
}
+ // slider not yet created
+ var cssClass = data.cssPrefix+'slider';
+ var html = '\
+ \
+
+
'+options.min+'
\
+
'+options.max+'
\
+
\
+ '+options.label+'\
+ '+options.start+'\
+
\
+
';
+ var $div = $(html);
+ var $handle = $div.find('div.'+cssClass+'handle');
+ var $label = $div.find('div.'+cssClass+'label');
+ var $input = $div.find('div.'+cssClass+'input');
+ var $numbers = $div.find('div.'+cssClass+'number')
+ var $min = $numbers[0];
+ var $max = $numbers[1];
+ var options = defaults;
+ $.extend(options, sliders[paramname], opts);
+ $.extend(options, {
+ '$handle' : $handle,
+ '$label' : $label,
+ '$input' : $input,
+ '$min' : $min,
+ '$max' : $max,
+ 'diff' : options.max - options.min,
+ 'vertical' : options.direction == 'y',
+ 'val' : options.start,
+ 'handlerect' : geom.rectangle(0, 0, options.handlesize, options.handlesize)
+ });
+ $div.data(options);
+ console.debug('new slider: ', $div, ', options: ', options);
return $div;
};