Commit a4f503d8 by Zachary Tong

Update Angular-Strap to 0.7.1

parent bdd11db9
/**
* AngularStrap - Twitter Bootstrap directives for AngularJS
* @version v0.6.3 - 2013-01-25
* @version v0.7.1 - 2013-03-21
* @link http://mgcrea.github.com/angular-strap
* @author Olivier Louvignes
* @author Olivier Louvignes <olivier@mg-crea.com>
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
angular.module("$strap.config",[]).value("$strap.config",{}),angular.module("$strap.filters",["$strap.config"]),angular.module("$strap.directives",["$strap.config"]),angular.module("$strap",["$strap.filters","$strap.directives","$strap.config"]),angular.module("$strap.directives").directive("bsAlert",["$parse","$timeout","$compile",function(e,t,n){"use strict";return{restrict:"A",link:function(r,i,s){r.$watch(s.bsAlert,function(e,s){if(typeof e=="undefined"){typeof s!="undefined"&&i.remove();return}i.html((e.title?"<strong>"+e.title+"</strong>&nbsp;":"")+e.content||""),t(function(){n(i.contents())(r)});if(e.type||s.type)s.type&&i.removeClass("alert-"+s.type),e.type&&i.addClass("alert-"+e.type);e.close!==!1&&i.prepend('<button type="button" class="close" data-dismiss="alert">&times;</button>')},!0),!s.bsAlert&&s.close!=="0"&&i.prepend('<button type="button" class="close" data-dismiss="alert">&times;</button>'),i.addClass("alert").alert()}}}]),angular.module("$strap.directives").directive("bsButton",["$parse","$timeout",function(e,t){"use strict";return{restrict:"A",require:"?ngModel",link:function(n,r,i,s){s&&(r.parent('[data-toggle="buttons-checkbox"], [data-toggle="buttons-radio"]').length||r.attr("data-toggle","button"),!n.$eval(i.ngModel)||r.addClass("active"),n.$watch(i.ngModel,function(e,t){var n=!!e,r=!!t;n!==r&&$.fn.button.Constructor.prototype.toggle.call(o)})),r.hasClass("btn")||r.on("click.button.data-api",function(e){r.button("toggle")}),r.button();var o=r.data("button");o.toggle=function(){if(!s)return $.fn.button.Constructor.prototype.toggle.call(this);var t=r.parent('[data-toggle="buttons-radio"]');t.length?(r.siblings("[ng-model]").each(function(t,r){e($(r).attr("ng-model")).assign(n,!1)}),n.$digest(),s.$modelValue||(s.$setViewValue(!s.$modelValue),n.$digest())):n.$apply(function(){s.$setViewValue(!s.$modelValue)})}}}}]).directive("bsButtonsCheckbox",["$parse",function(e){"use strict";return{restrict:"A",require:"?ngModel",compile:function(t,n,r){t.attr("data-toggle","buttons-checkbox").find("a, button").each(function(e,t){$(t).attr("bs-button","")})}}}]).directive("bsButtonsRadio",["$parse",function(e){"use strict";return{restrict:"A",require:"?ngModel",compile:function(t,n,r){return t.attr("data-toggle","buttons-radio"),n.ngModel||t.find("a, button").each(function(e,t){$(t).attr("bs-button","")}),function(t,n,r,i){i&&(n.find("[value]").button().filter('[value="'+t.$eval(r.ngModel)+'"]').addClass("active"),n.on("click.button.data-api",function(e){t.$apply(function(){i.$setViewValue($(e.target).closest("button").attr("value"))})}),t.$watch(r.ngModel,function(e,i){if(e!==i){var s=n.find('[value="'+t.$eval(r.ngModel)+'"]');$.fn.button.Constructor.prototype.toggle.call(s.data("button"))}}))}}}}]),angular.module("$strap.directives").directive("bsButtonSelect",["$parse","$timeout",function(e,t){"use strict";return{restrict:"A",require:"?ngModel",link:function(n,r,i,s){var o=e(i.bsButtonSelect),u=o.assign;s&&(r.text(n.$eval(i.ngModel)),n.$watch(i.ngModel,function(e,t){r.text(e)}));var a,f,l,c;r.on("click",function(){a=o(n),f=s?n.$eval(i.ngModel):r.text(),l=a.indexOf(f),c=l>a.length-2?a[0]:a[l+1],n.$apply(function(){r.text(c),s&&s.$setViewValue(c)})})}}}]),angular.module("$strap.directives").directive("bsDatepicker",["$timeout",function(e){"use strict";var t="ontouchstart"in window&&!window.navigator.userAgent.match(/PhantomJS/i),n={"/":"[\\/]","-":"[-]",".":"[.]",dd:"(?:(?:[0-2]?[0-9]{1})|(?:[3][01]{1}))",d:"(?:(?:[0-2]?[0-9]{1})|(?:[3][01]{1}))",mm:"(?:[0]?[1-9]|[1][012])",m:"(?:[0]?[1-9]|[1][012])",yyyy:"(?:(?:[1]{1}[0-9]{1}[0-9]{1}[0-9]{1})|(?:[2]{1}[0-9]{3}))(?![[0-9]])",yy:"(?:(?:[0-9]{1}[0-9]{1}))(?![[0-9]])"};return{restrict:"A",require:"?ngModel",link:function(r,i,s,o){var u=function(e,t){t||(t={});var r=e,i=n;return angular.forEach(i,function(e,t){r=r.split(t).join(e)}),new RegExp("^"+r+"$",["i"])},a=t?"yyyy/mm/dd":u(s.dateFormat||"mm/dd/yyyy");o&&o.$parsers.unshift(function(e){return!e||a.test(e)?(o.$setValidity("date",!0),e):(o.$setValidity("date",!1),undefined)});var f=i.next('[data-toggle="datepicker"]');f.length&&f.on("click",function(){t?i.trigger("focus"):i.datepicker("show")});if(t&&i.prop("type")==="text")i.prop("type","date"),i.on("change",function(e){r.$apply(function(){o.$setViewValue(i.val())})});else{o&&i.on("changeDate",function(e){r.$apply(function(){o.$setViewValue(i.val())})});var l=i.closest(".popover");l&&l.on("hide",function(e){var t=i.data("datepicker");t&&(t.picker.remove(),i.data("datepicker",null))}),i.attr("data-toggle","datepicker"),i.datepicker({autoclose:!0})}}}}]),angular.module("$strap.directives").directive("bsDropdown",["$parse","$compile",function(e,t){"use strict";var n=Array.prototype.slice,r='<ul class="dropdown-menu" role="menu" aria-labelledby="drop1"><li ng-repeat="item in items" ng-class="{divider: !!item.divider, \'dropdown-submenu\': !!item.submenu && item.submenu.length}"><a ng-hide="!!item.divider" tabindex="-1" ng-href="{{item.href}}" ng-click="{{item.click}}" target="{{item.target}}" ng-bind-html-unsafe="item.text"></a></li></ul>',i=function(e,n,i){var o,u,a;for(var f=0,l=e.length;f<l;f++)if(o=e[f].submenu)a=i.$new(),a.items=o,u=t(r)(a),u=u.appendTo(n.children("li:nth-child("+(f+1)+")")),s(o,u,a)},s=function(){var e=n.call(arguments);setTimeout(function(){i.apply(null,e)})};return{restrict:"EA",scope:!0,link:function(i,o,u){var a=e(u.bsDropdown);i.items=a(i);var f=t(r)(i);s(i.items,f,i),f.insertAfter(o),o.addClass("dropdown-toggle").attr("data-toggle","dropdown")}}}]),angular.module("$strap.directives").directive("bsModal",["$parse","$compile","$http","$timeout","$q","$templateCache",function(e,t,n,r,i,s){"use strict";return{restrict:"A",scope:!0,link:function(u,a,f,l){var c=e(f.bsModal),h=c.assign,p=c(u);i.when(s.get(p)||n.get(p,{cache:!0})).then(function(n){angular.isObject(n)&&(n=n.data);var i=c(u).replace(".html","").replace(/\//g,"-").replace(/\./g,"-")+"-"+u.$id,s=$("<div></div>").attr("id",i).attr("tabindex",-1).attr("data-backdrop",a.attr("data-backdrop")||!0).attr("data-keyboard",a.attr("data-keyboard")||!0).addClass("modal hide fade").html(n);$("body").append(s),a.attr("href","#"+i).attr("data-toggle","modal"),r(function(){t(s)(u)}),u._modal=function(e){s.modal(e)},u.hide=function(){s.modal("hide")},u.show=function(){s.modal("show")},u.dismiss=u.hide})}}}]),angular.module("$strap.directives").directive("bsNavbar",["$location",function(e){"use strict";return{restrict:"A",link:function(n,r,i,s){n.$watch(function(){return e.path()},function(e,t){r.find("li[data-match-route]").each(function(t,n){var r=angular.element(n),i=r.data("match-route"),s=new RegExp("^"+i+"$",["i"]);s.test(e)?r.addClass("active"):r.removeClass("active")})})}}}]),angular.module("$strap.directives").directive("bsPopover",["$parse","$compile","$http","$timeout","$q","$templateCache",function(e,t,n,r,i,s){"use strict";return $("body").on("keyup",function(e){e.keyCode===27&&$(".popover.in").each(function(){var e=$(this);e.popover("hide")})}),{restrict:"A",scope:!0,link:function(u,a,f,l){var c=e(f.bsPopover),h=c.assign,p=c(u),d={};angular.isObject(p)&&(d=p),i.when(d.content||s.get(p)||n.get(p,{cache:!0})).then(function(n){angular.isObject(n)&&(n=n.data),!f.unique||a.on("show",function(e){$(".popover.in").each(function(){var e=$(this),t=e.data("popover");t&&!t.$element.is(a)&&e.popover("hide")})}),a.popover(angular.extend({},d,{content:function(){return r(function(){var e=a.data("popover"),n=e.tip();t(n)(u),setTimeout(function(){e.refresh()})}),n},html:!0}));var i=a.data("popover");i.hasContent=function(){return this.getTitle()||n},i.refresh=function(){var e=this.tip(),t,n,r,i,s,o;s=typeof this.options.placement=="function"?this.options.placement.call(this,e[0],this.$element[0]):this.options.placement,t=/in/.test(s),n=this.getPosition(t),r=e[0].offsetWidth,i=e[0].offsetHeight;switch(t?s.split(" ")[1]:s){case"bottom":o={top:n.top+n.height+10,left:n.left+n.width/2-r/2};break;case"top":o={top:n.top-i-10,left:n.left+n.width/2-r/2};break;case"left":o={top:n.top+n.height/2-i/2,left:n.left-r-10};break;case"right":o={top:n.top+n.height/2-i/2,left:n.left+n.width+10}}e.offset(o)},i.show=function(){var e=$.Event("show");this.$element.trigger(e);if(e.isDefaultPrevented())return;var t=$.fn.popover.Constructor.prototype.show.apply(this,arguments);return this.$tip.data("popover",this),t},i.hide=function(){var e=$.Event("hide");this.$element.trigger(e);if(e.isDefaultPrevented())return;return $.fn.popover.Constructor.prototype.hide.apply(this,arguments)},u._popover=function(e){a.popover(e)},u.hide=function(){a.popover("hide")},u.show=function(){a.popover("show")},u.dismiss=u.hide})}}}]),angular.module("$strap.directives").directive("bsTimepicker",["$timeout",function(e){"use strict";var t="((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\\s?(?:am|AM|pm|PM))?)";return{restrict:"A",require:"?ngModel",link:function(n,r,i,s){s&&r.on("change",function(e){n.$apply(function(){s.$setViewValue(r.val())})});var o=new RegExp("^"+t+"$",["i"]);s.$parsers.unshift(function(e){return!e||o.test(e)?(s.$setValidity("time",!0),e):(s.$setValidity("time",!1),undefined)});var u=r.closest(".popover");u&&u.on("hide",function(e){var t=r.data("timepicker");t&&(t.$widget.remove(),r.data("timepicker",null))}),r.attr("data-toggle","timepicker"),r.timepicker()}}}]),angular.module("$strap.directives").directive("bsTooltip",["$parse","$compile",function(e,t){"use strict";return{restrict:"A",scope:!0,link:function(t,n,r,i){!r.unique||n.on("show",function(e){$(".tooltip.in").each(function(){var e=$(this),t=e.data("tooltip");t&&!t.$element.is(n)&&e.tooltip("hide")})}),n.tooltip({title:t.$eval(r.bsTooltip),html:!0});var s=n.data("tooltip");s.show=function(){var e=$.Event("show");this.$element.trigger(e);if(e.isDefaultPrevented())return;var t=$.fn.tooltip.Constructor.prototype.show.apply(this,arguments);return this.tip().data("tooltip",this),t},s.hide=function(){var e=$.Event("hide");this.$element.trigger(e);if(e.isDefaultPrevented())return;return $.fn.tooltip.Constructor.prototype.hide.apply(this,arguments)},t._tooltip=function(e){n.tooltip(e)},t.hide=function(){n.tooltip("hide")},t.show=function(){n.tooltip("show")},t.dismiss=t.hide}}}]),angular.module("$strap.directives").directive("bsTypeahead",["$parse",function(e){"use strict";return{restrict:"A",require:"?ngModel",link:function(n,r,i,s){var o=e(i.bsTypeahead),u=o.assign,a=o(n);n.$watch(i.bsTypeahead,function(e,t){e!==t&&(a=e)}),r.attr("data-provide","typeahead"),r.typeahead({source:function(e){return angular.isFunction(a)?a.apply(null,arguments):a},minLength:i.minLength||1,items:i.items,updater:function(e){return s&&n.$apply(function(){s.$setViewValue(e)}),e}});var f=r.data("typeahead");f.lookup=function(e){var t;return this.query=this.$element.val()||"",this.query.length<this.options.minLength?this.shown?this.hide():this:(t=$.isFunction(this.source)?this.source(this.query,$.proxy(this.process,this)):this.source,t?this.process(t):this)},i.minLength==="0"&&setTimeout(function(){r.on("focus",function(){setTimeout(r.typeahead.bind(r,"lookup"),200)})})}}}]);
\ No newline at end of file
angular.module("$strap.config",[]).value("$strap.config",{}),angular.module("$strap.filters",["$strap.config"]),angular.module("$strap.directives",["$strap.config"]),angular.module("$strap",["$strap.filters","$strap.directives","$strap.config"]),angular.module("$strap.directives").directive("bsAlert",["$parse","$timeout","$compile",function(t,e,n){"use strict";return{restrict:"A",link:function(e,a,i){var o=t(i.bsAlert),r=(o.assign,o(e));i.bsAlert?e.$watch(i.bsAlert,function(t,o){r=t,a.html((t.title?"<strong>"+t.title+"</strong>&nbsp;":"")+t.content||""),t.closed&&a.hide(),n(a.contents())(e),(t.type||o.type)&&(o.type&&a.removeClass("alert-"+o.type),t.type&&a.addClass("alert-"+t.type)),(angular.isUndefined(i.closeButton)||"0"!==i.closeButton&&"false"!==i.closeButton)&&a.prepend('<button type="button" class="close" data-dismiss="alert">&times;</button>')},!0):(angular.isUndefined(i.closeButton)||"0"!==i.closeButton&&"false"!==i.closeButton)&&a.prepend('<button type="button" class="close" data-dismiss="alert">&times;</button>'),a.addClass("alert").alert(),a.hasClass("fade")&&(a.removeClass("in"),setTimeout(function(){a.addClass("in")}));var s=i.ngRepeat&&i.ngRepeat.split(" in ").pop();a.on("close",function(t){var n;s?(t.preventDefault(),a.removeClass("in"),n=function(){a.trigger("closed"),e.$parent&&e.$parent.$apply(function(){for(var t=s.split("."),n=e.$parent,a=0;t.length>a;++a)n&&(n=n[t[a]]);n&&n.splice(e.$index,1)})},$.support.transition&&a.hasClass("fade")?a.on($.support.transition.end,n):n()):r&&(t.preventDefault(),a.removeClass("in"),n=function(){a.trigger("closed"),e.$apply(function(){r.closed=!0})},$.support.transition&&a.hasClass("fade")?a.on($.support.transition.end,n):n())})}}}]),angular.module("$strap.directives").directive("bsButton",["$parse","$timeout",function(t){"use strict";return{restrict:"A",require:"?ngModel",link:function(e,n,a,i){if(i){n.parent('[data-toggle="buttons-checkbox"], [data-toggle="buttons-radio"]').length||n.attr("data-toggle","button");var o=!!e.$eval(a.ngModel);o&&n.addClass("active"),e.$watch(a.ngModel,function(t,e){var a=!!t,i=!!e;a!==i?$.fn.button.Constructor.prototype.toggle.call(r):a&&!o&&n.addClass("active")})}n.hasClass("btn")||n.on("click.button.data-api",function(){n.button("toggle")}),n.button();var r=n.data("button");r.toggle=function(){if(!i)return $.fn.button.Constructor.prototype.toggle.call(this);var a=n.parent('[data-toggle="buttons-radio"]');a.length?(n.siblings("[ng-model]").each(function(n,a){t($(a).attr("ng-model")).assign(e,!1)}),e.$digest(),i.$modelValue||(i.$setViewValue(!i.$modelValue),e.$digest())):e.$apply(function(){i.$setViewValue(!i.$modelValue)})}}}}]).directive("bsButtonsCheckbox",["$parse",function(){"use strict";return{restrict:"A",require:"?ngModel",compile:function(t){t.attr("data-toggle","buttons-checkbox").find("a, button").each(function(t,e){$(e).attr("bs-button","")})}}}]).directive("bsButtonsRadio",["$parse",function(){"use strict";return{restrict:"A",require:"?ngModel",compile:function(t,e){return t.attr("data-toggle","buttons-radio"),e.ngModel||t.find("a, button").each(function(t,e){$(e).attr("bs-button","")}),function(t,e,n,a){a&&(e.find("[value]").button().filter('[value="'+t.$eval(n.ngModel)+'"]').addClass("active"),e.on("click.button.data-api",function(e){t.$apply(function(){a.$setViewValue($(e.target).closest("button").attr("value"))})}),t.$watch(n.ngModel,function(a,i){if(a!==i){var o=e.find('[value="'+t.$eval(n.ngModel)+'"]');o.length&&$.fn.button.Constructor.prototype.toggle.call(o.data("button"))}}))}}}}]),angular.module("$strap.directives").directive("bsButtonSelect",["$parse","$timeout",function(t){"use strict";return{restrict:"A",require:"?ngModel",link:function(e,n,a,i){var o=t(a.bsButtonSelect);o.assign,i&&(n.text(e.$eval(a.ngModel)),e.$watch(a.ngModel,function(t){n.text(t)}));var r,s,u,c;n.bind("click",function(){r=o(e),s=i?e.$eval(a.ngModel):n.text(),u=r.indexOf(s),c=u>r.length-2?r[0]:r[u+1],console.warn(r,c),e.$apply(function(){n.text(c),i&&i.$setViewValue(c)})})}}}]),angular.module("$strap.directives").directive("bsDatepicker",["$timeout","$strap.config",function(t,e){"use strict";var n="ontouchstart"in window&&!window.navigator.userAgent.match(/PhantomJS/i),a=function a(t){return t=t||"en",{"/":"[\\/]","-":"[-]",".":"[.]"," ":"[\\s]",dd:"(?:(?:[0-2]?[0-9]{1})|(?:[3][01]{1}))",d:"(?:(?:[0-2]?[0-9]{1})|(?:[3][01]{1}))",mm:"(?:[0]?[1-9]|[1][012])",m:"(?:[0]?[1-9]|[1][012])",DD:"(?:"+$.fn.datepicker.dates[t].days.join("|")+")",D:"(?:"+$.fn.datepicker.dates[t].daysShort.join("|")+")",MM:"(?:"+$.fn.datepicker.dates[t].months.join("|")+")",M:"(?:"+$.fn.datepicker.dates[t].monthsShort.join("|")+")",yyyy:"(?:(?:[1]{1}[0-9]{1}[0-9]{1}[0-9]{1})|(?:[2]{1}[0-9]{3}))(?![[0-9]])",yy:"(?:(?:[0-9]{1}[0-9]{1}))(?![[0-9]])"}},i=function i(t,e){var n,i=t,o=a(e);return n=0,angular.forEach(o,function(t,e){i=i.split(e).join("${"+n+"}"),n++}),n=0,angular.forEach(o,function(t){i=i.split("${"+n+"}").join(t),n++}),RegExp("^"+i+"$",["i"])};return{restrict:"A",require:"?ngModel",link:function(t,a,o,r){var s=e.datepicker||{},u=o.language||s.language||"en",c=o.dateFormat||s.format||$.fn.datepicker.dates[u]&&$.fn.datepicker.dates[u].format||"mm/dd/yyyy",l=n?"yyyy/mm/dd":i(c,u);if(r&&r.$parsers.unshift(function(t){return!t||l.test(t)?(r.$setValidity("date",!0),t):(r.$setValidity("date",!1),void 0)}),n&&"text"===a.prop("type"))a.prop("type","date"),a.on("change",function(){t.$apply(function(){r.$setViewValue(a.val())})});else{r&&a.on("changeDate",function(){t.$apply(function(){r.$setViewValue(a.val())})});var d=a.closest(".popover");d&&d.on("hide",function(){var t=a.data("datepicker");t&&(t.picker.remove(),a.data("datepicker",null))}),a.attr("data-toggle","datepicker"),a.datepicker({autoclose:!0,format:c,language:u,forceParse:o.forceParse||!1})}var p=a.siblings('[data-toggle="datepicker"]');p.length&&p.on("click",function(){a.trigger("focus")})}}}]),angular.module("$strap.directives").directive("bsDaterangepicker",["$timeout",function(){"use strict";return"ontouchstart"in window&&!window.navigator.userAgent.match(/PhantomJS/i),{restrict:"A",require:"?ngModel",link:function(t,e){console.log("postLink",this,arguments),window.element=e,e.attr("data-toggle","daterangepicker"),e.daterangepicker({})}}}]),angular.module("$strap.directives").directive("bsDropdown",["$parse","$compile","$timeout",function(t,e,n){"use strict";var a=function(t,e){return e||(e=['<ul class="dropdown-menu" role="menu" aria-labelledby="drop1">',"</ul>"]),angular.forEach(t,function(t,n){if(t.divider)return e.splice(n+1,0,'<li class="divider"></li>');var i="<li"+(t.submenu&&t.submenu.length?' class="dropdown-submenu"':"")+">"+'<a tabindex="-1" ng-href="'+(t.href||"")+'"'+(t.click?'" ng-click="'+t.click+'"':"")+(t.target?'" target="'+t.target+'"':"")+">"+(t.text||"")+"</a>";t.submenu&&t.submenu.length&&(i+=a(t.submenu).join("\n")),i+="</li>",e.splice(n+1,0,i)}),e};return{restrict:"EA",scope:!0,link:function(i,o,r){var s=t(r.bsDropdown),u=s(i);n(function(){!angular.isArray(u);var t=angular.element(a(u).join(""));t.insertAfter(o),e(o.next("ul.dropdown-menu"))(i)}),o.addClass("dropdown-toggle").attr("data-toggle","dropdown")}}}]),angular.module("$strap.directives").directive("bsModal",["$parse","$compile","$http","$timeout","$q","$templateCache",function(t,e,n,a,i,o){"use strict";return{restrict:"A",scope:!0,link:function(r,s,u){var c=t(u.bsModal),l=(c.assign,c(r));i.when(o.get(l)||n.get(l,{cache:!0})).then(function(t){angular.isObject(t)&&(t=t.data);var n=c(r).replace(".html","").replace(/[\/|\.|:]/g,"-")+"-"+r.$id,i=$('<div class="modal hide" tabindex="-1"></div>').attr("id",n).attr("data-backdrop",u.backdrop||!0).attr("data-keyboard",u.keyboard||!0).addClass(u.modalClass?"fade "+u.modalClass:"fade").html(t);$("body").append(i),s.attr("href","#"+n).attr("data-toggle","modal"),a(function(){e(i)(r)}),r._modal=function(t){i.modal(t)},r.hide=function(){i.modal("hide")},r.show=function(){i.modal("show")},r.dismiss=r.hide,i.on("show",function(t){r.$emit("modal-show",t)}),i.on("shown",function(t){r.$emit("modal-shown",t)}),i.on("hide",function(t){r.$emit("modal-hide",t)}),i.on("hidden",function(t){r.$emit("modal-hidden",t)})})}}}]),angular.module("$strap.directives").directive("bsNavbar",["$location",function(t){"use strict";return{restrict:"A",link:function(e,n){e.$watch(function(){return t.path()},function(t){n.find("li[data-match-route]").each(function(e,n){var a=angular.element(n),i=a.attr("data-match-route"),o=RegExp("^"+i+"$",["i"]);o.test(t)?a.addClass("active"):a.removeClass("active")})})}}}]),angular.module("$strap.directives").directive("bsPopover",["$parse","$compile","$http","$timeout","$q","$templateCache",function(t,e,n,a,i,o){"use strict";return $("body").on("keyup",function(t){27===t.keyCode&&$(".popover.in").each(function(){$(this).popover("hide")})}),{restrict:"A",scope:!0,link:function(a,r,s){var u=t(s.bsPopover),c=(u.assign,u(a)),l={};angular.isObject(c)&&(l=c),i.when(l.content||o.get(c)||n.get(c,{cache:!0})).then(function(t){angular.isObject(t)&&(t=t.data),s.unique&&r.on("show",function(){$(".popover.in").each(function(){var t=$(this),e=t.data("popover");e&&!e.$element.is(r)&&t.popover("hide")})}),s.hide&&a.$watch(s.hide,function(t,e){t?n.hide():t!==e&&n.show()}),r.popover(angular.extend({},l,{content:t,html:!0}));var n=r.data("popover");n.hasContent=function(){return this.getTitle()||t},n.getPosition=function(){var t=$.fn.popover.Constructor.prototype.getPosition.apply(this,arguments);return e(this.$tip)(a),a.$digest(),this.$tip.data("popover",this),t},a._popover=function(t){r.popover(t)},a.hide=function(){r.popover("hide")},a.show=function(){r.popover("show")},a.dismiss=a.hide})}}}]),angular.module("$strap.directives").directive("bsTabs",["$parse","$compile","$timeout",function(t,e,n){"use strict";return{restrict:"A",require:"?ngModel",scope:!0,link:function(a,i,o,r){var s=t(o.bsTabs),u=(s.assign,s(a)),c=['<ul class="nav nav-tabs">',"</ul>"],l=['<div class="tab-content">',"</div>"];i.hide();var d=0;n(function(){angular.isArray(u)||(u=[],i.children("[data-title], [data-tab]").each(function(){var t=angular.element(this);u.push({title:a.$eval(t.data("title")||t.data("tab")),content:this.innerHTML,active:t.hasClass("active"),fade:t.hasClass("fade")})})),angular.forEach(u,function(t,e){t.active&&(d=e)}),angular.forEach(u,function(t,e){var n="tab-"+a.$id+"-"+e,i=d===e,r=o.fade||t.fade;c.splice(e+1,0,"<li"+(i?' class="active"':"")+'><a href="#'+n+'" data-index="'+e+'" data-toggle="tab">'+t.title+"</a></li>"),l.splice(e+1,0,'<div class="tab-pane'+(i?" active":"")+(r?" fade":"")+(r&&i?" in":"")+'" id="'+n+'">'+t.content+"</div>")}),i.html(c.join("")+l.join("")).show(),e(i.children("div.tab-content"))(a)}),r&&(i.on("show",function(t){var e=$(t.target);a.$apply(function(){r.$setViewValue(e.data("index"))})}),a.$watch(o.ngModel,function(t){angular.isUndefined(t)||(d=t,setTimeout(function(){var e=i.children("ul.nav-tabs").find("li:eq("+1*t+")");e.hasClass("active")||e.children("a").tab("show")}))}))}}}]),angular.module("$strap.directives").directive("bsTimepicker",["$timeout",function(t){"use strict";var e="((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\\s?(?:am|AM|pm|PM))?)";return{restrict:"A",require:"?ngModel",link:function(n,a,i,o){o&&a.on("changeTime.timepicker",function(){t(function(){o.$setViewValue(a.val())})});var r=RegExp("^"+e+"$",["i"]);o.$parsers.unshift(function(t){return!t||r.test(t)?(o.$setValidity("time",!0),t):(o.$setValidity("time",!1),void 0)}),a.attr("data-toggle","timepicker"),a.parent().addClass("bootstrap-timepicker"),a.timepicker()}}}]),angular.module("$strap.directives").directive("bsTooltip",["$parse","$compile",function(t){"use strict";return{restrict:"A",scope:!0,link:function(e,n,a){var i=t(a.bsTooltip),o=(i.assign,i(e));e.$watch(a.bsTooltip,function(t,e){t!==e&&(o=t)}),a.unique&&n.on("show",function(){$(".tooltip.in").each(function(){var t=$(this),e=t.data("tooltip");e&&!e.$element.is(n)&&t.tooltip("hide")})}),n.tooltip({title:function(){return angular.isFunction(o)?o.apply(null,arguments):o},html:!0});var r=n.data("tooltip");r.show=function(){var t=$.fn.tooltip.Constructor.prototype.show.apply(this,arguments);return this.tip().data("tooltip",this),t},e._tooltip=function(t){n.tooltip(t)},e.hide=function(){n.tooltip("hide")},e.show=function(){n.tooltip("show")},e.dismiss=e.hide}}}]),angular.module("$strap.directives").directive("bsTypeahead",["$parse",function(t){"use strict";return{restrict:"A",require:"?ngModel",link:function(e,n,a,i){var o=t(a.bsTypeahead),r=(o.assign,o(e));e.$watch(a.bsTypeahead,function(t,e){t!==e&&(r=t)}),n.attr("data-provide","typeahead"),n.typeahead({source:function(){return angular.isFunction(r)?r.apply(null,arguments):r},minLength:a.minLength||1,items:a.items,updater:function(t){return i&&e.$apply(function(){i.$setViewValue(t)}),t}});var s=n.data("typeahead");s.lookup=function(){var t;return this.query=this.$element.val()||"",this.query.length<this.options.minLength?this.shown?this.hide():this:(t=$.isFunction(this.source)?this.source(this.query,$.proxy(this.process,this)):this.source,t?this.process(t):this)},"0"===a.minLength&&setTimeout(function(){n.on("focus",function(){0===n.val().length&&setTimeout(n.typeahead.bind(n,"lookup"),200)})})}}}]);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment