Stop editor form field visible on click
This commit is contained in:
parent
413896befa
commit
32592cbfa4
|
@ -1,11 +1,14 @@
|
||||||
(function($) {
|
(function($) {
|
||||||
var API_BASE = 'http://chalobest.in/1.0/';
|
var API_BASE = 'http://localhost:8000/1.0/';
|
||||||
console.log(API_BASE);
|
console.log(API_BASE);
|
||||||
var clickedName = 'stops';
|
var clickedName = 'stops';
|
||||||
var searchQuery = 'None';
|
var searchQuery = 'None';
|
||||||
var url1 = API_BASE + clickedName + '/' + '?q=';
|
var url1 = API_BASE + clickedName + '/' + '?q=';
|
||||||
var url2 = API_BASE + clickedName + '/';
|
var url2 = API_BASE + clickedName + '/';
|
||||||
var Features = Backbone.Model.extend({});
|
var Features = Backbone.Model.extend({
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
var apiCollection = Backbone.Collection.extend({
|
var apiCollection = Backbone.Collection.extend({
|
||||||
model: Features,
|
model: Features,
|
||||||
|
@ -15,126 +18,146 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var apiView = Backbone.View.extend({
|
var apiView = Backbone.View.extend({
|
||||||
//el: '#sideBar',
|
//el: '#content',
|
||||||
events: {
|
events: {
|
||||||
"click a": "stopDetails"
|
"click a": "clicked"
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
//this.render();
|
//this.render();
|
||||||
_.bindAll(this, "render");
|
_.bindAll(this, "render", "clicked");
|
||||||
this.collection.bind("all", this.render);
|
this.collection.bind("all", this.render, this.clicked);
|
||||||
//apiView.prototype.initialize.call(this);
|
//apiView.prototype.initialize.call(this);
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
//$(this.el).html(this.counter = this.collection.length);
|
//$(this.el).html(this.counter = this.collection.length);
|
||||||
console.log(this.collection.length);
|
//console.log(this.collection.length);
|
||||||
//console.log(this.el);
|
//console.log(this.el);
|
||||||
this.collection.each( function(model){
|
this.collection.each(function(model) {
|
||||||
$('#sideBar').append('<li> <a id=\''+model.cid+'\' href="#">' + model.get('properties').official_name + "</a></li>");
|
$('#sideBar').append('<li> <a id=\'' + model.cid + '\' href="#">' + model.get('properties').official_name + "</a></li>");
|
||||||
//console.log(model.cid);
|
//console.log(model.cid);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
return this;
|
||||||
|
|
||||||
return this;
|
},
|
||||||
|
clicked: function(e) {
|
||||||
},
|
//e.preventDefaults();
|
||||||
clicked: function(e) {
|
//var name1 = this.model.get('properties').official_name;
|
||||||
//e.preventDefaults();
|
|
||||||
//var name1 = this.model.get('properties').official_name;
|
//console.log(e);
|
||||||
console.log(e);
|
//alert("you clicked me"+ e.target.innerHTML);
|
||||||
//alert("you clicked me"+ e.target.innerHTML);
|
events.trigger('stopdetailsEvent', e);
|
||||||
|
//return this;
|
||||||
|
},
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//close: function() {
|
||||||
|
// $(this.el).unbind();
|
||||||
|
// $(this.el).remove();
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
var stopView = Backbone.View.extend({
|
||||||
|
el: '#content',
|
||||||
|
initialize: function() {
|
||||||
|
_.bindAll(this, "stopDetails");
|
||||||
|
this.collection.bind("stopdetailsEvent", this.stopDetails);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
stopDetails: function(e) {
|
stopDetails: function(e) {
|
||||||
var cid = $(e.target).attr('id');
|
//console.log(e);
|
||||||
//this.trigger
|
//alert("you clicked me"+ e.target.innerHTML);
|
||||||
//console.log(cid);
|
var cid = $(e.target).attr('id');
|
||||||
this.values= this.collection.getByCid(cid);
|
//this.trigger
|
||||||
//this.trigger('new-stage', this.collection.get)
|
//console.log(cid);
|
||||||
this.stopName = e.target.innerHTML;
|
this.values = this.collection.getByCid(cid);
|
||||||
//var test = this.collection.where({official_name: this.stopName});
|
//this.trigger('new-stage', this.collection.get)
|
||||||
console.log(this.values.get('properties').road);
|
this.stopName = e.target.innerHTML;
|
||||||
$('#sLug').append(this.values.get('properties').slug);
|
//var test = this.collection.where({official_name: this.stopName});
|
||||||
$('#rOads').append(this.values.get('properties').road);
|
//console.log(this.values.get('properties').road);
|
||||||
$('#rOutes').append(this.values.get('properties').routes);
|
//console.log(this.el);
|
||||||
$('#dIrection').append(this.values.get('properties').direction);
|
$(this.el).find('input#sLug').val(this.values.get('properties').slug);
|
||||||
//console.log(e.target);
|
//$('#sLug').attr('id', 'sLug').value(this.values.get('properties').slug);
|
||||||
$('#dIsplayName').append(this.values.get('properties').official_name);
|
$(this.el).find('input#rOads').val(this.values.get('properties').road);
|
||||||
$('#mArathiName').append(this.values.get('properties').name_mr);
|
$(this.el).find('textarea#rOutes').html(this.values.get('properties').routes);
|
||||||
$('#aLtName').append(this.values.get('properties').alternative_names);
|
$(this.el).find('input#dIrection').val(this.values.get('properties').direction);
|
||||||
},
|
//console.log(e.target);
|
||||||
close:function () {
|
$(this.el).find('input#dIsplayName').val(this.values.get('properties').official_name);
|
||||||
$(this.el).unbind();
|
$(this.el).find('input#mArathiName').val(this.values.get('properties').name_mr);
|
||||||
$(this.el).remove();
|
$(this.el).find('input#aLtName').val(this.values.get('properties').alternative_names);
|
||||||
}
|
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}),
|
|
||||||
events = new apiCollection();
|
events = new apiCollection();
|
||||||
$(function() {
|
$(function() {
|
||||||
|
stopDetailsView = new stopView({
|
||||||
|
el: $("#content"),
|
||||||
|
collection: events
|
||||||
|
});
|
||||||
eventView = new apiView({
|
eventView = new apiView({
|
||||||
el: $("#sideBar"),
|
el: $("#sideBar"),
|
||||||
//el: $('#slug'),
|
//el: $('#slug'),
|
||||||
//el:$('#displayName'),
|
//el:$('#displayName'),
|
||||||
collection: events
|
collection: events
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
events.fetch({
|
|
||||||
success: function() {
|
events.fetch({
|
||||||
console.log(events.length);
|
success: function() {
|
||||||
//console.log(this.official_name);
|
console.log(events.length);
|
||||||
//alert();
|
//console.log(this.official_name);
|
||||||
|
//alert();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var Map = Backbone.Model.extend({});
|
||||||
|
|
||||||
|
|
||||||
|
var MapView = Backbone.View.extend({
|
||||||
|
el: '#mapCol',
|
||||||
|
|
||||||
|
initialize: function() {
|
||||||
|
_.bindAll(this, 'initMap');
|
||||||
|
this.initMap();
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
initMap: function() {
|
||||||
|
// Initialize Basic Openlayers;
|
||||||
|
var center = new OpenLayers.LonLat(8110203.9998955, 2170000.4068373);
|
||||||
|
//alert("you are here");
|
||||||
|
map = new OpenLayers.Map(this.el, {
|
||||||
|
projection: new OpenLayers.Projection("EPSG:900913"),
|
||||||
|
displayProjection: new OpenLayers.Projection("EPSG:4326")
|
||||||
|
});
|
||||||
|
//alert(this.el);
|
||||||
|
var layers = [];
|
||||||
|
layers[0] = new OpenLayers.Layer.OSM(); //some more layer will go here
|
||||||
|
//$(this.el).html(map);
|
||||||
|
map.addLayers(layers);
|
||||||
|
map.setCenter(center, 12);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
$(function() {
|
||||||
|
var map_view = new MapView();
|
||||||
|
//alert("I am here" + this.el);
|
||||||
|
});
|
||||||
|
|
||||||
|
//var router = Backbone.Router.extend({
|
||||||
|
//routes:{
|
||||||
var Map = Backbone.Model.extend({});
|
//})
|
||||||
|
})(jQuery);
|
||||||
|
|
||||||
var MapView = Backbone.View.extend({
|
|
||||||
el: '#mapCol',
|
|
||||||
|
|
||||||
initialize: function() {
|
|
||||||
_.bindAll(this, 'initMap');
|
|
||||||
this.initMap();
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
initMap: function() {
|
|
||||||
// Initialize Basic Openlayers;
|
|
||||||
var center = new OpenLayers.LonLat(8110203.9998955, 2170000.4068373);
|
|
||||||
//alert("you are here");
|
|
||||||
map = new OpenLayers.Map(this.el, {
|
|
||||||
projection: new OpenLayers.Projection("EPSG:900913"),
|
|
||||||
displayProjection: new OpenLayers.Projection("EPSG:4326")
|
|
||||||
});
|
|
||||||
//alert(this.el);
|
|
||||||
var layers = [];
|
|
||||||
layers[0] = new OpenLayers.Layer.OSM(); //some more layer will go here
|
|
||||||
//$(this.el).html(map);
|
|
||||||
map.addLayers(layers);
|
|
||||||
map.setCenter(center, 12);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$(function() {
|
|
||||||
var map_view = new MapView();
|
|
||||||
//alert("I am here" + this.el);
|
|
||||||
});
|
|
||||||
|
|
||||||
//var router = Backbone.Router.extend({
|
|
||||||
//routes:{
|
|
||||||
|
|
||||||
//})
|
|
||||||
|
|
||||||
})(jQuery);
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user