From 8813939634ce428363c432f9c3ef5837a0f91f90 Mon Sep 17 00:00:00 2001 From: allipierre Date: Mon, 20 Nov 2017 15:46:15 +0100 Subject: [PATCH 01/22] add optional Parameter to confirmOptions --- types/confirmDialog/index.d.ts | 98 ++++ types/confirmDialog/jquery-confirm.ts | 644 ++++++++++++++++++++++++++ types/confirmDialog/tsconfig.json | 21 + types/confirmDialog/tslint.json | 31 ++ 4 files changed, 794 insertions(+) create mode 100644 types/confirmDialog/index.d.ts create mode 100644 types/confirmDialog/jquery-confirm.ts create mode 100644 types/confirmDialog/tsconfig.json create mode 100644 types/confirmDialog/tslint.json diff --git a/types/confirmDialog/index.d.ts b/types/confirmDialog/index.d.ts new file mode 100644 index 0000000000..d205b45957 --- /dev/null +++ b/types/confirmDialog/index.d.ts @@ -0,0 +1,98 @@ +// Type definitions for jquery-confirm v3.3.0 https://craftpip.github.io/jquery-confirm/ +// Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js +// Definitions by: Alli Pierre Yotti https://github.com/allipierre +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface JQueryStatic { + /** + * confirm Dialog + * @param {confirmOptions} pOtions + */ + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + + /** + * confirm alert + * @param {any} pMessage + */ + alert( pMessage?: any | string, title?:string): void; + + /** + * confirm Dialog + * @param {any} pMessage + */ + dialog( pOtions: options.confirmOptions | string): void; +} + + +interface JQuery { + /** + * confirm Dialog + * @param {confirmOptions} pOtions + */ + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + + /** + * confirm alert + * @param {any} pMessage + */ + alert( pMessage?: any, title?:string): void; + + /** + * confirm Dialog + * @param {any} pMessage + */ + dialog( pOtions: options.confirmOptions | any): void; +} + +interface Window { + setContentAppend: any; +} + + + +declare namespace options { + + interface confirmOptions { + buttons? : buttonOptionss | any, + title? : string | boolean, + content? : string | Function, + onContentReady?: Function, + lazyOpen?: boolean, + closeIcon?: boolean | Function, + type?: string, + typeAnimated?: boolean, + icon?: string, + closeIconClass?: string, + columnClass?: string, + containerFluid?: boolean, + boxWidth?: string, + useBootstrap?: boolean, + bootstrapClasses?: any, + draggable?: boolean, + dragWindowBorder?: boolean, + dragWindowGap?: number, + contentLoaded?: Function, + autoClose?: String, + backgroundDismiss?: boolean | Function | string, + backgroundDismissAnimation?: string, + escapeKey?: string | boolean, + onOpenBefore?:Function, + onOpen?: Function, + onClose?: Function, + onDestroy?: Function, + onAction?: Function + + + } + + interface buttonOptionss { + cancel?: Function, + confirm?: Function + } + +} + +declare namespace jconfirm { + let defaults: any; + +} diff --git a/types/confirmDialog/jquery-confirm.ts b/types/confirmDialog/jquery-confirm.ts new file mode 100644 index 0000000000..109558a737 --- /dev/null +++ b/types/confirmDialog/jquery-confirm.ts @@ -0,0 +1,644 @@ +/// +/// +namespace server { + export interface Iperson { + title: string, + content: string, + + + } +} + +class Confirm implements server.Iperson { + private title_: string; + private conTent_: string; + constructor(public title: string, public content: string) { + this.title_ = title; + this.conTent_ = content; + } + + + public confirm() { + $.confirm({ + title: 'Confirm!', + content: 'Simple confirm!', + buttons: { + confirm: function() { + $.alert('Confirmed!'); + }, + cancel: function(cancel: string) { + $.alert('Canceled! ' + cancel); + }, + somethingElse: { + text: 'Something else', + btnClass: 'btn-blue', + keys: ['enter', 'shift'], + action: function() { + alert('Something else?'); + } + } + } + }); + } + + public alert() { + $.alert({ + title: 'Alert!', + content: 'Simple alert!', + }); + } + + public confirm1() { + $.confirm({ + title: 'Prompt!', + content: '' + + '
' + + '
' + + '' + + '' + + '
' + + '
', + buttons: { + formSubmit: { + text: 'Submit', + btnClass: 'btn-blue', + action: function() { + let name = this.$content.find('.name').val(); + if (!name) { + $.alert('provide a valid name'); + return false; + } + $.alert('Your name is ' + name); + } + }, + cancel: function() { + //close + }, + }, + onContentReady: function() { + // bind to events + var jc = this; + this.$content.find('form').on('submit', function(e) { + // if the user submits the form by pressing enter in the field. + e.preventDefault(); + jc.$$formSubmit.trigger('click'); // reference the button and click it + }); + } + }); + + } + + public dialog() { + $.dialog({ + title: 'Text content!', + content: 'Simple modal!' + }); + } + public confirm_2() { + $('.atwitter').val(); + $('.atwitter').text(); + $('a.twitter').confirm({ + content: "...", + }); + $('a.twitter').confirm({ + buttons: { + hey: function() { + location.href = this.$target.attr('href'); + } + } + }); + } + + public confirm_3() { + $.alert('Content here', 'Title here'); + $.confirm('A message', 'Title is optional'); + $.dialog('Just to let you know'); + } + + public confirm_4() { + var a = $.confirm({ + lazyOpen: true, + }); + a.open(); + a.close(); + a.toggle(); // toggle open close. + + } + + public confirm_5() { + $.confirm({ + buttons: { + hello: function(helloButton) { + // shorthand method to define a button + // the button key will be used as button name + }, + hey: function(heyButton) { + // access the button using jquery + this.$$hello.trigger('click'); // click the 'hello' button + this.$$hey.prop('disabled', true); // disable the current button using jquery method + + // jconfirm button methods, all methods listed here + this.buttons.hello.setText('Helloooo'); // setText for 'hello' button + this.buttons.hey.disable(); // disable with button function provided by jconfirm + this.buttons.hey.enable(); // enable with button function provided by jconfirm + // the button's instance is passed as the first argument, for quick access + heyButton === this.buttons.hey + }, + heyThere: { + text: 'Hey there!', // text for button + btnClass: 'btn-blue', // class for the button + keys: ['enter', 'a'], // keyboard event for button + isHidden: false, // initially not hidden + isDisabled: false, // initially not disabled + action: function(heyThereButton) { + // longhand method to define a button + // provides more features + } + }, + } + }); + + } + + public confirm_6() { + $.confirm({ + buttons: { + hey: function() { + // here the button key 'hey' will be used as the text. + $.alert('You clicked on "hey".'); + }, + heyThere: { + text: 'hey there!', // With spaces and symbols + action: function() { + $.alert('You clicked on "heyThere"'); + } + } + } + }); + } + + public confirm_7() { + $.confirm({ + content: 'Time to use your keyboard, press shift, alert, A or B', + buttons: { + specialKey: { + text: 'On behalf of shift', + keys: ['shift', 'alt'], + action: function() { + $.alert('Shift or Alt was pressed'); + } + }, + alphabet: { + text: 'A, B', + keys: ['a', 'b'], + action: function() { + $.alert('A or B was pressed'); + } + } + } + }); + } + + public confirm_8() { + $.confirm({ + closeIcon: true, // explicitly show the close icon + buttons: { + buttonA: { + text: 'button a', + action: function(buttonA) { + this.buttons.resetButton.setText('reset button!!!'); + this.buttons.resetButton.disable(); + this.buttons.resetButton.enable(); + this.buttons.resetButton.hide(); + this.buttons.resetButton.show(); + this.buttons.resetButton.addClass('btn-red'); + this.buttons.resetButton.removeClass('btn-red'); + // or + this.$$resetButton // button's jquery element reference, go crazy + this.buttons.buttonA == buttonA // both are the same. + return false; // prevent the modal from closing + } + }, + resetButton: function(resetButton) {} + } + }); + } + + + public confirm_9() { + $.confirm({ + title: 'Encountered an error!', + content: 'Something went downhill, this may be serious', + type: 'red', + typeAnimated: true, + buttons: { + tryAgain: { + text: 'Try again', + btnClass: 'btn-red', + action: function() {} + }, + close: function() {} + } + }); + } + + public confirm_10() { + $.confirm({ + icon: 'glyphicon glyphicon-heart', + title: 'glyphicon' + }); + $.confirm({ + icon: 'fa fa-warning', + title: 'font-awesome' + }); + $.confirm({ + icon: 'fa fa-spinner fa-spin', + title: 'Working!', + content: 'Sit back, we are processing your request!' + }); + } + + public confirm_11() { + $.confirm({ + closeIcon: true + }); + + $.confirm({ + closeIcon: true, + closeIconClass: 'fa fa-close' + }); + } + + public confirm_12() { + $.confirm({ + closeIcon: function() { + return false; + }, + buttons: { + aRandomButton: function() { + $.alert('A random button is called, and i prevent closing the modal'); + return false; // you shall not pass + }, + close: function() {} + } + }); + } + + public confirm_13() { + $.confirm({ + columnClass: 'small' + }); + $.confirm({ + columnClass: 'col-md-4 col-md-offset-4', + }); + $.confirm({ + columnClass: 'col-md-12' + }); + $.confirm({ + columnClass: 'col-md-4 col-md-offset-8 col-xs-4 col-xs-offset-8', + containerFluid: true, // this will add 'container-fluid' instead of 'container' + }); + } + + public confirm_14() { + $.confirm({ + boxWidth: '30%', + useBootstrap: false, + }); + $.confirm({ + boxWidth: '500px', + useBootstrap: false, + }); + } + + public confirm_15() { + $.confirm({ + bootstrapClasses: { + container: 'container', + containerFluid: 'container-fluid', + row: 'row', + }, + }); + + $.confirm({ + title: 'Hello there', + content: 'click and hold on the title to drag', + draggable: true, + }); + + $.confirm({ + title: 'Hello there', + content: 'Drag this modal out of the window', + draggable: true, + dragWindowBorder: false, + }); + $.confirm({ + title: 'Hello there', + content: 'try to drag this modal out of the window', + draggable: true, + dragWindowGap: 0, // number of px of distance + }); + } + + public ajaxLoading() { + $.confirm({ + title: 'Title', + content: 'url:text.txt', + onContentReady: function() { + var self = this; + this.setContentPrepend('
Prepended text
'); + setTimeout(function() { + self.setContentAppend('
Appended text after 2 seconds
'); + }, 2000); + }, + columnClass: 'medium', + }); + + $.confirm({ + content: function() { + var self = this; + return $.ajax({ + url: 'bower.json', + dataType: 'json', + method: 'get' + }).done(function(response) { + self.setContent('Description: ' + response.description); + self.setContentAppend('
Version: ' + response.version); + self.setTitle(response.name); + }).fail(function() { + self.setContent('Something went wrong.'); + }); + } + }); + + $.confirm({ + content: 'url:text.txt', + contentLoaded: function(data, status, xhr) { + // data is already set in content + this.setContentAppend('
Status: ' + status); + } + }); + + $.confirm({ + content: function() { + var self = this; + self.setContent('Checking callback flow'); + return $.ajax({ + url: 'bower.json', + dataType: 'json', + method: 'get' + }).done(function(response) { + self.setContentAppend('
Done!
'); + }).fail(function() { + self.setContentAppend('
Fail!
'); + }).always(function() { + self.setContentAppend('
Always!
'); + }); + }, + contentLoaded: function(data, status, xhr) { + self.setContentAppend('
Content loaded!
'); + }, + onContentReady: function() { + this.setContentAppend('
Content ready!
'); + } + }); + + } + + public autoClose() { + $.confirm({ + title: 'Delete user?', + content: 'This dialog will automatically trigger \'cancel\' in 6 seconds if you don\'t respond.', + autoClose: 'cancelAction|8000', + buttons: { + deleteUser: { + text: 'delete user', + action: function() { + $.alert('Deleted the user!'); + } + }, + cancelAction: function() { + $.alert('action is canceled'); + } + } + }); + $.confirm({ + title: 'Logout?', + content: 'Your time is out, you will be automatically logged out in 10 seconds.', + autoClose: 'logoutUser|10000', + buttons: { + logoutUser: { + text: 'logout myself', + action: function() { + $.alert('The user was logged out'); + } + }, + cancel: function() { + $.alert('canceled'); + } + } + }); + } + + public backgroundDismisse() { + $.confirm({ + backgroundDismiss: true, // this will just close the modal + }); + $.confirm({ + backgroundDismiss: function() { + return false; // modal wont close. + }, + }); + $.confirm({ + backgroundDismiss: function() { + return 'buttonName'; // the button will handle it + }, + }); + $.confirm({ + backgroundDismiss: 'buttonName', + content: 'in here the backgroundDismiss action is handled by buttonName' + + '
', + buttons: { + buttonName: function() { + var $checkbox = this.$content.find('#enableCheckbox'); + return $checkbox.prop('checked'); + }, + close: function() {} + } + }); + } + + public backgroundDismisseAnimation(){ + $.confirm({ + backgroundDismiss: false, + backgroundDismissAnimation: 'shake', +}); +$.confirm({ + backgroundDismiss: false, + backgroundDismissAnimation: 'glow', +}); + } + + public escapeKey(){ + $.confirm({ + escapeKey: true, + backgroundDismiss: false, +}); +$.confirm({ + escapeKey: 'buttonName', + buttons: { + buttonName: function(){ + $.alert('Button name was called'); + }, + close: function(){ + } + } +}); + } + public rtlSupport(){ + $.alert({ + title: 'پیغام', + content: 'این یک متن به زبان شیرین فارسی است', + rtl: true, + closeIcon: true, + buttons: { + confirm: { + text: 'تایید', + btnClass: 'btn-blue', + action: function () { + $.alert('تایید شد.'); + } + }, + cancel: { + text: 'انصراف', + action: function () { + } + } + } +}); + + } + + public callBack(){ + $.confirm({ + title: false, + content: 'url:callback.html', + onContentReady: function () { + // when content is fetched & rendered in DOM + alert('onContentReady'); + var self = this; + this.buttons.ok.disable(); + this.$content.find('.btn').click(function(){ + self.$content.find('input').val('Chuck norris'); + self.buttons.ok.enable(); + }); + }, + contentLoaded: function(data, status, xhr){ + // when content is fetched + alert('contentLoaded: ' + status); + }, + onOpenBefore: function () { + // before the modal is displayed. + alert('onOpenBefore'); + }, + onOpen: function () { + // after the modal is displayed. + alert('onOpen'); + }, + onClose: function () { + // before the modal is hidden. + alert('onClose'); + }, + onDestroy: function () { + // when the modal is removed from DOM + alert('onDestroy'); + }, + onAction: function (btnName) { + // when a button is clicked, with the button name + alert('onAction: ' + btnName); + }, + buttons: { + ok: function(){ + } + } +}); + } + public globalSettings(){ + jconfirm.defaults = { + title: 'Hello', + titleClass: '', + type: 'default', + typeAnimated: true, + draggable: true, + dragWindowGap: 15, + dragWindowBorder: true, + animateFromElement: true, + smoothContent: true, + content: 'Are you sure to continue?', + buttons: {}, + defaultButtons: { + ok: { + action: function () { + } + }, + close: { + action: function () { + } + }, + }, + contentLoaded: function(data, status, xhr){ + }, + icon: '', + lazyOpen: false, + bgOpacity: null, + theme: 'light', + animation: 'scale', + closeAnimation: 'scale', + animationSpeed: 400, + animationBounce: 1, + rtl: false, + container: 'body', + containerFluid: false, + backgroundDismiss: false, + backgroundDismissAnimation: 'shake', + autoClose: false, + closeIcon: null, + closeIconClass: false, + watchInterval: 100, + columnClass: 'col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1', + boxWidth: '50%', + scrollToPreviousElement: true, + scrollToPreviousElementAnimate: true, + useBootstrap: true, + offsetTop: 40, + offsetBottom: 40, + bootstrapClasses: { + container: 'container', + containerFluid: 'container-fluid', + row: 'row', + }, + onContentReady: function () {}, + onOpenBefore: function () {}, + onOpen: function () {}, + onClose: function () {}, + onDestroy: function () {}, + onAction: function () {} +}; + } + + public api(){ + var jc = $.confirm({ + title: 'awesome', + onContentReady: function(){ + // this === jc + //jc.setTitle(title: string); + } +}); + } + +} + + +var firstName: string = 'Pierre'; +var lastName: string = 'Yotti'; +var type = new Confirm(firstName, lastName); diff --git a/types/confirmDialog/tsconfig.json b/types/confirmDialog/tsconfig.json new file mode 100644 index 0000000000..6949afdda5 --- /dev/null +++ b/types/confirmDialog/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "types", + "typeRoots": ["types"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jquery_confirm.ts" + ] +} diff --git a/types/confirmDialog/tslint.json b/types/confirmDialog/tslint.json new file mode 100644 index 0000000000..2f73ea817c --- /dev/null +++ b/types/confirmDialog/tslint.json @@ -0,0 +1,31 @@ +{ + "rules": { + "max-line-length": { + "options": [ + 120 + ] + }, + "new-parens": true, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-consecutive-blank-lines": false, + "no-console": { + "options": [ + "debug", + "info", + "log", + "time", + "timeEnd", + "trace" + ] + } + }, + "jsRules": { + "max-line-length": { + "options": [ + 120 + ] + } + } +} From e01be3c7700e3544cc907fd443ff48b4b234803c Mon Sep 17 00:00:00 2001 From: allipierre Date: Mon, 20 Nov 2017 16:01:57 +0100 Subject: [PATCH 02/22] add optional Parameter to confirmOptions --- types/confirmDialog/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/confirmDialog/index.d.ts b/types/confirmDialog/index.d.ts index d205b45957..417a299618 100644 --- a/types/confirmDialog/index.d.ts +++ b/types/confirmDialog/index.d.ts @@ -5,7 +5,7 @@ interface JQueryStatic { /** - * confirm Dialog + * jquery confirm Dialog * @param {confirmOptions} pOtions */ confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; From 966fb905c89979fabc1480ad959c813e137a3594 Mon Sep 17 00:00:00 2001 From: allipierre Date: Mon, 20 Nov 2017 16:10:05 +0100 Subject: [PATCH 03/22] add optional Parameter to confirmOptions --- types/confirmDialog/index.d.ts | 98 ---- types/confirmDialog/jquery-confirm.ts | 644 -------------------------- types/confirmDialog/tsconfig.json | 21 - types/confirmDialog/tslint.json | 31 -- 4 files changed, 794 deletions(-) delete mode 100644 types/confirmDialog/index.d.ts delete mode 100644 types/confirmDialog/jquery-confirm.ts delete mode 100644 types/confirmDialog/tsconfig.json delete mode 100644 types/confirmDialog/tslint.json diff --git a/types/confirmDialog/index.d.ts b/types/confirmDialog/index.d.ts deleted file mode 100644 index 417a299618..0000000000 --- a/types/confirmDialog/index.d.ts +++ /dev/null @@ -1,98 +0,0 @@ -// Type definitions for jquery-confirm v3.3.0 https://craftpip.github.io/jquery-confirm/ -// Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js -// Definitions by: Alli Pierre Yotti https://github.com/allipierre -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface JQueryStatic { - /** - * jquery confirm Dialog - * @param {confirmOptions} pOtions - */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; - - /** - * confirm alert - * @param {any} pMessage - */ - alert( pMessage?: any | string, title?:string): void; - - /** - * confirm Dialog - * @param {any} pMessage - */ - dialog( pOtions: options.confirmOptions | string): void; -} - - -interface JQuery { - /** - * confirm Dialog - * @param {confirmOptions} pOtions - */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; - - /** - * confirm alert - * @param {any} pMessage - */ - alert( pMessage?: any, title?:string): void; - - /** - * confirm Dialog - * @param {any} pMessage - */ - dialog( pOtions: options.confirmOptions | any): void; -} - -interface Window { - setContentAppend: any; -} - - - -declare namespace options { - - interface confirmOptions { - buttons? : buttonOptionss | any, - title? : string | boolean, - content? : string | Function, - onContentReady?: Function, - lazyOpen?: boolean, - closeIcon?: boolean | Function, - type?: string, - typeAnimated?: boolean, - icon?: string, - closeIconClass?: string, - columnClass?: string, - containerFluid?: boolean, - boxWidth?: string, - useBootstrap?: boolean, - bootstrapClasses?: any, - draggable?: boolean, - dragWindowBorder?: boolean, - dragWindowGap?: number, - contentLoaded?: Function, - autoClose?: String, - backgroundDismiss?: boolean | Function | string, - backgroundDismissAnimation?: string, - escapeKey?: string | boolean, - onOpenBefore?:Function, - onOpen?: Function, - onClose?: Function, - onDestroy?: Function, - onAction?: Function - - - } - - interface buttonOptionss { - cancel?: Function, - confirm?: Function - } - -} - -declare namespace jconfirm { - let defaults: any; - -} diff --git a/types/confirmDialog/jquery-confirm.ts b/types/confirmDialog/jquery-confirm.ts deleted file mode 100644 index 109558a737..0000000000 --- a/types/confirmDialog/jquery-confirm.ts +++ /dev/null @@ -1,644 +0,0 @@ -/// -/// -namespace server { - export interface Iperson { - title: string, - content: string, - - - } -} - -class Confirm implements server.Iperson { - private title_: string; - private conTent_: string; - constructor(public title: string, public content: string) { - this.title_ = title; - this.conTent_ = content; - } - - - public confirm() { - $.confirm({ - title: 'Confirm!', - content: 'Simple confirm!', - buttons: { - confirm: function() { - $.alert('Confirmed!'); - }, - cancel: function(cancel: string) { - $.alert('Canceled! ' + cancel); - }, - somethingElse: { - text: 'Something else', - btnClass: 'btn-blue', - keys: ['enter', 'shift'], - action: function() { - alert('Something else?'); - } - } - } - }); - } - - public alert() { - $.alert({ - title: 'Alert!', - content: 'Simple alert!', - }); - } - - public confirm1() { - $.confirm({ - title: 'Prompt!', - content: '' + - '
' + - '
' + - '' + - '' + - '
' + - '
', - buttons: { - formSubmit: { - text: 'Submit', - btnClass: 'btn-blue', - action: function() { - let name = this.$content.find('.name').val(); - if (!name) { - $.alert('provide a valid name'); - return false; - } - $.alert('Your name is ' + name); - } - }, - cancel: function() { - //close - }, - }, - onContentReady: function() { - // bind to events - var jc = this; - this.$content.find('form').on('submit', function(e) { - // if the user submits the form by pressing enter in the field. - e.preventDefault(); - jc.$$formSubmit.trigger('click'); // reference the button and click it - }); - } - }); - - } - - public dialog() { - $.dialog({ - title: 'Text content!', - content: 'Simple modal!' - }); - } - public confirm_2() { - $('.atwitter').val(); - $('.atwitter').text(); - $('a.twitter').confirm({ - content: "...", - }); - $('a.twitter').confirm({ - buttons: { - hey: function() { - location.href = this.$target.attr('href'); - } - } - }); - } - - public confirm_3() { - $.alert('Content here', 'Title here'); - $.confirm('A message', 'Title is optional'); - $.dialog('Just to let you know'); - } - - public confirm_4() { - var a = $.confirm({ - lazyOpen: true, - }); - a.open(); - a.close(); - a.toggle(); // toggle open close. - - } - - public confirm_5() { - $.confirm({ - buttons: { - hello: function(helloButton) { - // shorthand method to define a button - // the button key will be used as button name - }, - hey: function(heyButton) { - // access the button using jquery - this.$$hello.trigger('click'); // click the 'hello' button - this.$$hey.prop('disabled', true); // disable the current button using jquery method - - // jconfirm button methods, all methods listed here - this.buttons.hello.setText('Helloooo'); // setText for 'hello' button - this.buttons.hey.disable(); // disable with button function provided by jconfirm - this.buttons.hey.enable(); // enable with button function provided by jconfirm - // the button's instance is passed as the first argument, for quick access - heyButton === this.buttons.hey - }, - heyThere: { - text: 'Hey there!', // text for button - btnClass: 'btn-blue', // class for the button - keys: ['enter', 'a'], // keyboard event for button - isHidden: false, // initially not hidden - isDisabled: false, // initially not disabled - action: function(heyThereButton) { - // longhand method to define a button - // provides more features - } - }, - } - }); - - } - - public confirm_6() { - $.confirm({ - buttons: { - hey: function() { - // here the button key 'hey' will be used as the text. - $.alert('You clicked on "hey".'); - }, - heyThere: { - text: 'hey there!', // With spaces and symbols - action: function() { - $.alert('You clicked on "heyThere"'); - } - } - } - }); - } - - public confirm_7() { - $.confirm({ - content: 'Time to use your keyboard, press shift, alert, A or B', - buttons: { - specialKey: { - text: 'On behalf of shift', - keys: ['shift', 'alt'], - action: function() { - $.alert('Shift or Alt was pressed'); - } - }, - alphabet: { - text: 'A, B', - keys: ['a', 'b'], - action: function() { - $.alert('A or B was pressed'); - } - } - } - }); - } - - public confirm_8() { - $.confirm({ - closeIcon: true, // explicitly show the close icon - buttons: { - buttonA: { - text: 'button a', - action: function(buttonA) { - this.buttons.resetButton.setText('reset button!!!'); - this.buttons.resetButton.disable(); - this.buttons.resetButton.enable(); - this.buttons.resetButton.hide(); - this.buttons.resetButton.show(); - this.buttons.resetButton.addClass('btn-red'); - this.buttons.resetButton.removeClass('btn-red'); - // or - this.$$resetButton // button's jquery element reference, go crazy - this.buttons.buttonA == buttonA // both are the same. - return false; // prevent the modal from closing - } - }, - resetButton: function(resetButton) {} - } - }); - } - - - public confirm_9() { - $.confirm({ - title: 'Encountered an error!', - content: 'Something went downhill, this may be serious', - type: 'red', - typeAnimated: true, - buttons: { - tryAgain: { - text: 'Try again', - btnClass: 'btn-red', - action: function() {} - }, - close: function() {} - } - }); - } - - public confirm_10() { - $.confirm({ - icon: 'glyphicon glyphicon-heart', - title: 'glyphicon' - }); - $.confirm({ - icon: 'fa fa-warning', - title: 'font-awesome' - }); - $.confirm({ - icon: 'fa fa-spinner fa-spin', - title: 'Working!', - content: 'Sit back, we are processing your request!' - }); - } - - public confirm_11() { - $.confirm({ - closeIcon: true - }); - - $.confirm({ - closeIcon: true, - closeIconClass: 'fa fa-close' - }); - } - - public confirm_12() { - $.confirm({ - closeIcon: function() { - return false; - }, - buttons: { - aRandomButton: function() { - $.alert('A random button is called, and i prevent closing the modal'); - return false; // you shall not pass - }, - close: function() {} - } - }); - } - - public confirm_13() { - $.confirm({ - columnClass: 'small' - }); - $.confirm({ - columnClass: 'col-md-4 col-md-offset-4', - }); - $.confirm({ - columnClass: 'col-md-12' - }); - $.confirm({ - columnClass: 'col-md-4 col-md-offset-8 col-xs-4 col-xs-offset-8', - containerFluid: true, // this will add 'container-fluid' instead of 'container' - }); - } - - public confirm_14() { - $.confirm({ - boxWidth: '30%', - useBootstrap: false, - }); - $.confirm({ - boxWidth: '500px', - useBootstrap: false, - }); - } - - public confirm_15() { - $.confirm({ - bootstrapClasses: { - container: 'container', - containerFluid: 'container-fluid', - row: 'row', - }, - }); - - $.confirm({ - title: 'Hello there', - content: 'click and hold on the title to drag', - draggable: true, - }); - - $.confirm({ - title: 'Hello there', - content: 'Drag this modal out of the window', - draggable: true, - dragWindowBorder: false, - }); - $.confirm({ - title: 'Hello there', - content: 'try to drag this modal out of the window', - draggable: true, - dragWindowGap: 0, // number of px of distance - }); - } - - public ajaxLoading() { - $.confirm({ - title: 'Title', - content: 'url:text.txt', - onContentReady: function() { - var self = this; - this.setContentPrepend('
Prepended text
'); - setTimeout(function() { - self.setContentAppend('
Appended text after 2 seconds
'); - }, 2000); - }, - columnClass: 'medium', - }); - - $.confirm({ - content: function() { - var self = this; - return $.ajax({ - url: 'bower.json', - dataType: 'json', - method: 'get' - }).done(function(response) { - self.setContent('Description: ' + response.description); - self.setContentAppend('
Version: ' + response.version); - self.setTitle(response.name); - }).fail(function() { - self.setContent('Something went wrong.'); - }); - } - }); - - $.confirm({ - content: 'url:text.txt', - contentLoaded: function(data, status, xhr) { - // data is already set in content - this.setContentAppend('
Status: ' + status); - } - }); - - $.confirm({ - content: function() { - var self = this; - self.setContent('Checking callback flow'); - return $.ajax({ - url: 'bower.json', - dataType: 'json', - method: 'get' - }).done(function(response) { - self.setContentAppend('
Done!
'); - }).fail(function() { - self.setContentAppend('
Fail!
'); - }).always(function() { - self.setContentAppend('
Always!
'); - }); - }, - contentLoaded: function(data, status, xhr) { - self.setContentAppend('
Content loaded!
'); - }, - onContentReady: function() { - this.setContentAppend('
Content ready!
'); - } - }); - - } - - public autoClose() { - $.confirm({ - title: 'Delete user?', - content: 'This dialog will automatically trigger \'cancel\' in 6 seconds if you don\'t respond.', - autoClose: 'cancelAction|8000', - buttons: { - deleteUser: { - text: 'delete user', - action: function() { - $.alert('Deleted the user!'); - } - }, - cancelAction: function() { - $.alert('action is canceled'); - } - } - }); - $.confirm({ - title: 'Logout?', - content: 'Your time is out, you will be automatically logged out in 10 seconds.', - autoClose: 'logoutUser|10000', - buttons: { - logoutUser: { - text: 'logout myself', - action: function() { - $.alert('The user was logged out'); - } - }, - cancel: function() { - $.alert('canceled'); - } - } - }); - } - - public backgroundDismisse() { - $.confirm({ - backgroundDismiss: true, // this will just close the modal - }); - $.confirm({ - backgroundDismiss: function() { - return false; // modal wont close. - }, - }); - $.confirm({ - backgroundDismiss: function() { - return 'buttonName'; // the button will handle it - }, - }); - $.confirm({ - backgroundDismiss: 'buttonName', - content: 'in here the backgroundDismiss action is handled by buttonName' + - '
', - buttons: { - buttonName: function() { - var $checkbox = this.$content.find('#enableCheckbox'); - return $checkbox.prop('checked'); - }, - close: function() {} - } - }); - } - - public backgroundDismisseAnimation(){ - $.confirm({ - backgroundDismiss: false, - backgroundDismissAnimation: 'shake', -}); -$.confirm({ - backgroundDismiss: false, - backgroundDismissAnimation: 'glow', -}); - } - - public escapeKey(){ - $.confirm({ - escapeKey: true, - backgroundDismiss: false, -}); -$.confirm({ - escapeKey: 'buttonName', - buttons: { - buttonName: function(){ - $.alert('Button name was called'); - }, - close: function(){ - } - } -}); - } - public rtlSupport(){ - $.alert({ - title: 'پیغام', - content: 'این یک متن به زبان شیرین فارسی است', - rtl: true, - closeIcon: true, - buttons: { - confirm: { - text: 'تایید', - btnClass: 'btn-blue', - action: function () { - $.alert('تایید شد.'); - } - }, - cancel: { - text: 'انصراف', - action: function () { - } - } - } -}); - - } - - public callBack(){ - $.confirm({ - title: false, - content: 'url:callback.html', - onContentReady: function () { - // when content is fetched & rendered in DOM - alert('onContentReady'); - var self = this; - this.buttons.ok.disable(); - this.$content.find('.btn').click(function(){ - self.$content.find('input').val('Chuck norris'); - self.buttons.ok.enable(); - }); - }, - contentLoaded: function(data, status, xhr){ - // when content is fetched - alert('contentLoaded: ' + status); - }, - onOpenBefore: function () { - // before the modal is displayed. - alert('onOpenBefore'); - }, - onOpen: function () { - // after the modal is displayed. - alert('onOpen'); - }, - onClose: function () { - // before the modal is hidden. - alert('onClose'); - }, - onDestroy: function () { - // when the modal is removed from DOM - alert('onDestroy'); - }, - onAction: function (btnName) { - // when a button is clicked, with the button name - alert('onAction: ' + btnName); - }, - buttons: { - ok: function(){ - } - } -}); - } - public globalSettings(){ - jconfirm.defaults = { - title: 'Hello', - titleClass: '', - type: 'default', - typeAnimated: true, - draggable: true, - dragWindowGap: 15, - dragWindowBorder: true, - animateFromElement: true, - smoothContent: true, - content: 'Are you sure to continue?', - buttons: {}, - defaultButtons: { - ok: { - action: function () { - } - }, - close: { - action: function () { - } - }, - }, - contentLoaded: function(data, status, xhr){ - }, - icon: '', - lazyOpen: false, - bgOpacity: null, - theme: 'light', - animation: 'scale', - closeAnimation: 'scale', - animationSpeed: 400, - animationBounce: 1, - rtl: false, - container: 'body', - containerFluid: false, - backgroundDismiss: false, - backgroundDismissAnimation: 'shake', - autoClose: false, - closeIcon: null, - closeIconClass: false, - watchInterval: 100, - columnClass: 'col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1', - boxWidth: '50%', - scrollToPreviousElement: true, - scrollToPreviousElementAnimate: true, - useBootstrap: true, - offsetTop: 40, - offsetBottom: 40, - bootstrapClasses: { - container: 'container', - containerFluid: 'container-fluid', - row: 'row', - }, - onContentReady: function () {}, - onOpenBefore: function () {}, - onOpen: function () {}, - onClose: function () {}, - onDestroy: function () {}, - onAction: function () {} -}; - } - - public api(){ - var jc = $.confirm({ - title: 'awesome', - onContentReady: function(){ - // this === jc - //jc.setTitle(title: string); - } -}); - } - -} - - -var firstName: string = 'Pierre'; -var lastName: string = 'Yotti'; -var type = new Confirm(firstName, lastName); diff --git a/types/confirmDialog/tsconfig.json b/types/confirmDialog/tsconfig.json deleted file mode 100644 index 6949afdda5..0000000000 --- a/types/confirmDialog/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "types", - "typeRoots": ["types"], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "jquery_confirm.ts" - ] -} diff --git a/types/confirmDialog/tslint.json b/types/confirmDialog/tslint.json deleted file mode 100644 index 2f73ea817c..0000000000 --- a/types/confirmDialog/tslint.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "rules": { - "max-line-length": { - "options": [ - 120 - ] - }, - "new-parens": true, - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-consecutive-blank-lines": false, - "no-console": { - "options": [ - "debug", - "info", - "log", - "time", - "timeEnd", - "trace" - ] - } - }, - "jsRules": { - "max-line-length": { - "options": [ - 120 - ] - } - } -} From 77ceb8cd3835f63eeb3d45b97337ec7502860140 Mon Sep 17 00:00:00 2001 From: allipierre Date: Mon, 20 Nov 2017 16:11:02 +0100 Subject: [PATCH 04/22] add optional Parameter to confirmOptions --- types/confirmdialog/index.d.ts | 98 ++++ types/confirmdialog/jquery-confirm.ts | 644 ++++++++++++++++++++++++++ types/confirmdialog/tsconfig.json | 21 + types/confirmdialog/tslint.json | 31 ++ 4 files changed, 794 insertions(+) create mode 100644 types/confirmdialog/index.d.ts create mode 100644 types/confirmdialog/jquery-confirm.ts create mode 100644 types/confirmdialog/tsconfig.json create mode 100644 types/confirmdialog/tslint.json diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts new file mode 100644 index 0000000000..8ab3145c32 --- /dev/null +++ b/types/confirmdialog/index.d.ts @@ -0,0 +1,98 @@ +// Type definitions for jquery-confirm v3.3.0 https://craftpip.github.io/jquery-confirm/ +// Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js +// Definitions by: Alli Pierre Yotti https://github.com/allipierre +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface JQueryStatic { + /** + * confirm Dialog + * @param {confirmOptions} pOtions + */ + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + + /** + * confirm alert + * @param {any} pMessage + */ + alert( pMessage?: any | string, title?:string): void; + + /** + * confirm Dialog + * @param {any} pMessage + */ + dialog( pOtions: options.confirmOptions | string): void; +} + + +interface JQuery { + /** + * confirm Dialog + * @param {confirmOptions} pOtions + */ + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + + /** + * confirm alert + * @param {any} pMessage + */ + alert( pMessage?: any, title?:string): void; + + /** + * confirm Dialog + * @param {any} pMessage + */ + dialog( pOtions: options.confirmOptions | any): void; +} + +interface Window { + setContentAppend: any; +} + + + +declare namespace options { + + interface confirmOptions { + buttons? : buttonOptionss | any, + title? : string | boolean, + content? : string | Function, + onContentReady?: Function, + lazyOpen?: boolean, + closeIcon?: boolean | Function, + type?: string, + typeAnimated?: boolean, + icon?: string, + closeIconClass?: string, + columnClass?: string, + containerFluid?: boolean, + boxWidth?: string, + useBootstrap?: boolean, + bootstrapClasses?: any, + draggable?: boolean, + dragWindowBorder?: boolean, + dragWindowGap?: number, + contentLoaded?: Function, + autoClose?: String, + backgroundDismiss?: boolean | Function | string, + backgroundDismissAnimation?: string, + escapeKey?: string | boolean, + onOpenBefore?:Function, + onOpen?: Function, + onClose?: Function, + onDestroy?: Function, + onAction?: Function + + + } + + interface buttonOptionss { + cancel?: Function, + confirm?: Function + } + +} + +declare namespace jconfirm { + let defaults: any; + +} diff --git a/types/confirmdialog/jquery-confirm.ts b/types/confirmdialog/jquery-confirm.ts new file mode 100644 index 0000000000..109558a737 --- /dev/null +++ b/types/confirmdialog/jquery-confirm.ts @@ -0,0 +1,644 @@ +/// +/// +namespace server { + export interface Iperson { + title: string, + content: string, + + + } +} + +class Confirm implements server.Iperson { + private title_: string; + private conTent_: string; + constructor(public title: string, public content: string) { + this.title_ = title; + this.conTent_ = content; + } + + + public confirm() { + $.confirm({ + title: 'Confirm!', + content: 'Simple confirm!', + buttons: { + confirm: function() { + $.alert('Confirmed!'); + }, + cancel: function(cancel: string) { + $.alert('Canceled! ' + cancel); + }, + somethingElse: { + text: 'Something else', + btnClass: 'btn-blue', + keys: ['enter', 'shift'], + action: function() { + alert('Something else?'); + } + } + } + }); + } + + public alert() { + $.alert({ + title: 'Alert!', + content: 'Simple alert!', + }); + } + + public confirm1() { + $.confirm({ + title: 'Prompt!', + content: '' + + '
' + + '
' + + '' + + '' + + '
' + + '
', + buttons: { + formSubmit: { + text: 'Submit', + btnClass: 'btn-blue', + action: function() { + let name = this.$content.find('.name').val(); + if (!name) { + $.alert('provide a valid name'); + return false; + } + $.alert('Your name is ' + name); + } + }, + cancel: function() { + //close + }, + }, + onContentReady: function() { + // bind to events + var jc = this; + this.$content.find('form').on('submit', function(e) { + // if the user submits the form by pressing enter in the field. + e.preventDefault(); + jc.$$formSubmit.trigger('click'); // reference the button and click it + }); + } + }); + + } + + public dialog() { + $.dialog({ + title: 'Text content!', + content: 'Simple modal!' + }); + } + public confirm_2() { + $('.atwitter').val(); + $('.atwitter').text(); + $('a.twitter').confirm({ + content: "...", + }); + $('a.twitter').confirm({ + buttons: { + hey: function() { + location.href = this.$target.attr('href'); + } + } + }); + } + + public confirm_3() { + $.alert('Content here', 'Title here'); + $.confirm('A message', 'Title is optional'); + $.dialog('Just to let you know'); + } + + public confirm_4() { + var a = $.confirm({ + lazyOpen: true, + }); + a.open(); + a.close(); + a.toggle(); // toggle open close. + + } + + public confirm_5() { + $.confirm({ + buttons: { + hello: function(helloButton) { + // shorthand method to define a button + // the button key will be used as button name + }, + hey: function(heyButton) { + // access the button using jquery + this.$$hello.trigger('click'); // click the 'hello' button + this.$$hey.prop('disabled', true); // disable the current button using jquery method + + // jconfirm button methods, all methods listed here + this.buttons.hello.setText('Helloooo'); // setText for 'hello' button + this.buttons.hey.disable(); // disable with button function provided by jconfirm + this.buttons.hey.enable(); // enable with button function provided by jconfirm + // the button's instance is passed as the first argument, for quick access + heyButton === this.buttons.hey + }, + heyThere: { + text: 'Hey there!', // text for button + btnClass: 'btn-blue', // class for the button + keys: ['enter', 'a'], // keyboard event for button + isHidden: false, // initially not hidden + isDisabled: false, // initially not disabled + action: function(heyThereButton) { + // longhand method to define a button + // provides more features + } + }, + } + }); + + } + + public confirm_6() { + $.confirm({ + buttons: { + hey: function() { + // here the button key 'hey' will be used as the text. + $.alert('You clicked on "hey".'); + }, + heyThere: { + text: 'hey there!', // With spaces and symbols + action: function() { + $.alert('You clicked on "heyThere"'); + } + } + } + }); + } + + public confirm_7() { + $.confirm({ + content: 'Time to use your keyboard, press shift, alert, A or B', + buttons: { + specialKey: { + text: 'On behalf of shift', + keys: ['shift', 'alt'], + action: function() { + $.alert('Shift or Alt was pressed'); + } + }, + alphabet: { + text: 'A, B', + keys: ['a', 'b'], + action: function() { + $.alert('A or B was pressed'); + } + } + } + }); + } + + public confirm_8() { + $.confirm({ + closeIcon: true, // explicitly show the close icon + buttons: { + buttonA: { + text: 'button a', + action: function(buttonA) { + this.buttons.resetButton.setText('reset button!!!'); + this.buttons.resetButton.disable(); + this.buttons.resetButton.enable(); + this.buttons.resetButton.hide(); + this.buttons.resetButton.show(); + this.buttons.resetButton.addClass('btn-red'); + this.buttons.resetButton.removeClass('btn-red'); + // or + this.$$resetButton // button's jquery element reference, go crazy + this.buttons.buttonA == buttonA // both are the same. + return false; // prevent the modal from closing + } + }, + resetButton: function(resetButton) {} + } + }); + } + + + public confirm_9() { + $.confirm({ + title: 'Encountered an error!', + content: 'Something went downhill, this may be serious', + type: 'red', + typeAnimated: true, + buttons: { + tryAgain: { + text: 'Try again', + btnClass: 'btn-red', + action: function() {} + }, + close: function() {} + } + }); + } + + public confirm_10() { + $.confirm({ + icon: 'glyphicon glyphicon-heart', + title: 'glyphicon' + }); + $.confirm({ + icon: 'fa fa-warning', + title: 'font-awesome' + }); + $.confirm({ + icon: 'fa fa-spinner fa-spin', + title: 'Working!', + content: 'Sit back, we are processing your request!' + }); + } + + public confirm_11() { + $.confirm({ + closeIcon: true + }); + + $.confirm({ + closeIcon: true, + closeIconClass: 'fa fa-close' + }); + } + + public confirm_12() { + $.confirm({ + closeIcon: function() { + return false; + }, + buttons: { + aRandomButton: function() { + $.alert('A random button is called, and i prevent closing the modal'); + return false; // you shall not pass + }, + close: function() {} + } + }); + } + + public confirm_13() { + $.confirm({ + columnClass: 'small' + }); + $.confirm({ + columnClass: 'col-md-4 col-md-offset-4', + }); + $.confirm({ + columnClass: 'col-md-12' + }); + $.confirm({ + columnClass: 'col-md-4 col-md-offset-8 col-xs-4 col-xs-offset-8', + containerFluid: true, // this will add 'container-fluid' instead of 'container' + }); + } + + public confirm_14() { + $.confirm({ + boxWidth: '30%', + useBootstrap: false, + }); + $.confirm({ + boxWidth: '500px', + useBootstrap: false, + }); + } + + public confirm_15() { + $.confirm({ + bootstrapClasses: { + container: 'container', + containerFluid: 'container-fluid', + row: 'row', + }, + }); + + $.confirm({ + title: 'Hello there', + content: 'click and hold on the title to drag', + draggable: true, + }); + + $.confirm({ + title: 'Hello there', + content: 'Drag this modal out of the window', + draggable: true, + dragWindowBorder: false, + }); + $.confirm({ + title: 'Hello there', + content: 'try to drag this modal out of the window', + draggable: true, + dragWindowGap: 0, // number of px of distance + }); + } + + public ajaxLoading() { + $.confirm({ + title: 'Title', + content: 'url:text.txt', + onContentReady: function() { + var self = this; + this.setContentPrepend('
Prepended text
'); + setTimeout(function() { + self.setContentAppend('
Appended text after 2 seconds
'); + }, 2000); + }, + columnClass: 'medium', + }); + + $.confirm({ + content: function() { + var self = this; + return $.ajax({ + url: 'bower.json', + dataType: 'json', + method: 'get' + }).done(function(response) { + self.setContent('Description: ' + response.description); + self.setContentAppend('
Version: ' + response.version); + self.setTitle(response.name); + }).fail(function() { + self.setContent('Something went wrong.'); + }); + } + }); + + $.confirm({ + content: 'url:text.txt', + contentLoaded: function(data, status, xhr) { + // data is already set in content + this.setContentAppend('
Status: ' + status); + } + }); + + $.confirm({ + content: function() { + var self = this; + self.setContent('Checking callback flow'); + return $.ajax({ + url: 'bower.json', + dataType: 'json', + method: 'get' + }).done(function(response) { + self.setContentAppend('
Done!
'); + }).fail(function() { + self.setContentAppend('
Fail!
'); + }).always(function() { + self.setContentAppend('
Always!
'); + }); + }, + contentLoaded: function(data, status, xhr) { + self.setContentAppend('
Content loaded!
'); + }, + onContentReady: function() { + this.setContentAppend('
Content ready!
'); + } + }); + + } + + public autoClose() { + $.confirm({ + title: 'Delete user?', + content: 'This dialog will automatically trigger \'cancel\' in 6 seconds if you don\'t respond.', + autoClose: 'cancelAction|8000', + buttons: { + deleteUser: { + text: 'delete user', + action: function() { + $.alert('Deleted the user!'); + } + }, + cancelAction: function() { + $.alert('action is canceled'); + } + } + }); + $.confirm({ + title: 'Logout?', + content: 'Your time is out, you will be automatically logged out in 10 seconds.', + autoClose: 'logoutUser|10000', + buttons: { + logoutUser: { + text: 'logout myself', + action: function() { + $.alert('The user was logged out'); + } + }, + cancel: function() { + $.alert('canceled'); + } + } + }); + } + + public backgroundDismisse() { + $.confirm({ + backgroundDismiss: true, // this will just close the modal + }); + $.confirm({ + backgroundDismiss: function() { + return false; // modal wont close. + }, + }); + $.confirm({ + backgroundDismiss: function() { + return 'buttonName'; // the button will handle it + }, + }); + $.confirm({ + backgroundDismiss: 'buttonName', + content: 'in here the backgroundDismiss action is handled by buttonName' + + '
', + buttons: { + buttonName: function() { + var $checkbox = this.$content.find('#enableCheckbox'); + return $checkbox.prop('checked'); + }, + close: function() {} + } + }); + } + + public backgroundDismisseAnimation(){ + $.confirm({ + backgroundDismiss: false, + backgroundDismissAnimation: 'shake', +}); +$.confirm({ + backgroundDismiss: false, + backgroundDismissAnimation: 'glow', +}); + } + + public escapeKey(){ + $.confirm({ + escapeKey: true, + backgroundDismiss: false, +}); +$.confirm({ + escapeKey: 'buttonName', + buttons: { + buttonName: function(){ + $.alert('Button name was called'); + }, + close: function(){ + } + } +}); + } + public rtlSupport(){ + $.alert({ + title: 'پیغام', + content: 'این یک متن به زبان شیرین فارسی است', + rtl: true, + closeIcon: true, + buttons: { + confirm: { + text: 'تایید', + btnClass: 'btn-blue', + action: function () { + $.alert('تایید شد.'); + } + }, + cancel: { + text: 'انصراف', + action: function () { + } + } + } +}); + + } + + public callBack(){ + $.confirm({ + title: false, + content: 'url:callback.html', + onContentReady: function () { + // when content is fetched & rendered in DOM + alert('onContentReady'); + var self = this; + this.buttons.ok.disable(); + this.$content.find('.btn').click(function(){ + self.$content.find('input').val('Chuck norris'); + self.buttons.ok.enable(); + }); + }, + contentLoaded: function(data, status, xhr){ + // when content is fetched + alert('contentLoaded: ' + status); + }, + onOpenBefore: function () { + // before the modal is displayed. + alert('onOpenBefore'); + }, + onOpen: function () { + // after the modal is displayed. + alert('onOpen'); + }, + onClose: function () { + // before the modal is hidden. + alert('onClose'); + }, + onDestroy: function () { + // when the modal is removed from DOM + alert('onDestroy'); + }, + onAction: function (btnName) { + // when a button is clicked, with the button name + alert('onAction: ' + btnName); + }, + buttons: { + ok: function(){ + } + } +}); + } + public globalSettings(){ + jconfirm.defaults = { + title: 'Hello', + titleClass: '', + type: 'default', + typeAnimated: true, + draggable: true, + dragWindowGap: 15, + dragWindowBorder: true, + animateFromElement: true, + smoothContent: true, + content: 'Are you sure to continue?', + buttons: {}, + defaultButtons: { + ok: { + action: function () { + } + }, + close: { + action: function () { + } + }, + }, + contentLoaded: function(data, status, xhr){ + }, + icon: '', + lazyOpen: false, + bgOpacity: null, + theme: 'light', + animation: 'scale', + closeAnimation: 'scale', + animationSpeed: 400, + animationBounce: 1, + rtl: false, + container: 'body', + containerFluid: false, + backgroundDismiss: false, + backgroundDismissAnimation: 'shake', + autoClose: false, + closeIcon: null, + closeIconClass: false, + watchInterval: 100, + columnClass: 'col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1', + boxWidth: '50%', + scrollToPreviousElement: true, + scrollToPreviousElementAnimate: true, + useBootstrap: true, + offsetTop: 40, + offsetBottom: 40, + bootstrapClasses: { + container: 'container', + containerFluid: 'container-fluid', + row: 'row', + }, + onContentReady: function () {}, + onOpenBefore: function () {}, + onOpen: function () {}, + onClose: function () {}, + onDestroy: function () {}, + onAction: function () {} +}; + } + + public api(){ + var jc = $.confirm({ + title: 'awesome', + onContentReady: function(){ + // this === jc + //jc.setTitle(title: string); + } +}); + } + +} + + +var firstName: string = 'Pierre'; +var lastName: string = 'Yotti'; +var type = new Confirm(firstName, lastName); diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json new file mode 100644 index 0000000000..6949afdda5 --- /dev/null +++ b/types/confirmdialog/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "types", + "typeRoots": ["types"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jquery_confirm.ts" + ] +} diff --git a/types/confirmdialog/tslint.json b/types/confirmdialog/tslint.json new file mode 100644 index 0000000000..2f73ea817c --- /dev/null +++ b/types/confirmdialog/tslint.json @@ -0,0 +1,31 @@ +{ + "rules": { + "max-line-length": { + "options": [ + 120 + ] + }, + "new-parens": true, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-consecutive-blank-lines": false, + "no-console": { + "options": [ + "debug", + "info", + "log", + "time", + "timeEnd", + "trace" + ] + } + }, + "jsRules": { + "max-line-length": { + "options": [ + 120 + ] + } + } +} From 1558ac449a86b8b74c64d08b3aef4c7c55f4f193 Mon Sep 17 00:00:00 2001 From: allipierre Date: Mon, 20 Nov 2017 16:22:17 +0100 Subject: [PATCH 05/22] add optional Parameter to confirmOptions --- types/confirmdialog/index.d.ts | 4 ++-- types/confirmdialog/tsconfig.json | 9 ++++----- types/confirmdialog/tslint.json | 32 +------------------------------ 3 files changed, 7 insertions(+), 38 deletions(-) diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index 8ab3145c32..e2b3072fee 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -8,7 +8,7 @@ interface JQueryStatic { * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | any; /** * confirm alert @@ -29,7 +29,7 @@ interface JQuery { * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | any; /** * confirm alert diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json index 6949afdda5..b612d7b4be 100644 --- a/types/confirmdialog/tsconfig.json +++ b/types/confirmdialog/tsconfig.json @@ -2,20 +2,19 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6", - "dom" + "es6" ], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "baseUrl": "types", - "typeRoots": ["types"], + "baseUrl": "../", + "typeRoots": ["../"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", - "jquery_confirm.ts" + "jquery-confirm.ts" ] } diff --git a/types/confirmdialog/tslint.json b/types/confirmdialog/tslint.json index 2f73ea817c..3db14f85ea 100644 --- a/types/confirmdialog/tslint.json +++ b/types/confirmdialog/tslint.json @@ -1,31 +1 @@ -{ - "rules": { - "max-line-length": { - "options": [ - 120 - ] - }, - "new-parens": true, - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-consecutive-blank-lines": false, - "no-console": { - "options": [ - "debug", - "info", - "log", - "time", - "timeEnd", - "trace" - ] - } - }, - "jsRules": { - "max-line-length": { - "options": [ - 120 - ] - } - } -} +{ "extends": "dtslint/dt.json" } From 96df8480f9ed35a2f0a56b6103cbaa1a6cf3b477 Mon Sep 17 00:00:00 2001 From: allipierre Date: Mon, 20 Nov 2017 17:08:07 +0100 Subject: [PATCH 06/22] add optional Parameter to confirmOptions --- package.json | 3 + types/confirmdialog/index.d.ts | 8 +- types/confirmdialog/jquery-confirm.ts | 205 ++------------------------ types/confirmdialog/tsconfig.json | 7 +- types/confirmdialog/tslint.json | 32 +++- 5 files changed, 52 insertions(+), 203 deletions(-) diff --git a/package.json b/package.json index db67595b77..a9ddbdd977 100644 --- a/package.json +++ b/package.json @@ -23,5 +23,8 @@ "devDependencies": { "dtslint": "github:Microsoft/dtslint#production", "types-publisher": "Microsoft/types-publisher#production" + }, + "dependencies": { + "@types/jquery": "^3.2.16" } } diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index e2b3072fee..7844857464 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -5,10 +5,10 @@ interface JQueryStatic { /** - * confirm Dialog + * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | any; + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; /** * confirm alert @@ -29,7 +29,7 @@ interface JQuery { * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | any; + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; /** * confirm alert @@ -72,7 +72,7 @@ declare namespace options { dragWindowBorder?: boolean, dragWindowGap?: number, contentLoaded?: Function, - autoClose?: String, + autoClose?: string, backgroundDismiss?: boolean | Function | string, backgroundDismissAnimation?: string, escapeKey?: string | boolean, diff --git a/types/confirmdialog/jquery-confirm.ts b/types/confirmdialog/jquery-confirm.ts index 109558a737..2f63c28f60 100644 --- a/types/confirmdialog/jquery-confirm.ts +++ b/types/confirmdialog/jquery-confirm.ts @@ -63,7 +63,7 @@ class Confirm implements server.Iperson { text: 'Submit', btnClass: 'btn-blue', action: function() { - let name = this.$content.find('.name').val(); + let name; if (!name) { $.alert('provide a valid name'); return false; @@ -76,13 +76,7 @@ class Confirm implements server.Iperson { }, }, onContentReady: function() { - // bind to events - var jc = this; - this.$content.find('form').on('submit', function(e) { - // if the user submits the form by pressing enter in the field. - e.preventDefault(); - jc.$$formSubmit.trigger('click'); // reference the button and click it - }); + } }); @@ -128,11 +122,11 @@ class Confirm implements server.Iperson { public confirm_5() { $.confirm({ buttons: { - hello: function(helloButton) { + hello: function(helloButton:string) { // shorthand method to define a button // the button key will be used as button name }, - hey: function(heyButton) { + hey: function(heyButton:string) { // access the button using jquery this.$$hello.trigger('click'); // click the 'hello' button this.$$hey.prop('disabled', true); // disable the current button using jquery method @@ -150,7 +144,7 @@ class Confirm implements server.Iperson { keys: ['enter', 'a'], // keyboard event for button isHidden: false, // initially not hidden isDisabled: false, // initially not disabled - action: function(heyThereButton) { + action: function(heyThereButton:string) { // longhand method to define a button // provides more features } @@ -205,21 +199,12 @@ class Confirm implements server.Iperson { buttons: { buttonA: { text: 'button a', - action: function(buttonA) { - this.buttons.resetButton.setText('reset button!!!'); - this.buttons.resetButton.disable(); - this.buttons.resetButton.enable(); - this.buttons.resetButton.hide(); - this.buttons.resetButton.show(); - this.buttons.resetButton.addClass('btn-red'); - this.buttons.resetButton.removeClass('btn-red'); - // or - this.$$resetButton // button's jquery element reference, go crazy - this.buttons.buttonA == buttonA // both are the same. + action: function(buttonA:HTMLElement) { + return false; // prevent the modal from closing } }, - resetButton: function(resetButton) {} + resetButton: function(resetButton:HTMLElement) {} } }); } @@ -340,133 +325,7 @@ class Confirm implements server.Iperson { }); } - public ajaxLoading() { - $.confirm({ - title: 'Title', - content: 'url:text.txt', - onContentReady: function() { - var self = this; - this.setContentPrepend('
Prepended text
'); - setTimeout(function() { - self.setContentAppend('
Appended text after 2 seconds
'); - }, 2000); - }, - columnClass: 'medium', - }); - $.confirm({ - content: function() { - var self = this; - return $.ajax({ - url: 'bower.json', - dataType: 'json', - method: 'get' - }).done(function(response) { - self.setContent('Description: ' + response.description); - self.setContentAppend('
Version: ' + response.version); - self.setTitle(response.name); - }).fail(function() { - self.setContent('Something went wrong.'); - }); - } - }); - - $.confirm({ - content: 'url:text.txt', - contentLoaded: function(data, status, xhr) { - // data is already set in content - this.setContentAppend('
Status: ' + status); - } - }); - - $.confirm({ - content: function() { - var self = this; - self.setContent('Checking callback flow'); - return $.ajax({ - url: 'bower.json', - dataType: 'json', - method: 'get' - }).done(function(response) { - self.setContentAppend('
Done!
'); - }).fail(function() { - self.setContentAppend('
Fail!
'); - }).always(function() { - self.setContentAppend('
Always!
'); - }); - }, - contentLoaded: function(data, status, xhr) { - self.setContentAppend('
Content loaded!
'); - }, - onContentReady: function() { - this.setContentAppend('
Content ready!
'); - } - }); - - } - - public autoClose() { - $.confirm({ - title: 'Delete user?', - content: 'This dialog will automatically trigger \'cancel\' in 6 seconds if you don\'t respond.', - autoClose: 'cancelAction|8000', - buttons: { - deleteUser: { - text: 'delete user', - action: function() { - $.alert('Deleted the user!'); - } - }, - cancelAction: function() { - $.alert('action is canceled'); - } - } - }); - $.confirm({ - title: 'Logout?', - content: 'Your time is out, you will be automatically logged out in 10 seconds.', - autoClose: 'logoutUser|10000', - buttons: { - logoutUser: { - text: 'logout myself', - action: function() { - $.alert('The user was logged out'); - } - }, - cancel: function() { - $.alert('canceled'); - } - } - }); - } - - public backgroundDismisse() { - $.confirm({ - backgroundDismiss: true, // this will just close the modal - }); - $.confirm({ - backgroundDismiss: function() { - return false; // modal wont close. - }, - }); - $.confirm({ - backgroundDismiss: function() { - return 'buttonName'; // the button will handle it - }, - }); - $.confirm({ - backgroundDismiss: 'buttonName', - content: 'in here the backgroundDismiss action is handled by buttonName' + - '
', - buttons: { - buttonName: function() { - var $checkbox = this.$content.find('#enableCheckbox'); - return $checkbox.prop('checked'); - }, - close: function() {} - } - }); - } public backgroundDismisseAnimation(){ $.confirm({ @@ -519,50 +378,7 @@ $.confirm({ } - public callBack(){ - $.confirm({ - title: false, - content: 'url:callback.html', - onContentReady: function () { - // when content is fetched & rendered in DOM - alert('onContentReady'); - var self = this; - this.buttons.ok.disable(); - this.$content.find('.btn').click(function(){ - self.$content.find('input').val('Chuck norris'); - self.buttons.ok.enable(); - }); - }, - contentLoaded: function(data, status, xhr){ - // when content is fetched - alert('contentLoaded: ' + status); - }, - onOpenBefore: function () { - // before the modal is displayed. - alert('onOpenBefore'); - }, - onOpen: function () { - // after the modal is displayed. - alert('onOpen'); - }, - onClose: function () { - // before the modal is hidden. - alert('onClose'); - }, - onDestroy: function () { - // when the modal is removed from DOM - alert('onDestroy'); - }, - onAction: function (btnName) { - // when a button is clicked, with the button name - alert('onAction: ' + btnName); - }, - buttons: { - ok: function(){ - } - } -}); - } + public globalSettings(){ jconfirm.defaults = { title: 'Hello', @@ -586,8 +402,7 @@ $.confirm({ } }, }, - contentLoaded: function(data, status, xhr){ - }, + icon: '', lazyOpen: false, bgOpacity: null, diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json index b612d7b4be..b43b979bcc 100644 --- a/types/confirmdialog/tsconfig.json +++ b/types/confirmdialog/tsconfig.json @@ -2,13 +2,14 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": ["../"], + "baseUrl": "types", + "typeRoots": ["types"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/confirmdialog/tslint.json b/types/confirmdialog/tslint.json index 3db14f85ea..2f73ea817c 100644 --- a/types/confirmdialog/tslint.json +++ b/types/confirmdialog/tslint.json @@ -1 +1,31 @@ -{ "extends": "dtslint/dt.json" } +{ + "rules": { + "max-line-length": { + "options": [ + 120 + ] + }, + "new-parens": true, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-consecutive-blank-lines": false, + "no-console": { + "options": [ + "debug", + "info", + "log", + "time", + "timeEnd", + "trace" + ] + } + }, + "jsRules": { + "max-line-length": { + "options": [ + 120 + ] + } + } +} From 3ed8da33614d61dbf65c080d3a0f0e9cc5324736 Mon Sep 17 00:00:00 2001 From: allipierre Date: Wed, 22 Nov 2017 19:19:13 +0100 Subject: [PATCH 07/22] remove some errors --- types/confirmdialog/jquery-confirm.ts | 232 ++++++++++++++++++++++++-- types/confirmdialog/tsconfig.json | 2 +- 2 files changed, 223 insertions(+), 11 deletions(-) diff --git a/types/confirmdialog/jquery-confirm.ts b/types/confirmdialog/jquery-confirm.ts index 2f63c28f60..e75057f504 100644 --- a/types/confirmdialog/jquery-confirm.ts +++ b/types/confirmdialog/jquery-confirm.ts @@ -63,7 +63,7 @@ class Confirm implements server.Iperson { text: 'Submit', btnClass: 'btn-blue', action: function() { - let name; + let name = this.$content.find('.name').val(); if (!name) { $.alert('provide a valid name'); return false; @@ -76,7 +76,13 @@ class Confirm implements server.Iperson { }, }, onContentReady: function() { - + // bind to events + var jc = this; + this.$content.find('form').on('submit', function(e) { + // if the user submits the form by pressing enter in the field. + e.preventDefault(); + jc.$$formSubmit.trigger('click'); // reference the button and click it + }); } }); @@ -122,11 +128,11 @@ class Confirm implements server.Iperson { public confirm_5() { $.confirm({ buttons: { - hello: function(helloButton:string) { + hello: function(helloButton) { // shorthand method to define a button // the button key will be used as button name }, - hey: function(heyButton:string) { + hey: function(heyButton) { // access the button using jquery this.$$hello.trigger('click'); // click the 'hello' button this.$$hey.prop('disabled', true); // disable the current button using jquery method @@ -144,7 +150,7 @@ class Confirm implements server.Iperson { keys: ['enter', 'a'], // keyboard event for button isHidden: false, // initially not hidden isDisabled: false, // initially not disabled - action: function(heyThereButton:string) { + action: function(heyThereButton) { // longhand method to define a button // provides more features } @@ -199,12 +205,21 @@ class Confirm implements server.Iperson { buttons: { buttonA: { text: 'button a', - action: function(buttonA:HTMLElement) { - + action: function(buttonA) { + this.buttons.resetButton.setText('reset button!!!'); + this.buttons.resetButton.disable(); + this.buttons.resetButton.enable(); + this.buttons.resetButton.hide(); + this.buttons.resetButton.show(); + this.buttons.resetButton.addClass('btn-red'); + this.buttons.resetButton.removeClass('btn-red'); + // or + this.$$resetButton // button's jquery element reference, go crazy + this.buttons.buttonA == buttonA // both are the same. return false; // prevent the modal from closing } }, - resetButton: function(resetButton:HTMLElement) {} + resetButton: function(resetButton) {} } }); } @@ -325,7 +340,133 @@ class Confirm implements server.Iperson { }); } + public ajaxLoading() { + $.confirm({ + title: 'Title', + content: 'url:text.txt', + onContentReady: function() { + var self = this; + this.setContentPrepend('
Prepended text
'); + setTimeout(function() { + self.setContentAppend('
Appended text after 2 seconds
'); + }, 2000); + }, + columnClass: 'medium', + }); + $.confirm({ + content: function() { + var self = this; + return $.ajax({ + url: 'bower.json', + dataType: 'json', + method: 'get' + }).done(function(response) { + self.setContent('Description: ' + response.description); + self.setContentAppend('
Version: ' + response.version); + self.setTitle(response.name); + }).fail(function() { + self.setContent('Something went wrong.'); + }); + } + }); + + $.confirm({ + content: 'url:text.txt', + contentLoaded: function(data, status, xhr) { + // data is already set in content + this.setContentAppend('
Status: ' + status); + } + }); + + $.confirm({ + content: function() { + var self = this; + self.setContent('Checking callback flow'); + return $.ajax({ + url: 'bower.json', + dataType: 'json', + method: 'get' + }).done(function(response) { + self.setContentAppend('
Done!
'); + }).fail(function() { + self.setContentAppend('
Fail!
'); + }).always(function() { + self.setContentAppend('
Always!
'); + }); + }, + contentLoaded: function(data, status, xhr) { + self.setContentAppend('
Content loaded!
'); + }, + onContentReady: function() { + this.setContentAppend('
Content ready!
'); + } + }); + + } + + public autoClose() { + $.confirm({ + title: 'Delete user?', + content: 'This dialog will automatically trigger \'cancel\' in 6 seconds if you don\'t respond.', + autoClose: 'cancelAction|8000', + buttons: { + deleteUser: { + text: 'delete user', + action: function() { + $.alert('Deleted the user!'); + } + }, + cancelAction: function() { + $.alert('action is canceled'); + } + } + }); + $.confirm({ + title: 'Logout?', + content: 'Your time is out, you will be automatically logged out in 10 seconds.', + autoClose: 'logoutUser|10000', + buttons: { + logoutUser: { + text: 'logout myself', + action: function() { + $.alert('The user was logged out'); + } + }, + cancel: function() { + $.alert('canceled'); + } + } + }); + } + + public backgroundDismisse() { + $.confirm({ + backgroundDismiss: true, // this will just close the modal + }); + $.confirm({ + backgroundDismiss: function() { + return false; // modal wont close. + }, + }); + $.confirm({ + backgroundDismiss: function() { + return 'buttonName'; // the button will handle it + }, + }); + $.confirm({ + backgroundDismiss: 'buttonName', + content: 'in here the backgroundDismiss action is handled by buttonName' + + '
', + buttons: { + buttonName: function() { + var $checkbox = this.$content.find('#enableCheckbox'); + return $checkbox.prop('checked'); + }, + close: function() {} + } + }); + } public backgroundDismisseAnimation(){ $.confirm({ @@ -378,7 +519,50 @@ $.confirm({ } - + public callBack(){ + $.confirm({ + title: false, + content: 'url:callback.html', + onContentReady: function () { + // when content is fetched & rendered in DOM + alert('onContentReady'); + var self = this; + this.buttons.ok.disable(); + this.$content.find('.btn').click(function(){ + self.$content.find('input').val('Chuck norris'); + self.buttons.ok.enable(); + }); + }, + contentLoaded: function(data, status, xhr){ + // when content is fetched + alert('contentLoaded: ' + status); + }, + onOpenBefore: function () { + // before the modal is displayed. + alert('onOpenBefore'); + }, + onOpen: function () { + // after the modal is displayed. + alert('onOpen'); + }, + onClose: function () { + // before the modal is hidden. + alert('onClose'); + }, + onDestroy: function () { + // when the modal is removed from DOM + alert('onDestroy'); + }, + onAction: function (btnName) { + // when a button is clicked, with the button name + alert('onAction: ' + btnName); + }, + buttons: { + ok: function(){ + } + } +}); + } public globalSettings(){ jconfirm.defaults = { title: 'Hello', @@ -402,7 +586,8 @@ $.confirm({ } }, }, - + contentLoaded: function(data, status, xhr){ + }, icon: '', lazyOpen: false, bgOpacity: null, @@ -451,6 +636,33 @@ $.confirm({ }); } + + public confirm_84() { + $.confirm({ + closeIcon: true, + buttons: { + buttonA: { + text: 'button a', + action: function (buttonA: HTMLElement) { + this.buttons.resetButton.setText('reset button!!!'); + this.buttons.resetButton.disable(); + this.buttons.resetButton.enable(); + this.buttons.resetButton.hide(); + this.buttons.resetButton.show(); + this.buttons.resetButton.addClass('btn-red'); + this.buttons.resetButton.removeClass('btn-red'); + // or + this.$$resetButton // button's jquery element reference, go crazy + this.buttons.buttonA == buttonA // both are the same. + return false; // prevent the modal from closing + } + }, + resetButton: function (resetButton: string) { + } + } +}); + } + } diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json index b43b979bcc..6949afdda5 100644 --- a/types/confirmdialog/tsconfig.json +++ b/types/confirmdialog/tsconfig.json @@ -16,6 +16,6 @@ }, "files": [ "index.d.ts", - "jquery-confirm.ts" + "jquery_confirm.ts" ] } From 7c07552f854b63c28e773e79a7e4c43adc6a6622 Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 12:16:06 +0100 Subject: [PATCH 08/22] remove some errors --- .../confirmdialog/{jquery-confirm.ts => confirmdialog-tests.ts} | 0 types/confirmdialog/tsconfig.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename types/confirmdialog/{jquery-confirm.ts => confirmdialog-tests.ts} (100%) diff --git a/types/confirmdialog/jquery-confirm.ts b/types/confirmdialog/confirmdialog-tests.ts similarity index 100% rename from types/confirmdialog/jquery-confirm.ts rename to types/confirmdialog/confirmdialog-tests.ts diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json index 6949afdda5..98bea3c511 100644 --- a/types/confirmdialog/tsconfig.json +++ b/types/confirmdialog/tsconfig.json @@ -16,6 +16,6 @@ }, "files": [ "index.d.ts", - "jquery_confirm.ts" + "confirmdialog-tests.ts" ] } From c0ec4daf141dd756afcc723a22a1f4065cd86a5d Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 12:28:10 +0100 Subject: [PATCH 09/22] remove some errors --- types/confirmdialog/confirmdialog-tests.ts | 2 -- types/confirmdialog/index.d.ts | 4 +-- types/confirmdialog/tsconfig.json | 4 +-- types/confirmdialog/tslint.json | 32 +--------------------- 4 files changed, 5 insertions(+), 37 deletions(-) diff --git a/types/confirmdialog/confirmdialog-tests.ts b/types/confirmdialog/confirmdialog-tests.ts index e75057f504..9f0fd9430d 100644 --- a/types/confirmdialog/confirmdialog-tests.ts +++ b/types/confirmdialog/confirmdialog-tests.ts @@ -1,5 +1,3 @@ -/// -/// namespace server { export interface Iperson { title: string, diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index 7844857464..c22896c8c2 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for jquery-confirm v3.3.0 https://craftpip.github.io/jquery-confirm/ +// Type definitions for confirmdialog v3.3.0 // Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js -// Definitions by: Alli Pierre Yotti https://github.com/allipierre +// Definitions by: Alli Pierre Yotti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface JQueryStatic { diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json index 98bea3c511..76f091224e 100644 --- a/types/confirmdialog/tsconfig.json +++ b/types/confirmdialog/tsconfig.json @@ -8,8 +8,8 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "baseUrl": "types", - "typeRoots": ["types"], + "baseUrl": "../", + "typeRoots": ["../"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/confirmdialog/tslint.json b/types/confirmdialog/tslint.json index 2f73ea817c..3db14f85ea 100644 --- a/types/confirmdialog/tslint.json +++ b/types/confirmdialog/tslint.json @@ -1,31 +1 @@ -{ - "rules": { - "max-line-length": { - "options": [ - 120 - ] - }, - "new-parens": true, - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-consecutive-blank-lines": false, - "no-console": { - "options": [ - "debug", - "info", - "log", - "time", - "timeEnd", - "trace" - ] - } - }, - "jsRules": { - "max-line-length": { - "options": [ - 120 - ] - } - } -} +{ "extends": "dtslint/dt.json" } From 07de29ea090ab572e14efbfb6b7e4e98ae7bff20 Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 14:21:18 +0100 Subject: [PATCH 10/22] remove some errors --- package.json | 3 +- types/concaveman/concaveman-tests.ts | 2 +- types/concaveman/index.d.ts | 4 +- types/confirmdialog/confirmdialog-tests.ts | 531 +-------------------- types/confirmdialog/index.d.ts | 2 + 5 files changed, 12 insertions(+), 530 deletions(-) diff --git a/package.json b/package.json index a9ddbdd977..bef061f5bf 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "types-publisher": "Microsoft/types-publisher#production" }, "dependencies": { - "@types/jquery": "^3.2.16" + "@types/jquery": "^3.2.16", + "jquery": "^3.2.1" } } diff --git a/types/concaveman/concaveman-tests.ts b/types/concaveman/concaveman-tests.ts index 736d616ad9..1d951b5448 100644 --- a/types/concaveman/concaveman-tests.ts +++ b/types/concaveman/concaveman-tests.ts @@ -1,4 +1,4 @@ import * as concaveman from 'concaveman'; var points = [[10, 20], [30, 12.5]]; -var polygon = concaveman(points); \ No newline at end of file +var polygon = concaveman(points); diff --git a/types/concaveman/index.d.ts b/types/concaveman/index.d.ts index a5b55c8fa3..4c10ca6928 100644 --- a/types/concaveman/index.d.ts +++ b/types/concaveman/index.d.ts @@ -6,7 +6,7 @@ declare module "concaveman" { /** * A very fast 2D concave hull algorithm in JavaScript (generates a general outline of a point set). - * + * * @name concaveman * @param {Array>} points is an array of [x, y] points. * @param {number} [concavity=2] is a relative measure of concavity. 1 results in a relatively detailed shape, Infinity results in a convex hull. You can use values lower than 1, but they can produce pretty crazy shapes. @@ -15,7 +15,7 @@ declare module "concaveman" { * @example * var points = [[10, 20], [30, 12.5], ...]; * var polygon = concaveman(points); - * + * * //=hull */ function concaveman(points: number[][], concavity?: number, lengthThreshold?: number): number[][]; diff --git a/types/confirmdialog/confirmdialog-tests.ts b/types/confirmdialog/confirmdialog-tests.ts index 9f0fd9430d..77812221af 100644 --- a/types/confirmdialog/confirmdialog-tests.ts +++ b/types/confirmdialog/confirmdialog-tests.ts @@ -1,3 +1,6 @@ +import * as $ from 'jquery'; + + namespace server { export interface Iperson { title: string, @@ -46,521 +49,7 @@ class Confirm implements server.Iperson { }); } - public confirm1() { - $.confirm({ - title: 'Prompt!', - content: '' + - '
' + - '
' + - '' + - '' + - '
' + - '
', - buttons: { - formSubmit: { - text: 'Submit', - btnClass: 'btn-blue', - action: function() { - let name = this.$content.find('.name').val(); - if (!name) { - $.alert('provide a valid name'); - return false; - } - $.alert('Your name is ' + name); - } - }, - cancel: function() { - //close - }, - }, - onContentReady: function() { - // bind to events - var jc = this; - this.$content.find('form').on('submit', function(e) { - // if the user submits the form by pressing enter in the field. - e.preventDefault(); - jc.$$formSubmit.trigger('click'); // reference the button and click it - }); - } - }); - } - - public dialog() { - $.dialog({ - title: 'Text content!', - content: 'Simple modal!' - }); - } - public confirm_2() { - $('.atwitter').val(); - $('.atwitter').text(); - $('a.twitter').confirm({ - content: "...", - }); - $('a.twitter').confirm({ - buttons: { - hey: function() { - location.href = this.$target.attr('href'); - } - } - }); - } - - public confirm_3() { - $.alert('Content here', 'Title here'); - $.confirm('A message', 'Title is optional'); - $.dialog('Just to let you know'); - } - - public confirm_4() { - var a = $.confirm({ - lazyOpen: true, - }); - a.open(); - a.close(); - a.toggle(); // toggle open close. - - } - - public confirm_5() { - $.confirm({ - buttons: { - hello: function(helloButton) { - // shorthand method to define a button - // the button key will be used as button name - }, - hey: function(heyButton) { - // access the button using jquery - this.$$hello.trigger('click'); // click the 'hello' button - this.$$hey.prop('disabled', true); // disable the current button using jquery method - - // jconfirm button methods, all methods listed here - this.buttons.hello.setText('Helloooo'); // setText for 'hello' button - this.buttons.hey.disable(); // disable with button function provided by jconfirm - this.buttons.hey.enable(); // enable with button function provided by jconfirm - // the button's instance is passed as the first argument, for quick access - heyButton === this.buttons.hey - }, - heyThere: { - text: 'Hey there!', // text for button - btnClass: 'btn-blue', // class for the button - keys: ['enter', 'a'], // keyboard event for button - isHidden: false, // initially not hidden - isDisabled: false, // initially not disabled - action: function(heyThereButton) { - // longhand method to define a button - // provides more features - } - }, - } - }); - - } - - public confirm_6() { - $.confirm({ - buttons: { - hey: function() { - // here the button key 'hey' will be used as the text. - $.alert('You clicked on "hey".'); - }, - heyThere: { - text: 'hey there!', // With spaces and symbols - action: function() { - $.alert('You clicked on "heyThere"'); - } - } - } - }); - } - - public confirm_7() { - $.confirm({ - content: 'Time to use your keyboard, press shift, alert, A or B', - buttons: { - specialKey: { - text: 'On behalf of shift', - keys: ['shift', 'alt'], - action: function() { - $.alert('Shift or Alt was pressed'); - } - }, - alphabet: { - text: 'A, B', - keys: ['a', 'b'], - action: function() { - $.alert('A or B was pressed'); - } - } - } - }); - } - - public confirm_8() { - $.confirm({ - closeIcon: true, // explicitly show the close icon - buttons: { - buttonA: { - text: 'button a', - action: function(buttonA) { - this.buttons.resetButton.setText('reset button!!!'); - this.buttons.resetButton.disable(); - this.buttons.resetButton.enable(); - this.buttons.resetButton.hide(); - this.buttons.resetButton.show(); - this.buttons.resetButton.addClass('btn-red'); - this.buttons.resetButton.removeClass('btn-red'); - // or - this.$$resetButton // button's jquery element reference, go crazy - this.buttons.buttonA == buttonA // both are the same. - return false; // prevent the modal from closing - } - }, - resetButton: function(resetButton) {} - } - }); - } - - - public confirm_9() { - $.confirm({ - title: 'Encountered an error!', - content: 'Something went downhill, this may be serious', - type: 'red', - typeAnimated: true, - buttons: { - tryAgain: { - text: 'Try again', - btnClass: 'btn-red', - action: function() {} - }, - close: function() {} - } - }); - } - - public confirm_10() { - $.confirm({ - icon: 'glyphicon glyphicon-heart', - title: 'glyphicon' - }); - $.confirm({ - icon: 'fa fa-warning', - title: 'font-awesome' - }); - $.confirm({ - icon: 'fa fa-spinner fa-spin', - title: 'Working!', - content: 'Sit back, we are processing your request!' - }); - } - - public confirm_11() { - $.confirm({ - closeIcon: true - }); - - $.confirm({ - closeIcon: true, - closeIconClass: 'fa fa-close' - }); - } - - public confirm_12() { - $.confirm({ - closeIcon: function() { - return false; - }, - buttons: { - aRandomButton: function() { - $.alert('A random button is called, and i prevent closing the modal'); - return false; // you shall not pass - }, - close: function() {} - } - }); - } - - public confirm_13() { - $.confirm({ - columnClass: 'small' - }); - $.confirm({ - columnClass: 'col-md-4 col-md-offset-4', - }); - $.confirm({ - columnClass: 'col-md-12' - }); - $.confirm({ - columnClass: 'col-md-4 col-md-offset-8 col-xs-4 col-xs-offset-8', - containerFluid: true, // this will add 'container-fluid' instead of 'container' - }); - } - - public confirm_14() { - $.confirm({ - boxWidth: '30%', - useBootstrap: false, - }); - $.confirm({ - boxWidth: '500px', - useBootstrap: false, - }); - } - - public confirm_15() { - $.confirm({ - bootstrapClasses: { - container: 'container', - containerFluid: 'container-fluid', - row: 'row', - }, - }); - - $.confirm({ - title: 'Hello there', - content: 'click and hold on the title to drag', - draggable: true, - }); - - $.confirm({ - title: 'Hello there', - content: 'Drag this modal out of the window', - draggable: true, - dragWindowBorder: false, - }); - $.confirm({ - title: 'Hello there', - content: 'try to drag this modal out of the window', - draggable: true, - dragWindowGap: 0, // number of px of distance - }); - } - - public ajaxLoading() { - $.confirm({ - title: 'Title', - content: 'url:text.txt', - onContentReady: function() { - var self = this; - this.setContentPrepend('
Prepended text
'); - setTimeout(function() { - self.setContentAppend('
Appended text after 2 seconds
'); - }, 2000); - }, - columnClass: 'medium', - }); - - $.confirm({ - content: function() { - var self = this; - return $.ajax({ - url: 'bower.json', - dataType: 'json', - method: 'get' - }).done(function(response) { - self.setContent('Description: ' + response.description); - self.setContentAppend('
Version: ' + response.version); - self.setTitle(response.name); - }).fail(function() { - self.setContent('Something went wrong.'); - }); - } - }); - - $.confirm({ - content: 'url:text.txt', - contentLoaded: function(data, status, xhr) { - // data is already set in content - this.setContentAppend('
Status: ' + status); - } - }); - - $.confirm({ - content: function() { - var self = this; - self.setContent('Checking callback flow'); - return $.ajax({ - url: 'bower.json', - dataType: 'json', - method: 'get' - }).done(function(response) { - self.setContentAppend('
Done!
'); - }).fail(function() { - self.setContentAppend('
Fail!
'); - }).always(function() { - self.setContentAppend('
Always!
'); - }); - }, - contentLoaded: function(data, status, xhr) { - self.setContentAppend('
Content loaded!
'); - }, - onContentReady: function() { - this.setContentAppend('
Content ready!
'); - } - }); - - } - - public autoClose() { - $.confirm({ - title: 'Delete user?', - content: 'This dialog will automatically trigger \'cancel\' in 6 seconds if you don\'t respond.', - autoClose: 'cancelAction|8000', - buttons: { - deleteUser: { - text: 'delete user', - action: function() { - $.alert('Deleted the user!'); - } - }, - cancelAction: function() { - $.alert('action is canceled'); - } - } - }); - $.confirm({ - title: 'Logout?', - content: 'Your time is out, you will be automatically logged out in 10 seconds.', - autoClose: 'logoutUser|10000', - buttons: { - logoutUser: { - text: 'logout myself', - action: function() { - $.alert('The user was logged out'); - } - }, - cancel: function() { - $.alert('canceled'); - } - } - }); - } - - public backgroundDismisse() { - $.confirm({ - backgroundDismiss: true, // this will just close the modal - }); - $.confirm({ - backgroundDismiss: function() { - return false; // modal wont close. - }, - }); - $.confirm({ - backgroundDismiss: function() { - return 'buttonName'; // the button will handle it - }, - }); - $.confirm({ - backgroundDismiss: 'buttonName', - content: 'in here the backgroundDismiss action is handled by buttonName' + - '
', - buttons: { - buttonName: function() { - var $checkbox = this.$content.find('#enableCheckbox'); - return $checkbox.prop('checked'); - }, - close: function() {} - } - }); - } - - public backgroundDismisseAnimation(){ - $.confirm({ - backgroundDismiss: false, - backgroundDismissAnimation: 'shake', -}); -$.confirm({ - backgroundDismiss: false, - backgroundDismissAnimation: 'glow', -}); - } - - public escapeKey(){ - $.confirm({ - escapeKey: true, - backgroundDismiss: false, -}); -$.confirm({ - escapeKey: 'buttonName', - buttons: { - buttonName: function(){ - $.alert('Button name was called'); - }, - close: function(){ - } - } -}); - } - public rtlSupport(){ - $.alert({ - title: 'پیغام', - content: 'این یک متن به زبان شیرین فارسی است', - rtl: true, - closeIcon: true, - buttons: { - confirm: { - text: 'تایید', - btnClass: 'btn-blue', - action: function () { - $.alert('تایید شد.'); - } - }, - cancel: { - text: 'انصراف', - action: function () { - } - } - } -}); - - } - - public callBack(){ - $.confirm({ - title: false, - content: 'url:callback.html', - onContentReady: function () { - // when content is fetched & rendered in DOM - alert('onContentReady'); - var self = this; - this.buttons.ok.disable(); - this.$content.find('.btn').click(function(){ - self.$content.find('input').val('Chuck norris'); - self.buttons.ok.enable(); - }); - }, - contentLoaded: function(data, status, xhr){ - // when content is fetched - alert('contentLoaded: ' + status); - }, - onOpenBefore: function () { - // before the modal is displayed. - alert('onOpenBefore'); - }, - onOpen: function () { - // after the modal is displayed. - alert('onOpen'); - }, - onClose: function () { - // before the modal is hidden. - alert('onClose'); - }, - onDestroy: function () { - // when the modal is removed from DOM - alert('onDestroy'); - }, - onAction: function (btnName) { - // when a button is clicked, with the button name - alert('onAction: ' + btnName); - }, - buttons: { - ok: function(){ - } - } -}); - } public globalSettings(){ jconfirm.defaults = { title: 'Hello', @@ -584,8 +73,7 @@ $.confirm({ } }, }, - contentLoaded: function(data, status, xhr){ - }, + icon: '', lazyOpen: false, bgOpacity: null, @@ -642,16 +130,7 @@ $.confirm({ buttonA: { text: 'button a', action: function (buttonA: HTMLElement) { - this.buttons.resetButton.setText('reset button!!!'); - this.buttons.resetButton.disable(); - this.buttons.resetButton.enable(); - this.buttons.resetButton.hide(); - this.buttons.resetButton.show(); - this.buttons.resetButton.addClass('btn-red'); - this.buttons.resetButton.removeClass('btn-red'); - // or - this.$$resetButton // button's jquery element reference, go crazy - this.buttons.buttonA == buttonA // both are the same. + return false; // prevent the modal from closing } }, diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index c22896c8c2..ade096d977 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Alli Pierre Yotti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + interface JQueryStatic { /** * confirm Dialog @@ -21,6 +22,7 @@ interface JQueryStatic { * @param {any} pMessage */ dialog( pOtions: options.confirmOptions | string): void; + } From 3a84e4eed4b4dc2fa67fdbb131c068c09fc58fbc Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 15:40:52 +0100 Subject: [PATCH 11/22] remove some errors --- package.json | 6 ++-- types/confirmdialog/confirmdialog-tests.ts | 3 -- types/confirmdialog/index.d.ts | 8 ++++-- types/confirmdialog/tsconfig.json | 1 + types/confirmdialog/tslint.json | 32 +++++++++++++++++++++- 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index bef061f5bf..246d0b9d61 100644 --- a/package.json +++ b/package.json @@ -22,10 +22,12 @@ }, "devDependencies": { "dtslint": "github:Microsoft/dtslint#production", - "types-publisher": "Microsoft/types-publisher#production" + "types-publisher": "Microsoft/types-publisher#production", + "typescript": "^2.6.1" }, "dependencies": { "@types/jquery": "^3.2.16", - "jquery": "^3.2.1" + "jquery": "^3.1.1", + "typescript": "^2.6.1" } } diff --git a/types/confirmdialog/confirmdialog-tests.ts b/types/confirmdialog/confirmdialog-tests.ts index 77812221af..47ba509dc4 100644 --- a/types/confirmdialog/confirmdialog-tests.ts +++ b/types/confirmdialog/confirmdialog-tests.ts @@ -1,6 +1,3 @@ -import * as $ from 'jquery'; - - namespace server { export interface Iperson { title: string, diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index ade096d977..d20e0f8a27 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -3,13 +3,14 @@ // Definitions by: Alli Pierre Yotti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// -interface JQueryStatic { + interface JQueryStatic { /** * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; /** * confirm alert @@ -26,7 +27,7 @@ interface JQueryStatic { } -interface JQuery { + interface JQuery { /** * confirm Dialog * @param {confirmOptions} pOtions @@ -52,6 +53,7 @@ interface Window { + declare namespace options { interface confirmOptions { diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json index 76f091224e..187a733dba 100644 --- a/types/confirmdialog/tsconfig.json +++ b/types/confirmdialog/tsconfig.json @@ -8,6 +8,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": ["../"], "types": [], diff --git a/types/confirmdialog/tslint.json b/types/confirmdialog/tslint.json index 3db14f85ea..2f73ea817c 100644 --- a/types/confirmdialog/tslint.json +++ b/types/confirmdialog/tslint.json @@ -1 +1,31 @@ -{ "extends": "dtslint/dt.json" } +{ + "rules": { + "max-line-length": { + "options": [ + 120 + ] + }, + "new-parens": true, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-consecutive-blank-lines": false, + "no-console": { + "options": [ + "debug", + "info", + "log", + "time", + "timeEnd", + "trace" + ] + } + }, + "jsRules": { + "max-line-length": { + "options": [ + 120 + ] + } + } +} From 4bdef7f72fcae62f3379075492a32a364fc36fa5 Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 16:59:32 +0100 Subject: [PATCH 12/22] Remove interface confirmOptions --- package.json | 1 + types/concaveman/index.d.ts | 1 + types/confirmdialog/confirmdialog-tests.ts | 61 ------------ types/confirmdialog/index.d.ts | 81 +--------------- types/confirmdialog/tsconfig.json | 3 +- types/confirmdialog/tslint.json | 104 +++++++++++++++------ 6 files changed, 83 insertions(+), 168 deletions(-) diff --git a/package.json b/package.json index 246d0b9d61..61b734fec2 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "lint": "dtslint types" }, "devDependencies": { + "@types/node": "^8.0.53", "dtslint": "github:Microsoft/dtslint#production", "types-publisher": "Microsoft/types-publisher#production", "typescript": "^2.6.1" diff --git a/types/concaveman/index.d.ts b/types/concaveman/index.d.ts index 4c10ca6928..ed5da84fc9 100644 --- a/types/concaveman/index.d.ts +++ b/types/concaveman/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Denis Carriere // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + declare module "concaveman" { /** * A very fast 2D concave hull algorithm in JavaScript (generates a general outline of a point set). diff --git a/types/confirmdialog/confirmdialog-tests.ts b/types/confirmdialog/confirmdialog-tests.ts index 47ba509dc4..e1008442e1 100644 --- a/types/confirmdialog/confirmdialog-tests.ts +++ b/types/confirmdialog/confirmdialog-tests.ts @@ -47,67 +47,6 @@ class Confirm implements server.Iperson { } - public globalSettings(){ - jconfirm.defaults = { - title: 'Hello', - titleClass: '', - type: 'default', - typeAnimated: true, - draggable: true, - dragWindowGap: 15, - dragWindowBorder: true, - animateFromElement: true, - smoothContent: true, - content: 'Are you sure to continue?', - buttons: {}, - defaultButtons: { - ok: { - action: function () { - } - }, - close: { - action: function () { - } - }, - }, - - icon: '', - lazyOpen: false, - bgOpacity: null, - theme: 'light', - animation: 'scale', - closeAnimation: 'scale', - animationSpeed: 400, - animationBounce: 1, - rtl: false, - container: 'body', - containerFluid: false, - backgroundDismiss: false, - backgroundDismissAnimation: 'shake', - autoClose: false, - closeIcon: null, - closeIconClass: false, - watchInterval: 100, - columnClass: 'col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1', - boxWidth: '50%', - scrollToPreviousElement: true, - scrollToPreviousElementAnimate: true, - useBootstrap: true, - offsetTop: 40, - offsetBottom: 40, - bootstrapClasses: { - container: 'container', - containerFluid: 'container-fluid', - row: 'row', - }, - onContentReady: function () {}, - onOpenBefore: function () {}, - onOpen: function () {}, - onClose: function () {}, - onDestroy: function () {}, - onAction: function () {} -}; - } public api(){ var jc = $.confirm({ diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index d20e0f8a27..0f6b49cb5a 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js // Definitions by: Alli Pierre Yotti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - +// TypeScript Version: 2.3 /// interface JQueryStatic { @@ -10,7 +10,7 @@ * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + confirm( pOtions: any | string, title?:string): boolean | void | HTMLElement | any; /** * confirm alert @@ -22,81 +22,6 @@ * confirm Dialog * @param {any} pMessage */ - dialog( pOtions: options.confirmOptions | string): void; - -} - - - interface JQuery { - /** - * confirm Dialog - * @param {confirmOptions} pOtions - */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; - - /** - * confirm alert - * @param {any} pMessage - */ - alert( pMessage?: any, title?:string): void; - - /** - * confirm Dialog - * @param {any} pMessage - */ - dialog( pOtions: options.confirmOptions | any): void; -} - -interface Window { - setContentAppend: any; -} - - - - -declare namespace options { - - interface confirmOptions { - buttons? : buttonOptionss | any, - title? : string | boolean, - content? : string | Function, - onContentReady?: Function, - lazyOpen?: boolean, - closeIcon?: boolean | Function, - type?: string, - typeAnimated?: boolean, - icon?: string, - closeIconClass?: string, - columnClass?: string, - containerFluid?: boolean, - boxWidth?: string, - useBootstrap?: boolean, - bootstrapClasses?: any, - draggable?: boolean, - dragWindowBorder?: boolean, - dragWindowGap?: number, - contentLoaded?: Function, - autoClose?: string, - backgroundDismiss?: boolean | Function | string, - backgroundDismissAnimation?: string, - escapeKey?: string | boolean, - onOpenBefore?:Function, - onOpen?: Function, - onClose?: Function, - onDestroy?: Function, - onAction?: Function - - - } - - interface buttonOptionss { - cancel?: Function, - confirm?: Function - } - -} - -declare namespace jconfirm { - let defaults: any; + dialog( pOtions: any | string): void; } diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json index 187a733dba..95f33eb036 100644 --- a/types/confirmdialog/tsconfig.json +++ b/types/confirmdialog/tsconfig.json @@ -13,7 +13,8 @@ "typeRoots": ["../"], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "target": "es6" }, "files": [ "index.d.ts", diff --git a/types/confirmdialog/tslint.json b/types/confirmdialog/tslint.json index 2f73ea817c..a41bf5d19a 100644 --- a/types/confirmdialog/tslint.json +++ b/types/confirmdialog/tslint.json @@ -1,31 +1,79 @@ { - "rules": { - "max-line-length": { - "options": [ - 120 - ] - }, - "new-parens": true, - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-consecutive-blank-lines": false, - "no-console": { - "options": [ - "debug", - "info", - "log", - "time", - "timeEnd", - "trace" - ] + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false } - }, - "jsRules": { - "max-line-length": { - "options": [ - 120 - ] - } - } } From 19f62c87dca1cd8ae5efd5b44a28dca41c06c2b2 Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 17:08:10 +0100 Subject: [PATCH 13/22] perform some alert dialog --- types/confirmdialog/confirmdialog-tests.ts | 61 ++++++++++++++++++ types/confirmdialog/index.d.ts | 75 ++++++++++++++++++++++ 2 files changed, 136 insertions(+) diff --git a/types/confirmdialog/confirmdialog-tests.ts b/types/confirmdialog/confirmdialog-tests.ts index e1008442e1..47ba509dc4 100644 --- a/types/confirmdialog/confirmdialog-tests.ts +++ b/types/confirmdialog/confirmdialog-tests.ts @@ -47,6 +47,67 @@ class Confirm implements server.Iperson { } + public globalSettings(){ + jconfirm.defaults = { + title: 'Hello', + titleClass: '', + type: 'default', + typeAnimated: true, + draggable: true, + dragWindowGap: 15, + dragWindowBorder: true, + animateFromElement: true, + smoothContent: true, + content: 'Are you sure to continue?', + buttons: {}, + defaultButtons: { + ok: { + action: function () { + } + }, + close: { + action: function () { + } + }, + }, + + icon: '', + lazyOpen: false, + bgOpacity: null, + theme: 'light', + animation: 'scale', + closeAnimation: 'scale', + animationSpeed: 400, + animationBounce: 1, + rtl: false, + container: 'body', + containerFluid: false, + backgroundDismiss: false, + backgroundDismissAnimation: 'shake', + autoClose: false, + closeIcon: null, + closeIconClass: false, + watchInterval: 100, + columnClass: 'col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1', + boxWidth: '50%', + scrollToPreviousElement: true, + scrollToPreviousElementAnimate: true, + useBootstrap: true, + offsetTop: 40, + offsetBottom: 40, + bootstrapClasses: { + container: 'container', + containerFluid: 'container-fluid', + row: 'row', + }, + onContentReady: function () {}, + onOpenBefore: function () {}, + onOpen: function () {}, + onClose: function () {}, + onDestroy: function () {}, + onAction: function () {} +}; + } public api(){ var jc = $.confirm({ diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index 0f6b49cb5a..d8a025c8c8 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -25,3 +25,78 @@ dialog( pOtions: any | string): void; } + + + interface JQuery { + /** + * confirm Dialog + * @param {confirmOptions} pOtions + */ + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + + /** + * confirm alert + * @param {any} pMessage + */ + alert( pMessage?: any, title?:string): void; + + /** + * confirm Dialog + * @param {any} pMessage + */ + dialog( pOtions: options.confirmOptions | any): void; +} + +interface Window { + setContentAppend: any; +} + + + + +declare namespace options { + + interface confirmOptions { + buttons? : buttonOptionss | any, + title? : string | boolean, + content? : string | Function, + onContentReady?: Function, + lazyOpen?: boolean, + closeIcon?: boolean | Function, + type?: string, + typeAnimated?: boolean, + icon?: string, + closeIconClass?: string, + columnClass?: string, + containerFluid?: boolean, + boxWidth?: string, + useBootstrap?: boolean, + bootstrapClasses?: any, + draggable?: boolean, + dragWindowBorder?: boolean, + dragWindowGap?: number, + contentLoaded?: Function, + autoClose?: string, + backgroundDismiss?: boolean | Function | string, + backgroundDismissAnimation?: string, + escapeKey?: string | boolean, + onOpenBefore?:Function, + onOpen?: Function, + onClose?: Function, + onDestroy?: Function, + onAction?: Function + + + } + + interface buttonOptionss { + cancel?: Function, + confirm?: Function + } + +} + +declare namespace jconfirm { + let defaults: any; + +} From 0abd2e83e5c2a9ef371b2527e8091dc6821cf8b2 Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 17:12:52 +0100 Subject: [PATCH 14/22] add interface confirmOptions --- types/confirmdialog/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index d8a025c8c8..9be4d62489 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -10,7 +10,7 @@ * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: any | string, title?:string): boolean | void | HTMLElement | any; + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; /** * confirm alert @@ -22,7 +22,7 @@ * confirm Dialog * @param {any} pMessage */ - dialog( pOtions: any | string): void; + dialog( pOtions: options.confirmOptions | string): void; } From 15e10d681ca534c7764e88995874664dbec4104d Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 23:46:11 +0100 Subject: [PATCH 15/22] Added type definitions for jquery-notifier --- types/jquery-notifier/index.d.ts | 0 types/jquery-notifier/jquery-notifier-tests.ts | 0 types/jquery-notifier/jquery-notifier.d.ts | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 types/jquery-notifier/index.d.ts create mode 100644 types/jquery-notifier/jquery-notifier-tests.ts create mode 100644 types/jquery-notifier/jquery-notifier.d.ts diff --git a/types/jquery-notifier/index.d.ts b/types/jquery-notifier/index.d.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/jquery-notifier/jquery-notifier-tests.ts b/types/jquery-notifier/jquery-notifier-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/jquery-notifier/jquery-notifier.d.ts b/types/jquery-notifier/jquery-notifier.d.ts new file mode 100644 index 0000000000..e69de29bb2 From ea879349f0e056cb668caee1b0ce6c7b6e95f96e Mon Sep 17 00:00:00 2001 From: allipierre Date: Fri, 24 Nov 2017 00:12:54 +0100 Subject: [PATCH 16/22] Added type definitions for juery-notifier --- types/jquery-notifier/index.d.ts | 19 +++++ .../jquery-notifier/jquery-notifier-tests.ts | 36 +++++++++ types/jquery-notifier/jquery-notifier.d.ts | 0 types/jquery-notifier/tsconfig.json | 24 ++++++ types/jquery-notifier/tslint.json | 79 +++++++++++++++++++ 5 files changed, 158 insertions(+) delete mode 100644 types/jquery-notifier/jquery-notifier.d.ts create mode 100644 types/jquery-notifier/tsconfig.json create mode 100644 types/jquery-notifier/tslint.json diff --git a/types/jquery-notifier/index.d.ts b/types/jquery-notifier/index.d.ts index e69de29bb2..d67901b056 100644 --- a/types/jquery-notifier/index.d.ts +++ b/types/jquery-notifier/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for Notifier +// Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js +// Definitions by: Alli Pierre Yotti +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +declare namespace notifier { + /** + * notifier.show(title, msg, type, icon, timeout); + * @param {title} title + * @param {msg} msg + * @param {type} type + * @param {icon} icon + * @param {timeout} timeout + */ + function show(title: string, msg: string, type: string, icon: string, timeout?: number): string | number; + function hide(notificationId: string | number): boolean; + +} diff --git a/types/jquery-notifier/jquery-notifier-tests.ts b/types/jquery-notifier/jquery-notifier-tests.ts index e69de29bb2..9d73bce3c5 100644 --- a/types/jquery-notifier/jquery-notifier-tests.ts +++ b/types/jquery-notifier/jquery-notifier-tests.ts @@ -0,0 +1,36 @@ +notifier.show('Hello!', 'I am a default notification.', '', '', 0); +notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', '', 0); +notifier.show('Well Done!', 'You just submit your resume successfuly.', '', '', 0); +notifier.show('Warning!', 'The data presented here can be change.', '', '', 0); +notifier.show('Sorry!', 'Could not complete your transaction.', '', '', 0); + + +notifier.show('Default!', 'I am a default notification.', '', 'img/clock-48.png', 0); +notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', 'img/survey-48.png', 0); +notifier.show('Well Done!', 'You just submit your resume successfuly.', '', 'img/ok-48.png', 0); +notifier.show('Warning!', 'The data presented here can be change.', '', 'img/medium_priority-48.png', 0); +notifier.show('Sorry!', 'Could not complete your transaction.', '', 'img/high_priority-48.png', 0); + + + +notifier.show('Default!', 'I am a default notification.', '', 'img/clock-48.png', 4000); +notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', 'img/survey-48.png', 4000); +notifier.show('Well Done!', 'You just submit your resume successfuly.', '', 'img/ok-48.png', 4000); +notifier.show('Warning!', 'The data presented here can be change.', '', 'img/medium_priority-48.png', 4000); +notifier.show('Sorry!', 'Could not complete your transaction.', '', 'img/high_priority-48.png', 4000); + + + + + var notificationId:string | number; + + var showNotification = function () { + notificationId = notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', 'img/survey-48.png', 4000); + }; + + var hideNotification = function () { + notifier.hide(notificationId); + }; + + document.querySelector('#btn-nt-show').addEventListener('click', showNotification); + document.querySelector('#btn-nt-hide').addEventListener('click', hideNotification); diff --git a/types/jquery-notifier/jquery-notifier.d.ts b/types/jquery-notifier/jquery-notifier.d.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/types/jquery-notifier/tsconfig.json b/types/jquery-notifier/tsconfig.json new file mode 100644 index 0000000000..b2178bf718 --- /dev/null +++ b/types/jquery-notifier/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jquery-notifier-tests.ts" + ] +} diff --git a/types/jquery-notifier/tslint.json b/types/jquery-notifier/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/jquery-notifier/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} From 9d13bdab54ff3164c1e2243bf80658c54ffb68fd Mon Sep 17 00:00:00 2001 From: allipierre Date: Fri, 24 Nov 2017 00:19:43 +0100 Subject: [PATCH 17/22] Add types definition for jquery-notifier --- types/jquery-notifier/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jquery-notifier/index.d.ts b/types/jquery-notifier/index.d.ts index d67901b056..4c733ce0df 100644 --- a/types/jquery-notifier/index.d.ts +++ b/types/jquery-notifier/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for Notifier -// Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js +// Project: https://github.com/allipierre/jquery-notifier // Definitions by: Alli Pierre Yotti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From c55d3e9d4b9d2ea354e56504fd69b8aabd8e3445 Mon Sep 17 00:00:00 2001 From: allipierre Date: Fri, 24 Nov 2017 08:17:19 +0100 Subject: [PATCH 18/22] remove other rules in tslint.json --- types/confirmdialog/confirmdialog-tests.ts | 68 ++++++--------- types/confirmdialog/index.d.ts | 85 +++++++++---------- types/confirmdialog/tslint.json | 80 +---------------- types/jquery-notifier/index.d.ts | 5 +- .../jquery-notifier/jquery-notifier-tests.ts | 23 ++--- types/jquery-notifier/tslint.json | 80 +---------------- 6 files changed, 77 insertions(+), 264 deletions(-) diff --git a/types/confirmdialog/confirmdialog-tests.ts b/types/confirmdialog/confirmdialog-tests.ts index 47ba509dc4..cd2ad0e8ca 100644 --- a/types/confirmdialog/confirmdialog-tests.ts +++ b/types/confirmdialog/confirmdialog-tests.ts @@ -1,37 +1,27 @@ -namespace server { - export interface Iperson { - title: string, - content: string, - - - } -} - -class Confirm implements server.Iperson { +class Confirm { private title_: string; private conTent_: string; - constructor(public title: string, public content: string) { + constructor(title: string, content: string) { this.title_ = title; this.conTent_ = content; } - - public confirm() { + confirm() { $.confirm({ title: 'Confirm!', content: 'Simple confirm!', buttons: { - confirm: function() { + confirm: () => { $.alert('Confirmed!'); }, - cancel: function(cancel: string) { + cancel: (cancel: string) => { $.alert('Canceled! ' + cancel); }, somethingElse: { text: 'Something else', btnClass: 'btn-blue', keys: ['enter', 'shift'], - action: function() { + action: () => { alert('Something else?'); } } @@ -39,15 +29,14 @@ class Confirm implements server.Iperson { }); } - public alert() { + alert() { $.alert({ title: 'Alert!', content: 'Simple alert!', }); } - - public globalSettings(){ + globalSettings() { jconfirm.defaults = { title: 'Hello', titleClass: '', @@ -62,11 +51,11 @@ class Confirm implements server.Iperson { buttons: {}, defaultButtons: { ok: { - action: function () { + action: () => { } }, close: { - action: function () { + action: () => { } }, }, @@ -100,46 +89,41 @@ class Confirm implements server.Iperson { containerFluid: 'container-fluid', row: 'row', }, - onContentReady: function () {}, - onOpenBefore: function () {}, - onOpen: function () {}, - onClose: function () {}, - onDestroy: function () {}, - onAction: function () {} + onContentReady: () => {}, + onOpenBefore: () => {}, + onOpen: () => {}, + onClose: () => {}, + onDestroy: () => {}, + onAction: () => {} }; } - public api(){ - var jc = $.confirm({ + api() { + const jc = $.confirm({ title: 'awesome', - onContentReady: function(){ - // this === jc - //jc.setTitle(title: string); + onContentReady: () => { + jc.setTitle(); } }); } - - public confirm_84() { + confirm_84() { $.confirm({ closeIcon: true, buttons: { buttonA: { text: 'button a', - action: function (buttonA: HTMLElement) { - + action: (buttonA: string) => { return false; // prevent the modal from closing } }, - resetButton: function (resetButton: string) { + resetButton: (resetButton: string) => { } } }); } - } - -var firstName: string = 'Pierre'; -var lastName: string = 'Yotti'; -var type = new Confirm(firstName, lastName); +let firstName = 'Pierre'; +let lastName = 'Yotti'; +let type = new Confirm(firstName, lastName); diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index 9be4d62489..39a507f8ac 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -1,8 +1,9 @@ -// Type definitions for confirmdialog v3.3.0 +// Type definitions for confirmdialog 3.3 // Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js // Definitions by: Alli Pierre Yotti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 + /// interface JQueryStatic { @@ -10,93 +11,83 @@ * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + confirm(pOtions: options.confirmOptions | string, title?: string): any; /** * confirm alert * @param {any} pMessage */ - alert( pMessage?: any | string, title?:string): void; + alert(pMessage?: any | string, title?: string): any; /** * confirm Dialog * @param {any} pMessage */ - dialog( pOtions: options.confirmOptions | string): void; - + dialog(pOtions: options.confirmOptions | string): any; } - interface JQuery { /** * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + confirm(pOtions: options.confirmOptions | string, title?: string): any; /** * confirm alert * @param {any} pMessage */ - alert( pMessage?: any, title?:string): void; + alert(pMessage?: any, title?: string): any; /** * confirm Dialog * @param {any} pMessage */ - dialog( pOtions: options.confirmOptions | any): void; + dialog(pOtions: options.confirmOptions | any): any; } interface Window { setContentAppend: any; } - - - declare namespace options { - interface confirmOptions { - buttons? : buttonOptionss | any, - title? : string | boolean, - content? : string | Function, - onContentReady?: Function, - lazyOpen?: boolean, - closeIcon?: boolean | Function, - type?: string, - typeAnimated?: boolean, - icon?: string, - closeIconClass?: string, - columnClass?: string, - containerFluid?: boolean, - boxWidth?: string, - useBootstrap?: boolean, - bootstrapClasses?: any, - draggable?: boolean, - dragWindowBorder?: boolean, - dragWindowGap?: number, - contentLoaded?: Function, - autoClose?: string, - backgroundDismiss?: boolean | Function | string, - backgroundDismissAnimation?: string, - escapeKey?: string | boolean, - onOpenBefore?:Function, - onOpen?: Function, - onClose?: Function, - onDestroy?: Function, - onAction?: Function - - + buttons?: buttonOptionss | any; + title?: string | boolean; + content?: any; + onContentReady?: any; + lazyOpen?: boolean; + closeIcon?: boolean | any; + type?: string; + typeAnimated?: boolean; + icon?: string; + closeIconClass?: string; + columnClass?: string; + containerFluid?: boolean; + boxWidth?: string; + useBootstrap?: boolean; + bootstrapClasses?: any; + draggable?: boolean; + dragWindowBorder?: boolean; + dragWindowGap?: number; + contentLoaded?: () => void; + autoClose?: string; + backgroundDismiss?: boolean | any | string; + backgroundDismissAnimation?: string; + escapeKey?: string | boolean; + onOpenBefore?: () => void; + onOpen?: () => void; + onClose?: () => void; + onDestroy?: () => void; + onAction?: () => void; } interface buttonOptionss { - cancel?: Function, - confirm?: Function + cancel?: () => void; + confirm?: () => void; } - } declare namespace jconfirm { let defaults: any; - } diff --git a/types/confirmdialog/tslint.json b/types/confirmdialog/tslint.json index a41bf5d19a..3db14f85ea 100644 --- a/types/confirmdialog/tslint.json +++ b/types/confirmdialog/tslint.json @@ -1,79 +1 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} +{ "extends": "dtslint/dt.json" } diff --git a/types/jquery-notifier/index.d.ts b/types/jquery-notifier/index.d.ts index 4c733ce0df..855b3e50b1 100644 --- a/types/jquery-notifier/index.d.ts +++ b/types/jquery-notifier/index.d.ts @@ -1,9 +1,8 @@ -// Type definitions for Notifier +// Type definitions for notifier 1.0 // Project: https://github.com/allipierre/jquery-notifier // Definitions by: Alli Pierre Yotti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - declare namespace notifier { /** * notifier.show(title, msg, type, icon, timeout); @@ -14,6 +13,6 @@ declare namespace notifier { * @param {timeout} timeout */ function show(title: string, msg: string, type: string, icon: string, timeout?: number): string | number; - function hide(notificationId: string | number): boolean; + function hide(notificationId: string | number): boolean; } diff --git a/types/jquery-notifier/jquery-notifier-tests.ts b/types/jquery-notifier/jquery-notifier-tests.ts index 9d73bce3c5..18804758be 100644 --- a/types/jquery-notifier/jquery-notifier-tests.ts +++ b/types/jquery-notifier/jquery-notifier-tests.ts @@ -4,33 +4,28 @@ notifier.show('Well Done!', 'You just submit your resume successfuly.', '', '', notifier.show('Warning!', 'The data presented here can be change.', '', '', 0); notifier.show('Sorry!', 'Could not complete your transaction.', '', '', 0); - notifier.show('Default!', 'I am a default notification.', '', 'img/clock-48.png', 0); notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', 'img/survey-48.png', 0); notifier.show('Well Done!', 'You just submit your resume successfuly.', '', 'img/ok-48.png', 0); notifier.show('Warning!', 'The data presented here can be change.', '', 'img/medium_priority-48.png', 0); notifier.show('Sorry!', 'Could not complete your transaction.', '', 'img/high_priority-48.png', 0); - - notifier.show('Default!', 'I am a default notification.', '', 'img/clock-48.png', 4000); notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', 'img/survey-48.png', 4000); notifier.show('Well Done!', 'You just submit your resume successfuly.', '', 'img/ok-48.png', 4000); notifier.show('Warning!', 'The data presented here can be change.', '', 'img/medium_priority-48.png', 4000); notifier.show('Sorry!', 'Could not complete your transaction.', '', 'img/high_priority-48.png', 4000); +let notificationId: string | number; +let showNotification = () => { + notificationId = notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', 'img/survey-48.png', 4000); +}; +let hideNotification = () => { + notifier.hide(notificationId); +}; - var notificationId:string | number; +document.querySelector('#btn-nt-show').addEventListener('click', showNotification); - var showNotification = function () { - notificationId = notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', 'img/survey-48.png', 4000); - }; - - var hideNotification = function () { - notifier.hide(notificationId); - }; - - document.querySelector('#btn-nt-show').addEventListener('click', showNotification); - document.querySelector('#btn-nt-hide').addEventListener('click', hideNotification); +document.querySelector('#btn-nt-hide').addEventListener('click', hideNotification); diff --git a/types/jquery-notifier/tslint.json b/types/jquery-notifier/tslint.json index a41bf5d19a..3db14f85ea 100644 --- a/types/jquery-notifier/tslint.json +++ b/types/jquery-notifier/tslint.json @@ -1,79 +1 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} +{ "extends": "dtslint/dt.json" } From 7ffa7f591a9133c11ce8e625a0f6ed4c5e5a0011 Mon Sep 17 00:00:00 2001 From: allipierre Date: Fri, 24 Nov 2017 08:47:03 +0100 Subject: [PATCH 19/22] remove other rules in tslint.json --- package.json | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/package.json b/package.json index 61b734fec2..db67595b77 100644 --- a/package.json +++ b/package.json @@ -21,14 +21,7 @@ "lint": "dtslint types" }, "devDependencies": { - "@types/node": "^8.0.53", "dtslint": "github:Microsoft/dtslint#production", - "types-publisher": "Microsoft/types-publisher#production", - "typescript": "^2.6.1" - }, - "dependencies": { - "@types/jquery": "^3.2.16", - "jquery": "^3.1.1", - "typescript": "^2.6.1" + "types-publisher": "Microsoft/types-publisher#production" } } From e2fa7e85cc5af5740a22f63d1ba6037284669b38 Mon Sep 17 00:00:00 2001 From: allipierre Date: Fri, 24 Nov 2017 09:11:19 +0100 Subject: [PATCH 20/22] remove param in commentar --- types/confirmdialog/index.d.ts | 12 ++++++------ types/jquery-notifier/index.d.ts | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index 39a507f8ac..1b7d106fac 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -9,19 +9,19 @@ interface JQueryStatic { /** * confirm Dialog - * @param {confirmOptions} pOtions + * {confirmOptions} pOtions */ confirm(pOtions: options.confirmOptions | string, title?: string): any; /** * confirm alert - * @param {any} pMessage + * {any} pMessage */ alert(pMessage?: any | string, title?: string): any; /** * confirm Dialog - * @param {any} pMessage + * {any} pMessage */ dialog(pOtions: options.confirmOptions | string): any; } @@ -29,19 +29,19 @@ interface JQuery { /** * confirm Dialog - * @param {confirmOptions} pOtions + * {confirmOptions} pOtions */ confirm(pOtions: options.confirmOptions | string, title?: string): any; /** * confirm alert - * @param {any} pMessage + * {any} pMessage */ alert(pMessage?: any, title?: string): any; /** * confirm Dialog - * @param {any} pMessage + * {any} pMessage */ dialog(pOtions: options.confirmOptions | any): any; } diff --git a/types/jquery-notifier/index.d.ts b/types/jquery-notifier/index.d.ts index 855b3e50b1..bf9d0ff93b 100644 --- a/types/jquery-notifier/index.d.ts +++ b/types/jquery-notifier/index.d.ts @@ -6,11 +6,11 @@ declare namespace notifier { /** * notifier.show(title, msg, type, icon, timeout); - * @param {title} title - * @param {msg} msg - * @param {type} type - * @param {icon} icon - * @param {timeout} timeout + * {title} title + * {msg} msg + * {type} type + * {icon} icon + * {timeout} timeout */ function show(title: string, msg: string, type: string, icon: string, timeout?: number): string | number; From 9f47e5d4c4a9f5dae9ae7816779af8110b97de2c Mon Sep 17 00:00:00 2001 From: allipierre Date: Fri, 24 Nov 2017 09:18:46 +0100 Subject: [PATCH 21/22] remove any union --- types/confirmdialog/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index 1b7d106fac..212a3aa271 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -17,7 +17,7 @@ * confirm alert * {any} pMessage */ - alert(pMessage?: any | string, title?: string): any; + alert(pMessage?: any, title?: string): any; /** * confirm Dialog @@ -57,7 +57,7 @@ declare namespace options { content?: any; onContentReady?: any; lazyOpen?: boolean; - closeIcon?: boolean | any; + closeIcon?: any; type?: string; typeAnimated?: boolean; icon?: string; @@ -72,7 +72,7 @@ declare namespace options { dragWindowGap?: number; contentLoaded?: () => void; autoClose?: string; - backgroundDismiss?: boolean | any | string; + backgroundDismiss?: any; backgroundDismissAnimation?: string; escapeKey?: string | boolean; onOpenBefore?: () => void; From 4bc06272e9692de2ce2dde36128422fb2237071d Mon Sep 17 00:00:00 2001 From: allipierre Date: Fri, 24 Nov 2017 09:25:19 +0100 Subject: [PATCH 22/22] remove any union --- types/confirmdialog/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index 212a3aa271..9b98ab2389 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -43,7 +43,7 @@ * confirm Dialog * {any} pMessage */ - dialog(pOtions: options.confirmOptions | any): any; + dialog(pOtions: options.confirmOptions): any; } interface Window { @@ -52,7 +52,7 @@ interface Window { declare namespace options { interface confirmOptions { - buttons?: buttonOptionss | any; + buttons?: any; title?: string | boolean; content?: any; onContentReady?: any;