whowish_word 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/.gitignore +5 -5
  2. data/.loadpath +5 -5
  3. data/.project +18 -17
  4. data/Gemfile +2 -2
  5. data/HOW_TO_BUILD_WHOWISH_HOOK.md +9 -9
  6. data/ISSUE.md +93 -93
  7. data/README.md +208 -208
  8. data/lib/whowish_word/action_controller/base.rb +44 -44
  9. data/lib/whowish_word/action_mailer/base.rb +11 -11
  10. data/lib/whowish_word/action_view/base.rb +70 -70
  11. data/lib/whowish_word/action_view/template.rb +30 -30
  12. data/lib/whowish_word/authentication.rb +13 -13
  13. data/lib/whowish_word/config.rb +21 -21
  14. data/lib/whowish_word/constant.rb +8 -8
  15. data/lib/whowish_word/db_migration/active_record/whowish_word_html.rb +14 -14
  16. data/lib/whowish_word/db_migration/mongoid/whowish_word_html.rb +5 -5
  17. data/lib/whowish_word/initializer.rb +52 -52
  18. data/lib/whowish_word/rails/app/controllers/whowish_word_controller.rb +60 -60
  19. data/lib/whowish_word/rails/app/models/active_record/whowish_word_html.rb +3 -3
  20. data/lib/whowish_word/rails/app/models/mongoid/whowish_word_html.rb +8 -8
  21. data/lib/whowish_word/rails/public/javascripts/0_jquery-1.6.4-whowish_word.js +9046 -9046
  22. data/lib/whowish_word/rails/public/javascripts/1_csrf_token_hook.js +9 -9
  23. data/lib/whowish_word/rails/public/javascripts/1_jquery.loading_button.js +66 -66
  24. data/lib/whowish_word/rails/public/javascripts/2_whowish_word_variables.js +33 -33
  25. data/lib/whowish_word/rails/public/javascripts/3_whowish_word_dialog.js +136 -136
  26. data/lib/whowish_word/rails/public/javascripts/3_whowish_word_helper.js +116 -116
  27. data/lib/whowish_word/rails/public/javascripts/4_whowish_word_creator.js +69 -69
  28. data/lib/whowish_word/whowish_word.rb +41 -41
  29. data/lib/whowish_word/word_for.rb +93 -93
  30. data/rails/Gemfile +18 -18
  31. data/rails/Gemfile.lock +63 -64
  32. data/rails/app/controllers/application_controller.rb +22 -22
  33. data/rails/app/controllers/home_controller.rb +8 -8
  34. data/rails/app/views/home/index.html.erb +109 -109
  35. data/rails/app/views/home/static_edit.html.erb +50 -50
  36. data/rails/app/views/home/static_edit_select.html.erb +8 -8
  37. data/rails/app/views/integration/attr.html.erb +1 -1
  38. data/rails/app/views/integration/index.html.erb +1 -1
  39. data/rails/app/views/integration/select.html.erb +3 -3
  40. data/rails/app/views/integration/value.html.erb +1 -1
  41. data/rails/app/views/layouts/integration.html.erb +14 -14
  42. data/rails/app/views/layouts/main.html.erb +13 -13
  43. data/rails/app/views/layouts/nested_test_word_for.html.erb +17 -17
  44. data/rails/app/views/layouts/test_javascript.html.erb +13 -13
  45. data/rails/app/views/layouts/test_word_for.html.erb +24 -24
  46. data/rails/app/views/test_javascript/change_value.html.erb +32 -32
  47. data/rails/app/views/test_javascript/index.html.erb +87 -87
  48. data/rails/app/views/test_javascript/replace_with_html.html.erb +96 -96
  49. data/rails/app/views/test_word_for/_partial.html.erb +4 -4
  50. data/rails/app/views/test_word_for/index.html.erb +8 -8
  51. data/rails/config/application.rb +30 -30
  52. data/rails/config/boot.rb +9 -9
  53. data/rails/config/database.yml +24 -24
  54. data/rails/config/environment.rb +16 -16
  55. data/rails/config/initializers/whowish_word.rb +3 -3
  56. data/rails/config/mongoid.rb +6 -6
  57. data/rails/config/mongoid.yml +14 -14
  58. data/rails/config/routes.rb +7 -7
  59. data/rails/config.ru +4 -4
  60. data/rails/log/.gitignore +1 -1
  61. data/rails/mongo.bat +4 -4
  62. data/rails/public/javascripts/jquery.loading_button.js +72 -72
  63. data/rails/public/test/jquery_version.html +26 -26
  64. data/rails/script/rails +6 -6
  65. data/rails/spec/controllers/whowish_word_controller_spec.rb +55 -55
  66. data/rails/spec/integration/whowish_word_generator_spec.rb +139 -139
  67. data/rails/spec/integration/whowish_word_spec.rb +116 -116
  68. data/rails/spec/spec_helper.rb +34 -36
  69. data/rails/spec/support/browser.rb +193 -193
  70. data/rails/spec/support/json_rspec_helper.rb +8 -8
  71. data/rails/spec/support/mongoid_helper.rb +9 -9
  72. data/spec/spec_helper.rb +17 -19
  73. data/spec/unit/word_for_attr_in_edit_mode_spec.rb +43 -43
  74. data/spec/unit/word_for_attr_spec.rb +43 -43
  75. data/spec/unit/word_for_in_edit_mode_spec.rb +43 -43
  76. data/spec/unit/word_for_spec.rb +43 -43
  77. data/whowish_word.gemspec +21 -21
  78. metadata +73 -4
@@ -1,9 +1,9 @@
1
- /**
2
- * @author Tanin
3
- */
4
- $w.ajaxSetup({
5
- beforeSend: function(xhr) {
6
- xhr.setRequestHeader('X-CSRF-Token', $w('meta[name="csrf-token"]').attr('content'));
7
- }
8
- });
9
-
1
+ /**
2
+ * @author Tanin
3
+ */
4
+ $w.ajaxSetup({
5
+ beforeSend: function(xhr) {
6
+ xhr.setRequestHeader('X-CSRF-Token', $w('meta[name="csrf-token"]').attr('content'));
7
+ }
8
+ });
9
+
@@ -1,66 +1,66 @@
1
- (function($w){
2
-
3
- $w.fn.extend({
4
-
5
- loading_icon:function(enabled)
6
- {
7
- return this.each(function() {
8
-
9
- if (enabled == true)
10
- {
11
- if (this.loading == true) return;
12
- this.loading = true;
13
- this.save_background = $w(this).css('background-image');
14
- $w(this).css('background-image','url()');
15
-
16
- $w(this).html('<span style="display:inline-block;width:100%;height:100%;vertical-align:top;background-image:url(\'data:image/gif;base64,R0lGODlhEAALAPQAAP///0tMSuTk5N3d3e/v709QTktMSmtsaqanpo6Pjs7OzWJjYn9/fqysq5GSkNDR0GVmZE1OTIGCge3t7OPj4/b29nJzcebm5fX19cvLyru8u9nZ2fLy8gAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCwAAACwAAAAAEAALAAAFLSAgjmRpnqSgCuLKAq5AEIM4zDVw03ve27ifDgfkEYe04kDIDC5zrtYKRa2WQgAh+QQJCwAAACwAAAAAEAALAAAFJGBhGAVgnqhpHIeRvsDawqns0qeN5+y967tYLyicBYE7EYkYAgAh+QQJCwAAACwAAAAAEAALAAAFNiAgjothLOOIJAkiGgxjpGKiKMkbz7SN6zIawJcDwIK9W/HISxGBzdHTuBNOmcJVCyoUlk7CEAAh+QQJCwAAACwAAAAAEAALAAAFNSAgjqQIRRFUAo3jNGIkSdHqPI8Tz3V55zuaDacDyIQ+YrBH+hWPzJFzOQQaeavWi7oqnVIhACH5BAkLAAAALAAAAAAQAAsAAAUyICCOZGme1rJY5kRRk7hI0mJSVUXJtF3iOl7tltsBZsNfUegjAY3I5sgFY55KqdX1GgIAIfkECQsAAAAsAAAAABAACwAABTcgII5kaZ4kcV2EqLJipmnZhWGXaOOitm2aXQ4g7P2Ct2ER4AMul00kj5g0Al8tADY2y6C+4FIIACH5BAkLAAAALAAAAAAQAAsAAAUvICCOZGme5ERRk6iy7qpyHCVStA3gNa/7txxwlwv2isSacYUc+l4tADQGQ1mvpBAAIfkECQsAAAAsAAAAABAACwAABS8gII5kaZ7kRFGTqLLuqnIcJVK0DeA1r/u3HHCXC/aKxJpxhRz6Xi0ANAZDWa+kEAA7AAAAAAAAAAAA\');background-repeat:no-repeat;" onclick="if (event.stopPropagation) event.stopPropagation();event.cancelBubble = true;return false;"></span>');
17
- }
18
- else
19
- {
20
- if (this.loading == undefined || this.loading == false) return;
21
- this.loading = false;
22
- $w(this).html('');
23
- $w(this).css('background-image',this.save_background);
24
- }
25
-
26
- });
27
-
28
- },
29
-
30
- //pass the options variable to the function
31
- loading_button: function(enabled,options) {
32
-
33
-
34
- //Set the default values, use comma to separate the settings, example:
35
- var defaults = {
36
- image : '<img src="data:image/gif;base64,R0lGODlhEAALAPQAAP///0tMSuTk5N3d3e/v709QTktMSmtsaqanpo6Pjs7OzWJjYn9/fqysq5GSkNDR0GVmZE1OTIGCge3t7OPj4/b29nJzcebm5fX19cvLyru8u9nZ2fLy8gAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCwAAACwAAAAAEAALAAAFLSAgjmRpnqSgCuLKAq5AEIM4zDVw03ve27ifDgfkEYe04kDIDC5zrtYKRa2WQgAh+QQJCwAAACwAAAAAEAALAAAFJGBhGAVgnqhpHIeRvsDawqns0qeN5+y967tYLyicBYE7EYkYAgAh+QQJCwAAACwAAAAAEAALAAAFNiAgjothLOOIJAkiGgxjpGKiKMkbz7SN6zIawJcDwIK9W/HISxGBzdHTuBNOmcJVCyoUlk7CEAAh+QQJCwAAACwAAAAAEAALAAAFNSAgjqQIRRFUAo3jNGIkSdHqPI8Tz3V55zuaDacDyIQ+YrBH+hWPzJFzOQQaeavWi7oqnVIhACH5BAkLAAAALAAAAAAQAAsAAAUyICCOZGme1rJY5kRRk7hI0mJSVUXJtF3iOl7tltsBZsNfUegjAY3I5sgFY55KqdX1GgIAIfkECQsAAAAsAAAAABAACwAABTcgII5kaZ4kcV2EqLJipmnZhWGXaOOitm2aXQ4g7P2Ct2ER4AMul00kj5g0Al8tADY2y6C+4FIIACH5BAkLAAAALAAAAAAQAAsAAAUvICCOZGme5ERRk6iy7qpyHCVStA3gNa/7txxwlwv2isSacYUc+l4tADQGQ1mvpBAAIfkECQsAAAAsAAAAABAACwAABS8gII5kaZ7kRFGTqLLuqnIcJVK0DeA1r/u3HHCXC/aKxJpxhRz6Xi0ANAZDWa+kEAA7AAAAAAAAAAAA">',
37
- word: 'Loading'
38
- }
39
-
40
- var options = $w.extend(defaults, options);
41
-
42
- return this.each(function() {
43
-
44
- if (enabled == true)
45
- {
46
- var inside_content = $w(this).html();
47
-
48
- $w(this).html('<span style="display:inline-block;width:100%;height:100%;" onclick="if (event.stopPropagation) event.stopPropagation();event.cancelBubble = true;return false;">'+options.image + ' ' + options.word+'</span>');
49
-
50
- $w(this).append('<span class="loading_button_hidden_div" style="display: none;">'+inside_content+'</span>');
51
- }
52
- else
53
- {
54
- var hidden_div = $w('.loading_button_hidden_div',this);
55
-
56
- if (hidden_div.length == 0) return;
57
-
58
- $w(this).html($w(hidden_div).html());
59
- }
60
-
61
- });
62
- }
63
- });
64
-
65
- })(jQueryWhowishWord);
66
-
1
+ (function($w){
2
+
3
+ $w.fn.extend({
4
+
5
+ loading_icon:function(enabled)
6
+ {
7
+ return this.each(function() {
8
+
9
+ if (enabled == true)
10
+ {
11
+ if (this.loading == true) return;
12
+ this.loading = true;
13
+ this.save_background = $w(this).css('background-image');
14
+ $w(this).css('background-image','url()');
15
+
16
+ $w(this).html('<span style="display:inline-block;width:100%;height:100%;vertical-align:top;background-image:url(\'data:image/gif;base64,R0lGODlhEAALAPQAAP///0tMSuTk5N3d3e/v709QTktMSmtsaqanpo6Pjs7OzWJjYn9/fqysq5GSkNDR0GVmZE1OTIGCge3t7OPj4/b29nJzcebm5fX19cvLyru8u9nZ2fLy8gAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCwAAACwAAAAAEAALAAAFLSAgjmRpnqSgCuLKAq5AEIM4zDVw03ve27ifDgfkEYe04kDIDC5zrtYKRa2WQgAh+QQJCwAAACwAAAAAEAALAAAFJGBhGAVgnqhpHIeRvsDawqns0qeN5+y967tYLyicBYE7EYkYAgAh+QQJCwAAACwAAAAAEAALAAAFNiAgjothLOOIJAkiGgxjpGKiKMkbz7SN6zIawJcDwIK9W/HISxGBzdHTuBNOmcJVCyoUlk7CEAAh+QQJCwAAACwAAAAAEAALAAAFNSAgjqQIRRFUAo3jNGIkSdHqPI8Tz3V55zuaDacDyIQ+YrBH+hWPzJFzOQQaeavWi7oqnVIhACH5BAkLAAAALAAAAAAQAAsAAAUyICCOZGme1rJY5kRRk7hI0mJSVUXJtF3iOl7tltsBZsNfUegjAY3I5sgFY55KqdX1GgIAIfkECQsAAAAsAAAAABAACwAABTcgII5kaZ4kcV2EqLJipmnZhWGXaOOitm2aXQ4g7P2Ct2ER4AMul00kj5g0Al8tADY2y6C+4FIIACH5BAkLAAAALAAAAAAQAAsAAAUvICCOZGme5ERRk6iy7qpyHCVStA3gNa/7txxwlwv2isSacYUc+l4tADQGQ1mvpBAAIfkECQsAAAAsAAAAABAACwAABS8gII5kaZ7kRFGTqLLuqnIcJVK0DeA1r/u3HHCXC/aKxJpxhRz6Xi0ANAZDWa+kEAA7AAAAAAAAAAAA\');background-repeat:no-repeat;" onclick="if (event.stopPropagation) event.stopPropagation();event.cancelBubble = true;return false;"></span>');
17
+ }
18
+ else
19
+ {
20
+ if (this.loading == undefined || this.loading == false) return;
21
+ this.loading = false;
22
+ $w(this).html('');
23
+ $w(this).css('background-image',this.save_background);
24
+ }
25
+
26
+ });
27
+
28
+ },
29
+
30
+ //pass the options variable to the function
31
+ loading_button: function(enabled,options) {
32
+
33
+
34
+ //Set the default values, use comma to separate the settings, example:
35
+ var defaults = {
36
+ image : '<img src="data:image/gif;base64,R0lGODlhEAALAPQAAP///0tMSuTk5N3d3e/v709QTktMSmtsaqanpo6Pjs7OzWJjYn9/fqysq5GSkNDR0GVmZE1OTIGCge3t7OPj4/b29nJzcebm5fX19cvLyru8u9nZ2fLy8gAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCwAAACwAAAAAEAALAAAFLSAgjmRpnqSgCuLKAq5AEIM4zDVw03ve27ifDgfkEYe04kDIDC5zrtYKRa2WQgAh+QQJCwAAACwAAAAAEAALAAAFJGBhGAVgnqhpHIeRvsDawqns0qeN5+y967tYLyicBYE7EYkYAgAh+QQJCwAAACwAAAAAEAALAAAFNiAgjothLOOIJAkiGgxjpGKiKMkbz7SN6zIawJcDwIK9W/HISxGBzdHTuBNOmcJVCyoUlk7CEAAh+QQJCwAAACwAAAAAEAALAAAFNSAgjqQIRRFUAo3jNGIkSdHqPI8Tz3V55zuaDacDyIQ+YrBH+hWPzJFzOQQaeavWi7oqnVIhACH5BAkLAAAALAAAAAAQAAsAAAUyICCOZGme1rJY5kRRk7hI0mJSVUXJtF3iOl7tltsBZsNfUegjAY3I5sgFY55KqdX1GgIAIfkECQsAAAAsAAAAABAACwAABTcgII5kaZ4kcV2EqLJipmnZhWGXaOOitm2aXQ4g7P2Ct2ER4AMul00kj5g0Al8tADY2y6C+4FIIACH5BAkLAAAALAAAAAAQAAsAAAUvICCOZGme5ERRk6iy7qpyHCVStA3gNa/7txxwlwv2isSacYUc+l4tADQGQ1mvpBAAIfkECQsAAAAsAAAAABAACwAABS8gII5kaZ7kRFGTqLLuqnIcJVK0DeA1r/u3HHCXC/aKxJpxhRz6Xi0ANAZDWa+kEAA7AAAAAAAAAAAA">',
37
+ word: 'Loading'
38
+ }
39
+
40
+ var options = $w.extend(defaults, options);
41
+
42
+ return this.each(function() {
43
+
44
+ if (enabled == true)
45
+ {
46
+ var inside_content = $w(this).html();
47
+
48
+ $w(this).html('<span style="display:inline-block;width:100%;height:100%;" onclick="if (event.stopPropagation) event.stopPropagation();event.cancelBubble = true;return false;">'+options.image + ' ' + options.word+'</span>');
49
+
50
+ $w(this).append('<span class="loading_button_hidden_div" style="display: none;">'+inside_content+'</span>');
51
+ }
52
+ else
53
+ {
54
+ var hidden_div = $w('.loading_button_hidden_div',this);
55
+
56
+ if (hidden_div.length == 0) return;
57
+
58
+ $w(this).html($w(hidden_div).html());
59
+ }
60
+
61
+ });
62
+ }
63
+ });
64
+
65
+ })(jQueryWhowishWord);
66
+
@@ -1,33 +1,33 @@
1
- /**
2
- * @author Tanin
3
- */
4
- var whowishWordVariables = {
5
- idRunner: 0,
6
- separator: "_____"
7
- };
8
-
9
- whowishWordVariables.attributeValuePattern = new RegExp("^__whowishWord__" +
10
- whowishWordVariables.separator +
11
- "(.+)" +
12
- whowishWordVariables.separator + "(.+)");
13
-
14
- whowishWordVariables.whowishWordIdPattern = new RegExp("([^\|]+)(\|(.*))?");
15
-
16
- whowishWordVariables.matchers = [
17
- {
18
- match: function(element){ return WhowishWordElementGuard.check(element); },
19
- createWhowishWord: function(element) { new WhowishWordElementCreator(element); }
20
- },
21
- {
22
- match: function(element) { return WhowishWordHtmlGuard.check(element); },
23
- createWhowishWord: function(element) { new WhowishWordHtmlCreator(element); }
24
- },
25
- {
26
- match: function(element) { return WhowishWordValueGuardAndSanitizer.check(element); },
27
- createWhowishWord: function(element) { new WhowishWordValueCreator(element); }
28
- },
29
- {
30
- match: function(element) { return WhowishWordTextGuard.check(element); },
31
- createWhowishWord: function(element) { new WhowishWordTextCreator(element); }
32
- }
33
- ];
1
+ /**
2
+ * @author Tanin
3
+ */
4
+ var whowishWordVariables = {
5
+ idRunner: 0,
6
+ separator: "_____"
7
+ };
8
+
9
+ whowishWordVariables.attributeValuePattern = new RegExp("^__whowishWord__" +
10
+ whowishWordVariables.separator +
11
+ "(.+)" +
12
+ whowishWordVariables.separator + "(.+)");
13
+
14
+ whowishWordVariables.whowishWordIdPattern = new RegExp("([^\|]+)(\|(.*))?");
15
+
16
+ whowishWordVariables.matchers = [
17
+ {
18
+ match: function(element){ return WhowishWordElementGuard.check(element); },
19
+ createWhowishWord: function(element) { new WhowishWordElementCreator(element); }
20
+ },
21
+ {
22
+ match: function(element) { return WhowishWordHtmlGuard.check(element); },
23
+ createWhowishWord: function(element) { new WhowishWordHtmlCreator(element); }
24
+ },
25
+ {
26
+ match: function(element) { return WhowishWordValueGuardAndSanitizer.check(element); },
27
+ createWhowishWord: function(element) { new WhowishWordValueCreator(element); }
28
+ },
29
+ {
30
+ match: function(element) { return WhowishWordTextGuard.check(element); },
31
+ createWhowishWord: function(element) { new WhowishWordTextCreator(element); }
32
+ }
33
+ ];
@@ -1,136 +1,136 @@
1
- /**
2
- * @author Tanin Na Nakorn
3
- */
4
- (function($w){
5
-
6
- $w.extend({
7
-
8
- whowishWordDialog: {
9
-
10
- start_loading: function() {
11
- $w('#whowishWordDialog').find(".saveButton").loading_button(true);
12
- },
13
-
14
- stop_loading: function() {
15
- $w('#whowishWordDialog').find(".saveButton").loading_button(false);
16
- },
17
-
18
- close: function() {
19
- whowishWordDialogHelper.close();
20
- },
21
-
22
- open: function(extra_options) {
23
-
24
- var options = {
25
- whowishWordId: "Undefined",
26
- variables: "",
27
- attributeName: "",
28
- content: "",
29
- success: function(){
30
- throw "success() undefined for whowishWordDialog()";
31
- }
32
- }
33
-
34
- $w.extend(options, extra_options);
35
-
36
- whowishWordDialogHelper.createOverlay();
37
- whowishWordDialogHelper.createDialog();
38
-
39
-
40
- $w('#whowishWordDialog').find('.whowishWordId').html(options.whowishWordId);
41
-
42
-
43
- if (options.attributeName == "") {
44
- $w('#whowishWordDialog').find('.attributeNamePanel').hide();
45
- }
46
- else {
47
- $w('#whowishWordDialog').find('.attributeNamePanel').show();
48
- $w('#whowishWordDialog').find('.attributeName').html(options.attributeName);
49
- }
50
-
51
-
52
- if (options.variables == "") {
53
- $w('#whowishWordDialog').find('.variablesPanel').hide();
54
- }
55
- else {
56
- $w('#whowishWordDialog').find('.variablesPanel').show();
57
- $w('#whowishWordDialog').find('.variables').html(options.variables);
58
- }
59
-
60
-
61
- $w('#whowishWordDialog').find('.content').val(options.content);
62
- whowishWordDialogHelper.saveCallback = options.success;
63
-
64
- $w('#whowishWordDialog').css({
65
- left: (($w(window).width() - $w('#whowishWordDialog').width()) / 2) + 'px',
66
- top: ($w(window).scrollTop() + ($w(window).height() - $w('#whowishWordDialog').height()) / 2) + 'px'
67
- });
68
-
69
-
70
-
71
- whowishWordDialogHelper.open();
72
- }
73
-
74
- }
75
-
76
- });
77
-
78
- })(jQueryWhowishWord);
79
-
80
-
81
-
82
- var whowishWordDialogHelper = {};
83
-
84
-
85
- whowishWordDialogHelper.saveCallback = null;
86
-
87
-
88
- whowishWordDialogHelper.createOverlay = function() {
89
-
90
- if ($w('#whowishWordDialogOverlay').length > 0) return;
91
- $w('body').append('<div class="whowishWordDialogOverlay" id="whowishWordDialogOverlay"></div>');
92
-
93
- };
94
-
95
-
96
- whowishWordDialogHelper.createDialog = function() {
97
-
98
- if ($w('#whowishWordDialog').length > 0) return;
99
-
100
- $w('body').append('<div class="whowishWordDialog" id="whowishWordDialog">' +
101
- '<h1><span class="whowishWordId"></span></h1>' +
102
- '<span class="attributeNamePanel">' +
103
- '<b>Attribute\'s name:</b> <span class="attributeName"></span>' +
104
- '</span>' +
105
- '<span class="variablesPanel">' +
106
- '<b>Variables:</b> <span class="variables"></span>' +
107
- '</span>' +
108
- '<span class="contentPanel">' +
109
- '<b>Content:</b><br/>' +
110
- '<textarea id="whowishWordDialogContent" class="content"></textarea>' +
111
- '</span>' +
112
- '<span class="buttonPanel">' +
113
- '<span id="whowishWordDialogSaveButton" class="saveButton">Save</span>' +
114
- '<span id="whowishWordDialogCloseButton" class="closeButton">Close</span>' +
115
- '</span>' +
116
- '</div>');
117
-
118
- $w('#whowishWordDialog').find(".saveButton").click(function() {
119
- whowishWordDialogHelper.saveCallback($w('#whowishWordDialogContent').val());
120
- });
121
-
122
- $w('#whowishWordDialog').find(".closeButton").click(whowishWordDialogHelper.close);
123
-
124
- };
125
-
126
-
127
- whowishWordDialogHelper.open = function() {
128
- $w('#whowishWordDialogOverlay').show();
129
- $w('#whowishWordDialog').show();
130
- };
131
-
132
-
133
- whowishWordDialogHelper.close = function() {
134
- $w('#whowishWordDialogOverlay').hide();
135
- $w('#whowishWordDialog').hide();
136
- };
1
+ /**
2
+ * @author Tanin Na Nakorn
3
+ */
4
+ (function($w){
5
+
6
+ $w.extend({
7
+
8
+ whowishWordDialog: {
9
+
10
+ start_loading: function() {
11
+ $w('#whowishWordDialog').find(".saveButton").loading_button(true);
12
+ },
13
+
14
+ stop_loading: function() {
15
+ $w('#whowishWordDialog').find(".saveButton").loading_button(false);
16
+ },
17
+
18
+ close: function() {
19
+ whowishWordDialogHelper.close();
20
+ },
21
+
22
+ open: function(extra_options) {
23
+
24
+ var options = {
25
+ whowishWordId: "Undefined",
26
+ variables: "",
27
+ attributeName: "",
28
+ content: "",
29
+ success: function(){
30
+ throw "success() undefined for whowishWordDialog()";
31
+ }
32
+ }
33
+
34
+ $w.extend(options, extra_options);
35
+
36
+ whowishWordDialogHelper.createOverlay();
37
+ whowishWordDialogHelper.createDialog();
38
+
39
+
40
+ $w('#whowishWordDialog').find('.whowishWordId').html(options.whowishWordId);
41
+
42
+
43
+ if (options.attributeName == "") {
44
+ $w('#whowishWordDialog').find('.attributeNamePanel').hide();
45
+ }
46
+ else {
47
+ $w('#whowishWordDialog').find('.attributeNamePanel').show();
48
+ $w('#whowishWordDialog').find('.attributeName').html(options.attributeName);
49
+ }
50
+
51
+
52
+ if (options.variables == "") {
53
+ $w('#whowishWordDialog').find('.variablesPanel').hide();
54
+ }
55
+ else {
56
+ $w('#whowishWordDialog').find('.variablesPanel').show();
57
+ $w('#whowishWordDialog').find('.variables').html(options.variables);
58
+ }
59
+
60
+
61
+ $w('#whowishWordDialog').find('.content').val(options.content);
62
+ whowishWordDialogHelper.saveCallback = options.success;
63
+
64
+ $w('#whowishWordDialog').css({
65
+ left: (($w(window).width() - $w('#whowishWordDialog').width()) / 2) + 'px',
66
+ top: ($w(window).scrollTop() + ($w(window).height() - $w('#whowishWordDialog').height()) / 2) + 'px'
67
+ });
68
+
69
+
70
+
71
+ whowishWordDialogHelper.open();
72
+ }
73
+
74
+ }
75
+
76
+ });
77
+
78
+ })(jQueryWhowishWord);
79
+
80
+
81
+
82
+ var whowishWordDialogHelper = {};
83
+
84
+
85
+ whowishWordDialogHelper.saveCallback = null;
86
+
87
+
88
+ whowishWordDialogHelper.createOverlay = function() {
89
+
90
+ if ($w('#whowishWordDialogOverlay').length > 0) return;
91
+ $w('body').append('<div class="whowishWordDialogOverlay" id="whowishWordDialogOverlay"></div>');
92
+
93
+ };
94
+
95
+
96
+ whowishWordDialogHelper.createDialog = function() {
97
+
98
+ if ($w('#whowishWordDialog').length > 0) return;
99
+
100
+ $w('body').append('<div class="whowishWordDialog" id="whowishWordDialog">' +
101
+ '<h1><span class="whowishWordId"></span></h1>' +
102
+ '<span class="attributeNamePanel">' +
103
+ '<b>Attribute\'s name:</b> <span class="attributeName"></span>' +
104
+ '</span>' +
105
+ '<span class="variablesPanel">' +
106
+ '<b>Variables:</b> <span class="variables"></span>' +
107
+ '</span>' +
108
+ '<span class="contentPanel">' +
109
+ '<b>Content:</b><br/>' +
110
+ '<textarea id="whowishWordDialogContent" class="content"></textarea>' +
111
+ '</span>' +
112
+ '<span class="buttonPanel">' +
113
+ '<span id="whowishWordDialogSaveButton" class="saveButton">Save</span>' +
114
+ '<span id="whowishWordDialogCloseButton" class="closeButton">Close</span>' +
115
+ '</span>' +
116
+ '</div>');
117
+
118
+ $w('#whowishWordDialog').find(".saveButton").click(function() {
119
+ whowishWordDialogHelper.saveCallback($w('#whowishWordDialogContent').val());
120
+ });
121
+
122
+ $w('#whowishWordDialog').find(".closeButton").click(whowishWordDialogHelper.close);
123
+
124
+ };
125
+
126
+
127
+ whowishWordDialogHelper.open = function() {
128
+ $w('#whowishWordDialogOverlay').show();
129
+ $w('#whowishWordDialog').show();
130
+ };
131
+
132
+
133
+ whowishWordDialogHelper.close = function() {
134
+ $w('#whowishWordDialogOverlay').hide();
135
+ $w('#whowishWordDialog').hide();
136
+ };