Skip to content

Commit

Permalink
Merge pull request #1381 from adaptlearning/feature/#1380
Browse files Browse the repository at this point in the history
add a data-adapt-id attribute to the HTML for pages, menus, articles, blocks + components
  • Loading branch information
brian-learningpool authored Jan 19, 2017
2 parents 186056f + f3c887c commit 7be8269
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 53 deletions.
8 changes: 7 additions & 1 deletion src/core/js/views/adaptView.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
define([
'coreJS/adapt'
'core/js/adapt'
], function(Adapt) {

var AdaptView = Backbone.View.extend({

attributes: function() {
return {
"data-adapt-id": this.model.get('_id')
};
},

initialize: function() {
this.listenTo(Adapt, 'remove', this.remove);
this.listenTo(this.model, 'change:_isVisible', this.toggleVisibility);
Expand Down
24 changes: 12 additions & 12 deletions src/core/js/views/articleView.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
define(function(require) {

var AdaptView = require('coreViews/adaptView');
var BlockView = require('coreViews/blockView');
define([
'core/js/views/adaptView',
'core/js/views/blockView'
], function(AdaptView, BlockView) {

var ArticleView = AdaptView.extend({

className: function() {
return "article "
+ this.model.get('_id')
+ " " + this.model.get('_classes')
+ " " + this.setVisibility()
+ " nth-child-"
+ this.model.get("_nthChild");
return "article " +
this.model.get('_id') +
" " + this.model.get('_classes') +
" " + this.setVisibility() +
" nth-child-" +
this.model.get("_nthChild");
}

}, {
Expand All @@ -23,4 +23,4 @@ define(function(require) {

return ArticleView;

});
});
16 changes: 8 additions & 8 deletions src/core/js/views/blockView.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
define([
'core/js/views/adaptView'
], function(AdaptView) {
], function(AdaptView) {

var BlockView = AdaptView.extend({

className: function() {
return "block "
+ this.model.get('_id')
+ " " + this.model.get('_classes')
+ " " + this.setVisibility()
+ " nth-child-"
+ this.model.get("_nthChild");
return "block " +
this.model.get('_id') +
" " + this.model.get('_classes') +
" " + this.setVisibility() +
" nth-child-" +
this.model.get("_nthChild");
}

}, {
Expand All @@ -21,4 +21,4 @@ define([

return BlockView;

});
});
24 changes: 12 additions & 12 deletions src/core/js/views/componentView.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
define(function(require) {

var Adapt = require("coreJS/adapt");
var AdaptView = require('coreViews/adaptView');
define([
'core/js/adapt',
'core/js/views/adaptView'
], function(Adapt, AdaptView) {

var ComponentView = AdaptView.extend({

className: function() {
return "component "
+ this.model.get('_component')
+ "-component " + this.model.get('_id')
+ " " + this.model.get('_classes')
+ " " + this.setVisibility()
+ " component-" + this.model.get('_layout')
+ " nth-child-" + this.model.get("_nthChild");
return "component " +
this.model.get('_component') +
"-component " + this.model.get('_id') +
" " + this.model.get('_classes') +
" " + this.setVisibility() +
" component-" + this.model.get('_layout') +
" nth-child-" + this.model.get("_nthChild");
},

initialize: function(){
Expand Down Expand Up @@ -54,4 +54,4 @@ define(function(require) {

return ComponentView;

});
});
18 changes: 9 additions & 9 deletions src/core/js/views/menuView.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define(function(require) {

var AdaptView = require('coreViews/adaptView');
var Adapt = require('coreJS/adapt');
define([
'core/js/adapt',
'core/js/views/adaptView'
], function(Adapt, AdaptView) {

var MenuView = AdaptView.extend({

Expand All @@ -10,11 +10,11 @@ define(function(require) {
if (this.model.get('_isVisible')) {
visible = "";
}
return 'menu '
+ 'menu-'
+ this.model.get('_id')
+ " " + this.model.get('_classes')
+ " " + this.setVisibility();
return 'menu ' +
'menu-' +
this.model.get('_id') +
" " + this.model.get('_classes') +
" " + this.setVisibility();
},

preRender: function() {
Expand Down
22 changes: 11 additions & 11 deletions src/core/js/views/pageView.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
define(function(require) {

var AdaptView = require('coreViews/adaptView');
var ArticleView = require('coreViews/articleView');
var Adapt = require('coreJS/adapt');
define([
'core/js/adapt',
'core/js/views/adaptView',
'core/js/views/articleView'
], function(Adapt, AdaptView, ArticleView) {

var PageView = AdaptView.extend({

className: function() {
return "page "
+ this.model.get('_id')
+ " " + this.model.get('_classes')
+ " " + this.setVisibility();
return "page " +
this.model.get('_id') +
" " + this.model.get('_classes') +
" " + this.setVisibility();
},

preRender: function() {
Expand Down Expand Up @@ -51,4 +51,4 @@ define(function(require) {

return PageView;

});
});

0 comments on commit 7be8269

Please sign in to comment.