(function($) { $.u = { createclass: function(methods) { var constructor = methods.initialize; delete methods.initialize; $.extend(constructor.prototype, methods); return constructor; }, exist: function($e, type) { switch(type || 'jquery') { case 'string': return boolean(typeof $e == 'string' && $e.length > 0); break; case 'number': return boolean(typeof $e == 'number' && $e.length > 0); break; case 'object': return boolean(typeof $e == 'object' && $e.length > 0); break; case 'jquery': default: return boolean($e instanceof jquery && $e.length > 0); } }, event: { stop: function(e) { e.stoppropagation(); e.preventdefault(); }, ismouseout: function(e, classname) { } }, browser: { ie: navigator.useragent.indexof('msie') == -1 ? false : true, ie6: navigator.useragent.indexof('msie 6.0') == -1 ? false : true, ie7: navigator.useragent.indexof('msie 7.0') == -1 ? false : true, ie8: navigator.useragent.indexof('msie 8.0') == -1 ? false : true, ie9: navigator.useragent.indexof('msie 9.0') == -1 ? false : true, ie10: navigator.useragent.indexof('msie 10.0') == -1 ? false : true } }; $.u.fx = $.u.createclass({ initialize: function($element) { this.element = $element; this.style = {}; this.foldstyle = null; this.fxin = {}; this.fxout = {}; this.startshow = false; this.completehide = false; this.duration = 300; }, set: function(propertyname, from, to) { if(typeof propertyname == 'object') { for(var p in propertyname) { this.style[p] = propertyname[p][0]; this.fxin[p] = propertyname[p][1]; this.fxout[p] = propertyname[p][0]; } }else { this.style[propertyname] = from; this.fxin[propertyname] = to; this.fxout[propertyname] = from; } }, setfade: function() { this.set('opacity', 0, 1); }, setfold: function(side, length, isdynamic) { var $e = this.element; if(!length) length = $e[side](); this.foldstyle = {}; this.foldstyle[side] = math.floor(length); if(isdynamic) { var isheight = side == 'height' ? true : false, marginside = isheight ? 'margintop' : 'marginleft', marginproperty = isheight ? 'margin-top' : 'margin-left', paddingside = isheight ? 'paddingtop' : 'paddingleft', paddingproperty = isheight ? 'padding-top' : 'padding-left'; if($e[0].tagname == 'ul') { $e.fxlis = []; $e.children('li').each(function(index, element) { var $li = $(element), marginval = math.floor(parseint($li.css(marginproperty))), paddingval = math.floor(parseint($li.css(paddingproperty))); $li.createfx({marginside: [0, marginval], paddingside: [0, paddingval]}); $e.fxlis.push($li); }); }else { this.set(marginside, 0, $e.css(marginproperty)); this.set(paddingside, 0, $e.css(paddingproperty)); } } this.set(side, 0, this.foldstyle[side]); }, playin: function(duration, complete) { var fx = this, $e = this.element, s = this.style, d = duration || this.duration; if(this.startshow) $e.show(); if(!$.isemptyobject(this.fxin)) { if(this.foldstyle && $e.fxlis) $($e.fxlis).each(function(index, $li) { $li.fx.playin(d, function($e) { $e.fx.removefolddynamicstyle(); }); }); $e.css(s).animate(this.fxin, d, function() { fx.completedefaultin(); if(complete) complete($e); }); } }, playout: function(duration, complete) { var fx = this, $e = this.element, d = duration || this.duration; if(!$.isemptyobject(fx.fxout)) { if(this.foldstyle && $e.fxlis) $($e.fxlis).each(function(index, $li) { $li.fx.playout(d, function($e) { $e.fx.removefolddynamicstyle(); }); }); $e.animate(fx.fxout, d, function() { fx.completedefaultout(); if(complete) complete($e); }); } }, issetin: function() { return !$.isemptyobject(this.fxin); }, issetout: function() { return !$.isemptyobject(this.fxout); }, completedefaultin: function() { var $e = this.element; if(this.foldstyle) this.removefoldstyle(); }, completedefaultout: function() { var $e = this.element; if(this.completehide) $e.hide(); if(this.foldstyle) this.removefoldstyle(); }, removestyledeclaration: function(styleproperties) { var $e = this.element, inlinestyle = $e.attr('style'), pattern = new regexp('(' + styleproperties.join('|') + ')\\:\\s*\\w+\\;', 'g'); $e.attr('style', inlinestyle.replace(pattern, '')); }, removefoldstyle: function() { this.removestyledeclaration(['width', 'height']); }, removefolddynamicstyle: function() { this.removestyledeclaration(['margin-top', 'margin-left', 'padding-top', 'padding-left']); } }); $.fn.createfx = function() { this.fx = new $.u.fx(this); if(arguments.length > 0) this.fx.set.apply(this.fx, arguments); return this.fx; }, $.fn.move = function(options) { if(typeof options != 'object') return this.css({left: arguments[0], top: arguments[1]}); var o = $.extend({}, $.fn.move.defaults, options), iswindow = $.iswindow(o.view[0]) ? true : false, $e = this, $doc = $(document), w = $e.outerwidth(true), h = $e.outerheight(true), x = o.x + o.offsetx, y = o.y + o.offsety, docw = iswindow ? document.documentelement.scrollwidth : o.view[0].scrollwidth, doch = iswindow ? document.documentelement.scrollheight : o.view[0].scrollheight; if(!iswindow) { x += o.view.scrollleft(); y += o.view.scrolltop(); } $e.css({ left: o.bleeding ? x : math.min(math.max(x, 0), docw - w), top: o.bleeding ? y : math.min(math.max(y, 0), doch - h) }); if(o.scroll && $e.css('position') != 'fixed') { var vw = iswindow ? o.view.width() : o.view[0].clientwidth, vh = iswindow ? o.view.height() : o.view[0].clientheight, sl = iswindow ? $doc.scrollleft() : o.view.scrollleft(), st = iswindow ? $doc.scrolltop() : o.view.scrolltop(); if(x < sl) o.view.scrollleft(x); if((x + w) > (vw + sl)) o.view.scrollleft(x + w - vw); if(y < st) o.view.scrolltop(y); if((y + h) > (vh + st)) o.view.scrolltop(y + h - vh); } return $e; }; $.fn.move.defaults = { bleeding: true, scroll: false, view: $(window), x: 0, y: 0, offsetx: 0, offsety: 0 }; $.fn.pos = function(options) { if(typeof arguments[0] == 'string') return ie6fixed(this.css('position', arguments[0])); var o = $.extend({}, $.fn.pos.defaults, options), $e = this; if(!o.offset) o.offset = $(document.body); else if(!/absolute|fixed|relative/.test(o.offset.css('position'))) o.offset.css('position', 'relative'); $e.css('position', o.type).appendto(o.offset); if(o.at) { var hw = $e.outerwidth() / 2, hh = $e.outerheight() / 2; $e.css({margin: 0, left: 'auto', top: 'auto', right: 'auto', bottom: 'auto'}); switch(o.at) { case 7: $e.css({left: 0, top: 0}); break; case 8: $e.css({left: '50%', top: 0, marginleft: -hw}); break; case 9: $e.css({right: 0, top: 0}); break; case 4: $e.css({left: 0, top: '50%', margintop: -hh}); break; case 5: case 'center': default: $e.css({left: '50%', top: '50%', marginleft: -hw, margintop: -hh}); break; case 6: $e.css({right: 0, top: '50%', margintop: -hh}); break; case 1: $e.css({left: 0, bottom: 0}); break; case 2: $e.css({left: '50%', bottom: 0, marginleft: -hw}); break; case 3: $e.css({right: 0, bottom: 0}); break; } } return ie6fixed($e); function ie6fixed($e) { var s = $e[0].style; if($.u.browser.ie6 && s.position == 'fixed') { s.position = 'absolute'; if(s.left == '50%') s.setexpression('left', '(fakevar = document.documentelement.clientwidth / 2 + document.documentelement.scrollleft) + "px"'); else s.setexpression('left', '(fakevar = document.documentelement.scrollleft) + "px"'); if(s.top == '50%') s.setexpression('top', '(fakevar = document.documentelement.clientheight / 2 + document.documentelement.scrolltop) + "px"'); else s.setexpression('top', '(fakevar = document.documentelement.scrolltop) + "px"'); } return $e; } }; $.fn.pos.defaults = { offset: null, type: 'absolute' }; $.fn.draggable = function(options) { var o = $.extend({}, $.fn.draggable.defaults, options); var $e = this; if(!/absolute|fixed/.test($e.css('position'))) $e.css({position: 'absolute'}); if(!o.view) { for(var $p = $e.parent(); $p.size() > 0; $p = $p.parent()) { if(/absolute|fixed|relative/.test($p.css('position'))) { o.view = $p; break; } } } if(!o.view) o.view = $(window); var iswindow = o.view.length && $.iswindow(o.view[0]) ? true : false; var $doc = iswindow ? $(document) : o.view; if(iswindow) $(document.body).append($e); (o.trigger ? $e.find(o.trigger) : $e).css('cursor', 'move'); if(o.dispatch) drag(o.dispatch); else $e.on('mousedown', o.trigger, drag); function drag(event) { o.offsetx = -(event.pagex - $e.offset().left); o.offsety = -(event.pagey - $e.offset().top); $doc.off('mousemove.draggable').on('mousemove.draggable', function(event) { if($e.css('position') == 'fixed') { o.x = event.originalevent.clientx; o.y = event.originalevent.clienty; }else { o.x = iswindow ? event.pagex : event.pagex - o.view.offset().left; o.y = iswindow ? event.pagey : event.pagey - o.view.offset().top; } $e.move(o); if(o.mousemove && $.isfunction(o.mousemove)) o.mousemove.call($e, event); return false; }); $(document).off('mouseup.draggable').on('mouseup.draggable', function(event) { $doc.off('.draggable'); if(o.mouseup && $.isfunction(o.mouseup)) o.mouseup.call($e, event); return false; }); return false; } return $e; }; $.fn.draggable.defaults = { dispatch: null, mousemove: null, trigger: null, view: null } $.fn.dialog = function(options) { var o = $.extend({}, $.fn.dialog.defaults, options), $body = $(document.body), $dialog = this, $btnclose = $dialog.find('.' + o.classbtnclose), $bg, $offset; if(!$dialog.hasclass(o.classactive)) { if(o.draggable) o.fixed = false; if($btnclose.length) $btnclose.on('click.dialog', function(event) { event.stoppropagation(); event.preventdefault(); destroy(); }); if(o.width) $dialog.css({width: o.width}); if(o.height) $dialog.css({height: o.height}); build(); } return $dialog; function build() { $bg = $('
').addclass(o.classbg).css({opacity: o.bgopacity}), $offset = $('
').addclass(o.classbg).css({background: 'transparent', opacity: 1}); $body.append($bg).append($offset.append($dialog)); if(!o.modal) $offset.on('click.dialog', function(event) { event.stoppropagation(); event.preventdefault(); if(event.target == event.currenttarget) destroy(); }); $bg.hide().fadein(); $dialog.addclass(o.classactive).show().css({ marginleft: -math.round($dialog.outerwidth(true) / 2), margintop: -math.round($dialog.outerheight(true) / 2) }); if(o.draggable) { $dialog.draggable({ bleeding: true, scroll: false, view: $offset }); } } function destroy() { if($.isfunction(o.beforeclose)) o.beforeclose.call(this); $('.template').append($dialog.removeattr('style').removeclass(o.classactive)); $offset.remove(); $bg.fadeout(function() {$bg.remove();}); $btnclose.off('click'); if($.isfunction(o.afterclose)) o.afterclose.call(this); } } $.fn.dialogclose = function() { this.find('.dialog-close').trigger('click'); }; $.fn.dialog.defaults = { bgopacity: 0.5, classbg: 'dialog-bg', classdialog: 'dialog', classactive: 'dialog-active', classbtnclose: 'dialog-close', draggable: false, fxfade: false, fxslide: false, fxduration: 300, fixed: false, modal: true } $.fn.tab = function(options) { var o = $.extend({}, $.fn.tab.defaults, options); if(!/mouseover|click/.test(o.event)) o.event = 'click'; var $tablist = this, $links = $tablist.find('.' + o.classlinks).find('.' + o.classlink), $tabs = $tablist.find('.' + o.classtabs).find('.' + o.classtab), $linkactive = null, $tabactive = null; if(o.autoattach) { var r = string(math.random()).substring(2); $links.each(function(i, e) {$(this).attr('href', '#tabsheet-' + r + i)}); $tabs.each(function(i, e) {$(this).attr('id', 'tabsheet-' + r + i)}); } $links.each(function() {if($(this).hasclass(o.classlinkactive)) $linkactive = $(this);}); $tabs.each(function() {if($(this).hasclass(o.classtabactive)) $tabactive = $(this);}); if(!$linkactive) $linkactive = $links.first().addclass(o.classlinkactive); if(!$tabactive) { $tabactive = $linkactive ? gettab($linkactive) : $tabs.first(); $tabactive.addclass(o.classtabactive).show(); } if(o.event == 'mouseover') $links.on('click.tab', function(e) {return e.preventdefault();}); $links.on(o.event + '.tab', function(e) { if($(this).hasclass(o.classlinkactive)) return false; var $link = $(this), $tab = gettab($link); $linkactive.removeclass(o.classlinkactive); $linkactive = $link.addclass(o.classlinkactive); if(o.fxfade || o.fxresize) { $tab.createfx(); $tab.fx.startshow = $tab.fx.completehide = true; if(o.fxfade) $tab.fx.setfade(); if(o.fxresize) $tab.fx.set('height', $tabactive.height(), $tab.height()); if($tab.fx.issetin()) { if(o.fxfade) { $tabactive.fadeout(100, function() { switchtab($tab); $tab.fx.playin(o.fxduration, function($tab) { $tab.css({height: 'auto'}); }); }); }else { switchtab($tab); $tab.fx.playin(o.fxduration, function($tab) { $tab.css({height: 'auto'}); }); } } }else switchtab($tab); return false; }); function gettab($link) { var $tab = $($link.attr('href')); if($tab.length == 0) throw new error('[$.fn.tab] cannot find related tab. tab missing.'); return $tab; } function switchtab($tab) { if(o.preswitch) o.preswitch($tabactive, $tab); $tabactive.removeclass(o.classtabactive).hide(); $tab.addclass(o.classtabactive).show(); $tabactive = $tab; if(o.switchcomplete && typeof o.switchcomplete == 'function') o.switchcomplete($tabactive); } }; $.fn.tab.defaults = { autoattach: true, event: 'click', classlinks: 'tab-nav', classlink: 'tab-head', classlinkactive: 'tab-head-active', classtabs: 'tab-content', classtab: 'tab-sheet', classtabactive: 'tab-sheet-active', fxfade: false, fxresize: false, fxduration: 400 }; $.fn.list = function(options) { var o = $.extend({}, $.fn.list.defaults, options), $list = this, $lis = $list.children('li'), $licontentactive; $lis.each(function() { var $li = $(this), $lilinks = getlilink($li), $licontent = getlicontent($li); if($lilinks.hasclass(o.classitemlinkactive)) activate($lilinks); setfx($licontent); $lilinks.on('click.list', function(e) { var $link = $(this); if($link.hasclass(o.classitemlinkactive)) destroy($licontent); else { build($licontent); $link.addclass(o.classitemlinkactive); } e.preventdefault(); }); }); switch(o.selected) { case 'first': activate(getlilink($lis.first())); break; case 'last': activate(getlilink($lis.last())); break; case 'all': $lis.each(function() {activate(getlilink($(this)));}); break; } return $list; function build($licontent) { if(o.exclusive && !$licontent.is($licontentactive)) destroy($licontentactive); $licontentactive = $licontent.addclass(o.classitemcontentactive); $licontent.fx.playin(o.fxduration); } function destroy($licontent) { if($.u.exist($licontent)) { $licontent.removeclass(o.classitemcontentactive); $licontent.siblings('.' + o.classitemlink).removeclass(o.classitemlinkactive); if($licontent.fx.issetout()) $licontent.fx.playout(); else $licontent.hide(); } } function getlilink($li) { return $li.find('.' + o.classitemlink); } function getlicontent($e) { switch($e[0].tagname.tolowercase()) { case 'li': default: return $e.find('.' + o.classitemcontent); case 'a': return $e.siblings('.' + o.classitemcontent); } } function setfx($licontent) { $licontent.createfx(); $licontent.fx.startshow = $licontent.fx.completehide = true; if(o.fxfade) $licontent.fx.setfade(); if(o.fxfold) $licontent.fx.setfold('height', null, o.fxfolddynamic); } function activate($lilink) { $lilink.addclass(o.classitemlinkactive); $licontentactive = getlicontent($lilink).show(); setfx($licontentactive); } }; $.fn.list.defaults = { classlist: 'list', classitemlink: 'li-a', classitemlinkactive: 'li-a-active', classitemcontent: 'li-content', classitemcontentactive: 'li-content-active', exclusive: false, fxfade: false, fxfold: false, fxfolddynamic: false, fxduration: 300, selected: false } $.fn.tooltip = function(options) { var o = $.extend({}, $.fn.tooltip.defaults, options), $target = this, $tooltip, thistitle = $target.attr('title'), classtempdiv = 'ui-temp-div'; if(o.event == 'hover') $target.mouseover(build); else $target.click(function(e) { if($tooltip || $tooltip.hasclass(o.classtooltipactive)) destroy(e); else build(e); }); function build(e) { if(o.content) { if($.u.exist(o.content)) $tooltip = o.content; else if($.u.exist(o.content, 'string')) $tooltip = creatediv(o.content); else $.u.event.stop(e); }else { $tooltip = $target.find('.' + o.classtooltip); if($tooltip.length > 0) { var $btnclose = $tooltip.find('.' + o.classtooltipclose); if($btnclose.length > 0) $btnclose.unbind('click.tooltip').on('click.tooltip', destroy); }else { if(thistitle && thistitle.length > 0) $tooltip = creatediv(thistitle); else $.u.event.stop(e); } } if(o.context == 'global') $tooltip.pos(); if(thistitle) $target.attr('title', ''); $target.addclass(o.classtargetactive).off('mouseover').mouseout(destroy); $tooltip.addclass(o.classtooltipactive).mouseout(destroy); var x, y; if(o.follow) { $target.mousemove(function(e) { $tooltip.move(e.pagex + o.offsetx, e.pagey + o.offsety); $.u.event.stop(e); }); }else { var targetx = o.context != 'global' ? $target[0].offsetleft : $target.offset().left, targety = o.context != 'global' ? $target[0].offsettop : $target.offset().top, targetw = $target.width(), targeth = $target.height(), tooltipw = $tooltip.outerwidth(), tooltiph = $tooltip.outerheight(); switch(o.position) { case 'top': y = targety - tooltiph - o.offsety; break; case 'right': x = targetx + targetw + o.offsetx; break; case 'bottom': default: y = targety + targeth + o.offsety; break; case 'left': x = targetx - tooltipw - o.offsetx; break } if(/left|right/.test(o.position)) { switch(o.alignv) { case 'top': default: y = targety; break; case 'bottom': y = targety - (tooltiph - targeth); break; case 'center': y = targety - (tooltiph - targeth)/2; break; } }else { switch(o.alignh) { case 'left': default: x = targetx; break; case 'right': x = targetx - (tooltipw - targetw); break; case 'center': x = targetx - (tooltipw - targetw)/2; break; } } } $tooltip.move({ bleeding: true, x: math.round(x), y: math.round(y) }); if(o.fxfade || o.fxslide) { $tooltip.createfx(); $tooltip.fx.startshow = $tooltip.fx.completehide = true; if(o.fxfade) $tooltip.fx.setfade(); if(o.fxslide) { var halfw = math.round(tooltipw/2), halfh = math.round(tooltiph/2); switch(o.fxslidedir) { case 'up': $tooltip.fx.set('top', y + halfh, y); break; case 'right': $tooltip.fx.set('left', x - halfw, x); break; case 'down': default: $tooltip.fx.set('top', y - halfh, y); break; case 'left': $tooltip.fx.set('left', x + halfw, x); break; } } $tooltip.fx.playin(o.fxduration); }else { $tooltip.show(); } $.u.event.stop(e); } function creatediv(txt) { return $('
').addclass(o.classtooltip + ' ' + classtempdiv).text(txt) .append($('
')).append($('
')); } function destroy(event) { var $over = $(event.relatedtarget); if($over.hasclass(o.classtooltipactive)) return false; if($tooltip.fx && $tooltip.fx.issetout()) $tooltip.fx.playout(o.fxduration, clear); else { $tooltip.hide(); clear(); } } function clear() { $target.removeclass(o.classtargetactive).off('mouseout').mouseover(build); $tooltip.removeclass(o.classtooltipactive); if(thistitle) $target.attr('title', thistitle); if($tooltip.hasclass(classtempdiv)) $tooltip.remove(); } }; $.fn.tooltip.defaults = { alignh: 'left', alignv: 'top', classtooltip: 'tooltip', classtooltipactive: 'tooltip-active', classtooltipclose: 'tooltip-close', content: null, context: 'global', event: 'hover', follow: false, fxfade: false, fxslide: false, fxslidedir: 'down', fxduration: 300, offsetx: 10, offsety: 10, position: 'bottom' }; $.fn.draggable.defaults = { bleeding: true, scroll: false, view: null, trigger: null }; $.fn.rollover = function(options) { if(this.length == 0) return this; var o = $.extend({}, $.fn.rollover.defaults, options), $target = this, $active = $target.find('.' + o.classrolloveractive), targetw = $target.innerwidth(), targeth = $target.innerheight(), activew = $active.outerwidth(true), activeh = $active.outerheight(true); $target.css({overflow: 'hidden'}); $active.pos({offset: $target}).createfx(); $active.fx.startshow = $active.fx.complethide = true; if(o.fxfade) $active.fx.setfade(); if(o.fxslide) { switch(o.fxslidedir) { case 'top': $active.css({left: 0}).fx.set('bottom', -activeh, 0); break; case 'right': $active.css({top: 0}).fx.set('right', -activew, 0); break; case 'down': default: $active.css({left: 0}).fx.set('top', -activeh, 0); break; case 'left': $active.css({top: 0}).fx.set('left', -activew, 0); break; } } $target.hover(function(e) { build(); }, function(e) { destroy(); }); function build() { if($active.fx.issetin()) { if(!o.fxslide) $active.move(0, 0); $active.fx.playin(); }else $active.move(0, 0).show(); } function destroy() { if($active.fx.issetout()) $active.fx.playout(); else $active.hide(); } }; $.fn.rollover.defaults = { classrollover: 'ui-rollover', classrolloveractive: 'ui-rollover-active', fxfade: false, fxslide: false, fxslidedir: 'down' }; $.fn.inputinteger = function() { var $input = this; var ns = '.inputdate'; $input.on('keypress' + ns, function(event) { var char = string.fromcharcode(event.which); var int = '0123456789'; if(int.indexof(char) == -1) event.preventdefault(); }); }; $.fn.inputdate = function(options) { var o = $.extend({}, $.fn.inputdate.defaults, options); var $box = this.parent(); var $input = this; var $cal = o.update ? $box.find('.' + o.cls.calendar) : $('
').appendto($box); var val = $input.val(); var ns = '.inputdate'; if(val) { o.calendar.dateselected = val; o.calendar.datestart = 'selected'; $input.data('value', setdefaulttime(new date(val)).valueof()); } o.calendar.postselect = function(dateselected) { $input.val(formatdate(dateselected)); $input.data('value', dateselected.valueof()); hide(); if($.isfunction(o.postselect)) o.postselect(dateselected); }; $cal.empty().calendar(o.calendar); if(!o.update) { $cal.addclass(o.cls.calendar).hide(); $cal.css({ position: 'absolute', left: 0 }); if(!$.fn.inputdate._globalhide) { $('html').on('mousedown' + ns, function(event) { $('.' + o.cls.calendar).hide().parent().find('input').removeclass(o.cls.active); event.stoppropagation(); }); $.fn.inputdate._globalhide = true; } $box.on('mousedown' + ns, '*', function(event) { if($input.hasclass(o.cls.active)) return false; }); $input.on('click' + ns, function(event) { $(this).addclass(o.cls.active); show(); }); } function setdefaulttime(date) { date.sethours(12); date.setminutes(0); date.setseconds(0); date.setmilliseconds(0); return date; } function formatdate(date) { var mm = date.getmonth() + 1; var dd = date.getdate(); if(mm < 10) mm = '0' + mm; if(dd < 10) dd = '0' + dd; return date.getfullyear() + '-' + mm + '-' + dd; } function hide() { $cal.hide(); } function show() { var boxheight = $box.outerheight(); var scrollheight = $(window).scrolltop() + $(window).height(); var calheight = $box.offset().top + boxheight + $cal.outerheight(true); if(scrollheight > calheight) $cal.css({top: boxheight, bottom: 'auto'}); else $cal.css({top: 'auto', bottom: boxheight}); $cal.fadein('fast'); } }; $.fn.inputdate.defaults = { cls: { active: 'inputdate-active', calendar: 'calendar' }, calendar: {}, mode: 'drop', readonly: true, update: false }; $.fn.inputdate._globalhide = false; $.fn.calendar = function(options) { var o = $.extend(true, {}, $.fn.calendar.defaults, options); var $box = this; build(); return $box; function build() { var datetoday = getdatevalue(o.datetoday || new date()); var dateselected = o.dateselected ? getdatevalue(o.dateselected) : null; var datedynamic; if(o.datestart == 'today') datedynamic = new date(datetoday.valueof()); else if(o.datestart == 'selected' && dateselected instanceof date) datedynamic = new date(dateselected.valueof()); else datedynamic = getdatevalue(o.datestart || new date()); setdefaulttime(datetoday); setdefaulttime(dateselected); setdefaulttime(datedynamic); // control generate var $ctrl = $('
').addclass(o.cls.ctrl).appendto($box); if(o.yearbutton) $ctrl .append(getctrlbtn(o.text.prevyear, o.text.prevyeartitle, o.cls.btnprevyear)) .append(getctrlbtn(o.text.nextyear, o.text.nextyeartitle, o.cls.btnnextyear)); if(o.monthbutton) $ctrl .append(getctrlbtn(o.text.prevmonth, o.text.prevmonthtitle, o.cls.btnprevmonth)) .append(getctrlbtn(o.text.nextmonth, o.text.nextmonthtitle, o.cls.btnnextmonth)); var $strong = $('').appendto($ctrl); var $spanyear = $('').text(datedynamic.getfullyear()).addclass(o.cls.spanyear).appendto($strong); var $spanmonth = $('').addclass(o.cls.spanmonth).appendto($strong); if(o.monthselect) { var $select = $('