Archived
moved frontbox, but replaced it with simplemodal
This commit is contained in:
1 parent
d9c5f8da21
commit
8ab5ce5170
12 files changed
+2259
-4
No files matched your search
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
/*!
|
||||
* jQuery JavaScript Library v1.6.2
|
||||
* http://jquery.com/
|
||||
*
|
||||
* Copyright 2011, John Resig
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* Includes Sizzle.js
|
||||
* http://sizzlejs.com/
|
||||
* Copyright 2011, The Dojo Foundation
|
||||
* Released under the MIT, BSD, and GPL Licenses.
|
||||
*
|
||||
* Date: Thu Jun 30 14:16:56 2011 -0400
|
||||
*/
|
||||
(function(a,b){function cv(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cs(a){if(!cg[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ch||(ch=c.createElement("iframe"),ch.frameBorder=ch.width=ch.height=0),b.appendChild(ch);if(!ci||!ch.createElement)ci=(ch.contentWindow||ch.contentDocument).document,ci.write((c.compatMode==="CSS1Compat"?"<!doctype html>":"")+"<html><body>"),ci.close();d=ci.createElement(a),ci.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ch)}cg[a]=e}return cg[a]}function cr(a,b){var c={};f.each(cm.concat.apply([],cm.slice(0,b)),function(){c[this]=a});return c}function cq(){cn=b}function cp(){setTimeout(cq,0);return cn=f.now()}function cf(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ce(){try{return new a.XMLHttpRequest}catch(b){}}function b$(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function bZ(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function bY(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bC.test(a)?d(a,e):bY(a+"["+(typeof e=="object"||f.isArray(e)?b:"")+"]",e,c,d)});else if(!c&&b!=null&&typeof b=="object")for(var e in b)bY(a+"["+e+"]",b[e],c,d);else d(a,b)}function bX(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bR,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=bX(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=bX(a,c,d,e,"*",g));return l}function bW(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bN),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bA(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=b==="width"?bv:bw;if(d>0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bx(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function bm(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(be,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bl(a){f.nodeName(a,"input")?bk(a):"getElementsByTagName"in a&&f.grep(a.getElementsByTagName("input"),bk)}function bk(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bj(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bi(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bh(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(var i=0,j=g[h].length;i<j;i++)f.event.add(b,h+(g[h][i].namespace?".":"")+g[h][i].namespace,g[h][i],g[h][i].data)}}}}function bg(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function W(a,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return f.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=f.grep(a,function(a){return a.nodeType===1});if(R.test(b))return f.filter(b,d,!c);b=f.filter(b,d)}return f.grep(a,function(a,d){return f.inArray(a,b)>=0===c})}function V(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function N(a,b){return(a&&a!=="*"?a+"."Line truncated
|
||||
shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d!=null?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h<i;h++){var j=d[h];if(e||c.namespace_re.test(j.namespace)){c.handler=j.handler,c.data=j.data,c.handleObj=j;var k=j.handler.apply(this,g);k!==b&&(c.result=k,k===!1&&(c.preventDefault(),c.stopPropagation()));if(c.isImmediatePropagationStopped())break}}return c.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(a){if(a[f.expando])return a;var d=a;a=f.Event(d);for(var e=this.props.length,g;e;)g=this.props[--e],a[g]=d[g];a.target||(a.target=a.srcElement||c),a.target.nodeType===3&&(a.target=a.target.parentNode),!a.relatedTarget&&a.fromElement&&(a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement);if(a.pageX==null&&a.clientX!=null){var h=a.target.ownerDocument||c,i=h.documentElement,j=h.body;a.pageX=a.clientX+(i&&i.scrollLeft||j&&j.scrollLeft||0)-(i&&i.clientLeft||j&&j.clientLeft||0),a.pageY=a.clientY+(i&&i.scrollTop||j&&j.scrollTop||0)-(i&&i.clientTop||j&&j.clientTop||0)}a.which==null&&(a.charCode!=null||a.keyCode!=null)&&(a.which=a.charCode!=null?a.charCode:a.keyCode),!a.metaKey&&a.ctrlKey&&(a.metaKey=a.ctrlKey),!a.which&&a.button!==b&&(a.which=a.button&1?1:a.button&2?3:a.button&4?2:0);return a},guid:1e8,proxy:f.proxy,special:{ready:{setup:f.bindReady,teardown:f.noop},live:{add:function(a){f.event.add(this,N(a.origType,a.selector),f.extend({},a,{handler:M,guid:a.handler.guid}))},remove:function(a){f.event.remove(this,N(a.origType,a.selector),a)}},beforeunload:{setup:function(a,b,c){f.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}}},f.removeEvent=c.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)},f.Event=function(a,b){if(!this.preventDefault)return new f.Event(a,b);a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?E:D):this.type=a,b&&f.extend(this,b),this.timeStamp=f.now(),this[f.expando]=!0},f.Event.prototype={preventDefault:function(){this.isDefaultPrevented=E;var a=this.originalEvent;!a||(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=E;var a=this.originalEvent;!a||(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=E,this.stopPropagation()},isDefaultPrevented:D,isPropagationStopped:D,isImmediatePropagationStopped:D};var F=function(a){var b=a.relatedTarget,c=!1,d=a.type;a.type=a.data,b!==this&&(b&&(c=f.contains(this,b)),c||(f.event.handle.apply(this,arguments),a.type=d))},G=function(a){a.type=a.data,f.event.handle.apply(this,arguments)};f.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){f.event.special[a]={setup:function(c){f.event.add(this,b,c&&c.selector?G:F,a)},teardown:function(a){f.event.remove(this,b,a&&a.selector?G:F)}}}),f.support.submitBubbles||(f.event.special.submit={setup:function(a,b){if(!f.nodeName(this,"form"))f.event.add(this,"click.specialSubmit",function(a){var b=a.target,c=b.type;(c==="submit"||c==="image")&&f(b).closest("form").length&&K("submit",this,arguments)}),f.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,c=b.type;(c==="text"||c==="password")&&f(b).closest("form").length&&a.keyCode===13&&K("submit",this,arguLine truncated
|
||||
)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bi(a,d),e=bj(a),g=bj(d);for(h=0;e[h];++h)bi(e[h],g[h])}if(b){bh(a,d);if(c){e=bj(a),g=bj(d);for(h=0;e[h];++h)bh(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!ba.test(k))k=b.createTextNode(k);else{k=k.replace(Z,"<$1></$2>");var l=($.exec(k)||["",""])[1].toLowerCase(),m=bf[l]||bf._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=_.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]==="<table>"&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&Y.test(k)&&o.insertBefore(b.createTextNode(Y.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i<r;i++)bl(k[i]);else bl(k);k.nodeType?h.push(k):h=f.merge(h,k)}if(d){g=function(a){return!a.type||bd.test(a.type)};for(j=0;h[j];j++)if(e&&f.nodeName(h[j],"script")&&(!h[j].type||h[j].type.toLowerCase()==="text/javascript"))e.push(h[j].parentNode?h[j].parentNode.removeChild(h[j]):h[j]);else{if(h[j].nodeType===1){var s=f.grep(h[j].getElementsByTagName("script"),g);h.splice.apply(h,[j+1,0].concat(s))}d.appendChild(h[j])}}return h},cleanData:function(a){var b,c,d=f.cache,e=f.expando,g=f.event.special,h=f.support.deleteExpando;for(var i=0,j;(j=a[i])!=null;i++){if(j.nodeName&&f.noData[j.nodeName.toLowerCase()])continue;c=j[f.expando];if(c){b=d[c]&&d[c][e];if(b&&b.events){for(var k in b.events)g[k]?f.event.remove(j,k):f.removeEvent(j,k,b.handle);b.handle&&(b.handle.elem=null)}h?delete j[f.expando]:j.removeAttribute&&j.removeAttribute(f.expando),delete d[c]}}}});var bn=/alpha\([^)]*\)/i,bo=/opacity=([^)]*)/,bp=/([A-Z]|^ms)/g,bq=/^-?\d+(?:px)?$/i,br=/^-?\d/,bs=/^[+\-]=/,bt=/[^+\-\.\de]+/g,bu={position:"absolute",visibility:"hidden",display:"block"},bv=["Left","Right"],bw=["Top","Bottom"],bx,by,bz;f.fn.css=function(a,c){if(arguments.length===2&&c===b)return this;return f.access(this,a,c,!0,function(a,c,d){return d!==b?f.style(a,c,d):f.css(a,c)})},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bx(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d;if(h==="number"&&isNaN(d)||d==null)return;h==="string"&&bs.test(d)&&(d=+d.replace(bt,"")+parseFloat(f.css(a,c)),h="number"),h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(bx)return bx(a,c)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]}}),f.curCSS=f.css,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){var e;if(c){if(a.offsetWidth!==0)return bA(a,b,d);f.swap(a,bu,function(){e=bA(a,b,d)});return e}},set:function(a,b){if(!bq.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bo.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle;c.zoom=1;var e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.filter=bn.test(g)?g.replace(bn,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bx(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(by=function(a,c){var d,e,g;c=c.replace(bp,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bz=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bq.test(d)&&br.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===Line truncated
|
||||
@@ -0,0 +1,698 @@
|
||||
/*
|
||||
* SimpleModal 1.4.1 - jQuery Plugin
|
||||
* http://www.ericmmartin.com/projects/simplemodal/
|
||||
* Copyright (c) 2010 Eric Martin (http://twitter.com/ericmmartin)
|
||||
* Dual licensed under the MIT and GPL licenses
|
||||
* Revision: $Id: jquery.simplemodal.js 261 2010-11-05 21:16:20Z emartin24 $
|
||||
*/
|
||||
|
||||
/**
|
||||
* SimpleModal is a lightweight jQuery plugin that provides a simple
|
||||
* interface to create a modal dialog.
|
||||
*
|
||||
* The goal of SimpleModal is to provide developers with a cross-browser
|
||||
* overlay and container that will be populated with data provided to
|
||||
* SimpleModal.
|
||||
*
|
||||
* There are two ways to call SimpleModal:
|
||||
* 1) As a chained function on a jQuery object, like $('#myDiv').modal();.
|
||||
* This call would place the DOM object, #myDiv, inside a modal dialog.
|
||||
* Chaining requires a jQuery object. An optional options object can be
|
||||
* passed as a parameter.
|
||||
*
|
||||
* @example $('<div>my data</div>').modal({options});
|
||||
* @example $('#myDiv').modal({options});
|
||||
* @example jQueryObject.modal({options});
|
||||
*
|
||||
* 2) As a stand-alone function, like $.modal(data). The data parameter
|
||||
* is required and an optional options object can be passed as a second
|
||||
* parameter. This method provides more flexibility in the types of data
|
||||
* that are allowed. The data could be a DOM object, a jQuery object, HTML
|
||||
* or a string.
|
||||
*
|
||||
* @example $.modal('<div>my data</div>', {options});
|
||||
* @example $.modal('my data', {options});
|
||||
* @example $.modal($('#myDiv'), {options});
|
||||
* @example $.modal(jQueryObject, {options});
|
||||
* @example $.modal(document.getElementById('myDiv'), {options});
|
||||
*
|
||||
* A SimpleModal call can contain multiple elements, but only one modal
|
||||
* dialog can be created at a time. Which means that all of the matched
|
||||
* elements will be displayed within the modal container.
|
||||
*
|
||||
* SimpleModal internally sets the CSS needed to display the modal dialog
|
||||
* properly in all browsers, yet provides the developer with the flexibility
|
||||
* to easily control the look and feel. The styling for SimpleModal can be
|
||||
* done through external stylesheets, or through SimpleModal, using the
|
||||
* overlayCss, containerCss, and dataCss options.
|
||||
*
|
||||
* SimpleModal has been tested in the following browsers:
|
||||
* - IE 6, 7, 8, 9
|
||||
* - Firefox 2, 3, 4
|
||||
* - Opera 9, 10
|
||||
* - Safari 3, 4, 5
|
||||
* - Chrome 1, 2, 3, 4, 5, 6
|
||||
*
|
||||
* @name SimpleModal
|
||||
* @type jQuery
|
||||
* @requires jQuery v1.2.4
|
||||
* @cat Plugins/Windows and Overlays
|
||||
* @author Eric Martin (http://ericmmartin.com)
|
||||
* @version 1.4.1
|
||||
*/
|
||||
;(function ($) {
|
||||
var ie6 = $.browser.msie && parseInt($.browser.version) === 6 && typeof window['XMLHttpRequest'] !== 'object',
|
||||
ie7 = $.browser.msie && parseInt($.browser.version) === 7,
|
||||
ieQuirks = null,
|
||||
w = [];
|
||||
|
||||
/*
|
||||
* Create and display a modal dialog.
|
||||
*
|
||||
* @param {string, object} data A string, jQuery object or DOM object
|
||||
* @param {object} [options] An optional object containing options overrides
|
||||
*/
|
||||
$.modal = function (data, options) {
|
||||
return $.modal.impl.init(data, options);
|
||||
};
|
||||
|
||||
/*
|
||||
* Close the modal dialog.
|
||||
*/
|
||||
$.modal.close = function () {
|
||||
$.modal.impl.close();
|
||||
};
|
||||
|
||||
/*
|
||||
* Set focus on first or last visible input in the modal dialog. To focus on the last
|
||||
* element, call $.modal.focus('last'). If no input elements are found, focus is placed
|
||||
* on the data wrapper element.
|
||||
*/
|
||||
$.modal.focus = function (pos) {
|
||||
$.modal.impl.focus(pos);
|
||||
};
|
||||
|
||||
/*
|
||||
* Determine and set the dimensions of the modal dialog container.
|
||||
* setPosition() is called if the autoPosition option is true.
|
||||
*/
|
||||
$.modal.setContainerDimensions = function () {
|
||||
$.modal.impl.setContainerDimensions();
|
||||
};
|
||||
|
||||
/*
|
||||
* Re-position the modal dialog.
|
||||
*/
|
||||
$.modal.setPosition = function () {
|
||||
$.modal.impl.setPosition();
|
||||
};
|
||||
|
||||
/*
|
||||
* Update the modal dialog. If new dimensions are passed, they will be used to determine
|
||||
* the dimensions of the container.
|
||||
*
|
||||
* setContainerDimensions() is called, which in turn calls setPosition(), if enabled.
|
||||
* Lastly, focus() is called is the focus option is true.
|
||||
*/
|
||||
$.modal.update = function (height, width) {
|
||||
$.modal.impl.update(height, width);
|
||||
};
|
||||
|
||||
/*
|
||||
* Chained function to create a modal dialog.
|
||||
*
|
||||
* @param {object} [options] An optional object containing options overrides
|
||||
*/
|
||||
$.fn.modal = function (options) {
|
||||
return $.modal.impl.init(this, options);
|
||||
};
|
||||
|
||||
/*
|
||||
* SimpleModal default options
|
||||
*
|
||||
* appendTo: (String:'body') The jQuery selector to append the elements to. For .NET, use 'form'.
|
||||
* focus: (Boolean:true) Focus in the first visible, enabled element?
|
||||
* opacity: (Number:50) The opacity value for the overlay div, from 0 - 100
|
||||
* overlayId: (String:'simplemodal-overlay') The DOM element id for the overlay div
|
||||
* overlayCss: (Object:{}) The CSS styling for the overlay div
|
||||
* containerId: (String:'simplemodal-container') The DOM element id for the container div
|
||||
* containerCss: (Object:{}) The CSS styling for the container div
|
||||
* dataId: (String:'simplemodal-data') The DOM element id for the data div
|
||||
* dataCss: (Object:{}) The CSS styling for the data div
|
||||
* minHeight: (Number:null) The minimum height for the container
|
||||
* minWidth: (Number:null) The minimum width for the container
|
||||
* maxHeight: (Number:null) The maximum height for the container. If not specified, the window height is used.
|
||||
* maxWidth: (Number:null) The maximum width for the container. If not specified, the window width is used.
|
||||
* autoResize: (Boolean:false) Automatically resize the container if it exceeds the browser window dimensions?
|
||||
* autoPosition: (Boolean:true) Automatically position the container upon creation and on window resize?
|
||||
* zIndex: (Number: 1000) Starting z-index value
|
||||
* close: (Boolean:true) If true, closeHTML, escClose and overClose will be used if set.
|
||||
If false, none of them will be used.
|
||||
* closeHTML: (String:'<a class="modalCloseImg" title="Close"></a>') The HTML for the default close link.
|
||||
SimpleModal will automatically add the closeClass to this element.
|
||||
* closeClass: (String:'simplemodal-close') The CSS class used to bind to the close event
|
||||
* escClose: (Boolean:true) Allow Esc keypress to close the dialog?
|
||||
* overlayClose: (Boolean:false) Allow click on overlay to close the dialog?
|
||||
* position: (Array:null) Position of container [top, left]. Can be number of pixels or percentage
|
||||
* persist: (Boolean:false) Persist the data across modal calls? Only used for existing
|
||||
DOM elements. If true, the data will be maintained across modal calls, if false,
|
||||
the data will be reverted to its original state.
|
||||
* modal: (Boolean:true) User will be unable to interact with the page below the modal or tab away from the dialog.
|
||||
If false, the overlay, iframe, and certain events will be disabled allowing the user to interact
|
||||
with the page below the dialog.
|
||||
* onOpen: (Function:null) The callback function used in place of SimpleModal's open
|
||||
* onShow: (Function:null) The callback function used after the modal dialog has opened
|
||||
* onClose: (Function:null) The callback function used in place of SimpleModal's close
|
||||
*/
|
||||
$.modal.defaults = {
|
||||
appendTo: 'body',
|
||||
focus: true,
|
||||
opacity: 50,
|
||||
overlayId: 'simplemodal-overlay',
|
||||
overlayCss: {},
|
||||
containerId: 'simplemodal-container',
|
||||
containerCss: {},
|
||||
dataId: 'simplemodal-data',
|
||||
dataCss: {},
|
||||
minHeight: null,
|
||||
minWidth: null,
|
||||
maxHeight: null,
|
||||
maxWidth: null,
|
||||
autoResize: false,
|
||||
autoPosition: true,
|
||||
zIndex: 1000,
|
||||
close: true,
|
||||
closeHTML: '<a class="modalCloseImg" title="Close"></a>',
|
||||
closeClass: 'simplemodal-close',
|
||||
escClose: true,
|
||||
overlayClose: false,
|
||||
position: null,
|
||||
persist: false,
|
||||
modal: true,
|
||||
onOpen: null,
|
||||
onShow: null,
|
||||
onClose: null
|
||||
};
|
||||
|
||||
/*
|
||||
* Main modal object
|
||||
* o = options
|
||||
*/
|
||||
$.modal.impl = {
|
||||
/*
|
||||
* Contains the modal dialog elements and is the object passed
|
||||
* back to the callback (onOpen, onShow, onClose) functions
|
||||
*/
|
||||
d: {},
|
||||
/*
|
||||
* Initialize the modal dialog
|
||||
*/
|
||||
init: function (data, options) {
|
||||
var s = this;
|
||||
|
||||
// don't allow multiple calls
|
||||
if (s.d.data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// $.boxModel is undefined if checked earlier
|
||||
ieQuirks = $.browser.msie && !$.boxModel;
|
||||
|
||||
// merge defaults and user options
|
||||
s.o = $.extend({}, $.modal.defaults, options);
|
||||
|
||||
// keep track of z-index
|
||||
s.zIndex = s.o.zIndex;
|
||||
|
||||
// set the onClose callback flag
|
||||
s.occb = false;
|
||||
|
||||
// determine how to handle the data based on its type
|
||||
if (typeof data === 'object') {
|
||||
// convert DOM object to a jQuery object
|
||||
data = data instanceof jQuery ? data : $(data);
|
||||
s.d.placeholder = false;
|
||||
|
||||
// if the object came from the DOM, keep track of its parent
|
||||
if (data.parent().parent().size() > 0) {
|
||||
data.before($('<span></span>')
|
||||
.attr('id', 'simplemodal-placeholder')
|
||||
.css({display: 'none'}));
|
||||
|
||||
s.d.placeholder = true;
|
||||
s.display = data.css('display');
|
||||
|
||||
// persist changes? if not, make a clone of the element
|
||||
if (!s.o.persist) {
|
||||
s.d.orig = data.clone(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (typeof data === 'string' || typeof data === 'number') {
|
||||
// just insert the data as innerHTML
|
||||
data = $('<div></div>').html(data);
|
||||
}
|
||||
else {
|
||||
// unsupported data type!
|
||||
alert('SimpleModal Error: Unsupported data type: ' + typeof data);
|
||||
return s;
|
||||
}
|
||||
|
||||
// create the modal overlay, container and, if necessary, iframe
|
||||
s.create(data);
|
||||
data = null;
|
||||
|
||||
// display the modal dialog
|
||||
s.open();
|
||||
|
||||
// useful for adding events/manipulating data in the modal dialog
|
||||
if ($.isFunction(s.o.onShow)) {
|
||||
s.o.onShow.apply(s, [s.d]);
|
||||
}
|
||||
|
||||
// don't break the chain =)
|
||||
return s;
|
||||
},
|
||||
/*
|
||||
* Create and add the modal overlay and container to the page
|
||||
*/
|
||||
create: function (data) {
|
||||
var s = this;
|
||||
|
||||
// get the window properties
|
||||
w = s.getDimensions();
|
||||
|
||||
// add an iframe to prevent select options from bleeding through
|
||||
if (s.o.modal && ie6) {
|
||||
s.d.iframe = $('<iframe src="javascript:false;"></iframe>')
|
||||
.css($.extend(s.o.iframeCss, {
|
||||
display: 'none',
|
||||
opacity: 0,
|
||||
position: 'fixed',
|
||||
height: w[0],
|
||||
width: w[1],
|
||||
zIndex: s.o.zIndex,
|
||||
top: 0,
|
||||
left: 0
|
||||
}))
|
||||
.appendTo(s.o.appendTo);
|
||||
}
|
||||
|
||||
// create the overlay
|
||||
s.d.overlay = $('<div></div>')
|
||||
.attr('id', s.o.overlayId)
|
||||
.addClass('simplemodal-overlay')
|
||||
.css($.extend(s.o.overlayCss, {
|
||||
display: 'none',
|
||||
opacity: s.o.opacity / 100,
|
||||
height: s.o.modal ? w[0] : 0,
|
||||
width: s.o.modal ? w[1] : 0,
|
||||
position: 'fixed',
|
||||
left: 0,
|
||||
top: 0,
|
||||
zIndex: s.o.zIndex + 1
|
||||
}))
|
||||
.appendTo(s.o.appendTo);
|
||||
|
||||
// create the container
|
||||
s.d.container = $('<div></div>')
|
||||
.attr('id', s.o.containerId)
|
||||
.addClass('simplemodal-container')
|
||||
.css($.extend(s.o.containerCss, {
|
||||
display: 'none',
|
||||
position: 'fixed',
|
||||
zIndex: s.o.zIndex + 2
|
||||
}))
|
||||
.append(s.o.close && s.o.closeHTML
|
||||
? $(s.o.closeHTML).addClass(s.o.closeClass)
|
||||
: '')
|
||||
.appendTo(s.o.appendTo);
|
||||
|
||||
s.d.wrap = $('<div></div>')
|
||||
.attr('tabIndex', -1)
|
||||
.addClass('simplemodal-wrap')
|
||||
.css({height: '100%', outline: 0, width: '100%'})
|
||||
.appendTo(s.d.container);
|
||||
|
||||
// add styling and attributes to the data
|
||||
// append to body to get correct dimensions, then move to wrap
|
||||
s.d.data = data
|
||||
.attr('id', data.attr('id') || s.o.dataId)
|
||||
.addClass('simplemodal-data')
|
||||
.css($.extend(s.o.dataCss, {
|
||||
display: 'none'
|
||||
}))
|
||||
.appendTo('body');
|
||||
data = null;
|
||||
|
||||
s.setContainerDimensions();
|
||||
s.d.data.appendTo(s.d.wrap);
|
||||
|
||||
// fix issues with IE
|
||||
if (ie6 || ieQuirks) {
|
||||
s.fixIE();
|
||||
}
|
||||
},
|
||||
/*
|
||||
* Bind events
|
||||
*/
|
||||
bindEvents: function () {
|
||||
var s = this;
|
||||
|
||||
// bind the close event to any element with the closeClass class
|
||||
$('.' + s.o.closeClass).bind('click.simplemodal', function (e) {
|
||||
e.preventDefault();
|
||||
s.close();
|
||||
});
|
||||
|
||||
// bind the overlay click to the close function, if enabled
|
||||
if (s.o.modal && s.o.close && s.o.overlayClose) {
|
||||
s.d.overlay.bind('click.simplemodal', function (e) {
|
||||
e.preventDefault();
|
||||
s.close();
|
||||
});
|
||||
}
|
||||
|
||||
// bind keydown events
|
||||
$(document).bind('keydown.simplemodal', function (e) {
|
||||
if (s.o.modal && e.keyCode === 9) { // TAB
|
||||
s.watchTab(e);
|
||||
}
|
||||
else if ((s.o.close && s.o.escClose) && e.keyCode === 27) { // ESC
|
||||
e.preventDefault();
|
||||
s.close();
|
||||
}
|
||||
});
|
||||
|
||||
// update window size
|
||||
$(window).bind('resize.simplemodal', function () {
|
||||
// redetermine the window width/height
|
||||
w = s.getDimensions();
|
||||
|
||||
// reposition the dialog
|
||||
s.o.autoResize ? s.setContainerDimensions() : s.o.autoPosition && s.setPosition();
|
||||
|
||||
if (ie6 || ieQuirks) {
|
||||
s.fixIE();
|
||||
}
|
||||
else if (s.o.modal) {
|
||||
// update the iframe & overlay
|
||||
s.d.iframe && s.d.iframe.css({height: w[0], width: w[1]});
|
||||
s.d.overlay.css({height: w[0], width: w[1]});
|
||||
}
|
||||
});
|
||||
},
|
||||
/*
|
||||
* Unbind events
|
||||
*/
|
||||
unbindEvents: function () {
|
||||
$('.' + this.o.closeClass).unbind('click.simplemodal');
|
||||
$(document).unbind('keydown.simplemodal');
|
||||
$(window).unbind('resize.simplemodal');
|
||||
this.d.overlay.unbind('click.simplemodal');
|
||||
},
|
||||
/*
|
||||
* Fix issues in IE6 and IE7 in quirks mode
|
||||
*/
|
||||
fixIE: function () {
|
||||
var s = this, p = s.o.position;
|
||||
|
||||
// simulate fixed position - adapted from BlockUI
|
||||
$.each([s.d.iframe || null, !s.o.modal ? null : s.d.overlay, s.d.container], function (i, el) {
|
||||
if (el) {
|
||||
var bch = 'document.body.clientHeight', bcw = 'document.body.clientWidth',
|
||||
bsh = 'document.body.scrollHeight', bsl = 'document.body.scrollLeft',
|
||||
bst = 'document.body.scrollTop', bsw = 'document.body.scrollWidth',
|
||||
ch = 'document.documentElement.clientHeight', cw = 'document.documentElement.clientWidth',
|
||||
sl = 'document.documentElement.scrollLeft', st = 'document.documentElement.scrollTop',
|
||||
s = el[0].style;
|
||||
|
||||
s.position = 'absolute';
|
||||
if (i < 2) {
|
||||
s.removeExpression('height');
|
||||
s.removeExpression('width');
|
||||
s.setExpression('height','' + bsh + ' > ' + bch + ' ? ' + bsh + ' : ' + bch + ' + "px"');
|
||||
s.setExpression('width','' + bsw + ' > ' + bcw + ' ? ' + bsw + ' : ' + bcw + ' + "px"');
|
||||
}
|
||||
else {
|
||||
var te, le;
|
||||
if (p && p.constructor === Array) {
|
||||
var top = p[0]
|
||||
? typeof p[0] === 'number' ? p[0].toString() : p[0].replace(/px/, '')
|
||||
: el.css('top').replace(/px/, '');
|
||||
te = top.indexOf('%') === -1
|
||||
? top + ' + (t = ' + st + ' ? ' + st + ' : ' + bst + ') + "px"'
|
||||
: parseInt(top.replace(/%/, '')) + ' * ((' + ch + ' || ' + bch + ') / 100) + (t = ' + st + ' ? ' + st + ' : ' + bst + ') + "px"';
|
||||
|
||||
if (p[1]) {
|
||||
var left = typeof p[1] === 'number' ? p[1].toString() : p[1].replace(/px/, '');
|
||||
le = left.indexOf('%') === -1
|
||||
? left + ' + (t = ' + sl + ' ? ' + sl + ' : ' + bsl + ') + "px"'
|
||||
: parseInt(left.replace(/%/, '')) + ' * ((' + cw + ' || ' + bcw + ') / 100) + (t = ' + sl + ' ? ' + sl + ' : ' + bsl + ') + "px"';
|
||||
}
|
||||
}
|
||||
else {
|
||||
te = '(' + ch + ' || ' + bch + ') / 2 - (this.offsetHeight / 2) + (t = ' + st + ' ? ' + st + ' : ' + bst + ') + "px"';
|
||||
le = '(' + cw + ' || ' + bcw + ') / 2 - (this.offsetWidth / 2) + (t = ' + sl + ' ? ' + sl + ' : ' + bsl + ') + "px"';
|
||||
}
|
||||
s.removeExpression('top');
|
||||
s.removeExpression('left');
|
||||
s.setExpression('top', te);
|
||||
s.setExpression('left', le);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/*
|
||||
* Place focus on the first or last visible input
|
||||
*/
|
||||
focus: function (pos) {
|
||||
var s = this, p = pos && $.inArray(pos, ['first', 'last']) !== -1 ? pos : 'first';
|
||||
|
||||
// focus on dialog or the first visible/enabled input element
|
||||
var input = $(':input:enabled:visible:' + p, s.d.wrap);
|
||||
setTimeout(function () {
|
||||
input.length > 0 ? input.focus() : s.d.wrap.focus();
|
||||
}, 10);
|
||||
},
|
||||
getDimensions: function () {
|
||||
var el = $(window);
|
||||
|
||||
// fix a jQuery/Opera bug with determining the window height
|
||||
var h = $.browser.opera && $.browser.version > '9.5' && $.fn.jquery < '1.3'
|
||||
|| $.browser.opera && $.browser.version < '9.5' && $.fn.jquery > '1.2.6'
|
||||
? el[0].innerHeight : el.height();
|
||||
|
||||
return [h, el.width()];
|
||||
},
|
||||
getVal: function (v, d) {
|
||||
return v ? (typeof v === 'number' ? v
|
||||
: v === 'auto' ? 0
|
||||
: v.indexOf('%') > 0 ? ((parseInt(v.replace(/%/, '')) / 100) * (d === 'h' ? w[0] : w[1]))
|
||||
: parseInt(v.replace(/px/, '')))
|
||||
: null;
|
||||
},
|
||||
/*
|
||||
* Update the container. Set new dimensions, if provided.
|
||||
* Focus, if enabled. Re-bind events.
|
||||
*/
|
||||
update: function (height, width) {
|
||||
var s = this;
|
||||
|
||||
// prevent update if dialog does not exist
|
||||
if (!s.d.data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// reset orig values
|
||||
s.d.origHeight = s.getVal(height, 'h');
|
||||
s.d.origWidth = s.getVal(width, 'w');
|
||||
|
||||
// hide data to prevent screen flicker
|
||||
s.d.data.hide();
|
||||
height && s.d.container.css('height', height);
|
||||
width && s.d.container.css('width', width);
|
||||
s.setContainerDimensions();
|
||||
s.d.data.show();
|
||||
s.o.focus && s.focus();
|
||||
|
||||
// rebind events
|
||||
s.unbindEvents();
|
||||
s.bindEvents();
|
||||
},
|
||||
setContainerDimensions: function () {
|
||||
var s = this,
|
||||
badIE = ie6 || ie7;
|
||||
|
||||
// get the dimensions for the container and data
|
||||
var ch = s.d.origHeight ? s.d.origHeight : $.browser.opera ? s.d.container.height() : s.getVal(badIE ? s.d.container[0].currentStyle['height'] : s.d.container.css('height'), 'h'),
|
||||
cw = s.d.origWidth ? s.d.origWidth : $.browser.opera ? s.d.container.width() : s.getVal(badIE ? s.d.container[0].currentStyle['width'] : s.d.container.css('width'), 'w'),
|
||||
dh = s.d.data.outerHeight(true), dw = s.d.data.outerWidth(true);
|
||||
|
||||
s.d.origHeight = s.d.origHeight || ch;
|
||||
s.d.origWidth = s.d.origWidth || cw;
|
||||
|
||||
// mxoh = max option height, mxow = max option width
|
||||
var mxoh = s.o.maxHeight ? s.getVal(s.o.maxHeight, 'h') : null,
|
||||
mxow = s.o.maxWidth ? s.getVal(s.o.maxWidth, 'w') : null,
|
||||
mh = mxoh && mxoh < w[0] ? mxoh : w[0],
|
||||
mw = mxow && mxow < w[1] ? mxow : w[1];
|
||||
|
||||
// moh = min option height
|
||||
var moh = s.o.minHeight ? s.getVal(s.o.minHeight, 'h') : 'auto';
|
||||
if (!ch) {
|
||||
if (!dh) {ch = moh;}
|
||||
else {
|
||||
if (dh > mh) {ch = mh;}
|
||||
else if (s.o.minHeight && moh !== 'auto' && dh < moh) {ch = moh;}
|
||||
else {ch = dh;}
|
||||
}
|
||||
}
|
||||
else {
|
||||
ch = s.o.autoResize && ch > mh ? mh : ch < moh ? moh : ch;
|
||||
}
|
||||
|
||||
// mow = min option width
|
||||
var mow = s.o.minWidth ? s.getVal(s.o.minWidth, 'w') : 'auto';
|
||||
if (!cw) {
|
||||
if (!dw) {cw = mow;}
|
||||
else {
|
||||
if (dw > mw) {cw = mw;}
|
||||
else if (s.o.minWidth && mow !== 'auto' && dw < mow) {cw = mow;}
|
||||
else {cw = dw;}
|
||||
}
|
||||
}
|
||||
else {
|
||||
cw = s.o.autoResize && cw > mw ? mw : cw < mow ? mow : cw;
|
||||
}
|
||||
|
||||
s.d.container.css({height: ch, width: cw});
|
||||
s.d.wrap.css({overflow: (dh > ch || dw > cw) ? 'auto' : 'visible'});
|
||||
s.o.autoPosition && s.setPosition();
|
||||
},
|
||||
setPosition: function () {
|
||||
var s = this, top, left,
|
||||
hc = (w[0]/2) - (s.d.container.outerHeight(true)/2),
|
||||
vc = (w[1]/2) - (s.d.container.outerWidth(true)/2);
|
||||
|
||||
if (s.o.position && Object.prototype.toString.call(s.o.position) === '[object Array]') {
|
||||
top = s.o.position[0] || hc;
|
||||
left = s.o.position[1] || vc;
|
||||
} else {
|
||||
top = hc;
|
||||
left = vc;
|
||||
}
|
||||
s.d.container.css({left: left, top: top});
|
||||
},
|
||||
watchTab: function (e) {
|
||||
var s = this;
|
||||
|
||||
if ($(e.target).parents('.simplemodal-container').length > 0) {
|
||||
// save the list of inputs
|
||||
s.inputs = $(':input:enabled:visible:first, :input:enabled:visible:last', s.d.data[0]);
|
||||
|
||||
// if it's the first or last tabbable element, refocus
|
||||
if ((!e.shiftKey && e.target === s.inputs[s.inputs.length -1]) ||
|
||||
(e.shiftKey && e.target === s.inputs[0]) ||
|
||||
s.inputs.length === 0) {
|
||||
e.preventDefault();
|
||||
var pos = e.shiftKey ? 'last' : 'first';
|
||||
s.focus(pos);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// might be necessary when custom onShow callback is used
|
||||
e.preventDefault();
|
||||
s.focus();
|
||||
}
|
||||
},
|
||||
/*
|
||||
* Open the modal dialog elements
|
||||
* - Note: If you use the onOpen callback, you must "show" the
|
||||
* overlay and container elements manually
|
||||
* (the iframe will be handled by SimpleModal)
|
||||
*/
|
||||
open: function () {
|
||||
var s = this;
|
||||
// display the iframe
|
||||
s.d.iframe && s.d.iframe.show();
|
||||
|
||||
if ($.isFunction(s.o.onOpen)) {
|
||||
// execute the onOpen callback
|
||||
s.o.onOpen.apply(s, [s.d]);
|
||||
}
|
||||
else {
|
||||
// display the remaining elements
|
||||
s.d.overlay.show();
|
||||
s.d.container.show();
|
||||
s.d.data.show();
|
||||
}
|
||||
|
||||
s.o.focus && s.focus();
|
||||
|
||||
// bind default events
|
||||
s.bindEvents();
|
||||
},
|
||||
/*
|
||||
* Close the modal dialog
|
||||
* - Note: If you use an onClose callback, you must remove the
|
||||
* overlay, container and iframe elements manually
|
||||
*
|
||||
* @param {boolean} external Indicates whether the call to this
|
||||
* function was internal or external. If it was external, the
|
||||
* onClose callback will be ignored
|
||||
*/
|
||||
close: function () {
|
||||
var s = this;
|
||||
|
||||
// prevent close when dialog does not exist
|
||||
if (!s.d.data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove the default events
|
||||
s.unbindEvents();
|
||||
|
||||
if ($.isFunction(s.o.onClose) && !s.occb) {
|
||||
// set the onClose callback flag
|
||||
s.occb = true;
|
||||
|
||||
// execute the onClose callback
|
||||
s.o.onClose.apply(s, [s.d]);
|
||||
}
|
||||
else {
|
||||
// if the data came from the DOM, put it back
|
||||
if (s.d.placeholder) {
|
||||
var ph = $('#simplemodal-placeholder');
|
||||
// save changes to the data?
|
||||
if (s.o.persist) {
|
||||
// insert the (possibly) modified data back into the DOM
|
||||
ph.replaceWith(s.d.data.removeClass('simplemodal-data').css('display', s.display));
|
||||
}
|
||||
else {
|
||||
// remove the current and insert the original,
|
||||
// unmodified data back into the DOM
|
||||
s.d.data.hide().remove();
|
||||
ph.replaceWith(s.d.orig);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// otherwise, remove it
|
||||
s.d.data.hide().remove();
|
||||
}
|
||||
|
||||
// remove the remaining elements
|
||||
s.d.container.hide().remove();
|
||||
s.d.overlay.hide();
|
||||
s.d.iframe && s.d.iframe.hide().remove();
|
||||
setTimeout(function(){
|
||||
// opera work-around
|
||||
s.d.overlay.remove();
|
||||
|
||||
// reset the dialog object
|
||||
s.d = {};
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
Reference in new issue
Block a user