caboose-cms 0.7.57 → 0.7.58

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: 58a87dfdd169104d0678ba85f750809c5ab12e86
4
- data.tar.gz: 09d6a88d924f0ee3ce3e953dc3e86187b770f7c1
3
+ metadata.gz: 48c0687d2fc45445501533250e2534d1c7d7cd68
4
+ data.tar.gz: e7a704b7df30b88850791b5923522598a26c6d8f
5
5
  SHA512:
6
- metadata.gz: 245adebb5a83caf5a7671a3a3cae2d7c10b0651447b493679a8459c32568e2fe1e9bca51b6ce01d9ea8bc82a6ae12568e5ebbb5d5d43f783bd8dc02f722e55f3
7
- data.tar.gz: 50d81237125c19672c000e71850ca3b3f8f725e54722440304c03c9b06e1fbbf720742ca7ce567556d30d93221c12ffad3489408717d16635339b33256b0a30b
6
+ metadata.gz: 812da735cddcdeaff96d6f4a9e8bc253612c386ad7ff3f27643809fddf041b5ac26f6dea963d4c079be516a111558e98db56315f1cca55110e74077be62f284f
7
+ data.tar.gz: 3702ebd31ab65e0ca6ce6a21970a3fbfdef79cab71ca117e8b6bc0ec53b70cc3eba80fb398f5fce32b3a6fb8a8630b68d4e37e5d4532cb4dae799f9b567f971f
@@ -275,16 +275,10 @@ MediaController.prototype = {
275
275
  }
276
276
  if (that.selected_media.indexOf(m.id) > -1)
277
277
  li.addClass('selected ui-selected');
278
- if (that.allow_edit && m.image_urls) {
279
- li.append($("<a/>")
280
- .html("Edit Image")
281
- .click(function() { that.edit_image($(this).parent().data('media_id')); })
282
- );
283
- }
284
- if ( m.image_urls )
285
- li.append($("<a/>").addClass("dl i").html("Download").click(function() { that.download_image($(this).parent().data('media_id')); }));
286
- else
287
- li.append($("<a/>").addClass("dl").html("Download").click(function() { that.download_image($(this).parent().data('media_id')); }));
278
+ if (that.allow_edit && m.image_urls) li.append($("<a/>").html("Edit Image").click(function() { that.edit_image($(this).parent().data('media_id')); }));
279
+ else li.append($("<a/>").attr('href', m.file_url).html("Direct URL"));
280
+ if ( m.image_urls ) li.append($("<a/>").addClass("dl i").html("Download").click(function() { that.download_image($(this).parent().data('media_id')); }));
281
+ else li.append($("<a/>").addClass("dl").html("Download").click(function() { that.download_image($(this).parent().data('media_id')); }));
288
282
  ul.append(li);
289
283
  });
290
284
  }
@@ -504,16 +498,22 @@ MediaController.prototype = {
504
498
  return m;
505
499
  },
506
500
 
507
- download_image: function(media_id) {
501
+ download_image: function(media_id) {
502
+ var that = this;
503
+ url = that.download_url(media_id);
504
+ window.open(url);
505
+ },
506
+
507
+ download_url: function(media_id) {
508
508
  var that = this;
509
509
  var m = that.media_with_id(media_id);
510
510
  var url = '';
511
511
  if ( m.image_urls )
512
512
  url = m.image_urls.original_url;
513
513
  else
514
- url = m.file_url
515
- window.open(url);
516
- },
514
+ url = m.file_url;
515
+ return url;
516
+ },
517
517
 
518
518
  //============================================================================
519
519
  // Aviary
@@ -7,7 +7,7 @@ var Attribute = function(params) {
7
7
  this.value_clean = this.value;
8
8
  };
9
9
 
10
- Attribute.prototype = {
10
+ Attribute.prototype = {
11
11
  name: false,
12
12
  nice_name: false,
13
13
  type: false,
@@ -53,7 +53,7 @@ Attribute.prototype = {
53
53
  this2.value_clean = this2.value;
54
54
  }
55
55
  if (after) after(resp);
56
- if (this2.after_update) this2.after_update();
56
+ if (this2.after_update) this2.after_update(this2);
57
57
  },
58
58
  error: function() {
59
59
  if (after) after(false);
@@ -34,6 +34,28 @@ ModelBinder.tinymce_current_control = function() {
34
34
  return ModelBinder.tinymce_control(id);
35
35
  };
36
36
 
37
+ ModelBinder.find_control = function(model_name, model_id, attribute_name) {
38
+ var control = false;
39
+ $.each(all_model_binders, function(i, mb) {
40
+ if (mb.model.name == model_name && mb.model.id == model_id) {
41
+ $.each(mb.controls, function(i, c) {
42
+ if (c.attribute.name == attribute_name) { control = c; return false; }
43
+ });
44
+ }
45
+ if (control) return false;
46
+ });
47
+ return control;
48
+ };
49
+
50
+ ModelBinder.repopulate_options_for_control = function(model_name, model_id, attribute_name) {
51
+ var control = ModelBinder.find_control(model_name, model_id, attribute_name);
52
+ if (control)
53
+ {
54
+ control.attribute.options = false;
55
+ control.init({});
56
+ }
57
+ };
58
+
37
59
  //==============================================================================
38
60
 
39
61
  ModelBinder.options = {};
@@ -75,29 +97,26 @@ ModelBinder.prototype = {
75
97
  options: {},
76
98
 
77
99
  init: function(params) {
78
- this.model = new Model({
100
+ var that = this;
101
+ that.model = new Model({
79
102
  name: params['name'],
80
103
  id: params['id'],
81
104
  attributes: [],
82
105
  attributes_clean: []
83
106
  });
84
- if (params['update_url']) this.model.update_url = params['update_url'];
85
- if (params['success']) this.success = params['success'];
86
- if (params['authenticity_token']) this.authenticity_token = params['authenticity_token'];
87
- if (params['on_load']) this.on_load = params['on_load'];
88
-
89
- var m = this.model;
90
- $.each(params['attributes'], function(i, attrib) {
91
- m.attributes[m.attributes.length] = new Attribute(attrib);
92
- });
93
- //this.model.populate_options();
107
+ if (params['update_url']) that.model.update_url = params['update_url'];
108
+ if (params['success']) that.success = params['success'];
109
+ if (params['authenticity_token']) that.authenticity_token = params['authenticity_token'];
110
+ if (params['on_load']) that.on_load = params['on_load'];
94
111
 
95
- var this2 = this;
96
- $.each(this.model.attributes, function(i, attrib) {
112
+ $.each(params['attributes'], function(i, attrib) {
113
+ that.model.attributes[that.model.attributes.length] = new Attribute(attrib);
114
+ });
115
+ $.each(that.model.attributes, function(i, attrib) {
97
116
  var opts = {
98
- model: this2.model,
117
+ model: that.model,
99
118
  attribute: attrib,
100
- binder: this2
119
+ binder: that
101
120
  };
102
121
  var control = false;
103
122
 
@@ -119,21 +138,29 @@ ModelBinder.prototype = {
119
138
  control_class = "";
120
139
  $.each(attrib.type.split('-'), function(j, word) { control_class += word.charAt(0).toUpperCase() + word.toLowerCase().slice(1); });
121
140
  control = eval("new Bound" + control_class + "(opts)");
122
- }
123
-
124
- this2.controls.push(control);
141
+ }
142
+ that.controls.push(control);
125
143
  });
126
144
 
127
- if (this.on_load)
128
- this.on_load();
145
+ if (that.on_load)
146
+ that.on_load();
129
147
  },
130
148
 
149
+ reinit: function(control_id)
150
+ {
151
+ console.log('Reinitializing ' + control_id + '...');
152
+ var that = this;
153
+ var c = that.control_with_id(control_id);
154
+ console.log(c);
155
+ if (c) c.init({});
156
+ },
157
+
131
158
  control_with_id: function(id)
132
159
  {
133
160
  var control = false
134
- var this2 = this;
161
+ var that = this;
135
162
  $.each(this.controls, function(i, c) {
136
- if (id == (this2.model.name + "_" + this2.model.id + "_" + c.attribute.name).toLowerCase())
163
+ if (id == (that.model.name + "_" + that.model.id + "_" + c.attribute.name).toLowerCase())
137
164
  {
138
165
  control = c;
139
166
  return false;
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.7.57'
2
+ VERSION = '0.7.58'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.57
4
+ version: 0.7.58
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg