whowish_word 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,12 +39,14 @@ whowishWordHelper.repositionAllEditIconPanels = function() {
39
39
 
40
40
  whowishWordHelper.editIconPanelRepositioning = function() {
41
41
 
42
- var pos = $w(this.element).position();
43
- var marginLeft = $w(this.element).margin().left;
44
- var marginTop = $w(this.element).margin().top;
42
+ var elem = $w('#' + this.elementId)[0];
43
+
44
+ var pos = $w(elem).position();
45
+ var marginLeft = $w(elem).margin().left;
46
+ var marginTop = $w(elem).margin().top;
45
47
  var outdent = 1;
46
48
 
47
- $w(this.editIconPanel).css('position', 'absolute')
49
+ $w('#' + this.editIconPanelId).css('position', 'absolute')
48
50
  .css('left', (pos.left - outdent + marginLeft) + 'px')
49
51
  .css('top', (pos.top - outdent + marginTop) + 'px');
50
52
 
@@ -54,7 +56,7 @@ whowishWordHelper.editIconPanelRepositioning = function() {
54
56
  whowishWordHelper.editHandler = function(event) {
55
57
 
56
58
  event.stopPropagation();
57
- event.preventDefault()
59
+ event.preventDefault();
58
60
 
59
61
  var self = this;
60
62
  var customData = whowishWordStorage[this.id]
@@ -18,11 +18,6 @@ var whowishWordStorage = {};
18
18
  for (var j=0;j<matchers.length;j++) {
19
19
 
20
20
  if (matchers[j].match(elems[i])) {
21
-
22
- if (elems[i].id == "" || elems[i].id == undefined) {
23
- elems[i].id = "whowishWordId" + (whowishWordVariables.idRunner++);
24
- }
25
-
26
21
  matchers[j].createWhowishWord(elems[i]);
27
22
  }
28
23
  }
@@ -5,13 +5,16 @@ var WhowishWordCreator = Class.extend({
5
5
 
6
6
  this.element = elem;
7
7
 
8
+ if (this.element.id == "" || this.element.id == undefined) {
9
+ this.element.id = "whowishWordId" + (whowishWordVariables.idRunner++);
10
+ }
11
+
8
12
  if (this.element.tagName.toLowerCase() == "option") {
9
13
  this.editIconPanel = (new WhowishWordSelectCreator($w(this.element).parent()[0])).editIconPanel;
10
14
  } else {
11
15
  this.editIconPanel = this.createAndGetEditIconPanel();
12
16
  }
13
17
 
14
- this.element.editIconPanel = this.editIconPanel;
15
18
 
16
19
  this.makeEditIcon();
17
20
  this.sanitize();
@@ -32,17 +35,17 @@ var WhowishWordCreator = Class.extend({
32
35
 
33
36
  createAndGetEditIconPanel: function() {
34
37
 
35
- if (this.element.editIconPanel != undefined)
36
- return this.element.editIconPanel;
38
+ if ($('#' + this.makeEditIconPanelId()).length > 0)
39
+ return $('#' + this.makeEditIconPanelId())[0];
37
40
 
38
41
  var editIconPanel = document.createElement('span');
39
42
 
40
- $w(editIconPanel).attr('id', this.generateEditIconPanelId())
43
+ $w(editIconPanel).attr('id', this.makeEditIconPanelId())
41
44
  .addClass('whowishWordEditIconPanel');
42
45
 
43
46
  customData = {};
44
- customData.editIconPanel = editIconPanel;
45
- customData.element = this.element;
47
+ customData.editIconPanelId = editIconPanel.id;
48
+ customData.elementId = this.element.id;
46
49
  customData.reposition = whowishWordHelper.editIconPanelRepositioning;
47
50
 
48
51
  whowishWordStorage[editIconPanel.id] = customData;
@@ -58,8 +61,8 @@ var WhowishWordCreator = Class.extend({
58
61
  },
59
62
 
60
63
 
61
- generateEditIconPanelId: function() {
62
- return this.element.id + "EditPanel" + (whowishWordVariables.idRunner++);
64
+ makeEditIconPanelId: function() {
65
+ return this.element.id + "EditPanel";
63
66
  }
64
67
 
65
68
 
@@ -1,13 +1,13 @@
1
1
  var WhowishWordAttributeHandler = WhowishWordContentHandler.extend({
2
2
 
3
3
  init: function(elem,attributeName){
4
- this.element_id = elem.id;
4
+ this.elementId = elem.id;
5
5
  this.attributeName = attributeName;
6
6
  },
7
7
 
8
8
  setContent: function(content){
9
9
 
10
- var elem = $w('#' + this.element_id)[0];
10
+ var elem = $w('#' + this.elementId)[0];
11
11
 
12
12
  try {
13
13
  elem[this.attributeName] = content;
@@ -21,7 +21,7 @@ var WhowishWordAttributeHandler = WhowishWordContentHandler.extend({
21
21
  },
22
22
 
23
23
  getContent: function(){
24
- var elem = $w('#' + this.element_id)[0];
24
+ var elem = $w('#' + this.elementId)[0];
25
25
  return $w(elem).attr(this.attributeName);
26
26
 
27
27
  }
@@ -1,17 +1,17 @@
1
1
  var WhowishWordHtmlHandler = WhowishWordContentHandler.extend({
2
2
 
3
3
  init: function(elem){
4
- this.element_id = elem.id;
4
+ this.elementId = elem.id;
5
5
  },
6
6
 
7
7
  setContent: function(content){
8
- var elem = $w('#' + this.element_id)[0];
8
+ var elem = $w('#' + this.elementId)[0];
9
9
  $w(elem).html(content);
10
10
  },
11
11
 
12
12
  getContent: function(){
13
13
 
14
- var elem = $w('#' + this.element_id)[0];
14
+ var elem = $w('#' + this.elementId)[0];
15
15
  return $w(elem).html();
16
16
  }
17
17
 
@@ -1,16 +1,16 @@
1
1
  var WhowishWordTextHandler = WhowishWordContentHandler.extend({
2
2
 
3
3
  init: function(elem){
4
- this.element_id = elem.id;
4
+ this.elementId = elem.id;
5
5
  },
6
6
 
7
7
  setContent: function(content){
8
- var elem = $w('#' + this.element_id)[0];
8
+ var elem = $w('#' + this.elementId)[0];
9
9
  $w(elem).text(content);
10
10
  },
11
11
 
12
12
  getContent: function() {
13
- var elem = $w('#' + this.element_id)[0];
13
+ var elem = $w('#' + this.elementId)[0];
14
14
  return $w(elem).text();
15
15
  }
16
16
 
@@ -1,11 +1,11 @@
1
1
  var WhowishWordValueHandler = WhowishWordContentHandler.extend({
2
2
 
3
3
  init: function(elem){
4
- this.element_id = elem.id;
4
+ this.elementId = elem.id;
5
5
  },
6
6
 
7
7
  setContent: function(content){
8
- var elem = $w('#' + this.element_id)[0];
8
+ var elem = $w('#' + this.elementId)[0];
9
9
 
10
10
  $w(elem).val(content);
11
11
 
@@ -21,7 +21,7 @@ var WhowishWordValueHandler = WhowishWordContentHandler.extend({
21
21
  },
22
22
 
23
23
  getContent: function(){
24
- var elem = $w('#' + this.element_id)[0];
24
+ var elem = $w('#' + this.elementId)[0];
25
25
  return $w(elem).val();
26
26
  }
27
27
 
data/whowish_word.gemspec CHANGED
@@ -3,13 +3,13 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "whowish_word"
6
- s.version = "0.1.9"
6
+ s.version = "0.2.0"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Tanin Na Nakorn"]
9
9
  s.email = ["tanin47@yahoo.com"]
10
10
  s.homepage = "http://github.com/tanin47/whowish_word"
11
11
  s.summary = %q{WhowishWord}
12
- s.description = %q{A wording framework for Rails}
12
+ s.description = %q{A Rails gem that make static content editable}
13
13
 
14
14
  s.rubyforge_project = "whowish_word"
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whowish_word
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2011-09-27 00:00:00.000000000Z
13
13
  dependencies: []
14
- description: A wording framework for Rails
14
+ description: A Rails gem that make static content editable
15
15
  email:
16
16
  - tanin47@yahoo.com
17
17
  executables: []