summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vendor/jquery.condom.js
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
commitb80bd744ad873f6fc43018bc4bfb90677de167bd (patch)
tree072c4b0e33d442528555b82c415f5e7a1712b2b0 /app/assets/javascripts/vendor/jquery.condom.js
parent3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff)
Start of GS5.
Diffstat (limited to 'app/assets/javascripts/vendor/jquery.condom.js')
-rw-r--r--app/assets/javascripts/vendor/jquery.condom.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/app/assets/javascripts/vendor/jquery.condom.js b/app/assets/javascripts/vendor/jquery.condom.js
new file mode 100644
index 0000000..5d24a7e
--- /dev/null
+++ b/app/assets/javascripts/vendor/jquery.condom.js
@@ -0,0 +1,52 @@
+/*
+ * jQuery Condom (Use namespaces to protect your global integrity.)
+ * Version 0.0.3
+ *
+ * Copyright (c) 2011 Mario "Kuroir" Ricalde (http://kuroir.com)
+ * & Micha Niskin (micha@thinkminimo.com)
+ * Licensed jointly under the GPL and MIT licenses,
+ * choose which one suits your project best!
+ */
+(function($) {
+ var methods = {};
+ $.ns = function(ns) {
+ // Define namespace if it doesn't exist.
+ methods[ns] = methods[ns] || {};
+
+ // Get reference to a namespaced jQ object
+ function nsfun(selector, context) {
+ return $(selector, context).ns(ns);
+ }
+
+ // Allows you to add methods ala jQuery.fn (useful to namespace premade plugins)
+ nsfun.fn = methods[ns];
+
+ // Add a method.
+ nsfun.add = function(fname, fn) {
+ var new_funcs = typeof fname == "object" ? fname : {};
+ // One method.
+ if (new_funcs !== fname)
+ new_funcs[fname] = fn;
+ // Group of methods.
+ $.each(new_funcs, function(fname, fn) {
+ methods[ns][fname] = function() {
+ fn.apply(this, arguments);
+ return this;
+ };
+ });
+ return this;
+ };
+
+ // Get methods.
+ nsfun.methods = function() {
+ return $.extend({}, methods[ns]);
+ };
+
+ return nsfun;
+ };
+ // The only function that touches $.fn
+ $.fn.ns = function(ns) {
+ if (methods[ns]) $.extend(this, methods[ns]);
+ return this;
+ };
+})(jQuery);