stay 0.1.2 → 0.1.3

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.
data/README.md CHANGED
@@ -0,0 +1,119 @@
1
+ # Stay
2
+ **Stay** is a RESTful ajax inplace-editor helper based on jQuery and Unobustorsive javascript.
3
+ Similar and inspired by [best_in_place](https://github.com/bernat/best_in_place), with extra
4
+ enchancement. Support [TinyMCE](http://tinymce.moxiecode.com/) as its editor.
5
+
6
+ ## Installation
7
+ Installation **stay** is simple. In Rails > 3.0 just add **stay** in your Gemfile:
8
+
9
+ ```ruby
10
+ gem "stay"
11
+ ```
12
+
13
+ Then include the following Javascript include into your assets/javascript.js.
14
+
15
+ ```ruby
16
+ //= require jquery
17
+ //= require tinymce-jquery
18
+ //= require stay
19
+ ```
20
+
21
+ Then add javascript calling in your Javascript file
22
+
23
+ ```javascript
24
+ $(document).ready(function(){
25
+ jQuery(".stay").stay();
26
+ });
27
+ ```
28
+
29
+ or if you're using CoffeScript use
30
+
31
+ ```
32
+ jQuery ->
33
+ jQuery(".stay").stay()
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ ### call this in your view
39
+
40
+ ```
41
+ stay object, field, OPTIONS{}
42
+ ```
43
+
44
+ Call this helper in your view to build **Stay**
45
+
46
+ Example:
47
+
48
+ ```ruby
49
+ stay @user, :name, type: :text_field
50
+ ```
51
+
52
+ As default **type** will take :text_field, *for now* you can only pass :text_field, :text_area, :tiny_mce
53
+
54
+ **Stay** support sub-resources routes, therefore you can pass array into **object** param
55
+
56
+ Example:
57
+
58
+ ```ruby
59
+ stay [@user, @article], :title, type: :text_area
60
+ ```
61
+
62
+ You can use TinyMCE as text editor, just pass :tiny_mce to **type**
63
+
64
+ Example:
65
+
66
+ ```ruby
67
+ stay [@user, @article], :body, type: :tiny_mce
68
+ ```
69
+
70
+ This will use TinyMCE editor with "simple" theme, you can also change this theme by using
71
+
72
+ ```ruby
73
+ stay [@user, @article], :body, type: [:tiny_mce, "advanced"]
74
+ ```
75
+
76
+ When called, by default **Stay** triggered by clicking the displayed text on HTML page.
77
+ **Stay** accept external trigger and submit button:
78
+
79
+ To use, just passed **activator:** followed by id of HTML element id
80
+
81
+ Example:
82
+
83
+ ```ruby
84
+ stay [@user, @article], :body, type: [:tiny_mce, "advanced"], activator: "#id_of_activator"
85
+ ```
86
+
87
+ To use external submit button, just passed **submitter:** followed by id of HTML element id
88
+
89
+ ```ruby
90
+ stay [@user, @article], :body, type: [:tiny_mce, "advanced"], activator: "#id_of_activator", submitter: "#id_of_submit_button"
91
+ ```
92
+
93
+ Example of complete use:
94
+
95
+ ```ruby
96
+ <%= link_to "Click me to activate", "#", id: "activate_here" %>
97
+ <%= stay [@user, @article], :body, type: :tiny_mce, activator: "#activate_here", submitter: "#submit_here" %>
98
+ <%= link_to "Click me to submit", "#", id: "submit_here" %>
99
+ ```
100
+
101
+ ### call this in your controller
102
+
103
+ stay_response object
104
+
105
+ Example of complete use:
106
+
107
+ ```ruby
108
+ def update
109
+ user = User.find(params[:user_id])
110
+ article = user.articles.find(params[:id])
111
+ respond_to do |format|
112
+ if article.update_attributes(params[:article])
113
+ format.json { stay_response(article) }
114
+ else
115
+ format.json { stay_response(article) }
116
+ end
117
+ end
118
+ end
119
+ ```
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('stay', '0.1.2') do |p|
5
+ Echoe.new('stay', '0.1.3') do |p|
6
6
  p.description = "Form ajax helper with tinymce support"
7
7
  p.summary = "Helper for building ajax form, inspired by best_in_place, with some modifications, support tinymce as editor"
8
8
  p.url = "http://github.com/tejanium/stay"
@@ -64,7 +64,6 @@ Stay.prototype = {
64
64
  console.info("Stay successfully initialized");
65
65
  },
66
66
 
67
-
68
67
  bindTrigger: function(){
69
68
  var self = this;
70
69
 
@@ -78,17 +77,19 @@ Stay.prototype = {
78
77
  self.stayTinyMCE.tinymce().focus();
79
78
  }else{
80
79
  self.stayFormInput.focus();
81
-
82
- var ev = (typeof self.submitter_id === "undefined") ? "blur" : "click";
83
- console.log("Submitter event: " + ev + ", on:");
84
- console.log(self.submitter);
85
-
86
- self.submitter.bind(ev, function(){
87
- self.stayFormForm.submit();
88
- self.stayFormInput.disable();
89
- });
90
80
  }
91
81
  });
82
+
83
+ if(!self.tinyMCEUsed){
84
+ var ev = (typeof self.submitter_id === "undefined") ? "blur" : "click";
85
+ console.log("Submitter event: " + ev + ", on:");
86
+ console.log(self.submitter);
87
+
88
+ self.submitter.bind(ev, function(){
89
+ self.stayFormForm.submit();
90
+ self.stayFormInput.disable();
91
+ });
92
+ }
92
93
  },
93
94
 
94
95
  bindCallback: function(){
data/lib/stay/helper.rb CHANGED
@@ -18,7 +18,7 @@ module Stay
18
18
  html = "<span class='stay' "
19
19
  html << "data-activator='#{ opts[:activator] }' " if opts[:activator]
20
20
  html << "data-submitter='#{ opts[:submitter] }' " if opts[:submitter]
21
- html << "data-tinymce-theme='#{ opts[:type] }' " if opts[:type] == :tiny_mce
21
+ html << "data-tinymce-theme='simple' " if opts[:type] == :tiny_mce
22
22
  html << "data-tinymce-theme='#{ opts[:type][1] }' " if opts[:type].is_a?(Array)
23
23
  html << ">"
24
24
  html << "<span class='stay-object'>"
data/stay.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "stay"
5
- s.version = "0.1.2"
5
+ s.version = "0.1.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Teja Sophista"]
9
- s.date = "2012-02-04"
9
+ s.date = "2012-02-06"
10
10
  s.description = "Form ajax helper with tinymce support"
11
11
  s.email = "tejanium@yahoo.com"
12
12
  s.extra_rdoc_files = ["README.md", "README.rdoc", "lib/assets/javascripts/stay.js", "lib/stay.rb", "lib/stay/controller_extensions.rb", "lib/stay/engine.rb", "lib/stay/helper.rb", "lib/stay/string_extensions.rb"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-04 00:00:00.000000000Z
12
+ date: 2012-02-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jquery-rails
16
- requirement: &13965200 !ruby/object:Gem::Requirement
16
+ requirement: &21051000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *13965200
24
+ version_requirements: *21051000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: tinymce-rails
27
- requirement: &13964740 !ruby/object:Gem::Requirement
27
+ requirement: &21050540 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *13964740
35
+ version_requirements: *21050540
36
36
  description: Form ajax helper with tinymce support
37
37
  email: tejanium@yahoo.com
38
38
  executables: []