Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

232 - Internet Explorer 7 & 8 fixes #237

Merged
merged 6 commits into from Oct 2, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions _includes/recline-deps.html
Expand Up @@ -42,6 +42,7 @@
-->

<!-- model and backends -->
<script type="text/javascript" src="{{page.root}}src/ecma-fixes.js"></script>
<script type="text/javascript" src="{{page.root}}src/model.js"></script>
<script type="text/javascript" src="{{page.root}}src/backend.memory.js"></script>
<script type="text/javascript" src="{{page.root}}src/backend.dataproxy.js"></script>
Expand Down
6 changes: 3 additions & 3 deletions demos/multiview/app.js
Expand Up @@ -74,21 +74,21 @@ var createExplorer = function(dataset, state) {
label: 'Grid',
view: new recline.View.SlickGrid({
model: dataset
}),
})
},
{
id: 'graph',
label: 'Graph',
view: new recline.View.Graph({
model: dataset
}),
})
},
{
id: 'map',
label: 'Map',
view: new recline.View.Map({
model: dataset
}),
})
},
{
id: 'transform',
Expand Down
4 changes: 2 additions & 2 deletions dist/recline.dataset.js
Expand Up @@ -608,7 +608,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
});
};

this.delete = function(doc) {
this.remove = function(doc) {
var newdocs = _.reject(self.data, function(internalDoc) {
return (doc.id === internalDoc.id);
});
Expand All @@ -623,7 +623,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
self.update(record);
});
_.each(changes.deletes, function(record) {
self.delete(record);
self.remove(record);
});
dfd.resolve();
return dfd.promise();
Expand Down
89 changes: 77 additions & 12 deletions dist/recline.js
Expand Up @@ -529,7 +529,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
//
// @param {Object} id id of object to delete
// @return deferred supporting promise API
this.delete = function(id) {
this.remove = function(id) {
url = this.endpoint;
url += '/' + id;
return makeRequest({
Expand Down Expand Up @@ -669,7 +669,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
else if (changes.updates.length >0) {
return es.upsert(changes.updates[0]);
} else if (changes.deletes.length > 0) {
return es.delete(changes.deletes[0].id);
return es.remove(changes.deletes[0].id);
}
};

Expand All @@ -680,7 +680,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
var jqxhr = es.query(queryObj);
jqxhr.done(function(results) {
var out = {
total: results.hits.total,
total: results.hits.total
};
out.hits = _.map(results.hits.hits, function(hit) {
if (!('id' in hit._source) && hit._id) {
Expand Down Expand Up @@ -930,7 +930,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
});
};

this.delete = function(doc) {
this.remove = function(doc) {
var newdocs = _.reject(self.data, function(internalDoc) {
return (doc.id === internalDoc.id);
});
Expand All @@ -945,7 +945,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
self.update(record);
});
_.each(changes.deletes, function(record) {
self.delete(record);
self.remove(record);
});
dfd.resolve();
return dfd.promise();
Expand Down Expand Up @@ -1180,7 +1180,73 @@ my.Transform.mapDocs = function(docs, editFunc) {
};

}(this.recline.Data))
// # Recline Backbone Models
// This file adds in full array method support in browsers that don't support it
// see: http://stackoverflow.com/questions/2790001/fixing-javascript-array-functions-in-internet-explorer-indexof-foreach-etc

// Add ECMA262-5 Array methods if not supported natively
if (!('indexOf' in Array.prototype)) {
Array.prototype.indexOf= function(find, i /*opt*/) {
if (i===undefined) i= 0;
if (i<0) i+= this.length;
if (i<0) i= 0;
for (var n= this.length; i<n; i++)
if (i in this && this[i]===find)
return i;
return -1;
};
}
if (!('lastIndexOf' in Array.prototype)) {
Array.prototype.lastIndexOf= function(find, i /*opt*/) {
if (i===undefined) i= this.length-1;
if (i<0) i+= this.length;
if (i>this.length-1) i= this.length-1;
for (i++; i-->0;) /* i++ because from-argument is sadly inclusive */
if (i in this && this[i]===find)
return i;
return -1;
};
}
if (!('forEach' in Array.prototype)) {
Array.prototype.forEach= function(action, that /*opt*/) {
for (var i= 0, n= this.length; i<n; i++)
if (i in this)
action.call(that, this[i], i, this);
};
}
if (!('map' in Array.prototype)) {
Array.prototype.map= function(mapper, that /*opt*/) {
var other= new Array(this.length);
for (var i= 0, n= this.length; i<n; i++)
if (i in this)
other[i]= mapper.call(that, this[i], i, this);
return other;
};
}
if (!('filter' in Array.prototype)) {
Array.prototype.filter= function(filter, that /*opt*/) {
var other= [], v;
for (var i=0, n= this.length; i<n; i++)
if (i in this && filter.call(that, v= this[i], i, this))
other.push(v);
return other;
};
}
if (!('every' in Array.prototype)) {
Array.prototype.every= function(tester, that /*opt*/) {
for (var i= 0, n= this.length; i<n; i++)
if (i in this && !tester.call(that, this[i], i, this))
return false;
return true;
};
}
if (!('some' in Array.prototype)) {
Array.prototype.some= function(tester, that /*opt*/) {
for (var i= 0, n= this.length; i<n; i++)
if (i in this && tester.call(that, this[i], i, this))
return true;
return false;
};
}// # Recline Backbone Models
this.recline = this.recline || {};
this.recline.Model = this.recline.Model || {};

Expand Down Expand Up @@ -1974,7 +2040,7 @@ my.Graph = Backbone.View.extend({
horizontal: true,
shadowSize: 0,
barWidth: 0.8
},
}
},
columns: {
legend: legend,
Expand All @@ -1995,9 +2061,9 @@ my.Graph = Backbone.View.extend({
horizontal: false,
shadowSize: 0,
barWidth: 0.8
},
}
},
grid: { hoverable: true, clickable: true },
grid: { hoverable: true, clickable: true }
};
return optionsPerGraphType[typeId];
},
Expand Down Expand Up @@ -2177,7 +2243,7 @@ my.GraphControls = Backbone.View.extend({
addSeries: function (idx) {
var data = _.extend({
seriesIndex: idx,
seriesName: String.fromCharCode(idx + 64 + 1),
seriesName: String.fromCharCode(idx + 64 + 1)
}, this.model.toTemplateJSON());

var htmls = Mustache.render(this.templateSeriesEditor, data);
Expand Down Expand Up @@ -3183,7 +3249,7 @@ my.MultiView = Backbone.View.extend({
<div class="recline-data-explorer"> \
<div class="alert-messages"></div> \
\
<div class="header"> \
<div class="header clearfix"> \
<div class="navigation"> \
<div class="btn-group" data-toggle="buttons-radio"> \
{{#views}} \
Expand All @@ -3202,7 +3268,6 @@ my.MultiView = Backbone.View.extend({
</div> \
</div> \
<div class="query-editor-here" style="display:inline;"></div> \
<div class="clearfix"></div> \
</div> \
<div class="data-view-sidebar"></div> \
<div class="data-view-container"></div> \
Expand Down
6 changes: 3 additions & 3 deletions src/backend.couchdb.js
Expand Up @@ -97,7 +97,7 @@ my.__type__ = 'couchdb';
//
// @param {Object} id id of object to delete
// @return deferred supporting promise API
this.delete = function(_id) {
this.remove = function(_id) {
url = self.endpoint;
url += '/' + _id;
return self._makeRequest({
Expand Down Expand Up @@ -475,7 +475,7 @@ _deleteDocument = function (del_doc, dataset) {
var cdb = new my.CouchDBWrapper(db_url, view_url);

if (view_url.search('_all_docs') !== -1)
return cdb.delete(_id);
return cdb.remove(_id);
else {
_id = model.get('_id').split('__')[0];
var jqxhr = cdb.get(_id);
Expand All @@ -484,7 +484,7 @@ _deleteDocument = function (del_doc, dataset) {
if (dataset.record_delete)
old_doc = dataset.record_delete(del_doc, old_doc);
if (_.isNull(del_doc))
dfd.resolve(cdb.delete(_id)); // XXX is this the right thing to do?
dfd.resolve(cdb.remove(_id)); // XXX is this the right thing to do?
else {
// couchdb uses _id to identify documents, Backbone models use id.
// we should remove it before sending it to the server.
Expand Down
6 changes: 3 additions & 3 deletions src/backend.elasticsearch.js
Expand Up @@ -79,7 +79,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
//
// @param {Object} id id of object to delete
// @return deferred supporting promise API
this.delete = function(id) {
this.remove = function(id) {
url = this.endpoint;
url += '/' + id;
return makeRequest({
Expand Down Expand Up @@ -219,7 +219,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
else if (changes.updates.length >0) {
return es.upsert(changes.updates[0]);
} else if (changes.deletes.length > 0) {
return es.delete(changes.deletes[0].id);
return es.remove(changes.deletes[0].id);
}
};

Expand All @@ -230,7 +230,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
var jqxhr = es.query(queryObj);
jqxhr.done(function(results) {
var out = {
total: results.hits.total,
total: results.hits.total
};
out.hits = _.map(results.hits.hits, function(hit) {
if (!('id' in hit._source) && hit._id) {
Expand Down
4 changes: 2 additions & 2 deletions src/backend.memory.js
Expand Up @@ -37,7 +37,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
});
};

this.delete = function(doc) {
this.remove = function(doc) {
var newdocs = _.reject(self.data, function(internalDoc) {
return (doc.id === internalDoc.id);
});
Expand All @@ -52,7 +52,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
self.update(record);
});
_.each(changes.deletes, function(record) {
self.delete(record);
self.remove(record);
});
dfd.resolve();
return dfd.promise();
Expand Down
67 changes: 67 additions & 0 deletions src/ecma-fixes.js
@@ -0,0 +1,67 @@
// This file adds in full array method support in browsers that don't support it
// see: http://stackoverflow.com/questions/2790001/fixing-javascript-array-functions-in-internet-explorer-indexof-foreach-etc

// Add ECMA262-5 Array methods if not supported natively
if (!('indexOf' in Array.prototype)) {
Array.prototype.indexOf= function(find, i /*opt*/) {
if (i===undefined) i= 0;
if (i<0) i+= this.length;
if (i<0) i= 0;
for (var n= this.length; i<n; i++)
if (i in this && this[i]===find)
return i;
return -1;
};
}
if (!('lastIndexOf' in Array.prototype)) {
Array.prototype.lastIndexOf= function(find, i /*opt*/) {
if (i===undefined) i= this.length-1;
if (i<0) i+= this.length;
if (i>this.length-1) i= this.length-1;
for (i++; i-->0;) /* i++ because from-argument is sadly inclusive */
if (i in this && this[i]===find)
return i;
return -1;
};
}
if (!('forEach' in Array.prototype)) {
Array.prototype.forEach= function(action, that /*opt*/) {
for (var i= 0, n= this.length; i<n; i++)
if (i in this)
action.call(that, this[i], i, this);
};
}
if (!('map' in Array.prototype)) {
Array.prototype.map= function(mapper, that /*opt*/) {
var other= new Array(this.length);
for (var i= 0, n= this.length; i<n; i++)
if (i in this)
other[i]= mapper.call(that, this[i], i, this);
return other;
};
}
if (!('filter' in Array.prototype)) {
Array.prototype.filter= function(filter, that /*opt*/) {
var other= [], v;
for (var i=0, n= this.length; i<n; i++)
if (i in this && filter.call(that, v= this[i], i, this))
other.push(v);
return other;
};
}
if (!('every' in Array.prototype)) {
Array.prototype.every= function(tester, that /*opt*/) {
for (var i= 0, n= this.length; i<n; i++)
if (i in this && !tester.call(that, this[i], i, this))
return false;
return true;
};
}
if (!('some' in Array.prototype)) {
Array.prototype.some= function(tester, that /*opt*/) {
for (var i= 0, n= this.length; i<n; i++)
if (i in this && tester.call(that, this[i], i, this))
return true;
return false;
};
}
8 changes: 4 additions & 4 deletions src/view.graph.js
Expand Up @@ -221,7 +221,7 @@ my.Graph = Backbone.View.extend({
horizontal: true,
shadowSize: 0,
barWidth: 0.8
},
}
},
columns: {
legend: legend,
Expand All @@ -242,9 +242,9 @@ my.Graph = Backbone.View.extend({
horizontal: false,
shadowSize: 0,
barWidth: 0.8
},
}
},
grid: { hoverable: true, clickable: true },
grid: { hoverable: true, clickable: true }
};
return optionsPerGraphType[typeId];
},
Expand Down Expand Up @@ -424,7 +424,7 @@ my.GraphControls = Backbone.View.extend({
addSeries: function (idx) {
var data = _.extend({
seriesIndex: idx,
seriesName: String.fromCharCode(idx + 64 + 1),
seriesName: String.fromCharCode(idx + 64 + 1)
}, this.model.toTemplateJSON());

var htmls = Mustache.render(this.templateSeriesEditor, data);
Expand Down