2011-11-21 01:27:05 +00:00
|
|
|
class Locomotive.Models.Page extends Backbone.Model
|
|
|
|
|
2011-11-25 01:04:42 +00:00
|
|
|
paramRoot: 'page'
|
|
|
|
|
2012-01-14 13:54:01 +00:00
|
|
|
urlRoot: "#{Locomotive.mounted_on}/pages"
|
2011-11-25 01:04:42 +00:00
|
|
|
|
2011-11-21 01:27:05 +00:00
|
|
|
initialize: ->
|
2011-11-25 01:04:42 +00:00
|
|
|
@_normalize()
|
|
|
|
|
2012-01-17 11:05:39 +00:00
|
|
|
@set
|
|
|
|
edit_url: "#{Locomotive.mounted_on}/pages/#{@id}/edit"
|
|
|
|
|
2011-11-25 01:04:42 +00:00
|
|
|
_normalize: ->
|
2011-11-21 01:27:05 +00:00
|
|
|
@set
|
2012-02-04 01:10:55 +00:00
|
|
|
editable_elements: new Locomotive.Models.EditableElementsCollection(@get('editable_elements') || [])
|
2011-11-21 01:27:05 +00:00
|
|
|
|
2011-11-25 01:04:42 +00:00
|
|
|
toJSON: ->
|
|
|
|
_.tap super, (hash) =>
|
2012-03-22 18:20:31 +00:00
|
|
|
_.each ['content_type_id_text', 'edit_url', 'parent_id_text', 'response_type_text'], (key) => delete hash[key]
|
2012-02-04 01:10:55 +00:00
|
|
|
|
|
|
|
delete hash['editable_elements']
|
|
|
|
hash.editable_elements = @get('editable_elements').toJSONForSave() if @get('editable_elements')? && @get('editable_elements').length > 0
|
2011-11-25 01:04:42 +00:00
|
|
|
|
2012-02-09 23:57:57 +00:00
|
|
|
delete hash['target_klass_name']
|
|
|
|
hash.target_klass_name = @get('target_klass_name') if @get('templatized') == true
|
|
|
|
|
2011-11-21 01:27:05 +00:00
|
|
|
class Locomotive.Models.PagesCollection extends Backbone.Collection
|