jsharmony-cms 1.8.2 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,7 +74,8 @@ exports = module.exports = function(jsh, cms, toolbarContainer){
74
74
  branding: false,
75
75
  browser_spellcheck: true,
76
76
  valid_elements: '+*[*],#p[*]',
77
- valid_children: '+h1[p],+h2[p],+h3[p],+h4[p],+h5[p],+h6[p]',
77
+ valid_children: '+h1[p],+h2[p],+h3[p],+h4[p],+h5[p],+h6[p],+body[style],+div[style],+p[style]',
78
+ extended_valid_elements: 'script[language|type|src|async|defer|charset],style[type]',
78
79
  entity_encoding: 'numeric',
79
80
  plugins: [
80
81
  'advlist autolink autoresize lists link image charmapmaterialicons anchor',
@@ -23,6 +23,7 @@ exports = module.exports = function(jsh, cms){
23
23
  var _ = jsh._;
24
24
 
25
25
  this.editorBarDocked = true;
26
+ this.pageElements = [];
26
27
  this.origMarginTop = [];
27
28
  this.origMarginTopLoaded = false;
28
29
  this.currentOffsetTop = 0;
@@ -83,6 +84,7 @@ exports = module.exports = function(jsh, cms){
83
84
  var jelem = $(elem);
84
85
  var offsetId = jelem.attr('cms-toolbar-offsetid');
85
86
  if(typeof offsetId != 'undefined'){
87
+ _this.pageElements[offsetId] = elem;
86
88
  if(!options.refreshExisting) return;
87
89
  }
88
90
  else if(jelem.parent().closest('[cms-content-editor]').length) return;
@@ -96,6 +98,7 @@ exports = module.exports = function(jsh, cms){
96
98
  jelem.attr('cms-toolbar-offsetid', offsetId);
97
99
  }
98
100
  _this.origMarginTop[offsetId] = computedStyles.marginTop;
101
+ _this.pageElements[offsetId] = elem;
99
102
  }
100
103
  });
101
104
  if(!options.preload) _this.origMarginTopLoaded = true;
@@ -115,6 +118,30 @@ exports = module.exports = function(jsh, cms){
115
118
  return computedStyles.marginTop;
116
119
  };
117
120
 
121
+ function elementIsValid(obj){
122
+ var parentNode = obj;
123
+ var lastNode = null;
124
+ while(parentNode){
125
+ if(_.includes(['BODY','HTML'], (parentNode.nodeName||'').toUpperCase())) return true;
126
+ lastNode = parentNode;
127
+ parentNode = parentNode.parentNode;
128
+ if(lastNode == parentNode) return false;
129
+ }
130
+ return true;
131
+ }
132
+
133
+ this.getPageElement = function(offsetId){
134
+ let jelem = null;
135
+ if(elementIsValid(_this.pageElements[offsetId])){
136
+ jelem = $(_this.pageElements[offsetId]);
137
+ }
138
+ else{
139
+ jelem = $('[cms-toolbar-offsetid='+offsetId.toString()+']');
140
+ if(jelem.length) _this.pageElements[offsetId] = jelem[0];
141
+ }
142
+ return jelem;
143
+ };
144
+
118
145
  this.refreshOffsets = function(options){
119
146
  options = _.extend({ addNewOffsets: false }, options);
120
147
  if(!_this.origMarginTopLoaded) return;
@@ -127,7 +154,7 @@ exports = module.exports = function(jsh, cms){
127
154
  var startingOffsets = [];
128
155
  for(let i=0;i<_this.origMarginTop.length;i++){
129
156
  if(_this.origMarginTop[i] === null) continue;
130
- let jelem = $('[cms-toolbar-offsetid='+i.toString()+']');
157
+ let jelem = _this.getPageElement(i);
131
158
  if(jelem.length){
132
159
  let elemIsBody = (jelem[0].tagName=='BODY');
133
160
  //Fixed elements need to subtract scrollTop from offset().top
@@ -141,7 +168,7 @@ exports = module.exports = function(jsh, cms){
141
168
  //Apply offsets
142
169
  for(let i=0;i<_this.origMarginTop.length;i++){
143
170
  if(_this.origMarginTop[i] === null) continue;
144
- let jelem = $('[cms-toolbar-offsetid='+i.toString()+']');
171
+ let jelem = _this.getPageElement(i);
145
172
  if(jelem.length){
146
173
  let elemIsBody = (jelem[0].tagName=='BODY');
147
174
  if(offsetTop){
@@ -154,11 +181,11 @@ exports = module.exports = function(jsh, cms){
154
181
  }
155
182
  else {
156
183
  var newMarginTop = _this.origMarginTop[i] ? 'calc(' + _this.origMarginTop[i] + ' + ' + offsetTop + 'px)' : offsetTop+'px';
157
- $('[cms-toolbar-offsetid='+i.toString()+']').css('marginTop', newMarginTop);
184
+ jelem.css('marginTop', newMarginTop);
158
185
  }
159
186
  }
160
187
  else {
161
- $('[cms-toolbar-offsetid='+i.toString()+']').css('marginTop', _this.origMarginTop[i]);
188
+ jelem.css('marginTop', _this.origMarginTop[i]);
162
189
  }
163
190
  //If changing body offset
164
191
  if(scrollTop && elemIsBody){
@@ -173,7 +173,7 @@
173
173
  "unique": [
174
174
  ["sys_user_id", "site_id"]
175
175
  ],
176
- "dependencies": ["{schema}.branch"],
176
+ "dependencies": ["{schema}.branch","{schema}.site"],
177
177
  "triggers": [
178
178
  { "on": ["validate_update", "validate_insert"], "exec": [
179
179
  "errorif((inserted(sys_user_site_editor) is not null and inserted(sys_user_site_editor) not in (select deployment_target_id from {schema}.v_my_deployment_target where deployment_target_can_editor = 1 and site_id = inserted(site_id))),'Target Editor not available for this site')",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsharmony-cms",
3
- "version": "1.8.2",
3
+ "version": "1.9.1",
4
4
  "description": "jsHarmony CMS",
5
5
  "main": "index.js",
6
6
  "scripts": {