[llvm-commits] [LNT] r161423 - in /lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults: ./ LICENCE README.mkdn jquery.formdefaults.js jquery.formdefaults.min.js

Michael Gottesman mgottesman at apple.com
Tue Aug 7 09:37:29 PDT 2012


Author: mgottesman
Date: Tue Aug  7 11:37:29 2012
New Revision: 161423

URL: http://llvm.org/viewvc/llvm-project?rev=161423&view=rev
Log:
[LNT] Added jquery plugin jquery.formdefaults in ui/static/jquery/jquery.formdefaults
for use with the new compiler status overview page.

*NOTE* code is MIT Licensed.

Added:
    lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/
    lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/LICENCE   (with props)
    lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/README.mkdn   (with props)
    lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/jquery.formdefaults.js   (with props)
    lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/jquery.formdefaults.min.js   (with props)

Added: lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/LICENCE
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/LICENCE?rev=161423&view=auto
==============================================================================
--- lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/LICENCE (added)
+++ lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/LICENCE Tue Aug  7 11:37:29 2012
@@ -0,0 +1,19 @@
+The MIT License (MIT)
+
+Copyright (c) 2011 Rob Schmitt
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this 
+software and associated documentation files (the "Software"), to deal in the Software 
+without restriction, including without limitation the rights to use, copy, modify, merge, 
+publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 
+to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or 
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
+FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+DEALINGS IN THE SOFTWARE.
\ No newline at end of file

Propchange: lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/LICENCE
------------------------------------------------------------------------------
    svn:executable = *

Added: lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/README.mkdn
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/README.mkdn?rev=161423&view=auto
==============================================================================
--- lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/README.mkdn (added)
+++ lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/README.mkdn Tue Aug  7 11:37:29 2012
@@ -0,0 +1,22 @@
+# FormDefaults for jQuery
+
+This plugin allows you to provide default values for form fields, which are automatically hidden/shown as the user focuses into and out of the form field. The plugin will also bubble up the DOM tree and attach itself to the form to prevent the default values from being submitted.
+
+## Usage
+
+Usage is simple:
+
+    $(".form-text").formDefaults();
+
+This will attach the plugin to any form field with a class of 'form-text'.
+
+You can also provide some settings for the active and inactive text color (depending on whether the form fields is in focus or not):
+
+    $(".form-text").formDefaults({
+      activeColor: '#000',
+      inactiveColor: '#ccc' 
+    });
+
+## Copyright
+
+Copyright (c) 2011 Rob Schmitt. See LICENSE for details.
\ No newline at end of file

Propchange: lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/README.mkdn
------------------------------------------------------------------------------
    svn:executable = *

Added: lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/jquery.formdefaults.js
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/jquery.formdefaults.js?rev=161423&view=auto
==============================================================================
--- lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/jquery.formdefaults.js (added)
+++ lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/jquery.formdefaults.js Tue Aug  7 11:37:29 2012
@@ -0,0 +1,56 @@
+(function($) {
+  
+  $.fn.formDefaults = function(options) {
+    
+    var opts = $.extend({}, $.fn.formDefaults.defaults, options);
+    
+    return this.each(function() {
+      
+      var $this = $(this);
+      var $form = $this.parents("form");
+      
+      $this
+        .data("defaultValue", this.value)
+        .addClass("form-default-value-processed");
+      
+      if (opts.inactiveColor) {
+        $this.css("color", opts.inactiveColor);
+      }
+      
+      $this
+        .focus(function() {
+          if (this.value == $this.data("defaultValue")) {
+            this.value = '';
+            this.style.color = opts.activeColor;
+          }
+        })
+        .blur(function() {
+          if (this.value == '') {
+            this.style.color = opts.inactiveColor;
+            this.value = $this.data("defaultValue");
+          }
+        });
+      
+      if (!$form.data("defaultValueProcessed")) {
+        $form
+          .data("defaultValueProcessed", true)
+          .submit(function(e) {
+            $(this).find(".form-default-value-processed").each(function() {
+              var $el = $(this);
+              if ($el.data("defaultValue") == $el.val()) {
+                $el.val('');
+              }
+            });
+          });
+      }
+      
+    });
+    
+  };
+  
+  $.fn.formDefaults.defaults = {
+    activeColor: '#000', // Color of text when form field is active
+    inactiveColor: '' // Color of text when form field is inactive (ignored when not specified)
+  };
+
+}(jQuery));

Propchange: lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/jquery.formdefaults.js
------------------------------------------------------------------------------
    svn:executable = *

Added: lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/jquery.formdefaults.min.js
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/jquery.formdefaults.min.js?rev=161423&view=auto
==============================================================================
--- lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/jquery.formdefaults.min.js (added)
+++ lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/jquery.formdefaults.min.js Tue Aug  7 11:37:29 2012
@@ -0,0 +1,2 @@
+(function(b){b.fn.formDefaults=function(e){var c=b.extend({},b.fn.formDefaults.defaults,e);return this.each(function(){var a=b(this),d=a.parents("form");a.data("defaultValue",this.value).addClass("form-default-value-processed");c.inactiveColor&&a.css("color",c.inactiveColor);a.focus(function(){this.value==a.data("defaultValue")&&(this.value="",this.style.color=c.activeColor)}).blur(function(){""==this.value&&(this.style.color=c.inactiveColor,this.value=a.data("defaultValue"))});d.data("defaultValueProcessed")||
+d.data("defaultValueProcessed",!0).submit(function(){b(this).find(".form-default-value-processed").each(function(){var a=b(this);a.data("defaultValue")==a.val()&&a.val("")})})})};b.fn.formDefaults.defaults={activeColor:"#000",inactiveColor:""}})(jQuery);

Propchange: lnt/trunk/lnt/server/ui/static/jquery/jquery.formdefaults/jquery.formdefaults.min.js
------------------------------------------------------------------------------
    svn:executable = *





More information about the llvm-commits mailing list