Add angular-notify 1.0.0
An initial commit providing javascript, scss and other meta files.
This commit is contained in:
commit
5a6671713d
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
*.pyc
|
||||
*.sw?
|
||||
*.sqlite3
|
||||
.DS_STORE
|
||||
*.egg-info
|
||||
.venv
|
||||
.tox
|
||||
build
|
||||
dist
|
22
LICENSE
Normal file
22
LICENSE
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License
|
||||
|
||||
Copyright 2013 Chris Gross
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
6
MANIFEST.in
Normal file
6
MANIFEST.in
Normal file
@ -0,0 +1,6 @@
|
||||
include README.txt
|
||||
recursive-include xstatic *
|
||||
global-exclude *.pyc
|
||||
global-exclude *.pyo
|
||||
global-exclude *.orig
|
||||
global-exclude *.rej
|
13
README.txt
Normal file
13
README.txt
Normal file
@ -0,0 +1,13 @@
|
||||
XStatic-Angular-Notify
|
||||
--------------
|
||||
|
||||
Angular-Notify JavaScript and SCSS library packaged for setuptools (easy_install) / pip.
|
||||
|
||||
This package is intended to be used by **any** project that needs these files.
|
||||
|
||||
It intentionally does **not** provide any extra code except some metadata
|
||||
**nor** has any extra requirements. You MAY use some minimal support code from
|
||||
the XStatic base package, if you like.
|
||||
|
||||
You can find more info about the xstatic packaging way in the package `XStatic`.
|
||||
|
20
setup.cfg
Normal file
20
setup.cfg
Normal file
@ -0,0 +1,20 @@
|
||||
[metadata]
|
||||
name = XStatic-Angular-Notify
|
||||
description = Angular-Notify 2.5.1 (XStatic packaging standard)
|
||||
description-file = README.rst
|
||||
maintainer = xinni.ge
|
||||
maintainer-email = xinni.ge@ntt.com
|
||||
home-page = https://github.com/cgross/angular-notify
|
||||
keywords = angular_notify xstatic
|
||||
license = MIT
|
||||
zip_safe = False
|
||||
namespace_packages =
|
||||
xstatic
|
||||
xstatic.pkg
|
||||
|
||||
[files]
|
||||
packages =
|
||||
xstatic
|
||||
|
||||
[bdist_wheel]
|
||||
universal = True
|
25
setup.py
Normal file
25
setup.py
Normal file
@ -0,0 +1,25 @@
|
||||
from setuptools import setup, find_packages
|
||||
from xstatic.pkg import angular_notify as xs
|
||||
|
||||
# The README.txt file should be written in reST so that PyPI can use
|
||||
# it to generate your project's PyPI page.
|
||||
long_description = open('README.txt').read()
|
||||
|
||||
setup(
|
||||
name=xs.PACKAGE_NAME,
|
||||
version=xs.PACKAGE_VERSION,
|
||||
description=xs.DESCRIPTION,
|
||||
long_description=long_description,
|
||||
classifiers=xs.CLASSIFIERS,
|
||||
keywords=xs.KEYWORDS,
|
||||
maintainer=xs.MAINTAINER,
|
||||
maintainer_email=xs.MAINTAINER_EMAIL,
|
||||
license=xs.LICENSE,
|
||||
url=xs.HOMEPAGE,
|
||||
platforms=xs.PLATFORMS,
|
||||
packages=find_packages(),
|
||||
namespace_packages=['xstatic', 'xstatic.pkg'],
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
install_requires=[],
|
||||
)
|
8
tox.ini
Normal file
8
tox.ini
Normal file
@ -0,0 +1,8 @@
|
||||
[tox]
|
||||
minversion = 1.6
|
||||
skipsdist = True
|
||||
envlist = py27,py33,py34
|
||||
|
||||
[testenv:venv]
|
||||
commands = {posargs}
|
||||
|
1
xstatic/__init__.py
Normal file
1
xstatic/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
__import__('pkg_resources').declare_namespace(__name__)
|
1
xstatic/pkg/__init__.py
Normal file
1
xstatic/pkg/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
__import__('pkg_resources').declare_namespace(__name__)
|
50
xstatic/pkg/angular_notify/__init__.py
Normal file
50
xstatic/pkg/angular_notify/__init__.py
Normal file
@ -0,0 +1,50 @@
|
||||
"""
|
||||
XStatic resource package
|
||||
|
||||
See package 'XStatic' for documentation and basic tools.
|
||||
"""
|
||||
|
||||
DISPLAY_NAME = 'Angular-Notify' # official name, upper/lowercase allowed, no spaces
|
||||
PACKAGE_NAME = 'XStatic-%s' % DISPLAY_NAME # name used for PyPi
|
||||
|
||||
NAME = __name__.split('.')[-1] # package name (e.g. 'foo' or 'foo_bar')
|
||||
# please use a all-lowercase valid python
|
||||
# package name
|
||||
|
||||
VERSION = '2.5.1' # version of the packaged files, please use the upstream
|
||||
# version number
|
||||
BUILD = '0' # our package build number, so we can release new builds
|
||||
# with fixes for xstatic stuff.
|
||||
PACKAGE_VERSION = VERSION + '.' + BUILD # version used for PyPi
|
||||
|
||||
DESCRIPTION = "%s %s (XStatic packaging standard)" % (DISPLAY_NAME, VERSION)
|
||||
|
||||
PLATFORMS = 'any'
|
||||
CLASSIFIERS = []
|
||||
KEYWORDS = '%s xstatic' % NAME
|
||||
|
||||
# XStatic-* package maintainer:
|
||||
MAINTAINER = 'xinni.ge'
|
||||
MAINTAINER_EMAIL = 'xinni.ge@ntt.com'
|
||||
|
||||
# this refers to the project homepage of the stuff we packaged:
|
||||
HOMEPAGE = 'https://github.com/cgross/angular-notify'
|
||||
|
||||
# this refers to all files:
|
||||
LICENSE = 'MIT'
|
||||
|
||||
from os.path import join, dirname
|
||||
BASE_DIR = join(dirname(__file__), 'data')
|
||||
# linux package maintainers just can point to their file locations like this:
|
||||
#BASE_DIR = '/usr/share/javascript/angular-notify'
|
||||
|
||||
LOCATIONS = {
|
||||
# CDN locations (if no public CDN exists, use an empty dict)
|
||||
# if value is a string, it is a base location, just append relative
|
||||
# path/filename. if value is a dict, do another lookup using the
|
||||
# relative path/filename you want.
|
||||
# your relative path/filenames should usually be without version
|
||||
# information, because either the base dir/url is exactly for this
|
||||
# version or the mapping will care for accessing this version.
|
||||
}
|
||||
|
184
xstatic/pkg/angular_notify/data/angular-notify.js
vendored
Normal file
184
xstatic/pkg/angular_notify/data/angular-notify.js
vendored
Normal file
@ -0,0 +1,184 @@
|
||||
angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile','$templateCache','$rootScope',
|
||||
function($timeout,$http,$compile,$templateCache,$rootScope){
|
||||
|
||||
var startTop = 10;
|
||||
var verticalSpacing = 15;
|
||||
var defaultDuration = 10000;
|
||||
var defaultTemplateUrl = 'angular-notify.html';
|
||||
var position = 'center';
|
||||
var container = document.body;
|
||||
var maximumOpen = 0;
|
||||
|
||||
var messageElements = [];
|
||||
var openNotificationsScope = [];
|
||||
|
||||
var notify = function(args){
|
||||
|
||||
if (typeof args !== 'object'){
|
||||
args = {message:args};
|
||||
}
|
||||
|
||||
args.duration = args.duration ? args.duration : defaultDuration;
|
||||
args.templateUrl = args.templateUrl ? args.templateUrl : defaultTemplateUrl;
|
||||
args.container = args.container ? args.container : container;
|
||||
args.classes = args.classes ? args.classes : '';
|
||||
|
||||
var scope = args.scope ? args.scope.$new() : $rootScope.$new();
|
||||
scope.$position = args.position ? args.position : position;
|
||||
scope.$message = args.message;
|
||||
scope.$classes = args.classes;
|
||||
scope.$messageTemplate = args.messageTemplate;
|
||||
|
||||
if (maximumOpen > 0) {
|
||||
var numToClose = (openNotificationsScope.length + 1) - maximumOpen;
|
||||
for (var i = 0; i < numToClose; i++) {
|
||||
openNotificationsScope[i].$close();
|
||||
}
|
||||
}
|
||||
|
||||
$http.get(args.templateUrl,{cache: $templateCache}).then(function(template){
|
||||
|
||||
var templateElement = $compile(template.data)(scope);
|
||||
templateElement.bind('webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd', function(e){
|
||||
if (e.propertyName === 'opacity' || e.currentTarget.style.opacity === 0 ||
|
||||
(e.originalEvent && e.originalEvent.propertyName === 'opacity')){
|
||||
|
||||
templateElement.remove();
|
||||
messageElements.splice(messageElements.indexOf(templateElement),1);
|
||||
openNotificationsScope.splice(openNotificationsScope.indexOf(scope),1);
|
||||
layoutMessages();
|
||||
}
|
||||
});
|
||||
|
||||
if (args.messageTemplate){
|
||||
var messageTemplateElement;
|
||||
for (var i = 0; i < templateElement.children().length; i ++){
|
||||
if (angular.element(templateElement.children()[i]).hasClass('cg-notify-message-template')){
|
||||
messageTemplateElement = angular.element(templateElement.children()[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (messageTemplateElement){
|
||||
messageTemplateElement.append($compile(args.messageTemplate)(scope));
|
||||
} else {
|
||||
throw new Error('cgNotify could not find the .cg-notify-message-template element in '+args.templateUrl+'.');
|
||||
}
|
||||
}
|
||||
|
||||
angular.element(args.container).append(templateElement);
|
||||
messageElements.push(templateElement);
|
||||
|
||||
if (scope.$position === 'center'){
|
||||
$timeout(function(){
|
||||
scope.$centerMargin = '-' + (templateElement[0].offsetWidth /2) + 'px';
|
||||
});
|
||||
}
|
||||
|
||||
scope.$close = function(){
|
||||
templateElement.css('opacity',0).attr('data-closing','true');
|
||||
layoutMessages();
|
||||
};
|
||||
|
||||
var layoutMessages = function(){
|
||||
var j = 0;
|
||||
var currentY = startTop;
|
||||
for(var i = messageElements.length - 1; i >= 0; i --){
|
||||
var shadowHeight = 10;
|
||||
var element = messageElements[i];
|
||||
var height = element[0].offsetHeight;
|
||||
var top = currentY + height + shadowHeight;
|
||||
if (element.attr('data-closing')){
|
||||
top += 20;
|
||||
} else {
|
||||
currentY += height + verticalSpacing;
|
||||
}
|
||||
element.css('top',top + 'px').css('margin-top','-' + (height+shadowHeight) + 'px').css('visibility','visible');
|
||||
j ++;
|
||||
}
|
||||
};
|
||||
|
||||
$timeout(function(){
|
||||
layoutMessages();
|
||||
});
|
||||
|
||||
if (args.duration > 0){
|
||||
$timeout(function(){
|
||||
scope.$close();
|
||||
},args.duration);
|
||||
}
|
||||
|
||||
}, function(data) {
|
||||
throw new Error('Template specified for cgNotify ('+args.templateUrl+') could not be loaded. ' + data);
|
||||
});
|
||||
|
||||
var retVal = {};
|
||||
|
||||
retVal.close = function(){
|
||||
if (scope.$close){
|
||||
scope.$close();
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(retVal,'message',{
|
||||
get: function(){
|
||||
return scope.$message;
|
||||
},
|
||||
set: function(val){
|
||||
scope.$message = val;
|
||||
}
|
||||
});
|
||||
|
||||
openNotificationsScope.push(scope);
|
||||
|
||||
return retVal;
|
||||
|
||||
};
|
||||
|
||||
notify.config = function(args){
|
||||
startTop = !angular.isUndefined(args.startTop) ? args.startTop : startTop;
|
||||
verticalSpacing = !angular.isUndefined(args.verticalSpacing) ? args.verticalSpacing : verticalSpacing;
|
||||
defaultDuration = !angular.isUndefined(args.duration) ? args.duration : defaultDuration;
|
||||
defaultTemplateUrl = args.templateUrl ? args.templateUrl : defaultTemplateUrl;
|
||||
position = !angular.isUndefined(args.position) ? args.position : position;
|
||||
container = args.container ? args.container : container;
|
||||
maximumOpen = args.maximumOpen ? args.maximumOpen : maximumOpen;
|
||||
};
|
||||
|
||||
notify.closeAll = function(){
|
||||
for(var i = messageElements.length - 1; i >= 0; i --){
|
||||
var element = messageElements[i];
|
||||
element.css('opacity',0);
|
||||
}
|
||||
};
|
||||
|
||||
return notify;
|
||||
}
|
||||
]);
|
||||
|
||||
angular.module('cgNotify').run(['$templateCache', function($templateCache) {
|
||||
'use strict';
|
||||
|
||||
$templateCache.put('angular-notify.html',
|
||||
"<div class=\"cg-notify-message\" ng-class=\"[$classes, \n" +
|
||||
" $position === 'center' ? 'cg-notify-message-center' : '',\n" +
|
||||
" $position === 'left' ? 'cg-notify-message-left' : '',\n" +
|
||||
" $position === 'right' ? 'cg-notify-message-right' : '']\"\n" +
|
||||
" ng-style=\"{'margin-left': $centerMargin}\">\n" +
|
||||
"\n" +
|
||||
" <div ng-show=\"!$messageTemplate\">\n" +
|
||||
" {$ $message $}\n" +
|
||||
" </div>\n" +
|
||||
"\n" +
|
||||
" <div ng-show=\"$messageTemplate\" class=\"cg-notify-message-template\">\n" +
|
||||
" \n" +
|
||||
" </div>\n" +
|
||||
"\n" +
|
||||
" <button type=\"button\" class=\"cg-notify-close\" ng-click=\"$close()\">\n" +
|
||||
" <span aria-hidden=\"true\">×</span>\n" +
|
||||
" <span class=\"cg-notify-sr-only\">Close</span>\n" +
|
||||
" </button>\n" +
|
||||
"\n" +
|
||||
"</div>"
|
||||
);
|
||||
|
||||
}]);
|
83
xstatic/pkg/angular_notify/data/angular-notify.scss
Normal file
83
xstatic/pkg/angular_notify/data/angular-notify.scss
Normal file
@ -0,0 +1,83 @@
|
||||
.cg-notify-message {
|
||||
position:fixed;
|
||||
top:0px;
|
||||
z-index: 9999;
|
||||
max-width:400px;
|
||||
text-align: center;
|
||||
|
||||
background-color: #d9edf7;
|
||||
color: #31708f;
|
||||
padding: 15px;
|
||||
border: 1px solid #bce8f1;
|
||||
border-radius: 4px;
|
||||
|
||||
-webkit-transition: top 0.5s ease-out,opacity 0.2s ease-out;
|
||||
-moz-transition: top 0.5s ease-out,opacity 0.2s ease-out;
|
||||
-o-transition: top 0.5s ease-out,opacity 0.2s ease-out;
|
||||
transition: top 0.5s ease-out,opacity 0.2s ease-out;
|
||||
|
||||
visibility:hidden;
|
||||
|
||||
-webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175);
|
||||
box-shadow: 0 6px 12px rgba(0,0,0,.175);
|
||||
}
|
||||
|
||||
.cg-notify-message-center {
|
||||
left:50%;
|
||||
}
|
||||
|
||||
.cg-notify-message-left {
|
||||
left:15px;
|
||||
}
|
||||
|
||||
.cg-notify-message-right {
|
||||
right:15px;
|
||||
}
|
||||
|
||||
.cg-notify-message a {
|
||||
font-weight:bold;
|
||||
color:inherit;
|
||||
}
|
||||
|
||||
.cg-notify-message a:hover {
|
||||
color:inherit;
|
||||
}
|
||||
|
||||
.cg-notify-close {
|
||||
-webkit-appearance: none;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
background: 0 0;
|
||||
border: 0;
|
||||
font-size: 21px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
color: #000;
|
||||
text-shadow: 0 1px 0 #fff;
|
||||
filter: alpha(opacity=20);
|
||||
opacity: .2;
|
||||
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 3px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.cg-notify-close:hover, .cg-notify-close:focus {
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
filter: alpha(opacity=50);
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
.cg-notify-sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0,0,0,0);
|
||||
border: 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user