GithubHelp home page GithubHelp logo

craftpip / angular-confirm Goto Github PK

View Code? Open in Web Editor NEW
115.0 12.0 20.0 1.15 MB

A multipurpose plugin for alert, confirm & dialog for angular1

Home Page: http://craftpip.github.io/angular-confirm/

License: MIT License

JavaScript 100.00%
angular angular1 angular-confirm javascript-confirm angular-module angular-model angular-modal dialog alert

angular-confirm's Introduction

jquery-confirm

alerts, confirms and dialogs in one.

v1.1.0

Angular-confirm targets to make it really easy to use confirm dialogs with angular.
With angular-confirm you can harness the angular two-way data binding to update the content as well as make changes to the model in runtime.

A re-write of the jquery-confirm v3 plugin with all features.

  • Define multiple buttons
  • Trigger buttons on key up events
  • Beautiful themes and animations
  • All modal properties are two-way binded.
  • Do things the angular way

View detailed features here Documentation & Examples

Installation

Download the latest release here and use the files within the dist directory

via Bower:
$ bower install angular-confirm1

via NPM:
$ npm install angular-confirm1

##Basic usage

The snippet below shows the most commonly used properties, there are more to find in the docs.

angular.module('myApp', ['cp.ngConfirm'])
.controller('myController', function($scope, $ngConfirm){
    $scope.hey = 'Hello there!';
    $ngConfirm({
        title: 'What is up?',
        content: 'Here goes a little content, <strong>{{hey}}</strong>',
        contentUrl: 'template.html', // if contentUrl is provided, 'content' is ignored.
        scope: $scope,
        buttons: {   
            // long hand button definition
            ok: { 
                text: "ok!",
                btnClass: 'btn-primary',
                keys: ['enter'], // will trigger when enter is pressed
                action: function(scope){
                     $ngConfirm('the user clicked ok');
                }
            },
            // short hand button definition
            close: function(scope){
                $ngConfirm('the user clicked close');
            }
        },
    });
});

Demo and Documentation

See Detailed Docs + Example here.

Issues

Please post issues and feature request here Github issues

Version changes

(coming in 1.11.0)

  • remove jquery as dependency

(new in 1.1.0)

  • Major performance fixes
  • Fix memory leaks
  • Removed ngAnimate and ngSanitize as dependencies
  • added set methods to modal
  • watchInterval property removed, content watch is now done with $digest
  • button functions added
  • theme fixes
  • onScopeReady callback added

(new in 1.0.1)

  • Added project to bower

Copyright and license

Copyright (C) 2016 angular-confirm

Licensed under the MIT license.

angular-confirm's People

Contributors

craftpip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-confirm's Issues

Digest Cycles Infinitely After $ngConfirm open and close

When we open up any #ngConfirm dialog on a page, the digest loop count just runs wild until the user leaves the page.

This is the case even when you close the dialog window. I've tried several ideas within my controller, including manually closing, setting the $ngConfirm object to a variable and then un-setting it, but the problem does not go away.

I don't think we can implement your library until this issue is fixed.

Content Cropped

When I open the modal, if the content is longer than the initial height of the modal, it is cropped. If I close and re-open the same modal (or any modal that has extended content, it works fine.'.

The content is an image.

Has anyone else experienced this?

Some scope watch may caused angular dirty check goes wrong.

In Line 481:

 _bindEvents: function () {
                    var that = this;
                    this._scope.$watch('[ngc.alignMiddle, ngc.offsetTop, ngc.offsetBottom]', function () {
                        that.setDialogCenter('bindEvents');
                    });

due to angular offical document (https://docs.angularjs.org/error/$rootScope/infdig ),those code may caused dirty check error.
I modified to this.

_bindEvents: function () {
          var that = this;
          var boxSets = [this._scope.ngc.alignMiddle, this._scope.ngc.offsetTop, this._scope.ngc.offsetBottom];
          this._scope.$watch(boxSets, function () {
            that.setDialogCenter('bindEvents');
          });

Error: [jqLite:nosel]

screenshot 8

I am getting this error when trying to call this

 $ngConfirm({
             title: 'Alert',
             icon: 'fa fa-info-circle',
             theme: 'supervan',
             content: '',
             animation: 'scale',
             closeAnimation: 'scale',
             buttons: {
                 ok: {
                     btnClass: "btn-blue",
                 },
                 close: function () {

                 }
             },
         })

Angular-7 release

Hi, it would be grateful if you release plugin for angular. (version 2- 7)

angular-confirm requires jQuery

I am using Webpack with bootstrap 4 which is working fine. After I installed angular-confirm I am only receiving this message 'angular-confirm requires jQuery'.

Can't opt out of default button styling

If you have to implement a custom design, the theme feature gets you most of the way there, but there's a bunch of built-in styles applied to the buttons that block any easy way of using custom button classes.

A config property that allows you to turn off default styling for buttons would be great, so that you don't have to counteract the offending styles in your custom class.

.ng-confirm .ng-confirm-box .ng-confirm-buttons button {
    display: inline-block;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.42857143;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    -ms-touch-action: manipulation;
    touch-action: manipulation;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    border-radius: 4px;
    min-height: 1em;
    outline: 0;
    -webkit-transition: opacity 0.1s ease, background-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
    transition: opacity 0.1s ease, background-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    border: none;
    background-image: none;
}

How to install?

Could somebody please give a more in-depth description of how I can add this to my angular project. I'm writing my project in typescript. I've npm installed the package files for this plugin. But I don't understand how I can start to use it in my project.

Add position option

Ability to show the dialog at different places of the screen.

  • top-left
  • top-center
  • top-right
  • center-left
  • center (default)
  • center-right
  • bottom-left
  • bottom-center
  • bottom-right

ControllerAs synax

Don't think I saw an option for this in the document, but 'ControllerAs' syntax would be nice to have. This would allow the ability to pass 'this' as scope. Not sure if the following will be helpful:

// controller declaration
var vm = this;
$ngConfirm({
    scope: vm
});

Need scope.$apply in version 1.1.0

On close function:
if (typeof this.onClose === 'function') this.onClose.apply(this, [this.scope]);
and in the setTimeout function:
if (typeof self.onDestroy == 'function') self.onDestroy.apply(self, [self.scope]);

These two functions will not emit anything to angular,so some angular function calls in onClose or onDestroy will not work properly like:
onDestroy: function () { $location.path($scope.backurl); return true; }

so I changed those code to:
if (typeof this.onClose === 'function') { this.onClose.apply(this, [this.scope]); self.scope.$parent.$apply(); }

to call angular apply the changes.

"Undefined is not a function" when escapeKey property is true

I get the following error in Chrome with the following:

  1. These properties are set:
    escapeKey: true,
    backgroundDismiss: true

  2. Press the "Escape" key when a confirm dialog window is open

The following error in the Chrome console comes up:

Uncaught TypeError: undefined is not a function

Popover style

Hi , is it possible a popover also like boostrap popover
Thank you

Angular 14 support

I have a request concerning this library. Please, can we have Angular 14 support?

Draggable

I was looking at the jQuery plugin, and it had draggable feature.
Was that made possible through jQueryUi? And is it possible to port over that functionality without (preferably) jQueryUi? If that is not possible, then perhaps jQueryUi dependency could be optional. So if jQueryUi is not included, then draggable feature will not work.

ngShow / ngHide Classes Get Applied In The $$postDigest Phase Caused confirm box height error

Hi,
I'm using angular 1.5.9 and angular-confirm 1.1.0.

Due to this article:
https://www.bennadel.com/blog/2853-ngshow-nghide-classes-get-applied-in-the-postdigest-phase-in-angularjs-1-3.htm
If I use dom controller with ng-hide or ng-show in confirm box template, the digest will first update confirm box height, then the dom get updated.
so I changed some code on line 913~917 :

var thisBox = this;
          $timeout(function asyncTestCheck(){
            console.log($content.outerHeight());
            thisBox.$contentPane.css({
              'height': $content.outerHeight(),
            }).scrollTop(0);
            thisBox.$confirmBox.css(style);
          },0,false);

As a walkaround, I doesnt changed the calculate of contentHeight. Maybe could get fixed in next version.

Error jqLite

I got an error when run this

Error: [jqLite:nosel] http://errors.angularjs.org/1.6.2/jqLite/nosel
M/

any solution?

How to pass parameters to ‘contentUrl’

// tpl/insuranceCard_mamanger.html   ng-controller="insuranceCardMamangerCtrl"
$scope.id = '123456';
$ngConfirm({
            title: 'card',
            contentUrl: 'tpl/insuranceCard_detail.html',
            buttons: {
            }
})

// tpl/insuranceCard_detail.html   ng-controller="InsuranceCardDetailCtrl"
$http.get('url', params: { id : $scope.id}).then(// do something);

how to pass '123456' to insuranceCard_detail.html?

missing $digests

I don't currently have any solutions for this.
At least some of the time, the $digest loop is not executed after an action is performed. For example, if a button's action changes some model variable that should show up on the screen it will not show up until I force a $digest in some other way. I can do that with a call to scope.$apply() at the end of the action.

Close by controller

I have open the confirm box. Now I want to close this through controller not by clicking the close icon. How can I do that?

Input Example

Can you put an input example on your page? The one you have as an example works great but I can not find any examples of how you are defining it. What scope its using, If it is an inline template, whether you can defind it in a schema like you do the buttons etc. Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.