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
+ ]
+ }
+ }
+}