Permalink
Browse files

Fixes for eborhood front page

  • Loading branch information...
1 parent 0fc60f4 commit af13d1bc7a1319be9e24a13a2284ac6192ba0dca Winton Welsh committed Jun 18, 2008
Showing with 62 additions and 30 deletions.
  1. +2 −1 Dialog.js
  2. +15 −0 Element.js
  3. +25 −12 Gmap.js
  4. +20 −17 Table.js
View
@@ -299,7 +299,7 @@ var Dialog = Base.extend({
this.fireEvent('onRespond', [ this.el.dialog, json ]);
if (json.errors) {
var inputs = $ES('input, textarea', form).filter(function(item) {
- return (item.getProperty('type') != 'submit');
+ return (item.getProperty('type') != 'submit' && item.getProperty('type') != 'hidden');
});
inputs = inputs.sort(function(a, b) {
return a.getProperty('tabindex').toInt() - b.getProperty('tabindex').toInt();
@@ -309,6 +309,7 @@ var Dialog = Base.extend({
$each(json.errors, function(value, model) {
$each(value, function(messages, name) {
var el = form[model + '[' + name + ']'];
+ el = el.length ? el[0] : el;
index = inputs.indexOf(el) < index ? inputs.indexOf(el) : index;
this.fireEvent('onValidationFailed', [ validation, el , messages ]);
}, this);
View
@@ -33,6 +33,21 @@ Element.extend({
},
/*
+ Property: elasticize
+ Keeps a div in browser view (scrolls vertically)...with elasticity
+ */
+
+ elasticize: function() {
+ var fx = new Fx.Styles(this, { duration: 1500, wait: false, transition: Fx.Transitions.Elastic.easeOut });
+ var og_top = this.getPosition().y;
+ window.addEvent('scroll', function() {
+ var top = window.getScrollTop();
+ if (top > og_top) fx.start({ top: top - og_top + 15 });
+ else fx.start({ top: 0 });
+ });
+ },
+
+ /*
Property: hide
Sets display:none.
*/
View
37 Gmap.js
@@ -24,7 +24,6 @@ var Gmap = new Class({
this.markers = {};
this.map.changeZoomImage();
- this.map.elasticize();
this.map.killGoogleLogo();
window.onunload = function() { GUnload(); };
@@ -45,15 +44,6 @@ var Gmap = new Class({
}
}).periodical(100);
},
- elasticize: function() {
- var fx = new Fx.Styles($('map'), { duration: 1500, wait: false, transition: Fx.Transitions.Elastic.easeOut });
- var og_top = this.container.getPosition().y;
- window.addEvent('scroll', function() {
- var top = window.getScrollTop();
- if (top > og_top) fx.start({ top: top - og_top + 15 });
- else fx.start({ top: 0 });
- }.bind(this));
- },
killGoogleLogo: function() {
var children = $('map').getChildren();
children[1].setStyle('opacity', 0);
@@ -88,6 +78,10 @@ var Gmap = new Class({
var marker = new GMarker(latlng, {
icon: this.marker.icon(type, num), zIndexProcess: function() { return 100 - num; }
});
+
+ GEvent.addListener(marker, 'click', function() {
+ this.fireEvent('onMarkerClick', [marker, type, num]);
+ }.bind(this));
GEvent.addListener(marker, 'mouseover', function() {
this.marker.highlight(true, type, num);
@@ -107,13 +101,15 @@ var Gmap = new Class({
return marker;
},
remove: function(type, num) {
- this.gmap.removeOverlay(this.markers[type][num]);
+ if (this.markers[type] && this.markers[type][num])
+ this.gmap.removeOverlay(this.markers[type][num]);
},
remove_all: function() {
this.marker.each(function(marker, type, num) { this.marker.remove(type, num); }, this);
},
highlight: function(on, type, num) {
- this.markers[type][num].setImage(this.marker.imageUrl(type, num, on));
+ if (this.markers[type] && this.markers[type][num])
+ this.markers[type][num].setImage(this.marker.imageUrl(type, num, on));
},
imageUrl: function(type, num, highlight) {
return '/images/markers/' + type + '/' + (highlight ? 'highlights/' : '') + (num+1) + '.png';
@@ -132,6 +128,23 @@ var Gmap = new Class({
$each(this.markers, function(value, key) {
$each(value, function(v, k) { fn.bind(bind)(this.markers[key][k], key, k); }, this);
}, this);
+ },
+ tooltip: function(on, type, num, form, template) {
+ var tooltip = $('map_tooltip_' + type + '_' + num);
+ if (on) {
+ var marker_offset = this.gmap.fromLatLngToContainerPixel(this.markers[type][num].getLatLng());
+ var map_offset = this.container.getPosition();
+ var offset = { x: marker_offset.x + map_offset.x, y: marker_offset.y + map_offset.y };
+ if (!tooltip) {
+ tooltip = $(template||'template_map_tooltip').render({ form: form });
+ tooltip.id = 'map_tooltip_' + type + '_' + num;
+ tooltip.hide();
+ tooltip.injectInside(document.body);
+ }
+ tooltip.setStyles({ top: offset.y, left: offset.x });
+ tooltip.fadeIn();
+ } else
+ tooltip.fadeOut();
}
}
});
View
@@ -16,6 +16,7 @@ var Table = Base.extend({
row_height: 30,
tips: false,
+ onReloadContent: Class.empty,
onRowAdd: Class.empty,
onRowAddFinished: Class.empty,
onRowRemove: Class.empty,
@@ -116,6 +117,8 @@ var Table = Base.extend({
this.loadElements('table');
var fn = function(item, index) {
+ if (item.hasClass('ignore')) return;
+
var form = $ES('form', item)[0];
this.fireEvent('onRowAdd', [ item, index, form ]);
@@ -170,29 +173,29 @@ var Table = Base.extend({
},
reloadContent: function(content) {
this.el.content.getChildren().each(function(item, index) {
- this.fireEvent('onRowRemove', [ item, index ]);
+ if (!item.hasClass('ignore'))
+ this.fireEvent('onRowRemove', [ item, index ]);
}, this);
var hr = $ES('.hr', this.container)[0];
var header = $ES('.header', this.container)[0];
var pagination = $ES('.pagination', this.container)[0];
- this.el.content.getFx(600).start({ opacity:0, 'margin-left':150 }).chain(function() {
- var div = new Element('div');
- div.setHTML(content);
- div.getChildren().each(function(item) {
- item.setStyle('opacity', 0);
- item.injectInside(this.container);
- item.fadeIn();
- }, this);
-
- if (hr) hr.remove();
- if (header) header.remove();
- if (pagination) pagination.remove();
- this.el.content.remove();
-
- this.attach();
- }.bind(this));
+ var div = new Element('div');
+ div.setHTML(content);
+ div.getChildren().each(function(item) {
+ item.setStyle('opacity', 0);
+ item.injectInside(this.container);
+ item.fadeIn();
+ }, this);
+
+ if (hr) hr.remove();
+ if (header) header.remove();
+ if (pagination) pagination.remove();
+ this.el.content.remove();
+
+ this.attach();
+ this.fireEvent('onReloadContent');
}
});

0 comments on commit af13d1b

Please sign in to comment.