aboutsummaryrefslogtreecommitdiffstats
path: root/library/jslider/js/jquery.dependClass-0.1.js
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-07-13 07:09:29 -0700
committerfriendica <info@friendica.com>2012-07-13 07:09:29 -0700
commita20a6377277a985fa596b0ea460d91b97f79b4a5 (patch)
tree1878d488143e2f0d698dc42ae924ab7be93ffb54 /library/jslider/js/jquery.dependClass-0.1.js
parent599f3d29610b2cc509ab51df0f42d154dd70278d (diff)
downloadvolse-hubzilla-a20a6377277a985fa596b0ea460d91b97f79b4a5.tar.gz
volse-hubzilla-a20a6377277a985fa596b0ea460d91b97f79b4a5.tar.bz2
volse-hubzilla-a20a6377277a985fa596b0ea460d91b97f79b4a5.zip
merge upstream, slider work, refactor ping module, language selection work
Diffstat (limited to 'library/jslider/js/jquery.dependClass-0.1.js')
-rw-r--r--library/jslider/js/jquery.dependClass-0.1.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/library/jslider/js/jquery.dependClass-0.1.js b/library/jslider/js/jquery.dependClass-0.1.js
new file mode 100644
index 000000000..2636f6673
--- /dev/null
+++ b/library/jslider/js/jquery.dependClass-0.1.js
@@ -0,0 +1,56 @@
+/**
+ * jquery.dependClass - Attach class based on first class in list of current element
+ *
+ * Written by
+ * Egor Khmelev (hmelyoff@gmail.com)
+ *
+ * Licensed under the MIT (MIT-LICENSE.txt).
+ *
+ * @author Egor Khmelev
+ * @version 0.1.0-BETA ($Id$)
+ *
+ **/
+
+(function($) {
+ $.baseClass = function(obj){
+ obj = $(obj);
+ return obj.get(0).className.match(/([^ ]+)/)[1];
+ };
+
+ $.fn.addDependClass = function(className, delimiter){
+ var options = {
+ delimiter: delimiter ? delimiter : '-'
+ }
+ return this.each(function(){
+ var baseClass = $.baseClass(this);
+ if(baseClass)
+ $(this).addClass(baseClass + options.delimiter + className);
+ });
+ };
+
+ $.fn.removeDependClass = function(className, delimiter){
+ var options = {
+ delimiter: delimiter ? delimiter : '-'
+ }
+ return this.each(function(){
+ var baseClass = $.baseClass(this);
+ if(baseClass)
+ $(this).removeClass(baseClass + options.delimiter + className);
+ });
+ };
+
+ $.fn.toggleDependClass = function(className, delimiter){
+ var options = {
+ delimiter: delimiter ? delimiter : '-'
+ }
+ return this.each(function(){
+ var baseClass = $.baseClass(this);
+ if(baseClass)
+ if($(this).is("." + baseClass + options.delimiter + className))
+ $(this).removeClass(baseClass + options.delimiter + className);
+ else
+ $(this).addClass(baseClass + options.delimiter + className);
+ });
+ };
+
+})(jQuery); \ No newline at end of file