frontendeditor 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 02774b3e3d1a9110d10bbfe3d87c3ff4b2b1ff71
4
+ data.tar.gz: 6dfedb085ca9f8c20d72ca2806432ca1cc54e281
5
+ SHA512:
6
+ metadata.gz: 57e12ddc42ee8793b55b991378762334155016d2030e0965287f0d7ca243622879e80e2d786cc15e65fd7ed4b740fcdbb67ef94e1c1d1cbaca977fec6560836b
7
+ data.tar.gz: f6c4fc80873372db4ee7460c22b4a7c66dedb491eeee53e22449ef37fbfc560c40265e1269b0984fc87094057dd7cd8308ec2a3ec2e4dfedc1d6e048714139f1
@@ -3,13 +3,15 @@ module FrontendEditorHelper
3
3
  options[:id] ||= model.id
4
4
  options[:method] ||= 'body'
5
5
  options[:object] ||= model.class.name.demodulize.pluralize.downcase
6
+ options[:prefix] ||= ''
6
7
 
7
8
  content_tag(:div,
8
9
  class: 'editable-long-text',
9
10
  data: {
10
11
  object: options[:object],
11
12
  id: options[:id],
12
- attribute: options[:method]
13
+ attribute: options[:method],
14
+ prefix: options[:prefix]
13
15
  } ) do
14
16
 
15
17
  raw(yield)
@@ -1,4 +1,2 @@
1
1
  require "frontendeditor/version"
2
2
  require "frontendeditor/engine"
3
- require "jquery-ui-rails"
4
- require "backbone-on-rails"
@@ -1,3 +1,3 @@
1
1
  module Frontendeditor
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -0,0 +1,34 @@
1
+ // Generated by CoffeeScript 1.7.1
2
+ (function() {
3
+ window.Editor = (function() {
4
+ function Editor() {}
5
+
6
+ Editor.active = function() {
7
+ var current, textarea;
8
+ current = this.el().html();
9
+ textarea = $('<textarea/>');
10
+ textarea.html(current);
11
+ return this.el().html(textarea);
12
+ };
13
+
14
+ Editor.commitAll = function() {
15
+ var id, model;
16
+ id = this.el().data('id');
17
+ model = FrontendEditor.getCurrentModel(id);
18
+ model.id = id;
19
+ return model.set(this.el().data('attribute'), this.el().find('textarea').html());
20
+ };
21
+
22
+ Editor.deactive = function() {
23
+ return this.el().html(this.el().find('textarea').html());
24
+ };
25
+
26
+ Editor.el = function() {
27
+ return $('.editable-long-text');
28
+ };
29
+
30
+ return Editor;
31
+
32
+ })();
33
+
34
+ }).call(this);
@@ -0,0 +1,133 @@
1
+ // Generated by CoffeeScript 1.7.1
2
+ (function() {
3
+ var _base, _base1,
4
+ __hasProp = {}.hasOwnProperty,
5
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
+
7
+ window.FrontendEditor = {
8
+ Models: {},
9
+ Collections: {},
10
+ Views: {},
11
+ Routers: {},
12
+ init: function() {
13
+ var view;
14
+ view = new FrontendEditor.Views.InlineEditor.ToolbarView();
15
+ $('body').prepend(view.render().el);
16
+ return this.currentModels = new FrontendEditor.Collections.InlineEditor.Items();
17
+ },
18
+ getCurrentModel: function(modelName) {
19
+ var currentModel;
20
+ currentModel = this.currentModels[modelName];
21
+ if (currentModel === void 0) {
22
+ currentModel = new this.Models.Item(modelName);
23
+ this.currentModels.add(currentModel);
24
+ }
25
+ return currentModel;
26
+ }
27
+ };
28
+
29
+ FrontendEditor.Models.Item = (function(_super) {
30
+ __extends(Item, _super);
31
+
32
+ function Item() {
33
+ return Item.__super__.constructor.apply(this, arguments);
34
+ }
35
+
36
+ Item.prototype.initialize = function(plural) {
37
+ return this.urlRoot = "/" + plural;
38
+ };
39
+
40
+ Item.prototype.prefix = function(prefix) {
41
+ return this.urlRoot = prefix + this.urlRoot;
42
+ };
43
+
44
+ return Item;
45
+
46
+ })(Backbone.Model);
47
+
48
+ (_base = FrontendEditor.Views).InlineEditor || (_base.InlineEditor = {});
49
+
50
+ FrontendEditor.Views.InlineEditor.ToolbarView = (function(_super) {
51
+ __extends(ToolbarView, _super);
52
+
53
+ function ToolbarView() {
54
+ return ToolbarView.__super__.constructor.apply(this, arguments);
55
+ }
56
+
57
+ ToolbarView.prototype.template = $('#toolbar-template').html();
58
+
59
+ ToolbarView.prototype.events = {
60
+ 'click .editing-mode': 'toggleEditingMode',
61
+ 'click .save': 'saveChanges',
62
+ 'click .cancel': 'cancelChanges'
63
+ };
64
+
65
+ ToolbarView.prototype.render = function() {
66
+ ToolbarView.__super__.render.apply(this, arguments);
67
+ $(this.el).html($('#frontend_toolbar').html());
68
+ this.$('.save').hide();
69
+ this.$('.cancel').hide();
70
+ return this;
71
+ };
72
+
73
+ ToolbarView.prototype.saveChanges = function(event) {
74
+ var prefix;
75
+ Editor.commitAll();
76
+ prefix = Editor.el().data('prefix');
77
+ if (prefix) {
78
+ FrontendEditor.currentModels.prefix(prefix);
79
+ }
80
+ FrontendEditor.currentModels.save();
81
+ FrontendEditor.currentModels.reset();
82
+ alert("Enregistrement Effectué");
83
+ return this.toggleEditingMode();
84
+ };
85
+
86
+ ToolbarView.prototype.cancelChanges = function(event) {
87
+ return window.location.reload();
88
+ };
89
+
90
+ ToolbarView.prototype.toggleEditingMode = function() {
91
+ if ($('.save').is(':hidden')) {
92
+ this.$('.save').show();
93
+ this.$('.cancel').show();
94
+ return Editor.active();
95
+ } else {
96
+ this.$('.save').hide();
97
+ this.$('.cancel').hide();
98
+ return Editor.deactive();
99
+ }
100
+ };
101
+
102
+ return ToolbarView;
103
+
104
+ })(Backbone.View);
105
+
106
+ (_base1 = FrontendEditor.Collections).InlineEditor || (_base1.InlineEditor = {});
107
+
108
+ FrontendEditor.Collections.InlineEditor.Items = (function(_super) {
109
+ __extends(Items, _super);
110
+
111
+ function Items() {
112
+ return Items.__super__.constructor.apply(this, arguments);
113
+ }
114
+
115
+ Items.prototype.model = FrontendEditor.Collections.InlineEditor.Item;
116
+
117
+ Items.prototype.save = function() {
118
+ return this.each(function(model) {
119
+ return model.save();
120
+ });
121
+ };
122
+
123
+ Items.prototype.prefix = function(prefix) {
124
+ return this.each(function(model) {
125
+ return model.prefix(prefix);
126
+ });
127
+ };
128
+
129
+ return Items;
130
+
131
+ })(Backbone.Collection);
132
+
133
+ }).call(this);
metadata CHANGED
@@ -1,48 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frontendeditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
5
- prerelease:
4
+ version: 0.0.7
6
5
  platform: ruby
7
6
  authors:
8
7
  - gcorbel
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-24 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: jquery-ui-rails
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 3.0.1
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: 3.0.1
30
- - !ruby/object:Gem::Dependency
31
- name: backbone-on-rails
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: 0.9.2.1
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 0.9.2.1
11
+ date: 2014-05-03 00:00:00.000000000 Z
12
+ dependencies: []
46
13
  description: This is an editor for any rails application
47
14
  email:
48
15
  - guirec.corbel@gmail.com
@@ -50,42 +17,35 @@ executables: []
50
17
  extensions: []
51
18
  extra_rdoc_files: []
52
19
  files:
20
+ - README.md
21
+ - Rakefile
53
22
  - app/helpers/frontend_editor_helper.rb
54
- - lib/frontendeditor/version.rb
55
- - lib/frontendeditor/engine.rb
56
23
  - lib/frontendeditor.rb
57
- - vendor/assets/javascripts/frontend_editor/collections/items.js.coffee
58
- - vendor/assets/javascripts/frontend_editor/frontend_editor.js.coffee~
59
- - vendor/assets/javascripts/frontend_editor/templates/toolbar_views.jst.eco.erb
60
- - vendor/assets/javascripts/frontend_editor/frontend_editor.coffee
61
- - vendor/assets/javascripts/frontend_editor/views/toolbar_view.js.coffee
62
- - vendor/assets/javascripts/frontend_editor/rcbvm.js.coffee~
63
- - vendor/assets/javascripts/frontend_editor/frontend_editor.coffee~
64
- - vendor/assets/javascripts/frontend_editor/models/item.js.coffee
65
- - Rakefile
66
- - README.md
24
+ - lib/frontendeditor/engine.rb
25
+ - lib/frontendeditor/version.rb
26
+ - vendor/assets/javascripts/frontend_editor/basic_editor.js
27
+ - vendor/assets/javascripts/frontend_editor/frontend_editor.js
67
28
  homepage: https://github.com/GCorbel/frontendeditor
68
29
  licenses: []
30
+ metadata: {}
69
31
  post_install_message:
70
32
  rdoc_options: []
71
33
  require_paths:
72
34
  - lib
73
35
  required_ruby_version: !ruby/object:Gem::Requirement
74
- none: false
75
36
  requirements:
76
- - - ! '>='
37
+ - - ">="
77
38
  - !ruby/object:Gem::Version
78
39
  version: '0'
79
40
  required_rubygems_version: !ruby/object:Gem::Requirement
80
- none: false
81
41
  requirements:
82
- - - ! '>='
42
+ - - ">="
83
43
  - !ruby/object:Gem::Version
84
44
  version: '0'
85
45
  requirements: []
86
46
  rubyforge_project:
87
- rubygems_version: 1.8.23
47
+ rubygems_version: 2.2.2
88
48
  signing_key:
89
- specification_version: 3
49
+ specification_version: 4
90
50
  summary: This editor is integrable to any rails application
91
51
  test_files: []
@@ -1,7 +0,0 @@
1
- FrontendEditor.Collections.InlineEditor ||= {}
2
-
3
- class FrontendEditor.Collections.InlineEditor.Items extends Backbone.Collection
4
- model: FrontendEditor.Collections.InlineEditor.Item
5
-
6
- save: ->
7
- @each((model) -> model.save())
@@ -1,33 +0,0 @@
1
- //= require_self
2
- //= require_tree ./templates/
3
- //= require_tree .//models
4
- //= require_tree .//views
5
- //= require_tree .//collections
6
-
7
- window.FrontendEditor =
8
- Models: {}
9
- Collections: {}
10
- Views: {}
11
- Routers: {}
12
-
13
- #Init the application
14
- init: ->
15
- #Create the toolbar, at the bottom
16
- view = new FrontendEditor.Views.InlineEditor.ToolbarView()
17
- #Add the view at the top of the body
18
- $('body').prepend(view.render().el)
19
- #Init all the models as an empty list
20
- @currentModels = new FrontendEditor.Collections.InlineEditor.Items()
21
-
22
- #Find or add a model to the current list
23
- getCurrentModel: (modelName) ->
24
- #Find the model
25
- currentModel = @currentModels[modelName]
26
- #If the model is not found
27
- if currentModel == undefined
28
- #Create a new own
29
- currentModel = new @Models.Item(modelName)
30
- #Add It to the list
31
- @currentModels.add(currentModel)
32
- #Return the model
33
- currentModel
@@ -1,41 +0,0 @@
1
- //= require jquery
2
- //= require jquery_ujs
3
- //= require ./init_ckeditor
4
- //= require ckeditor/ckeditor
5
- //= require ./editor
6
- //= require underscore
7
- //= require backbone
8
- //= require .//rcbvm
9
- //= require_tree ./templates/
10
- //= require_tree .//models
11
- //= require_tree .//views
12
- //= require jquery.effects.highlight
13
- //= require_self
14
-
15
- window.FrontendEditor =
16
- Models: {}
17
- Collections: {}
18
- Views: {}
19
- Routers: {}
20
-
21
- #Init the application
22
- init: ->
23
- #Create the toolbar, at the bottom
24
- view = new FrontendEditor.Views.InlineEditor.ToolbarView()
25
- #Add the view at the top of the body
26
- $('body').prepend(view.render().el)
27
- #Init all the models as an empty list
28
- @currentModels = {}
29
-
30
- #Find or add a model to the current list
31
- getCurrentModel: (modelName) ->
32
- #Find the model
33
- currentModel = @currentModels[modelName]
34
- #If the model is not found
35
- if currentModel == undefined
36
- #Create a new own
37
- currentModel = new @Models.Item(modelName)
38
- #Add It to the list
39
- @currentModels[modelName] = currentModel
40
- #Return the model
41
- currentModel
@@ -1,8 +0,0 @@
1
- #Send the csrf token before an ajax send for rails
2
- $.ajaxSetup
3
- beforeSend: (xhr, settings) ->
4
- csrf_token = $('meta[name="csrf-token"]').attr('content')
5
- return if settings.crossDomain
6
- return if settings.type == "GET"
7
- if csrf_token
8
- xhr.setRequestHeader('X-CSRF-Token', csrf_token)
@@ -1,6 +0,0 @@
1
- #This is a generic class for all the models
2
- class FrontendEditor.Models.Item extends Backbone.Model
3
- #Take the plural name of the model and at it to urlRool
4
- #When the save method is called, an ajax request is sent at the controller
5
- initialize: (plural) ->
6
- @urlRoot = "/#{plural}"
@@ -1,40 +0,0 @@
1
- window.Rcbvm =
2
- Models: {}
3
- Collections: {}
4
- Views: {}
5
- Routers: {}
6
-
7
- #Init the application
8
- init: ->
9
- #Create the toolbar, at the bottom
10
- view = new Rcbvm.Views.InlineEditor.ToolbarView()
11
- #Add the view at the top of the body
12
- $('body').prepend(view.render().el)
13
- #Init all the models as an empty list
14
- @currentModels = {}
15
-
16
- #Find or add a model to the current list
17
- getCurrentModel: (modelName) ->
18
- #Find the model
19
- currentModel = @currentModels[modelName]
20
- #If the model is not found
21
- if currentModel == undefined
22
- #Create a new own
23
- currentModel = new @Models.Item(modelName)
24
- #Add It to the list
25
- @currentModels[modelName] = currentModel
26
- #Return the model
27
- currentModel
28
-
29
- #Send the csrf token before an ajax send for rails
30
- $.ajaxSetup
31
- beforeSend: (xhr, settings) ->
32
- csrf_token = $('meta[name="csrf-token"]').attr('content')
33
- return if settings.crossDomain
34
- return if settings.type == "GET"
35
- if csrf_token
36
- xhr.setRequestHeader('X-CSRF-Token', csrf_token)
37
-
38
- #Init the backbone application when jQuery is ready
39
- $(document).ready ->
40
- Rcbvm.init()
@@ -1,5 +0,0 @@
1
- <div id="toolbar">
2
- <a class="editing-mode">Mode edition</a>
3
- <a class="save">Sauvegarder</a>
4
- <a class="cancel">Annuler</a>
5
- </div>
@@ -1,44 +0,0 @@
1
- FrontendEditor.Views.InlineEditor ||= {}
2
-
3
- class FrontendEditor.Views.InlineEditor.ToolbarView extends Backbone.View
4
-
5
- template: JST['frontend_editor/templates/toolbar_views']
6
-
7
- events:
8
- 'click .editing-mode': 'toggleEditingMode'
9
- 'click .save': 'saveChanges'
10
- 'click .cancel': 'cancelChanges'
11
-
12
- render: ->
13
- super
14
- if $('#frontend_toolbar').length != 0
15
- $(@el).html($('#frontend_toolbar').html())
16
- else
17
- $(@el).html(@template())
18
-
19
- @$('.save').hide()
20
- @$('.cancel').hide()
21
- @
22
-
23
- # commit all changes for all stored model
24
- saveChanges: (event) ->
25
- Editor.commitAll()
26
- FrontendEditor.currentModels.save()
27
- FrontendEditor.currentModels.reset()
28
- alert "Enregistrement Effectué"
29
- @toggleEditingMode()
30
-
31
- # reload the page to cancel all change
32
- cancelChanges: (event) ->
33
- window.location.reload()
34
-
35
- # toggle the editing mode
36
- toggleEditingMode: ->
37
- if $('.save').is(':hidden')
38
- @$('.save').show()
39
- @$('.cancel').show()
40
- Editor.active()
41
- else
42
- @$('.save').hide()
43
- @$('.cancel').hide()
44
- Editor.deactive()