Can it be changed to something else?
var PopupDetail = new Class({
Implements: [Options, Events],
visible: false,
observed: false,
hasData: false,
options: {
observerAction: 'mouseenter', //or click
closeOnMouseOut: true,
linkPopup: false, //or true to use observer href, or url
data: {}, //key/value parse to parse in to html
templateOptions: {}, //see simple template parser
useAjax: false,
ajaxOptions:{
method: 'get'
},
ajaxLink: false, //defaults to use observer.src
ajaxCache: {},
delayOn: 100,
delayOff: 100,
stickyWinOptions:{},
showNow: false,
htmlResponse: false,
regExp: /\\?%([^%]+)%/g
/* onPopupShow: $empty,
onPopupHide: $empty */
},
initialize: function(html, observer, options){
this.setOptions({
stickyWinToUse: StickyWin
}, options);
this.observer = document.id(observer);
this.html = (document.id(html))?
document.id(html).get('html'):html||'';
if (this.options.showNow) this.show.delay(this.options.delayOn,
this);
this.setUpObservers();
},
setUpObservers: function(){
var opt = this.options; //saving bytes here
this.observer.addEvent(opt.observerAction, function(){
this.observed = true;
this.show.delay(opt.delayOn, this);
}.bind(this));
if ((opt.observerAction == "mouseenter" || opt.observerAction ==
"mouseover") && this.options.closeOnMouseOut){
this.observer.addEvent("mouseleave", function(){
this.observed = false;
this.hide.delay(opt.delayOff, this);
}.bind(this));
}
return this;
},
parseTemplate: function(string, values){
return string.substitute(values, this.options.regExp);
},
makePopup: function(){
if (!this.stickyWin){
var opt = this.options;//saving bytes
if (opt.htmlResponse) this.content = this.data;
else this.content = this.parseTemplate(this.html, opt.data);
this.stickyWin = new
opt.stickyWinToUse(Object.merge(opt.stickyWinOptions, {
relativeTo: this.observer,
showNow: false,
content: this.content,
allowMultipleByClass: true
}));
if (document.id(opt.linkPopup) || typeOf(opt.linkPopup)=='string') {
this.stickyWin.win.setStyle('cursor','pointer').addEvent('click',
function(){
window.location.href = ($type(url)=='string')?url:url.src;
});
}
this.stickyWin.win.addEvent('mouseenter', function(){
this.observed = true;
}.bind(this));
this.stickyWin.win.addEvent('mouseleave', function(){
this.observed = false;
if (opt.closeOnMouseOut) this.hide.delay(opt.delayOff, this);
}.bind(this));
}
return this;
},
getContent: function(){
try {
new Request(Object.merge(this.options.ajaxOptions, {
url: this.options.ajaxLink || this.observer.href,
onSuccess: this.show.bind(this)
})
).send();
} catch(e) {
dbug.log('ajax error on PopupDetail: %s', e);
}
},
show: function(data){
var opt = this.options;
if (data) this.data = data;
if (this.observed && !this.visible) {
if (opt.useAjax && !this.data) {
var cachedVal = opt.ajaxCache[this.options.ajaxLink] ||
opt.ajaxCache[this.observer.href];
if (cachedVal) {
this.fireEvent('onPopupShow', this);
return this.show(cachedVal);
}
this.cursorStyle = this.observer.getStyle('cursor');
this.observer.setStyle('cursor', 'wait');
this.getContent();
return false;
} else {
if (this.cursorStyle) this.observer.setStyle('cursor',
this.cursorStyle);
if (opt.useAjax && !opt.htmlResponse) opt.data =
JSON.decode(this.data);
this.makePopup();
this.fireEvent('onPopupShow', this);
this.stickyWin.show();
this.visible = true;
return this;
}
}
return this;
},
hide: function(){
if (!this.observed){
this.fireEvent('onPopupHide');
if (this.stickyWin)this.stickyWin.hide();
this.visible = false;
}
return this;
}
});
var PopupDetailCollection = new Class({
Implements: [Options],
options: {
details: {},
links: [],
ajaxLinks: [],
useCache: true,
template: '',
popupDetailOptions: {}
},
cache: {},
initialize: function(observers, options) {
this.observers = $$(observers);
this.setOptions(options);
var ln = this.options.ajaxLinks.length;
if (ln <= 0) ln = this.options.details.length;
if (this.observers.length != ln) dbug.log("warning: observers and
details are out of sync.");
this.makePopupDetails();
},
makePopupDetails: function(){
this.popupDetailObjs = this.observers.map(function(observer, index){
var opt = this.options.popupDetailOptions;//saving bytes
var pd = new PopupDetail(this.options.template, observer,
Object.merge(opt, {
data: Array.pick(this.options.details[index], {}),
linkItem: Array.pick(this.options.links[index],
Array.pick(opt.linkItem, false)),
ajaxLink: Array.pick(this.options.ajaxLinks[index], false),
ajaxCache: (this.options.useCache)?this.cache:{},
useAjax: this.options.ajaxLinks.length>0
}));
return pd;
}, this);
}
});
--
You received this message because you are subscribed to the Google Groups "Clientcide" group.
To post to this group, send email to clien...@googlegroups.com.
To unsubscribe from this group, send email to clientside+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/clientside?hl=en.
Aaron> I've sent a pull request with new option cacheRequest and also
added the StickyWin.PointyTip.Ajax