diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d0567940a..43654ba60 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -277,7 +277,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](forge-di/forge-di.d.ts) [forge-di](https://github.com/nkohari/forge) by [Adam Carr](https://github.com/adamcarr) * [:link:](form-data/form-data.d.ts) [form-data](https://github.com/felixge/node-form-data) by [Carlos Ballesteros Velasco](https://github.com/soywiz) * [:link:](formidable/formidable.d.ts) [Formidable](https://github.com/felixge/node-formidable) by [Wim Looman](https://github.com/Nemo157) -* [:link:](foundation/foundation.d.ts) [Foundation](http://foundation.zurb.com) by [Boris Yankov](https://github.com/borisyankov) +* [:link:](foundation/foundation.d.ts) [Foundation](http://foundation.zurb.com) by [Boris Yankov](https://github.com/borisyankov), [George Marshall](https://github.com/georgemarshall), [Boltmade](https://github.com/Boltmade) * [:link:](fpsmeter/FPSMeter.d.ts) [FPSmeter](http://darsa.in/fpsmeter) by [Aaron Lampros](http://github.com/alampros) * [:link:](from/from.d.ts) [from](https://github.com/dominictarr/from) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](fs-extra/fs-extra.d.ts) [fs-extra](https://github.com/jprichardson/node-fs-extra) by [midknight41](https://github.com/midknight41) diff --git a/foundation/foundation-tests.ts b/foundation/foundation-tests.ts index f64c83483..9706fbf97 100644 --- a/foundation/foundation-tests.ts +++ b/foundation/foundation-tests.ts @@ -1,33 +1,346 @@ -/// -/// - -function test_orbit() { - $("#featured").orbit(); - $('#featured').orbit({ - animation: 'fade', - animationSpeed: 800, - timer: true, - resetTimerOnClick: false, - advanceSpeed: 4000, - pauseOnHover: false, - startClockOnMouseOut: false, - startClockOnMouseOutAfter: 1000, - directionalNav: true, - captions: true, - captionAnimation: 'fade', - captionAnimationSpeed: 800, - bullets: false, - bulletThumbs: false, - bulletThumbLocation: '', - afterSlideChange: function () { }, - fluid: true - }); -} - -function test_fluid() { - $("#myModal").reveal(); -} - -function test_joyride() { - $("#chooseID").joyride(); -} \ No newline at end of file +/// +/// + +function empty_callback() : void {} + +function plugin_list() { + return [ + "abide", + "accordion", + "alert", + "clearing", + "dropdown", + "interchange", + "joyride", + "magellan", + "offcanvas", + "orbit", + "reveal", + "slider", + "tab", + "tooltip", + "topbar" + ]; +} + +function abide_patterns() { + var patterns : Foundation.AbidePatterns = {}; + patterns.alpha = /^[a-zA-Z]+$/; + patterns.alpha_numeric = /^[a-zA-Z0-9]+$/; + patterns.integer = /^[-+]?\d+$/; + patterns.number = /^[-+]?[1-9]\d*$/; + patterns.card = /^[0-9]{8}$/; + patterns.cvv = /^([0-9]){3,4}$/; + patterns.email = /^test@example\.org$/; + patterns.url = /http:\/\/www\.google\.com\//; + patterns.domain = /definitelytyped\.org/; + patterns.datetime = /([0-2][0-9]{3})\-([0-1][0-9])\-([0-3][0-9])T([0-5][0-9])\:([0-5][0-9])\:([0-5][0-9])(Z|([\-\+]([0-1][0-9])\:00))/; + patterns.date = /(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))/; + patterns.time = /(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]){2}/; + patterns.dateISO = /\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/; + patterns.month_day_year = /(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d/; + patterns.color = /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/; + return patterns; +} + +function abide_options() { + var opts : Foundation.AbideOptions = {}; + opts.live_validate = false; + opts.validate_on_blur = true; + opts.focus_on_invalid = true; + opts.error_labels = true; + opts.timeout = 500; + opts.patterns = abide_patterns(); + opts.validators = { + diceRoll: function(el : HTMLInputElement, required : boolean, parent : HTMLElement) { + var possibilities = [true, false]; + return possibilities[Math.round(Math.random())]; + }, + isAllowed: function(el : HTMLInputElement, required : boolean, parent : HTMLElement) { + var possibilities = ["a@zurb.com", "b.zurb.com"]; + return possibilities.indexOf(el.value) > -1; + } + } + return opts; +} + +function accordion_options() { + var opts : Foundation.AccordionOptions = {}; + opts.content_class = "content"; + opts.active_class = "class-name"; + opts.multi_expand = false; + opts.toggleable = true; + opts.callback = empty_callback; + return opts; +} + +function alert_options() { + var opts : Foundation.AlertOptions = {}; + opts.callback = empty_callback; + return opts; +} + +function clearing_options() { + var opts : Foundation.ClearingOptions = {}; + opts.templates = { + viewing : '
Some HTML
' + }; + opts.close_selectors = "#id-value, .class-name"; + opts.open_selectors = "li#id-value"; + opts.skip_selector = ".skip-class"; + opts.touch_label = "Display string"; + opts.init = true; + opts.locked = false; + return opts; +} + +function dropdown_options() { + var opts : Foundation.DropdownOptions = {}; + opts.active_class = "class-name"; + opts.disabled_class = "disabled-class"; + opts.mega_class = "big"; + opts.align = "top"; + opts.is_hover = false; + opts.hover_timeout = 250; + opts.opened = empty_callback; + opts.closed = empty_callback; + return opts; +} + +function equalizer_options() { + var opts : Foundation.EqualizerOptions = {}; + opts.use_tallest = true; + opts.equalize_on_stack = false; + return opts; +} + +function interchange_options() { + var opts : Foundation.InterchangeOptions = {}; + opts.load_attr = "interchange"; + opts.named_queries = { + my_custom_query: "only screen and (max-width: 200px)" + }; + opts.directives = { + replace: empty_callback + }; + return opts; +} + +function joyride_options() { + var opts : Foundation.JoyrideOptions = {}; + opts.expose = false; + opts.modal = true; + opts.keyboard = true; + opts.tip_location = "bottom"; + opts.nub_position = "left"; + opts.scroll_speed = 2500; + opts.scroll_animation = "lineaer"; + opts.timer = 100; + opts.start_timer_on_click = true; + opts.start_offset = 3; + opts.next_button = false; + opts.prev_button = false; + opts.tip_animation = "pulse"; + opts.pause_after = [4, 7, 10, 14]; + opts.exposed = ["#elm-id-one", "#elm-id-two"]; + opts.tip_animation_fade_speed = 100; + opts.cookie_monster = true; + opts.cookie_name = "ts_joyride"; + opts.cookie_domain = false; + opts.cookie_expires = 7; + opts.tip_container = '#header'; + opts.tip_location_patterns = { + top: ['botom'], + bottom: [], + left: ['right', 'top', 'bottom'], + right: ['left', 'top', 'bottom'] + }; + opts.post_ride_callback = empty_callback; + opts.post_step_callback = empty_callback; + opts.pre_step_callback = empty_callback; + opts.pre_ride_callback = empty_callback; + opts.post_expose_callback = empty_callback; + opts.template = { + link: '×', + timer: '
', + tip: '
', + wrapper: '
', + button: '', + prev_button: '', + modal: '
', + expose: '
', + expose_cover: '
' + }; + opts.expose_add_class = ".expose .class-name"; + return opts; +} + +function magellan_options() { + var opts : Foundation.MagellanOptions = {}; + opts.active_class = ".active-element"; + opts.threshold = 20; + opts.destination_threshold = 30; + opts.throttle_delay = 24; + opts.fixed_top = 0; + opts.offset_by_height = false; + opts.duration = 1000; + opts.easing = "linear"; + return opts; +} + +function offcanvas_options() { + var opts : Foundation.OffCanvasOptions = {}; + opts.open_method = "overlap_single"; + opts.close_on_click = true; + return opts; +} + +function orbit_options() { + var opts : Foundation.OrbitOptions = {}; + opts.animation = 'slide'; + opts.timer_speed = 10000; + opts.pause_on_hover = true; + opts.resume_on_mouseout = false; + opts.next_on_click = true; + opts.animation_speed = 500; + opts.stack_on_small = false; + opts.navigation_arrows = true; + opts.slide_number = true; + opts.slide_number_text = 'of'; + opts.container_class = 'orbit-container'; + opts.stack_on_small_class = 'orbit-stack-on-small'; + opts.next_class = 'orbit-next'; + opts.prev_class = 'orbit-prev'; + opts.timer_container_class = 'orbit-timer'; + opts.timer_paused_class = 'paused'; + opts.timer_progress_class = 'orbit-progress'; + opts.slides_container_class = 'orbit-slides-container'; + opts.preloader_class = 'preloader'; + opts.slide_selector = 'li'; + opts.bullets_container_class = 'orbit-bullets'; + opts.bullets_active_class = 'active'; + opts.slide_number_class = 'orbit-slide-number'; + opts.caption_class = 'orbit-caption'; + opts.active_slide_class = 'active'; + opts.orbit_transition_class = 'orbit-transitioning'; + opts.bullets = true; + opts.circular = true; + opts.timer = true; + opts.variable_height = false; + opts.swipe = true; + opts.before_slide_change = empty_callback; + opts.after_slide_change = empty_callback; + return opts; +} + +function reveal_css_options() { + var opts : Foundation.RevealCSSOptions = {}; + opts.opacity = 0; + opts.visibility = 'hidden'; + opts.display = "inline-block"; + return opts; +} + +function reveal_options() { + var opts : Foundation.RevealOptions = {}; + opts.animation = "linear"; + opts.animation_speed = 500; + opts.close_on_background_click = false; + opts.dismiss_modal_class = ".modal-bye-bye"; + opts.multiple_opened = true; + opts.bg_class = ".modal-background"; + opts.root_element = "#element-id.element-class"; + opts.on_ajax_error = empty_callback; + opts.open = empty_callback; + opts.opened = empty_callback; + opts.close = empty_callback; + opts.close = empty_callback; + opts.bg = $("#my-modal-id .background"); + opts.css = { + open: reveal_css_options(), + close: reveal_css_options() + }; + return opts; +} + +function slider_options() { + var opts : Foundation.SliderOptions = {}; + opts.start = -1000; + opts.end = 1000; + opts.step = 50; + opts.precision = 4; + opts.initial = 0; + opts.vertical = false; + opts.trigger_input_change = true; + opts.on_change = empty_callback; + return opts; +} + +function tab_options() { + var opts : Foundation.TabOptions = {}; + opts.active_class = "class-name"; + opts.callback = empty_callback; + opts.deep_linking = false; + opts.scroll_to_content = true; + opts.is_hover = false; + return opts; +} + +function tooltip_options() { + var opts : Foundation.TooltipOptions = {}; + opts.additional_inheritable_classes = ["class1", "class2"]; + opts.tooltip_class = "tooltip"; + opts.append_to = "append-class"; + opts.touch_close_text = "Close"; + opts.disable_for_touch = true; + opts.hover_delay = 100; + opts.show_on = "all"; + opts.tip_template = function (selector, content) { + return '' + content + ''; + }; + return opts; +} + +function topbar_options() { + var opts : Foundation.TopbarOptions = {}; + opts.index = 1; + opts.sticky_class = "top-bar"; + opts.custom_back_text = true; + opts.back_text = "Return"; + opts.is_hover = false; + opts.mobile_show_parent_link = true; + opts.scrolltop = true; + opts.sticky_on = "all"; + return opts; +} + +function foundation_options() { + var opts : Foundation.Options = {}; + opts.abide = abide_options(); + opts.accordion = accordion_options(); + opts.alert = alert_options(); + opts.clearing = clearing_options(); + opts.dropdown = dropdown_options(); + opts.equalizer = equalizer_options(); + opts.joyride = joyride_options(); + opts.magellan = magellan_options(); + opts.offcanvas = offcanvas_options(); + opts.orbit = orbit_options(); + opts.reveal = reveal_options(); + opts.slider = slider_options(); + opts.tab = tab_options(); + opts.tooltip = tooltip_options(); + opts.topbar = topbar_options(); + return opts; +} + +$(document).foundation(); + +$(document).foundation(foundation_options()); + +$(document).foundation("reflow"); +plugin_list().forEach((plugin) => $(document).foundation(plugin, "reflow")); + +$(document).foundation("slider", "set_value", 100); diff --git a/foundation/foundation.d.ts b/foundation/foundation.d.ts index d74e954e6..c2dc4fc24 100644 --- a/foundation/foundation.d.ts +++ b/foundation/foundation.d.ts @@ -1,88 +1,317 @@ -// Type definitions for Foundation 3.2 -// Project: http://foundation.zurb.com/ -// Definitions by: Boris Yankov -// Definitions: https://github.com/borisyankov/DefinitelyTyped - - -/// - -interface OrbitOptions { - animation?: string; - animationSpeed?: number; - timer?: boolean; - resetTimerOnClick?: boolean; - advanceSpeed?: number; - pauseOnHover?: boolean; - startClockOnMouseOut?: boolean; - startClockOnMouseOutAfter?: number; - directionalNav?: number; - captions?: number; - captionAnimation?: string; - captionAnimationSpeed?: number; - bullets?: boolean; - bulletThumbs?: boolean; - bulletThumbLocation?: string; - afterSlideChange?: () => void; - fluid?: boolean; -} - -interface RevealOptions { - animation?: string; - animationSpeed?: number; - closeOnBackgroundClick?: boolean; - dismissModalClass?: string; - /** - * The class of the modals background. - */ - bgClass?: string; - open?: () => void; - opened?: () => void; - close?: () => void; - closed?: () => void; - /** - * The modals background object. - */ - bg: JQuery; - /** - * The css property for when the modal is opened and closed. - */ - css: { - open: { - opacity?: number; - visibility?: string; - display: string; - }; - close: { - opacity: number; - visibility: string; - display: string; - }; - }; -} - -interface JoyrideOptions { - tipLocation?: string; - nubPosition?: string; - scrollSpeed?: number; - timer?: number; - startTimerOnClick?: boolean; - nextButton?: boolean; - tipAnimation?: string; - pauseAfter?: number[]; - tipAnimationFadeSpeed?: number; - cookieMonster?: boolean; - cookieName?: string; - cookieDomain?: boolean; - tipContainer?: string; - postRideCallback?: () => void; - postStepCallback?: () => void; -} - -interface JQuery { - orbit(): JQuery; - orbit(OrbitOptions): JQuery; - reveal(): JQuery; - reveal(RevealOptions): JQuery; - joyride(): JQuery; - joyride(JoyrideOptions): JQuery; -} +// Type definitions for Foundation v5.5.1 +// Project: http://foundation.zurb.com/ +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +declare module Foundation { + // http://foundation.zurb.com/docs/components/abide.html#optional-javascript-configuration + interface AbidePatterns { + alpha? : RegExp; + alpha_numeric? : RegExp; + integer? : RegExp; + number? : RegExp; + card? : RegExp; + cvv? : RegExp; + email? : RegExp; + url? : RegExp; + domain? : RegExp; + datetime? : RegExp; + date? : RegExp; + time? : RegExp; + dateISO? : RegExp; + month_day_year? : RegExp; + color? : RegExp; + } + + interface AbideOptions { + live_validate? : boolean; + validate_on_blur? : boolean; + focus_on_invalid? : boolean; + error_labels? : boolean; + timeout? : number; + patterns? : AbidePatterns; + validators? : Object; + } + + // http://foundation.zurb.com/docs/components/accordion.html#optional-javascript-configuration + interface AccordionOptions { + content_class? : string; + active_class? : string; + multi_expand? : boolean; + toggleable? : boolean; + callback? : () => any; + } + + // http://foundation.zurb.com/docs/components/alert_boxes.html + interface AlertOptions { + callback? : () => any; + } + + // http://foundation.zurb.com/docs/components/clearing.html#optional-javascript-configuration + interface ClearingOptions { + templates? : Object; + close_selectors? : string; + open_selectors? : string; + skip_selector? : string; + touch_label? : string; + init? : boolean; + locked? : boolean; + } + + // http://foundation.zurb.com/docs/components/dropdown.html#optional-javascript-configuration + interface DropdownOptions { + active_class? : string; + disabled_class? : string; + mega_class? : string; + align? : string; + is_hover? : boolean; + hover_timeout? : number; + opened? : () => any; + closed? : () => any; + } + + // http://foundation.zurb.com/docs/components/equalizer.html#optional-javascript-configuration + interface EqualizerOptions { + use_tallest? : boolean; + equalize_on_stack? : boolean; + } + + // http://foundation.zurb.com/docs/components/interchange.html#custom-named-queries + interface InterchangeOptions { + load_attr? : string; + named_queries? : Object; + directives? : Object; + } + + // http://foundation.zurb.com/docs/components/joyride.html#optional-javascript-configuration + interface JoyrideOptions { + expose? : boolean; + modal? : boolean; + keyboard? : boolean; + tip_location? : string; + nub_position? : string; + scroll_speed? : number; + scroll_animation? : string; + timer? : number; + start_timer_on_click? : boolean; + start_offset? : number; + next_button? : boolean; + prev_button? : boolean; + tip_animation? : string; + pause_after? : number[]; + exposed? : string[]; + tip_animation_fade_speed? : number; + cookie_monster? : boolean; + cookie_name? : string; + cookie_domain? : boolean; + cookie_expires? : number; + tip_container? : string; + tip_location_patterns? : { + top? : string[]; + bottom? : string[]; + left? : string[]; + right? : string[]; + }; + post_ride_callback? : () => void; + post_step_callback? : () => void; + pre_step_callback? : () => void; + pre_ride_callback? : () => void; + post_expose_callback? : () => void; + template? : { + link? : string; + timer? : string; + tip? : string; + wrapper? : string; + button? : string; + modal? : string; + expose? : string; + expose_cover? : string; + }; + expose_add_class? : string; + } + + // http://foundation.zurb.com/docs/components/magellan.html#js + interface MagellanOptions { + active_class? : string; + threshold? : number; + destination_threshold? : number; + throttle_delay? : number; + fixed_top? : number; + offset_by_height? : boolean; + duration? : number; + easing? : string; + } + + // http://foundation.zurb.com/docs/components/offcanvas.html#optional-javascript-configuration + interface OffCanvasOptions { + open_method? : string; + close_on_click? : boolean; + } + + // http://foundation.zurb.com/docs/components/orbit.html#advanced + interface OrbitOptions { + animation? : string; + timer_speed? : number; + pause_on_hover? : boolean; + resume_on_mouseout? : boolean; + next_on_click? : boolean; + animation_speed? : number; + stack_on_small? : boolean; + navigation_arrows? : boolean; + slide_number? : boolean; + slide_number_text? : string; + container_class? : string; + stack_on_small_class? : string; + next_class? : string; + prev_class? : string; + timer_container_class? : string; + timer_paused_class? : string; + timer_progress_class? : string; + slides_container_class? : string; + preloader_class? : string; + slide_selector? : string; + bullets_container_class? : string; + bullets_active_class? : string; + slide_number_class? : string; + caption_class? : string; + active_slide_class? : string; + orbit_transition_class? : string; + bullets? : boolean; + circular? : boolean; + timer? : boolean; + variable_height? : boolean; + swipe? : boolean; + before_slide_change? : () => any; + after_slide_change? : () => any; + } + + // http://foundation.zurb.com/docs/components/reveal.html + interface RevealCSSOptions { + opacity? : number; + visibility? : string; + display? : string; + } + + interface RevealOptions { + animation? : string; + animation_speed? : number; + close_on_background_click? : boolean; + dismiss_modal_class? : string; + multiple_opened? : boolean; + bg_class? : string; + root_element? : string; + on_ajax_error? : () => any; + open? : () => any; + opened? : () => any; + close? : () => any; + closed? : () => any; + bg? : JQuery; + css? : { + open? : RevealCSSOptions; + close? : RevealCSSOptions; + }; + } + + // http://foundation.zurb.com/docs/components/range_slider.html + interface SliderOptions { + start? : number; + end? : number; + step? : number; + precision? : number; + initial? : number; + vertical? : boolean; + trigger_input_change? : boolean; + on_change? : () => any; + } + + // http://foundation.zurb.com/docs/components/tabs.html + interface TabOptions { + active_class? : string; + callback? : () => any; + deep_linking? : boolean; + scroll_to_content? : boolean; + is_hover? : boolean; + } + + interface TooltipOptions { + additional_inheritable_classes? : string[]; + tooltip_class? : string; + append_to? : string; + touch_close_text? : string; + disable_for_touch? : boolean; + hover_delay? : number; + show_on? : string; + tip_template? : (selector : string, content : string) => string; + } + + interface TopbarOptions { + index? : number; + sticky_class? : string; + custom_back_text? : boolean; + back_text? : string; + is_hover? : boolean; + mobile_show_parent_link? : boolean; + scrolltop? : boolean; + sticky_on? : string; + } + + interface Options { + abide? : AbideOptions; + accordion? : AccordionOptions; + alert? : AlertOptions; + clearing? : ClearingOptions; + dropdown? : DropdownOptions; + equalizer? : EqualizerOptions; + interchange? : InterchangeOptions; + joyride? : JoyrideOptions; + magellan? : MagellanOptions; + offcanvas? : OffCanvasOptions; + orbit? : OrbitOptions; + reveal? : RevealOptions; + slider? : SliderOptions; + tab? : TabOptions; + tooltip? : TooltipOptions; + topbar? : TopbarOptions; + } + + interface FoundationStatic { + name : string; + version : string; + media_queries : Object; + stylesheet : CSSStyleSheet; + global : { + namespace : string; + }; + init(scope : JQuery) : JQuery; + init(scope : JQuery, libraries : Options) : JQuery; + init(scope : JQuery, libraries : string, method : Options) : JQuery; + init(scope : JQuery, libraries : string, method : string, options : Object) : JQuery; + init_lib(lib : any, args : any) : (...args : any[]) => any; + patch(lib : any) : void; + inherit(scope : JQuery, methods : string) : void; + set_namespace() : void; + libs : any; + utils : { + S(selector : any, context : any) : JQuery; + throttle(func : (...args : any[]) => any, delay : number) : (...args : any[]) => any; + debounce(func : (...args : any[]) => any, delay : number, immediate : boolean) : (...args : any[]) => any; + data_options(el : JQuery) : Object; + register_media(media : string, media_class : string) : void; + add_custom_rule(rule : string, media : string) : void; + image_loaded(images : JQuery, callback : (...args : any[]) => any) : void; + random_str(length? : number) : string; + }; + } +} + +interface JQuery { + foundation() : JQuery; + foundation(libraries : Foundation.Options | string) : JQuery; + foundation(libraries : string, method : Foundation.Options | string) : JQuery; + foundation(libraries : string, method : string, options : Object) : JQuery; +} + +declare var Foundation : Foundation.FoundationStatic;