whowish_word 0.1.3 → 0.1.4

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.
Files changed (44) hide show
  1. data/README.md +12 -1
  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 +71 -64
  6. data/lib/whowish_word/rails/public/javascripts/3_whowish_word_dialog.js +136 -136
  7. data/lib/whowish_word/rails/public/javascripts/3_whowish_word_helper.js +95 -92
  8. data/lib/whowish_word/rails/public/javascripts/4_whowish_word.js +43 -43
  9. data/lib/whowish_word/rails/public/javascripts/4_whowish_word_content_handler.js +15 -15
  10. data/lib/whowish_word/rails/public/javascripts/5_whowish_word_common_creator.js +48 -48
  11. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_element_creator.js +81 -81
  12. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_html_creator.js +18 -18
  13. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_select_creator.js +10 -10
  14. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_text_creator.js +19 -19
  15. data/lib/whowish_word/rails/public/javascripts/6_whowish_word_value_creator.js +19 -19
  16. data/lib/whowish_word/rails/public/javascripts/7_whowish_word_attribute_handler.js +24 -24
  17. data/lib/whowish_word/rails/public/javascripts/7_whowish_word_html_handler.js +14 -14
  18. data/lib/whowish_word/rails/public/javascripts/7_whowish_word_text_handler.js +14 -14
  19. data/lib/whowish_word/rails/public/javascripts/7_whowish_word_value_handler.js +18 -18
  20. data/lib/whowish_word/rails/public/stylesheets/whowish_word.css +197 -197
  21. data/rails/Gemfile.lock +130 -130
  22. data/rails/Rakefile +7 -7
  23. data/rails/app/assets/javascripts/integration.js +2 -2
  24. data/rails/app/assets/javascripts/test_javascript.js +2 -2
  25. data/rails/app/assets/javascripts/test_word_for.js +2 -2
  26. data/rails/app/assets/stylesheets/integration.css +4 -4
  27. data/rails/app/assets/stylesheets/test_javascript.css +4 -4
  28. data/rails/app/assets/stylesheets/test_word_for.css +4 -4
  29. data/rails/app/controllers/integration_controller.rb +5 -5
  30. data/rails/app/controllers/test_javascript_controller.rb +11 -11
  31. data/rails/app/controllers/test_word_for_controller.rb +5 -5
  32. data/rails/app/helpers/integration_helper.rb +2 -2
  33. data/rails/app/helpers/test_javascript_helper.rb +2 -2
  34. data/rails/app/helpers/test_word_for_helper.rb +2 -2
  35. data/rails/public/jasmine/MIT.LICENSE +20 -20
  36. data/rails/public/jasmine/jasmine-html.js +190 -190
  37. data/rails/public/jasmine/jasmine.css +166 -166
  38. data/rails/public/jasmine/jasmine.js +2476 -2476
  39. data/rails/public/javascripts/jquery-1.6.4.js +9046 -9046
  40. data/rails/public/sinonjs/sinonjs.js +2821 -2821
  41. data/rails/public/stylesheets/main.css +21 -21
  42. data/whowish_word.gemspec +21 -21
  43. metadata +3 -4
  44. data/config.ru +0 -4
@@ -1,92 +1,95 @@
1
- /**
2
- * @author Tanin
3
- */
4
- var whowishWordHelper = {};
5
-
6
- function log(msg) {
7
- try {
8
- console.log(msg);
9
- } catch (e) {}
10
- };
11
-
12
- whowishWordHelper.repositionAllEditIconPanels = function() {
13
-
14
- var editIconPanels = $w('.whowishWordEditIconPanel');
15
- for (var i=0;i<editIconPanels.length;i++) {
16
- editIconPanels[i].whowishWord.reposition();
17
- }
18
-
19
- };
20
-
21
-
22
- whowishWordHelper.editIconPanelRepositioning = function() {
23
-
24
- var pos = $w(this.element).position();
25
- var marginLeft = $w(this.element).margin().left;
26
- var marginTop = $w(this.element).margin().top;
27
- var outdent = 10;
28
-
29
- $w(this.editIconPanel).css('position', 'absolute')
30
- .css('left', (pos.left - outdent + marginLeft) + 'px')
31
- .css('top', (pos.top - outdent + marginTop) + 'px');
32
-
33
- };
34
-
35
-
36
- whowishWordHelper.editHandler = function() {
37
-
38
- var self = this;
39
-
40
- $w.whowishWordDialog.open({
41
-
42
- whowishWordId: this.whowishWord.id,
43
- variables: this.whowishWord.variables,
44
- attributeName: this.whowishWord.attributeName,
45
- content: this.whowishWord.contentHandler.getContent(),
46
- success: function(html){
47
-
48
- $w.whowishWordDialog.start_loading();
49
-
50
- $w.ajax({
51
- type: "POST",
52
- url: '/whowish_word/change_word',
53
- cache: false,
54
- headers: {
55
- "Connection": "close"
56
- },
57
- data: {
58
- "word_id": self.whowishWord.id,
59
- "content": html
60
- },
61
- success: function(data) {
62
- self.whowishWord.contentHandler.setContent(html);
63
- $w.whowishWordDialog.close();
64
- $w.whowishWordDialog.stop_loading();
65
- },
66
- error: function(req, status, e){
67
- alert('WhowishWord cannot save the data. The Ajax resquest is not sent. Please try again later.');
68
- $w.whowishWordDialog.stop_loading();
69
- }
70
- });
71
-
72
- }
73
- });
74
-
75
- };
76
-
77
-
78
- whowishWordHelper.extractWhowishWordIdFromText = function(text) {
79
- var result = text.match(whowishWordVariables.attributeValuePattern);
80
- return result[1];
81
-
82
- };
83
-
84
-
85
- whowishWordHelper.parseWhowishWordIdPackage = function(whowishWordIdPackage){
86
- var result = whowishWordIdPackage.match(whowishWordVariables.whowishWordIdPattern);
87
-
88
- return {
89
- id: result[1],
90
- variables: result[3]
91
- };
92
- };
1
+ /**
2
+ * @author Tanin
3
+ */
4
+ var whowishWordHelper = {};
5
+
6
+ function log(msg) {
7
+ try {
8
+ console.log(msg);
9
+ } catch (e) {}
10
+ };
11
+
12
+ whowishWordHelper.repositionAllEditIconPanels = function() {
13
+
14
+ var editIconPanels = $w('.whowishWordEditIconPanel');
15
+ for (var i=0;i<editIconPanels.length;i++) {
16
+ editIconPanels[i].whowishWord.reposition();
17
+ }
18
+
19
+ };
20
+
21
+
22
+ whowishWordHelper.editIconPanelRepositioning = function() {
23
+
24
+ var pos = $w(this.element).position();
25
+ var marginLeft = $w(this.element).margin().left;
26
+ var marginTop = $w(this.element).margin().top;
27
+ var outdent = 10;
28
+
29
+ $w(this.editIconPanel).css('position', 'absolute')
30
+ .css('left', (pos.left - outdent + marginLeft) + 'px')
31
+ .css('top', (pos.top - outdent + marginTop) + 'px');
32
+
33
+ };
34
+
35
+
36
+ whowishWordHelper.editHandler = function(event) {
37
+
38
+ event.stopPropagation();
39
+ event.preventDefault()
40
+
41
+ var self = this;
42
+
43
+ $w.whowishWordDialog.open({
44
+
45
+ whowishWordId: this.whowishWord.id,
46
+ variables: this.whowishWord.variables,
47
+ attributeName: this.whowishWord.attributeName,
48
+ content: this.whowishWord.contentHandler.getContent(),
49
+ success: function(html){
50
+
51
+ $w.whowishWordDialog.start_loading();
52
+
53
+ $w.ajax({
54
+ type: "POST",
55
+ url: '/whowish_word/change_word',
56
+ cache: false,
57
+ headers: {
58
+ "Connection": "close"
59
+ },
60
+ data: {
61
+ "word_id": self.whowishWord.id,
62
+ "content": html
63
+ },
64
+ success: function(data) {
65
+ self.whowishWord.contentHandler.setContent(html);
66
+ $w.whowishWordDialog.close();
67
+ $w.whowishWordDialog.stop_loading();
68
+ },
69
+ error: function(req, status, e){
70
+ alert('WhowishWord cannot save the data. The Ajax resquest is not sent. Please try again later.');
71
+ $w.whowishWordDialog.stop_loading();
72
+ }
73
+ });
74
+
75
+ }
76
+ });
77
+
78
+ };
79
+
80
+
81
+ whowishWordHelper.extractWhowishWordIdFromText = function(text) {
82
+ var result = text.match(whowishWordVariables.attributeValuePattern);
83
+ return result[1];
84
+
85
+ };
86
+
87
+
88
+ whowishWordHelper.parseWhowishWordIdPackage = function(whowishWordIdPackage){
89
+ var result = whowishWordIdPackage.match(whowishWordVariables.whowishWordIdPattern);
90
+
91
+ return {
92
+ id: result[1],
93
+ variables: result[3]
94
+ };
95
+ };
@@ -1,43 +1,43 @@
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
+ (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,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
+ });
@@ -1,49 +1,49 @@
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
+ 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
+
49
49
  });
@@ -1,82 +1,82 @@
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
+ 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
+
82
82
  });
@@ -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
  });
@@ -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
  });