-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from timmit-nl/AMD-support
AMD support and updated bower.json en added package.json
- Loading branch information
Showing
3 changed files
with
51 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "metisMenuAutoOpen", | ||
"version": "0.0.8", | ||
"version": "1.0.0", | ||
"authors": [ | ||
"Tim Schoondergang <[email protected]>" | ||
], | ||
|
@@ -25,6 +25,6 @@ | |
], | ||
"dependencies": { | ||
"jquery": ">2.1.1", | ||
"metisMenu": ">1.0.0 <1.2.0" | ||
"metisMenu": ">1.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,55 @@ | ||
;(function ($, window, document, undefined) { | ||
|
||
; | ||
(function(global, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define(['jquery'], factory); | ||
} else if (typeof exports !== "undefined") { | ||
factory(require('jquery')); | ||
} else { | ||
var mod = { | ||
exports: {} | ||
}; | ||
factory(global.jquery); | ||
global.metisMenuAutoOpen = mod.exports; | ||
} | ||
})(this, function(_jquery) { | ||
var pluginName = "metisMenuAutoOpen", | ||
defaults = { | ||
classToAdd: 'current-page-item', | ||
currentLocation: window.location | ||
}; | ||
|
||
function Plugin(element, options) { | ||
this.element = element; | ||
this.settings = $.extend({}, defaults, options); | ||
this.settings = _jquery.extend({}, defaults, options); | ||
this._defaults = defaults; | ||
this._name = pluginName; | ||
this.init(); | ||
} | ||
|
||
Plugin.prototype = { | ||
init: function () { | ||
|
||
var $this_element = $(this.element), | ||
init: function() { | ||
var $this_element = _jquery(this.element), | ||
$classToAdd = this.settings.classToAdd, | ||
$currentLocation = this.settings.currentLocation; | ||
|
||
|
||
if (!window.location.origin){ | ||
window.location.origin = window.location.protocol+"//"+window.location.host; | ||
} | ||
$currentLocation = window.location.origin + $currentLocation; | ||
|
||
|
||
$this_element.find("li .nav-second-level li a").each(function(){ | ||
//var classname = $(this).attr('class'); | ||
var url = $(this).prop('href'); | ||
|
||
if($currentLocation == url){ | ||
$(this).parentsUntil('ul').addClass($classToAdd); | ||
$(this).parentsUntil('.nav-second-level').parent().addClass("in"); | ||
$(this).parentsUntil('#side-menu','li:not(.'+$classToAdd+')').addClass("active"); | ||
return false; | ||
} | ||
|
||
|
||
//var width = images.width(); | ||
//var imgLength = images.length; | ||
//$(this).find(".scrolling").width( width * imgLength * 1.2 ); | ||
}); | ||
|
||
$currentLocation = this.settings.currentLocation; | ||
if (!window.location.origin) { | ||
window.location.origin = window.location.protocol + "//" + window.location.host; | ||
} | ||
$currentLocation = window.location.origin + $currentLocation; | ||
$this_element.find("li .nav-second-level li a").each(function() { | ||
var url = _jquery(this).prop('href'); | ||
if ($currentLocation == url) { | ||
_jquery(this).parentsUntil('ul').addClass($classToAdd); | ||
_jquery(this).parentsUntil('.nav-second-level').parent().addClass("in"); | ||
_jquery(this).parentsUntil('#side-menu', 'li:not(.' + $classToAdd + ')').addClass("active"); | ||
return false; | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
$.fn[ pluginName ] = function (options) { | ||
return this.each(function () { | ||
if (!$.data(this, "plugin_" + pluginName)) { | ||
$.data(this, "plugin_" + pluginName, new Plugin(this, options)); | ||
_jquery.fn[pluginName] = function(options) { | ||
return this.each(function() { | ||
if (!_jquery.data(this, "plugin_" + pluginName)) { | ||
_jquery.data(this, "plugin_" + pluginName, new Plugin(this, options)); | ||
} | ||
}); | ||
}; | ||
|
||
})(jQuery, window, document); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "metisMenuAutoOpen", | ||
"version": "1.0.0", | ||
"description": "metisMenu with auto open on url", | ||
"main": "jquery.metisMenuAutoOpen.js", | ||
"repository": { | ||
"url": "https://github.com/timmit-nl/metisMenuAutoOpen", | ||
"type": "git" | ||
}, | ||
"author": "Tim Schoondergang <[email protected]>", | ||
"license": "MIT" | ||
} |