ItEr27S07CUVistaRecursosTempoPorProxectoItEr26S08: Extracting ScrollSync class to its own file. Updating dependencies.
This commit is contained in:
parent
72a26a083e
commit
980c4ec329
4 changed files with 62 additions and 51 deletions
|
|
@ -2,7 +2,7 @@ package org.zkoss.ganttz;
|
|||
|
||||
import org.zkoss.ganttz.util.script.ScriptsRequiredDeclaration;
|
||||
|
||||
@ScriptsRequiredDeclaration(dependsOn = YUIMin.class)
|
||||
@ScriptsRequiredDeclaration(dependsOn = { YUIMin.class, ScrollSyncScript.class })
|
||||
public class ScriptsRequiredByPlanner {
|
||||
|
||||
public static final String SELECTOR = "/zkau/web/js/yui/2.7.0/selector/selector-min.js";
|
||||
|
|
|
|||
12
ganttzk/src/main/java/org/zkoss/ganttz/ScrollSyncScript.java
Normal file
12
ganttzk/src/main/java/org/zkoss/ganttz/ScrollSyncScript.java
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package org.zkoss.ganttz;
|
||||
|
||||
import org.zkoss.ganttz.util.script.ScriptsRequiredDeclaration;
|
||||
|
||||
@ScriptsRequiredDeclaration(dependsOn = YUIMin.class)
|
||||
public class ScrollSyncScript {
|
||||
|
||||
public static final String SCROLL_SYNC = "/zkau/web/js/ganttz/scrollSync.js";
|
||||
|
||||
public static final String YAHOO_DOM_EVENT = "/zkau/web/js/yui/2.7.0/yahoo-dom-event/yahoo-dom-event.js";
|
||||
|
||||
}
|
||||
|
|
@ -1,53 +1,3 @@
|
|||
function ScrollSync(element){
|
||||
var xChanges = [];
|
||||
var yChanges = [];
|
||||
var notifyScrollX = function(){
|
||||
for ( var i = 0; i < xChanges.length; i++) {
|
||||
xChanges[i]();
|
||||
}
|
||||
};
|
||||
var notifyScrollY = function(){
|
||||
for ( var i = 0; i < yChanges.length; i++) {
|
||||
yChanges[i]();
|
||||
}
|
||||
};
|
||||
var notifyListeners = function(){
|
||||
notifyScrollX();
|
||||
notifyScrollY();
|
||||
};
|
||||
var toFunction = function(value){
|
||||
var result = value;
|
||||
if(typeof(value) !== 'function'){
|
||||
result = function(){return synched};
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
this.synchXChangeTo = function(synched){
|
||||
var target = toFunction(synched);
|
||||
xChanges.push(function(){ target().scrollLeft = element.scrollLeft; });
|
||||
};
|
||||
this.synchYChangeTo = function(synched){
|
||||
var target = toFunction(synched);
|
||||
yChanges.push(function(){ target().scrollTop = element.scrollTop; });
|
||||
};
|
||||
|
||||
this.notifyXChangeTo = function(listenerReceivingScroll){
|
||||
xChanges.push(function(){
|
||||
listenerReceivingScroll(element.scrollLeft);
|
||||
});
|
||||
};
|
||||
|
||||
this.notifyYChangeTo = function(listenerReceivingScroll){
|
||||
yChanges.push(function() {
|
||||
listenerReceivingScroll(element.scrollTop);
|
||||
});
|
||||
};
|
||||
|
||||
YAHOO.util.Event.addListener(element,'scroll', notifyListeners);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Javascript behaviuor for Planner elements
|
||||
* @author Lorenzo Tilve Álvaro <ltilve@igalia.com>
|
||||
|
|
|
|||
49
ganttzk/src/main/resources/web/js/ganttz/scrollSync.js
Normal file
49
ganttzk/src/main/resources/web/js/ganttz/scrollSync.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
function ScrollSync(element){
|
||||
var xChanges = [];
|
||||
var yChanges = [];
|
||||
var notifyScrollX = function(){
|
||||
for ( var i = 0; i < xChanges.length; i++) {
|
||||
xChanges[i]();
|
||||
}
|
||||
};
|
||||
var notifyScrollY = function(){
|
||||
for ( var i = 0; i < yChanges.length; i++) {
|
||||
yChanges[i]();
|
||||
}
|
||||
};
|
||||
var notifyListeners = function(){
|
||||
notifyScrollX();
|
||||
notifyScrollY();
|
||||
};
|
||||
var toFunction = function(value){
|
||||
var result = value;
|
||||
if(typeof(value) !== 'function'){
|
||||
result = function(){return synched};
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
this.synchXChangeTo = function(synched){
|
||||
var target = toFunction(synched);
|
||||
xChanges.push(function(){ target().scrollLeft = element.scrollLeft; });
|
||||
};
|
||||
this.synchYChangeTo = function(synched){
|
||||
var target = toFunction(synched);
|
||||
yChanges.push(function(){ target().scrollTop = element.scrollTop; });
|
||||
};
|
||||
|
||||
this.notifyXChangeTo = function(listenerReceivingScroll){
|
||||
xChanges.push(function(){
|
||||
listenerReceivingScroll(element.scrollLeft);
|
||||
});
|
||||
};
|
||||
|
||||
this.notifyYChangeTo = function(listenerReceivingScroll){
|
||||
yChanges.push(function() {
|
||||
listenerReceivingScroll(element.scrollTop);
|
||||
});
|
||||
};
|
||||
|
||||
YAHOO.util.Event.addListener(element,'scroll', notifyListeners);
|
||||
return this;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue