interpret 0.2.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -4
- data/Gemfile +2 -3
- data/README.md +1 -10
- data/{public/stylesheets → app/assets/images}/folder.png +0 -0
- data/{public → app/assets}/javascripts/interpret.js +0 -0
- data/{public/stylesheets/interpret_style.css → app/assets/stylesheets/interpret_style.css.erb} +1 -1
- data/app/controllers/interpret/base_controller.rb +1 -1
- data/app/controllers/interpret/search_controller.rb +8 -2
- data/app/controllers/interpret/tools_controller.rb +5 -5
- data/app/controllers/interpret/translations_controller.rb +59 -69
- data/app/models/interpret/translation.rb +1 -0
- data/app/views/interpret/missing_translations/blank.html.erb +1 -1
- data/app/views/interpret/missing_translations/index.html.erb +1 -1
- data/app/views/interpret/missing_translations/stale.html.erb +2 -2
- data/app/views/interpret/search/_blank_search.html.erb +1 -1
- data/app/views/interpret/search/_filled_search.html.erb +1 -1
- data/app/views/interpret/tools/index.html.erb +2 -2
- data/app/views/interpret/translations/_listing.html.erb +3 -3
- data/app/views/interpret/translations/new.html.erb +2 -2
- data/app/views/layouts/interpret/interpret.html.erb +55 -0
- data/app/views/layouts/{interpret_base.html.erb → interpret/interpret_base.html.erb} +0 -0
- data/config/routes.rb +19 -21
- data/{lib/generators/interpret/templates/migration.rb → db/migrate/20111108094329_create_translations.rb} +3 -4
- data/interpret.gemspec +3 -3
- data/lib/interpret/engine.rb +6 -4
- data/lib/interpret/helpers.rb +4 -53
- data/lib/interpret/version.rb +1 -1
- data/lib/interpret.rb +0 -4
- data/script/rails +5 -0
- data/spec/integration/missing_translations_spec.rb +8 -8
- data/spec/integration/search_spec.rb +8 -8
- data/spec/integration/stale_translations_spec.rb +5 -5
- data/spec/integration/tools_spec.rb +9 -9
- data/spec/integration/translations_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -9
- data/spec/support/load_routes.rb +6 -0
- data/test_app/Gemfile +11 -6
- data/test_app/{public → app/assets}/images/a1.gif +0 -0
- data/test_app/{public → app/assets}/images/a10.jpg +0 -0
- data/test_app/{public → app/assets}/images/a16.gif +0 -0
- data/test_app/{public → app/assets}/images/a18.gif +0 -0
- data/test_app/{public → app/assets}/images/a22.gif +0 -0
- data/test_app/{public → app/assets}/images/a26.gif +0 -0
- data/test_app/{public → app/assets}/images/a33.gif +0 -0
- data/test_app/{public → app/assets}/images/a36.gif +0 -0
- data/test_app/{public → app/assets}/images/a38.gif +0 -0
- data/test_app/{public → app/assets}/images/a41.gif +0 -0
- data/test_app/{public → app/assets}/images/a47.gif +0 -0
- data/test_app/{public → app/assets}/images/a50.gif +0 -0
- data/test_app/{public → app/assets}/images/a8.gif +0 -0
- data/test_app/{public → app/assets}/images/abg.gif +0 -0
- data/test_app/{public → app/assets}/images/pic1.jpg +0 -0
- data/test_app/{public → app/assets}/images/pic2.jpg +0 -0
- data/test_app/{public → app/assets}/images/spacer.gif +0 -0
- data/test_app/{public → app/assets}/images/upbg.gif +0 -0
- data/test_app/app/assets/javascripts/application.js +4 -0
- data/test_app/{public → app/assets}/stylesheets/.gitkeep +0 -0
- data/test_app/{public/stylesheets/default.css → app/assets/stylesheets/default.css.erb} +16 -16
- data/test_app/{public → app/assets}/stylesheets/private.css +0 -0
- data/test_app/app/controllers/admin/dashboard_controller.rb +6 -0
- data/test_app/app/views/admin/dashboard/index.html.erb +1 -0
- data/test_app/app/views/layouts/application.html.erb +3 -13
- data/test_app/app/views/layouts/backoffice.html.erb +3 -4
- data/test_app/app/views/pages/index.html.erb +2 -2
- data/test_app/config/application.rb +12 -3
- data/test_app/config/environments/development.rb +0 -1
- data/test_app/config/initializers/interpret.rb +0 -1
- data/test_app/config/routes.rb +10 -1
- data/test_app/db/migrate/{20111021100344_interpret_create_translations.rb → 20111108094455_create_translations.rb} +3 -4
- data/test_app/db/schema.rb +3 -0
- metadata +60 -78
- data/app/views/interpret/translations/live_edit.html.erb +0 -11
- data/app/views/layouts/interpret.html.erb +0 -56
- data/lib/generators/interpret/migration_generator.rb +0 -25
- data/lib/generators/interpret/setup_generator.rb +0 -21
- data/lib/interpret/capistrano.rb +0 -18
- data/lib/interpret/controller_filter.rb +0 -12
- data/public/javascripts/facebox-1.3/closelabel.png +0 -0
- data/public/javascripts/facebox-1.3/facebox.css +0 -80
- data/public/javascripts/facebox-1.3/facebox.js +0 -309
- data/public/javascripts/facebox-1.3/loading.gif +0 -0
- data/public/stylesheets/interpret_live_edit_style.css +0 -38
- data/test_app/config/deploy.rb +0 -24
- data/test_app/config/initializers/rack_patch.rb +0 -13
- data/test_app/public/javascripts/application.js +0 -2
- data/test_app/public/javascripts/best_in_place.js +0 -456
- data/test_app/public/javascripts/facebox-1.3/closelabel.png +0 -0
- data/test_app/public/javascripts/facebox-1.3/facebox.css +0 -80
- data/test_app/public/javascripts/facebox-1.3/facebox.js +0 -309
- data/test_app/public/javascripts/facebox-1.3/loading.gif +0 -0
- data/test_app/public/javascripts/interpret.js +0 -4
- data/test_app/public/javascripts/rails.js +0 -134
- data/test_app/public/stylesheets/folder.png +0 -0
- data/test_app/public/stylesheets/interpret_live_edit_style.css +0 -38
- data/test_app/public/stylesheets/interpret_style.css +0 -535
@@ -1,456 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
BestInPlace (for jQuery)
|
3
|
-
version: 0.1.0 (01/01/2011)
|
4
|
-
@requires jQuery >= v1.4
|
5
|
-
@requires jQuery.purr to display pop-up windows
|
6
|
-
|
7
|
-
By Bernat Farrero based on the work of Jan Varwig.
|
8
|
-
Examples at http://bernatfarrero.com
|
9
|
-
|
10
|
-
Licensed under the MIT:
|
11
|
-
http://www.opensource.org/licenses/mit-license.php
|
12
|
-
|
13
|
-
Usage:
|
14
|
-
|
15
|
-
Attention.
|
16
|
-
The format of the JSON object given to the select inputs is the following:
|
17
|
-
[["key", "value"],["key", "value"]]
|
18
|
-
The format of the JSON object given to the checkbox inputs is the following:
|
19
|
-
["falseValue", "trueValue"]
|
20
|
-
*/
|
21
|
-
|
22
|
-
function BestInPlaceEditor(e) {
|
23
|
-
this.element = jQuery(e);
|
24
|
-
this.initOptions();
|
25
|
-
this.bindForm();
|
26
|
-
this.initNil();
|
27
|
-
$(this.activator).bind('click', {editor: this}, this.clickHandler);
|
28
|
-
}
|
29
|
-
|
30
|
-
BestInPlaceEditor.prototype = {
|
31
|
-
// Public Interface Functions //////////////////////////////////////////////
|
32
|
-
|
33
|
-
activate : function() {
|
34
|
-
var elem = this.isNil ? "" : this.element.html();
|
35
|
-
this.oldValue = elem;
|
36
|
-
$(this.activator).unbind("click", this.clickHandler);
|
37
|
-
this.activateForm();
|
38
|
-
},
|
39
|
-
|
40
|
-
abort : function() {
|
41
|
-
if (this.isNil) this.element.html(this.nil);
|
42
|
-
else this.element.html(this.oldValue);
|
43
|
-
$(this.activator).bind('click', {editor: this}, this.clickHandler);
|
44
|
-
},
|
45
|
-
|
46
|
-
update : function() {
|
47
|
-
var editor = this;
|
48
|
-
if (this.formType in {"input":1, "textarea":1} && this.getValue() == this.oldValue)
|
49
|
-
{ // Avoid request if no change is made
|
50
|
-
this.abort();
|
51
|
-
return true;
|
52
|
-
}
|
53
|
-
this.isNil = false;
|
54
|
-
editor.ajax({
|
55
|
-
"type" : "post",
|
56
|
-
"dataType" : "text",
|
57
|
-
"data" : editor.requestData(),
|
58
|
-
"success" : function(data){ editor.loadSuccessCallback(data); },
|
59
|
-
"error" : function(request, error){ editor.loadErrorCallback(request, error); }
|
60
|
-
});
|
61
|
-
if (this.formType == "select") {
|
62
|
-
var value = this.getValue();
|
63
|
-
$.each(this.values, function(i, v) {
|
64
|
-
if (value == v[0]) {
|
65
|
-
editor.element.html(v[1]);
|
66
|
-
}
|
67
|
-
}
|
68
|
-
);
|
69
|
-
} else if (this.formType == "checkbox") {
|
70
|
-
editor.element.html(this.getValue() ? this.values[1] : this.values[0]);
|
71
|
-
} else {
|
72
|
-
editor.element.html(this.getValue());
|
73
|
-
}
|
74
|
-
},
|
75
|
-
|
76
|
-
activateForm : function() {
|
77
|
-
alert("The form was not properly initialized. activateForm is unbound");
|
78
|
-
},
|
79
|
-
|
80
|
-
// Helper Functions ////////////////////////////////////////////////////////
|
81
|
-
|
82
|
-
initOptions : function() {
|
83
|
-
// Try parent supplied info
|
84
|
-
var self = this;
|
85
|
-
self.element.parents().each(function(){
|
86
|
-
self.url = self.url || jQuery(this).attr("data-url");
|
87
|
-
self.collection = self.collection || jQuery(this).attr("data-collection");
|
88
|
-
self.formType = self.formType || jQuery(this).attr("data-type");
|
89
|
-
self.objectName = self.objectName || jQuery(this).attr("data-object");
|
90
|
-
self.attributeName = self.attributeName || jQuery(this).attr("data-attribute");
|
91
|
-
self.nil = self.nil || jQuery(this).attr("data-nil");
|
92
|
-
});
|
93
|
-
|
94
|
-
// Try Rails-id based if parents did not explicitly supply something
|
95
|
-
self.element.parents().each(function(){
|
96
|
-
var res = this.id.match(/^(\w+)_(\d+)$/i);
|
97
|
-
if (res) {
|
98
|
-
self.objectName = self.objectName || res[1];
|
99
|
-
}
|
100
|
-
});
|
101
|
-
|
102
|
-
// Load own attributes (overrides all others)
|
103
|
-
self.url = self.element.attr("data-url") || self.url || document.location.pathname;
|
104
|
-
self.collection = self.element.attr("data-collection") || self.collection;
|
105
|
-
self.formType = self.element.attr("data-type") || self.formtype || "input";
|
106
|
-
self.objectName = self.element.attr("data-object") || self.objectName;
|
107
|
-
self.attributeName = self.element.attr("data-attribute") || self.attributeName;
|
108
|
-
self.activator = self.element.attr("data-activator") || self.element;
|
109
|
-
self.nil = self.element.attr("data-nil") || self.nil || "-";
|
110
|
-
|
111
|
-
if (!self.element.attr("data-sanitize")) {
|
112
|
-
self.sanitize = true;
|
113
|
-
}
|
114
|
-
else {
|
115
|
-
self.sanitize = (self.element.attr("data-sanitize") == "true");
|
116
|
-
}
|
117
|
-
|
118
|
-
if ((self.formType == "select" || self.formType == "checkbox") && self.collection !== null)
|
119
|
-
{
|
120
|
-
self.values = jQuery.parseJSON(self.collection);
|
121
|
-
}
|
122
|
-
},
|
123
|
-
|
124
|
-
bindForm : function() {
|
125
|
-
this.activateForm = BestInPlaceEditor.forms[this.formType].activateForm;
|
126
|
-
this.getValue = BestInPlaceEditor.forms[this.formType].getValue;
|
127
|
-
},
|
128
|
-
|
129
|
-
initNil: function() {
|
130
|
-
if (this.element.html() == "")
|
131
|
-
{
|
132
|
-
this.isNil = true
|
133
|
-
this.element.html(this.nil)
|
134
|
-
}
|
135
|
-
},
|
136
|
-
|
137
|
-
getValue : function() {
|
138
|
-
alert("The form was not properly initialized. getValue is unbound");
|
139
|
-
},
|
140
|
-
|
141
|
-
// Trim and Strips HTML from text
|
142
|
-
sanitizeValue : function(s) {
|
143
|
-
if (this.sanitize)
|
144
|
-
{
|
145
|
-
var tmp = document.createElement("DIV");
|
146
|
-
tmp.innerHTML = s;
|
147
|
-
s = tmp.textContent || tmp.innerText;
|
148
|
-
}
|
149
|
-
return jQuery.trim(s);
|
150
|
-
},
|
151
|
-
|
152
|
-
/* Generate the data sent in the POST request */
|
153
|
-
requestData : function() {
|
154
|
-
// To prevent xss attacks, a csrf token must be defined as a meta attribute
|
155
|
-
csrf_token = $('meta[name=csrf-token]').attr('content');
|
156
|
-
csrf_param = $('meta[name=csrf-param]').attr('content');
|
157
|
-
|
158
|
-
var data = "_method=put";
|
159
|
-
data += "&" + this.objectName + '[' + this.attributeName + ']=' + encodeURIComponent(this.getValue());
|
160
|
-
|
161
|
-
if (csrf_param !== undefined && csrf_token !== undefined) {
|
162
|
-
data += "&" + csrf_param + "=" + encodeURIComponent(csrf_token);
|
163
|
-
}
|
164
|
-
return data;
|
165
|
-
},
|
166
|
-
|
167
|
-
ajax : function(options) {
|
168
|
-
options.url = this.url;
|
169
|
-
options.beforeSend = function(xhr){ xhr.setRequestHeader("Accept", "application/json"); };
|
170
|
-
return jQuery.ajax(options);
|
171
|
-
},
|
172
|
-
|
173
|
-
// Handlers ////////////////////////////////////////////////////////////////
|
174
|
-
|
175
|
-
loadSuccessCallback : function(data) {
|
176
|
-
this.element.html(data[this.objectName]);
|
177
|
-
// Binding back after being clicked
|
178
|
-
$(this.activator).bind('click', {editor: this}, this.clickHandler);
|
179
|
-
},
|
180
|
-
|
181
|
-
loadErrorCallback : function(request, error) {
|
182
|
-
this.element.html(this.oldValue);
|
183
|
-
|
184
|
-
// Display all error messages from server side validation
|
185
|
-
$.each(jQuery.parseJSON(request.responseText), function(index, value) {
|
186
|
-
var container = $("<span class='flash-error'></span>").html(value);
|
187
|
-
container.purr();
|
188
|
-
});
|
189
|
-
|
190
|
-
// Binding back after being clicked
|
191
|
-
$(this.activator).bind('click', {editor: this}, this.clickHandler);
|
192
|
-
},
|
193
|
-
|
194
|
-
clickHandler : function(event) {
|
195
|
-
event.data.editor.activate();
|
196
|
-
}
|
197
|
-
};
|
198
|
-
|
199
|
-
|
200
|
-
BestInPlaceEditor.forms = {
|
201
|
-
"input" : {
|
202
|
-
activateForm : function() {
|
203
|
-
var output = '<form class="form_in_place" action="javascript:void(0)" style="display:inline;">';
|
204
|
-
output += '<input type="text" value="' + this.sanitizeValue(this.oldValue) + '"></form>';
|
205
|
-
this.element.html(output);
|
206
|
-
this.element.find('input')[0].select();
|
207
|
-
this.element.find("form").bind('submit', {editor: this}, BestInPlaceEditor.forms.input.submitHandler);
|
208
|
-
this.element.find("input").bind('blur', {editor: this}, BestInPlaceEditor.forms.input.inputBlurHandler);
|
209
|
-
this.element.find("input").bind('keyup', {editor: this}, BestInPlaceEditor.forms.input.keyupHandler);
|
210
|
-
},
|
211
|
-
|
212
|
-
getValue : function() {
|
213
|
-
return this.sanitizeValue(this.element.find("input").val());
|
214
|
-
},
|
215
|
-
|
216
|
-
inputBlurHandler : function(event) {
|
217
|
-
event.data.editor.update();
|
218
|
-
},
|
219
|
-
|
220
|
-
submitHandler : function(event) {
|
221
|
-
event.data.editor.update();
|
222
|
-
},
|
223
|
-
|
224
|
-
keyupHandler : function(event) {
|
225
|
-
if (event.keyCode == 27) {
|
226
|
-
event.data.editor.abort();
|
227
|
-
}
|
228
|
-
}
|
229
|
-
},
|
230
|
-
|
231
|
-
"select" : {
|
232
|
-
activateForm : function() {
|
233
|
-
var output = "<form action='javascript:void(0)' style='display:inline;'><select>";
|
234
|
-
var selected = "";
|
235
|
-
var oldValue = this.oldValue;
|
236
|
-
$.each(this.values, function(index, value) {
|
237
|
-
selected = (value[1] == oldValue ? "selected='selected'" : "");
|
238
|
-
output += "<option value='" + value[0] + "' " + selected + ">" + value[1] + "</option>";
|
239
|
-
});
|
240
|
-
output += "</select></form>";
|
241
|
-
this.element.html(output);
|
242
|
-
this.element.find("select").bind('change', {editor: this}, BestInPlaceEditor.forms.select.blurHandler);
|
243
|
-
this.element.find("select").bind('blur', {editor: this}, BestInPlaceEditor.forms.select.blurHandler);
|
244
|
-
this.element.find("select").bind('keyup', {editor: this}, BestInPlaceEditor.forms.select.keyupHandler);
|
245
|
-
this.element.find("select")[0].focus();
|
246
|
-
},
|
247
|
-
|
248
|
-
getValue : function() {
|
249
|
-
return this.sanitizeValue(this.element.find("select").val());
|
250
|
-
},
|
251
|
-
|
252
|
-
blurHandler : function(event) {
|
253
|
-
event.data.editor.update();
|
254
|
-
},
|
255
|
-
|
256
|
-
keyupHandler : function(event) {
|
257
|
-
if (event.keyCode == 27) event.data.editor.abort();
|
258
|
-
}
|
259
|
-
},
|
260
|
-
|
261
|
-
"checkbox" : {
|
262
|
-
activateForm : function() {
|
263
|
-
var newValue = Boolean(this.oldValue != this.values[1]);
|
264
|
-
var output = newValue ? this.values[1] : this.values[0];
|
265
|
-
this.element.html(output);
|
266
|
-
this.update();
|
267
|
-
},
|
268
|
-
|
269
|
-
getValue : function() {
|
270
|
-
return Boolean(this.element.html() == this.values[1]);
|
271
|
-
}
|
272
|
-
},
|
273
|
-
|
274
|
-
"textarea" : {
|
275
|
-
activateForm : function() {
|
276
|
-
// grab width and height of text
|
277
|
-
width = this.element.css('width');
|
278
|
-
height = this.element.css('height');
|
279
|
-
|
280
|
-
// construct the form
|
281
|
-
var output = '<form action="javascript:void(0)" style="display:inline;"><textarea>';
|
282
|
-
output += this.sanitizeValue(this.oldValue);
|
283
|
-
output += '</textarea></form>';
|
284
|
-
this.element.html(output);
|
285
|
-
|
286
|
-
// set width and height of textarea
|
287
|
-
jQuery(this.element.find("textarea")[0]).css({ 'min-width': width, 'min-height': height });
|
288
|
-
jQuery(this.element.find("textarea")[0]).elastic();
|
289
|
-
|
290
|
-
this.element.find("textarea")[0].focus();
|
291
|
-
this.element.find("textarea").bind('blur', {editor: this}, BestInPlaceEditor.forms.textarea.blurHandler);
|
292
|
-
this.element.find("textarea").bind('keyup', {editor: this}, BestInPlaceEditor.forms.textarea.keyupHandler);
|
293
|
-
},
|
294
|
-
|
295
|
-
getValue : function() {
|
296
|
-
return this.sanitizeValue(this.element.find("textarea").val());
|
297
|
-
},
|
298
|
-
|
299
|
-
blurHandler : function(event) {
|
300
|
-
event.data.editor.update();
|
301
|
-
},
|
302
|
-
|
303
|
-
keyupHandler : function(event) {
|
304
|
-
if (event.keyCode == 27) {
|
305
|
-
BestInPlaceEditor.forms.textarea.abort(event.data.editor);
|
306
|
-
}
|
307
|
-
},
|
308
|
-
|
309
|
-
abort : function(editor) {
|
310
|
-
if (confirm("Are you sure you want to discard your changes?")) {
|
311
|
-
editor.abort();
|
312
|
-
}
|
313
|
-
}
|
314
|
-
}
|
315
|
-
};
|
316
|
-
|
317
|
-
jQuery.fn.best_in_place = function() {
|
318
|
-
this.each(function(){
|
319
|
-
jQuery(this).data('bestInPlaceEditor', new BestInPlaceEditor(this));
|
320
|
-
});
|
321
|
-
return this;
|
322
|
-
};
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
/**
|
327
|
-
* @name Elastic
|
328
|
-
* @descripton Elastic is Jquery plugin that grow and shrink your textareas automaticliy
|
329
|
-
* @version 1.6.5
|
330
|
-
* @requires Jquery 1.2.6+
|
331
|
-
*
|
332
|
-
* @author Jan Jarfalk
|
333
|
-
* @author-email jan.jarfalk@unwrongest.com
|
334
|
-
* @author-website http://www.unwrongest.com
|
335
|
-
*
|
336
|
-
* @licens MIT License - http://www.opensource.org/licenses/mit-license.php
|
337
|
-
*/
|
338
|
-
|
339
|
-
(function(jQuery){
|
340
|
-
jQuery.fn.extend({
|
341
|
-
elastic: function() {
|
342
|
-
// We will create a div clone of the textarea
|
343
|
-
// by copying these attributes from the textarea to the div.
|
344
|
-
var mimics = [
|
345
|
-
'paddingTop',
|
346
|
-
'paddingRight',
|
347
|
-
'paddingBottom',
|
348
|
-
'paddingLeft',
|
349
|
-
'fontSize',
|
350
|
-
'lineHeight',
|
351
|
-
'fontFamily',
|
352
|
-
'width',
|
353
|
-
'fontWeight'];
|
354
|
-
|
355
|
-
return this.each( function() {
|
356
|
-
|
357
|
-
// Elastic only works on textareas
|
358
|
-
if ( this.type != 'textarea' ) {
|
359
|
-
return false;
|
360
|
-
}
|
361
|
-
|
362
|
-
var $textarea = jQuery(this),
|
363
|
-
$twin = jQuery('<div />').css({'position': 'absolute','display':'none','word-wrap':'break-word'}),
|
364
|
-
lineHeight = parseInt($textarea.css('line-height'),10) || parseInt($textarea.css('font-size'),'10'),
|
365
|
-
minheight = parseInt($textarea.css('height'),10) || lineHeight*3,
|
366
|
-
maxheight = parseInt($textarea.css('max-height'),10) || Number.MAX_VALUE,
|
367
|
-
goalheight = 0,
|
368
|
-
i = 0;
|
369
|
-
|
370
|
-
// Opera returns max-height of -1 if not set
|
371
|
-
if (maxheight < 0) { maxheight = Number.MAX_VALUE; }
|
372
|
-
|
373
|
-
// Append the twin to the DOM
|
374
|
-
// We are going to meassure the height of this, not the textarea.
|
375
|
-
$twin.appendTo($textarea.parent());
|
376
|
-
|
377
|
-
// Copy the essential styles (mimics) from the textarea to the twin
|
378
|
-
var i = mimics.length;
|
379
|
-
while(i--){
|
380
|
-
$twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()));
|
381
|
-
}
|
382
|
-
|
383
|
-
|
384
|
-
// Sets a given height and overflow state on the textarea
|
385
|
-
function setHeightAndOverflow(height, overflow){
|
386
|
-
curratedHeight = Math.floor(parseInt(height,10));
|
387
|
-
if($textarea.height() != curratedHeight){
|
388
|
-
$textarea.css({'height': curratedHeight + 'px','overflow':overflow});
|
389
|
-
|
390
|
-
}
|
391
|
-
}
|
392
|
-
|
393
|
-
|
394
|
-
// This function will update the height of the textarea if necessary
|
395
|
-
function update() {
|
396
|
-
|
397
|
-
// Get curated content from the textarea.
|
398
|
-
var textareaContent = $textarea.val().replace(/&/g,'&').replace(/ /g, ' ').replace(/<|>/g, '>').replace(/\n/g, '<br />');
|
399
|
-
|
400
|
-
// Compare curated content with curated twin.
|
401
|
-
var twinContent = $twin.html().replace(/<br>/ig,'<br />');
|
402
|
-
|
403
|
-
if(textareaContent+' ' != twinContent){
|
404
|
-
|
405
|
-
// Add an extra white space so new rows are added when you are at the end of a row.
|
406
|
-
$twin.html(textareaContent+' ');
|
407
|
-
|
408
|
-
// Change textarea height if twin plus the height of one line differs more than 3 pixel from textarea height
|
409
|
-
if(Math.abs($twin.height() + lineHeight - $textarea.height()) > 3){
|
410
|
-
|
411
|
-
var goalheight = $twin.height()+lineHeight;
|
412
|
-
if(goalheight >= maxheight) {
|
413
|
-
setHeightAndOverflow(maxheight,'auto');
|
414
|
-
} else if(goalheight <= minheight) {
|
415
|
-
setHeightAndOverflow(minheight,'hidden');
|
416
|
-
} else {
|
417
|
-
setHeightAndOverflow(goalheight,'hidden');
|
418
|
-
}
|
419
|
-
|
420
|
-
}
|
421
|
-
|
422
|
-
}
|
423
|
-
|
424
|
-
}
|
425
|
-
|
426
|
-
// Hide scrollbars
|
427
|
-
$textarea.css({'overflow':'hidden'});
|
428
|
-
|
429
|
-
// Update textarea size on keyup, change, cut and paste
|
430
|
-
$textarea.bind('keyup change cut paste', function(){
|
431
|
-
update();
|
432
|
-
});
|
433
|
-
|
434
|
-
// Compact textarea on blur
|
435
|
-
// Lets animate this....
|
436
|
-
$textarea.bind('blur',function(){
|
437
|
-
if($twin.height() < maxheight){
|
438
|
-
if($twin.height() > minheight) {
|
439
|
-
$textarea.height($twin.height());
|
440
|
-
} else {
|
441
|
-
$textarea.height(minheight);
|
442
|
-
}
|
443
|
-
}
|
444
|
-
});
|
445
|
-
|
446
|
-
// And this line is to catch the browser paste event
|
447
|
-
$textarea.live('input paste',function(e){ setTimeout( update, 250); });
|
448
|
-
|
449
|
-
// Run update once when elastic is initialized
|
450
|
-
update();
|
451
|
-
|
452
|
-
});
|
453
|
-
|
454
|
-
}
|
455
|
-
});
|
456
|
-
})(jQuery);
|
Binary file
|
@@ -1,80 +0,0 @@
|
|
1
|
-
#facebox {
|
2
|
-
position: absolute;
|
3
|
-
top: 0;
|
4
|
-
left: 0;
|
5
|
-
z-index: 100;
|
6
|
-
text-align: left;
|
7
|
-
}
|
8
|
-
|
9
|
-
|
10
|
-
#facebox .popup{
|
11
|
-
position:relative;
|
12
|
-
border:3px solid rgba(0,0,0,0);
|
13
|
-
-webkit-border-radius:5px;
|
14
|
-
-moz-border-radius:5px;
|
15
|
-
border-radius:5px;
|
16
|
-
-webkit-box-shadow:0 0 18px rgba(0,0,0,0.4);
|
17
|
-
-moz-box-shadow:0 0 18px rgba(0,0,0,0.4);
|
18
|
-
box-shadow:0 0 18px rgba(0,0,0,0.4);
|
19
|
-
}
|
20
|
-
|
21
|
-
#facebox .content {
|
22
|
-
display:table;
|
23
|
-
width: 370px;
|
24
|
-
padding: 10px;
|
25
|
-
background: #fff;
|
26
|
-
-webkit-border-radius:4px;
|
27
|
-
-moz-border-radius:4px;
|
28
|
-
border-radius:4px;
|
29
|
-
}
|
30
|
-
|
31
|
-
#facebox .content > p:first-child{
|
32
|
-
margin-top:0;
|
33
|
-
}
|
34
|
-
#facebox .content > p:last-child{
|
35
|
-
margin-bottom:0;
|
36
|
-
}
|
37
|
-
|
38
|
-
#facebox .close{
|
39
|
-
position:absolute;
|
40
|
-
top:5px;
|
41
|
-
right:5px;
|
42
|
-
padding:2px;
|
43
|
-
background:#fff;
|
44
|
-
}
|
45
|
-
#facebox .close img{
|
46
|
-
opacity:0.3;
|
47
|
-
}
|
48
|
-
#facebox .close:hover img{
|
49
|
-
opacity:1.0;
|
50
|
-
}
|
51
|
-
|
52
|
-
#facebox .loading {
|
53
|
-
text-align: center;
|
54
|
-
}
|
55
|
-
|
56
|
-
#facebox .image {
|
57
|
-
text-align: center;
|
58
|
-
}
|
59
|
-
|
60
|
-
#facebox img {
|
61
|
-
border: 0;
|
62
|
-
margin: 0;
|
63
|
-
}
|
64
|
-
|
65
|
-
#facebox_overlay {
|
66
|
-
position: fixed;
|
67
|
-
top: 0px;
|
68
|
-
left: 0px;
|
69
|
-
height:100%;
|
70
|
-
width:100%;
|
71
|
-
}
|
72
|
-
|
73
|
-
.facebox_hide {
|
74
|
-
z-index:-100;
|
75
|
-
}
|
76
|
-
|
77
|
-
.facebox_overlayBG {
|
78
|
-
background-color: #000;
|
79
|
-
z-index: 99;
|
80
|
-
}
|