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
@@ -1,82 +1,58 @@
1
- var WhowishWordElementCreator = WhowishWordCreator.extend({
2
-
3
- makeEditIcon: function(){
4
-
5
- var attrs = this.getRelevantAttributes();
6
-
7
- for (var i=0;i<attrs.length;i++) {
8
-
9
- var editIcon = document.createElement('span');
10
- $w(editIcon).addClass('whowishWordEditIcon');
11
- $w(editIcon).attr('id', this.getEditIconId(attrs[i]));
12
- $w(editIcon).attr('title', attrs[i]);
13
-
14
- var whowishWordIdPackage = whowishWordHelper.extractWhowishWordIdFromText($w(this.element).attr(attrs[i]));
15
- var idPackage = whowishWordHelper.parseWhowishWordIdPackage(whowishWordIdPackage);
16
-
17
- editIcon.whowishWord = {};
18
- editIcon.whowishWord.contentHandler = new WhowishWordAttributeHandler(this.element, attrs[i]);
19
-
20
- editIcon.whowishWord.id = idPackage.id;
21
- editIcon.whowishWord.variables = idPackage.variables;
22
- editIcon.whowishWord.attributeName = attrs[i];
23
-
24
- this.addEditIcon(editIcon);
25
- }
26
-
27
- },
28
-
29
-
30
- sanitize: function(){
31
-
32
- var attrs = this.getRelevantAttributes();
33
-
34
- for (var i=0;i<attrs.length;i++) {
35
-
36
- var newValue = $w(this.element).attr(attrs[i]).replace(whowishWordVariables.attributeValuePattern,"$2");
37
-
38
- try {
39
- this.element[attrs[i]] = newValue;
40
- } catch(e) {}
41
-
42
- try {
43
- this.element.attributes[attrs[i]].value = newValue;
44
- } catch (e) {}
45
-
46
- $w(this.element).attr(attrs[i], newValue);
47
-
48
- }
49
-
50
- },
51
-
52
- getEditIconId: function(attributeName) {
53
-
54
- return this.element.id +
55
- whowishWordVariables.separator +
56
- attributeName;
57
- },
58
-
59
-
60
-
61
- getRelevantAttributes: function() {
62
-
63
- var attrs = [];
64
-
65
- for (var i = 0; i < this.element.attributes.length; i++) {
66
-
67
- if (this.element.attributes[i].name.toLowerCase() == "id") continue;
68
- if (this.element.attributes[i].name.toLowerCase() == "value") continue;
69
-
70
- if (this.element.attributes[i].value.match(whowishWordVariables.attributeValuePattern) != null) {
71
- attrs.push(this.element.attributes[i].name);
72
- }
73
-
74
- }
75
-
76
- return attrs;
77
-
78
- }
79
-
80
-
81
-
1
+ var WhowishWordElementCreator = WhowishWordCreator.extend({
2
+
3
+ makeEditIcon: function(){
4
+
5
+ this.attrs = WhowishWordElementGuard.getRelevantAttributes(this.element);
6
+ var attrs = this.attrs;
7
+
8
+ for (var i=0;i<attrs.length;i++) {
9
+
10
+ var editIcon = document.createElement('span');
11
+ $w(editIcon).addClass('whowishWordEditIcon');
12
+ $w(editIcon).attr('id', whowishWordHelper.makeEditIconId(this.element, attrs[i]));
13
+ $w(editIcon).attr('title', attrs[i]);
14
+
15
+ var whowishWordIdPackage = whowishWordHelper.extractWhowishWordIdFromText($w(this.element).attr(attrs[i]));
16
+ var idPackage = whowishWordHelper.parseWhowishWordIdPackage(whowishWordIdPackage);
17
+
18
+
19
+ customData = {};
20
+ customData.contentHandler = new WhowishWordAttributeHandler(this.element, attrs[i]);
21
+
22
+ customData.id = idPackage.id;
23
+ customData.variables = idPackage.variables;
24
+ customData.attributeName = attrs[i];
25
+
26
+ whowishWordStorage[editIcon.id] = customData;
27
+
28
+ this.addEditIcon(editIcon);
29
+ }
30
+
31
+ },
32
+
33
+
34
+ sanitize: function(){
35
+
36
+ var attrs = this.attrs;
37
+
38
+ for (var i=0;i<attrs.length;i++) {
39
+
40
+ var newValue = whowishWordHelper.sanitize($w(this.element).attr(attrs[i]));
41
+
42
+ try {
43
+ this.element[attrs[i]] = newValue;
44
+ } catch(e) {}
45
+
46
+ try {
47
+ this.element.attributes[attrs[i]].value = newValue;
48
+ } catch (e) {}
49
+
50
+ $w(this.element).attr(attrs[i], newValue);
51
+
52
+ }
53
+
54
+ },
55
+
56
+
57
+
82
58
  });
@@ -0,0 +1,32 @@
1
+ var WhowishWordElementGuard = {
2
+
3
+ check: function(element){
4
+ return (this.getRelevantAttributes(element).length > 0)
5
+ },
6
+
7
+ getRelevantAttributes: function(element) {
8
+
9
+ var attrs = [];
10
+
11
+ for (var i = 0; i < element.attributes.length; i++) {
12
+
13
+ var attr_name = element.attributes[i].name.toLowerCase();
14
+
15
+ if (attr_name == "id") continue;
16
+ if (attr_name == "value") continue;
17
+ if ($w('#' + whowishWordHelper.makeEditIconId(element, attr_name)).length > 0) continue;
18
+
19
+ var value = element.attributes[i].value;
20
+
21
+ if (typeof(value).toLowerCase() != "string") continue;
22
+
23
+ if (whowishWordHelper.match(value)) {
24
+ attrs.push(element.attributes[i].name);
25
+ }
26
+
27
+ }
28
+
29
+ return attrs;
30
+
31
+ }
32
+ };
@@ -1,19 +1,19 @@
1
- var WhowishWordHtmlCreator = WhowishWordCommonCreator.extend({
2
-
3
- identity: function() {
4
- return 'html';
5
- },
6
-
7
- getContent: function() {
8
- return $w(this.element).html();
9
- },
10
-
11
- setContent: function(content) {
12
- $w(this.element).html(content);
13
- },
14
-
15
- instantiateAndGetContentHandler: function() {
16
- return new WhowishWordHtmlHandler(this.element);
17
- }
18
-
1
+ var WhowishWordHtmlCreator = WhowishWordCommonCreator.extend({
2
+
3
+ identity: function() {
4
+ return 'html';
5
+ },
6
+
7
+ getContent: function() {
8
+ return $w(this.element).html();
9
+ },
10
+
11
+ setContent: function(content) {
12
+ $w(this.element).html(content);
13
+ },
14
+
15
+ instantiateAndGetContentHandler: function() {
16
+ return new WhowishWordHtmlHandler(this.element);
17
+ }
18
+
19
19
  });
@@ -0,0 +1,12 @@
1
+ var WhowishWordHtmlGuard = {
2
+
3
+ check: function(element) {
4
+ return (element.tagName.toLowerCase() == "dfn"
5
+ || element.tagName.toLowerCase() == "button"
6
+ || element.tagName.toLowerCase() == "label")
7
+ && (typeof(html = $w(element).html())).toLowerCase() == "string"
8
+ && whowishWordHelper.match(html)
9
+ && ($w('#' + whowishWordHelper.makeEditIconId(element, 'html')).length == 0);
10
+ }
11
+
12
+ };
@@ -1,11 +1,11 @@
1
- var WhowishWordSelectCreator = WhowishWordCreator.extend({
2
-
3
- makeEditIcon: function() {
4
-
5
- },
6
-
7
- sanitize: function() {
8
-
9
- }
10
-
1
+ var WhowishWordSelectCreator = WhowishWordCreator.extend({
2
+
3
+ makeEditIcon: function() {
4
+
5
+ },
6
+
7
+ sanitize: function() {
8
+
9
+ }
10
+
11
11
  });
@@ -1,20 +1,20 @@
1
- var WhowishWordTextCreator = WhowishWordCommonCreator.extend({
2
-
3
- identity: function() {
4
- return 'text';
5
- },
6
-
7
- getContent: function() {
8
- return $w(this.element).text();
9
- },
10
-
11
- setContent: function(content) {
12
- $w(this.element).text(content);
13
- },
14
-
15
- instantiateAndGetContentHandler: function() {
16
- return new WhowishWordTextHandler(this.element);
17
- }
18
-
19
-
1
+ var WhowishWordTextCreator = WhowishWordCommonCreator.extend({
2
+
3
+ identity: function() {
4
+ return 'text';
5
+ },
6
+
7
+ getContent: function() {
8
+ return $w(this.element).text();
9
+ },
10
+
11
+ setContent: function(content) {
12
+ $w(this.element).text(content);
13
+ },
14
+
15
+ instantiateAndGetContentHandler: function() {
16
+ return new WhowishWordTextHandler(this.element);
17
+ }
18
+
19
+
20
20
  });
@@ -0,0 +1,10 @@
1
+ var WhowishWordTextGuard = {
2
+
3
+ check: function(element) {
4
+ return element.tagName.toLowerCase() == "option"
5
+ && (typeof(text = $w(element).text())).toLowerCase() == "string"
6
+ && whowishWordHelper.match(text)
7
+ && ($w('#' + whowishWordHelper.makeEditIconId(element, 'text')).length == 0);
8
+ }
9
+
10
+ };
@@ -1,20 +1,20 @@
1
- var WhowishWordValueCreator = WhowishWordCommonCreator.extend({
2
-
3
- identity: function() {
4
- return 'value';
5
- },
6
-
7
- getContent: function() {
8
- return $w(this.element).val();
9
- },
10
-
11
- setContent: function(content) {
12
- $w(this.element).val(content);
13
- },
14
-
15
- instantiateAndGetContentHandler: function() {
16
- return new WhowishWordValueHandler(this.element);
17
- }
18
-
19
-
1
+ var WhowishWordValueCreator = WhowishWordCommonCreator.extend({
2
+
3
+ identity: function() {
4
+ return 'value';
5
+ },
6
+
7
+ getContent: function() {
8
+ return $w(this.element).val();
9
+ },
10
+
11
+ setContent: function(content) {
12
+ $w(this.element).val(content);
13
+ },
14
+
15
+ instantiateAndGetContentHandler: function() {
16
+ return new WhowishWordValueHandler(this.element);
17
+ }
18
+
19
+
20
20
  });
@@ -0,0 +1,24 @@
1
+ var WhowishWordValueGuardAndSanitizer = {
2
+
3
+ check: function(element) {
4
+
5
+ var val;
6
+
7
+ if (element.tagName.toLowerCase() != "select"
8
+ && (typeof(val = $w(element).val())).toLowerCase() == "string"
9
+ && whowishWordHelper.match(val)) {
10
+
11
+ if ($w('#'+whowishWordHelper.makeEditIconId(element, "value")).length == 0) {
12
+ return true;
13
+ } else {
14
+ $w(element).val(whowishWordHelper.sanitize(val));
15
+ }
16
+
17
+ }
18
+
19
+ return false;
20
+
21
+ }
22
+
23
+
24
+ };
@@ -1,25 +1,25 @@
1
- var WhowishWordAttributeHandler = WhowishWordContentHandler.extend({
2
-
3
- init: function(elem,attributeName){
4
- this.element = elem;
5
- this.attributeName = attributeName;
6
- },
7
-
8
- setContent: function(content){
9
-
10
- try {
11
- this.element[this.attributeName] = content;
12
- } catch(e) {}
13
-
14
- try {
15
- this.element.attributes[this.attributeName].value = content;
16
- } catch (e) {}
17
-
18
- $w(this.element).attr(this.attributeName, content);
19
- },
20
-
21
- getContent: function(){
22
- return $(this.element).attr(this.attributeName);
23
- }
24
-
1
+ var WhowishWordAttributeHandler = WhowishWordContentHandler.extend({
2
+
3
+ init: function(elem,attributeName){
4
+ this.element = elem;
5
+ this.attributeName = attributeName;
6
+ },
7
+
8
+ setContent: function(content){
9
+
10
+ try {
11
+ this.element[this.attributeName] = content;
12
+ } catch(e) {}
13
+
14
+ try {
15
+ this.element.attributes[this.attributeName].value = content;
16
+ } catch (e) {}
17
+
18
+ $w(this.element).attr(this.attributeName, content);
19
+ },
20
+
21
+ getContent: function(){
22
+ return $(this.element).attr(this.attributeName);
23
+ }
24
+
25
25
  });
@@ -1,15 +1,15 @@
1
- var WhowishWordHtmlHandler = WhowishWordContentHandler.extend({
2
-
3
- init: function(elem){
4
- this.element = elem;
5
- },
6
-
7
- setContent: function(content){
8
- $w(this.element).html(content);
9
- },
10
-
11
- getContent: function(){
12
- return $w(this.element).html();
13
- }
14
-
1
+ var WhowishWordHtmlHandler = WhowishWordContentHandler.extend({
2
+
3
+ init: function(elem){
4
+ this.element = elem;
5
+ },
6
+
7
+ setContent: function(content){
8
+ $w(this.element).html(content);
9
+ },
10
+
11
+ getContent: function(){
12
+ return $w(this.element).html();
13
+ }
14
+
15
15
  });
@@ -1,15 +1,15 @@
1
- var WhowishWordTextHandler = WhowishWordContentHandler.extend({
2
-
3
- init: function(elem){
4
- this.element = elem;
5
- },
6
-
7
- setContent: function(content){
8
- $w(this.element).text(content);
9
- },
10
-
11
- getContent: function() {
12
- return $w(this.element).text();
13
- }
14
-
1
+ var WhowishWordTextHandler = WhowishWordContentHandler.extend({
2
+
3
+ init: function(elem){
4
+ this.element = elem;
5
+ },
6
+
7
+ setContent: function(content){
8
+ $w(this.element).text(content);
9
+ },
10
+
11
+ getContent: function() {
12
+ return $w(this.element).text();
13
+ }
14
+
15
15
  });
@@ -1,19 +1,25 @@
1
- var WhowishWordValueHandler = WhowishWordContentHandler.extend({
2
-
3
- init: function(elem){
4
- this.element = elem;
5
- },
6
-
7
- setContent: function(content){
8
- $w(this.element).val(content);
9
-
10
- if (this.element.attributes['value'] != undefined) {
11
- this.element.attributes['value'].value = content;
12
- }
13
- },
14
-
15
- getContent: function(){
16
- return $w(this.element).val();
17
- }
18
-
1
+ var WhowishWordValueHandler = WhowishWordContentHandler.extend({
2
+
3
+ init: function(elem){
4
+ this.element = elem;
5
+ },
6
+
7
+ setContent: function(content){
8
+ $w(this.element).val(content);
9
+
10
+ if (this.element.attributes['value'] != undefined) {
11
+ this.element.attributes['value'].value = content;
12
+ }
13
+
14
+ if (this.element.value != undefined) {
15
+ this.element.value = content;
16
+ }
17
+
18
+ $w(this.element).attr('value', content);
19
+ },
20
+
21
+ getContent: function(){
22
+ return $w(this.element).val();
23
+ }
24
+
19
25
  });