cedar 0.2.82.pre → 0.2.89.pre
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.
- checksums.yaml +4 -4
- data/lib/assets/javascripts/cedar.js +1 -0
- data/lib/assets/javascripts/cedar_admin.js +152 -0
- data/lib/assets/javascripts/cedar_handlebars.js +8 -2
- data/lib/assets/javascripts/cedar_source.js +19 -115
- data/lib/assets/stylesheets/cedar_source.scss +12 -1
- data/lib/cedar/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61cd279be961e3cd97cad704240677073eacd27d
|
4
|
+
data.tar.gz: 1f3d0e661c90041381875e2495670faeef9a5d17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fd8439a3a20c9ac3fa86cd8fc258e6fc671ff074e5fe12f0577cff47a1db979cbf2c24339806c7b112ae92167b9604b716fc3508b561de99ab2097bdb6ca384
|
7
|
+
data.tar.gz: 70d27a853e183c1585b6c467f58ef361cb4b144043010db5d3f52e99c0e5500e245e700dfdf163124561038d49a91fcf9097ac6c74abb975a7d4064afb79ecff
|
@@ -0,0 +1,152 @@
|
|
1
|
+
window.Cedar = window.Cedar || {};
|
2
|
+
|
3
|
+
Cedar.Admin = function() {
|
4
|
+
if (this.isEditMode()) {
|
5
|
+
this.showGlobalActions();
|
6
|
+
}
|
7
|
+
|
8
|
+
this.scanDOM();
|
9
|
+
this.observeDOM('body', _.bind(function() {
|
10
|
+
this.scanDOM();
|
11
|
+
}, this));
|
12
|
+
};
|
13
|
+
|
14
|
+
Cedar.Admin.prototype.scanDOM = function() {
|
15
|
+
var cedarClass = "cedar-cms-editable";
|
16
|
+
if (this.isEditMode()) {
|
17
|
+
$('[data-cedar-type]').each(_.bind(function(index, el){
|
18
|
+
var $el = $(el);
|
19
|
+
if (!$el.hasClass(cedarClass)) {
|
20
|
+
var editTools = $(this.getEditTools($el.data()));
|
21
|
+
$el.prepend(editTools);
|
22
|
+
$el.addClass(cedarClass + " clearfix");
|
23
|
+
}
|
24
|
+
}, this));
|
25
|
+
}
|
26
|
+
};
|
27
|
+
|
28
|
+
Cedar.Admin.prototype.observeDOM = function(selector, callback) {
|
29
|
+
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
30
|
+
if (MutationObserver){
|
31
|
+
var observer = new MutationObserver(function(mutations, observer) {
|
32
|
+
if (mutations[0].addedNodes.length || mutations[0].removedNodes.length) {
|
33
|
+
observer.disconnect();
|
34
|
+
callback();
|
35
|
+
observer.observe($(selector)[0], { childList:true, subtree:true });
|
36
|
+
}
|
37
|
+
});
|
38
|
+
observer.observe($(selector)[0], { childList:true, subtree:true });
|
39
|
+
}
|
40
|
+
};
|
41
|
+
|
42
|
+
Cedar.Admin.prototype.isEditMode = function() {
|
43
|
+
return this.hasEditModeCookie() || this.hasEditModeUrl();
|
44
|
+
};
|
45
|
+
|
46
|
+
Cedar.Admin.prototype.hasEditModeUrl = function() {
|
47
|
+
var sPageURL = window.location.search.substring(1);
|
48
|
+
var sURLVariables = sPageURL.split('&');
|
49
|
+
var i = 0;
|
50
|
+
while (i < sURLVariables.length) {
|
51
|
+
if (sURLVariables[i] === 'cdrlogin') {
|
52
|
+
document.cookie = "cedarEditMode=";
|
53
|
+
return true;
|
54
|
+
}
|
55
|
+
i++;
|
56
|
+
}
|
57
|
+
return false;
|
58
|
+
};
|
59
|
+
|
60
|
+
Cedar.Admin.prototype.hasEditModeCookie = function() {
|
61
|
+
return (new RegExp("(?:^|;\\s*)cedarEditMode\\s*\\=")).test(document.cookie);
|
62
|
+
};
|
63
|
+
|
64
|
+
Cedar.Admin.prototype.showGlobalActions = function() {
|
65
|
+
$(document).ready(_.bind(function() {
|
66
|
+
var $body = $('body');
|
67
|
+
var globalActions = '<div class="cedar-cms-global-actions">' +
|
68
|
+
'<a class="cedar-cms-global-action js-cedar-cms-log-off" href="#">' +
|
69
|
+
'<span class="cedar-cms-icon cedar-cms-icon-nav"></span> ' +
|
70
|
+
'<span class="cedar-cms-global-action-label">Log Off</span>' +
|
71
|
+
'</a>' +
|
72
|
+
'</div>';
|
73
|
+
$body.append(globalActions);
|
74
|
+
$('.js-cedar-cms-log-off').on('click', _.bind(function(e) {
|
75
|
+
this.logOff(e);
|
76
|
+
}, this));
|
77
|
+
}, this));
|
78
|
+
};
|
79
|
+
|
80
|
+
Cedar.Admin.prototype.logOff = function(event) {
|
81
|
+
event.preventDefault();
|
82
|
+
document.cookie = "cedarEditMode=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
|
83
|
+
if (location.href === this.getLogOffURL()) {
|
84
|
+
location.reload(true);
|
85
|
+
} else {
|
86
|
+
window.location.href = this.getLogOffURL();
|
87
|
+
}
|
88
|
+
};
|
89
|
+
|
90
|
+
Cedar.Admin.prototype.getLogOffURL = function() {
|
91
|
+
return this.removeURLParameter(window.location.href, 'cdrlogin');
|
92
|
+
};
|
93
|
+
|
94
|
+
Cedar.Admin.prototype.getEditLink = function(options) {
|
95
|
+
var output = Cedar.config.server + '/cmsadmin/';
|
96
|
+
output += options.cedarType === 'ContentEntry' ? 'Edit' : 'Select';
|
97
|
+
output += 'Data?cdr=1&t=' + options.cedarType + '&o=' + encodeURIComponent(options.cedarId);
|
98
|
+
|
99
|
+
return output;
|
100
|
+
};
|
101
|
+
|
102
|
+
Cedar.Admin.prototype.getEditTools = function(options) {
|
103
|
+
var jsString = "if(event.stopPropagation){event.stopPropagation();}" +
|
104
|
+
"event.cancelBubble=true;" +
|
105
|
+
"window.location.href=this.attributes.href.value + \'&referer=' + encodeURIComponent(window.location.href) + '\';" +
|
106
|
+
"return false;";
|
107
|
+
|
108
|
+
var iconClass = options.cedarType === 'ContentEntry' ? 'edit' : 'list';
|
109
|
+
|
110
|
+
var block = '<span class="cedar-cms-edit-tools">';
|
111
|
+
block += '<a onclick="' + jsString + '" href="' + this.getEditLink(options) +
|
112
|
+
'" class="cedar-cms-edit-icon cedar-js-edit" >';
|
113
|
+
block += '<i class="cedar-cms-icon cedar-cms-icon-right cedar-cms-icon-' + iconClass + '"></i></a>';
|
114
|
+
block += '</span>';
|
115
|
+
return block;
|
116
|
+
};
|
117
|
+
|
118
|
+
// adapted from stackoverflow:
|
119
|
+
// http://stackoverflow.com/questions/1634748/how-can-i-delete-a-query-string-parameter-in-javascript
|
120
|
+
Cedar.Admin.prototype.removeURLParameter = function(url, parameter) {
|
121
|
+
var splitUrl = url.split('#');
|
122
|
+
var serverUrl = splitUrl[0];
|
123
|
+
var clientUrl = splitUrl[1] || '';
|
124
|
+
if (clientUrl) {
|
125
|
+
clientUrl = '#' + clientUrl;
|
126
|
+
}
|
127
|
+
// prefer to use l.search if you have a location/link object
|
128
|
+
var splitServerUrl= serverUrl.split('?');
|
129
|
+
if (splitServerUrl.length>=2) {
|
130
|
+
|
131
|
+
var prefix = encodeURIComponent(parameter); //+'=';
|
132
|
+
var pars = splitServerUrl[1].split(/[&;]/g);
|
133
|
+
|
134
|
+
//reverse iteration as may be destructive
|
135
|
+
var i = pars.length - 1;
|
136
|
+
while (i >= 0) {
|
137
|
+
// idiom for string.startsWith
|
138
|
+
if (pars[i].lastIndexOf(prefix, 0) !== -1) {
|
139
|
+
pars.splice(i, 1);
|
140
|
+
}
|
141
|
+
i--;
|
142
|
+
}
|
143
|
+
|
144
|
+
var updatedServerUrl= splitServerUrl[0];
|
145
|
+
if (pars.length > 0) {
|
146
|
+
updatedServerUrl += '?'+pars.join('&');
|
147
|
+
}
|
148
|
+
return updatedServerUrl + clientUrl;
|
149
|
+
} else {
|
150
|
+
return url;
|
151
|
+
}
|
152
|
+
};
|
@@ -1,3 +1,9 @@
|
|
1
|
+
if (_(Handlebars).isUndefined()) {
|
2
|
+
if (!_(Ember).isUndefined()) {
|
3
|
+
var Handlebars = Ember.Handlebars;
|
4
|
+
}
|
5
|
+
}
|
6
|
+
|
1
7
|
Handlebars.registerHelper('cedar', function(options) {
|
2
8
|
"use strict";
|
3
9
|
|
@@ -71,11 +77,11 @@ Handlebars.registerHelper('cedar', function(options) {
|
|
71
77
|
cedarObject.setContent(data);
|
72
78
|
|
73
79
|
if (blockHelperStyle()) {
|
74
|
-
if (Cedar.
|
80
|
+
if (Cedar.admin.isEditMode()) {
|
75
81
|
output += cedarObject.getEditOpen();
|
76
82
|
}
|
77
83
|
output += unescapeHtml(options.fn(cedarObject.toJSON()));
|
78
|
-
if (Cedar.
|
84
|
+
if (Cedar.admin.isEditMode()) {
|
79
85
|
output += cedarObject.getEditClose();
|
80
86
|
}
|
81
87
|
} else {
|
@@ -5,7 +5,7 @@ window.Cedar = window.Cedar || {};
|
|
5
5
|
window.Cedar = $.extend({}, window.Cedar, {
|
6
6
|
initialized: false,
|
7
7
|
store: null,
|
8
|
-
|
8
|
+
admin: null
|
9
9
|
});
|
10
10
|
window.Cedar.config = window.Cedar.config || {};
|
11
11
|
|
@@ -47,7 +47,8 @@ Cedar.Application = function(options) {
|
|
47
47
|
wait: false,
|
48
48
|
allowUnsecured: false,
|
49
49
|
objectNameFilter: '',
|
50
|
-
liveMode: true
|
50
|
+
liveMode: true,
|
51
|
+
initHTML: false
|
51
52
|
};
|
52
53
|
|
53
54
|
this.options = $.extend({}, $.extend({}, defaults, window.Cedar.config), options);
|
@@ -63,6 +64,7 @@ Cedar.Application = function(options) {
|
|
63
64
|
Cedar.config.fetch = this.options.fetch;
|
64
65
|
Cedar.config.objectNameFilter = this.options.objectNameFilter;
|
65
66
|
Cedar.config.liveMode = this.options.liveMode;
|
67
|
+
Cedar.config.initHTML = this.options.initHTML;
|
66
68
|
|
67
69
|
if (Cedar.events === undefined) {
|
68
70
|
Cedar.events = new Cedar.Events();
|
@@ -72,17 +74,15 @@ Cedar.Application = function(options) {
|
|
72
74
|
Cedar.store = new Cedar.Store();
|
73
75
|
}
|
74
76
|
|
75
|
-
if ( Cedar.
|
76
|
-
Cedar.
|
77
|
-
}
|
78
|
-
|
79
|
-
if (Cedar.auth.isEditMode()) {
|
80
|
-
this.showGlobalActions();
|
77
|
+
if ( Cedar.admin === null ) {
|
78
|
+
Cedar.admin = new Cedar.Admin();
|
81
79
|
}
|
82
80
|
|
83
81
|
Cedar.initialized = true;
|
84
82
|
|
85
|
-
|
83
|
+
if (Cedar.config.initHTML) {
|
84
|
+
this.initializeHTML();
|
85
|
+
}
|
86
86
|
};
|
87
87
|
|
88
88
|
Cedar.Application.prototype.initializeHTML = function() {
|
@@ -108,23 +108,6 @@ Cedar.Application.prototype.getProtocol = function() {
|
|
108
108
|
}
|
109
109
|
};
|
110
110
|
|
111
|
-
Cedar.Application.prototype.showGlobalActions = function() {
|
112
|
-
$(document).ready(function() {
|
113
|
-
var $body = $('body');
|
114
|
-
var globalActions = '<div class="cedar-cms-global-actions">' +
|
115
|
-
'<a href="#" class="cedar-cms-global-action" onclick="window.location.reload();">' +
|
116
|
-
'<span class="cedar-cms-icon cedar-cms-icon-edit"></span> ' +
|
117
|
-
'<span class="cedar-cms-global-action-label">Refresh</span>' +
|
118
|
-
'</a><br>' +
|
119
|
-
'<a class="cedar-cms-global-action" href="' + Cedar.auth.getLogOffURL() + '">' +
|
120
|
-
'<span class="cedar-cms-icon cedar-cms-icon-edit"></span> ' +
|
121
|
-
'<span class="cedar-cms-global-action-label">Log Off Cedar</span>' +
|
122
|
-
'</a>' +
|
123
|
-
'</div>';
|
124
|
-
$body.append(globalActions);
|
125
|
-
});
|
126
|
-
};
|
127
|
-
|
128
111
|
/**
|
129
112
|
* Cedar.Events
|
130
113
|
*/
|
@@ -144,73 +127,6 @@ Cedar.Events.prototype.on = function(eventName, eventCallback) {
|
|
144
127
|
document.addEventListener(eventName, eventCallback);
|
145
128
|
};
|
146
129
|
|
147
|
-
/**
|
148
|
-
* Cedar.Auth
|
149
|
-
*
|
150
|
-
* responsible for determining if we're in edit mode
|
151
|
-
*/
|
152
|
-
Cedar.Auth = function() {
|
153
|
-
return;
|
154
|
-
};
|
155
|
-
|
156
|
-
Cedar.Auth.prototype.isEditMode = function() {
|
157
|
-
return this.isEditUrl();
|
158
|
-
};
|
159
|
-
|
160
|
-
Cedar.Auth.prototype.isEditUrl = function() {
|
161
|
-
var sPageURL = window.location.search.substring(1);
|
162
|
-
var sURLVariables = sPageURL.split('&');
|
163
|
-
var i = 0;
|
164
|
-
while (i < sURLVariables.length) {
|
165
|
-
if (sURLVariables[i] === 'cdrlogin') {
|
166
|
-
return true;
|
167
|
-
}
|
168
|
-
i++;
|
169
|
-
}
|
170
|
-
return false;
|
171
|
-
};
|
172
|
-
|
173
|
-
Cedar.Auth.prototype.getLogOffURL = function() {
|
174
|
-
return this.removeURLParameter(window.location.href, 'cdrlogin');
|
175
|
-
};
|
176
|
-
|
177
|
-
// adapted from stackoverflow:
|
178
|
-
// http://stackoverflow.com/questions/1634748/how-can-i-delete-a-query-string-parameter-in-javascript
|
179
|
-
Cedar.Auth.prototype.removeURLParameter = function(url, parameter) {
|
180
|
-
var splitUrl = url.split('#');
|
181
|
-
var serverUrl = splitUrl[0];
|
182
|
-
var clientUrl = splitUrl[1] || '';
|
183
|
-
if (clientUrl) {
|
184
|
-
clientUrl = '#' + clientUrl;
|
185
|
-
}
|
186
|
-
// prefer to use l.search if you have a location/link object
|
187
|
-
var splitServerUrl= serverUrl.split('?');
|
188
|
-
if (splitServerUrl.length>=2) {
|
189
|
-
|
190
|
-
var prefix = encodeURIComponent(parameter); //+'=';
|
191
|
-
var pars = splitServerUrl[1].split(/[&;]/g);
|
192
|
-
|
193
|
-
//reverse iteration as may be destructive
|
194
|
-
var i = pars.length - 1;
|
195
|
-
while (i >= 0) {
|
196
|
-
// idiom for string.startsWith
|
197
|
-
if (pars[i].lastIndexOf(prefix, 0) !== -1) {
|
198
|
-
pars.splice(i, 1);
|
199
|
-
}
|
200
|
-
i--;
|
201
|
-
}
|
202
|
-
|
203
|
-
var updatedServerUrl= splitServerUrl[0];
|
204
|
-
if (pars.length > 0) {
|
205
|
-
updatedServerUrl += '?'+pars.join('&');
|
206
|
-
}
|
207
|
-
return updatedServerUrl + clientUrl;
|
208
|
-
} else {
|
209
|
-
return url;
|
210
|
-
}
|
211
|
-
};
|
212
|
-
|
213
|
-
|
214
130
|
/**
|
215
131
|
* Cedar.Store
|
216
132
|
*
|
@@ -267,12 +183,12 @@ Cedar.Store.prototype.get = function(type, attributes) {
|
|
267
183
|
|
268
184
|
// Retrieve the locally-stored model or collection if it exists
|
269
185
|
Cedar.Store.prototype.cachedObject = function(type, attributes) {
|
270
|
-
var cachedCollection =
|
186
|
+
var cachedCollection = (this.cache[type] && JSON.parse(this.cache[type]) || []);
|
271
187
|
var result;
|
272
188
|
if (attributes && attributes.hasOwnProperty('id')) {
|
273
|
-
result =
|
189
|
+
result = _.findWhere(cachedCollection, attributes);
|
274
190
|
} else {
|
275
|
-
result =
|
191
|
+
result = _.where(cachedCollection, attributes);
|
276
192
|
}
|
277
193
|
return result;
|
278
194
|
};
|
@@ -333,7 +249,7 @@ Cedar.Store.prototype.getRemote = function(options) {
|
|
333
249
|
path: options.path,
|
334
250
|
params: params,
|
335
251
|
success: function(response) {
|
336
|
-
_.
|
252
|
+
_.each(response, function(collection, type) {
|
337
253
|
this.putCollection(type, collection);
|
338
254
|
Cedar.debug("storing: " + type);
|
339
255
|
}.bind(this));
|
@@ -465,7 +381,7 @@ Cedar.ContentObject.prototype = {
|
|
465
381
|
},
|
466
382
|
|
467
383
|
toString: function() {
|
468
|
-
return Cedar.
|
384
|
+
return Cedar.admin.isEditMode() ? this.getContentWithEditTools() : this.getContent();
|
469
385
|
},
|
470
386
|
|
471
387
|
toJSON: function() {
|
@@ -477,22 +393,10 @@ Cedar.ContentObject.prototype = {
|
|
477
393
|
},
|
478
394
|
|
479
395
|
getEditOpen: function() {
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
var block = '<span class="cedar-cms-editable clearfix">';
|
486
|
-
block += '<span class="cedar-cms-edit-tools">';
|
487
|
-
block += '<a onclick="' + jsString + '" href="' + Cedar.config.server +
|
488
|
-
'/cmsadmin/EditData?cdr=1&t=' +
|
489
|
-
this.options.cedarType +
|
490
|
-
'&o=' +
|
491
|
-
encodeURIComponent(this.options.cedarId) +
|
492
|
-
'" class="cedar-cms-edit-icon cedar-js-edit" >';
|
493
|
-
block += '<i class="cedar-cms-icon cedar-cms-icon-right cedar-cms-icon-edit"></i></a>';
|
494
|
-
block += '</span>';
|
495
|
-
return block;
|
396
|
+
return '<span ' +
|
397
|
+
'data-cedar-type="' + this.options.cedarType + '" ' +
|
398
|
+
'data-cedar-id="' + this.options.cedarId + '" ' +
|
399
|
+
'>';
|
496
400
|
},
|
497
401
|
|
498
402
|
getEditClose: function() {
|
@@ -513,7 +417,7 @@ Cedar.ContentEntry.prototype = Object.create(Cedar.ContentObject.prototype);
|
|
513
417
|
Cedar.ContentEntry.prototype.constructor = Cedar.ContentEntry;
|
514
418
|
|
515
419
|
Cedar.ContentEntry.prototype.setContent = function(data) {
|
516
|
-
this.content = (data && data.content) || '';
|
420
|
+
this.content = (data && data.content) || (data && (data.settings && data.settings.content)) || '';
|
517
421
|
};
|
518
422
|
|
519
423
|
Cedar.ContentEntry.prototype.toJSON = function(data) {
|
@@ -16,6 +16,9 @@
|
|
16
16
|
height: auto !important;
|
17
17
|
margin: 0 !important;
|
18
18
|
}
|
19
|
+
div.cedar-cms-editable {
|
20
|
+
width: 100% !important;
|
21
|
+
}
|
19
22
|
|
20
23
|
.cedar-cms-editable:before {
|
21
24
|
content: "";
|
@@ -99,9 +102,15 @@
|
|
99
102
|
}
|
100
103
|
|
101
104
|
|
105
|
+
.cedar-cms-icon-nav {
|
106
|
+
background-position: -67px 0;
|
107
|
+
}
|
102
108
|
.cedar-cms-icon-edit {
|
103
109
|
background-position: -89px -20px;
|
104
110
|
}
|
111
|
+
.cedar-cms-icon-list {
|
112
|
+
background-position: -34px -40px;
|
113
|
+
}
|
105
114
|
|
106
115
|
/* Action Links */
|
107
116
|
.cedar-cms-global-actions {
|
@@ -109,13 +118,15 @@
|
|
109
118
|
top: 0;
|
110
119
|
right: 0;
|
111
120
|
text-align: left !important;
|
121
|
+
z-index: 1000000;
|
112
122
|
}
|
113
123
|
.cedar-cms-global-action {
|
114
124
|
display: inline-block !important;
|
115
125
|
color: #F65126 !important;
|
116
126
|
background: #FFF !important;
|
127
|
+
font-size: 14px !important;
|
117
128
|
line-height: 18px !important;
|
118
|
-
padding:
|
129
|
+
padding: 2px 8px 3px 3px !important;
|
119
130
|
text-decoration: none !important;
|
120
131
|
}
|
121
132
|
.cedar-cms-global-action * {
|
data/lib/cedar/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cedar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.89.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jed Murdock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- README.md
|
50
50
|
- lib/assets/images/cedar-display-tools-sprite.png
|
51
51
|
- lib/assets/javascripts/cedar.js
|
52
|
+
- lib/assets/javascripts/cedar_admin.js
|
52
53
|
- lib/assets/javascripts/cedar_config.js.erb
|
53
54
|
- lib/assets/javascripts/cedar_handlebars.js
|
54
55
|
- lib/assets/javascripts/cedar_source.js
|