whowish_word 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/README.md +17 -5
  2. data/lib/whowish_word/rails/public/javascripts/0_class.js +64 -64
  3. data/lib/whowish_word/rails/public/javascripts/1_jquery.escape.js +23 -23
  4. data/lib/whowish_word/rails/public/javascripts/1_jquery.sizes.min.js +7 -7
  5. data/lib/whowish_word/rails/public/javascripts/2_whowish_word_variables.js +4 -42
  6. data/lib/whowish_word/rails/public/javascripts/3_whowish_word_helper.js +28 -9
  7. data/lib/whowish_word/rails/public/javascripts/4_whowish_word.js +45 -43
  8. data/lib/whowish_word/rails/public/javascripts/4_whowish_word_content_handler.js +15 -15
  9. data/lib/whowish_word/rails/public/javascripts/4_whowish_word_creator.js +10 -6
  10. data/lib/whowish_word/rails/public/javascripts/5_whowish_word_common_creator.js +50 -48
  11. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_element_creator.js +57 -81
  12. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_element_guard.js +32 -0
  13. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_html_creator.js +18 -18
  14. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_html_guard.js +12 -0
  15. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_select_creator.js +10 -10
  16. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_text_creator.js +19 -19
  17. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_text_guard.js +10 -0
  18. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_value_creator.js +19 -19
  19. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_value_guard_and_sanitizer.js +24 -0
  20. data/lib/whowish_word/rails/public/javascripts/7_whowish_word_attribute_handler.js +24 -24
  21. data/lib/whowish_word/rails/public/javascripts/7_whowish_word_html_handler.js +14 -14
  22. data/lib/whowish_word/rails/public/javascripts/7_whowish_word_text_handler.js +14 -14
  23. data/lib/whowish_word/rails/public/javascripts/7_whowish_word_value_handler.js +24 -18
  24. data/lib/whowish_word/rails/public/stylesheets/whowish_word.css +197 -197
  25. data/rails/Gemfile.lock +130 -130
  26. data/rails/Rakefile +7 -7
  27. data/rails/app/assets/javascripts/integration.js +2 -2
  28. data/rails/app/assets/javascripts/test_javascript.js +2 -2
  29. data/rails/app/assets/javascripts/test_word_for.js +2 -2
  30. data/rails/app/assets/stylesheets/integration.css +4 -4
  31. data/rails/app/assets/stylesheets/test_javascript.css +4 -4
  32. data/rails/app/assets/stylesheets/test_word_for.css +4 -4
  33. data/rails/app/controllers/integration_controller.rb +5 -5
  34. data/rails/app/controllers/test_javascript_controller.rb +11 -11
  35. data/rails/app/controllers/test_word_for_controller.rb +5 -5
  36. data/rails/app/helpers/integration_helper.rb +2 -2
  37. data/rails/app/helpers/test_javascript_helper.rb +2 -2
  38. data/rails/app/helpers/test_word_for_helper.rb +2 -2
  39. data/rails/app/views/test_javascript/replace_with_html.html.erb +96 -0
  40. data/rails/public/jasmine/MIT.LICENSE +20 -20
  41. data/rails/public/jasmine/jasmine-html.js +190 -190
  42. data/rails/public/jasmine/jasmine.css +166 -166
  43. data/rails/public/jasmine/jasmine.js +2476 -2476
  44. data/rails/public/javascripts/jquery-1.6.4.js +9046 -9046
  45. data/rails/public/javascripts/jquery.loading_button.js +72 -0
  46. data/rails/public/sinonjs/sinonjs.js +2821 -2821
  47. data/rails/public/stylesheets/main.css +26 -21
  48. data/whowish_word.gemspec +1 -1
  49. metadata +9 -3
data/README.md CHANGED
@@ -1,15 +1,27 @@
1
- WhowishWord - A wording framework for Rails
1
+ WhowishWord - a Rails gem that make static content editable
2
2
  ====================
3
3
 
4
- Have you ever been bored when a project manager (or marketing department) keeps changing wording on a website?
5
- This kind of tasks can make programmers go crazy.
4
+ WhowishWord makes static content editable, as long as the programmers follow its convention.
6
5
 
7
- WhowishWord allows normal users to change wording on a Rails website, directly.
6
+
7
+ The problem WhowishWord tries to solve
8
+ ---------------------------------------
9
+
10
+ The problem that I personally faced in my company, Whowish, is that:
11
+
12
+ Occasionally CEO or VP of Marketing would send me an email to change the word 'Save'(on a submit button) to the word 'Post'.
13
+ I would have to go to the source code and change it.
14
+ And when this happens too often, it drives us, the programmers, crazy
15
+
16
+ WhowishWord tries to solve this problem elegantly. It is much better than using a config file.
17
+
18
+ It gives a simple tool for CEO, VP of Marketing (or whoever it is) to make changes themselves.
8
19
 
9
20
  The beauty of WhowishWord is that:
10
21
 
11
22
  * It is almost transparent to programmers
12
23
  * Programmers don't have to care how wording should be. This makes them work much faster
24
+ * It does not clutter up your source code because you replace one static content unit with one function call
13
25
 
14
26
 
15
27
  How you should work
@@ -151,7 +163,7 @@ Tanin Na Nakorn
151
163
  Tanun Niyomjit (Designer)
152
164
 
153
165
 
154
- Boring license stuffs
166
+ Boring legal stuff
155
167
  -----------------------
156
168
 
157
169
  WhowishWord relies on several libraries that you won't see.
@@ -1,64 +1,64 @@
1
- /* Simple JavaScript Inheritance
2
- * By John Resig http://ejohn.org/
3
- * MIT Licensed.
4
- */
5
- // Inspired by base2 and Prototype
6
- (function(){
7
- var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
8
-
9
- // The base Class implementation (does nothing)
10
- this.Class = function(){};
11
-
12
- // Create a new Class that inherits from this class
13
- Class.extend = function(prop) {
14
- var _super = this.prototype;
15
-
16
- // Instantiate a base class (but only create the instance,
17
- // don't run the init constructor)
18
- initializing = true;
19
- var prototype = new this();
20
- initializing = false;
21
-
22
- // Copy the properties over onto the new prototype
23
- for (var name in prop) {
24
- // Check if we're overwriting an existing function
25
- prototype[name] = typeof prop[name] == "function" &&
26
- typeof _super[name] == "function" && fnTest.test(prop[name]) ?
27
- (function(name, fn){
28
- return function() {
29
- var tmp = this._super;
30
-
31
- // Add a new ._super() method that is the same method
32
- // but on the super-class
33
- this._super = _super[name];
34
-
35
- // The method only need to be bound temporarily, so we
36
- // remove it when we're done executing
37
- var ret = fn.apply(this, arguments);
38
- this._super = tmp;
39
-
40
- return ret;
41
- };
42
- })(name, prop[name]) :
43
- prop[name];
44
- }
45
-
46
- // The dummy class constructor
47
- function Class() {
48
- // All construction is actually done in the init method
49
- if ( !initializing && this.init )
50
- this.init.apply(this, arguments);
51
- }
52
-
53
- // Populate our constructed prototype object
54
- Class.prototype = prototype;
55
-
56
- // Enforce the constructor to be what we expect
57
- Class.prototype.constructor = Class;
58
-
59
- // And make this class extendable
60
- Class.extend = arguments.callee;
61
-
62
- return Class;
63
- };
64
- })();
1
+ /* Simple JavaScript Inheritance
2
+ * By John Resig http://ejohn.org/
3
+ * MIT Licensed.
4
+ */
5
+ // Inspired by base2 and Prototype
6
+ (function(){
7
+ var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
8
+
9
+ // The base Class implementation (does nothing)
10
+ this.Class = function(){};
11
+
12
+ // Create a new Class that inherits from this class
13
+ Class.extend = function(prop) {
14
+ var _super = this.prototype;
15
+
16
+ // Instantiate a base class (but only create the instance,
17
+ // don't run the init constructor)
18
+ initializing = true;
19
+ var prototype = new this();
20
+ initializing = false;
21
+
22
+ // Copy the properties over onto the new prototype
23
+ for (var name in prop) {
24
+ // Check if we're overwriting an existing function
25
+ prototype[name] = typeof prop[name] == "function" &&
26
+ typeof _super[name] == "function" && fnTest.test(prop[name]) ?
27
+ (function(name, fn){
28
+ return function() {
29
+ var tmp = this._super;
30
+
31
+ // Add a new ._super() method that is the same method
32
+ // but on the super-class
33
+ this._super = _super[name];
34
+
35
+ // The method only need to be bound temporarily, so we
36
+ // remove it when we're done executing
37
+ var ret = fn.apply(this, arguments);
38
+ this._super = tmp;
39
+
40
+ return ret;
41
+ };
42
+ })(name, prop[name]) :
43
+ prop[name];
44
+ }
45
+
46
+ // The dummy class constructor
47
+ function Class() {
48
+ // All construction is actually done in the init method
49
+ if ( !initializing && this.init )
50
+ this.init.apply(this, arguments);
51
+ }
52
+
53
+ // Populate our constructed prototype object
54
+ Class.prototype = prototype;
55
+
56
+ // Enforce the constructor to be what we expect
57
+ Class.prototype.constructor = Class;
58
+
59
+ // And make this class extendable
60
+ Class.extend = arguments.callee;
61
+
62
+ return Class;
63
+ };
64
+ })();
@@ -1,23 +1,23 @@
1
- // jquery.escape 1.0 - escape strings for use in jQuery selectors
2
- // http://ianloic.com/tag/jquery.escape
3
- // Copyright 2009 Ian McKellar <http://ian.mckellar.org/>
4
- // Just like jQuery you can use it under either the MIT license or the GPL
5
- // (see: http://docs.jquery.com/License)
6
-
7
- (function($w){
8
-
9
- $w.extend({
10
-
11
- escape: function(s) {
12
- escape_re = /[#;&,\.\+\*~':"!\^\$\[\]\(\)=>|\/\\]/;
13
-
14
- var left = s.split(escape_re, 1)[0];
15
- if (left == s) return s;
16
- return left + '\\' +
17
- s.substr(left.length, 1) +
18
- jQueryWhowishWord.escape(s.substr(left.length+1));
19
- }
20
- });
21
-
22
- })(jQueryWhowishWord);
23
-
1
+ // jquery.escape 1.0 - escape strings for use in jQuery selectors
2
+ // http://ianloic.com/tag/jquery.escape
3
+ // Copyright 2009 Ian McKellar <http://ian.mckellar.org/>
4
+ // Just like jQuery you can use it under either the MIT license or the GPL
5
+ // (see: http://docs.jquery.com/License)
6
+
7
+ (function($w){
8
+
9
+ $w.extend({
10
+
11
+ escape: function(s) {
12
+ escape_re = /[#;&,\.\+\*~':"!\^\$\[\]\(\)=>|\/\\]/;
13
+
14
+ var left = s.split(escape_re, 1)[0];
15
+ if (left == s) return s;
16
+ return left + '\\' +
17
+ s.substr(left.length, 1) +
18
+ jQueryWhowishWord.escape(s.substr(left.length+1));
19
+ }
20
+ });
21
+
22
+ })(jQueryWhowishWord);
23
+
@@ -1,8 +1,8 @@
1
- /*
2
- * JSizes - JQuery plugin v0.33
3
- *
4
- * Licensed under the revised BSD License.
5
- * Copyright 2008-2010 Bram Stein
6
- * All rights reserved.
7
- */
1
+ /*
2
+ * JSizes - JQuery plugin v0.33
3
+ *
4
+ * Licensed under the revised BSD License.
5
+ * Copyright 2008-2010 Bram Stein
6
+ * All rights reserved.
7
+ */
8
8
  (function(b){var a=function(c){return parseInt(c,10)||0};b.each(["min","max"],function(d,c){b.fn[c+"Size"]=function(g){var f,e;if(g){if(g.width!==undefined){this.css(c+"-width",g.width)}if(g.height!==undefined){this.css(c+"-height",g.height)}return this}else{f=this.css(c+"-width");e=this.css(c+"-height");return{width:(c==="max"&&(f===undefined||f==="none"||a(f)===-1)&&Number.MAX_VALUE)||a(f),height:(c==="max"&&(e===undefined||e==="none"||a(e)===-1)&&Number.MAX_VALUE)||a(e)}}}});b.fn.isVisible=function(){return this.is(":visible")};b.each(["border","margin","padding"],function(d,c){b.fn[c]=function(e){if(e){if(e.top!==undefined){this.css(c+"-top"+(c==="border"?"-width":""),e.top)}if(e.bottom!==undefined){this.css(c+"-bottom"+(c==="border"?"-width":""),e.bottom)}if(e.left!==undefined){this.css(c+"-left"+(c==="border"?"-width":""),e.left)}if(e.right!==undefined){this.css(c+"-right"+(c==="border"?"-width":""),e.right)}return this}else{return{top:a(this.css(c+"-top"+(c==="border"?"-width":""))),bottom:a(this.css(c+"-bottom"+(c==="border"?"-width":""))),left:a(this.css(c+"-left"+(c==="border"?"-width":""))),right:a(this.css(c+"-right"+(c==="border"?"-width":"")))}}}})})(jQueryWhowishWord);
@@ -15,57 +15,19 @@ whowishWordVariables.whowishWordIdPattern = new RegExp("([^\|]+)(\|(.*))?");
15
15
 
16
16
  whowishWordVariables.matchers = [
17
17
  {
18
- match: function(element) {
19
-
20
- for (var i = 0; i < element.attributes.length; i++) {
21
-
22
- if (element.attributes[i].name.toLowerCase() == "id") continue;
23
- if (element.attributes[i].name.toLowerCase() == "value") continue;
24
-
25
- var value = element.attributes[i].value;
26
-
27
- if (typeof(value).toLowerCase() != "string") continue;
28
-
29
- if (value.match(whowishWordVariables.attributeValuePattern) != null) {
30
-
31
- return true;
32
- }
33
- }
34
-
35
- return false;
36
- },
18
+ match: function(element){ return WhowishWordElementGuard.check(element); },
37
19
  createWhowishWord: function(element) { new WhowishWordElementCreator(element); }
38
20
  },
39
21
  {
40
- match: function(element) {
41
-
42
- return (element.tagName.toLowerCase() == "dfn"
43
- || element.tagName.toLowerCase() == "button"
44
- || element.tagName.toLowerCase() == "label")
45
- && (typeof(html = $w(element).html())).toLowerCase() == "string"
46
- && html.match(whowishWordVariables.attributeValuePattern) != null;
47
-
48
- },
22
+ match: function(element) { return WhowishWordHtmlGuard.check(element); },
49
23
  createWhowishWord: function(element) { new WhowishWordHtmlCreator(element); }
50
24
  },
51
25
  {
52
- match: function(element) {
53
-
54
- return element.tagName.toLowerCase() != "select"
55
- && (typeof(val = $w(element).val())).toLowerCase() == "string"
56
- && val.match(whowishWordVariables.attributeValuePattern) != null;
57
-
58
- },
26
+ match: function(element) { return WhowishWordValueGuardAndSanitizer.check(element); },
59
27
  createWhowishWord: function(element) { new WhowishWordValueCreator(element); }
60
28
  },
61
29
  {
62
- match: function(element) {
63
-
64
- return element.tagName.toLowerCase() == "option"
65
- && (typeof(text = $w(element).text())).toLowerCase() == "string"
66
- && text.match(whowishWordVariables.attributeValuePattern) != null;
67
-
68
- },
30
+ match: function(element) { return WhowishWordTextGuard.check(element); },
69
31
  createWhowishWord: function(element) { new WhowishWordTextCreator(element); }
70
32
  }
71
33
  ];
@@ -3,7 +3,25 @@
3
3
  */
4
4
  var whowishWordHelper = {};
5
5
 
6
- function log(msg) {
6
+ whowishWordHelper.sanitize = function(content) {
7
+ return content.replace(whowishWordVariables.attributeValuePattern,"$2")
8
+ }
9
+
10
+ whowishWordHelper.match = function(content) {
11
+ return whowishWordHelper.matchWithResult(content) != null;
12
+ }
13
+
14
+ whowishWordHelper.matchWithResult = function(content) {
15
+ return content.match(whowishWordVariables.attributeValuePattern);
16
+ }
17
+
18
+ whowishWordHelper.makeEditIconId = function(element, name) {
19
+ return element.id +
20
+ whowishWordVariables.separator +
21
+ name;
22
+ }
23
+
24
+ whowishWordHelper.log = function(msg) {
7
25
  try {
8
26
  console.log(msg);
9
27
  } catch (e) {}
@@ -13,7 +31,7 @@ whowishWordHelper.repositionAllEditIconPanels = function() {
13
31
 
14
32
  var editIconPanels = $w('.whowishWordEditIconPanel');
15
33
  for (var i=0;i<editIconPanels.length;i++) {
16
- editIconPanels[i].whowishWord.reposition();
34
+ whowishWordStorage[editIconPanels[i].id].reposition();
17
35
  }
18
36
 
19
37
  };
@@ -39,13 +57,14 @@ whowishWordHelper.editHandler = function(event) {
39
57
  event.preventDefault()
40
58
 
41
59
  var self = this;
60
+ var customData = whowishWordStorage[this.id]
42
61
 
43
62
  $w.whowishWordDialog.open({
44
63
 
45
- whowishWordId: this.whowishWord.id,
46
- variables: this.whowishWord.variables,
47
- attributeName: this.whowishWord.attributeName,
48
- content: this.whowishWord.contentHandler.getContent(),
64
+ whowishWordId: customData.id,
65
+ variables: customData.variables,
66
+ attributeName: customData.attributeName,
67
+ content: customData.contentHandler.getContent(),
49
68
  success: function(html){
50
69
 
51
70
  $w.whowishWordDialog.start_loading();
@@ -58,11 +77,11 @@ whowishWordHelper.editHandler = function(event) {
58
77
  "Connection": "close"
59
78
  },
60
79
  data: {
61
- "word_id": self.whowishWord.id,
80
+ "word_id": customData.id,
62
81
  "content": html
63
82
  },
64
83
  success: function(data) {
65
- self.whowishWord.contentHandler.setContent(html);
84
+ customData.contentHandler.setContent(html);
66
85
  $w.whowishWordDialog.close();
67
86
  $w.whowishWordDialog.stop_loading();
68
87
  },
@@ -79,7 +98,7 @@ whowishWordHelper.editHandler = function(event) {
79
98
 
80
99
 
81
100
  whowishWordHelper.extractWhowishWordIdFromText = function(text) {
82
- var result = text.match(whowishWordVariables.attributeValuePattern);
101
+ var result = whowishWordHelper.matchWithResult(text);
83
102
  return result[1];
84
103
 
85
104
  };
@@ -1,43 +1,45 @@
1
- /**
2
- * @author Tanin Na Nakorn
3
- */
4
-
5
- (function($w){
6
-
7
- $w.extend({
8
-
9
- whowishWord: function(recurring) {
10
-
11
- var elems = $w('body').find('*');
12
- var matchers = whowishWordVariables.matchers;
13
-
14
- for (var i=0;i<elems.length;i++) {
15
-
16
- for (var j=0;j<matchers.length;j++) {
17
-
18
- if (matchers[j].match(elems[i])) {
19
-
20
- if (elems[i].id == "" || elems[i].id == undefined) {
21
- elems[i].id = "whowishWordId" + (whowishWordVariables.idRunner++);
22
- }
23
-
24
- matchers[j].createWhowishWord(elems[i]);
25
- }
26
- }
27
-
28
- }
29
-
30
- $w('.whowishWordEditIcon').die('click');
31
- whowishWordHelper.repositionAllEditIconPanels();
32
- $w('.whowishWordEditIcon').live('click', whowishWordHelper.editHandler);
33
-
34
- if (recurring != false) {
35
- setTimeout("$w.whowishWord(true);",1000);
36
- }
37
-
38
- }
39
-
40
- });
41
-
42
- })(jQueryWhowishWord);
43
-
1
+ /**
2
+ * @author Tanin Na Nakorn
3
+ */
4
+
5
+ var whowishWordStorage = {};
6
+
7
+ (function($w){
8
+
9
+ $w.extend({
10
+
11
+ whowishWord: function(recurring) {
12
+
13
+ var elems = $w('body').find('*');
14
+ var matchers = whowishWordVariables.matchers;
15
+
16
+ for (var i=0;i<elems.length;i++) {
17
+
18
+ for (var j=0;j<matchers.length;j++) {
19
+
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
+ matchers[j].createWhowishWord(elems[i]);
27
+ }
28
+ }
29
+
30
+ }
31
+
32
+ $w('.whowishWordEditIcon').die('click');
33
+ whowishWordHelper.repositionAllEditIconPanels();
34
+ $w('.whowishWordEditIcon').live('click', whowishWordHelper.editHandler);
35
+
36
+ if (recurring != false) {
37
+ setTimeout("$w.whowishWord(true);",1000);
38
+ }
39
+
40
+ }
41
+
42
+ });
43
+
44
+ })(jQueryWhowishWord);
45
+
@@ -1,15 +1,15 @@
1
- var WhowishWordContentHandler = Class.extend({
2
-
3
- init: function(elem){
4
- this.element = elem;
5
- },
6
-
7
- setContent: function(){
8
- throw 'Not implemented';
9
- },
10
-
11
- getContent: function(){
12
- throw 'Not implemented';
13
- }
14
-
15
- });
1
+ var WhowishWordContentHandler = Class.extend({
2
+
3
+ init: function(elem){
4
+ this.element = elem;
5
+ },
6
+
7
+ setContent: function(){
8
+ throw 'Not implemented';
9
+ },
10
+
11
+ getContent: function(){
12
+ throw 'Not implemented';
13
+ }
14
+
15
+ });
@@ -37,15 +37,19 @@ var WhowishWordCreator = Class.extend({
37
37
 
38
38
  var editIconPanel = document.createElement('span');
39
39
 
40
- editIconPanel.whowishWord = {};
41
- editIconPanel.whowishWord.editIconPanel = editIconPanel;
42
- editIconPanel.whowishWord.element = this.element;
43
- editIconPanel.whowishWord.reposition = whowishWordHelper.editIconPanelRepositioning;
44
-
45
40
  $w(editIconPanel).attr('id', this.generateEditIconPanelId())
46
41
  .addClass('whowishWordEditIconPanel');
42
+
43
+ customData = {};
44
+ customData.editIconPanel = editIconPanel;
45
+ customData.element = this.element;
46
+ customData.reposition = whowishWordHelper.editIconPanelRepositioning;
47
+
48
+ whowishWordStorage[editIconPanel.id] = customData;
49
+
50
+
47
51
 
48
- editIconPanel.whowishWord.reposition();
52
+ whowishWordStorage[editIconPanel.id].reposition();
49
53
 
50
54
 
51
55
  $w(this.element).after(editIconPanel);
@@ -1,49 +1,51 @@
1
- var WhowishWordCommonCreator = WhowishWordCreator.extend({
2
-
3
- identity: function() {
4
- throw 'identity() is not implemented'
5
- },
6
-
7
- getContent: function() {
8
- throw 'getContent() is not implemented'
9
- },
10
-
11
- setContent: function() {
12
- throw 'setContent() is not implemented'
13
- },
14
-
15
- instantiateAndGetContentHandler: function() {
16
- throw 'instantiateAndGetContentHandler() is not implemented'
17
- },
18
-
19
- makeEditIcon: function(){
20
-
21
- var editIcon = document.createElement('span');
22
- $w(editIcon).addClass('whowishWordEditIcon');
23
- $w(editIcon).attr('id', this.element.id +
24
- whowishWordVariables.separator +
25
- this.identity());
26
- $w(editIcon).attr('title', this.identity());
27
-
28
- var whowishWordIdPackage = whowishWordHelper.extractWhowishWordIdFromText(this.getContent());
29
- var idPackage = whowishWordHelper.parseWhowishWordIdPackage(whowishWordIdPackage);
30
-
31
- editIcon.whowishWord = {};
32
- editIcon.whowishWord.contentHandler = this.instantiateAndGetContentHandler();
33
-
34
- editIcon.whowishWord.id = idPackage.id;
35
- editIcon.whowishWord.variables = idPackage.variables;
36
-
37
- this.addEditIcon(editIcon);
38
-
39
- },
40
-
41
-
42
- sanitize: function(){
43
-
44
- this.setContent(this.getContent().replace(whowishWordVariables.attributeValuePattern,"$2"));
45
-
46
- },
47
-
48
-
1
+ var WhowishWordCommonCreator = WhowishWordCreator.extend({
2
+
3
+ identity: function() {
4
+ throw 'identity() is not implemented'
5
+ },
6
+
7
+ getContent: function() {
8
+ throw 'getContent() is not implemented'
9
+ },
10
+
11
+ setContent: function() {
12
+ throw 'setContent() is not implemented'
13
+ },
14
+
15
+ instantiateAndGetContentHandler: function() {
16
+ throw 'instantiateAndGetContentHandler() is not implemented'
17
+ },
18
+
19
+ makeEditIcon: function(){
20
+
21
+ var editIcon = document.createElement('span');
22
+ $w(editIcon).addClass('whowishWordEditIcon');
23
+ $w(editIcon).attr('id', this.element.id +
24
+ whowishWordVariables.separator +
25
+ this.identity());
26
+ $w(editIcon).attr('title', this.identity());
27
+
28
+ var whowishWordIdPackage = whowishWordHelper.extractWhowishWordIdFromText(this.getContent());
29
+ var idPackage = whowishWordHelper.parseWhowishWordIdPackage(whowishWordIdPackage);
30
+
31
+ customData = {};
32
+ customData.contentHandler = this.instantiateAndGetContentHandler();
33
+
34
+ customData.id = idPackage.id;
35
+ customData.variables = idPackage.variables;
36
+
37
+ whowishWordStorage[editIcon.id] = customData;
38
+
39
+ this.addEditIcon(editIcon);
40
+
41
+ },
42
+
43
+
44
+ sanitize: function(){
45
+
46
+ this.setContent(whowishWordHelper.sanitize(this.getContent()));
47
+
48
+ },
49
+
50
+
49
51
  });