cedar 0.2.2.pre → 0.2.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf2950b665fbe82d9d8ab1caccbc0d5edc85652b
4
- data.tar.gz: 3e78607fc3fd68a95cbcf05091938abd2c0744a4
3
+ metadata.gz: f7d74b293b2538cffefe506978bd5c83c6f7e125
4
+ data.tar.gz: bc52ad897fcc6eaa77dc2bf73b048fe3d58b8d8f
5
5
  SHA512:
6
- metadata.gz: 48ff2dc4745c1627f012426f956d1d171f2437de4fd3092f76482f230376bed99e21e1dd504f42e9ef9d547387525ad90296340894eb4795e4c8b01ebb06d2ff
7
- data.tar.gz: 269b10bb9838954318ada7681bd7d324ad8e0e1cb117c2c29988b70a98ac9e6e284b53fc8061846442ad1b3d72b6a66b9d97733e0184ed1d92fba099aee01eda
6
+ metadata.gz: ed3977de0160ec57f098be971cc9aab6ecc163cdd0cd84c326772051ff604d46b650b3c84927ab73a733f1998a5aa8875fc37684fcf1d857a489d61422852860
7
+ data.tar.gz: 60f2081e495fb9080b125e78c1bcc67f01ae4118d82848ce709bfb21e64db5583495f43dfe336eaadaf5274824c17f5046b87f82b43592e86c39230e870086b4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cedar (0.2.2.pre)
4
+ cedar (0.2.3.pre)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -53,6 +53,7 @@ Cedar.Application = function(options) {
53
53
  var defaults = {
54
54
  debug: false,
55
55
  fetch: true,
56
+ wait: false,
56
57
  forceHttps: false
57
58
  };
58
59
 
@@ -65,6 +66,12 @@ Cedar.Application = function(options) {
65
66
  Cedar.config.server = this.getProtocol() + this.options.server;
66
67
  Cedar.config.api = this.getProtocol() + this.options.server + '/api';
67
68
  Cedar.config.debug = this.options.debug;
69
+ Cedar.config.wait = this.options.wait;
70
+ Cedar.config.fetch = this.options.fetch;
71
+
72
+ if (typeof Cedar.$ === "undefined") {
73
+ Cedar.$ = jQuery({});
74
+ }
68
75
 
69
76
  if ( Cedar.store === null ) {
70
77
  Cedar.store = new Cedar.Store();
@@ -78,11 +85,28 @@ Cedar.Application = function(options) {
78
85
  this.showGlobalActions();
79
86
  }
80
87
 
81
- if (this.options.fetch) {
88
+ if (Cedar.config.fetch) {
82
89
  Cedar.store.fetched = Cedar.store.fetch();
83
90
  }
84
91
 
85
92
  Cedar.initialized = true;
93
+
94
+ this.initializeHTML()
95
+ }
96
+
97
+ Cedar.Application.prototype.initializeHTML = function() {
98
+ $('[data-cedar-id]').each(function(){
99
+ var $this = $(this);
100
+ $this.data("cedarObject", new Cedar.ContentEntry({
101
+ el: this,
102
+ cedarId: $this.data("cedarId")
103
+ }));
104
+
105
+ Cedar.$.on("content:loaded", function() {
106
+ $this.data("cedarObject").render();
107
+ }.bind(this));
108
+ });
109
+ Cedar.$.trigger("content:loaded");
86
110
  }
87
111
 
88
112
  Cedar.Application.prototype.getProtocol = function() {
@@ -138,7 +162,10 @@ Cedar.Auth.prototype.getLogOffURL = function() {
138
162
  Cedar.Auth.prototype.removeURLParameter = function(url, parameter) {
139
163
  var splitUrl = url.split('#');
140
164
  var serverUrl = splitUrl[0];
141
- var clientUrl = splitUrl[1];
165
+ var clientUrl = splitUrl[1] || '';
166
+ if (clientUrl) {
167
+ clientUrl = '#' + clientUrl;
168
+ }
142
169
  //prefer to use l.search if you have a location/link object
143
170
  var splitServerUrl= serverUrl.split('?');
144
171
  if (splitServerUrl.length>=2) {
@@ -158,7 +185,7 @@ Cedar.Auth.prototype.removeURLParameter = function(url, parameter) {
158
185
  if (pars.length > 0) {
159
186
  updatedServerUrl += '?'+pars.join('&');
160
187
  }
161
- return updatedServerUrl + "#" + clientUrl;
188
+ return updatedServerUrl + clientUrl;
162
189
  } else {
163
190
  return url;
164
191
  }
@@ -202,11 +229,14 @@ Cedar.Store.prototype.get = function ( object, key ) {
202
229
  if ( object.apiGet() === null ) {
203
230
  throw 'Cedar Error: must provide api "get" path';
204
231
  }
205
- if (typeof localStorage[key] !== "undefined") {
232
+
233
+ if (Cedar.store.loaded || (object.hasLocalContent() && !Cedar.config.wait)) {
234
+ Cedar.debug("loaded in get: " + Cedar.store.loaded);
206
235
  Cedar.debug('get from cache: ' + key);
207
236
  return $.Deferred().resolve(localStorage[key]);
237
+
208
238
  } else {
209
- Cedar.debug('checking server...');
239
+ Cedar.debug("loaded: " + Cedar.store.loaded);
210
240
  return $.getJSON(Cedar.config.api + object.apiGet() + key, function(json) {
211
241
  Cedar.debug('get from server: ' + key);
212
242
  Cedar.store.put(key, json);
@@ -235,7 +265,9 @@ Cedar.Store.prototype.fetch = function ( options ) {
235
265
  this.clear();
236
266
  }
237
267
 
238
- return $.when(Cedar.store.checkData()).then( function() {
268
+ return $.when(Cedar.store.checkData()).then( function(response) {
269
+
270
+ Cedar.debug("fetch data check complete");
239
271
 
240
272
  if (Cedar.store.loaded) {
241
273
 
@@ -252,7 +284,9 @@ Cedar.Store.prototype.fetch = function ( options ) {
252
284
  Cedar.debug("storing: " + val.id);
253
285
  }
254
286
  });
287
+ Cedar.debug("setting loaded to true");
255
288
  Cedar.store.loaded = true;
289
+ Cedar.$.trigger("content:loaded");
256
290
  });
257
291
  }
258
292
 
@@ -295,15 +329,17 @@ Cedar.Store.prototype.getVersion = function() {
295
329
  */
296
330
  Cedar.Store.prototype.checkData = function() {
297
331
  Cedar.debug("checking version #" + Cedar.store.getVersion());
298
- return $.getJSON(Cedar.config.api + '/queries/status').done( function(json) {
332
+ return $.when($.getJSON(Cedar.config.api + '/queries/status'))
299
333
 
300
- if ( Cedar.store.getVersion() != json.settings.version ) {
301
- Cedar.debug('setting version: ' + json.settings.version);
334
+ .then( function(response) {
335
+ if ( Cedar.store.getVersion() != response.settings.version ) {
336
+ Cedar.debug('setting version: ' + response.settings.version);
302
337
  Cedar.store.loaded = false;
303
- Cedar.store.setVersion(json.settings.version);
304
- }
305
- else {
338
+ Cedar.store.setVersion(response.settings.version);
339
+ } else {
340
+ Cedar.debug("version is up to date");
306
341
  Cedar.store.loaded = true;
342
+ Cedar.$.trigger("content:loaded");
307
343
  }
308
344
  });
309
345
  }
@@ -321,7 +357,7 @@ Cedar.Store.prototype.checkData = function() {
321
357
  */
322
358
  Cedar.ContentEntry = function(options) {
323
359
  var defaults = {
324
- el: 'div'
360
+ el: '<div />'
325
361
  };
326
362
 
327
363
  this.options = $.extend( {}, defaults, options );
@@ -347,20 +383,35 @@ Cedar.ContentEntry.prototype.apiList = function() {
347
383
  return 'guidlist';
348
384
  };
349
385
 
386
+ Cedar.ContentEntry.prototype.hasLocalContent = function() {
387
+ if (typeof this.localContentExists === "undefined") {
388
+ var content = localStorage[this.cedarId];
389
+ this.localContentExists = false;
390
+ if (typeof content !== "undefined") {
391
+ var json = JSON.parse(content);
392
+ if (typeof json.id !== "undefined") {
393
+ this.localContentExists = true;
394
+ }
395
+ }
396
+ }
397
+ return this.localContentExists;
398
+ }
399
+
350
400
  /**
351
401
  * parse the json for content and set this object's content
352
402
  *
353
403
  * @param <json>
354
404
  */
355
- Cedar.ContentEntry.prototype.setContent = function(json) {
356
- if (typeof json === 'undefined') return;
357
- if (json.code == 'UNKNOWN_ID'){
358
- this.content = '&nbsp;'; // if an element is new, fill with blank space to allow edit box to display
359
- }
360
- else if (typeof json.settings.content !== 'undefined') {
361
- this.content = json.settings.content;
405
+ Cedar.ContentEntry.prototype.setContent = function(data) {
406
+ if (typeof data === 'undefined') return;
407
+ if (typeof data === 'string') {
408
+ data = JSON.parse(data);
362
409
  }
363
- else {
410
+ if (data.code == 'UNKNOWN_ID'){
411
+ this.content = '';
412
+ } else if (typeof data.settings.content !== 'undefined') {
413
+ this.content = data.settings.content;
414
+ } else {
364
415
  this.content = '';
365
416
  Cedar.debug('Cedar Error: Unable to parse json');
366
417
  }
@@ -410,8 +461,7 @@ Cedar.ContentEntry.prototype.toJSON = function(){
410
461
  Cedar.ContentEntry.prototype.fill = function(element) {
411
462
  if (typeof element !== 'undefined') {
412
463
  $(element).html(this.getContent());
413
- }
414
- else if (typeof this.$el !== 'undefined') {
464
+ } else if (typeof this.$el !== 'undefined') {
415
465
  this.$el.html(this.getContent());
416
466
  }
417
467
  }
@@ -419,13 +469,10 @@ Cedar.ContentEntry.prototype.fill = function(element) {
419
469
  * check store for this object's content
420
470
  */
421
471
  Cedar.ContentEntry.prototype.retrieve = function() {
422
- return Cedar.store.get(this, this.cedarId).then(function(response) {
423
- if (typeof response === 'string') {
424
- response = JSON.parse(response);
425
- }
426
- this.setContent(response);
427
- return this;
428
- }.bind(this));
472
+ return Cedar.store.get(this, this.cedarId).then(function(response) {
473
+ this.setContent(response);
474
+ return this;
475
+ }.bind(this));
429
476
  }
430
477
  /**
431
478
  * retrive and fill the associated element
@@ -435,6 +482,7 @@ Cedar.ContentEntry.prototype.render = function() {
435
482
  this.fill();
436
483
  }.bind(this));
437
484
  }
485
+
438
486
  /**
439
487
  * provides styling for edit box
440
488
  */
@@ -4,32 +4,44 @@
4
4
  **/
5
5
 
6
6
  .cedar-cms-editable {
7
- position: relative;
7
+ position: relative !important;
8
8
  display: inline-block !important;
9
- min-height: 22px;
9
+ min-width: 22px !important;
10
+ min-height: 22px !important;
10
11
  vertical-align: middle;
11
-
12
- &:before {
13
- content: "";
14
- position: absolute;
15
- top: 0;
16
- left: 0;
17
- width: 100%;
18
- height: 100%;
19
- border: 1px dotted #F65126 !important;
20
- box-sizing: border-box;
21
- }
12
+ font-size: inherit !important;
13
+ color: inherit !important;
14
+ background: inherit !important;
15
+ width: auto !important;
16
+ height: auto !important;
17
+ margin: 0 !important;
22
18
  }
23
19
 
24
- .cedar-cms-edit-tools {
25
- font-family: Arial, sans-serif;
20
+ .cedar-cms-editable:before {
21
+ content: "";
26
22
  position: absolute;
27
23
  top: 0;
28
- right: -18px;
24
+ left: 0;
25
+ width: 100%;
26
+ height: 100%;
27
+ border: 1px dotted #F65126 !important;
28
+ box-sizing: border-box;
29
+ }
30
+
31
+ .cedar-cms-edit-tools {
32
+ font-family: Arial, sans-serif !important;
33
+ position: absolute !important;
34
+ top: 0 !important;
35
+ right: -18px !important;
29
36
  display: block !important;
30
37
  font-size: 10px !important;
31
38
  line-height: 1.2 !important;
32
39
  text-align: left !important;
40
+ float: none !important;
41
+ background: none !important;
42
+ margin: 0 !important;
43
+ height: 22px !important;
44
+ z-index: 9;
33
45
  }
34
46
 
35
47
  .cedar-cms-edit-tools a {
@@ -96,13 +108,15 @@
96
108
  position: absolute;
97
109
  top: 0;
98
110
  right: 0;
111
+ text-align: left !important;
99
112
  }
100
113
  .cedar-cms-global-action {
101
- display: inline-block;
114
+ display: inline-block !important;
102
115
  color: #F65126 !important;
103
- background: #FFF;
104
- line-height: 18px;
105
- padding: 3px 4px 3px 3px;
116
+ background: #FFF !important;
117
+ line-height: 18px !important;
118
+ padding: 3px 4px 3px 3px !important;
119
+ text-decoration: none !important;
106
120
  }
107
121
  .cedar-cms-global-action * {
108
122
  vertical-align: top;
@@ -1,3 +1,3 @@
1
1
  module Cedar
2
- VERSION = "0.2.2.pre"
2
+ VERSION = "0.2.3.pre"
3
3
  end
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.2.pre
4
+ version: 0.2.3.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-04-10 00:00:00.000000000 Z
11
+ date: 2015-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler