/*modal*/
jQuery(function ($, undefined) { var $w = $(window), $d = $(document), $b = $('body'), baseHref = $('base').attr('href'), _nmObj = { filters: [], callbacks: {}, loadFilter: undefined, modal: false, closeOnEscape: true, closeOnClick: true, useKeyHandler: false, showCloseButton: true, closeButton: '<a href="#" class="nyroModalClose nyroModalCloseButton nmReposition" title="close">Close</a>', stack: false, nonStackable: 'form', header: undefined, footer: undefined, galleryLoop: true, galleryCounts: true, ltr: true, imageRegex: '[^\.]\.(jpg|jpeg|png|tiff|gif|bmp)\s*$', selIndicator: 'nyroModalSel', swfObjectId: undefined, swf: { allowFullScreen: 'true', allowscriptaccess: 'always', wmode: 'transparent' }, store: {}, errorMsg: 'An error occured', elts: { all: undefined, bg: undefined, load: undefined, cont: undefined, hidden: undefined }, sizes: { initW: undefined, initH: undefined, w: undefined, h: undefined, minW: undefined, minH: undefined, wMargin: undefined, hMargin: undefined }, anim: { def: undefined, showBg: undefined, hideBg: undefined, showLoad: undefined, hideLoad: undefined, showCont: undefined, hideCont: undefined, showTrans: undefined, hideTrans: undefined, resize: undefined }, _open: false, _bgReady: false, _opened: false, _loading: false, _animated: false, _transition: false, _nmOpener: undefined, _nbContentLoading: 0, _scripts: '', _scriptsShown: '', saveObj: function () { this.opener.data('nmObj', this); }, open: function () { if (this._nmOpener) this._nmOpener._close(); this.getInternal()._pushStack(this.opener); this._opened = false; this._bgReady = false; this._open = true; this._initElts(); this._load(); this._nbContentLoading = 0; this._callAnim('showBg', $.proxy(function () { this._bgReady = true; if (this._nmOpener) { this._nmOpener._bgReady = false; this._nmOpener._loading = false; this._nmOpener._animated = false; this._nmOpener._opened = false; this._nmOpener._open = false; this._nmOpener.elts.cont = this._nmOpener.elts.hidden = this._nmOpener.elts.load = this._nmOpener.elts.bg = this._nmOpener.elts.all = undefined; this._nmOpener.saveObj(); this._nmOpener = undefined; } this._contentLoading(); }, this)); }, resize: function (recalc) { if (recalc) { this.elts.hidden.append(this.elts.cont.children().first().clone()); this.sizes.initW = this.sizes.w = this.elts.hidden.width(); this.sizes.initH = this.sizes.h = this.elts.hidden.height(); this.elts.hidden.empty(); } else { this.sizes.w = this.sizes.initW; this.sizes.h = this.sizes.initH; } this._unreposition(); this.size(); this._callAnim('resize', $.proxy(function () { this._reposition(); }, this)); }, size: function () { var maxHeight = this.getInternal().fullSize.viewH - this.sizes.hMargin, maxWidth = this.getInternal().fullSize.viewW - this.sizes.wMargin; if (this.sizes.minW && this.sizes.minW > this.sizes.w) this.sizes.w = this.sizes.minW; if (this.sizes.minH && this.sizes.minH > this.sizes.h) this.sizes.h = this.sizes.minH; if (this.sizes.h > maxHeight || this.sizes.w > maxWidth) { this.sizes.h = Math.min(this.sizes.h, maxHeight); this.sizes.w = Math.min(this.sizes.w, maxWidth); } this._callFilters('size'); }, getForNewLinks: function (elt) { var ret; if (this.stack && (!elt || this.isStackable(elt))) { ret = $.extend(true, {}, this); ret._nmOpener = undefined; ret.elts.all = undefined; } else { ret = $.extend({}, this); ret._nmOpener = this; } ret.filters = []; ret.opener = undefined; ret._open = false; return ret; }, isStackable: function (elt) { return !elt.is(this.nonStackable); }, keyHandle: function (e) { this.keyEvent = e; this._callFilters('keyHandle'); this.keyEvent = undefined; delete (this.keyEvent); }, getInternal: function () { return _internal; }, _close: function () { this.getInternal()._removeStack(this.opener); this._opened = false; this._open = false; this._callFilters('close'); }, close: function () { this._close(); this._callFilters('beforeClose'); var self = this; this._unreposition(); self._callAnim('hideCont', function () { self._callAnim('hideLoad', function () { self._callAnim('hideBg', function () { self._callFilters('afterClose'); self.elts.cont.remove(); self.elts.hidden.remove(); self.elts.load.remove(); self.elts.bg.remove(); self.elts.all.remove(); self.elts.cont = self.elts.hidden = self.elts.load = self.elts.bg = self.elts.all = undefined; }); }); }); }, _initElts: function () { if (!this.stack && this.getInternal().stack.length > 1) this.elts = this.getInternal().stack[this.getInternal().stack.length - 2]['nmObj'].elts; if (!this.elts.all || this.elts.all.closest('body').length == 0) this.elts.all = this.elts.bg = this.elts.cont = this.elts.hidden = this.elts.load = undefined; if (!this.elts.all) this.elts.all = $('<div />').appendTo(this.getInternal()._container); if (!this.elts.bg) this.elts.bg = $('<div />').hide().appendTo(this.elts.all); if (!this.elts.cont) this.elts.cont = $('<div />').hide().appendTo(this.elts.all); if (!this.elts.hidden) this.elts.hidden = $('<div />').hide().appendTo(this.elts.all); this.elts.hidden.empty(); if (!this.elts.load) this.elts.load = $('<div />').hide().appendTo(this.elts.all); this._callFilters('initElts'); }, _error: function () { this._callFilters('error'); }, _setCont: function (html, selector) { if (selector) { var tmp = [], i = 0; html = html.replace(/\r\n/gi, 'nyroModalLN').replace(/<script(.|\s)*?\/script>/gi, function (x) { tmp[i] = x; return '<pre class=nyroModalScript rel="' + (i++) + '"></pre>'; }); var cur = $('<div>' + html + '</div>').find(selector); if (cur.length) { html = cur.html().replace(/<pre class="?nyroModalScript"? rel="?(.?)"?><\/pre>/gi, function (x, y, z) { return tmp[y]; }).replace(/nyroModalLN/gi, "\r\n"); } else { this._error(); return; } } this.elts.hidden.append(this._filterScripts(html)).prepend(this.header).append(this.footer).wrapInner('<div class="nyroModal' + ucfirst(this.loadFilter) + '" />'); this.sizes.initW = this.sizes.w = this.elts.hidden.width(); this.sizes.initH = this.sizes.h = this.elts.hidden.height(); var outer = this.getInternal()._getOuter(this.elts.cont); this.sizes.hMargin = outer.h.total; this.sizes.wMargin = outer.w.total; this.size(); this.loading = false; this._callFilters('filledContent'); this._contentLoading(); }, _filterScripts: function (data) { if (typeof data != 'string') return data; this._scripts = []; this._scriptsShown = []; var start = 0, stStart = '<script', stEnd = '</script>', endLn = stEnd.length, pos, pos2, tmp; while ((pos = data.indexOf(stStart, start)) > -1) { pos2 = data.indexOf(stEnd) + endLn; tmp = $(data.substring(pos, pos2)); if (!tmp.attr('src') || tmp.attr('rel') == 'forceLoad') { if (tmp.attr('rev') == 'shown') this._scriptsShown.push(tmp.get(0)); else this._scripts.push(tmp.get(0)); } data = data.substring(0, pos) + data.substr(pos2); start = pos; } return data; }, _hasFilter: function (filter) { var ret = false; $.each(this.filters, function (i, f) { ret = ret || f == filter; }); return ret; }, _delFilter: function (filter) { this.filters = $.map(this.filters, function (v) { if (v != filter) return v; }); }, _callFilters: function (fct) { this.getInternal()._debug(fct); var ret = [], self = this; $.each(this.filters, function (i, f) { ret[f] = self._callFilter(f, fct); }); if (this.callbacks[fct] && $.isFunction(this.callbacks[fct])) this.callbacks[fct](this); return ret; }, _callFilter: function (f, fct) { if (_filters[f] && _filters[f][fct] && $.isFunction(_filters[f][fct])) return _filters[f][fct](this); return undefined; }, _callAnim: function (fct, clb) { this.getInternal()._debug(fct); this._callFilters('before' + ucfirst(fct)); if (!this._animated) { this._animated = true; if (!$.isFunction(clb)) clb = $.noop; var set = this.anim[fct] || this.anim.def || 'basic'; if (!_animations[set] || !_animations[set][fct] || !$.isFunction(_animations[set][fct])) set = 'basic'; _animations[set][fct](this, $.proxy(function () { this._animated = false; this._callFilters('after' + ucfirst(fct)); clb(); }, this)); } }, _load: function () { this.getInternal()._debug('_load'); if (!this.loading && this.loadFilter) { this.loading = true; this._callFilter(this.loadFilter, 'load'); } }, _contentLoading: function () { if (!this._animated && this._bgReady) { if (!this._transition && this.elts.cont.html().length > 0) this._transition = true; this._nbContentLoading++; if (!this.loading) { if (!this._opened) { this._opened = true; if (this._transition) { var fct = $.proxy(function () { this._writeContent(); this._callFilters('beforeShowCont'); this._callAnim('hideTrans', $.proxy(function () { this._transition = false; this._callFilters('afterShowCont'); this.elts.cont.append(this._scriptsShown); this._reposition(); }, this)); }, this); if (this._nbContentLoading == 1) { this._unreposition(); this._callAnim('showTrans', fct); } else { fct(); } } else { this._callAnim('hideLoad', $.proxy(function () { this._writeContent(); this._callAnim('showCont', $.proxy(function () { this.elts.cont.append(this._scriptsShown); this._reposition(); }, this)); }, this)); } } } else if (this._nbContentLoading == 1) { var outer = this.getInternal()._getOuter(this.elts.load); this.elts.load.css({ position: 'fixed', top: (this.getInternal().fullSize.viewH - this.elts.load.height() - outer.h.margin) / 2, left: (this.getInternal().fullSize.viewW - this.elts.load.width() - outer.w.margin) / 2 }); if (this._transition) { this._unreposition(); this._callAnim('showTrans', $.proxy(function () { this._contentLoading(); }, this)); } else { this._callAnim('showLoad', $.proxy(function () { this._contentLoading(); }, this)); } } } }, _writeContent: function () { this.elts.cont.empty().append(this.elts.hidden.contents()).append(this._scripts).append(this.showCloseButton ? this.closeButton : '').css({ position: 'fixed', width: this.sizes.w, height: this.sizes.h, top: (this.getInternal().fullSize.viewH - this.sizes.h - this.sizes.hMargin) / 2, left: (this.getInternal().fullSize.viewW - this.sizes.w - this.sizes.wMargin) / 2 }); }, _reposition: function () { var elts = this.elts.cont.find('.nmReposition'); if (elts.length) { var space = this.getInternal()._getSpaceReposition(); elts.each(function () { var me = $(this), offset = me.offset(); me.css({ position: 'fixed', top: offset.top - space.top, left: offset.left - space.left }); }); this.elts.cont.after(elts); } this.elts.cont.css('overflow', 'auto'); this._callFilters('afterReposition'); }, _unreposition: function () { this.elts.cont.css('overflow', ''); var elts = this.elts.all.find('.nmReposition'); if (elts.length) this.elts.cont.append(elts.removeAttr('style')); this._callFilters('afterUnreposition'); } }, _internal = { firstInit: true, debug: false, stack: [], fullSize: { w: 0, h: 0, wW: 0, wH: 0, viewW: 0, viewH: 0 }, nyroModal: function (opts, fullObj) { if (_internal.firstInit) { _internal._container = $('<div />').appendTo($b); $w.smartresize($.proxy(_internal._resize, _internal)); $d.bind('keydown.nyroModal', $.proxy(_internal._keyHandler, _internal)); _internal._calculateFullSize(); _internal.firstInit = false; } return this.nmInit(opts, fullObj).each(function () { _internal._init($(this).data('nmObj')); }); }, nmInit: function (opts, fullObj) { return this.each(function () { var me = $(this); if (fullObj) me.data('nmObj', $.extend(true, { opener: me }, opts)); else me.data('nmObj', me.data('nmObj') ? $.extend(true, me.data('nmObj'), opts) : $.extend(true, { opener: me }, _nmObj, opts)); }); }, nmCall: function () { return this.trigger('nyroModal'); }, nmManual: function (url, opts) { $('<a href="' + url + '"></a>').nyroModal(opts).trigger('nyroModal'); }, nmData: function (data, opts) { this.nmManual('#', $.extend({ data: data }, opts)); }, nmObj: function (opts) { $.extend(true, _nmObj, opts); }, nmInternal: function (opts) { $.extend(true, _internal, opts); }, nmAnims: function (opts) { $.extend(true, _animations, opts); }, nmFilters: function (opts) { $.extend(true, _filters, opts); }, nmTop: function () { if (_internal.stack.length) return _internal.stack[_internal.stack.length - 1]['nmObj']; return undefined; }, _debug: function (msg) { if (this.debug && window.console && window.console.log) window.console.log(msg); }, _container: undefined, _init: function (nm) { nm.filters = []; $.each(_filters, function (f, obj) { if (obj.is && $.isFunction(obj.is) && obj.is(nm)) { nm.filters.push(f); } }); nm._callFilters('initFilters'); nm._callFilters('init'); nm.opener.unbind('nyroModal.nyroModal nmClose.nyroModal nmResize.nyroModal').bind({ 'nyroModal.nyroModal': function (e) { nm.open(); return false; }, 'nmClose.nyroModal': function () { nm.close(); return false; }, 'nmResize.nyroModal': function () { nm.resize(); return false; } }); }, _scrollWidth: (function () { var scrollbarWidth; if ($.browser.msie) { var $textarea1 = $('<textarea cols="10" rows="2"></textarea>').css({ position: 'absolute', top: -1000, left: -1000 }).appendTo($b), $textarea2 = $('<textarea cols="10" rows="2" style="overflow: hidden;"></textarea>').css({ position: 'absolute', top: -1000, left: -1000 }).appendTo($b); scrollbarWidth = $textarea1.width() - $textarea2.width(); $textarea1.add($textarea2).remove(); } else { var $div = $('<div />').css({ width: 100, height: 100, overflow: 'auto', position: 'absolute', top: -1000, left: -1000 }).prependTo($b).append('<div />').find('div').css({ width: '100%', height: 200 }); scrollbarWidth = 100 - $div.width(); $div.parent().remove(); } return scrollbarWidth; })(), _selNyroModal: function (obj) { return $(obj).data('nmObj') ? true : false; }, _selNyroModalOpen: function (obj) { var me = $(obj); return me.data('nmObj') ? me.data('nmObj')._open : false; }, _keyHandler: function (e) { var nmTop = $.nmTop(); if (nmTop && nmTop.useKeyHandler) { return nmTop.keyHandle(e); } }, _pushStack: function (obj) { this.stack = $.map(this.stack, function (elA) { if (elA['nmOpener'] != obj.get(0)) return elA; }); this.stack.push({ nmOpener: obj.get(0), nmObj: $(obj).data('nmObj') }); }, _removeStack: function (obj) { this.stack = $.map(this.stack, function (elA) { if (elA['nmOpener'] != obj.get(0)) return elA; }); }, _resize: function () { var opens = $(':nmOpen').each(function () { $(this).data('nmObj')._unreposition(); }); this._calculateFullSize(); opens.trigger('nmResize'); }, _calculateFullSize: function () { this.fullSize = { w: $d.width(), h: $d.height(), wW: $w.width(), wH: $w.height() }; this.fullSize.viewW = Math.min(this.fullSize.w, this.fullSize.wW); this.fullSize.viewH = Math.min(this.fullSize.h, this.fullSize.wH); }, _getCurCSS: function (elm, name) { var ret = parseInt($.curCSS(elm, name, true)); return isNaN(ret) ? 0 : ret; }, _getOuter: function (elm) { elm = elm.get(0); var ret = { h: { margin: this._getCurCSS(elm, 'marginTop') + this._getCurCSS(elm, 'marginBottom'), border: this._getCurCSS(elm, 'borderTopWidth') + this._getCurCSS(elm, 'borderBottomWidth'), padding: this._getCurCSS(elm, 'paddingTop') + this._getCurCSS(elm, 'paddingBottom') }, w: { margin: this._getCurCSS(elm, 'marginLeft') + this._getCurCSS(elm, 'marginRight'), border: this._getCurCSS(elm, 'borderLeftWidth') + this._getCurCSS(elm, 'borderRightWidth'), padding: this._getCurCSS(elm, 'paddingLeft') + this._getCurCSS(elm, 'paddingRight')} }; ret.h.outer = ret.h.margin + ret.h.border; ret.w.outer = ret.w.margin + ret.w.border; ret.h.inner = ret.h.padding + ret.h.border; ret.w.inner = ret.w.padding + ret.w.border; ret.h.total = ret.h.outer + ret.h.padding; ret.w.total = ret.w.outer + ret.w.padding; return ret; }, _getSpaceReposition: function () { var outer = this._getOuter($b), ie7 = $.browser.msie && $.browser.version < 8 && !(screen.height <= $w.height() + 23); return { top: $w.scrollTop() - (!ie7 ? outer.h.border / 2 : 0), left: $w.scrollLeft() - (!ie7 ? outer.w.border / 2 : 0) }; }, _getHash: function (url) { if (typeof url == 'string') { var hashPos = url.indexOf('#'); if (hashPos > -1) return url.substring(hashPos); } return ''; }, _extractUrl: function (url) { var ret = { url: undefined, sel: undefined }; if (url) { var hash = this._getHash(url), hashLoc = this._getHash(window.location.href), curLoc = window.location.href.substring(0, window.location.href.length - hashLoc.length), req = url.substring(0, url.length - hash.length); ret.sel = hash; if (req != curLoc && req != baseHref) ret.url = req; } return ret; } }, _animations = { basic: { showBg: function (nm, clb) { nm.elts.bg.css({ opacity: 0.7 }).show(); clb(); }, hideBg: function (nm, clb) { nm.elts.bg.hide(); clb(); }, showLoad: function (nm, clb) { nm.elts.load.show(); clb(); }, hideLoad: function (nm, clb) { nm.elts.load.hide(); clb(); }, showCont: function (nm, clb) { nm.elts.cont.show(); clb(); }, hideCont: function (nm, clb) { nm.elts.cont.hide(); clb(); }, showTrans: function (nm, clb) { nm.elts.cont.hide(); nm.elts.load.show(); clb(); }, hideTrans: function (nm, clb) { nm.elts.cont.show(); nm.elts.load.hide(); clb(); }, resize: function (nm, clb) { nm.elts.cont.css({ width: nm.sizes.w, height: nm.sizes.h, top: (nm.getInternal().fullSize.viewH - nm.sizes.h - nm.sizes.hMargin) / 2, left: (nm.getInternal().fullSize.viewW - nm.sizes.w - nm.sizes.wMargin) / 2 }); clb(); } } }, _filters = { basic: { is: function (nm) { return true; }, init: function (nm) { if (nm.opener.attr('rev') == 'modal') nm.modal = true; if (nm.modal) nm.closeOnEscape = nm.closeOnClick = nm.showCloseButton = false; if (nm.closeOnEscape) nm.useKeyHandler = true; }, initElts: function (nm) { nm.elts.bg.addClass('nyroModalBg'); if (nm.closeOnClick) nm.elts.bg.unbind('click.nyroModal').bind('click.nyroModal', function (e) { e.preventDefault(); nm.close(); }); nm.elts.cont.addClass('nyroModalCont'); nm.elts.hidden.addClass('nyroModalCont nyroModalHidden'); nm.elts.load.addClass('nyroModalCont nyroModalLoad'); }, error: function (nm) { nm.elts.hidden.addClass('nyroModalError'); nm.elts.cont.addClass('nyroModalError'); nm._setCont(nm.errorMsg); }, beforeShowCont: function (nm) { nm.elts.cont.find('.nyroModal').each(function () { var cur = $(this); cur.nyroModal(nm.getForNewLinks(cur), true); }).end().find('.nyroModalClose').bind('click.nyroModal', function (e) { e.preventDefault(); nm.close(); }); }, keyHandle: function (nm) { if (nm.keyEvent.keyCode == 27 && nm.closeOnEscape) { nm.keyEvent.preventDefault(); nm.close(); } } }, custom: { is: function (nm) { return true; } } }; $.fn.extend({ nm: _internal.nyroModal, nyroModal: _internal.nyroModal, nmInit: _internal.nmInit, nmCall: _internal.nmCall }); $.extend({ nmManual: _internal.nmManual, nmData: _internal.nmData, nmObj: _internal.nmObj, nmInternal: _internal.nmInternal, nmAnims: _internal.nmAnims, nmFilters: _internal.nmFilters, nmTop: _internal.nmTop }); $.expr[':'].nyroModal = $.expr[':'].nm = _internal._selNyroModal; $.expr[':'].nmOpen = _internal._selNyroModalOpen; }); (function ($, sr) { var debounce = function (func, threshold, execAsap) { var timeout; return function debounced() { var obj = this, args = arguments; function delayed() { if (!execAsap) func.apply(obj, args); timeout = null; }; if (timeout) clearTimeout(timeout); else if (execAsap) func.apply(obj, args); timeout = setTimeout(delayed, threshold || 100); }; }; jQuery.fn[sr] = function (fn) { return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); }; })(jQuery, 'smartresize'); function ucfirst(str) { str += ''; var f = str.charAt(0).toUpperCase(); return f + str.substr(1); };
jQuery(function ($, undefined) { $.nmAnims({ fade: { showBg: function (nm, clb) { nm.elts.bg.fadeTo(250, 0.7, clb); }, hideBg: function (nm, clb) { nm.elts.bg.fadeOut(clb); }, showLoad: function (nm, clb) { nm.elts.load.fadeIn(clb); }, hideLoad: function (nm, clb) { nm.elts.load.fadeOut(clb); }, showCont: function (nm, clb) { nm.elts.cont.fadeIn(clb); }, hideCont: function (nm, clb) { nm.elts.cont.css('overflow', 'hidden').fadeOut(clb); }, showTrans: function (nm, clb) { nm.elts.load.css({ position: nm.elts.cont.css('position'), top: nm.elts.cont.css('top'), left: nm.elts.cont.css('left'), width: nm.elts.cont.css('width'), height: nm.elts.cont.css('height'), marginTop: nm.elts.cont.css('marginTop'), marginLeft: nm.elts.cont.css('marginLeft') }).fadeIn(function () { nm.elts.cont.hide(); clb(); }); }, hideTrans: function (nm, clb) { nm.elts.cont.css('visibility', 'hidden').show(); nm.elts.load.css('position', nm.elts.cont.css('position')).animate({ top: nm.elts.cont.css('top'), left: nm.elts.cont.css('left'), width: nm.elts.cont.css('width'), height: nm.elts.cont.css('height'), marginTop: nm.elts.cont.css('marginTop'), marginLeft: nm.elts.cont.css('marginLeft') }, function () { nm.elts.cont.css('visibility', ''); nm.elts.load.fadeOut(clb); }); }, resize: function (nm, clb) { nm.elts.cont.animate({ width: nm.sizes.w, height: nm.sizes.h, top: (nm.getInternal().fullSize.viewH - nm.sizes.h - nm.sizes.hMargin) / 2, left: (nm.getInternal().fullSize.viewW - nm.sizes.w - nm.sizes.wMargin) / 2 }, clb); } } }); $.nmObj({ anim: { def: 'fade'} }); }); ;
jQuery(function ($, undefined) { $.nmFilters({ link: { is: function (nm) { var ret = nm.opener.is('[href]'); if (ret) nm.store.link = nm.getInternal()._extractUrl(nm.opener.attr('href')); return ret; }, init: function (nm) { nm.loadFilter = 'link'; nm.opener.unbind('click.nyroModal').bind('click.nyroModal', function (e) { e.preventDefault(); nm.opener.trigger('nyroModal'); }); }, load: function (nm) { $.ajax({ url: nm.store.link.url, data: nm.store.link.sel ? [{ name: nm.selIndicator, value: nm.store.link.sel.substring(1)}] : undefined, success: function (data) { nm._setCont(data, nm.store.link.sel); }, error: function () { nm._error(); } }); } } }); }); ;
/*jQuery(function ($, undefined) { $.nmFilters({ dom: { is: function (nm) { return nm._hasFilter('link') && !nm.store.link.url && nm.store.link.sel; }, init: function (nm) { nm.loadFilter = 'dom'; }, load: function (nm) { nm.store.domEl = $(nm.store.link.sel); if (nm.store.domEl.length) nm._setCont(nm.store.domEl.contents()); else nm._error(); }, close: function (nm) { if (nm.store.domEl && nm.elts.cont) nm.store.domEl.append(nm.elts.cont.find('.nyroModalDom').contents()); } } }); }); ;
jQuery(function ($, undefined) { $.nmFilters({ data: { is: function (nm) { var ret = nm.data ? true : false; if (ret) { nm._delFilter('dom'); } return ret; }, init: function (nm) { nm.loadFilter = 'data'; }, load: function (nm) { nm._setCont(nm.data); } } }); }); ;
jQuery(function ($, undefined) { $.nmFilters({ form: { is: function (nm) { var ret = nm.opener.is('form'); if (ret) nm.store.form = nm.getInternal()._extractUrl(nm.opener.attr('action')); return ret; }, init: function (nm) { nm.loadFilter = 'form'; nm.opener.unbind('submit.nyroModal').bind('submit.nyroModal', function (e) { e.preventDefault(); nm.opener.trigger('nyroModal'); }); }, load: function (nm) { var data = nm.opener.serializeArray(); if (nm.store.form.sel) data.push({ name: nm.selIndicator, value: nm.store.form.sel.substring(1) }); $.ajax({ url: nm.store.form.url, data: data, type: nm.opener.attr('method') ? nm.opener.attr('method') : 'get', success: function (data) { nm._setCont(data, nm.store.form.sel); }, error: function () { nm._error(); } }); } } }); }); ;*/

/*form*/
; (function ($) { $.fn.ajaxSubmit = function (options) { if (!this.length) { log('ajaxSubmit: skipping submit process - no element selected'); return this } var method, action, url, $form = this; if (typeof options == 'function') { options = { success: options} } method = this.attr('method'); action = this.attr('action'); url = (typeof action === 'string') ? $.trim(action) : ''; url = url || window.location.href || ''; if (url) { url = (url.match(/^([^#]+)/) || [])[1] } options = $.extend(true, { url: url, success: $.ajaxSettings.success, type: method || 'GET', iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' }, options); var veto = {}; this.trigger('form-pre-serialize', [this, options, veto]); if (veto.veto) { log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); return this } if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { log('ajaxSubmit: submit aborted via beforeSerialize callback'); return this } var traditional = options.traditional; if (traditional === undefined) { traditional = $.ajaxSettings.traditional } var qx, n, v, a = this.formToArray(options.semantic); if (options.data) { options.extraData = options.data; qx = $.param(options.data, traditional) } if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { log('ajaxSubmit: submit aborted via beforeSubmit callback'); return this } this.trigger('form-submit-validate', [a, this, options, veto]); if (veto.veto) { log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); return this } var q = $.param(a, traditional); if (qx) q = (q ? (q + '&' + qx) : qx); if (options.type.toUpperCase() == 'GET') { options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; options.data = null } else { options.data = q } var callbacks = []; if (options.resetForm) { callbacks.push(function () { $form.resetForm() }) } if (options.clearForm) { callbacks.push(function () { $form.clearForm(options.includeHidden) }) } if (!options.dataType && options.target) { var oldSuccess = options.success || function () { }; callbacks.push(function (data) { var fn = options.replaceTarget ? 'replaceWith' : 'html'; $(options.target)[fn](data).each(oldSuccess, arguments) }) } else if (options.success) { callbacks.push(options.success) } options.success = function (data, status, xhr) { var context = options.context || options; for (var i = 0, max = callbacks.length; i < max; i++) { callbacks[i].apply(context, [data, status, xhr || $form, $form]) } }; var fileInputs = $('input:file', this).length > 0; var mp = 'multipart/form-data'; var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); if (options.iframe !== false && (fileInputs || options.iframe || multipart)) { if (options.closeKeepAlive) { $.get(options.closeKeepAlive, function () { fileUpload(a) }) } else { fileUpload(a) } } else { if ($.browser.msie && method == 'get' && typeof options.type === "undefined") { var ieMeth = $form[0].getAttribute('method'); if (typeof ieMeth === 'string') options.type = ieMeth } $.ajax(options) } this.trigger('form-submit-notify', [this, options]); return this; function fileUpload(a) { var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle; var useProp = !!$.fn.prop; if (a) { if (useProp) { for (i = 0; i < a.length; i++) { el = $(form[a[i].name]); el.prop('disabled', false) } } else { for (i = 0; i < a.length; i++) { el = $(form[a[i].name]); el.removeAttr('disabled') } } } if ($(':input[name=submit],:input[id=submit]', form).length) { alert('Error: Form elements must not have name or id of "submit".'); return } s = $.extend(true, {}, $.ajaxSettings, options); s.context = s.context || s; id = 'jqFormIO' + (new Date().getTime()); if (s.iframeTarget) { $io = $(s.iframeTarget); n = $io.attr('name'); if (n == null) $io.attr('name', id); else id = n } else { $io = $('<iframe name="' + id + '" src="' + s.iframeSrc + '" />'); $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' }) } io = $io[0]; xhr = { aborted: 0, responseText: null, responseXML: null, status: 0, statusText: 'n/a', getAllResponseHeaders: function () { }, getResponseHeader: function () { }, setRequestHeader: function () { }, abort: function (status) { var e = (status === 'timeout' ? 'timeout' : 'aborted'); log('aborting upload... ' + e); this.aborted = 1; $io.attr('src', s.iframeSrc); xhr.error = e; s.error && s.error.call(s.context, xhr, e, status); g && $.event.trigger("ajaxError", [xhr, s, e]); s.complete && s.complete.call(s.context, xhr, e) } }; g = s.global; if (g && !$.active++) { $.event.trigger("ajaxStart") } if (g) { $.event.trigger("ajaxSend", [xhr, s]) } if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) { if (s.global) { $.active-- } return } if (xhr.aborted) { return } sub = form.clk; if (sub) { n = sub.name; if (n && !sub.disabled) { s.extraData = s.extraData || {}; s.extraData[n] = sub.value; if (sub.type == "image") { s.extraData[n + '.x'] = form.clk_x; s.extraData[n + '.y'] = form.clk_y } } } var CLIENT_TIMEOUT_ABORT = 1; var SERVER_ABORT = 2; function getDoc(frame) { var doc = frame.contentWindow ? frame.contentWindow.document : frame.contentDocument ? frame.contentDocument : frame.document; return doc } function doSubmit() { var t = $form.attr('target'), a = $form.attr('action'); form.setAttribute('target', id); if (!method) { form.setAttribute('method', 'POST') } if (a != s.url) { form.setAttribute('action', s.url) } if (!s.skipEncodingOverride && (!method || /post/i.test(method))) { $form.attr({ encoding: 'multipart/form-data', enctype: 'multipart/form-data' }) } if (s.timeout) { timeoutHandle = setTimeout(function () { timedOut = true; cb(CLIENT_TIMEOUT_ABORT) }, s.timeout) } function checkState() { try { var state = getDoc(io).readyState; log('state = ' + state); if (state.toLowerCase() == 'uninitialized') setTimeout(checkState, 50) } catch (e) { log('Server abort: ', e, ' (', e.name, ')'); cb(SERVER_ABORT); timeoutHandle && clearTimeout(timeoutHandle); timeoutHandle = undefined } } var extraInputs = []; try { if (s.extraData) { for (var n in s.extraData) { extraInputs.push($('<input type="hidden" name="' + n + '" />').attr('value', s.extraData[n]).appendTo(form)[0]) } } if (!s.iframeTarget) { $io.appendTo('body'); io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false) } setTimeout(checkState, 15); form.submit() } finally { form.setAttribute('action', a); if (t) { form.setAttribute('target', t) } else { $form.removeAttr('target') } $(extraInputs).remove() } } if (s.forceSync) { doSubmit() } else { setTimeout(doSubmit, 10) } var data, doc, domCheckCount = 50, callbackProcessed; function cb(e) { if (xhr.aborted || callbackProcessed) { return } try { doc = getDoc(io) } catch (ex) { log('cannot access response document: ', ex); e = SERVER_ABORT } if (e === CLIENT_TIMEOUT_ABORT && xhr) { xhr.abort('timeout'); return } else if (e == SERVER_ABORT && xhr) { xhr.abort('server abort'); return } if (!doc || doc.location.href == s.iframeSrc) { if (!timedOut) return } io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false); var status = 'success', errMsg; try { if (timedOut) { throw 'timeout' } var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc); log('isXml=' + isXml); if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) { if (--domCheckCount) { log('requeing onLoad callback, DOM not available'); setTimeout(cb, 250); return } } var docRoot = doc.body ? doc.body : doc.documentElement; xhr.responseText = docRoot ? docRoot.innerHTML : null; xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc; if (isXml) s.dataType = 'xml'; xhr.getResponseHeader = function (header) { var headers = { 'content-type': s.dataType }; return headers[header] }; if (docRoot) { xhr.status = Number(docRoot.getAttribute('status')) || xhr.status; xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText } var dt = (s.dataType || '').toLowerCase(); var scr = /(json|script|text)/.test(dt); if (scr || s.textarea) { var ta = doc.getElementsByTagName('textarea')[0]; if (ta) { xhr.responseText = ta.value; xhr.status = Number(ta.getAttribute('status')) || xhr.status; xhr.statusText = ta.getAttribute('statusText') || xhr.statusText } else if (scr) { var pre = doc.getElementsByTagName('pre')[0]; var b = doc.getElementsByTagName('body')[0]; if (pre) { xhr.responseText = pre.textContent ? pre.textContent : pre.innerText } else if (b) { xhr.responseText = b.textContent ? b.textContent : b.innerText } } } else if (dt == 'xml' && !xhr.responseXML && xhr.responseText != null) { xhr.responseXML = toXml(xhr.responseText) } try { data = httpData(xhr, dt, s) } catch (e) { status = 'parsererror'; xhr.error = errMsg = (e || status) } } catch (e) { log('error caught: ', e); status = 'error'; xhr.error = errMsg = (e || status) } if (xhr.aborted) { log('upload aborted'); status = null } if (xhr.status) { status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success' : 'error' } if (status === 'success') { s.success && s.success.call(s.context, data, 'success', xhr); g && $.event.trigger("ajaxSuccess", [xhr, s]) } else if (status) { if (errMsg == undefined) errMsg = xhr.statusText; s.error && s.error.call(s.context, xhr, status, errMsg); g && $.event.trigger("ajaxError", [xhr, s, errMsg]) } g && $.event.trigger("ajaxComplete", [xhr, s]); if (g && ! --$.active) { $.event.trigger("ajaxStop") } s.complete && s.complete.call(s.context, xhr, status); callbackProcessed = true; if (s.timeout) clearTimeout(timeoutHandle); setTimeout(function () { if (!s.iframeTarget) $io.remove(); xhr.responseXML = null }, 100) } var toXml = $.parseXML || function (s, doc) { if (window.ActiveXObject) { doc = new ActiveXObject('Microsoft.XMLDOM'); doc.async = 'false'; doc.loadXML(s) } else { doc = (new DOMParser()).parseFromString(s, 'text/xml') } return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null }; var parseJSON = $.parseJSON || function (s) { return window['eval']('(' + s + ')') }; var httpData = function (xhr, type, s) { var ct = xhr.getResponseHeader('content-type') || '', xml = type === 'xml' || !type && ct.indexOf('xml') >= 0, data = xml ? xhr.responseXML : xhr.responseText; if (xml && data.documentElement.nodeName === 'parsererror') { $.error && $.error('parsererror') } if (s && s.dataFilter) { data = s.dataFilter(data, type) } if (typeof data === 'string') { if (type === 'json' || !type && ct.indexOf('json') >= 0) { data = parseJSON(data) } else if (type === "script" || !type && ct.indexOf("javascript") >= 0) { $.globalEval(data) } } return data } } }; $.fn.ajaxForm = function (options) { if (this.length === 0) { var o = { s: this.selector, c: this.context }; if (!$.isReady && o.s) { log('DOM not ready, queuing ajaxForm'); $(function () { $(o.s, o.c).ajaxForm(options) }); return this } log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)')); return this } return this.ajaxFormUnbind().bind('submit.form-plugin', function (e) { if (!e.isDefaultPrevented()) { e.preventDefault(); $(this).ajaxSubmit(options) } }).bind('click.form-plugin', function (e) { var target = e.target; var $el = $(target); if (!($el.is(":submit,input:image"))) { var t = $el.closest(':submit'); if (t.length == 0) { return } target = t[0] } var form = this; form.clk = target; if (target.type == 'image') { if (e.offsetX != undefined) { form.clk_x = e.offsetX; form.clk_y = e.offsetY } else if (typeof $.fn.offset == 'function') { var offset = $el.offset(); form.clk_x = e.pageX - offset.left; form.clk_y = e.pageY - offset.top } else { form.clk_x = e.pageX - target.offsetLeft; form.clk_y = e.pageY - target.offsetTop } } setTimeout(function () { form.clk = form.clk_x = form.clk_y = null }, 100) }) }; $.fn.ajaxFormUnbind = function () { return this.unbind('submit.form-plugin click.form-plugin') }; $.fn.formToArray = function (semantic) { var a = []; if (this.length === 0) { return a } var form = this[0]; var els = semantic ? form.getElementsByTagName('*') : form.elements; if (!els) { return a } var i, j, n, v, el, max, jmax; for (i = 0, max = els.length; i < max; i++) { el = els[i]; n = el.name; if (!n) { continue } if (semantic && form.clk && el.type == "image") { if (!el.disabled && form.clk == el) { a.push({ name: n, value: $(el).val() }); a.push({ name: n + '.x', value: form.clk_x }, { name: n + '.y', value: form.clk_y }) } continue } v = $.fieldValue(el, true); if (v && v.constructor == Array) { for (j = 0, jmax = v.length; j < jmax; j++) { a.push({ name: n, value: v[j] }) } } else if (v !== null && typeof v != 'undefined') { a.push({ name: n, value: v }) } } if (!semantic && form.clk) { var $input = $(form.clk), input = $input[0]; n = input.name; if (n && !input.disabled && input.type == 'image') { a.push({ name: n, value: $input.val() }); a.push({ name: n + '.x', value: form.clk_x }, { name: n + '.y', value: form.clk_y }) } } return a }; $.fn.formSerialize = function (semantic) { return $.param(this.formToArray(semantic)) }; $.fn.fieldSerialize = function (successful) { var a = []; this.each(function () { var n = this.name; if (!n) { return } var v = $.fieldValue(this, successful); if (v && v.constructor == Array) { for (var i = 0, max = v.length; i < max; i++) { a.push({ name: n, value: v[i] }) } } else if (v !== null && typeof v != 'undefined') { a.push({ name: this.name, value: v }) } }); return $.param(a) }; $.fn.fieldValue = function (successful) { for (var val = [], i = 0, max = this.length; i < max; i++) { var el = this[i]; var v = $.fieldValue(el, successful); if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) { continue } v.constructor == Array ? $.merge(val, v) : val.push(v) } return val }; $.fieldValue = function (el, successful) { var n = el.name, t = el.type, tag = el.tagName.toLowerCase(); if (successful === undefined) { successful = true } if (successful && (!n || el.disabled || t == 'reset' || t == 'button' || (t == 'checkbox' || t == 'radio') && !el.checked || (t == 'submit' || t == 'image') && el.form && el.form.clk != el || tag == 'select' && el.selectedIndex == -1)) { return null } if (tag == 'select') { var index = el.selectedIndex; if (index < 0) { return null } var a = [], ops = el.options; var one = (t == 'select-one'); var max = (one ? index + 1 : ops.length); for (var i = (one ? index : 0); i < max; i++) { var op = ops[i]; if (op.selected) { var v = op.value; if (!v) { v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value } if (one) { return v } a.push(v) } } return a } return $(el).val() }; $.fn.clearForm = function (includeHidden) { return this.each(function () { $('input,select,textarea', this).clearFields(includeHidden) }) }; $.fn.clearFields = $.fn.clearInputs = function (includeHidden) { var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; return this.each(function () { var t = this.type, tag = this.tagName.toLowerCase(); if (re.test(t) || tag == 'textarea' || (includeHidden && /hidden/.test(t))) { this.value = '' } else if (t == 'checkbox' || t == 'radio') { this.checked = false } else if (tag == 'select') { this.selectedIndex = -1 } }) }; $.fn.resetForm = function () { return this.each(function () { if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) { this.reset() } }) }; $.fn.enable = function (b) { if (b === undefined) { b = true } return this.each(function () { this.disabled = !b }) }; $.fn.selected = function (select) { if (select === undefined) { select = true } return this.each(function () { var t = this.type; if (t == 'checkbox' || t == 'radio') { this.checked = select } else if (this.tagName.toLowerCase() == 'option') { var $sel = $(this).parent('select'); if (select && $sel[0] && $sel[0].type == 'select-one') { $sel.find('option').selected(false) } this.selected = select } }) }; $.fn.ajaxSubmit.debug = false; function log() { if (!$.fn.ajaxSubmit.debug) return; var msg = '[jquery.form] ' + Array.prototype.join.call(arguments, ''); if (window.console && window.console.log) { window.console.log(msg) } else if (window.opera && window.opera.postError) { window.opera.postError(msg) } } })(jQuery);
