{"size": 6460, "ext": "js", "max_stars_repo_path": "public/js/plugin/x-editable/combodate.min.js", "max_stars_repo_name": "mysteryos/swift", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/js/plugin/x-editable/combodate.min.js", "max_issues_repo_name": "mysteryos/swift", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/js/plugin/x-editable/combodate.min.js", "max_forks_repo_name": "mysteryos/swift", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 807.5, "max_line_length": 6254, "alphanum_fraction": 0.6761609907}
/**
* Combodate - 1.0.7
* Dropdown date and time picker.
* Author: Vitaliy Potapov
* Project page: http://github.com/vitalets/combodate
* Copyright (c) 2012 Vitaliy Potapov. Released under MIT License.
**/
(function(e){var t=function(t,n){this.$element=e(t);if(!this.$element.is("input")){e.error("Combodate should be applied to INPUT element");return}this.options=e.extend({},e.fn.combodate.defaults,n,this.$element.data());this.init()};t.prototype={constructor:t,init:function(){this.map={day:["D","date"],month:["M","month"],year:["Y","year"],hour:["[Hh]","hours"],minute:["m","minutes"],second:["s","seconds"],ampm:["[Aa]",""]};this.$widget=e('<span class="combodate"></span>').html(this.getTemplate());this.initCombos();this.$widget.on("change","select",e.proxy(function(t){this.$element.val(this.getValue()).change();if(this.options.smartDays){if(e(t.target).is(".month")||e(t.target).is(".year")){this.fillCombo("day")}}},this));this.$widget.find("select").css("width","auto");this.$element.hide().after(this.$widget);this.setValue(this.$element.val()||this.options.value)},getTemplate:function(){var t=this.options.template;var n=this.options.customClass;e.each(this.map,function(e,n){n=n[0];var r=new RegExp(n+"+"),i=n.length>1?n.substring(1,2):n;t=t.replace(r,"{"+i+"}")});t=t.replace(/ /g,"&nbsp;");e.each(this.map,function(e,r){r=r[0];var i=r.length>1?r.substring(1,2):r;t=t.replace("{"+i+"}",'<select class="'+e+" "+n+'"></select>')});return t},initCombos:function(){for(var e in this.map){var t=this.$widget.find("."+e);this["$"+e]=t.length?t:null;this.fillCombo(e)}},fillCombo:function(e){var t=this["$"+e];if(!t){return}var n="fill"+e.charAt(0).toUpperCase()+e.slice(1);var r=this[n]();var i=t.val();t.empty();for(var s=0;s<r.length;s++){t.append('<option value="'+r[s][0]+'">'+r[s][1]+"</option>")}t.val(i)},fillCommon:function(e){var t=[],n;if(this.options.firstItem==="name"){n=moment.relativeTime||moment.langData()._relativeTime;var r=typeof n[e]==="function"?n[e](1,true,e,false):n[e];r=r.split(" ").reverse()[0];t.push(["",r])}else if(this.options.firstItem==="empty"){t.push(["",""])}return t},fillDay:function(){var e=this.fillCommon("d"),t,n,r=this.options.template.indexOf("DD")!==-1,i=31;if(this.options.smartDays&&this.$month&&this.$year){var s=parseInt(this.$month.val(),10);var o=parseInt(this.$year.val(),10);if(!isNaN(s)&&!isNaN(o)){i=moment([o,s]).daysInMonth()}}for(n=1;n<=i;n++){t=r?this.leadZero(n):n;e.push([n,t])}return e},fillMonth:function(){var e=this.fillCommon("M"),t,n,r=this.options.template.indexOf("MMMM")!==-1,i=this.options.template.indexOf("MMM")!==-1,s=this.options.template.indexOf("MM")!==-1;for(n=0;n<=11;n++){if(r){t=moment().date(1).month(n).format("MMMM")}else if(i){t=moment().date(1).month(n).format("MMM")}else if(s){t=this.leadZero(n+1)}else{t=n+1}e.push([n,t])}return e},fillYear:function(){var e=[],t,n,r=this.options.template.indexOf("YYYY")!==-1;for(n=this.options.maxYear;n>=this.options.minYear;n--){t=r?n:(n+"").substring(2);e[this.options.yearDescending?"push":"unshift"]([n,t])}e=this.fillCommon("y").concat(e);return e},fillHour:function(){var e=this.fillCommon("h"),t,n,r=this.options.template.indexOf("h")!==-1,i=this.options.template.indexOf("H")!==-1,s=this.options.template.toLowerCase().indexOf("hh")!==-1,o=r?1:0,u=r?12:23;for(n=o;n<=u;n++){t=s?this.leadZero(n):n;e.push([n,t])}return e},fillMinute:function(){var e=this.fillCommon("m"),t,n,r=this.options.template.indexOf("mm")!==-1;for(n=0;n<=59;n+=this.options.minuteStep){t=r?this.leadZero(n):n;e.push([n,t])}return e},fillSecond:function(){var e=this.fillCommon("s"),t,n,r=this.options.template.indexOf("ss")!==-1;for(n=0;n<=59;n+=this.options.secondStep){t=r?this.leadZero(n):n;e.push([n,t])}return e},fillAmpm:function(){var e=this.options.template.indexOf("a")!==-1,t=this.options.template.indexOf("A")!==-1,n=[["am",e?"am":"AM"],["pm",e?"pm":"PM"]];return n},getValue:function(t){var n,r={},i=this,s=false;e.each(this.map,function(e,t){if(e==="ampm"){return}var n=e==="day"?1:0;r[e]=i["$"+e]?parseInt(i["$"+e].val(),10):n;if(isNaN(r[e])){s=true;return false}});if(s){return""}if(this.$ampm){if(r.hour===12){r.hour=this.$ampm.val()==="am"?0:12}else{r.hour=this.$ampm.val()==="am"?r.hour:r.hour+12}}n=moment([r.year,r.month,r.day,r.hour,r.minute,r.second]);this.highlight(n);t=t===undefined?this.options.format:t;if(t===null){return n.isValid()?n:null}else{return n.isValid()?n.format(t):""}},setValue:function(t){function s(t,n){var r={};t.children("option").each(function(t,i){var s=e(i).attr("value"),o;if(s==="")return;o=Math.abs(s-n);if(typeof r.distance==="undefined"||o<r.distance){r={value:s,distance:o}}});return r.value}if(!t){return}var n=typeof t==="string"?moment(t,this.options.format,true):moment(t),r=this,i={};if(n.isValid()){e.each(this.map,function(e,t){if(e==="ampm"){return}i[e]=n[t[1]]()});if(this.$ampm){if(i.hour>=12){i.ampm="pm";if(i.hour>12){i.hour-=12}}else{i.ampm="am";if(i.hour===0){i.hour=12}}}e.each(i,function(e,t){if(r["$"+e]){if(e==="minute"&&r.options.minuteStep>1&&r.options.roundTime){t=s(r["$"+e],t)}if(e==="second"&&r.options.secondStep>1&&r.options.roundTime){t=s(r["$"+e],t)}r["$"+e].val(t)}});if(this.options.smartDays){this.fillCombo("day")}this.$element.val(n.format(this.options.format)).change()}},highlight:function(e){if(!e.isValid()){if(this.options.errorClass){this.$widget.addClass(this.options.errorClass)}else{if(!this.borderColor){this.borderColor=this.$widget.find("select").css("border-color")}this.$widget.find("select").css("border-color","red")}}else{if(this.options.errorClass){this.$widget.removeClass(this.options.errorClass)}else{this.$widget.find("select").css("border-color",this.borderColor)}}},leadZero:function(e){return e<=9?"0"+e:e},destroy:function(){this.$widget.remove();this.$element.removeData("combodate").show()}};e.fn.combodate=function(n){var r,i=Array.apply(null,arguments);i.shift();if(n==="getValue"&&this.length&&(r=this.eq(0).data("combodate"))){return r.getValue.apply(r,i)}return this.each(function(){var r=e(this),s=r.data("combodate"),o=typeof n=="object"&&n;if(!s){r.data("combodate",s=new t(this,o))}if(typeof n=="string"&&typeof s[n]=="function"){s[n].apply(s,i)}})};e.fn.combodate.defaults={format:"DD-MM-YYYY HH:mm",template:"D / MMM / YYYY   H : mm",value:null,minYear:1970,maxYear:2015,yearDescending:true,minuteStep:5,secondStep:1,firstItem:"empty",errorClass:null,customClass:"",roundTime:true,smartDays:false}})(window.jQuery)