diff options
| author | mo <mokha@cisco.com> | 2017-09-02 14:48:43 -0600 |
|---|---|---|
| committer | mo <mokha@cisco.com> | 2017-09-02 14:48:43 -0600 |
| commit | b8dfe131c6c5fe9d0e5b4ee2d271feeb5d411502 (patch) | |
| tree | 05b475a8b6442e2a43d9529c42362a3460df7d13 /app/assets/javascripts/backbone/models | |
| parent | bba21d02643d632fee5fa4bdbc876d44832ccf4b (diff) | |
promote backbone subdirectory up to root.
Diffstat (limited to 'app/assets/javascripts/backbone/models')
6 files changed, 0 insertions, 129 deletions
diff --git a/app/assets/javascripts/backbone/models/.gitkeep b/app/assets/javascripts/backbone/models/.gitkeep deleted file mode 100644 index e69de29b..00000000 --- a/app/assets/javascripts/backbone/models/.gitkeep +++ /dev/null diff --git a/app/assets/javascripts/backbone/models/cake.js.coffee b/app/assets/javascripts/backbone/models/cake.js.coffee deleted file mode 100644 index 7f925394..00000000 --- a/app/assets/javascripts/backbone/models/cake.js.coffee +++ /dev/null @@ -1,27 +0,0 @@ -class CakeSide.Models.Cake extends Backbone.Model - paramRoot: 'cake' - - defaults: - id: null - name: null - story: null - created_at: null - updated_at: null - category_id: null - - validate: (attributes, options) -> - return "Name can't be blank" unless attributes.name && attributes.name.trim() - return "Category can't be blank" unless attributes.category_id - - photos: -> - CakeSide.Application.request('PhotosRepository', @id) - - public_url: -> - "#{window.location.origin}/creations/#{@get('slug')}" - - category_id: -> - @get('category_id') || @get('category').id - -class CakeSide.Collections.CakesCollection extends Backbone.Collection - model: CakeSide.Models.Cake - url: '/api/v1/cakes' diff --git a/app/assets/javascripts/backbone/models/category.js.coffee b/app/assets/javascripts/backbone/models/category.js.coffee deleted file mode 100644 index 98437966..00000000 --- a/app/assets/javascripts/backbone/models/category.js.coffee +++ /dev/null @@ -1,10 +0,0 @@ -class CakeSide.Models.Category extends Backbone.Model - paramRoot: 'category' - - defaults: - name: null - slug: null - -class CakeSide.Collections.CategoriesCollection extends Backbone.Collection - model: CakeSide.Models.Category - url: '/api/v1/categories' diff --git a/app/assets/javascripts/backbone/models/photo.js.coffee b/app/assets/javascripts/backbone/models/photo.js.coffee deleted file mode 100644 index eb1cff76..00000000 --- a/app/assets/javascripts/backbone/models/photo.js.coffee +++ /dev/null @@ -1,30 +0,0 @@ -class CakeSide.Models.Photo extends Backbone.Model - paramRoot: 'photo' - fileAttribute: 'image' - - defaults: - id: null - cake_id: null - content_type: null - original_filename: null - thumb_url: null - large_url: null - original_url: null - created_at: null - updated_at: null - - initialize: (options) -> - @set('cake_id', options.cake_id) - if options.id - @url="/api/v1/cakes/#{options.cake_id}/photos/#{options.id}" - else - @url="/api/v1/cakes/#{options.cake_id}/photos" - - super(options) - -class CakeSide.Collections.PhotosCollection extends Backbone.Collection - model: CakeSide.Models.Photo - - initialize: (options) -> - @set('cake_id', options.cake_id) - @url="/api/v1/cakes/#{options.cake_id}/photos" diff --git a/app/assets/javascripts/backbone/models/profile.js.coffee b/app/assets/javascripts/backbone/models/profile.js.coffee deleted file mode 100644 index 189d83e4..00000000 --- a/app/assets/javascripts/backbone/models/profile.js.coffee +++ /dev/null @@ -1,38 +0,0 @@ -class CakeSide.Models.Profile extends Backbone.Model - paramRoot: 'profile' - urlRoot: '/api/v1/profiles' - modelEvents: - "change": "render" - - defaults: - id: null - name: null - email: null - city: null - website: null - facebook: null - twitter: null - - validate: (attributes, options) -> - return "Name can't be blank" unless attributes.name && attributes.name.trim() - return "Email can't be blank" unless attributes.email && attributes.email.trim() - return "Email is invalid" unless @validateEmail(attributes.email) - return "URL is invalid" if attributes.website && !@validateUrl(attributes.website) - return "Twitter handle is invalid" if !@validateTwitter(attributes.twitter) - - validateEmail: (email) -> - regex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ - regex.test(email) - - validateUrl: (url) -> - regex = new RegExp( "^" + "(?:(?:https?|ftp)://)" + "(?:\\S+(?::\\S*)?@)?" + "(?:" + "(?!(?:10|127)(?:\\.\\d{1,3}){3})" + "(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" + "(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})" + "(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" + "(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" + "(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" + "|" + "(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)" + "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*" + "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))" + ")" + "(?::\\d{2,5})?" + "(?:/\\S*)?" + "$", "i") - regex.test(url) - - validateTwitter: (twitter) -> - return true unless twitter - regex = /^@?(\w){1,15}$/ - regex.test(twitter) - -class CakeSide.Collections.ProfilesCollection extends Backbone.Collection - model: CakeSide.Models.Profile - url: '/api/v1/profiles' diff --git a/app/assets/javascripts/backbone/models/tutorials.js.coffee b/app/assets/javascripts/backbone/models/tutorials.js.coffee deleted file mode 100644 index 9e2e8a1f..00000000 --- a/app/assets/javascripts/backbone/models/tutorials.js.coffee +++ /dev/null @@ -1,24 +0,0 @@ -class CakeSide.Models.Tutorial extends Backbone.Model - paramRoot: 'tutorial' - - defaults: - id: null - url: null - image_url: null - heading: null - description: null - - validate: (attributes, options) -> - return "Invalid Url." unless @isValidUrl(attributes.url || '') - return "This tutorial has no photos." unless @hasImage(attributes.image_url) - - isValidUrl: (url) -> - expression = /[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi; - url.match(new RegExp(expression)) - - hasImage: (image_url) -> - image_url - -class CakeSide.Collections.TutorialsCollection extends Backbone.Collection - model: CakeSide.Models.Tutorial - url: '/api/v1/tutorials' |
