From e1d199edf38c03ed390cd362727c12f006566483 Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Fri, 3 Apr 2015 09:18:08 +0200 Subject: Commits changes available on PyPi The release .2 on PyPi already includes changes acted uppon in Horizon. This patch commits those changes to stackforge. It also adds a .gitreview file. Change-Id: Ibc25f66dba97c2121b5d7fe485175d7cd76b6267 --- .gitreview | 4 + MANIFEST.in | 2 +- PKG-INFO | 25 --- README.txt | 4 +- setup.py | 2 +- xstatic/pkg/angular_irdragndrop/__init__.py | 57 ------- .../pkg/angular_irdragndrop/data/irdragndrop.js | 184 --------------------- xstatic/pkg/angular_lrdragndrop/__init__.py | 57 +++++++ .../pkg/angular_lrdragndrop/data/lrdragndrop.js | 184 +++++++++++++++++++++ 9 files changed, 249 insertions(+), 270 deletions(-) create mode 100644 .gitreview delete mode 100644 PKG-INFO delete mode 100644 xstatic/pkg/angular_irdragndrop/__init__.py delete mode 100644 xstatic/pkg/angular_irdragndrop/data/irdragndrop.js create mode 100644 xstatic/pkg/angular_lrdragndrop/__init__.py create mode 100644 xstatic/pkg/angular_lrdragndrop/data/lrdragndrop.js diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..17ae1e0 --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.openstack.org +port=29418 +project=stackforge/xstatic-angular-lrdragndrop.git diff --git a/MANIFEST.in b/MANIFEST.in index 397d3ca..ca53438 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ include README.txt -recursive-include xstatic/pkg/angular_irdragndrop * +recursive-include xstatic/pkg/angular_lrdragndrop * global-exclude *.pyc global-exclude *.pyo diff --git a/PKG-INFO b/PKG-INFO deleted file mode 100644 index 151a3d7..0000000 --- a/PKG-INFO +++ /dev/null @@ -1,25 +0,0 @@ -Metadata-Version: 1.0 -Name: XStatic-angular-irdragndrop -Version: 1.0.2 -Summary: irdragndrop 1.0.2 (XStatic packaging standard) -Home-page: https://github.com/lorenzofox3/lrDragNDrop -Author: Thai Tran -Author-email: tqtran@us.ibm.com -License: MIT -Description: - XStatic-angular-IrDragNDrop - ------------------- - - IrDragNDrop javascript 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`. - -Keywords: drag-n-drop angular table irdragndrop xstatic -Platform: any diff --git a/README.txt b/README.txt index 86be7eb..dc05bf6 100644 --- a/README.txt +++ b/README.txt @@ -1,8 +1,8 @@ -XStatic-angular-IrDragNDrop +XStatic-Angular-lrdragndrop ------------------- -IrDragNDrop javascript library packaged for setuptools (easy_install) / pip. +lrDragNDrop javascript library packaged for setuptools (easy_install) / pip. This package is intended to be used by **any** project that needs these files. diff --git a/setup.py b/setup.py index d7ecd21..a0a4057 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ -from xstatic.pkg import angular_smart_table as xs +from xstatic.pkg import angular_lrdragndrop as xs # The README.txt file should be written in reST so that PyPI can use # it to generate your project's PyPI page. diff --git a/xstatic/pkg/angular_irdragndrop/__init__.py b/xstatic/pkg/angular_irdragndrop/__init__.py deleted file mode 100644 index 0a1dbb4..0000000 --- a/xstatic/pkg/angular_irdragndrop/__init__.py +++ /dev/null @@ -1,57 +0,0 @@ - -""" -XStatic resource package - -See package 'XStatic' for documentation and basic tools. -""" - -# official name, upper/lowercase allowed, no spaces -DISPLAY_NAME = 'IrDragNDrop' - -# name used for PyPi -PACKAGE_NAME = 'XStatic-%s' % DISPLAY_NAME - -NAME = __name__.split('.')[-1] # package name (e.g. 'foo' or 'foo_bar') - # please use a all-lowercase valid python - # package name - -VERSION = '1.0.2' # 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 = 'drag-n-drop angular table irdragndrop xstatic' - -# XStatic-* package maintainer: -MAINTAINER = 'Thai Tran' -MAINTAINER_EMAIL = 'tqtran@us.ibm.com' - -# this refers to the project homepage of the stuff we packaged: -HOMEPAGE = 'https://github.com/lorenzofox3/lrDragNDrop' - -# this refers to all files: -LICENSE = '(same as %s)' % DISPLAY_NAME - -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/' + NAME - -# location of the Javascript file that's the entry point for this package, if -# one exists, relative to BASE_DIR -MAIN='irdragndrop.js' - -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. -} diff --git a/xstatic/pkg/angular_irdragndrop/data/irdragndrop.js b/xstatic/pkg/angular_irdragndrop/data/irdragndrop.js deleted file mode 100644 index 2b7c383..0000000 --- a/xstatic/pkg/angular_irdragndrop/data/irdragndrop.js +++ /dev/null @@ -1,184 +0,0 @@ -(function (ng) { - 'use strict'; - - function isJqueryEventDataTransfer(){ - return window.jQuery && (-1 == window.jQuery.event.props.indexOf('dataTransfer')); - } - - if (isJqueryEventDataTransfer()) { - window.jQuery.event.props.push('dataTransfer'); - } - - var module = ng.module('lrDragNDrop', []); - - module.service('lrDragStore', ['$document', function (document) { - - var store = {}; - - this.hold = function hold(key, item, collectionFrom, safe) { - store[key] = { - item: item, - collection: collectionFrom, - safe: safe === true - } - }; - - this.get = function (namespace) { - var - modelItem = store[namespace], itemIndex; - - if (modelItem) { - itemIndex = modelItem.collection.indexOf(modelItem.item); - return modelItem.safe === true ? modelItem.item : modelItem.collection.splice(itemIndex, 1)[0]; - } else { - return null; - } - }; - - this.clean = function clean() { - store = {}; - }; - - this.isHolding = function (namespace) { - return store[namespace] !== undefined; - }; - - document.bind('dragend', this.clean); - }]); - - module.service('lrDragHelper', function () { - var th = this; - - th.parseRepeater = function(scope, attr) { - var - repeatExpression = attr.ngRepeat, - match; - - if (!repeatExpression) { - throw Error('this directive must be used with ngRepeat directive'); - } - match = repeatExpression.match(/^(.*\sin).(\S*)/); - if (!match) { - throw Error("Expected ngRepeat in form of '_item_ in _collection_' but got '" + - repeatExpression + "'."); - } - - return scope.$eval(match[2]); - }; - - th.lrDragSrcDirective = function(store, safe) { - return function compileFunc(el, iattr) { - iattr.$set('draggable', true); - return function linkFunc(scope, element, attr) { - var - collection, - key = (safe === true ? attr.lrDragSrcSafe : attr.lrDragSrc ) || 'temp'; - - if(attr.lrDragData) { - scope.$watch(attr.lrDragData, function (newValue) { - collection = newValue; - }); - } else { - collection = th.parseRepeater(scope, attr); - } - - element.bind('dragstart', function (evt) { - store.hold(key, collection[scope.$index], collection, safe); - if(angular.isDefined(evt.dataTransfer)) { - evt.dataTransfer.setData('text/html', null); //FF/jQuery fix - } - }); - } - } - } - }); - - module.directive('lrDragSrc', ['lrDragStore', 'lrDragHelper', function (store, dragHelper) { - return{ - compile: dragHelper.lrDragSrcDirective(store) - }; - }]); - - module.directive('lrDragSrcSafe', ['lrDragStore', 'lrDragHelper', function (store, dragHelper) { - return{ - compile: dragHelper.lrDragSrcDirective(store, true) - }; - }]); - - module.directive('lrDropTarget', ['lrDragStore', 'lrDragHelper', '$parse', function (store, dragHelper, $parse) { - return { - link: function (scope, element, attr) { - - var - collection, - key = attr.lrDropTarget || 'temp', - classCache = null; - - function isAfter(x, y) { - //check if below or over the diagonal of the box element - return (element[0].offsetHeight - x * element[0].offsetHeight / element[0].offsetWidth) < y; - } - - function resetStyle() { - if (classCache !== null) { - element.removeClass(classCache); - classCache = null; - } - } - - if(attr.lrDragData) { - scope.$watch(attr.lrDragData, function (newValue) { - collection = newValue; - }); - } else { - collection = dragHelper.parseRepeater(scope, attr); - } - - element.bind('drop', function (evt) { - var - collectionCopy = ng.copy(collection), - item = store.get(key), - dropIndex, i, l; - if (item !== null) { - dropIndex = scope.$index; - dropIndex = isAfter(evt.offsetX, evt.offsetY) ? dropIndex + 1 : dropIndex; - //srcCollection=targetCollection => we may need to apply a correction - if (collectionCopy.length > collection.length) { - for (i = 0, l = Math.min(dropIndex, collection.length - 1); i <= l; i++) { - if (!ng.equals(collectionCopy[i], collection[i])) { - dropIndex = dropIndex - 1; - break; - } - } - } - scope.$apply(function () { - collection.splice(dropIndex, 0, item); - var fn = $parse(attr.lrDropSuccess) || ng.noop; - fn(scope, {e: evt, item: item, collection: collection}); - }); - evt.preventDefault(); - resetStyle(); - store.clean(); - } - }); - - element.bind('dragleave', resetStyle); - - element.bind('dragover', function (evt) { - var className; - if (store.isHolding(key)) { - className = isAfter(evt.offsetX, evt.offsetY) ? 'lr-drop-target-after' : 'lr-drop-target-before'; - if (classCache !== className && classCache !== null) { - element.removeClass(classCache); - } - if (classCache !== className) { - element.addClass(className); - } - classCache = className; - } - evt.preventDefault(); - }); - } - }; - }]); -})(angular); \ No newline at end of file diff --git a/xstatic/pkg/angular_lrdragndrop/__init__.py b/xstatic/pkg/angular_lrdragndrop/__init__.py new file mode 100644 index 0000000..93c6b69 --- /dev/null +++ b/xstatic/pkg/angular_lrdragndrop/__init__.py @@ -0,0 +1,57 @@ + +""" +XStatic resource package + +See package 'XStatic' for documentation and basic tools. +""" + +# official name, upper/lowercase allowed, no spaces +DISPLAY_NAME = 'Angular-lrdragndrop' + +# name used for PyPi +PACKAGE_NAME = 'XStatic-%s' % DISPLAY_NAME + +NAME = __name__.split('.')[-1] # package name (e.g. 'foo' or 'foo_bar') + # please use a all-lowercase valid python + # package name + +VERSION = '1.0.2' # version of the packaged files, please use the upstream + # version number +BUILD = '2' # 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 = 'drag-n-drop angular table lrdragndrop xstatic' + +# XStatic-* package maintainer: +MAINTAINER = 'Thai Tran' +MAINTAINER_EMAIL = 'tqtran@us.ibm.com' + +# this refers to the project homepage of the stuff we packaged: +HOMEPAGE = 'https://github.com/lorenzofox3/lrDragNDrop' + +# this refers to all files: +LICENSE = '(same as %s)' % DISPLAY_NAME + +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/' + NAME + +# location of the Javascript file that's the entry point for this package, if +# one exists, relative to BASE_DIR +MAIN='lrdragndrop.js' + +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. +} diff --git a/xstatic/pkg/angular_lrdragndrop/data/lrdragndrop.js b/xstatic/pkg/angular_lrdragndrop/data/lrdragndrop.js new file mode 100644 index 0000000..2b7c383 --- /dev/null +++ b/xstatic/pkg/angular_lrdragndrop/data/lrdragndrop.js @@ -0,0 +1,184 @@ +(function (ng) { + 'use strict'; + + function isJqueryEventDataTransfer(){ + return window.jQuery && (-1 == window.jQuery.event.props.indexOf('dataTransfer')); + } + + if (isJqueryEventDataTransfer()) { + window.jQuery.event.props.push('dataTransfer'); + } + + var module = ng.module('lrDragNDrop', []); + + module.service('lrDragStore', ['$document', function (document) { + + var store = {}; + + this.hold = function hold(key, item, collectionFrom, safe) { + store[key] = { + item: item, + collection: collectionFrom, + safe: safe === true + } + }; + + this.get = function (namespace) { + var + modelItem = store[namespace], itemIndex; + + if (modelItem) { + itemIndex = modelItem.collection.indexOf(modelItem.item); + return modelItem.safe === true ? modelItem.item : modelItem.collection.splice(itemIndex, 1)[0]; + } else { + return null; + } + }; + + this.clean = function clean() { + store = {}; + }; + + this.isHolding = function (namespace) { + return store[namespace] !== undefined; + }; + + document.bind('dragend', this.clean); + }]); + + module.service('lrDragHelper', function () { + var th = this; + + th.parseRepeater = function(scope, attr) { + var + repeatExpression = attr.ngRepeat, + match; + + if (!repeatExpression) { + throw Error('this directive must be used with ngRepeat directive'); + } + match = repeatExpression.match(/^(.*\sin).(\S*)/); + if (!match) { + throw Error("Expected ngRepeat in form of '_item_ in _collection_' but got '" + + repeatExpression + "'."); + } + + return scope.$eval(match[2]); + }; + + th.lrDragSrcDirective = function(store, safe) { + return function compileFunc(el, iattr) { + iattr.$set('draggable', true); + return function linkFunc(scope, element, attr) { + var + collection, + key = (safe === true ? attr.lrDragSrcSafe : attr.lrDragSrc ) || 'temp'; + + if(attr.lrDragData) { + scope.$watch(attr.lrDragData, function (newValue) { + collection = newValue; + }); + } else { + collection = th.parseRepeater(scope, attr); + } + + element.bind('dragstart', function (evt) { + store.hold(key, collection[scope.$index], collection, safe); + if(angular.isDefined(evt.dataTransfer)) { + evt.dataTransfer.setData('text/html', null); //FF/jQuery fix + } + }); + } + } + } + }); + + module.directive('lrDragSrc', ['lrDragStore', 'lrDragHelper', function (store, dragHelper) { + return{ + compile: dragHelper.lrDragSrcDirective(store) + }; + }]); + + module.directive('lrDragSrcSafe', ['lrDragStore', 'lrDragHelper', function (store, dragHelper) { + return{ + compile: dragHelper.lrDragSrcDirective(store, true) + }; + }]); + + module.directive('lrDropTarget', ['lrDragStore', 'lrDragHelper', '$parse', function (store, dragHelper, $parse) { + return { + link: function (scope, element, attr) { + + var + collection, + key = attr.lrDropTarget || 'temp', + classCache = null; + + function isAfter(x, y) { + //check if below or over the diagonal of the box element + return (element[0].offsetHeight - x * element[0].offsetHeight / element[0].offsetWidth) < y; + } + + function resetStyle() { + if (classCache !== null) { + element.removeClass(classCache); + classCache = null; + } + } + + if(attr.lrDragData) { + scope.$watch(attr.lrDragData, function (newValue) { + collection = newValue; + }); + } else { + collection = dragHelper.parseRepeater(scope, attr); + } + + element.bind('drop', function (evt) { + var + collectionCopy = ng.copy(collection), + item = store.get(key), + dropIndex, i, l; + if (item !== null) { + dropIndex = scope.$index; + dropIndex = isAfter(evt.offsetX, evt.offsetY) ? dropIndex + 1 : dropIndex; + //srcCollection=targetCollection => we may need to apply a correction + if (collectionCopy.length > collection.length) { + for (i = 0, l = Math.min(dropIndex, collection.length - 1); i <= l; i++) { + if (!ng.equals(collectionCopy[i], collection[i])) { + dropIndex = dropIndex - 1; + break; + } + } + } + scope.$apply(function () { + collection.splice(dropIndex, 0, item); + var fn = $parse(attr.lrDropSuccess) || ng.noop; + fn(scope, {e: evt, item: item, collection: collection}); + }); + evt.preventDefault(); + resetStyle(); + store.clean(); + } + }); + + element.bind('dragleave', resetStyle); + + element.bind('dragover', function (evt) { + var className; + if (store.isHolding(key)) { + className = isAfter(evt.offsetX, evt.offsetY) ? 'lr-drop-target-after' : 'lr-drop-target-before'; + if (classCache !== className && classCache !== null) { + element.removeClass(classCache); + } + if (classCache !== className) { + element.addClass(className); + } + classCache = className; + } + evt.preventDefault(); + }); + } + }; + }]); +})(angular); \ No newline at end of file -- cgit v1.2.1