Author: abelevich
Date: 2010-03-13 09:10:48 -0500 (Sat, 13 Mar 2010)
New Revision: 16575
Modified:
root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources/script/datascroller.js
Log:
add events processing
Modified:
root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources/script/datascroller.js
===================================================================
---
root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources/script/datascroller.js 2010-03-13
14:09:37 UTC (rev 16574)
+++
root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources/script/datascroller.js 2010-03-13
14:10:48 UTC (rev 16575)
@@ -3,36 +3,141 @@
richfaces.ui = richfaces.ui || {};
richfaces.ui.DataScroller = function(id, options) {
- $super.constructor.call(this);
+
+ $super.constructor.call(this,id);
- this.id = id;
- this.options = options;
+ this.options = options;
+
+ var buttons = options.buttons;
+ var digitals = options.digitals;
- RichFaces.Event.bindById(this.id, 'rich:datascroller:onscroll',
this.submitFunction, this);
+ var css = {};
- this.init(options);
+ if(buttons) {
+ var leftButtons = buttons.left;
+
+ css.mouseover = "ds_button ds_left ds_over";
+ css.mouseup = "ds_button ds_left";
+ css.mouseout = "ds_button ds_left";
+ css.mousedown = "ds_button ds_left ds_over";
+
+ this.initButtons(leftButtons,css);
+
+ var rightButtons = buttons.right;
+ css.mouseover = "ds_button ds_right ds_over";
+ css.mouseup = "ds_button ds_right";
+ css.mouseout = "ds_button ds_right";
+ css.mousedown = "ds_button ds_right ds_over";
+
+ this.initButtons(rightButtons,css);
+ }
+
+ if(digitals) {
+ css.mouseover= "ds_digital ds_over";
+ css.mouseup= "ds_digital ds_over";
+ css.mouseout = "ds_digital";
+ css.mousedown="ds_digital ds_press";
+
+ this.initButtons(digitals,css);
+ }
+
+
};
-
-
var $super = richfaces.BaseComponent.extend(richfaces.BaseComponent,
richfaces.ui.DataScroller);
jQuery.extend(richfaces.ui.DataScroller.prototype, (function (options) {
+
+ var button_right_css = "ds_button ds_right";
+ var button_left_css = "ds_button ds_left"
+
+ var button_right_over_css = "ds_button ds_right ds_over";
+ var button_left_over_css = "ds_button ds_left ds_over";
-
+ var button_right_press_css = "ds_button ds_right ds_over";
+ var button_left_press_css = "ds_button ds_left ds_over";
+
+ var digital_css = "ds_digital";
+ var digital_over_css = "ds_digital ds_over";
+ var digital_press_css = "ds_digital ds_press";
+
+
+ var copy = function(data) {
+ var key;
+ var eventData = {};
+
+ for (key in data) {
+ eventData[key] = data[key];
+ }
+
+ return eventData;
+ };
+
+ var processEvents = function(event) {
+ var data = event.data;
+
+ if(data) {
+
+ var element = data.element;
+ var css = data.css;
+ var page = data.page;
+
+ if(element && css) {
+ element.attr('class', css);
+ }
+
+ if(event.type == 'click') {
+ this.switchToPage(page);
+ }
+ }
+ };
+
return {
name: "RichFaces.ui.DataScroller",
-
- submitFunction: function(event) {
- alert(test);
+
+ initButtons: function(buttons, css) {
+
+ var id;
+
+ var fn = function(e) {
+ e.data.fn.call(e.data.component, e, this);
+ }
+
+ var data = {};
+ data.component = this;
+ data.fn = processEvents;
+
+ for(id in buttons) {
+
+ var element = jQuery(document.getElementById(id));
+
+ data.id = id;
+ data.page = buttons[id];
+ data.element = element;
+
+ element.bind('click', copy(data), fn);
+
+ if(css) {
+ data.css = css.mousedown;
+ element.bind('mousedown', copy(data), fn);
+
+ data.css = css.mouseup;
+ element.bind('mouseup', copy(data), fn);
+
+ data.css = css.mouseout;
+ element.bind('mouseout', copy(data), fn);
+
+ data.css = css.mouseover;
+ element.bind('mouseover', copy(data), fn);
+ }
+ }
+
},
switchToPage: function(page) {
- if (typeof page != 'undefined' && page != null) {
- RichFaces.Event.callHandlerById(this.id, 'rich:datascroller:onscroll',
{'page': page});
- }
- },
+ alert(page);
+ },
next: function() {
this.switchToPage("next");
@@ -57,7 +162,7 @@
fastRewind: function() {
this.switchToPage("fastrewind");
}
- }
+ }
})());