Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Bug fixes, added position option to placement.

  • Loading branch information...
commit 1b19d1ccc80ec1140764417ada6293cf72a16219 1 parent 3f5cf4c
Matt Wiggins authored May 10, 2011
4  README.txt
@@ -11,6 +11,10 @@
11 11
 
12 12
 Legwork modals have magical powers. Check out example.html for docs and examples.
13 13
 
  14
+v0.5
  15
+ * Added 'position' option to placement
  16
+ * More IE bug fixes
  17
+
14 18
 v0.4
15 19
  * IE bug fix
16 20
  * open method bug fix
12  example.html
@@ -16,6 +16,9 @@
16 16
   <!-- Whatever you do, do it with style -->
17 17
   <link rel="stylesheet" href="http://yui.yahooapis.com/3.3.0/build/cssreset/reset-min.css">
18 18
   <link rel="stylesheet" href="lib/css/main.css" />
  19
+  
  20
+  <!-- Keep it modern -->
  21
+  <script type="text/javascript" src="lib/js/modernizr-1.7.min.js"></script>
19 22
 </head>
20 23
 
21 24
 <body>
@@ -50,7 +53,7 @@
50 53
     </p>
51 54
     
52 55
     <p>
53  
-      <b>placement:Array = [top:String, left:String, margin-top:String, margin-left:String]<br>
  56
+      <b>placement:Array = [top:String, left:String, margin-top:String, margin-left:String, position:String]<br>
54 57
       default = []</b><br><br>
55 58
       Array describing custom placement for the modal (values should be css, e.g. '20px' or '50%').
56 59
     </p>
@@ -134,7 +137,7 @@
134 137
       })<br>
135 138
       .modal({<br>
136 139
       &nbsp;&nbsp;background: ['#000', 'none', 0.85, true],<br>
137  
-      &nbsp;&nbsp;placement: ['20px', '50%', '0px', '-320px'],<br>
  140
+      &nbsp;&nbsp;placement: ['20px', '50%', '0px', '-320px', 'absolute'],<br>
138 141
       &nbsp;&nbsp;openNow: true<br>
139 142
       });
140 143
     </code>
@@ -198,7 +201,7 @@
198 201
       // then later<br>
199 202
       $('#example-8').modal({<br>
200 203
       &nbsp;&nbsp;background: ['#f00', 'none', 0.85, true],<br>
201  
-      &nbsp;&nbsp;placement: ['20px', '50%', '0px', '-360px'],<br>
  204
+      &nbsp;&nbsp;placement: ['20px', '50%', '0px', '-360px', 'fixed'],<br>
202 205
       &nbsp;&nbsp;openNow: true<br>
203 206
       });
204 207
     </code>
@@ -244,8 +247,7 @@
244 247
   
245 248
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.js"></script>
246 249
   <script type="text/javascript">window.jQuery || document.write('<script src="lib/js/jquery-1.5.2.min.js">\x3C/script>')</script>
247  
-  <script type="text/javascript" src="lib/js/jquery.legwork-modal.0.4.js"></script>
  250
+  <script type="text/javascript" src="lib/js/jquery.legwork-modal.0.5.js"></script>
248 251
   <script type="text/javascript" src="lib/js/modals.examples.js"></script>
249  
-
250 252
 </body>
251 253
 </html>
13  lib/js/jquery.legwork-modal.0.4.js → lib/js/jquery.legwork-modal.0.5.js
... ...
@@ -1,6 +1,6 @@
1 1
 /*************************************************** 
2 2
  * Copyright © 2011 Legwork. All Rights Reserved.  *
3  
- * Updated by: Matt Wiggins, 26-Apr-2011           *
  3
+ * Updated by: Matt Wiggins, 10-May-2011           *
4 4
  *                                                 *
5 5
  * Legwork modals have magical powers.             *
6 6
  ***************************************************
@@ -9,7 +9,7 @@
9 9
 
10 10
 // TODO: wrapper so that something like $('<h1>Yeah girl!</h1><p>Oh, oops.</p>').modal() doesn't break?
11 11
 
12  
-// v0.3
  12
+// v0.5
13 13
 ;(function($) {
14 14
   
15 15
   // methods
@@ -66,7 +66,6 @@
66 66
         
67 67
         // position and hide
68 68
         $this.css({
69  
-          'position':'fixed',
70 69
           'display':'none',
71 70
           'z-index':'49500'
72 71
         });
@@ -82,6 +81,7 @@
82 81
             
83 82
             // default placement
84 83
             $this.css({
  84
+              'position':'fixed',
85 85
               'top':'50%',
86 86
               'left':'50%',
87 87
               'margin-top':-Math.round($this.outerHeight() / 2) + 'px',
@@ -94,7 +94,8 @@
94 94
               'top':data.settings.placement[0],
95 95
               'left':data.settings.placement[1],
96 96
               'margin-top':data.settings.placement[2],
97  
-              'margin-left':data.settings.placement[3]
  97
+              'margin-left':data.settings.placement[3],
  98
+              'position':data.settings.placement[4]
98 99
             });
99 100
           }
100 101
           
@@ -115,11 +116,12 @@
115 116
             data = $this.data('modal');
116 117
         
117 118
         // remove styles added by modal
  119
+        $this.hide();
118 120
         $this.attr('style', data.style);
119 121
         
120 122
         // transition out, clean up
121 123
         data.bg.animate({'opacity':'0'}, 500, 'linear', function() {
122  
-          data.bg.remove();
  124
+          data.bg.unbind('click').remove();
123 125
           
124 126
           if(typeof callback === 'function') callback.call($this);
125 127
           if(typeof data.settings.onClosed === 'function') data.settings.onClosed.call($this);
@@ -137,7 +139,6 @@
137 139
             data = $this.data('modal'),
138 140
             rip = data.rip;
139 141
 
140  
-        $this.removeData('modal');
141 142
         if(rip) $this.remove();
142 143
       });
143 144
     }
4  lib/js/modals.examples.js
@@ -62,7 +62,7 @@ var Modals = Modals || {};
62 62
 					case '#example-3':
63 63
 						$('<div id="example-3"></div>').css({'width':'640px', 'height':'480px', 'background-color':'#fff'}).modal({
64 64
     					background: ['#000', 'none', 0.85, true],
65  
-    					placement: ['20px', '50%', '0px', '-320px'],
  65
+    					placement: ['20px', '50%', '0px', '-320px', 'absolute'],
66 66
     					openNow: true
67 67
     				});
68 68
 						break;
@@ -105,7 +105,7 @@ var Modals = Modals || {};
105 105
           case '#example-8-2':
106 106
 						$('#example-8').modal({
107 107
     					background: ['#f00', 'none', 0.85, true],
108  
-    					placement: ['20px', '50%', '0px', '-360px'],
  108
+    					placement: ['20px', '50%', '0px', '-360px', 'fixed'],
109 109
     					openNow: true
110 110
     				});
111 111
 						break;
2  lib/js/modernizr-1.7.min.js
... ...
@@ -0,0 +1,2 @@
  1
+// Modernizr v1.7  www.modernizr.com
  2
+window.Modernizr=function(a,b,c){function G(){e.input=function(a){for(var b=0,c=a.length;b<c;b++)t[a[b]]=!!(a[b]in l);return t}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")),e.inputtypes=function(a){for(var d=0,e,f,h,i=a.length;d<i;d++)l.setAttribute("type",f=a[d]),e=l.type!=="text",e&&(l.value=m,l.style.cssText="position:absolute;visibility:hidden;",/^range$/.test(f)&&l.style.WebkitAppearance!==c?(g.appendChild(l),h=b.defaultView,e=h.getComputedStyle&&h.getComputedStyle(l,null).WebkitAppearance!=="textfield"&&l.offsetHeight!==0,g.removeChild(l)):/^(search|tel)$/.test(f)||(/^(url|email)$/.test(f)?e=l.checkValidity&&l.checkValidity()===!1:/^color$/.test(f)?(g.appendChild(l),g.offsetWidth,e=l.value!=m,g.removeChild(l)):e=l.value!=m)),s[a[d]]=!!e;return s}("search tel url email datetime date month week time datetime-local number range color".split(" "))}function F(a,b){var c=a.charAt(0).toUpperCase()+a.substr(1),d=(a+" "+p.join(c+" ")+c).split(" ");return!!E(d,b)}function E(a,b){for(var d in a)if(k[a[d]]!==c&&(!b||b(a[d],j)))return!0}function D(a,b){return(""+a).indexOf(b)!==-1}function C(a,b){return typeof a===b}function B(a,b){return A(o.join(a+";")+(b||""))}function A(a){k.cssText=a}var d="1.7",e={},f=!0,g=b.documentElement,h=b.head||b.getElementsByTagName("head")[0],i="modernizr",j=b.createElement(i),k=j.style,l=b.createElement("input"),m=":)",n=Object.prototype.toString,o=" -webkit- -moz- -o- -ms- -khtml- ".split(" "),p="Webkit Moz O ms Khtml".split(" "),q={svg:"http://www.w3.org/2000/svg"},r={},s={},t={},u=[],v,w=function(a){var c=b.createElement("style"),d=b.createElement("div"),e;c.textContent=a+"{#modernizr{height:3px}}",h.appendChild(c),d.id="modernizr",g.appendChild(d),e=d.offsetHeight===3,c.parentNode.removeChild(c),d.parentNode.removeChild(d);return!!e},x=function(){function d(d,e){e=e||b.createElement(a[d]||"div");var f=(d="on"+d)in e;f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=C(e[d],"function"),C(e[d],c)||(e[d]=c),e.removeAttribute(d))),e=null;return f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),y=({}).hasOwnProperty,z;C(y,c)||C(y.call,c)?z=function(a,b){return b in a&&C(a.constructor.prototype[b],c)}:z=function(a,b){return y.call(a,b)},r.flexbox=function(){function c(a,b,c,d){a.style.cssText=o.join(b+":"+c+";")+(d||"")}function a(a,b,c,d){b+=":",a.style.cssText=(b+o.join(c+";"+b)).slice(0,-b.length)+(d||"")}var d=b.createElement("div"),e=b.createElement("div");a(d,"display","box","width:42px;padding:0;"),c(e,"box-flex","1","width:10px;"),d.appendChild(e),g.appendChild(d);var f=e.offsetWidth===42;d.removeChild(e),g.removeChild(d);return f},r.canvas=function(){var a=b.createElement("canvas");return a.getContext&&a.getContext("2d")},r.canvastext=function(){return e.canvas&&C(b.createElement("canvas").getContext("2d").fillText,"function")},r.webgl=function(){return!!a.WebGLRenderingContext},r.touch=function(){return"ontouchstart"in a||w("@media ("+o.join("touch-enabled),(")+"modernizr)")},r.geolocation=function(){return!!navigator.geolocation},r.postmessage=function(){return!!a.postMessage},r.websqldatabase=function(){var b=!!a.openDatabase;return b},r.indexedDB=function(){for(var b=-1,c=p.length;++b<c;){var d=p[b].toLowerCase();if(a[d+"_indexedDB"]||a[d+"IndexedDB"])return!0}return!1},r.hashchange=function(){return x("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},r.history=function(){return !!(a.history&&history.pushState)},r.draganddrop=function(){return x("dragstart")&&x("drop")},r.websockets=function(){return"WebSocket"in a},r.rgba=function(){A("background-color:rgba(150,255,150,.5)");return D(k.backgroundColor,"rgba")},r.hsla=function(){A("background-color:hsla(120,40%,100%,.5)");return D(k.backgroundColor,"rgba")||D(k.backgroundColor,"hsla")},r.multiplebgs=function(){A("background:url(//:),url(//:),red url(//:)");return(new RegExp("(url\\s*\\(.*?){3}")).test(k.background)},r.backgroundsize=function(){return F("backgroundSize")},r.borderimage=function(){return F("borderImage")},r.borderradius=function(){return F("borderRadius","",function(a){return D(a,"orderRadius")})},r.boxshadow=function(){return F("boxShadow")},r.textshadow=function(){return b.createElement("div").style.textShadow===""},r.opacity=function(){B("opacity:.55");return/^0.55$/.test(k.opacity)},r.cssanimations=function(){return F("animationName")},r.csscolumns=function(){return F("columnCount")},r.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";A((a+o.join(b+a)+o.join(c+a)).slice(0,-a.length));return D(k.backgroundImage,"gradient")},r.cssreflections=function(){return F("boxReflect")},r.csstransforms=function(){return!!E(["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"])},r.csstransforms3d=function(){var a=!!E(["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"]);a&&"webkitPerspective"in g.style&&(a=w("@media ("+o.join("transform-3d),(")+"modernizr)"));return a},r.csstransitions=function(){return F("transitionProperty")},r.fontface=function(){var a,c,d=h||g,e=b.createElement("style"),f=b.implementation||{hasFeature:function(){return!1}};e.type="text/css",d.insertBefore(e,d.firstChild),a=e.sheet||e.styleSheet;var i=f.hasFeature("CSS2","")?function(b){if(!a||!b)return!1;var c=!1;try{a.insertRule(b,0),c=/src/i.test(a.cssRules[0].cssText),a.deleteRule(a.cssRules.length-1)}catch(d){}return c}:function(b){if(!a||!b)return!1;a.cssText=b;return a.cssText.length!==0&&/src/i.test(a.cssText)&&a.cssText.replace(/\r+|\n+/g,"").indexOf(b.split(" ")[0])===0};c=i('@font-face { font-family: "font"; src: url(data:,); }'),d.removeChild(e);return c},r.video=function(){var a=b.createElement("video"),c=!!a.canPlayType;if(c){c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"');var d='video/mp4; codecs="avc1.42E01E';c.h264=a.canPlayType(d+'"')||a.canPlayType(d+', mp4a.40.2"'),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"')}return c},r.audio=function(){var a=b.createElement("audio"),c=!!a.canPlayType;c&&(c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"'),c.mp3=a.canPlayType("audio/mpeg;"),c.wav=a.canPlayType('audio/wav; codecs="1"'),c.m4a=a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;"));return c},r.localstorage=function(){try{return!!localStorage.getItem}catch(a){return!1}},r.sessionstorage=function(){try{return!!sessionStorage.getItem}catch(a){return!1}},r.webWorkers=function(){return!!a.Worker},r.applicationcache=function(){return!!a.applicationCache},r.svg=function(){return!!b.createElementNS&&!!b.createElementNS(q.svg,"svg").createSVGRect},r.inlinesvg=function(){var a=b.createElement("div");a.innerHTML="<svg/>";return(a.firstChild&&a.firstChild.namespaceURI)==q.svg},r.smil=function(){return!!b.createElementNS&&/SVG/.test(n.call(b.createElementNS(q.svg,"animate")))},r.svgclippaths=function(){return!!b.createElementNS&&/SVG/.test(n.call(b.createElementNS(q.svg,"clipPath")))};for(var H in r)z(r,H)&&(v=H.toLowerCase(),e[v]=r[H](),u.push((e[v]?"":"no-")+v));e.input||G(),e.crosswindowmessaging=e.postmessage,e.historymanagement=e.history,e.addTest=function(a,b){a=a.toLowerCase();if(!e[a]){b=!!b(),g.className+=" "+(b?"":"no-")+a,e[a]=b;return e}},A(""),j=l=null,f&&a.attachEvent&&function(){var a=b.createElement("div");a.innerHTML="<elem></elem>";return a.childNodes.length!==1}()&&function(a,b){function p(a,b){var c=-1,d=a.length,e,f=[];while(++c<d)e=a[c],(b=e.media||b)!="screen"&&f.push(p(e.imports,b),e.cssText);return f.join("")}function o(a){var b=-1;while(++b<e)a.createElement(d[b])}var c="abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",d=c.split("|"),e=d.length,f=new RegExp("(^|\\s)("+c+")","gi"),g=new RegExp("<(/*)("+c+")","gi"),h=new RegExp("(^|[^\\n]*?\\s)("+c+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),i=b.createDocumentFragment(),j=b.documentElement,k=j.firstChild,l=b.createElement("body"),m=b.createElement("style"),n;o(b),o(i),k.insertBefore(m,k.firstChild),m.media="print",a.attachEvent("onbeforeprint",function(){var a=-1,c=p(b.styleSheets,"all"),k=[],o;n=n||b.body;while((o=h.exec(c))!=null)k.push((o[1]+o[2]+o[3]).replace(f,"$1.iepp_$2")+o[4]);m.styleSheet.cssText=k.join("\n");while(++a<e){var q=b.getElementsByTagName(d[a]),r=q.length,s=-1;while(++s<r)q[s].className.indexOf("iepp_")<0&&(q[s].className+=" iepp_"+d[a])}i.appendChild(n),j.appendChild(l),l.className=n.className,l.innerHTML=n.innerHTML.replace(g,"<$1font")}),a.attachEvent("onafterprint",function(){l.innerHTML="",j.removeChild(l),j.appendChild(n),m.styleSheet.cssText=""})}(a,b),e._enableHTML5=f,e._version=d,g.className=g.className.replace(/\bno-js\b/,"")+" js "+u.join(" ");return e}(this,this.document)

0 notes on commit 1b19d1c

Please sign in to comment.
Something went wrong with that request. Please try again.