social_stream-base 0.17.1 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,5 @@
1
1
  //= require hoverIntent
2
2
  //= require superfish
3
- //= require jquery.watermarkinput
4
3
  //
5
4
  $(function() {
6
5
  jQuery('ul.sf-menu').superfish({
@@ -1,3 +1,5 @@
1
+ //= require jquery.watermark
2
+ //
1
3
  //= require social_stream.timeline
2
4
  //= require social_stream.objects
3
5
 
@@ -15,7 +17,7 @@ SocialStream.Comments = (function(SS, $, undefined){
15
17
  $(".actor_name_new_comment").hide();
16
18
  $(".actor_logo_new_comment").hide();
17
19
 
18
- $(".input_new_comments").Watermark(I18n.t('comment.input'),"#666");
20
+ $(".input_new_comments").watermark(I18n.t('comment.input'),"#666");
19
21
 
20
22
  $(".input_new_comments")
21
23
  .change(function(){autoSize(this);})
@@ -40,8 +42,13 @@ SocialStream.Comments = (function(SS, $, undefined){
40
42
  //javascript for tocomment option
41
43
  $(".to_comment").click(function(){
42
44
  $(this).parents(".activity_content").find(".activity_new_comment").show();
43
- $(this).parents(".activity_content").find(".input_new_comments").click();
44
- $(this).parents(".activity_content").find(".input_new_comments").focus();
45
+ $(this)
46
+ .closest(".activity_content")
47
+ .find(".input_new_comments")
48
+ .click()
49
+ .focus()
50
+ .val("");
51
+
45
52
  return false;
46
53
  });
47
54
  }
@@ -1,3 +1,5 @@
1
+ //= require jquery.watermark
2
+
1
3
  SocialStream.Search = (function(SS, $, undefined){
2
4
  function init(){
3
5
  $.preloadImages ("<%= asset_path "mini-loading.gif" %>");
@@ -17,7 +19,7 @@ SocialStream.Search = (function(SS, $, undefined){
17
19
  return true;
18
20
  });
19
21
 
20
- $("#global_search_input").Watermark(I18n.t('search.write'));
22
+ $("#global_search_input").watermark(I18n.t('search.write'));
21
23
  }
22
24
 
23
25
  return {
@@ -1,5 +1,7 @@
1
- //= require social_stream.timeline
1
+ //= require jquery.watermark
2
2
  //
3
+ //= require social_stream.timeline
4
+
3
5
  SocialStream.Wall = (function(SS, $, undefined){
4
6
  var initCallbacks = [];
5
7
 
@@ -23,6 +25,10 @@ SocialStream.Wall = (function(SS, $, undefined){
23
25
  });
24
26
  }
25
27
 
28
+ var initPostWatermark = function(){
29
+ $("#input_activities").watermark(I18n.t('post.input'), "#666");
30
+ }
31
+
26
32
  var initFormSelector = function(){
27
33
  $('.activity_form_selector').click(function(){
28
34
  $('.activity_form_selector').removeClass('selected');
@@ -129,6 +135,7 @@ SocialStream.Wall = (function(SS, $, undefined){
129
135
 
130
136
  addInitCallback(initFirstForm);
131
137
  addInitCallback(initFormButton);
138
+ addInitCallback(initPostWatermark );
132
139
  addInitCallback(initFormSelector);
133
140
  addInitCallback(initSecuritySelect);
134
141
  addInitCallback(activateAntiRebounds);
@@ -8,7 +8,7 @@
8
8
 
9
9
  /* Fixes to tipsy, the plugin for tooltips */
10
10
 
11
- .tipsy{ background-image: url(../assets/tipsy.gif); }
11
+ .tipsy{ background-image: url(<%= asset_path "tipsy.gif" %>); }
12
12
  .tipsy-inner { background-color: $secondary-color; color: $sentence-color; }
13
13
 
14
14
  /****************** WALL - ACTIVITIES *********************/
@@ -63,6 +63,10 @@ class Relation < ActiveRecord::Base
63
63
  where(:sender_type => st, :receiver_type => rt)
64
64
  }
65
65
 
66
+ scope :positive, lambda {
67
+ where(:type => positive_names)
68
+ }
69
+
66
70
  before_create :initialize_sender_type
67
71
 
68
72
  class << self
data/app/models/tie.rb CHANGED
@@ -48,6 +48,11 @@ class Tie < ActiveRecord::Base
48
48
  end
49
49
  }
50
50
 
51
+ scope :positive, lambda {
52
+ joins(:relation).
53
+ merge(Relation.positive)
54
+ }
55
+
51
56
  scope :with_permissions, lambda { |action, object|
52
57
  joins(:relation => :permissions).
53
58
  where('permissions.action' => action).
@@ -48,7 +48,7 @@
48
48
  $("#center_body").css("width","782px");
49
49
  $("#center_body").css("max-width","782px");
50
50
  $("#content").css("width","782px");
51
- $("#contacts_filter_input").Watermark("<%= escape_javascript(I18n.t('search.name')) %>");
51
+ $("#contacts_filter_input").watermark("<%= escape_javascript(I18n.t('search.name')) %>");
52
52
  //When clicking an unselected actor
53
53
  var unselected_actor_click = function(){
54
54
  var clone = $(this).clone();
@@ -138,4 +138,4 @@
138
138
  });
139
139
  });
140
140
  <%= render :partial => 'cheesecake' %>
141
- <% end %>
141
+ <% end %>
@@ -27,7 +27,7 @@ $(document).ready(function() {
27
27
  $("#header_search_display").hide();
28
28
  });
29
29
 
30
- $("#header_search_input").Watermark("<%= escape_javascript(I18n.t('search.name')) %>");
30
+ $("#header_search_input").watermark("<%= escape_javascript(I18n.t('search.name')) %>");
31
31
 
32
32
  $("#header_search_input").keyup(function() {
33
33
  var searchstring = $(this).val();
@@ -59,4 +59,4 @@ $(document).ready(function() {
59
59
  return false;
60
60
  });
61
61
  })
62
- <% end %>
62
+ <% end %>
@@ -1,7 +1 @@
1
1
  <%= f.text_field :text, :id => "input_activities", :size => 85 %>
2
-
3
- <%= javascript_tag do %>
4
- $(function() {
5
- $("#input_activities").Watermark("<%= I18n.t('post.input') %>","#666");
6
- });
7
- <% end %>
@@ -1,11 +1,11 @@
1
1
  # Default relations for Social Stream
2
2
  #
3
- # Define the default relations and permissions supported by your application
4
- # Though subjects can customize their own relations, these are the defaults
5
- # to start up
3
+ # Define the default relations and permissions offered by your application
4
+ # Though subjects (user, groups, etc.) can customize their own relations,
5
+ # these are the defaults to start up with
6
6
  #
7
7
  # Detailed information on permissions is available at:
8
- # http://rdoc.info/gems/social_stream/Permission
8
+ # http://rdoc.info/gems/social_stream-base/Permission
9
9
  #
10
10
  user:
11
11
  friend:
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Base
3
- VERSION = "0.17.1".freeze
3
+ VERSION = "0.17.2".freeze
4
4
  end
5
5
  end
@@ -162,7 +162,7 @@ namespace :db do
162
162
  puts 'Post population'
163
163
  posts_start = Time.now
164
164
 
165
- SocialStream::Populate.power_law(Tie.all) do |t|
165
+ SocialStream::Populate.power_law(Tie.positive.all) do |t|
166
166
  updated = Time.at(rand(Time.now.to_i))
167
167
 
168
168
  author = t.sender
@@ -170,7 +170,7 @@ namespace :db do
170
170
  user_author = ( t.sender.subject_type == "User" ? t.sender : t.sender.user_author )
171
171
 
172
172
  p = Post.create :text =>
173
- "This post sActorhould be for #{ t.relation.name } of #{ t.sender.name }.\n#{ Forgery::LoremIpsum.paragraph(:random => true) }",
173
+ "This post should be for #{ t.relation.name } of #{ t.sender.name }.\n#{ Forgery::LoremIpsum.paragraph(:random => true) }",
174
174
  :created_at => Time.at(rand(updated.to_i)),
175
175
  :updated_at => updated,
176
176
  :author_id => author.id,
@@ -1,11 +1,11 @@
1
1
  # Default relations for Social Stream
2
2
  #
3
- # Define the default relations and permissions supported by your application
4
- # Though subjects can customize their own relations, these are the defaults
5
- # to start up
3
+ # Define the default relations and permissions offered by your application
4
+ # Though subjects (user, groups, etc.) can customize their own relations,
5
+ # these are the defaults to start up with
6
6
  #
7
7
  # Detailed information on permissions is available at:
8
- # http://rdoc.info/gems/social_stream/Permission
8
+ # http://rdoc.info/gems/social_stream-base/Permission
9
9
  #
10
10
  user:
11
11
  friend:
@@ -0,0 +1,563 @@
1
+ /*
2
+ Watermark plugin for jQuery
3
+ Version: 3.1.3
4
+ http://jquery-watermark.googlecode.com/
5
+
6
+ Copyright (c) 2009-2011 Todd Northrop
7
+ http://www.speednet.biz/
8
+
9
+ March 22, 2011
10
+
11
+ Requires: jQuery 1.2.3+
12
+
13
+ Dual licensed under the MIT or GPL Version 2 licenses.
14
+ See mit-license.txt and gpl2-license.txt in the project root for details.
15
+ ------------------------------------------------------*/
16
+
17
+ (function ($, window, undefined) {
18
+
19
+ var
20
+ // String constants for data names
21
+ dataFlag = "watermark",
22
+ dataClass = "watermarkClass",
23
+ dataFocus = "watermarkFocus",
24
+ dataFormSubmit = "watermarkSubmit",
25
+ dataMaxLen = "watermarkMaxLength",
26
+ dataPassword = "watermarkPassword",
27
+ dataText = "watermarkText",
28
+
29
+ // Copy of native jQuery regex use to strip return characters from element value
30
+ rreturn = /\r/g,
31
+
32
+ // Includes only elements with watermark defined
33
+ selWatermarkDefined = "input:data(" + dataFlag + "),textarea:data(" + dataFlag + ")",
34
+
35
+ // Includes only elements capable of having watermark
36
+ selWatermarkAble = "input:text,input:password,input[type=search],input:not([type]),textarea",
37
+
38
+ // triggerFns:
39
+ // Array of function names to look for in the global namespace.
40
+ // Any such functions found will be hijacked to trigger a call to
41
+ // hideAll() any time they are called. The default value is the
42
+ // ASP.NET function that validates the controls on the page
43
+ // prior to a postback.
44
+ //
45
+ // Am I missing other important trigger function(s) to look for?
46
+ // Please leave me feedback:
47
+ // http://code.google.com/p/jquery-watermark/issues/list
48
+ triggerFns = [
49
+ "Page_ClientValidate"
50
+ ],
51
+
52
+ // Holds a value of true if a watermark was displayed since the last
53
+ // hideAll() was executed. Avoids repeatedly calling hideAll().
54
+ pageDirty = false,
55
+
56
+ // Detects if the browser can handle native placeholders
57
+ hasNativePlaceholder = ("placeholder" in document.createElement("input"));
58
+
59
+ // Best practice: this plugin adds only one method to the jQuery object.
60
+ // Also ensures that the watermark code is only added once.
61
+ $.watermark = $.watermark || {
62
+
63
+ // Current version number of the plugin
64
+ version: "3.1.3",
65
+
66
+ runOnce: true,
67
+
68
+ // Default options used when watermarks are instantiated.
69
+ // Can be changed to affect the default behavior for all
70
+ // new or updated watermarks.
71
+ options: {
72
+
73
+ // Default class name for all watermarks
74
+ className: "watermark",
75
+
76
+ // If true, plugin will detect and use native browser support for
77
+ // watermarks, if available. (e.g., WebKit's placeholder attribute.)
78
+ useNative: true,
79
+
80
+ // If true, all watermarks will be hidden during the window's
81
+ // beforeunload event. This is done mainly because WebKit
82
+ // browsers remember the watermark text during navigation
83
+ // and try to restore the watermark text after the user clicks
84
+ // the Back button. We can avoid this by hiding the text before
85
+ // the browser has a chance to save it. The regular unload event
86
+ // was tried, but it seems the browser saves the text before
87
+ // that event kicks off, because it didn't work.
88
+ hideBeforeUnload: true
89
+ },
90
+
91
+ // Hide one or more watermarks by specifying any selector type
92
+ // i.e., DOM element, string selector, jQuery matched set, etc.
93
+ hide: function (selector) {
94
+ $(selector).filter(selWatermarkDefined).each(
95
+ function () {
96
+ $.watermark._hide($(this));
97
+ }
98
+ );
99
+ },
100
+
101
+ // Internal use only.
102
+ _hide: function ($input, focus) {
103
+ var elem = $input[0],
104
+ inputVal = (elem.value || "").replace(rreturn, ""),
105
+ inputWm = $input.data(dataText) || "",
106
+ maxLen = $input.data(dataMaxLen) || 0,
107
+ className = $input.data(dataClass);
108
+
109
+ if ((inputWm.length) && (inputVal == inputWm)) {
110
+ elem.value = "";
111
+
112
+ // Password type?
113
+ if ($input.data(dataPassword)) {
114
+
115
+ if (($input.attr("type") || "") === "text") {
116
+ var $pwd = $input.data(dataPassword) || [],
117
+ $wrap = $input.parent() || [];
118
+
119
+ if (($pwd.length) && ($wrap.length)) {
120
+ $wrap[0].removeChild($input[0]); // Can't use jQuery methods, because they destroy data
121
+ $wrap[0].appendChild($pwd[0]);
122
+ $input = $pwd;
123
+ }
124
+ }
125
+ }
126
+
127
+ if (maxLen) {
128
+ $input.attr("maxLength", maxLen);
129
+ $input.removeData(dataMaxLen);
130
+ }
131
+
132
+ if (focus) {
133
+ $input.attr("autocomplete", "off"); // Avoid NS_ERROR_XPC_JS_THREW_STRING error in Firefox
134
+
135
+ window.setTimeout(
136
+ function () {
137
+ $input.select(); // Fix missing cursor in IE
138
+ }
139
+ , 1);
140
+ }
141
+ }
142
+
143
+ className && $input.removeClass(className);
144
+ },
145
+
146
+ // Display one or more watermarks by specifying any selector type
147
+ // i.e., DOM element, string selector, jQuery matched set, etc.
148
+ // If conditions are not right for displaying a watermark, ensures that watermark is not shown.
149
+ show: function (selector) {
150
+ $(selector).filter(selWatermarkDefined).each(
151
+ function () {
152
+ $.watermark._show($(this));
153
+ }
154
+ );
155
+ },
156
+
157
+ // Internal use only.
158
+ _show: function ($input) {
159
+ var elem = $input[0],
160
+ val = (elem.value || "").replace(rreturn, ""),
161
+ text = $input.data(dataText) || "",
162
+ type = $input.attr("type") || "",
163
+ className = $input.data(dataClass);
164
+
165
+ if (((val.length == 0) || (val == text)) && (!$input.data(dataFocus))) {
166
+ pageDirty = true;
167
+
168
+ // Password type?
169
+ if ($input.data(dataPassword)) {
170
+
171
+ if (type === "password") {
172
+ var $pwd = $input.data(dataPassword) || [],
173
+ $wrap = $input.parent() || [];
174
+
175
+ if (($pwd.length) && ($wrap.length)) {
176
+ $wrap[0].removeChild($input[0]); // Can't use jQuery methods, because they destroy data
177
+ $wrap[0].appendChild($pwd[0]);
178
+ $input = $pwd;
179
+ $input.attr("maxLength", text.length);
180
+ elem = $input[0];
181
+ }
182
+ }
183
+ }
184
+
185
+ // Ensure maxLength big enough to hold watermark (input of type="text" or type="search" only)
186
+ if ((type === "text") || (type === "search")) {
187
+ var maxLen = $input.attr("maxLength") || 0;
188
+
189
+ if ((maxLen > 0) && (text.length > maxLen)) {
190
+ $input.data(dataMaxLen, maxLen);
191
+ $input.attr("maxLength", text.length);
192
+ }
193
+ }
194
+
195
+ className && $input.addClass(className);
196
+ elem.value = text;
197
+ }
198
+ else {
199
+ $.watermark._hide($input);
200
+ }
201
+ },
202
+
203
+ // Hides all watermarks on the current page.
204
+ hideAll: function () {
205
+ if (pageDirty) {
206
+ $.watermark.hide(selWatermarkAble);
207
+ pageDirty = false;
208
+ }
209
+ },
210
+
211
+ // Displays all watermarks on the current page.
212
+ showAll: function () {
213
+ $.watermark.show(selWatermarkAble);
214
+ }
215
+ };
216
+
217
+ $.fn.watermark = $.fn.watermark || function (text, options) {
218
+ /// <summary>
219
+ /// Set watermark text and class name on all input elements of type="text/password/search" and
220
+ /// textareas within the matched set. If className is not specified in options, the default is
221
+ /// "watermark". Within the matched set, only input elements with type="text/password/search"
222
+ /// and textareas are affected; all other elements are ignored.
223
+ /// </summary>
224
+ /// <returns type="jQuery">
225
+ /// Returns the original jQuery matched set (not just the input and texarea elements).
226
+ /// </returns>
227
+ /// <param name="text" type="String">
228
+ /// Text to display as a watermark when the input or textarea element has an empty value and does not
229
+ /// have focus. The first time watermark() is called on an element, if this argument is empty (or not
230
+ /// a String type), then the watermark will have the net effect of only changing the class name when
231
+ /// the input or textarea element's value is empty and it does not have focus.
232
+ /// </param>
233
+ /// <param name="options" type="Object" optional="true">
234
+ /// Provides the ability to override the default watermark options ($.watermark.options). For backward
235
+ /// compatibility, if a string value is supplied, it is used as the class name that overrides the class
236
+ /// name in $.watermark.options.className. Properties include:
237
+ /// className: When the watermark is visible, the element will be styled using this class name.
238
+ /// useNative (Boolean or Function): Specifies if native browser support for watermarks will supersede
239
+ /// plugin functionality. If useNative is a function, the return value from the function will
240
+ /// determine if native support is used. The function is passed one argument -- a jQuery object
241
+ /// containing the element being tested as the only element in its matched set -- and the DOM
242
+ /// element being tested is the object on which the function is invoked (the value of "this").
243
+ /// </param>
244
+ /// <remarks>
245
+ /// The effect of changing the text and class name on an input element is called a watermark because
246
+ /// typically light gray text is used to provide a hint as to what type of input is required. However,
247
+ /// the appearance of the watermark can be something completely different: simply change the CSS style
248
+ /// pertaining to the supplied class name.
249
+ ///
250
+ /// The first time watermark() is called on an element, the watermark text and class name are initialized,
251
+ /// and the focus and blur events are hooked in order to control the display of the watermark. Also, as
252
+ /// of version 3.0, drag and drop events are hooked to guard against dropped text being appended to the
253
+ /// watermark. If native watermark support is provided by the browser, it is detected and used, unless
254
+ /// the useNative option is set to false.
255
+ ///
256
+ /// Subsequently, watermark() can be called again on an element in order to change the watermark text
257
+ /// and/or class name, and it can also be called without any arguments in order to refresh the display.
258
+ ///
259
+ /// For example, after changing the value of the input or textarea element programmatically, watermark()
260
+ /// should be called without any arguments to refresh the display, because the change event is only
261
+ /// triggered by user actions, not by programmatic changes to an input or textarea element's value.
262
+ ///
263
+ /// The one exception to programmatic updates is for password input elements: you are strongly cautioned
264
+ /// against changing the value of a password input element programmatically (after the page loads).
265
+ /// The reason is that some fairly hairy code is required behind the scenes to make the watermarks bypass
266
+ /// IE security and switch back and forth between clear text (for watermarks) and obscured text (for
267
+ /// passwords). It is *possible* to make programmatic changes, but it must be done in a certain way, and
268
+ /// overall it is not recommended.
269
+ /// </remarks>
270
+
271
+ if (!this.length) {
272
+ return this;
273
+ }
274
+
275
+ var hasClass = false,
276
+ hasText = (typeof(text) === "string");
277
+
278
+ if (hasText) {
279
+ text = text.replace(rreturn, "");
280
+ }
281
+
282
+ if (typeof(options) === "object") {
283
+ hasClass = (typeof(options.className) === "string");
284
+ options = $.extend({}, $.watermark.options, options);
285
+ }
286
+ else if (typeof(options) === "string") {
287
+ hasClass = true;
288
+ options = $.extend({}, $.watermark.options, {className: options});
289
+ }
290
+ else {
291
+ options = $.watermark.options;
292
+ }
293
+
294
+ if (typeof(options.useNative) !== "function") {
295
+ options.useNative = options.useNative? function () { return true; } : function () { return false; };
296
+ }
297
+
298
+ return this.each(
299
+ function () {
300
+ var $input = $(this);
301
+
302
+ if (!$input.is(selWatermarkAble)) {
303
+ return;
304
+ }
305
+
306
+ // Watermark already initialized?
307
+ if ($input.data(dataFlag)) {
308
+
309
+ // If re-defining text or class, first remove existing watermark, then make changes
310
+ if (hasText || hasClass) {
311
+ $.watermark._hide($input);
312
+
313
+ if (hasText) {
314
+ $input.data(dataText, text);
315
+ }
316
+
317
+ if (hasClass) {
318
+ $input.data(dataClass, options.className);
319
+ }
320
+ }
321
+ }
322
+ else {
323
+
324
+ // Detect and use native browser support, if enabled in options
325
+ if (
326
+ (hasNativePlaceholder)
327
+ && (options.useNative.call(this, $input))
328
+ && (($input.attr("tagName") || "") !== "TEXTAREA")
329
+ ) {
330
+ // className is not set because current placeholder standard doesn't
331
+ // have a separate class name property for placeholders (watermarks).
332
+ if (hasText) {
333
+ $input.attr("placeholder", text);
334
+ }
335
+
336
+ // Only set data flag for non-native watermarks
337
+ // [purposely commented-out] -> $input.data(dataFlag, 1);
338
+ return;
339
+ }
340
+
341
+ $input.data(dataText, hasText? text : "");
342
+ $input.data(dataClass, options.className);
343
+ $input.data(dataFlag, 1); // Flag indicates watermark was initialized
344
+
345
+ // Special processing for password type
346
+ if (($input.attr("type") || "") === "password") {
347
+ var $wrap = $input.wrap("<span>").parent(),
348
+ $wm = $($wrap.html().replace(/type=["']?password["']?/i, 'type="text"'));
349
+
350
+ $wm.data(dataText, $input.data(dataText));
351
+ $wm.data(dataClass, $input.data(dataClass));
352
+ $wm.data(dataFlag, 1);
353
+ $wm.attr("maxLength", text.length);
354
+
355
+ $wm.focus(
356
+ function () {
357
+ $.watermark._hide($wm, true);
358
+ }
359
+ ).bind("dragenter",
360
+ function () {
361
+ $.watermark._hide($wm);
362
+ }
363
+ ).bind("dragend",
364
+ function () {
365
+ window.setTimeout(function () { $wm.blur(); }, 1);
366
+ }
367
+ );
368
+ $input.blur(
369
+ function () {
370
+ $.watermark._show($input);
371
+ }
372
+ ).bind("dragleave",
373
+ function () {
374
+ $.watermark._show($input);
375
+ }
376
+ );
377
+
378
+ $wm.data(dataPassword, $input);
379
+ $input.data(dataPassword, $wm);
380
+ }
381
+ else {
382
+
383
+ $input.focus(
384
+ function () {
385
+ $input.data(dataFocus, 1);
386
+ $.watermark._hide($input, true);
387
+ }
388
+ ).blur(
389
+ function () {
390
+ $input.data(dataFocus, 0);
391
+ $.watermark._show($input);
392
+ }
393
+ ).bind("dragenter",
394
+ function () {
395
+ $.watermark._hide($input);
396
+ }
397
+ ).bind("dragleave",
398
+ function () {
399
+ $.watermark._show($input);
400
+ }
401
+ ).bind("dragend",
402
+ function () {
403
+ window.setTimeout(function () { $.watermark._show($input); }, 1);
404
+ }
405
+ ).bind("drop",
406
+ // Firefox makes this lovely function necessary because the dropped text
407
+ // is merged with the watermark before the drop event is called.
408
+ function (evt) {
409
+ var elem = $input[0],
410
+ dropText = evt.originalEvent.dataTransfer.getData("Text");
411
+
412
+ if ((elem.value || "").replace(rreturn, "").replace(dropText, "") === $input.data(dataText)) {
413
+ elem.value = dropText;
414
+ }
415
+
416
+ $input.focus();
417
+ }
418
+ );
419
+ }
420
+
421
+ // In order to reliably clear all watermarks before form submission,
422
+ // we need to replace the form's submit function with our own
423
+ // function. Otherwise watermarks won't be cleared when the form
424
+ // is submitted programmatically.
425
+ if (this.form) {
426
+ var form = this.form,
427
+ $form = $(form);
428
+
429
+ if (!$form.data(dataFormSubmit)) {
430
+ $form.submit($.watermark.hideAll);
431
+
432
+ // form.submit exists for all browsers except Google Chrome
433
+ // (see "else" below for explanation)
434
+ if (form.submit) {
435
+ $form.data(dataFormSubmit, form.submit);
436
+
437
+ form.submit = (function (f, $f) {
438
+ return function () {
439
+ var nativeSubmit = $f.data(dataFormSubmit);
440
+
441
+ $.watermark.hideAll();
442
+
443
+ if (nativeSubmit.apply) {
444
+ nativeSubmit.apply(f, Array.prototype.slice.call(arguments));
445
+ }
446
+ else {
447
+ nativeSubmit();
448
+ }
449
+ };
450
+ })(form, $form);
451
+ }
452
+ else {
453
+ $form.data(dataFormSubmit, 1);
454
+
455
+ // This strangeness is due to the fact that Google Chrome's
456
+ // form.submit function is not visible to JavaScript (identifies
457
+ // as "undefined"). I had to invent a solution here because hours
458
+ // of Googling (ironically) for an answer did not turn up anything
459
+ // useful. Within my own form.submit function I delete the form's
460
+ // submit function, and then call the non-existent function --
461
+ // which, in the world of Google Chrome, still exists.
462
+ form.submit = (function (f) {
463
+ return function () {
464
+ $.watermark.hideAll();
465
+ delete f.submit;
466
+ f.submit();
467
+ };
468
+ })(form);
469
+ }
470
+ }
471
+ }
472
+ }
473
+
474
+ $.watermark._show($input);
475
+ }
476
+ );
477
+ };
478
+
479
+ // The code included within the following if structure is guaranteed to only run once,
480
+ // even if the watermark script file is included multiple times in the page.
481
+ if ($.watermark.runOnce) {
482
+ $.watermark.runOnce = false;
483
+
484
+ $.extend($.expr[":"], {
485
+
486
+ // Extends jQuery with a custom selector - ":data(...)"
487
+ // :data(<name>) Includes elements that have a specific name defined in the jQuery data
488
+ // collection. (Only the existence of the name is checked; the value is ignored.)
489
+ // A more sophisticated version of the :data() custom selector originally part of this plugin
490
+ // was removed for compatibility with jQuery UI. The original code can be found in the SVN
491
+ // source listing in the file, "jquery.data.js".
492
+ data: function( elem, i, match ) {
493
+ return !!$.data( elem, match[ 3 ] );
494
+ }
495
+ });
496
+
497
+ // Overloads the jQuery .val() function to return the underlying input value on
498
+ // watermarked input elements. When .val() is being used to set values, this
499
+ // function ensures watermarks are properly set/removed after the values are set.
500
+ // Uses self-executing function to override the default jQuery function.
501
+ (function (valOld) {
502
+
503
+ $.fn.val = function () {
504
+
505
+ // Best practice: return immediately if empty matched set
506
+ if ( !this.length ) {
507
+ return arguments.length? this : undefined;
508
+ }
509
+
510
+ // If no args, then we're getting the value of the first element;
511
+ // otherwise we're setting values for all elements in matched set
512
+ if ( !arguments.length ) {
513
+
514
+ // If element is watermarked, get the underlying value;
515
+ // otherwise use native jQuery .val()
516
+ if ( this.data(dataFlag) ) {
517
+ var v = (this[0].value || "").replace(rreturn, "");
518
+ return (v === (this.data(dataText) || ""))? "" : v;
519
+ }
520
+ else {
521
+ return valOld.apply( this, arguments );
522
+ }
523
+ }
524
+ else {
525
+ valOld.apply( this, arguments );
526
+ $.watermark.show(this);
527
+ return this;
528
+ }
529
+ };
530
+
531
+ })($.fn.val);
532
+
533
+ // Hijack any functions found in the triggerFns list
534
+ if (triggerFns.length) {
535
+
536
+ // Wait until DOM is ready before searching
537
+ $(function () {
538
+ var i, name, fn;
539
+
540
+ for (i=triggerFns.length-1; i>=0; i--) {
541
+ name = triggerFns[i];
542
+ fn = window[name];
543
+
544
+ if (typeof(fn) === "function") {
545
+ window[name] = (function (origFn) {
546
+ return function () {
547
+ $.watermark.hideAll();
548
+ return origFn.apply(null, Array.prototype.slice.call(arguments));
549
+ };
550
+ })(fn);
551
+ }
552
+ }
553
+ });
554
+ }
555
+
556
+ $(window).bind("beforeunload", function () {
557
+ if ($.watermark.options.hideBeforeUnload) {
558
+ $.watermark.hideAll();
559
+ }
560
+ });
561
+ }
562
+
563
+ })(jQuery, window);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 0.17.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-07 00:00:00.000000000Z
13
+ date: 2012-03-12 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &76571270 !ruby/object:Gem::Requirement
17
+ requirement: &73996770 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 3.1.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *76571270
25
+ version_requirements: *73996770
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: ancestry
28
- requirement: &76568600 !ruby/object:Gem::Requirement
28
+ requirement: &73996210 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 1.2.3
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *76568600
36
+ version_requirements: *73996210
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: foreigner
39
- requirement: &76567430 !ruby/object:Gem::Requirement
39
+ requirement: &73995510 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.1.1
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *76567430
47
+ version_requirements: *73995510
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: devise
50
- requirement: &76566640 !ruby/object:Gem::Requirement
50
+ requirement: &73994640 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 1.5.3
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *76566640
58
+ version_requirements: *73994640
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: inherited_resources
61
- requirement: &76565790 !ruby/object:Gem::Requirement
61
+ requirement: &73993470 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 1.3.0
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *76565790
69
+ version_requirements: *73993470
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: stringex
72
- requirement: &76564780 !ruby/object:Gem::Requirement
72
+ requirement: &73992940 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 1.3.0
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *76564780
80
+ version_requirements: *73992940
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: avatars_for_rails
83
- requirement: &76564050 !ruby/object:Gem::Requirement
83
+ requirement: &73992090 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ~>
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: 0.2.2
89
89
  type: :runtime
90
90
  prerelease: false
91
- version_requirements: *76564050
91
+ version_requirements: *73992090
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: jquery-rails
94
- requirement: &76562900 !ruby/object:Gem::Requirement
94
+ requirement: &73991590 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: 1.0.9
100
100
  type: :runtime
101
101
  prerelease: false
102
- version_requirements: *76562900
102
+ version_requirements: *73991590
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: cancan
105
- requirement: &76562250 !ruby/object:Gem::Requirement
105
+ requirement: &73991050 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ~>
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: 1.6.4
111
111
  type: :runtime
112
112
  prerelease: false
113
- version_requirements: *76562250
113
+ version_requirements: *73991050
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: kaminari
116
- requirement: &76561610 !ruby/object:Gem::Requirement
116
+ requirement: &73990470 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ~>
@@ -121,10 +121,10 @@ dependencies:
121
121
  version: 0.13.0
122
122
  type: :runtime
123
123
  prerelease: false
124
- version_requirements: *76561610
124
+ version_requirements: *73990470
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: omniauth
127
- requirement: &76561160 !ruby/object:Gem::Requirement
127
+ requirement: &73987100 !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
130
  - - ~>
@@ -132,10 +132,10 @@ dependencies:
132
132
  version: 1.0.2
133
133
  type: :runtime
134
134
  prerelease: false
135
- version_requirements: *76561160
135
+ version_requirements: *73987100
136
136
  - !ruby/object:Gem::Dependency
137
137
  name: omniauth-facebook
138
- requirement: &76560710 !ruby/object:Gem::Requirement
138
+ requirement: &73986560 !ruby/object:Gem::Requirement
139
139
  none: false
140
140
  requirements:
141
141
  - - ~>
@@ -143,10 +143,10 @@ dependencies:
143
143
  version: 1.2.0
144
144
  type: :runtime
145
145
  prerelease: false
146
- version_requirements: *76560710
146
+ version_requirements: *73986560
147
147
  - !ruby/object:Gem::Dependency
148
148
  name: omniauth-linkedin
149
- requirement: &76559970 !ruby/object:Gem::Requirement
149
+ requirement: &73986050 !ruby/object:Gem::Requirement
150
150
  none: false
151
151
  requirements:
152
152
  - - ~>
@@ -154,10 +154,10 @@ dependencies:
154
154
  version: 0.0.6
155
155
  type: :runtime
156
156
  prerelease: false
157
- version_requirements: *76559970
157
+ version_requirements: *73986050
158
158
  - !ruby/object:Gem::Dependency
159
159
  name: mailboxer
160
- requirement: &76559650 !ruby/object:Gem::Requirement
160
+ requirement: &73985530 !ruby/object:Gem::Requirement
161
161
  none: false
162
162
  requirements:
163
163
  - - ~>
@@ -165,10 +165,10 @@ dependencies:
165
165
  version: 0.6.0
166
166
  type: :runtime
167
167
  prerelease: false
168
- version_requirements: *76559650
168
+ version_requirements: *73985530
169
169
  - !ruby/object:Gem::Dependency
170
170
  name: acts-as-taggable-on
171
- requirement: &76558950 !ruby/object:Gem::Requirement
171
+ requirement: &73985000 !ruby/object:Gem::Requirement
172
172
  none: false
173
173
  requirements:
174
174
  - - ~>
@@ -176,10 +176,10 @@ dependencies:
176
176
  version: 2.2.2
177
177
  type: :runtime
178
178
  prerelease: false
179
- version_requirements: *76558950
179
+ version_requirements: *73985000
180
180
  - !ruby/object:Gem::Dependency
181
181
  name: formtastic
182
- requirement: &76558000 !ruby/object:Gem::Requirement
182
+ requirement: &73984580 !ruby/object:Gem::Requirement
183
183
  none: false
184
184
  requirements:
185
185
  - - ~>
@@ -187,10 +187,10 @@ dependencies:
187
187
  version: 1.2.3
188
188
  type: :runtime
189
189
  prerelease: false
190
- version_requirements: *76558000
190
+ version_requirements: *73984580
191
191
  - !ruby/object:Gem::Dependency
192
192
  name: simple-navigation
193
- requirement: &76557140 !ruby/object:Gem::Requirement
193
+ requirement: &73984140 !ruby/object:Gem::Requirement
194
194
  none: false
195
195
  requirements:
196
196
  - - ~>
@@ -198,10 +198,10 @@ dependencies:
198
198
  version: 3.5.1
199
199
  type: :runtime
200
200
  prerelease: false
201
- version_requirements: *76557140
201
+ version_requirements: *73984140
202
202
  - !ruby/object:Gem::Dependency
203
203
  name: resque
204
- requirement: &76556750 !ruby/object:Gem::Requirement
204
+ requirement: &73983710 !ruby/object:Gem::Requirement
205
205
  none: false
206
206
  requirements:
207
207
  - - ~>
@@ -209,10 +209,10 @@ dependencies:
209
209
  version: 1.19.0
210
210
  type: :runtime
211
211
  prerelease: false
212
- version_requirements: *76556750
212
+ version_requirements: *73983710
213
213
  - !ruby/object:Gem::Dependency
214
214
  name: modernizr-rails
215
- requirement: &76556100 !ruby/object:Gem::Requirement
215
+ requirement: &73983050 !ruby/object:Gem::Requirement
216
216
  none: false
217
217
  requirements:
218
218
  - - ~>
@@ -220,10 +220,10 @@ dependencies:
220
220
  version: 2.0.6
221
221
  type: :runtime
222
222
  prerelease: false
223
- version_requirements: *76556100
223
+ version_requirements: *73983050
224
224
  - !ruby/object:Gem::Dependency
225
225
  name: thinking-sphinx
226
- requirement: &76554490 !ruby/object:Gem::Requirement
226
+ requirement: &73982570 !ruby/object:Gem::Requirement
227
227
  none: false
228
228
  requirements:
229
229
  - - ~>
@@ -231,10 +231,10 @@ dependencies:
231
231
  version: 2.0.8
232
232
  type: :runtime
233
233
  prerelease: false
234
- version_requirements: *76554490
234
+ version_requirements: *73982570
235
235
  - !ruby/object:Gem::Dependency
236
236
  name: sass-rails
237
- requirement: &76551540 !ruby/object:Gem::Requirement
237
+ requirement: &73981710 !ruby/object:Gem::Requirement
238
238
  none: false
239
239
  requirements:
240
240
  - - ! '>='
@@ -242,10 +242,10 @@ dependencies:
242
242
  version: 3.1.0
243
243
  type: :runtime
244
244
  prerelease: false
245
- version_requirements: *76551540
245
+ version_requirements: *73981710
246
246
  - !ruby/object:Gem::Dependency
247
247
  name: rails_autolink
248
- requirement: &76550070 !ruby/object:Gem::Requirement
248
+ requirement: &73980800 !ruby/object:Gem::Requirement
249
249
  none: false
250
250
  requirements:
251
251
  - - ~>
@@ -253,10 +253,10 @@ dependencies:
253
253
  version: 1.0.4
254
254
  type: :runtime
255
255
  prerelease: false
256
- version_requirements: *76550070
256
+ version_requirements: *73980800
257
257
  - !ruby/object:Gem::Dependency
258
258
  name: social_cheesecake
259
- requirement: &76547020 !ruby/object:Gem::Requirement
259
+ requirement: &73979930 !ruby/object:Gem::Requirement
260
260
  none: false
261
261
  requirements:
262
262
  - - ~>
@@ -264,10 +264,10 @@ dependencies:
264
264
  version: 0.4.0
265
265
  type: :runtime
266
266
  prerelease: false
267
- version_requirements: *76547020
267
+ version_requirements: *73979930
268
268
  - !ruby/object:Gem::Dependency
269
269
  name: i18n-js
270
- requirement: &76544820 !ruby/object:Gem::Requirement
270
+ requirement: &73979430 !ruby/object:Gem::Requirement
271
271
  none: false
272
272
  requirements:
273
273
  - - ~>
@@ -275,10 +275,10 @@ dependencies:
275
275
  version: 2.1.2
276
276
  type: :runtime
277
277
  prerelease: false
278
- version_requirements: *76544820
278
+ version_requirements: *73979430
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: capybara
281
- requirement: &76542470 !ruby/object:Gem::Requirement
281
+ requirement: &73975840 !ruby/object:Gem::Requirement
282
282
  none: false
283
283
  requirements:
284
284
  - - ~>
@@ -286,10 +286,10 @@ dependencies:
286
286
  version: 0.3.9
287
287
  type: :development
288
288
  prerelease: false
289
- version_requirements: *76542470
289
+ version_requirements: *73975840
290
290
  - !ruby/object:Gem::Dependency
291
291
  name: sqlite3-ruby
292
- requirement: &76540830 !ruby/object:Gem::Requirement
292
+ requirement: &73975480 !ruby/object:Gem::Requirement
293
293
  none: false
294
294
  requirements:
295
295
  - - ! '>='
@@ -297,10 +297,10 @@ dependencies:
297
297
  version: '0'
298
298
  type: :development
299
299
  prerelease: false
300
- version_requirements: *76540830
300
+ version_requirements: *73975480
301
301
  - !ruby/object:Gem::Dependency
302
302
  name: ruby-debug19
303
- requirement: &76538610 !ruby/object:Gem::Requirement
303
+ requirement: &73975030 !ruby/object:Gem::Requirement
304
304
  none: false
305
305
  requirements:
306
306
  - - ! '>='
@@ -308,10 +308,10 @@ dependencies:
308
308
  version: '0'
309
309
  type: :development
310
310
  prerelease: false
311
- version_requirements: *76538610
311
+ version_requirements: *73975030
312
312
  - !ruby/object:Gem::Dependency
313
313
  name: rspec-rails
314
- requirement: &76537000 !ruby/object:Gem::Requirement
314
+ requirement: &73974540 !ruby/object:Gem::Requirement
315
315
  none: false
316
316
  requirements:
317
317
  - - ~>
@@ -319,10 +319,10 @@ dependencies:
319
319
  version: 2.6.1
320
320
  type: :development
321
321
  prerelease: false
322
- version_requirements: *76537000
322
+ version_requirements: *73974540
323
323
  - !ruby/object:Gem::Dependency
324
324
  name: factory_girl
325
- requirement: &76528490 !ruby/object:Gem::Requirement
325
+ requirement: &73974160 !ruby/object:Gem::Requirement
326
326
  none: false
327
327
  requirements:
328
328
  - - ~>
@@ -330,10 +330,10 @@ dependencies:
330
330
  version: 1.3.2
331
331
  type: :development
332
332
  prerelease: false
333
- version_requirements: *76528490
333
+ version_requirements: *73974160
334
334
  - !ruby/object:Gem::Dependency
335
335
  name: forgery
336
- requirement: &76527450 !ruby/object:Gem::Requirement
336
+ requirement: &73973800 !ruby/object:Gem::Requirement
337
337
  none: false
338
338
  requirements:
339
339
  - - ~>
@@ -341,10 +341,10 @@ dependencies:
341
341
  version: 0.4.2
342
342
  type: :development
343
343
  prerelease: false
344
- version_requirements: *76527450
344
+ version_requirements: *73973800
345
345
  - !ruby/object:Gem::Dependency
346
346
  name: ci_reporter
347
- requirement: &76526190 !ruby/object:Gem::Requirement
347
+ requirement: &73973410 !ruby/object:Gem::Requirement
348
348
  none: false
349
349
  requirements:
350
350
  - - ~>
@@ -352,10 +352,10 @@ dependencies:
352
352
  version: 1.6.4
353
353
  type: :development
354
354
  prerelease: false
355
- version_requirements: *76526190
355
+ version_requirements: *73973410
356
356
  - !ruby/object:Gem::Dependency
357
357
  name: nifty-generators
358
- requirement: &76525210 !ruby/object:Gem::Requirement
358
+ requirement: &73972990 !ruby/object:Gem::Requirement
359
359
  none: false
360
360
  requirements:
361
361
  - - ~>
@@ -363,7 +363,7 @@ dependencies:
363
363
  version: 0.4.5
364
364
  type: :development
365
365
  prerelease: false
366
- version_requirements: *76525210
366
+ version_requirements: *73972990
367
367
  description: ! 'Social Stream is a Ruby on Rails engine providing your application
368
368
  with social networking features and activity streams.
369
369
 
@@ -565,7 +565,7 @@ files:
565
565
  - app/assets/javascripts/toolbar.js
566
566
  - app/assets/javascripts/users.js
567
567
  - app/assets/stylesheets/_colors.scss
568
- - app/assets/stylesheets/activities.css.scss
568
+ - app/assets/stylesheets/activities.css.scss.erb
569
569
  - app/assets/stylesheets/base.css.scss
570
570
  - app/assets/stylesheets/cheesecake.css.scss
571
571
  - app/assets/stylesheets/contacts.css.scss
@@ -1012,7 +1012,7 @@ files:
1012
1012
  - vendor/assets/javascripts/jquery.tipsy.js
1013
1013
  - vendor/assets/javascripts/jquery.validate.js
1014
1014
  - vendor/assets/javascripts/jquery.validate.old.js
1015
- - vendor/assets/javascripts/jquery.watermarkinput.js
1015
+ - vendor/assets/javascripts/jquery.watermark.js
1016
1016
  - vendor/assets/javascripts/superfish.js
1017
1017
  - vendor/assets/stylesheets/carousel.css
1018
1018
  - vendor/assets/stylesheets/chosen-sprite.png
@@ -1,81 +0,0 @@
1
- /*
2
- * Copyright (c) 2007 Josh Bush (digitalbush.com)
3
- *
4
- * Permission is hereby granted, free of charge, to any person
5
- * obtaining a copy of this software and associated documentation
6
- * files (the "Software"), to deal in the Software without
7
- * restriction, including without limitation the rights to use,
8
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- * copies of the Software, and to permit persons to whom the
10
- * Software is furnished to do so, subject to the following
11
- * conditions:
12
-
13
- * The above copyright notice and this permission notice shall be
14
- * included in all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
- * OTHER DEALINGS IN THE SOFTWARE.
24
- */
25
-
26
- /*
27
- * Version: Beta 1
28
- * Release: 2007-06-01
29
- */
30
- (function($) {
31
- var map=new Array();
32
- $.Watermark = {
33
- ShowAll:function(){
34
- for (var i=0;i<map.length;i++){
35
- if(map[i].obj.val()==""){
36
- map[i].obj.val(map[i].text);
37
- map[i].obj.css("color",map[i].WatermarkColor);
38
- }else{
39
- map[i].obj.css("color",map[i].DefaultColor);
40
- }
41
- }
42
- },
43
- HideAll:function(){
44
- for (var i=0;i<map.length;i++){
45
- if(map[i].obj.val()==map[i].text)
46
- map[i].obj.val("");
47
- }
48
- }
49
- }
50
-
51
- $.fn.Watermark = function(text,color) {
52
- if(!color)
53
- color="#aaa";
54
- return this.each(
55
- function(){
56
- var input=$(this);
57
- var defaultColor=input.css("color");
58
- map[map.length]={text:text,obj:input,DefaultColor:defaultColor,WatermarkColor:color};
59
- function clearMessage(){
60
- if(input.val()==text)
61
- input.val("");
62
- input.css("color",defaultColor);
63
- }
64
-
65
- function insertMessage(){
66
- if(input.val().length==0 || input.val()==text){
67
- input.val(text);
68
- input.css("color",color);
69
- }else
70
- input.css("color",defaultColor);
71
- }
72
-
73
- input.focus(clearMessage);
74
- input.blur(insertMessage);
75
- input.change(insertMessage);
76
-
77
- insertMessage();
78
- }
79
- );
80
- };
81
- })(jQuery);