X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fmehrpadin%2Fsuperfish%2Fsfsmallscreen.js;fp=vendor%2Fmehrpadin%2Fsuperfish%2Fsfsmallscreen.js;h=7a2d1981cbcff201c0e0df5ddf9e3c854a34a280;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/vendor/mehrpadin/superfish/sfsmallscreen.js b/vendor/mehrpadin/superfish/sfsmallscreen.js new file mode 100644 index 000000000..7a2d1981c --- /dev/null +++ b/vendor/mehrpadin/superfish/sfsmallscreen.js @@ -0,0 +1,333 @@ +/* + * sf-Smallscreen v1.3b - Provides small-screen compatibility for the jQuery Superfish plugin. + * + * Developer's note: + * Built as a part of the Superfish project for Drupal (http://drupal.org/project/superfish) + * Found any bug? have any cool ideas? contact me right away! http://drupal.org/user/619294/contact + * + * jQuery version: 1.3.x or higher. + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + */ + +(function($){ + $.fn.sfsmallscreen = function(options){ + options = $.extend({ + mode: 'inactive', + type: 'accordion', + breakpoint: 768, + breakpointUnit: 'px', + useragent: '', + title: '', + addSelected: false, + menuClasses: false, + hyperlinkClasses: false, + excludeClass_menu: '', + excludeClass_hyperlink: '', + includeClass_menu: '', + includeClass_hyperlink: '', + accordionButton: 1, + expandText: 'Expand', + collapseText: 'Collapse' + }, options); + + // We need to clean up the menu from anything unnecessary. + function refine(menu){ + var + refined = menu.clone(), + // Things that should not be in the small-screen menus. + rm = refined.find('span.sf-sub-indicator'), + // This is a helper class for those who need to add extra markup that shouldn't exist + // in the small-screen versions. + rh = refined.find('.sf-smallscreen-remove'), + // Mega-menus has to be removed too. + mm = refined.find('ul.sf-multicolumn'); + for (var a = 0; a < rh.length; a++){ + rh.eq(a).replaceWith(rh.eq(a).html()); + } + if (options.accordionButton == 2 || options.type == 'select'){ + for (var b = 0; b < rm.length; b++){ + rm.eq(b).remove(); + } + } + if (mm.length > 0){ + mm.removeClass('sf-multicolumn'); + var ol = refined.find('div.sf-multicolumn-column > ol'); + for (var o = 0; o < ol.length; o++){ + ol.eq(o).replaceWith(''); + } + var elements = ['div.sf-multicolumn-column','.sf-multicolumn-wrapper > ol','li.sf-multicolumn-wrapper']; + for (var i = 0; i < elements.length; i++){ + obj = refined.find(elements[i]); + for (var t = 0; t < obj.length; t++){ + obj.eq(t).replaceWith(obj.eq(t).html()); + } + } + refined.find('.sf-multicolumn-column').removeClass('sf-multicolumn-column'); + } + refined.add(refined.find('*')).css({width:''}); + return refined; + } + + // Creating ', + childUL = list.find('> ul'); + // Using the function for the sub-menu of this item. + for (var u = 0; u < childUL.length; u++){ + items += toSelect(childUL.eq(u), level + 1); + } + } + } + return items; + } + + // Create the new version, hide the original. + function convert(menu){ + var menuID = menu.attr('id'), + // Creating a refined version of the menu. + refinedMenu = refine(menu); + // Currently the plugin provides two reactions to small screens. + // Converting the menu to a element does not exist already. + if ($('#' + menuID + '-select').length == 0){ + // Creating the