fae-rails 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/fae/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fae
2
- VERSION = '1.2.2'
2
+ VERSION = '1.2.3'
3
3
  end
@@ -14,5 +14,5 @@
14
14
 
15
15
  <section>
16
16
  <h2>Documentation</h2>
17
- <p><%= link_to 'Technical Doumentation', 'https://bitbucket.org/wearefine/fae', target: '_blank' %></p>
17
+ <p><%= link_to 'Technical Doumentation', 'https://github.com/wearefine/fae', target: '_blank' %></p>
18
18
  </section>
@@ -0,0 +1,2 @@
1
+ /* Chosen v1.0.0 | (c) 2011-2013 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
2
+ !function(){var a,AbstractChosen,Chosen,SelectParser,b,c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(a){return"OPTGROUP"===a.nodeName.toUpperCase()?this.add_group(a):this.add_option(a)},SelectParser.prototype.add_group=function(a){var b,c,d,e,f,g;for(b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:this.escapeExpression(a.label),children:0,disabled:a.disabled}),f=a.childNodes,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},SelectParser.prototype.add_option=function(a,b,c){return"OPTION"===a.nodeName.toUpperCase()?(""!==a.text?(null!=b&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,classes:a.className,style:a.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1):void 0},SelectParser.prototype.escapeExpression=function(a){var b,c;return null==a||a===!1?"":/[\&\<\>\"\'\`]/.test(a)?(b={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},c=/&(?!\w+;)|[\<\>\"\'\`]/g,a.replace(c,function(a){return b[a]||"&amp;"})):a},SelectParser}(),SelectParser.select_to_array=function(a){var b,c,d,e,f;for(c=new SelectParser,f=a.childNodes,d=0,e=f.length;e>d;d++)b=f[d],c.add_node(b);return c.parsed},AbstractChosen=function(){function AbstractChosen(a,b){this.form_field=a,this.options=null!=b?b:{},AbstractChosen.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers())}return AbstractChosen.prototype.set_default_values=function(){var a=this;return this.click_test_action=function(b){return a.test_active_click(b)},this.activate_action=function(b){return a.activate_field(b)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.result_single_selected=null,this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null!=this.options.enable_split_word_search?this.options.enable_split_word_search:!0,this.group_search=null!=this.options.group_search?this.options.group_search:!0,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null!=this.options.single_backstroke_delete?this.options.single_backstroke_delete:!0,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null!=this.options.display_selected_options?this.options.display_selected_options:!0,this.display_disabled_options=null!=this.options.display_disabled_options?this.options.display_disabled_options:!0},AbstractChosen.prototype.set_default_text=function(){return this.default_text=this.form_field.getAttribute("data-placeholder")?this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.options.placeholder_text_multiple||this.options.placeholder_text||AbstractChosen.default_multiple_text:this.options.placeholder_text_single||this.options.placeholder_text||AbstractChosen.default_single_text,this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||AbstractChosen.default_no_result_text},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(){var a=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return a.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(){var a=this;return this.mouse_on_container?void 0:(this.active_field=!1,setTimeout(function(){return a.blur_test()},100))},AbstractChosen.prototype.results_option_build=function(a){var b,c,d,e,f;for(b="",f=this.results_data,d=0,e=f.length;e>d;d++)c=f[d],b+=c.group?this.result_add_group(c):this.result_add_option(c),(null!=a?a.first:void 0)&&(c.selected&&this.is_multiple?this.choice_build(c):c.selected&&!this.is_multiple&&this.single_set_selected_text(c.text));return b},AbstractChosen.prototype.result_add_option=function(a){var b,c;return a.search_match?this.include_option_in_results(a)?(b=[],a.disabled||a.selected&&this.is_multiple||b.push("active-result"),!a.disabled||a.selected&&this.is_multiple||b.push("disabled-result"),a.selected&&b.push("result-selected"),null!=a.group_array_index&&b.push("group-option"),""!==a.classes&&b.push(a.classes),c=""!==a.style.cssText?' style="'+a.style+'"':"",'<li class="'+b.join(" ")+'"'+c+' data-option-array-index="'+a.array_index+'">'+a.search_text+"</li>"):"":""},AbstractChosen.prototype.result_add_group=function(a){return a.search_match||a.group_match?a.active_options>0?'<li class="group-result">'+a.search_text+"</li>":"":""},AbstractChosen.prototype.results_update_field=function(){return this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.result_single_selected=null,this.results_build(),this.results_showing?this.winnow_results():void 0},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m;for(this.no_results_clear(),e=0,g=this.get_search_text(),a=g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),d=this.search_contains?"":"^",c=new RegExp(d+a,"i"),j=new RegExp(a,"i"),m=this.results_data,k=0,l=m.length;l>k;k++)b=m[k],b.search_match=!1,f=null,this.include_option_in_results(b)&&(b.group&&(b.group_match=!1,b.active_options=0),null!=b.group_array_index&&this.results_data[b.group_array_index]&&(f=this.results_data[b.group_array_index],0===f.active_options&&f.search_match&&(e+=1),f.active_options+=1),(!b.group||this.group_search)&&(b.search_text=b.group?b.label:b.html,b.search_match=this.search_string_match(b.search_text,c),b.search_match&&!b.group&&(e+=1),b.search_match?(g.length&&(h=b.search_text.search(j),i=b.search_text.substr(0,h+g.length)+"</em>"+b.search_text.substr(h+g.length),b.search_text=i.substr(0,h)+"<em>"+i.substr(h)),null!=f&&(f.group_match=!0)):null!=b.group_array_index&&this.results_data[b.group_array_index].search_match&&(b.search_match=!0)));return this.result_clear_highlight(),1>e&&g.length?(this.update_results_content(""),this.no_results(g)):(this.update_results_content(this.results_option_build()),this.winnow_results_set_highlight())},AbstractChosen.prototype.search_string_match=function(a,b){var c,d,e,f;if(b.test(a))return!0;if(this.enable_split_word_search&&(a.indexOf(" ")>=0||0===a.indexOf("["))&&(d=a.replace(/\[|\]/g,"").split(" "),d.length))for(e=0,f=d.length;f>e;e++)if(c=d[e],b.test(c))return!0},AbstractChosen.prototype.choices_count=function(){var a,b,c,d;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,d=this.form_field.options,b=0,c=d.length;c>b;b++)a=d[b],a.selected&&(this.selected_option_count+=1);return this.selected_option_count},AbstractChosen.prototype.choices_click=function(a){return a.preventDefault(),this.results_showing||this.is_disabled?void 0:this.results_show()},AbstractChosen.prototype.keyup_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:if(a.preventDefault(),this.results_showing)return this.result_select(a);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},AbstractChosen.prototype.container_width=function(){return null!=this.options.width?this.options.width:""+this.form_field.offsetWidth+"px"},AbstractChosen.prototype.include_option_in_results=function(a){return this.is_multiple&&!this.display_selected_options&&a.selected?!1:!this.display_disabled_options&&a.disabled?!1:a.empty?!1:!0},AbstractChosen.browser_is_supported=function(){return"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:/iP(od|hone)/i.test(window.navigator.userAgent)?!1:/Android/i.test(window.navigator.userAgent)&&/Mobile/i.test(window.navigator.userAgent)?!1:!0},AbstractChosen.default_multiple_text="Select Some Options",AbstractChosen.default_single_text="Select an Option",AbstractChosen.default_no_result_text="No results match",AbstractChosen}(),a=jQuery,a.fn.extend({chosen:function(b){return AbstractChosen.browser_is_supported()?this.each(function(){var c,d;c=a(this),d=c.data("chosen"),"destroy"===b&&d?d.destroy():d||c.data("chosen",new Chosen(this,b))}):this}}),Chosen=function(c){function Chosen(){return b=Chosen.__super__.constructor.apply(this,arguments)}return d(Chosen,c),Chosen.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex,this.is_rtl=this.form_field_jq.hasClass("chosen-rtl")},Chosen.prototype.set_up_html=function(){var b,c;return b=["chosen-container"],b.push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&b.push(this.form_field.className),this.is_rtl&&b.push("chosen-rtl"),c={"class":b.join(" "),style:"width: "+this.container_width()+";",title:this.form_field.title},this.form_field.id.length&&(c.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=a("<div />",c),this.is_multiple?this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="'+this.default_text+'" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>'):this.container.html('<a class="chosen-single chosen-default" tabindex="-1"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>'),this.form_field_jq.hide().after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.results_build(),this.set_tab_index(),this.set_label_behavior(),this.form_field_jq.trigger("chosen:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var a=this;return this.container.bind("mousedown.chosen",function(b){a.container_mousedown(b)}),this.container.bind("mouseup.chosen",function(b){a.container_mouseup(b)}),this.container.bind("mouseenter.chosen",function(b){a.mouse_enter(b)}),this.container.bind("mouseleave.chosen",function(b){a.mouse_leave(b)}),this.search_results.bind("mouseup.chosen",function(b){a.search_results_mouseup(b)}),this.search_results.bind("mouseover.chosen",function(b){a.search_results_mouseover(b)}),this.search_results.bind("mouseout.chosen",function(b){a.search_results_mouseout(b)}),this.search_results.bind("mousewheel.chosen DOMMouseScroll.chosen",function(b){a.search_results_mousewheel(b)}),this.form_field_jq.bind("chosen:updated.chosen",function(b){a.results_update_field(b)}),this.form_field_jq.bind("chosen:activate.chosen",function(b){a.activate_field(b)}),this.form_field_jq.bind("chosen:open.chosen",function(b){a.container_mousedown(b)}),this.search_field.bind("blur.chosen",function(b){a.input_blur(b)}),this.search_field.bind("keyup.chosen",function(b){a.keyup_checker(b)}),this.search_field.bind("keydown.chosen",function(b){a.keydown_checker(b)}),this.search_field.bind("focus.chosen",function(b){a.input_focus(b)}),this.is_multiple?this.search_choices.bind("click.chosen",function(b){a.choices_click(b)}):this.container.bind("click.chosen",function(a){a.preventDefault()})},Chosen.prototype.destroy=function(){return a(document).unbind("click.chosen",this.click_test_action),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()},Chosen.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field_jq[0].disabled,this.is_disabled?(this.container.addClass("chosen-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus.chosen",this.activate_action),this.close_field()):(this.container.removeClass("chosen-disabled"),this.search_field[0].disabled=!1,this.is_multiple?void 0:this.selected_item.bind("focus.chosen",this.activate_action))},Chosen.prototype.container_mousedown=function(b){return this.is_disabled||(b&&"mousedown"===b.type&&!this.results_showing&&b.preventDefault(),null!=b&&a(b.target).hasClass("search-choice-close"))?void 0:(this.active_field?this.is_multiple||!b||a(b.target)[0]!==this.selected_item[0]&&!a(b.target).parents("a.chosen-single").length||(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(document).bind("click.chosen",this.click_test_action),this.results_show()),this.activate_field())},Chosen.prototype.container_mouseup=function(a){return"ABBR"!==a.target.nodeName||this.is_disabled?void 0:this.results_reset(a)},Chosen.prototype.search_results_mousewheel=function(a){var b,c,d;return b=-(null!=(c=a.originalEvent)?c.wheelDelta:void 0)||(null!=(d=a.originialEvent)?d.detail:void 0),null!=b?(a.preventDefault(),"DOMMouseScroll"===a.type&&(b=40*b),this.search_results.scrollTop(b+this.search_results.scrollTop())):void 0},Chosen.prototype.blur_test=function(){return!this.active_field&&this.container.hasClass("chosen-container-active")?this.close_field():void 0},Chosen.prototype.close_field=function(){return a(document).unbind("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},Chosen.prototype.test_active_click=function(b){return this.container.is(a(b.target).closest(".chosen-container"))?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=SelectParser.select_to_array(this.form_field),this.is_multiple?this.search_choices.find("li.search-choice").remove():this.is_multiple||(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},Chosen.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){if(this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight(),b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(f>c)return this.search_results.scrollTop(c)}},Chosen.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},Chosen.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.container.addClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results())},Chosen.prototype.update_results_content=function(a){return this.search_results.html(a)},Chosen.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},Chosen.prototype.set_tab_index=function(){var a;return this.form_field.tabIndex?(a=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=a):void 0},Chosen.prototype.set_label_behavior=function(){var b=this;return this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=a("label[for='"+this.form_field.id+"']")),this.form_field_label.length>0?this.form_field_label.bind("click.chosen",function(a){return b.is_multiple?b.container_mousedown(a):b.activate_field()}):void 0},Chosen.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.val(this.default_text),this.search_field.addClass("default")):(this.search_field.val(""),this.search_field.removeClass("default"))},Chosen.prototype.search_results_mouseup=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c.length?(this.result_highlight=c,this.result_select(b),this.search_field.focus()):void 0},Chosen.prototype.search_results_mouseover=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c?this.result_do_highlight(c):void 0},Chosen.prototype.search_results_mouseout=function(b){return a(b.target).hasClass("active-result")?this.result_clear_highlight():void 0},Chosen.prototype.choice_build=function(b){var c,d,e=this;return c=a("<li />",{"class":"search-choice"}).html("<span>"+b.html+"</span>"),b.disabled?c.addClass("search-choice-disabled"):(d=a("<a />",{"class":"search-choice-close","data-option-array-index":b.array_index}),d.bind("click.chosen",function(a){return e.choice_destroy_link_click(a)}),c.append(d)),this.search_container.before(c)},Chosen.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),b.stopPropagation(),this.is_disabled?void 0:this.choice_destroy(a(b.target))},Chosen.prototype.choice_destroy=function(a){return this.result_deselect(a[0].getAttribute("data-option-array-index"))?(this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.search_field.val().length<1&&this.results_hide(),a.parents("li").first().remove(),this.search_field_scale()):void 0},Chosen.prototype.results_reset=function(){return this.form_field.options[0].selected=!0,this.selected_option_count=null,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.form_field_jq.trigger("change"),this.active_field?this.results_hide():void 0},Chosen.prototype.results_reset_cleanup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()},Chosen.prototype.result_select=function(a){var b,c,d;return this.result_highlight?(b=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?b.removeClass("active-result"):(this.result_single_selected&&(this.result_single_selected.removeClass("result-selected"),d=this.result_single_selected[0].getAttribute("data-option-array-index"),this.results_data[d].selected=!1),this.result_single_selected=b),b.addClass("result-selected"),c=this.results_data[b[0].getAttribute("data-option-array-index")],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(c):this.single_set_selected_text(c.text),(a.metaKey||a.ctrlKey)&&this.is_multiple||this.results_hide(),this.search_field.val(""),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.form_field_jq.trigger("change",{selected:this.form_field.options[c.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,this.search_field_scale())):void 0},Chosen.prototype.single_set_selected_text=function(a){return null==a&&(a=this.default_text),a===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").text(a)},Chosen.prototype.result_deselect=function(a){var b;return b=this.results_data[a],this.form_field.options[b.options_index].disabled?!1:(b.selected=!1,this.form_field.options[b.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.form_field_jq.trigger("change",{deselected:this.form_field.options[b.options_index].value}),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){return this.allow_single_deselect?(this.selected_item.find("abbr").length||this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>'),this.selected_item.addClass("chosen-single-with-deselect")):void 0},Chosen.prototype.get_search_text=function(){return this.search_field.val()===this.default_text?"":a("<div/>").text(a.trim(this.search_field.val())).html()},Chosen.prototype.winnow_results_set_highlight=function(){var a,b;return b=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),a=b.length?b.first():this.search_results.find(".active-result").first(),null!=a?this.result_do_highlight(a):void 0},Chosen.prototype.no_results=function(b){var c;return c=a('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),c.find("span").first().html(b),this.search_results.append(c)},Chosen.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},Chosen.prototype.keydown_arrow=function(){var a;return this.results_showing&&this.result_highlight?(a=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(a):void 0:this.results_show()},Chosen.prototype.keyup_arrow=function(){var a;return this.results_showing||this.is_multiple?this.result_highlight?(a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight())):void 0:this.results_show()},Chosen.prototype.keydown_backstroke=function(){var a;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(a=this.search_container.siblings("li.search-choice").last(),a.length&&!a.hasClass("search-choice-disabled")?(this.pending_backstroke=a,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0)},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),8!==b&&this.pending_backstroke&&this.clear_backstroke(),b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:a.preventDefault(),this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){for(d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"],i=0,j=g.length;j>i;i++)e=g[i],f+=e+":"+this.search_field.css(e)+";";return b=a("<div />",{style:f}),b.text(this.search_field.val()),a("body").append(b),h=b.width()+25,b.remove(),c=this.container.outerWidth(),h>c-10&&(h=c-10),this.search_field.css({width:h+"px"})}},Chosen}(AbstractChosen)}.call(this);
@@ -0,0 +1,331 @@
1
+ 'use strict';
2
+
3
+ function Grinder(callback) {
4
+ return this.init(callback);
5
+ }
6
+
7
+ (function () {
8
+
9
+ /**
10
+ * @private
11
+ * @function removeValue - delete value based on key
12
+ * @param {string} key - param to target
13
+ * @param {mixed} value - value to delete from param
14
+ */
15
+ var removeValue = function(key, value) {
16
+ var hash = window.location.hash;
17
+ // check for key, anything between key and value, the value itself, and optionally the trailing comma
18
+ var regex_for_value = new RegExp('(' + key + '=.*)(' + value + '\,?)');
19
+ // results come back [<search through value>, <search before value>, <value>]
20
+ var regex_match = hash.match(regex_for_value);
21
+ // replace <search through value> with everything before <value>
22
+ // Key is included in search in case multiple keys have the same value
23
+ hash = hash.replace(regex_match[0], regex_match[1]);
24
+
25
+ // Remove trailing commas
26
+ hash = hash.replace(/\,\&/g, '&');
27
+ hash = hash.replace(/\,$/, '');
28
+ hash = hash.replace(/\=\,/g, '=');
29
+
30
+ window.location.hash = hash;
31
+ };
32
+
33
+ /**
34
+ * @private
35
+ * @function addValue - add value based on key
36
+ * @param {string} key - param to target
37
+ * @param {mixed} value - value to add to param
38
+ * @param {optional boolean} should_replace_value - if false, value will be appended to the param
39
+ */
40
+ var addValue = function(key, value, should_replace_value) {
41
+ var hash = window.location.hash;
42
+
43
+ var old_value = param(key);
44
+ var new_value;
45
+
46
+ // If it's blank or is the value of the next param
47
+ if(old_value.charAt(0) === '&' || old_value === '') {
48
+ old_value = key + '=';
49
+ new_value = old_value + value;
50
+
51
+ } else {
52
+ old_value = key + '=' + old_value;
53
+
54
+ // If the value of the param should be replaced, don't append it to the existing value
55
+ new_value = should_replace_value ? (key + '=' + value) : (old_value + ',' + value);
56
+ }
57
+
58
+ hash = hash.replace(old_value, new_value);
59
+
60
+ window.location.hash = hash;
61
+ };
62
+
63
+ /**
64
+ * @private
65
+ * @function removeKey - remove key from hash. Key's value must be removed prior to executing this function
66
+ * @param {string} key - key to search and destroy
67
+ */
68
+ var removeKey = function(key) {
69
+ var hash = window.location.hash;
70
+ var key_search = new RegExp('[?&]' + key + '=', 'g');
71
+
72
+ hash = hash.replace(key_search, '');
73
+ // if initial key removed, replace ampersand with question
74
+ hash = hash.replace('#&', '#?');
75
+
76
+ window.location.hash = hash;
77
+ }
78
+
79
+ /**
80
+ * @private
81
+ * @see documentation in the public `param` function
82
+ */
83
+ var param = function(key) {
84
+ if(!window.location.hash) {
85
+ return '';
86
+ }
87
+ var hash = window.location.hash;
88
+ var search = new RegExp('#.*[?&]' + key + '=([^&]+)(&|$)');
89
+ var key_value = hash.match(search);
90
+
91
+ return (key_value ? key_value[1] : '');
92
+ };
93
+
94
+ /**
95
+ * @private
96
+ * @function setDefault - Apply value to variable if it has none
97
+ * @param {var} variable - variable to set default to
98
+ * @param {anything} value - default value to attribute to variable
99
+ */
100
+ var setDefault = function(variable, value){
101
+ return (typeof variable === 'undefined') ? value : variable;
102
+ };
103
+
104
+
105
+ Grinder.prototype = {
106
+
107
+ // Very important object holder
108
+ params: {},
109
+
110
+ /**
111
+ * @function init - call once to initialize filtering
112
+ * @param {func} hashChangeCallback - called on every hashchange (first argument is the updated params)
113
+ */
114
+ init: function(hashChangeCallback) {
115
+ var _this = this;
116
+
117
+ var privateHashChange = function() {
118
+ var params = _this.parse();
119
+ hashChangeCallback.call(this, params);
120
+ };
121
+
122
+ window.onhashchange = privateHashChange;
123
+
124
+ privateHashChange();
125
+
126
+ return this;
127
+
128
+ },
129
+
130
+ /**
131
+ * @function update - remove key/value if present in hash; add key/value if not present in hash
132
+ * @param {string} key - param key to query against
133
+ * @param {mixed} value - value for param key
134
+ * @param {optional boolean} key_is_required {false} - if the key is not required, it will be removed from the hash
135
+ * @param {optional boolean} should_replace_value {false} - if false, value will be appended to the key
136
+ */
137
+ update: function(key, value, key_is_required, should_replace_value) {
138
+ var hash = window.location.hash;
139
+ key_is_required = setDefault(key_is_required, false);
140
+ should_replace_value = setDefault(should_replace_value, false);
141
+
142
+ // Ensure key exists in the hash
143
+ if(hash.indexOf(key) !== -1) {
144
+ var key_value = param(key);
145
+
146
+ var regex_for_value = new RegExp(value, 'g');
147
+
148
+ // If key_value contains the new value
149
+ if(regex_for_value.test(key_value)) {
150
+
151
+ // If key is required, swap it out
152
+ if(key_is_required) {
153
+ addValue(key, value, should_replace_value);
154
+
155
+ } else {
156
+
157
+ // If the value is blank, remove the original value from the key
158
+ if(value === '') {
159
+ removeValue(key, key_value);
160
+
161
+ // Otherwise remove the vanilla value
162
+ } else {
163
+ removeValue(key, value);
164
+
165
+ }
166
+
167
+ // If key's value is blank, remove it from hash
168
+ if(param(key) === '') {
169
+ removeKey(key);
170
+ }
171
+
172
+ }
173
+
174
+ // key_value does not contain the new value
175
+ } else {
176
+ addValue(key, value, should_replace_value);
177
+
178
+ }
179
+
180
+ // Add key if it doesn't exist
181
+ } else {
182
+
183
+ if(window.location.hash) {
184
+ window.location.hash += '&' + key + '=' + value;
185
+ } else {
186
+ // Use a question mark if first key
187
+ window.location.hash = '?' + key + '=' + value;
188
+ }
189
+
190
+ }
191
+
192
+ // Log it to the history
193
+ if (window.history && window.history.pushState) {
194
+ window.history.pushState(null, null, window.location.hash);
195
+ }
196
+
197
+ },
198
+
199
+ /**
200
+ * @function parse - evaluate the hash
201
+ * @return key/value hash of the hash broken down by params
202
+ */
203
+ parse: function() {
204
+ var hash = window.location.hash;
205
+ var params;
206
+
207
+ // clear zombie keys and values
208
+ this.params = {};
209
+
210
+ if(window.location.hash && /\?/g.test(hash)) {
211
+ params = hash.split('?')[1];
212
+ params = params.split('&');
213
+
214
+ // Separate params into key values
215
+ for(var i = 0; i < params.length; i++) {
216
+ var key_value = params[i].split('=');
217
+ var key = key_value[0];
218
+ var value = key_value[1];
219
+
220
+ this.params[key] = value;
221
+ }
222
+ }
223
+
224
+ return this.params;
225
+ },
226
+
227
+ /**
228
+ * @function convert - change a JSON object into a string for the hash
229
+ * @param {object | string} obj - object to convert
230
+ * @return {string | boolean} to use in window.location.hash. Returns false if param is not object or string
231
+ */
232
+ convert: function(obj) {
233
+ if( obj.constructor === String ) {
234
+ obj = JSON.parse(obj);
235
+ }
236
+
237
+ // Escape if we're not dealing with an object
238
+ if( obj.constructor !== Object ) {
239
+ return false;
240
+ }
241
+
242
+ var keys = Object.keys(obj);
243
+ // Set start with a ?
244
+ var new_hash = '?';
245
+
246
+ // Loop through all keys in the obj
247
+ for(var i = 0; i < keys.length; i++) {
248
+ var key = keys[i];
249
+ var value = obj[keys[i]];
250
+
251
+ if( value.constructor === Array ) {
252
+ value = value.join(',');
253
+ }
254
+
255
+ // On next key, if it isn't the first, precede with an ampersand
256
+ if(new_hash !== '?') {
257
+ new_hash += '&';
258
+ }
259
+
260
+ // Append key/value to new_hash
261
+ new_hash += key + '=' + value;
262
+ }
263
+
264
+ return new_hash;
265
+ },
266
+
267
+ /**
268
+ * @function merge - wipe out or selectively replace keys in params
269
+ * @param {object | string} obj - query to replace
270
+ * @param {boolean} replace_all {false} - whether or not to blast existing params away or replace only changed keys
271
+ * @return {string} but also updates hash
272
+ */
273
+ merge: function(obj, replace_all) {
274
+ replace_all = setDefault(replace_all, false);
275
+ var new_hash;
276
+
277
+ // If it's a string, convert to an object
278
+ if( obj.constructor === String ) {
279
+ obj = JSON.parse(obj);
280
+ }
281
+
282
+ if( replace_all ) {
283
+ // Unilaterally make a string based on the params to use
284
+ new_hash = this.convert(obj);
285
+
286
+ } else {
287
+ var new_params = this.parse();
288
+ var keys = Object.keys(new_params);
289
+
290
+ for(var i = 0; i < keys.length; i++) {
291
+ var key = keys[i];
292
+ var value = new_params[key[i]];
293
+
294
+ if(obj.hasOwnProperty(key)) {
295
+ new_params[key] = obj[key];
296
+ }
297
+ }
298
+
299
+ new_hash = this.convert(new_params);
300
+ }
301
+
302
+ window.location.hash = '#' + new_hash;
303
+
304
+ return new_hash;
305
+ },
306
+
307
+ /**
308
+ * @function param - retrieve a key's value
309
+ * @param {string} key - param to target
310
+ * @example
311
+ * window.location.hash = ?color=blue
312
+ * grinder.param('color') // => 'blue'
313
+ * @return {string} the value of the key
314
+ */
315
+ param: function(key) {
316
+ return param(key);
317
+ },
318
+
319
+ /**
320
+ * @function paramPresent - determine if param is blank or undefined
321
+ * @param {string} key - param to target
322
+ * @return boolean
323
+ */
324
+ paramPresent: function(key) {
325
+ var value = this.params[key];
326
+ return (typeof value !== 'undefined' && value !== '');
327
+ },
328
+
329
+ };
330
+
331
+ })();
@@ -0,0 +1,7 @@
1
+ (function(m,j){function q(a,c){var f=a.createElement("p"),b=a.getElementsByTagName("head")[0]||a.documentElement;f.innerHTML="x<style>"+c+"</style>";return b.insertBefore(f.lastChild,b.firstChild)}function n(){var a=k.elements;return"string"==typeof a?a.split(" "):a}function u(a){var c={},f=a.createElement,b=a.createDocumentFragment,d=b();a.createElement=function(a){if(!k.shivMethods)return f(a);var e;e=c[a]?c[a].cloneNode():v.test(a)?(c[a]=f(a)).cloneNode():f(a);return e.canHaveChildren&&!w.test(a)?
2
+ d.appendChild(e):e};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+n().join().replace(/\w+/g,function(a){f(a);d.createElement(a);return'c("'+a+'")'})+");return n}")(k,d)}function r(a){var c;if(a.documentShived)return a;k.shivCSS&&!s&&(c=!!q(a,"article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}mark{background:#FF0;color:#000}"));o||(c=!u(a));if(c)a.documentShived=c;return a}function x(a){for(var c,f=a.attributes,
3
+ b=f.length,d=a.ownerDocument.createElement(l+":"+a.nodeName);b--;)c=f[b],c.specified&&d.setAttribute(c.nodeName,c.nodeValue);d.style.cssText=a.style.cssText;return d}function t(a){var c,f,b=a.namespaces,d=a.parentWindow;if(!y||a.printShived)return a;"undefined"==typeof b[l]&&b.add(l);d.attachEvent("onbeforeprint",function(){var g,e,i;i=a.styleSheets;for(var b=[],h=i.length,d=Array(h);h--;)d[h]=i[h];for(;i=d.pop();)if(!i.disabled&&z.test(i.media)){try{g=i.imports,e=g.length}catch(j){e=0}for(h=0;h<
4
+ e;h++)d.push(g[h]);try{b.push(i.cssText)}catch(k){}}g=b.reverse().join("").split("{");e=g.length;h=RegExp("(^|[\\s,>+~])("+n().join("|")+")(?=[[\\s,>+~#.:]|$)","gi");for(d="$1"+l+"\\:$2";e--;)b=g[e]=g[e].split("}"),b[b.length-1]=b[b.length-1].replace(h,d),g[e]=b.join("}");b=g.join("{");e=a.getElementsByTagName("*");h=e.length;d=RegExp("^(?:"+n().join("|")+")$","i");for(i=[];h--;)g=e[h],d.test(g.nodeName)&&i.push(g.applyElement(x(g)));f=i;c=q(a,b)});d.attachEvent("onafterprint",function(){for(var a=
5
+ f,b=a.length;b--;)a[b].removeNode();c.removeNode(!0)});a.printShived=!0;return a}var p=m.html5||{},w=/^<|^(?:button|form|map|select|textarea|object|iframe|option|optgroup)$/i,v=/^<|^(?:a|b|button|code|div|fieldset|form|h1|h2|h3|h4|h5|h6|i|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul)$/i,s,o;(function(){var a=j.createElement("a");a.innerHTML="<xyz></xyz>";s="hidden"in a;if(!(a=1==a.childNodes.length))a:{try{j.createElement("a")}catch(c){a=
6
+ !0;break a}a=j.createDocumentFragment();a="undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}o=a})();var k={elements:p.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:!1!==p.shivCSS,shivMethods:!1!==p.shivMethods,type:"default",shivDocument:r};m.html5=k;r(j);var z=/^$|\b(?:all|print)\b/,l="html5shiv",y=!o&&function(){var a=
7
+ j.documentElement;return!("undefined"==typeof j.namespaces||"undefined"==typeof j.parentWindow||"undefined"==typeof a.applyElement||"undefined"==typeof a.removeNode||"undefined"==typeof m.attachEvent)}();k.type+=" print";k.shivPrint=t;t(j)})(this,document);
@@ -0,0 +1,4 @@
1
+ (function(g,b){function k(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function l(a){var c={},f=a.createElement,b=a.createDocumentFragment,d=b();a.createElement=function(a){if(!e.shivMethods)return f(a);var b;b=c[a]?c[a].cloneNode():m.test(a)?(c[a]=f(a)).cloneNode():f(a);return b.canHaveChildren&&!n.test(a)?d.appendChild(b):b};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+k().join().replace(/\w+/g,function(a){f(a);
2
+ d.createElement(a);return'c("'+a+'")'})+");return n}")(e,d)}function h(a){var c;if(a.documentShived)return a;if(e.shivCSS&&!i){c=a.createElement("p");var b=a.getElementsByTagName("head")[0]||a.documentElement;c.innerHTML="x<style>article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}mark{background:#FF0;color:#000}</style>";c=!!b.insertBefore(c.lastChild,b.firstChild)}j||(c=!l(a));if(c)a.documentShived=c;return a}var d=g.html5||{},n=/^<|^(?:button|form|map|select|textarea|object|iframe|option|optgroup)$/i,
3
+ m=/^<|^(?:a|b|button|code|div|fieldset|form|h1|h2|h3|h4|h5|h6|i|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul)$/i,i,j;(function(){var a=b.createElement("a");a.innerHTML="<xyz></xyz>";i="hidden"in a;if(!(a=1==a.childNodes.length))a:{try{b.createElement("a")}catch(c){a=!0;break a}a=b.createDocumentFragment();a="undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}j=
4
+ a})();var e={elements:d.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:!1!==d.shivCSS,shivMethods:!1!==d.shivMethods,type:"default",shivDocument:h};g.html5=e;h(b)})(this,document);
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * imagesLoaded PACKAGED v3.1.4
3
+ * JavaScript is all like "You images are done yet or what?"
4
+ * MIT License
5
+ */
6
+
7
+ (function(){function e(){}function t(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var i=e.prototype,r=this,o=r.EventEmitter;i.getListeners=function(e){var t,n,i=this._getEvents();if("object"==typeof e){t={};for(n in i)i.hasOwnProperty(n)&&e.test(n)&&(t[n]=i[n])}else t=i[e]||(i[e]=[]);return t},i.flattenListeners=function(e){var t,n=[];for(t=0;e.length>t;t+=1)n.push(e[t].listener);return n},i.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},i.addListener=function(e,n){var i,r=this.getListenersAsObject(e),o="object"==typeof n;for(i in r)r.hasOwnProperty(i)&&-1===t(r[i],n)&&r[i].push(o?n:{listener:n,once:!1});return this},i.on=n("addListener"),i.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},i.once=n("addOnceListener"),i.defineEvent=function(e){return this.getListeners(e),this},i.defineEvents=function(e){for(var t=0;e.length>t;t+=1)this.defineEvent(e[t]);return this},i.removeListener=function(e,n){var i,r,o=this.getListenersAsObject(e);for(r in o)o.hasOwnProperty(r)&&(i=t(o[r],n),-1!==i&&o[r].splice(i,1));return this},i.off=n("removeListener"),i.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},i.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},i.manipulateListeners=function(e,t,n){var i,r,o=e?this.removeListener:this.addListener,s=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(i=n.length;i--;)o.call(this,t,n[i]);else for(i in t)t.hasOwnProperty(i)&&(r=t[i])&&("function"==typeof r?o.call(this,i,r):s.call(this,i,r));return this},i.removeEvent=function(e){var t,n=typeof e,i=this._getEvents();if("string"===n)delete i[e];else if("object"===n)for(t in i)i.hasOwnProperty(t)&&e.test(t)&&delete i[t];else delete this._events;return this},i.removeAllListeners=n("removeEvent"),i.emitEvent=function(e,t){var n,i,r,o,s=this.getListenersAsObject(e);for(r in s)if(s.hasOwnProperty(r))for(i=s[r].length;i--;)n=s[r][i],n.once===!0&&this.removeListener(e,n.listener),o=n.listener.apply(this,t||[]),o===this._getOnceReturnValue()&&this.removeListener(e,n.listener);return this},i.trigger=n("emitEvent"),i.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},i.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},i._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},i._getEvents=function(){return this._events||(this._events={})},e.noConflict=function(){return r.EventEmitter=o,e},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return e}):"object"==typeof module&&module.exports?module.exports=e:this.EventEmitter=e}).call(this),function(e){function t(t){var n=e.event;return n.target=n.target||n.srcElement||t,n}var n=document.documentElement,i=function(){};n.addEventListener?i=function(e,t,n){e.addEventListener(t,n,!1)}:n.attachEvent&&(i=function(e,n,i){e[n+i]=i.handleEvent?function(){var n=t(e);i.handleEvent.call(i,n)}:function(){var n=t(e);i.call(e,n)},e.attachEvent("on"+n,e[n+i])});var r=function(){};n.removeEventListener?r=function(e,t,n){e.removeEventListener(t,n,!1)}:n.detachEvent&&(r=function(e,t,n){e.detachEvent("on"+t,e[t+n]);try{delete e[t+n]}catch(i){e[t+n]=void 0}});var o={bind:i,unbind:r};"function"==typeof define&&define.amd?define("eventie/eventie",o):e.eventie=o}(this),function(e,t){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,i){return t(e,n,i)}):"object"==typeof exports?module.exports=t(e,require("eventEmitter"),require("eventie")):e.imagesLoaded=t(e,e.EventEmitter,e.eventie)}(this,function(e,t,n){function i(e,t){for(var n in t)e[n]=t[n];return e}function r(e){return"[object Array]"===d.call(e)}function o(e){var t=[];if(r(e))t=e;else if("number"==typeof e.length)for(var n=0,i=e.length;i>n;n++)t.push(e[n]);else t.push(e);return t}function s(e,t,n){if(!(this instanceof s))return new s(e,t);"string"==typeof e&&(e=document.querySelectorAll(e)),this.elements=o(e),this.options=i({},this.options),"function"==typeof t?n=t:i(this.options,t),n&&this.on("always",n),this.getImages(),a&&(this.jqDeferred=new a.Deferred);var r=this;setTimeout(function(){r.check()})}function c(e){this.img=e}function f(e){this.src=e,v[e]=this}var a=e.jQuery,u=e.console,h=u!==void 0,d=Object.prototype.toString;s.prototype=new t,s.prototype.options={},s.prototype.getImages=function(){this.images=[];for(var e=0,t=this.elements.length;t>e;e++){var n=this.elements[e];"IMG"===n.nodeName&&this.addImage(n);for(var i=n.querySelectorAll("img"),r=0,o=i.length;o>r;r++){var s=i[r];this.addImage(s)}}},s.prototype.addImage=function(e){var t=new c(e);this.images.push(t)},s.prototype.check=function(){function e(e,r){return t.options.debug&&h&&u.log("confirm",e,r),t.progress(e),n++,n===i&&t.complete(),!0}var t=this,n=0,i=this.images.length;if(this.hasAnyBroken=!1,!i)return this.complete(),void 0;for(var r=0;i>r;r++){var o=this.images[r];o.on("confirm",e),o.check()}},s.prototype.progress=function(e){this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded;var t=this;setTimeout(function(){t.emit("progress",t,e),t.jqDeferred&&t.jqDeferred.notify&&t.jqDeferred.notify(t,e)})},s.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var t=this;setTimeout(function(){if(t.emit(e,t),t.emit("always",t),t.jqDeferred){var n=t.hasAnyBroken?"reject":"resolve";t.jqDeferred[n](t)}})},a&&(a.fn.imagesLoaded=function(e,t){var n=new s(this,e,t);return n.jqDeferred.promise(a(this))}),c.prototype=new t,c.prototype.check=function(){var e=v[this.img.src]||new f(this.img.src);if(e.isConfirmed)return this.confirm(e.isLoaded,"cached was confirmed"),void 0;if(this.img.complete&&void 0!==this.img.naturalWidth)return this.confirm(0!==this.img.naturalWidth,"naturalWidth"),void 0;var t=this;e.on("confirm",function(e,n){return t.confirm(e.isLoaded,n),!0}),e.check()},c.prototype.confirm=function(e,t){this.isLoaded=e,this.emit("confirm",this,t)};var v={};return f.prototype=new t,f.prototype.check=function(){if(!this.isChecked){var e=new Image;n.bind(e,"load",this),n.bind(e,"error",this),e.src=this.src,this.isChecked=!0}},f.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},f.prototype.onload=function(e){this.confirm(!0,"onload"),this.unbindProxyEvents(e)},f.prototype.onerror=function(e){this.confirm(!1,"onerror"),this.unbindProxyEvents(e)},f.prototype.confirm=function(e,t){this.isConfirmed=!0,this.isLoaded=e,this.emit("confirm",this,t)},f.prototype.unbindProxyEvents=function(e){n.unbind(e.target,"load",this),n.unbind(e.target,"error",this)},s});
@@ -0,0 +1,1292 @@
1
+ // daterangepicker.js
2
+ // version : 0.0.5
3
+ // author : Chunlong Liu
4
+ // last updated at: 2014-05-27
5
+ // license : MIT
6
+ // www.jszen.com
7
+
8
+ (function($)
9
+ {
10
+
11
+ $.dateRangePickerLanguages =
12
+ {
13
+ 'cn':
14
+ {
15
+ 'selected': '已选择:',
16
+ 'day':'天',
17
+ 'days': '天',
18
+ 'apply': '确定',
19
+ 'week-1' : '一',
20
+ 'week-2' : '二',
21
+ 'week-3' : '三',
22
+ 'week-4' : '四',
23
+ 'week-5' : '五',
24
+ 'week-6' : '六',
25
+ 'week-7' : '日',
26
+ 'month-name': ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
27
+ 'shortcuts' : '快捷选择',
28
+ 'past': '过去',
29
+ 'following':'将来',
30
+ 'previous' : '&nbsp;&nbsp;&nbsp;',
31
+ 'prev-week' : '上周',
32
+ 'prev-month' : '上个月',
33
+ 'prev-year' : '去年',
34
+ 'next': '&nbsp;&nbsp;&nbsp;',
35
+ 'next-week':'下周',
36
+ 'next-month':'下个月',
37
+ 'next-year':'明年',
38
+ 'less-than' : '所选日期范围不能大于%d天',
39
+ 'more-than' : '所选日期范围不能小于%d天',
40
+ 'default-more' : '请选择大于%d天的日期范围',
41
+ 'default-less' : '请选择小于%d天的日期范围',
42
+ 'default-range' : '请选择%d天到%d天的日期范围',
43
+ 'default-single':'请选择一个日期',
44
+ 'default-default': '请选择一个日期范围'
45
+ },
46
+ 'en':
47
+ {
48
+ 'selected': 'Selected:',
49
+ 'day':'Day',
50
+ 'days': 'Days',
51
+ 'apply': 'Close',
52
+ 'week-1' : 'MO',
53
+ 'week-2' : 'TU',
54
+ 'week-3' : 'WE',
55
+ 'week-4' : 'TH',
56
+ 'week-5' : 'FR',
57
+ 'week-6' : 'SA',
58
+ 'week-7' : 'SU',
59
+ 'month-name': ['JANUARY','FEBRUARY','MARCH','APRIL','MAY','JUNE','JULY','AUGUST','SEPTEMBER','OCTOBER','NOVEMBER','DECEMBER'],
60
+ 'shortcuts' : 'Shortcuts',
61
+ 'past': 'Past',
62
+ 'following':'Following',
63
+ 'previous' : 'Previous',
64
+ 'prev-week' : 'Week',
65
+ 'prev-month' : 'Month',
66
+ 'prev-year' : 'Year',
67
+ 'next':'Next',
68
+ 'next-week':'Week',
69
+ 'next-month':'Month',
70
+ 'next-year':'Year',
71
+ 'less-than' : 'Date range should not be more than %d days',
72
+ 'more-than' : 'Date range should not be less than %d days',
73
+ 'default-more' : 'Please select a date range longer than %d days',
74
+ 'default-single' : 'Please select a date',
75
+ 'default-less' : 'Please select a date range less than %d days',
76
+ 'default-range' : 'Please select a date range between %d and %d days',
77
+ 'default-default': 'Please select a date range'
78
+ },
79
+ 'it':
80
+ {
81
+ 'selected': 'Selezionati:',
82
+ 'day':'Giorno',
83
+ 'days': 'Giorni',
84
+ 'apply': 'Chiudi',
85
+ 'week-1' : 'LU',
86
+ 'week-2' : 'MA',
87
+ 'week-3' : 'ME',
88
+ 'week-4' : 'GI',
89
+ 'week-5' : 'VE',
90
+ 'week-6' : 'SA',
91
+ 'week-7' : 'DO',
92
+ 'month-name': ['GENNAIO','FEBBRAIO','MARZO','APRILE','MAGGIO','GIUGNO','LUGLIO','AGOSTO','SETTEMBRE','OTTOBRE','NOVEMBRE','DICEMBRE'],
93
+ 'shortcuts' : 'Scorciatoie',
94
+ 'past': 'Scorso',
95
+ 'following':'Successivo',
96
+ 'previous' : 'Precedente',
97
+ 'prev-week' : 'Settimana',
98
+ 'prev-month' : 'Mese',
99
+ 'prev-year' : 'Anno',
100
+ 'next':'Prossimo',
101
+ 'next-week':'Settimana',
102
+ 'next-month':'Mese',
103
+ 'next-year':'Anno',
104
+ 'less-than' : 'L\'intervallo non dev\'essere maggiore di %d giorni',
105
+ 'more-than' : 'L\'intervallo non dev\'essere minore di %d giorni',
106
+ 'default-more' : 'Seleziona un intervallo maggiore di %d giorni',
107
+ 'default-single' : 'Seleziona una data',
108
+ 'default-less' : 'Seleziona un intervallo minore di %d giorni',
109
+ 'default-range' : 'Seleziona un intervallo compreso tra i %d e i %d giorni',
110
+ 'default-default': 'Seleziona un intervallo di date'
111
+ },
112
+ 'es':
113
+ {
114
+ 'selected': 'Seleccionado:',
115
+ 'day':'Dia',
116
+ 'days': 'Dias',
117
+ 'apply': 'Cerrar',
118
+ 'week-1' : 'LU',
119
+ 'week-2' : 'MA',
120
+ 'week-3' : 'MI',
121
+ 'week-4' : 'JU',
122
+ 'week-5' : 'VI',
123
+ 'week-6' : 'SA',
124
+ 'week-7' : 'DO',
125
+ 'month-name': ['ENERO','FEBRERO','MARZO','ABRIL','MAYO','JUNIO','JULIO','AGOSTO','SEPTIEMBRE','OCTUBRE','NOVIEMBRE','DICIEMBRE'],
126
+ 'shortcuts' : 'Accesos directos',
127
+ 'past': 'Pasado',
128
+ 'following':'Siguiente',
129
+ 'previous' : 'Anterior',
130
+ 'prev-week' : 'Semana',
131
+ 'prev-month' : 'Mes',
132
+ 'prev-year' : 'Año',
133
+ 'next':'Siguiente',
134
+ 'next-week':'Semana',
135
+ 'next-month':'Mes',
136
+ 'next-year':'Año',
137
+ 'less-than' : 'El rango no deberia ser mayor de %d dias',
138
+ 'more-than' : 'El rango no deberia ser menor de %d dias',
139
+ 'default-more' : 'Por favor selecciona un rango mayor a %d dias',
140
+ 'default-single' : 'Por favor selecciona un dia',
141
+ 'default-less' : 'Por favor selecciona un rango menor a %d dias',
142
+ 'default-range' : 'Por favor selecciona un rango entre %d y %d dias',
143
+ 'default-default': 'Por favor selecciona un rango de fechas.'
144
+ },
145
+ 'de':
146
+ {
147
+ 'selected': 'Auswahl:',
148
+ 'day':'Tag',
149
+ 'days': 'Tage',
150
+ 'apply': 'Schließen',
151
+ 'week-1' : 'MO',
152
+ 'week-2' : 'DI',
153
+ 'week-3' : 'MI',
154
+ 'week-4' : 'DO',
155
+ 'week-5' : 'FR',
156
+ 'week-6' : 'SA',
157
+ 'week-7' : 'SO',
158
+ 'month-name': ['JANUAR','FEBRUAR','MÄRZ','APRIL','MAI','JUNI','JULI','AUGUST','SEPTEMBER','OKTOBER','NOVEMBER','DEZEMBER'],
159
+ 'shortcuts' : 'Schnellwahl',
160
+ 'past': 'Vorherige',
161
+ 'following':'Folgende',
162
+ 'previous' : 'Vorherige',
163
+ 'prev-week' : 'Woche',
164
+ 'prev-month' : 'Monat',
165
+ 'prev-year' : 'Jahr',
166
+ 'next':'Nächste',
167
+ 'next-week':'Woche',
168
+ 'next-month':'Monat',
169
+ 'next-year':'Jahr',
170
+ 'less-than' : 'Datumsbereich darf nicht größer sein als %d Tage',
171
+ 'more-than' : 'Datumsbereich darf nicht kleiner sein als %d Tage',
172
+ 'default-more' : 'Bitte mindestens %d Tage auswählen',
173
+ 'default-single' : 'Bitte ein Datum auswählen',
174
+ 'default-less' : 'Bitte weniger als %d Tage auswählen',
175
+ 'default-range' : 'Bitte einen Datumsbereich zwischen %d und %d Tagen auswählen',
176
+ 'default-default': 'Bitte ein Start- und Enddatum auswählen'
177
+ },
178
+ 'ru':
179
+ {
180
+ 'selected': 'Выбрано:',
181
+ 'day': 'День',
182
+ 'days': 'Дней',
183
+ 'apply': 'Закрыть',
184
+ 'week-1': 'ПН',
185
+ 'week-2': 'ВТ',
186
+ 'week-3': 'СР',
187
+ 'week-4': 'ЧТ',
188
+ 'week-5': 'ПТ',
189
+ 'week-6': 'СБ',
190
+ 'week-7': 'ВС',
191
+ 'month-name': ['ЯНВАРЬ','ФЕВРАЛЬ','МАРТ','АПРЕЛЬ','МАЙ','ИЮНЬ','ИЮЛЬ','АВГУСТ','СЕНТЯБРЬ','ОКТЯБРЬ','НОЯБРЬ','ДЕКАБРЬ'],
192
+ 'shortcuts': 'Быстрый выбор',
193
+ 'past': 'Прошедшие',
194
+ 'following': 'Следующие',
195
+ 'previous': '&nbsp;&nbsp;&nbsp;',
196
+ 'prev-week': 'Неделя',
197
+ 'prev-month': 'Месяц',
198
+ 'prev-year': 'Год',
199
+ 'next': '&nbsp;&nbsp;&nbsp;',
200
+ 'next-week': 'Неделя',
201
+ 'next-month': 'Месяц',
202
+ 'next-year': 'Год',
203
+ 'less-than': 'Диапазон не может быть больше %d дней',
204
+ 'more-than': 'Диапазон не может быть меньше %d дней',
205
+ 'default-more': 'Пожалуйста выберите диапазон больше %d дней',
206
+ 'default-single': 'Пожалуйста выберите дату',
207
+ 'default-less': 'Пожалуйста выберите диапазон меньше %d дней',
208
+ 'default-range': 'Пожалуйста выберите диапазон между %d и %d днями',
209
+ 'default-default': 'Пожалуйста выберите диапазон'
210
+ }
211
+ };
212
+
213
+
214
+ if (window['moment'] === undefined)
215
+ {
216
+ if (window['console'] && console['warn']) console.warn('Please import moment.js before daterangepicker.js');
217
+ return;
218
+ }
219
+
220
+ $.fn.dateRangePicker = function(opt)
221
+ {
222
+ if (!opt) opt = {};
223
+ opt = $.extend(true,
224
+ {
225
+ autoClose: false,
226
+ format: 'YYYY-MM-DD',
227
+ separator: ' to ',
228
+ language: 'auto',
229
+ startOfWeek: 'sunday',// or monday
230
+ getValue: function()
231
+ {
232
+ return $(this).val();
233
+ },
234
+ setValue: function(s)
235
+ {
236
+ $(this).val(s);
237
+ },
238
+ startDate: false,
239
+ endDate: false,
240
+ time: {
241
+ enabled: false
242
+ },
243
+ minDays: 0,
244
+ maxDays: 0,
245
+ showShortcuts: true,
246
+ shortcuts:
247
+ {
248
+ //'prev-days': [1,3,5,7],
249
+ 'next-days': [3,5,7],
250
+ //'prev' : ['week','month','year'],
251
+ 'next' : ['week','month','year']
252
+ },
253
+ customShortcuts : [],
254
+ inline:false,
255
+ container:'body',
256
+ alwaysOpen:false,
257
+ singleDate:false,
258
+ batchMode: false
259
+ },opt);
260
+
261
+ opt.start = false;
262
+ opt.end = false;
263
+
264
+ if (opt.startDate && typeof opt.startDate == 'string') opt.startDate = moment(opt.startDate,opt.format).toDate();
265
+ if (opt.endDate && typeof opt.endDate == 'string') opt.endDate = moment(opt.endDate,opt.format).toDate();
266
+
267
+ var langs = getLanguages();
268
+ var box;
269
+ var initiated = false;
270
+ var self = this;
271
+ var selfDom = $(self).get(0);
272
+
273
+ $(this).unbind('.datepicker').bind('click.datepicker',function(evt)
274
+ {
275
+ evt.stopPropagation();
276
+ open(200);
277
+ });
278
+
279
+ init_datepicker.call(this);
280
+
281
+ if (opt.alwaysOpen)
282
+ {
283
+ open(0);
284
+ }
285
+
286
+ // expose some api
287
+ $(this).data('dateRangePicker',
288
+ {
289
+ setDateRange : function(d1,d2)
290
+ {
291
+ if (typeof d1 == 'string' && typeof d2 == 'string')
292
+ {
293
+ d1 = moment(d1,opt.format).toDate();
294
+ d2 = moment(d2,opt.format).toDate();
295
+ }
296
+ setDateRange(d1,d2);
297
+ },
298
+ clear: clearSelection,
299
+ close: closeDatePicker,
300
+ open: open,
301
+ destroy: function()
302
+ {
303
+ $(self).unbind('.datepicker');
304
+ $(self).data('dateRangePicker','');
305
+ box.remove();
306
+ $(window).unbind('resize.datepicker',calcPosition);
307
+ $(document).unbind('click.datepicker',closeDatePicker);
308
+ }
309
+ });
310
+
311
+ $(window).bind('resize.datepicker',calcPosition);
312
+
313
+ return this;
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+ function init_datepicker()
326
+ {
327
+ var self = this;
328
+
329
+ if ($(this).data('date-picker-opened'))
330
+ {
331
+ closeDatePicker();
332
+ return;
333
+ }
334
+ $(this).data('date-picker-opened',true);
335
+
336
+
337
+
338
+
339
+
340
+ box = createDom().hide();
341
+ $(opt.container).append(box);
342
+
343
+ if (!opt.inline)
344
+ {
345
+ calcPosition();
346
+ }
347
+ else
348
+ {
349
+ box.css({position:'static'});
350
+ }
351
+
352
+ if (opt.alwaysOpen)
353
+ {
354
+ box.find('.apply-btn').hide();
355
+ }
356
+
357
+ var defaultTime = new Date();
358
+ if (opt.startDate && compare_month(defaultTime,opt.startDate) < 0 ) defaultTime = moment(opt.startDate).toDate();
359
+ if (opt.endDate && compare_month(nextMonth(defaultTime),opt.endDate) > 0 ) defaultTime = prevMonth(moment(opt.endDate).toDate());
360
+
361
+
362
+ showMonth(defaultTime,'month1');
363
+ showMonth(nextMonth(defaultTime),'month2');
364
+
365
+ if (opt.time.enabled) {
366
+ if ((opt.startDate && opt.endDate) || (opt.start && opt.end)) {
367
+ showTime(moment(opt.start || opt.startDate).toDate(),'time1');
368
+ showTime(moment(opt.end || opt.endDate).toDate(),'time2');
369
+ } else {
370
+ showTime(defaultTime,'time1');
371
+ showTime(defaultTime,'time2');
372
+ }
373
+ }
374
+
375
+ //showSelectedInfo();
376
+
377
+
378
+
379
+
380
+ var defaultTopText = '';
381
+ if (opt.singleDate)
382
+ defaultTopText = lang('default-single');
383
+ else if (opt.minDays && opt.maxDays)
384
+ defaultTopText = lang('default-range');
385
+ else if (opt.minDays)
386
+ defaultTopText = lang('default-more');
387
+ else if (opt.maxDays)
388
+ defaultTopText = lang('default-less');
389
+ else
390
+ defaultTopText = lang('default-default');
391
+
392
+ box.find('.default-top').html( defaultTopText.replace(/\%d/,opt.minDays).replace(/\%d/,opt.maxDays));
393
+
394
+
395
+
396
+
397
+ setTimeout(function()
398
+ {
399
+ initiated = true;
400
+ },0);
401
+
402
+ box.click(function(evt)
403
+ {
404
+ evt.stopPropagation();
405
+ });
406
+
407
+ $(document).bind('click.datepicker',closeDatePicker);
408
+
409
+ box.find('.next').click(function()
410
+ {
411
+ var isMonth2 = $(this).parents('table').hasClass('month2');
412
+ var month = isMonth2 ? opt.month2 : opt.month1;
413
+ month = nextMonth(month);
414
+ if (!opt.singleDate && !isMonth2 && compare_month(month,opt.month2) >= 0) return;
415
+ showMonth(month,isMonth2 ? 'month2' : 'month1');
416
+ showGap();
417
+ });
418
+
419
+ box.find('.prev').click(function()
420
+ {
421
+ var isMonth2 = $(this).parents('table').hasClass('month2');
422
+ var month = isMonth2 ? opt.month2 : opt.month1;
423
+ month = prevMonth(month);
424
+ //if (isMonth2 && month.getFullYear()+''+month.getMonth() <= opt.month1.getFullYear()+''+opt.month1.getMonth()) return;
425
+ if (isMonth2 && compare_month(month,opt.month1) <= 0) return;
426
+ showMonth(month,isMonth2 ? 'month2' : 'month1');
427
+ showGap();
428
+ });
429
+
430
+
431
+ box.bind('click',function(evt)
432
+ {
433
+ if ($(evt.target).hasClass('day'))
434
+ {
435
+ dayClicked($(evt.target));
436
+ }
437
+ });
438
+
439
+ box.attr('unselectable', 'on')
440
+ .css('user-select', 'none')
441
+ .bind('selectstart', function(e)
442
+ {
443
+ e.preventDefault(); return false;
444
+ });
445
+
446
+ box.find('.apply-btn').click(function()
447
+ {
448
+ closeDatePicker();
449
+ var dateRange = getDateString(new Date(opt.start))+ opt.separator +getDateString(new Date(opt.end));
450
+ $(self).trigger('datepicker-apply',
451
+ {
452
+ 'value': dateRange,
453
+ 'date1' : new Date(opt.start),
454
+ 'date2' : new Date(opt.end)
455
+ });
456
+ });
457
+
458
+ box.find('[shortcut]').click(function()
459
+ {
460
+ var shortcut = $(this).attr('shortcut');
461
+ var end = new Date(),start = false;
462
+ if (shortcut.indexOf('day') != -1)
463
+ {
464
+ var day = parseInt(shortcut.split(',',2)[1],10);
465
+ start = new Date(new Date().getTime() + 86400000*day);
466
+ end = new Date(end.getTime() + 86400000*(day>0?1:-1) );
467
+ }
468
+ else if (shortcut.indexOf('week')!= -1)
469
+ {
470
+ var dir = shortcut.indexOf('prev,') != -1 ? -1 : 1;
471
+
472
+ if (dir == 1)
473
+ var stopDay = opt.startOfWeek == 'monday' ? 1 : 0;
474
+ else
475
+ var stopDay = opt.startOfWeek == 'monday' ? 0 : 6;
476
+
477
+ end = new Date(end.getTime() - 86400000);
478
+ while(end.getDay() != stopDay) end = new Date(end.getTime() + dir*86400000);
479
+ start = new Date(end.getTime() + dir*86400000*6);
480
+ }
481
+ else if (shortcut.indexOf('month') != -1)
482
+ {
483
+ var dir = shortcut.indexOf('prev,') != -1 ? -1 : 1;
484
+ if (dir == 1)
485
+ start = nextMonth(end);
486
+ else
487
+ start = prevMonth(end);
488
+ start.setDate(1);
489
+ end = nextMonth(start);
490
+ end.setDate(1);
491
+ end = new Date(end.getTime() - 86400000);
492
+ }
493
+ else if (shortcut.indexOf('year') != -1)
494
+ {
495
+ var dir = shortcut.indexOf('prev,') != -1 ? -1 : 1;
496
+ start = new Date();
497
+ start.setFullYear(end.getFullYear() + dir);
498
+ start.setMonth(0);
499
+ start.setDate(1);
500
+ end.setFullYear(end.getFullYear() + dir);
501
+ end.setMonth(11);
502
+ end.setDate(31);
503
+ }
504
+ else if (shortcut == 'custom')
505
+ {
506
+ var name = $(this).html();
507
+ if (opt.customShortcuts && opt.customShortcuts.length > 0)
508
+ {
509
+ for(var i=0;i<opt.customShortcuts.length;i++)
510
+ {
511
+ var sh = opt.customShortcuts[i];
512
+ if (sh.name == name)
513
+ {
514
+ var data = [];
515
+ // try
516
+ // {
517
+ data = sh['dates'].call();
518
+ //}catch(e){}
519
+ if (data && data.length == 2)
520
+ {
521
+ start = data[0];
522
+ end = data[1];
523
+ }
524
+
525
+ // if only one date is specified then just move calendars there
526
+ // move calendars to show this date's month and next months
527
+ if (data && data.length == 1)
528
+ {
529
+ movetodate = data[0];
530
+ showMonth(movetodate,'month1');
531
+ showMonth(nextMonth(movetodate),'month2');
532
+ showGap();
533
+ }
534
+
535
+ break;
536
+ }
537
+ }
538
+ }
539
+ }
540
+ if (start && end)
541
+ {
542
+ setDateRange(start,end);
543
+ checkSelectionValid();
544
+ }
545
+ });
546
+
547
+ box.find(".time1 input[type=range]").bind("change mousemove", function (e) {
548
+ var target = e.target,
549
+ hour = target.name == "hour" ? $(target).val().replace(/^(\d{1})$/, "0$1") : undefined,
550
+ min = target.name == "minute" ? $(target).val().replace(/^(\d{1})$/, "0$1") : undefined;
551
+ setTime("time1", hour, min);
552
+ });
553
+
554
+ box.find(".time2 input[type=range]").bind("change mousemove", function (e) {
555
+ var target = e.target,
556
+ hour = target.name == "hour" ? $(target).val().replace(/^(\d{1})$/, "0$1") : undefined,
557
+ min = target.name == "minute" ? $(target).val().replace(/^(\d{1})$/, "0$1") : undefined;
558
+ setTime("time2", hour, min);
559
+ });
560
+
561
+ }
562
+
563
+
564
+ function calcPosition()
565
+ {
566
+ if (!opt.inline)
567
+ {
568
+ var offset = $(self).offset();
569
+ if (offset.left < 460) //left to right
570
+ {
571
+ box.css(
572
+ {
573
+ top: offset.top+$(self).outerHeight() + parseInt($('body').css('border-top') || 0,10 ),
574
+ left: offset.left
575
+ });
576
+ }
577
+ else
578
+ {
579
+ box.css(
580
+ {
581
+ top: offset.top+$(self).outerHeight() + parseInt($('body').css('border-top') || 0,10 ),
582
+ left: offset.left + $(self).width() - box.width() - 16
583
+ });
584
+ }
585
+ }
586
+ }
587
+
588
+ function open(animationTime)
589
+ {
590
+ calcPosition();
591
+ var __default_string = opt.getValue.call(selfDom);
592
+ var defaults = __default_string ? __default_string.split( opt.separator ) : '';
593
+
594
+ if (defaults && defaults.length >= 2)
595
+ {
596
+ var ___format = opt.format;
597
+ if (___format.match(/Do/))
598
+ {
599
+ ___format = ___format.replace(/Do/,'D');
600
+ defaults[0] = defaults[0].replace(/(\d+)(th|nd|st)/,'$1');
601
+ defaults[1] = defaults[1].replace(/(\d+)(th|nd|st)/,'$1');
602
+ }
603
+ // set initiated to avoid triggerring datepicker-change event
604
+ initiated = false;
605
+ setDateRange(moment(defaults[0], ___format).toDate(),moment(defaults[1], ___format).toDate());
606
+ initiated = true;
607
+ }
608
+ box.slideDown(animationTime);
609
+ }
610
+
611
+
612
+
613
+ function renderTime (name, date) {
614
+ box.find("." + name + " input[type=range].hour-range").val(moment(date).hours());
615
+ box.find("." + name + " input[type=range].minute-range").val(moment(date).minutes());
616
+ setTime(name, moment(date).format("HH"), moment(date).format("mm"));
617
+ }
618
+
619
+ function changeTime (name, date) {
620
+ opt[name] = parseInt(
621
+ moment(parseInt(date))
622
+ .startOf('day')
623
+ .add('h', moment(opt[name + "Time"]).format("HH"))
624
+ .add('m', moment(opt[name + "Time"]).format("mm")).valueOf()
625
+ );
626
+ }
627
+
628
+ function swapTime () {
629
+ renderTime("time1", opt.start);
630
+ renderTime("time2", opt.end);
631
+ }
632
+
633
+ function setTime (name, hour, minute) {
634
+ hour && (box.find("." + name + " .hour-val").text(hour));
635
+ minute && (box.find("." + name + " .minute-val").text(minute));
636
+ switch (name) {
637
+ case "time1":
638
+ if (opt.start) {
639
+ setRange("start", moment(opt.start));
640
+ }
641
+ setRange("startTime", moment(opt.startTime || moment().valueOf()));
642
+ break;
643
+ case "time2":
644
+ if (opt.end) {
645
+ setRange("end", moment(opt.end));
646
+ }
647
+ setRange("endTime", moment(opt.endTime || moment().valueOf()));
648
+ break;
649
+ }
650
+ function setRange(name, timePoint) {
651
+ var h = timePoint.format("HH"),
652
+ m = timePoint.format("mm");
653
+ opt[name] = timePoint
654
+ .startOf('day')
655
+ .add("h", hour || h)
656
+ .add("m", minute || m)
657
+ .valueOf();
658
+ }
659
+ checkSelectionValid();
660
+ showSelectedInfo();
661
+ showSelectedDays();
662
+ }
663
+
664
+ function clearSelection()
665
+ {
666
+ opt.start = false;
667
+ opt.end = false;
668
+ box.find('.day.checked').removeClass('checked');
669
+ opt.setValue.call(selfDom, '');
670
+ checkSelectionValid();
671
+ showSelectedInfo();
672
+ showSelectedDays();
673
+ }
674
+
675
+ function handleStart(time)
676
+ {
677
+ var r = time;
678
+ if (opt.batchMode === 'week-range') {
679
+ if (opt.startOfWeek === 'monday') {
680
+ r = moment(parseInt(time)).startOf('isoweek').valueOf();
681
+ } else {
682
+ r = moment(parseInt(time)).startOf('week').valueOf();
683
+ }
684
+ } else if (opt.batchMode === 'month-range') {
685
+ r = moment(parseInt(time)).startOf('month').valueOf();
686
+ }
687
+
688
+ return r;
689
+ }
690
+
691
+ function handleEnd(time)
692
+ {
693
+ var r = time;
694
+ if (opt.batchMode === 'week-range') {
695
+ if (opt.startOfWeek === 'monday') {
696
+ r = moment(parseInt(time)).endOf('isoweek').valueOf();
697
+ } else {
698
+ r = moment(parseInt(time)).endOf('week').valueOf();
699
+ }
700
+ } else if (opt.batchMode === 'month') {
701
+ r = moment(parseInt(time)).endOf('month').valueOf();
702
+ }
703
+
704
+ return r;
705
+ }
706
+
707
+
708
+ function dayClicked(day)
709
+ {
710
+ if (day.hasClass('invalid')) return;
711
+ var time = day.attr('time');
712
+ day.addClass('checked');
713
+ if ( opt.singleDate )
714
+ {
715
+ opt.start = time;
716
+ opt.end = false;
717
+ if (opt.time.enabled) {
718
+ changeTime("start", opt.start);
719
+ }
720
+ }
721
+ else if (opt.batchMode === 'week')
722
+ {
723
+ if (opt.startOfWeek === 'monday') {
724
+ opt.start = moment(parseInt(time)).startOf('isoweek').valueOf();
725
+ opt.end = moment(parseInt(time)).endOf('isoweek').valueOf();
726
+ } else {
727
+ opt.end = moment(parseInt(time)).endOf('week').valueOf();
728
+ opt.start = moment(parseInt(time)).startOf('week').valueOf();
729
+ }
730
+ }
731
+ else if (opt.batchMode === 'month')
732
+ {
733
+ opt.start = moment(parseInt(time)).startOf('month').valueOf();
734
+ opt.end = moment(parseInt(time)).endOf('month').valueOf();
735
+ }
736
+ else if ((opt.start && opt.end) || (!opt.start && !opt.end) )
737
+ {
738
+ opt.start = handleStart(time);
739
+ opt.end = false;
740
+ if (opt.time.enabled) {
741
+ changeTime("start", opt.start);
742
+ }
743
+ }
744
+ else if (opt.start)
745
+ {
746
+ opt.end = handleEnd(time);
747
+ if (opt.time.enabled) {
748
+ changeTime("end", opt.end);
749
+ }
750
+ }
751
+
752
+ if (!opt.singleDate && opt.start && opt.end && opt.start > opt.end)
753
+ {
754
+ var tmp = opt.end;
755
+ opt.end = handleEnd(opt.start);
756
+ opt.start = handleStart(tmp);
757
+ if (opt.time.enabled) {
758
+ swapTime();
759
+ }
760
+ }
761
+
762
+ opt.start = parseInt(opt.start);
763
+ opt.end = parseInt(opt.end);
764
+
765
+ checkSelectionValid();
766
+ showSelectedInfo();
767
+ showSelectedDays();
768
+ autoclose();
769
+ }
770
+
771
+ function autoclose () {
772
+ if (opt.singleDate === true) {
773
+ if (initiated && opt.start )
774
+ {
775
+ if (opt.autoClose) closeDatePicker();
776
+ }
777
+ } else {
778
+ if (initiated && opt.start && opt.end)
779
+ {
780
+ if (opt.autoClose) closeDatePicker();
781
+ }
782
+ }
783
+ }
784
+
785
+ function checkSelectionValid()
786
+ {
787
+ var days = Math.ceil( (opt.end - opt.start) / 86400000 ) + 1;
788
+ if (opt.singleDate) { // Validate if only start is there
789
+ if (opt.start && !opt.end)
790
+ box.find('.drp_top-bar').removeClass('error').addClass('normal');
791
+ else
792
+ box.find('.drp_top-bar').removeClass('error').removeClass('normal');
793
+ }
794
+ else if ( opt.maxDays && days > opt.maxDays)
795
+ {
796
+ opt.start = false;
797
+ opt.end = false;
798
+ box.find('.day').removeClass('checked');
799
+ box.find('.drp_top-bar').removeClass('normal').addClass('error').find('.error-top').html( lang('less-than').replace('%d',opt.maxDays) );
800
+ }
801
+ else if ( opt.minDays && days < opt.minDays)
802
+ {
803
+ opt.start = false;
804
+ opt.end = false;
805
+ box.find('.day').removeClass('checked');
806
+ box.find('.drp_top-bar').removeClass('normal').addClass('error').find('.error-top').html( lang('more-than').replace('%d',opt.minDays) );
807
+ }
808
+ else
809
+ {
810
+ if (opt.start || opt.end)
811
+ box.find('.drp_top-bar').removeClass('error').addClass('normal');
812
+ else
813
+ box.find('.drp_top-bar').removeClass('error').removeClass('normal');
814
+ }
815
+
816
+ if ( (opt.singleDate && opt.start && !opt.end) || (!opt.singleDate && opt.start && opt.end) )
817
+ {
818
+ box.find('.apply-btn').removeClass('disabled');
819
+ }
820
+ else
821
+ {
822
+ box.find('.apply-btn').addClass('disabled');
823
+ }
824
+
825
+ if (opt.batchMode)
826
+ {
827
+ if ( (opt.start && opt.startDate && compare_day(opt.start, opt.startDate) < 0)
828
+ || (opt.end && opt.endDate && compare_day(opt.end, opt.endDate) > 0) )
829
+ {
830
+ opt.start = false;
831
+ opt.end = false;
832
+ box.find('.day').removeClass('checked');
833
+ }
834
+ }
835
+ }
836
+
837
+ function showSelectedInfo()
838
+ {
839
+ box.find('.start-day').html('...');
840
+ box.find('.end-day').html('...');
841
+ box.find('.selected-days').hide();
842
+ if (opt.start)
843
+ {
844
+ box.find('.start-day').html(getDateString(new Date(parseInt(opt.start))));
845
+ }
846
+ if (opt.end)
847
+ {
848
+ box.find('.end-day').html(getDateString(new Date(parseInt(opt.end))));
849
+ }
850
+
851
+ if (opt.start && opt.singleDate)
852
+ {
853
+ box.find('.apply-btn').removeClass('disabled');
854
+ var dateRange = getDateString(new Date(opt.start));
855
+ opt.setValue.call(selfDom, dateRange, getDateString(new Date(opt.start)), getDateString(new Date(opt.end)));
856
+
857
+ if (initiated)
858
+ {
859
+ $(self).trigger('datepicker-change',
860
+ {
861
+ 'value': dateRange,
862
+ 'date1' : new Date(opt.start)
863
+ });
864
+ }
865
+ }
866
+ else if (opt.start && opt.end)
867
+ {
868
+ box.find('.selected-days').show().find('.selected-days-num').html(Math.round((opt.end-opt.start)/86400000)+1);
869
+ box.find('.apply-btn').removeClass('disabled');
870
+ var dateRange = getDateString(new Date(opt.start))+ opt.separator +getDateString(new Date(opt.end));
871
+ opt.setValue.call(selfDom,dateRange, getDateString(new Date(opt.start)), getDateString(new Date(opt.end)));
872
+ if (initiated)
873
+ {
874
+ $(self).trigger('datepicker-change',
875
+ {
876
+ 'value': dateRange,
877
+ 'date1' : new Date(opt.start),
878
+ 'date2' : new Date(opt.end)
879
+ });
880
+ }
881
+ }
882
+ else
883
+ {
884
+ box.find('.apply-btn').addClass('disabled');
885
+ }
886
+ }
887
+
888
+ function setDateRange(date1,date2)
889
+ {
890
+ if (date1.getTime() > date2.getTime())
891
+ {
892
+ var tmp = date2;
893
+ date2 = date1;
894
+ date1 = tmp;
895
+ tmp = null;
896
+ }
897
+ var valid = true;
898
+ if (opt.startDate && compare_day(date1,opt.startDate) < 0) valid = false;
899
+ if (opt.endDate && compare_day(date2,opt.endDate) > 0) valid = false;
900
+ if (!valid)
901
+ {
902
+ showMonth(opt.startDate,'month1');
903
+ showMonth(nextMonth(opt.startDate),'month2');
904
+ showGap();
905
+ return;
906
+ }
907
+
908
+ opt.start = date1.getTime();
909
+ opt.end = date2.getTime();
910
+ if (compare_month(date1,date2) == 0)
911
+ {
912
+ date2 = nextMonth(date1);
913
+ }
914
+ if (opt.time.enabled) {
915
+ renderTime("time1", date1);
916
+ renderTime("time2", date2);
917
+ }
918
+ showMonth(date1,'month1');
919
+ showMonth(date2,'month2');
920
+ showGap();
921
+ showSelectedInfo();
922
+ autoclose();
923
+ }
924
+
925
+ function showSelectedDays()
926
+ {
927
+ if (!opt.start && !opt.end) return;
928
+ box.find('.day').each(function()
929
+ {
930
+ var time = parseInt($(this).attr('time')),
931
+ start = opt.start,
932
+ end = opt.end;
933
+ if (opt.time.enabled) {
934
+ time = moment(time).startOf('day').valueOf();
935
+ start = moment(start || moment().valueOf()).startOf('day').valueOf();
936
+ end = moment(end || moment().valueOf()).startOf('day').valueOf();
937
+ }
938
+ if (
939
+ (opt.start && opt.end && end >= time && start <= time )
940
+ || ( opt.start && !opt.end && moment(start).format('YYYY-MM-DD') == moment(time).format('YYYY-MM-DD') )
941
+ )
942
+ {
943
+ $(this).addClass('checked');
944
+ }
945
+ else
946
+ {
947
+ $(this).removeClass('checked');
948
+ }
949
+ });
950
+ }
951
+
952
+ function showMonth(date,month)
953
+ {
954
+ date = moment(date).toDate();
955
+ var monthName = nameMonth(date.getMonth());
956
+ box.find('.'+month+' .month-name').html(monthName+' '+date.getFullYear());
957
+ box.find('.'+month+' tbody').html(createMonthHTML(date));
958
+ opt[month] = date;
959
+ }
960
+
961
+ function showTime(date,name)
962
+ {
963
+ box.find('.' + name).append(getTimeHTML());
964
+ renderTime(name, date);
965
+ }
966
+
967
+ function nameMonth(m)
968
+ {
969
+ return lang('month-name')[m];
970
+ }
971
+
972
+ function getDateString(d)
973
+ {
974
+ return moment(d).format(opt.format);
975
+ }
976
+
977
+ function showGap()
978
+ {
979
+ showSelectedDays();
980
+ var m1 = parseInt(moment(opt.month1).format('YYYYMM'));
981
+ var m2 = parseInt(moment(opt.month2).format('YYYYMM'));
982
+ var p = Math.abs(m1 - m2);
983
+ var shouldShow = (p > 1 && p !=89);
984
+ if (shouldShow)
985
+ box.find('.gap').show();
986
+ else
987
+ box.find('.gap').hide();
988
+ }
989
+
990
+ function closeDatePicker()
991
+ {
992
+ if (opt.alwaysOpen) return;
993
+ $(box).slideUp(200,function()
994
+ {
995
+ $(self).data('date-picker-opened',false);
996
+ });
997
+ //$(document).unbind('.datepicker');
998
+ $(self).trigger('datepicker-close');
999
+ }
1000
+
1001
+ function compare_month(m1,m2)
1002
+ {
1003
+ var p = parseInt(moment(m1).format('YYYYMM')) - parseInt(moment(m2).format('YYYYMM'));
1004
+ if (p > 0 ) return 1;
1005
+ if (p == 0) return 0;
1006
+ return -1;
1007
+ }
1008
+
1009
+ function compare_day(m1,m2)
1010
+ {
1011
+ var p = parseInt(moment(m1).format('YYYYMMDD')) - parseInt(moment(m2).format('YYYYMMDD'));
1012
+ if (p > 0 ) return 1;
1013
+ if (p == 0) return 0;
1014
+ return -1;
1015
+ }
1016
+
1017
+ function nextMonth(month)
1018
+ {
1019
+ month = moment(month).toDate();
1020
+ var toMonth = month.getMonth();
1021
+ while(month.getMonth() == toMonth) month = new Date(month.getTime()+86400000);
1022
+ return month;
1023
+ }
1024
+
1025
+ function prevMonth(month)
1026
+ {
1027
+ month = moment(month).toDate();
1028
+ var toMonth = month.getMonth();
1029
+ while(month.getMonth() == toMonth) month = new Date(month.getTime()-86400000);
1030
+ return month;
1031
+ }
1032
+
1033
+ function getTimeHTML()
1034
+ {
1035
+ var timeHtml = '<div>'
1036
+ +'<span>Time: <span class="hour-val">00</span>:<span class="minute-val">00</span></span>'
1037
+ +'</div>'
1038
+ +'<div class="hour">'
1039
+ +'<label>Hour: <input type="range" class="hour-range" name="hour" min="0" max="23"></label>'
1040
+ +'</div>'
1041
+ +'<div class="minute">'
1042
+ +'<label>Minute: <input type="range" class="minute-range" name="minute" min="0" max="59"></label>'
1043
+ +'</div>';
1044
+ return timeHtml;
1045
+ }
1046
+
1047
+ function createDom()
1048
+ {
1049
+ var html = '<div class="date-picker-wrapper'
1050
+ if ( opt.singleDate ) html += ' single-date';
1051
+ if ( !opt.showShortcuts ) html += ' no-shortcuts ';
1052
+ html += '">'
1053
+ +'<div class="drp_top-bar">\
1054
+ <div class="normal-top">\
1055
+ <span style="color:#333">'+lang('selected')+' </span> <b class="start-day">...</b>'
1056
+ if ( ! opt.singleDate ) {
1057
+ html += ' <span class="separator-day">'+opt.separator+'</span> <b class="end-day">...</b> <i class="selected-days">(<span class="selected-days-num">3</span> '+lang('days')+')</i>'
1058
+ }
1059
+ html += '</div>\
1060
+ <div class="error-top">error</div>\
1061
+ <div class="default-top">default</div>\
1062
+ <input type="button" class="apply-btn disabled '+ getHideClass() +'" value="'+lang('apply')+'" />\
1063
+ </div>'
1064
+ +'<div class="month-wrapper">'
1065
+ +'<table class="month1" cellspacing="0" border="0" cellpadding="0"><thead><tr class="caption"><th style="width:27px;"><span class="prev">&lt;</span></th><th colspan="5" class="month-name">January, 2011</th><th style="width:27px;"><span class="next">&gt;</span></th></tr><tr class="week-name">'+getWeekHead()+'</thead><tbody></tbody></table>'
1066
+ if ( ! opt.singleDate ) {
1067
+ html += '<div class="gap">'+getGapHTML()+'</div>'
1068
+ +'<table class="month2" cellspacing="0" border="0" cellpadding="0"><thead><tr class="caption"><th style="width:27px;"><span class="prev">&lt;</span></th><th colspan="5" class="month-name">January, 2011</th><th style="width:27px;"><span class="next">&gt;</span></th></tr><tr class="week-name">'+getWeekHead()+'</thead><tbody></tbody></table>'
1069
+ }
1070
+ //+'</div>'
1071
+ html += '<div style="clear:both;height:0;font-size:0;"></div>'
1072
+ +'<div class="time">'
1073
+ +'<div class="time1"></div>'
1074
+ if ( ! opt.singleDate ) {
1075
+ html += '<div class="time2"></div>'
1076
+ }
1077
+ html += '</div>'
1078
+ +'<div style="clear:both;height:0;font-size:0;"></div>'
1079
+ +'</div>';
1080
+
1081
+ if (opt.showShortcuts)
1082
+ {
1083
+ html += '<div class="footer"><b>'+lang('shortcuts')+'</b>';
1084
+
1085
+ var data = opt.shortcuts;
1086
+ if (data)
1087
+ {
1088
+ if (data['prev-days'] && data['prev-days'].length > 0)
1089
+ {
1090
+ html += '&nbsp;<span class="prev-days">'+lang('past');
1091
+ for(var i=0;i<data['prev-days'].length; i++)
1092
+ {
1093
+ var name = data['prev-days'][i];
1094
+ name += (data['prev-days'][i] > 1) ? lang('days') : lang('day');
1095
+ html += ' <a href="javascript:;" shortcut="day,-'+data['prev-days'][i]+'">'+name+'</a>';
1096
+ }
1097
+ html+='</span>';
1098
+ }
1099
+
1100
+ if (data['next-days'] && data['next-days'].length > 0)
1101
+ {
1102
+ html += '&nbsp;<span class="next-days">'+lang('following');
1103
+ for(var i=0;i<data['next-days'].length; i++)
1104
+ {
1105
+ var name = data['next-days'][i];
1106
+ name += (data['next-days'][i] > 1) ? lang('days') : lang('day');
1107
+ html += ' <a href="javascript:;" shortcut="day,'+data['next-days'][i]+'">'+name+'</a>';
1108
+ }
1109
+ html+= '</span>';
1110
+ }
1111
+
1112
+ if (data['prev'] && data['prev'].length > 0)
1113
+ {
1114
+ html += '&nbsp;<span class="prev-buttons">'+lang('previous');
1115
+ for(var i=0;i<data['prev'].length; i++)
1116
+ {
1117
+ var name = lang('prev-'+data['prev'][i]);
1118
+ html += ' <a href="javascript:;" shortcut="prev,'+data['prev'][i]+'">'+name+'</a>';
1119
+ }
1120
+ html+='</span>';
1121
+ }
1122
+
1123
+ if (data['next'] && data['next'].length > 0)
1124
+ {
1125
+ html += '&nbsp;<span class="next-buttons">'+lang('next');
1126
+ for(var i=0;i<data['next'].length; i++)
1127
+ {
1128
+ var name = lang('next-'+data['next'][i]);
1129
+ html += ' <a href="javascript:;" shortcut="next,'+data['next'][i]+'">'+name+'</a>';
1130
+ }
1131
+ html+='</span>';
1132
+ }
1133
+ }
1134
+
1135
+ if (opt.customShortcuts)
1136
+ {
1137
+ for(var i=0;i<opt.customShortcuts.length; i++)
1138
+ {
1139
+ var sh = opt.customShortcuts[i];
1140
+ html+= '&nbsp;<span class="custom-shortcut"><a href="javascript:;" shortcut="custom">'+sh.name+'</a></span>';
1141
+ }
1142
+ }
1143
+
1144
+ html +='</div>';
1145
+ }
1146
+ html += '</div>';
1147
+
1148
+
1149
+ return $(html);
1150
+ }
1151
+
1152
+ function getHideClass()
1153
+ {
1154
+ if (opt.autoClose === true) {
1155
+ return 'hide';
1156
+ }
1157
+ return '';
1158
+ }
1159
+
1160
+ function getWeekHead()
1161
+ {
1162
+ if (opt.startOfWeek == 'monday')
1163
+ {
1164
+ return '<th>'+lang('week-1')+'</th>\
1165
+ <th>'+lang('week-2')+'</th>\
1166
+ <th>'+lang('week-3')+'</th>\
1167
+ <th>'+lang('week-4')+'</th>\
1168
+ <th>'+lang('week-5')+'</th>\
1169
+ <th>'+lang('week-6')+'</th>\
1170
+ <th>'+lang('week-7')+'</th>';
1171
+ }
1172
+ else
1173
+ {
1174
+ return '<th>'+lang('week-7')+'</th>\
1175
+ <th>'+lang('week-1')+'</th>\
1176
+ <th>'+lang('week-2')+'</th>\
1177
+ <th>'+lang('week-3')+'</th>\
1178
+ <th>'+lang('week-4')+'</th>\
1179
+ <th>'+lang('week-5')+'</th>\
1180
+ <th>'+lang('week-6')+'</th>';
1181
+ }
1182
+ }
1183
+
1184
+ function getGapHTML()
1185
+ {
1186
+ var html = ['<div class="gap-top-mask"></div><div class="gap-bottom-mask"></div><div class="gap-lines">'];
1187
+ for(var i=0;i<20;i++)
1188
+ {
1189
+ html.push('<div class="gap-line">\
1190
+ <div class="gap-1"></div>\
1191
+ <div class="gap-2"></div>\
1192
+ <div class="gap-3"></div>\
1193
+ </div>');
1194
+ }
1195
+ html.push('</div>');
1196
+ return html.join('');
1197
+ }
1198
+
1199
+ function createMonthHTML(d)
1200
+ {
1201
+ var days = [];
1202
+ d.setDate(1);
1203
+ var lastMonth = new Date(d.getTime() - 86400000);
1204
+ var now = new Date();
1205
+
1206
+ var dayOfWeek = d.getDay();
1207
+ if((dayOfWeek == 0) && (opt.startOfWeek == 'monday')) {
1208
+ // add one week
1209
+ dayOfWeek = 7;
1210
+ }
1211
+
1212
+ if (dayOfWeek > 0)
1213
+ {
1214
+ for (var i = dayOfWeek; i > 0; i--)
1215
+ {
1216
+ var day = new Date(d.getTime() - 86400000*i);
1217
+ var valid = true;
1218
+ if (opt.startDate && compare_day(day,opt.startDate) < 0) valid = false;
1219
+ if (opt.endDate && compare_day(day,opt.endDate) > 0) valid = false;
1220
+ days.push({type:'lastMonth',day: day.getDate(),time:day.getTime(), valid:valid });
1221
+ }
1222
+ }
1223
+ var toMonth = d.getMonth();
1224
+ for(var i=0; i<40; i++)
1225
+ {
1226
+ var today = moment(d).add('days', i).toDate();
1227
+ var valid = true;
1228
+ if (opt.startDate && compare_day(today,opt.startDate) < 0) valid = false;
1229
+ if (opt.endDate && compare_day(today,opt.endDate) > 0) valid = false;
1230
+ days.push({type: today.getMonth() == toMonth ? 'toMonth' : 'nextMonth',day: today.getDate(),time:today.getTime(), valid:valid });
1231
+ }
1232
+ var html = [];
1233
+ for(var week=0; week<6; week++)
1234
+ {
1235
+ if (days[week*7].type == 'nextMonth') break;
1236
+ html.push('<tr>');
1237
+ for(var day = 0; day<7; day++)
1238
+ {
1239
+ var _day = (opt.startOfWeek == 'monday') ? day+1 : day;
1240
+ var today = days[week*7+_day];
1241
+ var highlightToday = moment(today.time).format('L') == moment(now).format('L');
1242
+ today.extraClass = '';
1243
+ today.tooltip = '';
1244
+ if(opt.beforeShowDay && typeof opt.beforeShowDay == 'function')
1245
+ {
1246
+ var _r = opt.beforeShowDay(moment(today.time).toDate());
1247
+ today.valid = _r[0];
1248
+ today.extraClass = _r[1] || '';
1249
+ today.tooltip = _r[2] || '';
1250
+ if (today.tooltip != '') today.extraClass += ' has-tooltip ';
1251
+ }
1252
+ html.push('<td><div time="'+today.time+'" title="'+today.tooltip+'" class="day '+today.type+' '+today.extraClass+' '+(today.valid ? 'valid' : 'invalid')+' '+(highlightToday?'real-today':'')+'">'+today.day+'</div></td>');
1253
+ }
1254
+ html.push('</tr>');
1255
+ }
1256
+ return html.join('');
1257
+ }
1258
+
1259
+ function getLanguages()
1260
+ {
1261
+ if (opt.language == 'auto')
1262
+ {
1263
+ var language = navigator.language ? navigator.language : navigator.browserLanguage;
1264
+ if (!language) return $.dateRangePickerLanguages['en'];
1265
+ var language = language.toLowerCase();
1266
+ for(var key in $.dateRangePickerLanguages)
1267
+ {
1268
+ if (language.indexOf(key) != -1)
1269
+ {
1270
+ return $.dateRangePickerLanguages[key];
1271
+ }
1272
+ }
1273
+ return $.dateRangePickerLanguages['en'];
1274
+ }
1275
+ else if ( opt.language && opt.language in $.dateRangePickerLanguages)
1276
+ {
1277
+ return $.dateRangePickerLanguages[opt.language];
1278
+ }
1279
+ else
1280
+ {
1281
+ return $.dateRangePickerLanguages['en'];
1282
+ }
1283
+ }
1284
+
1285
+ function lang(t)
1286
+ {
1287
+ return (t in langs)? langs[t] : t;
1288
+ }
1289
+
1290
+
1291
+ };
1292
+ })(jQuery);