/ themecrosser.js
themecrosser.js
  1  (function(window) {
  2  	var old$=window.jQuery||{};
  3  	(function(new$) {
  4  		if (window.$==window.jQuery) {
  5  			window.$=new$;
  6  		}
  7  		window.jQuery=new$;
  8  	})((function($) {
  9  		$.themecrosser={};
 10  		$.themecrosser.modes=["jQuery UI to Bootstrap","jQuery UI icons to FontAwesome"];
 11  		$.themecrosser.classMap={
 12  			"Bootstrap to jQuery UI":{
 13  				//btn
 14  					"btn":"ui-button",
 15  					"btn&btn-primary":"ui-button .ui-priority-primary",
 16  					"btn&btn-secondary":"ui-button .ui-priority-secondary",
 17  					"btn&btn-warning":"ui-button .ui-state-highlight",
 18  					"btn&btn-danger":"ui-button .ui-state-error",
 19  				//Widget-card
 20  					"card":"ui-widget",
 21  					"card-header":"ui-widget-header",
 22  					"card-block":"ui-widget-content",
 23  				//sr
 24  					"sr-only":"ui-helper-hidden-accessible",
 25  				//corners
 26  					"rounded":"ui-corner-all",
 27  					"rounded-top":"ui-corner-top",
 28  					"rounded-bottom":"ui-corner-bottom",
 29  					"rounded-left":"ui-corner-left",
 30  					"rounded-right":"ui-corner-right",
 31  			},
 32  			"jQuery UI to Bootstrap":{
 33  				//accordion
 34  					"ui-accordion-header":"card-header",
 35  					"ui-accordion-header-collapsed":"rounded",
 36  					"ui-accordion-content":"card-block",
 37  				//btn
 38  					"ui-button":"btn btn-primary!card",
 39  					"ui-button&.ui-state-highlight":"btn btn-warning!btn-primary",
 40  					"ui-button&.ui-state-error":"btn btn-danger!btn-primary",
 41  					//"ui-button&.ui-priority-primary":"btn btn-primary",
 42  					"ui-button&.ui-priority-secondary":"btn btn-secondary!btn-primary",
 43  				//btn-group
 44  					"ui-controlgroup":"btn-group",
 45  				//dialog
 46  					"ui-dialog":"modal modal-dialog modal-content ml-0 mt-0",
 47  					"ui-dialog-titlebar":"modal-header h5!card-header",
 48  					"ui-dialog-title":"modal-title",
 49  					//"ui-dialog-titlebar-close":"close!ui-button btn btn-primary card ui-corner-all rounded",
 50  					"ui-dialog-content":"modal-body",
 51  					"ui-dialog-buttonset":"modal-footer",
 52  					
 53  				//menu
 54  				
 55  					"ui-menu":"list-unstyled dropdown-menu position-static",
 56  					"ui-menu&ui-front":"list-unstyled position-absolute ml-0!position-static",
 57  					
 58  					"ui-menu-item-wrapper":"dropdown-item",
 59  					"ui-menu-item":"mh-25",
 60  					"ui-menu-divider":"dropdown-divider",
 61  					
 62  				//Widget-card
 63  					"ui-widget":"card",
 64  					"ui-widget-header":"card-header",
 65  					"ui-widget-content":"card-block",
 66  				//sr
 67  					"ui-helper-hidden-accessible":"sr-only",
 68  				//corners
 69  					"ui-corner-all":"rounded",
 70  					"ui-corner-top":"rounded-top",
 71  					"ui-corner-bottom":"rounded-bottom",
 72  					"ui-corner-left":"rounded-left",
 73  					"ui-corner-right":"rounded-right",
 74  				//states
 75  					"ui-state-active":"active",
 76  					
 77  					
 78  			},
 79  			"jQuery UI icons to FontAwesome":{
 80  				//"ui-icon":"fa",
 81  				"ui-icon-triangle-1-s":"fa fa-caret-down fa-xs",	
 82  				"ui-icon-triangle-1-e":"fa fa-caret-right fa-xs",
 83  				"ui-icon-triangle-1-w":"fa fa-caret-left fa-xs",
 84  				"ui-icon-triangle-1-n":"fa fa-caret-up fa-xs",
 85  				"ui-icon-caret-1-e":"fas fa-angle-right",
 86  				//"ui-corner-all&ui-icon-blank":"far fa-circle",
 87  				//"ui-corner-all&ui-icon-blank&ui-state-active":"far fa-dot-circle",
 88  			},
 89  		};//"class-name&and-others or-others":"new classes!remove"
 90  		function mod(classes) {
 91  				var toBeRemoved=[],//array of classes to be removed
 92  				stringifiedClasses=classes.toString();//the suggested classes to be changed about this element
 93  			for (var themeMode=0; themeMode<$.themecrosser.modes.length; themeMode++) {
 94  				for (var fullSelector in $.themecrosser.classMap[$.themecrosser.modes[themeMode]]) {
 95  					var spaceQuery=fullSelector.split(/[\,\s]/g);
 96  					for (var spaceSelector=0; spaceSelector<spaceQuery.length; spaceSelector++) {
 97  						var andQuery=spaceQuery[spaceSelector].split(/&/g),
 98  							total=0;
 99  						for (var andSelector=0; andSelector<andQuery.length; andSelector++) {
100  							var input=stringifiedClasses.split(/[\,\s]/g);
101  							for (var inputItorator=0; inputItorator<input.length; inputItorator++) {
102  								if (input[inputItorator]===andQuery[andSelector]) {
103  									total++;
104  								}
105  							}
106  						}
107  						if (total===andQuery.length) {
108  							var thing=$.themecrosser.classMap[$.themecrosser.modes[themeMode]][fullSelector].split("!");
109  							stringifiedClasses+=" "+thing[0];
110  							if (thing.length>1) {
111  								toBeRemoved.push.apply(toBeRemoved,thing[1].split(/[\,\s]/g));
112  							}
113  						}
114  					}
115  				}
116  			}
117  			for (var removeItorator=0; removeItorator<toBeRemoved.length; removeItorator++) {
118  				stringifiedClasses=stringifiedClasses.replace(new RegExp(toBeRemoved[removeItorator], "g"),"");//"g" is the global flag for dynamic regexps
119  			}
120  			return stringifiedClasses;
121  		}
122  		$.themecrosser.classFilter=mod;
123  		$.fn.extend({
124  			/*
125  			toggleClass:( function( orig ) {
126  				return function(value,$switch,duration,easing,complete) {
127  					orig.call( this, mod(value),$switch,duration,easing,complete);
128  				};
129  			})( $.fn.toggleClass ),
130  			//*/
131  			addClass: (function (orig) {
132  				return function(value,duration,easing,complete) {
133  				orig.call( this, mod(value),duration,easing,complete);
134  				};
135  			})( $.fn.addClass ),
136  			removeClass: (function (orig) {
137  
138  				return function(value,duration,easing,complete) {
139  				orig.call( this, mod(value),duration,easing,complete);
140  				};
141  			})( $.fn.removeClass ),
142  			/*
143  			switchClass:( function( orig ) {
144  				return function(value1,value2,duration,easing,complete) {
145  					orig.call( this, mod(value1),mod(value2),duration,easing,complete);
146  				};
147  			})( $.fn.switchClass ),
148  			//*/
149  		});
150  		return $;
151  	})(window.jQuery));
152  })(this);