Created
July 26, 2013 01:59
-
-
Save Shelob9/6085459 to your computer and use it in GitHub Desktop.
JQuery sidr plugin by Alberto Varela with a fix for compaatiblity with jQuery 1.8+ by MaddinXx (https://github.com/MaddinXx) all nice and minimized for you. (c) 2013 Alberto Varela. MIT License.
https://github.com/artberri/sidr
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
/* | |
* Sidr | |
* https://github.com/artberri/sidr | |
* | |
* Copyright (c) 2013 Alberto Varela | |
* Licensed under the MIT license. | |
* | |
* Using fixed version (curtesy of MaddinXx) compatible with jQuery 1.8+ found at: https://raw.github.com/MaddinXx/sidr/master/src/jquery.sidr.js | |
* tested with jQuery 1.10.2 | |
*/ | |
(function(e){var t=false,n=false;var r={isUrl:function(e){var t=new RegExp("^(https?:\\/\\/)?"+"((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|"+"((\\d{1,3}\\.){3}\\d{1,3}))"+"(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*"+"(\\?[;&a-z\\d%_.~+=-]*)?"+"(\\#[-a-z\\d_]*)?$","i");if(!t.test(e)){return false}else{return true}},loadContent:function(e,t){e.html(t)},addPrefix:function(e){var t=e.attr("id"),n=e.attr("class");if(typeof t==="string"&&""!==t){e.attr("id",t.replace(/([A-Za-z0-9_.\-]+)/g,"sidr-id-$1"))}if(typeof n==="string"&&""!==n&&"sidr-inner"!==n){e.attr("class",n.replace(/([A-Za-z0-9_.\-]+)/g,"sidr-class-$1"))}e.removeAttr("style")},execute:function(r,s,o){if(typeof s==="function"){o=s;s="sidr"}else if(!s){s="sidr"}var u=e("#"+s),a=e(u.data("body")),f=e("html"),l=u.outerWidth(true),c=u.data("speed"),h=u.data("side"),p,d,v;if("open"===r||"toogle"===r&&!u.is(":visible")){if(u.is(":visible")||t){return}if(n!==false){i.close(n,function(){i.open(s)});return}t=true;if(h==="left"){p={left:l+"px"};d={left:"0px"}}else{p={right:l+"px"};d={right:"0px"}}v=f.scrollTop();f.css("overflow-x","hidden").scrollTop(v);a.css({width:a.width(),position:"absolute"}).animate(p,c);u.css("display","block").animate(d,c,function(){t=false;n=s;if(typeof o==="function"){o(s)}})}else{if(!u.is(":visible")||t){return}t=true;if(h==="left"){p={left:0};d={left:"-"+l+"px"}}else{p={right:0};d={right:"-"+l+"px"}}v=f.scrollTop();f.removeAttr("style").scrollTop(v);a.animate(p,c);u.animate(d,c,function(){u.removeAttr("style").hide();a.removeAttr("style");e("html").removeAttr("style");t=false;n=false;if(typeof o==="function"){o(s)}})}}};var i={open:function(e,t){r.execute("open",e,t)},close:function(e,t){r.execute("close",e,t)},toogle:function(e,t){r.execute("toogle",e,t)}};e.sidr=function(t){if(i[t]){return i[t].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof t==="function"||typeof t==="string"||!t){return i.toogle.apply(this,arguments)}else{e.error("Method "+t+" does not exist on jQuery.sidr")}};e.fn.sidr=function(t){var n=e.extend({name:"sidr",speed:200,side:"left",source:null,renaming:true,body:"body"},t);var s=n.name,o=e("#"+s);if(o.length===0){o=e("<div />").attr("id",s).appendTo(e("body"))}o.addClass("sidr").addClass(n.side).data({speed:n.speed,side:n.side,body:n.body});if(typeof n.source==="function"){var u=n.source(s);r.loadContent(o,u)}else if(typeof n.source==="string"&&r.isUrl(n.source)){e.get(n.source,function(e){r.loadContent(o,e)})}else if(typeof n.source==="string"){var a="",f=n.source.split(",");e.each(f,function(t,n){a+='<div class="sidr-inner">'+e(n).html()+"</div>"});if(n.renaming){var l=e("<div />").html(a);l.find("*").each(function(t,n){var i=e(n);r.addPrefix(i)});a=l.html()}r.loadContent(o,a)}else if(n.source!==null){e.error("Invalid Sidr Source")}return this.each(function(){var t=e(this),n=t.data("sidr");if(!n){t.data("sidr",s);t.click(function(e){e.preventDefault();i.toogle(s)})}})}})(jQuery) |
You can get all the code here:
https://github.com/artberri/sidr
Thanks @artberri for the response and the awesome sidr plugin
This version has resolution for artberri/sidr#53
Where can I find the unminified version of this file in the repo?
I couldn't find it in the dist folder, using which, the issue still persists
Just unminify it yourself, search for "js beautify" on google and you find lot of services doing it
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you please point to the unminified version of this script?