whowish_word 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -1
- data/lib/whowish_word/rails/public/javascripts/0_class.js +64 -64
- data/lib/whowish_word/rails/public/javascripts/1_jquery.escape.js +23 -23
- data/lib/whowish_word/rails/public/javascripts/1_jquery.sizes.min.js +7 -7
- data/lib/whowish_word/rails/public/javascripts/2_whowish_word_variables.js +71 -64
- data/lib/whowish_word/rails/public/javascripts/3_whowish_word_dialog.js +136 -136
- data/lib/whowish_word/rails/public/javascripts/3_whowish_word_helper.js +95 -92
- data/lib/whowish_word/rails/public/javascripts/4_whowish_word.js +43 -43
- data/lib/whowish_word/rails/public/javascripts/4_whowish_word_content_handler.js +15 -15
- data/lib/whowish_word/rails/public/javascripts/5_whowish_word_common_creator.js +48 -48
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_element_creator.js +81 -81
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_html_creator.js +18 -18
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_select_creator.js +10 -10
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_text_creator.js +19 -19
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_value_creator.js +19 -19
- data/lib/whowish_word/rails/public/javascripts/7_whowish_word_attribute_handler.js +24 -24
- data/lib/whowish_word/rails/public/javascripts/7_whowish_word_html_handler.js +14 -14
- data/lib/whowish_word/rails/public/javascripts/7_whowish_word_text_handler.js +14 -14
- data/lib/whowish_word/rails/public/javascripts/7_whowish_word_value_handler.js +18 -18
- data/lib/whowish_word/rails/public/stylesheets/whowish_word.css +197 -197
- data/rails/Gemfile.lock +130 -130
- data/rails/Rakefile +7 -7
- data/rails/app/assets/javascripts/integration.js +2 -2
- data/rails/app/assets/javascripts/test_javascript.js +2 -2
- data/rails/app/assets/javascripts/test_word_for.js +2 -2
- data/rails/app/assets/stylesheets/integration.css +4 -4
- data/rails/app/assets/stylesheets/test_javascript.css +4 -4
- data/rails/app/assets/stylesheets/test_word_for.css +4 -4
- data/rails/app/controllers/integration_controller.rb +5 -5
- data/rails/app/controllers/test_javascript_controller.rb +11 -11
- data/rails/app/controllers/test_word_for_controller.rb +5 -5
- data/rails/app/helpers/integration_helper.rb +2 -2
- data/rails/app/helpers/test_javascript_helper.rb +2 -2
- data/rails/app/helpers/test_word_for_helper.rb +2 -2
- data/rails/public/jasmine/MIT.LICENSE +20 -20
- data/rails/public/jasmine/jasmine-html.js +190 -190
- data/rails/public/jasmine/jasmine.css +166 -166
- data/rails/public/jasmine/jasmine.js +2476 -2476
- data/rails/public/javascripts/jquery-1.6.4.js +9046 -9046
- data/rails/public/sinonjs/sinonjs.js +2821 -2821
- data/rails/public/stylesheets/main.css +21 -21
- data/whowish_word.gemspec +21 -21
- metadata +3 -4
- data/config.ru +0 -4
data/README.md
CHANGED
@@ -26,7 +26,8 @@ Prerequisite
|
|
26
26
|
|
27
27
|
Rails 3.1.*
|
28
28
|
|
29
|
-
|
29
|
+
It does not work with Rails 3.0.*, yet. Please send me an issue and I will fix it. (I'm just lazy)
|
30
|
+
|
30
31
|
|
31
32
|
|
32
33
|
How to use it
|
@@ -55,6 +56,15 @@ WhowishWord.password = "pass"
|
|
55
56
|
|
56
57
|
You can use either use :active_record or :mongoid
|
57
58
|
|
59
|
+
And, in your layout, please drop this line inside the tag header:
|
60
|
+
|
61
|
+
```erb
|
62
|
+
<%= whowish_word_javascript_and_css%>
|
63
|
+
```
|
64
|
+
|
65
|
+
It is to include the required Javascript and css files, when the edit mode is activated.
|
66
|
+
|
67
|
+
|
58
68
|
Performance
|
59
69
|
-------------------
|
60
70
|
|
@@ -73,4 +83,5 @@ Authors
|
|
73
83
|
-------------------
|
74
84
|
|
75
85
|
Tanin Na Nakorn
|
86
|
+
|
76
87
|
Tanun Niyomjit (The design of a dialog box)
|
@@ -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);
|
@@ -1,64 +1,71 @@
|
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
+
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
|
+
},
|
37
|
+
createWhowishWord: function(element) { new WhowishWordElementCreator(element); }
|
38
|
+
},
|
39
|
+
{
|
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
|
+
},
|
49
|
+
createWhowishWord: function(element) { new WhowishWordHtmlCreator(element); }
|
50
|
+
},
|
51
|
+
{
|
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
|
+
},
|
59
|
+
createWhowishWord: function(element) { new WhowishWordValueCreator(element); }
|
60
|
+
},
|
61
|
+
{
|
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
|
+
},
|
69
|
+
createWhowishWord: function(element) { new WhowishWordTextCreator(element); }
|
70
|
+
}
|
71
|
+
];
|
@@ -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).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).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
|
+
};
|