whowish_word 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.loadpath +5 -0
- data/.project +17 -0
- data/Gemfile +3 -0
- data/HOW_TO_BUILD_WHOWISH_HOOK.md +10 -0
- data/ISSUE.md +93 -0
- data/README.md +72 -0
- data/config.ru +4 -0
- data/lib/legacy/whowish_word/config.rb +1 -0
- data/lib/legacy/whowish_word/init.rb +4 -0
- data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_controller.rb +115 -0
- data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb +66 -0
- data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_facebook_controller.rb +62 -0
- data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word.rb +12 -0
- data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word_email.rb +10 -0
- data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word_facebook.rb +28 -0
- data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word.rb +5 -0
- data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word_email.rb +5 -0
- data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word_facebook.rb +18 -0
- data/lib/legacy/whowish_word/lib/app/views/layouts/whowish_word_blank.html.erb +94 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb +82 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/_row.html.erb +50 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/index.html.erb +219 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/login.html.erb +5 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_email/_row.html.erb +42 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_email/index.html.erb +99 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_facebook/_row.html.erb +48 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_facebook/index.html.erb +100 -0
- data/lib/legacy/whowish_word/lib/db_migration.rb +2 -0
- data/lib/legacy/whowish_word/lib/db_migration/mongodb.rb +0 -0
- data/lib/legacy/whowish_word/lib/db_migration/mysql.rb +60 -0
- data/lib/legacy/whowish_word/lib/hook.rb +186 -0
- data/lib/whowish_word.rb +1 -0
- data/lib/whowish_word/action_controller/base.rb +35 -0
- data/lib/whowish_word/action_mailer/base.rb +12 -0
- data/lib/whowish_word/action_view/base.rb +65 -0
- data/lib/whowish_word/action_view/template.rb +22 -0
- data/lib/whowish_word/authentication.rb +14 -0
- data/lib/whowish_word/constant.rb +9 -0
- data/lib/whowish_word/db_migration/active_record/whowish_word_html.rb +15 -0
- data/lib/whowish_word/initializer.rb +55 -0
- data/lib/whowish_word/rails/app/controllers/whowish_word_controller.rb +71 -0
- data/lib/whowish_word/rails/app/models/active_record/whowish_word_html.rb +4 -0
- data/lib/whowish_word/rails/app/models/mongoid/whowish_word_html.rb +10 -0
- data/lib/whowish_word/rails/public/javascripts/0_class.js +64 -0
- data/lib/whowish_word/rails/public/javascripts/0_jquery-1.6.4-whowish_word.js +9046 -0
- data/lib/whowish_word/rails/public/javascripts/1_csrf_and_authenticity_token_hook.js +9 -0
- data/lib/whowish_word/rails/public/javascripts/1_jquery.escape.js +23 -0
- data/lib/whowish_word/rails/public/javascripts/1_jquery.loading_button.js +66 -0
- data/lib/whowish_word/rails/public/javascripts/1_jquery.sizes.min.js +8 -0
- data/lib/whowish_word/rails/public/javascripts/2_whowish_word_variables.js +64 -0
- data/lib/whowish_word/rails/public/javascripts/3_whowish_word_dialog.js +136 -0
- data/lib/whowish_word/rails/public/javascripts/3_whowish_word_helper.js +94 -0
- data/lib/whowish_word/rails/public/javascripts/4_whowish_word.js +43 -0
- data/lib/whowish_word/rails/public/javascripts/4_whowish_word_content_handler.js +15 -0
- data/lib/whowish_word/rails/public/javascripts/4_whowish_word_creator.js +62 -0
- data/lib/whowish_word/rails/public/javascripts/5_whowish_word_common_creator.js +49 -0
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_element_creator.js +72 -0
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_html_creator.js +19 -0
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_select_creator.js +11 -0
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_text_creator.js +20 -0
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_value_creator.js +20 -0
- data/lib/whowish_word/rails/public/javascripts/7_whowish_word_attribute_handler.js +17 -0
- data/lib/whowish_word/rails/public/javascripts/7_whowish_word_html_handler.js +15 -0
- data/lib/whowish_word/rails/public/javascripts/7_whowish_word_text_handler.js +15 -0
- data/lib/whowish_word/rails/public/javascripts/7_whowish_word_value_handler.js +19 -0
- data/lib/whowish_word/rails/public/stylesheets/whowish_word.css +197 -0
- data/lib/whowish_word/whowish_word.rb +39 -0
- data/lib/whowish_word/word_for.rb +97 -0
- data/rails/Gemfile +18 -0
- data/rails/Gemfile.lock +130 -0
- data/rails/Rakefile +7 -0
- data/rails/app/assets/javascripts/integration.js +2 -0
- data/rails/app/assets/javascripts/test_javascript.js +2 -0
- data/rails/app/assets/javascripts/test_word_for.js +2 -0
- data/rails/app/assets/stylesheets/integration.css +4 -0
- data/rails/app/assets/stylesheets/test_javascript.css +4 -0
- data/rails/app/assets/stylesheets/test_word_for.css +4 -0
- data/rails/app/controllers/application_controller.rb +14 -0
- data/rails/app/controllers/home_controller.rb +9 -0
- data/rails/app/controllers/integration_controller.rb +5 -0
- data/rails/app/controllers/test_javascript_controller.rb +11 -0
- data/rails/app/controllers/test_word_for_controller.rb +5 -0
- data/rails/app/helpers/integration_helper.rb +2 -0
- data/rails/app/helpers/test_javascript_helper.rb +2 -0
- data/rails/app/helpers/test_word_for_helper.rb +2 -0
- data/rails/app/views/home/index.html.erb +95 -0
- data/rails/app/views/home/static_edit.html.erb +50 -0
- data/rails/app/views/home/static_edit_select.html.erb +9 -0
- data/rails/app/views/integration/attr.html.erb +1 -0
- data/rails/app/views/integration/index.html.erb +1 -0
- data/rails/app/views/integration/select.html.erb +3 -0
- data/rails/app/views/integration/value.html.erb +1 -0
- data/rails/app/views/layouts/integration.html.erb +14 -0
- data/rails/app/views/layouts/main.html.erb +14 -0
- data/rails/app/views/layouts/nested_test_word_for.html.erb +14 -0
- data/rails/app/views/layouts/test_javascript.html.erb +13 -0
- data/rails/app/views/layouts/test_word_for.html.erb +22 -0
- data/rails/app/views/test_javascript/change_value.html.erb +32 -0
- data/rails/app/views/test_javascript/index.html.erb +78 -0
- data/rails/app/views/test_word_for/_partial.html.erb +5 -0
- data/rails/app/views/test_word_for/index.html.erb +7 -0
- data/rails/config.ru +4 -0
- data/rails/config/application.rb +30 -0
- data/rails/config/boot.rb +9 -0
- data/rails/config/database.yml +25 -0
- data/rails/config/environment.rb +16 -0
- data/rails/config/initializers/whowish_word.rb +5 -0
- data/rails/config/mongoid.rb +6 -0
- data/rails/config/mongoid.yml +14 -0
- data/rails/config/routes.rb +7 -0
- data/rails/log/.gitignore +2 -0
- data/rails/mongo.bat +5 -0
- data/rails/public/jasmine/MIT.LICENSE +20 -0
- data/rails/public/jasmine/jasmine-html.js +190 -0
- data/rails/public/jasmine/jasmine.css +166 -0
- data/rails/public/jasmine/jasmine.js +2476 -0
- data/rails/public/jasmine/jasmine_favicon.png +0 -0
- data/rails/public/javascripts/jquery-1.6.4.js +9046 -0
- data/rails/public/sinonjs/sinonjs.js +2821 -0
- data/rails/public/stylesheets/main.css +22 -0
- data/rails/public/test/jquery_version.html +26 -0
- data/rails/script/rails +6 -0
- data/rails/spec/controllers/whowish_word_controller_spec.rb +56 -0
- data/rails/spec/integration/whowish_word_generator_spec.rb +116 -0
- data/rails/spec/integration/whowish_word_spec.rb +110 -0
- data/rails/spec/spec_helper.rb +44 -0
- data/rails/spec/support/browser.rb +194 -0
- data/rails/spec/support/json_rspec_helper.rb +9 -0
- data/rails/spec/support/mongoid_helper.rb +10 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/unit/word_for_attr_in_edit_mode_spec.rb +44 -0
- data/spec/unit/word_for_attr_spec.rb +44 -0
- data/spec/unit/word_for_in_edit_mode_spec.rb +44 -0
- data/spec/unit/word_for_spec.rb +44 -0
- data/whowish_word.gemspec +21 -0
- metadata +181 -0
@@ -0,0 +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
|
+
|
@@ -0,0 +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
|
+
|
@@ -0,0 +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
|
+
*/
|
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);
|
@@ -0,0 +1,64 @@
|
|
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) {
|
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
|
+
if (element.attributes[i].value.match(whowishWordVariables.attributeValuePattern) != null) {
|
26
|
+
|
27
|
+
return true;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
return false;
|
32
|
+
},
|
33
|
+
createWhowishWord: function(element) { new WhowishWordElementCreator(element); }
|
34
|
+
},
|
35
|
+
{
|
36
|
+
match: function(element) {
|
37
|
+
|
38
|
+
return (element.tagName.toLowerCase() == "dfn"
|
39
|
+
|| element.tagName.toLowerCase() == "button"
|
40
|
+
|| element.tagName.toLowerCase() == "label")
|
41
|
+
&& $w(element).html().match(whowishWordVariables.attributeValuePattern) != null;
|
42
|
+
|
43
|
+
},
|
44
|
+
createWhowishWord: function(element) { new WhowishWordHtmlCreator(element); }
|
45
|
+
},
|
46
|
+
{
|
47
|
+
match: function(element) {
|
48
|
+
|
49
|
+
return element.tagName.toLowerCase() != "select"
|
50
|
+
&& $w(element).val().match(whowishWordVariables.attributeValuePattern) != null;
|
51
|
+
|
52
|
+
},
|
53
|
+
createWhowishWord: function(element) { new WhowishWordValueCreator(element); }
|
54
|
+
},
|
55
|
+
{
|
56
|
+
match: function(element) {
|
57
|
+
|
58
|
+
return element.tagName.toLowerCase() == "option" &&
|
59
|
+
$w(element).text().match(whowishWordVariables.attributeValuePattern) != null;
|
60
|
+
|
61
|
+
},
|
62
|
+
createWhowishWord: function(element) { new WhowishWordTextCreator(element); }
|
63
|
+
}
|
64
|
+
];
|
@@ -0,0 +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).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
|
+
};
|
@@ -0,0 +1,94 @@
|
|
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
|
+
console.log(self.whowishWord.id);
|
49
|
+
|
50
|
+
$w.whowishWordDialog.start_loading();
|
51
|
+
|
52
|
+
$w.ajax({
|
53
|
+
type: "POST",
|
54
|
+
url: '/whowish_word/change_word',
|
55
|
+
cache: false,
|
56
|
+
headers: {
|
57
|
+
"Connection": "close"
|
58
|
+
},
|
59
|
+
data: {
|
60
|
+
"word_id": self.whowishWord.id,
|
61
|
+
"content": html
|
62
|
+
},
|
63
|
+
success: function(data) {
|
64
|
+
self.whowishWord.contentHandler.setContent(html);
|
65
|
+
$w.whowishWordDialog.close();
|
66
|
+
$w.whowishWordDialog.stop_loading();
|
67
|
+
},
|
68
|
+
error: function(req, status, e){
|
69
|
+
alert('WhowishWord cannot save the data. The Ajax resquest is not sent. Please try again later.');
|
70
|
+
$w.whowishWordDialog.stop_loading();
|
71
|
+
}
|
72
|
+
});
|
73
|
+
|
74
|
+
}
|
75
|
+
});
|
76
|
+
|
77
|
+
};
|
78
|
+
|
79
|
+
|
80
|
+
whowishWordHelper.extractWhowishWordIdFromText = function(text) {
|
81
|
+
var result = text.match(whowishWordVariables.attributeValuePattern);
|
82
|
+
return result[1];
|
83
|
+
|
84
|
+
};
|
85
|
+
|
86
|
+
|
87
|
+
whowishWordHelper.parseWhowishWordIdPackage = function(whowishWordIdPackage){
|
88
|
+
var result = whowishWordIdPackage.match(whowishWordVariables.whowishWordIdPattern);
|
89
|
+
|
90
|
+
return {
|
91
|
+
id: result[1],
|
92
|
+
variables: result[3]
|
93
|
+
};
|
94
|
+
};
|
@@ -0,0 +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
|
+
|