misc: use xstatic-select2 instead of local copy (#63487)

This commit is contained in:
Frédéric Péters 2022-04-03 12:29:39 +02:00
parent 63c31fa6d9
commit ca940dec59
14 changed files with 14 additions and 6587 deletions

1
debian/control vendored
View File

@ -35,6 +35,7 @@ Depends: graphviz,
python3-xstatic-godo,
python3-xstatic-leaflet,
python3-xstatic-leaflet-gesturehandling,
python3-xstatic-select2,
uwsgi,
uwsgi-plugin-python3,
${misc:Depends},

View File

@ -175,6 +175,7 @@ setup(
'django-ratelimit<3',
'XStatic-Leaflet',
'XStatic-Leaflet-GestureHandling',
'XStatic-Select2',
'pyproj',
'unidecode',
],

View File

@ -1256,7 +1256,7 @@ class FormPage(Directory):
get_response().add_javascript(
['jquery.js', '../../i18n.js', 'qommon.forms.js', 'select2.js']
)
get_response().add_css_include('../js/select2/select2.css')
get_response().add_css_include('select2.css')
if self.view and self.view.visibility == 'datasource':
options.append(('{}', _('custom value'), '{}'))
if filter_field_value and filter_field_value not in [x[0] for x in options]:

View File

@ -71,12 +71,12 @@ class HTTPResponse(quixote.http_response.HTTPResponse):
mappings = {
'jquery.js': '../xstatic/jquery.min.js',
'jquery-ui.js': '../xstatic/jquery-ui.min.js',
'select2.js': 'select2/select2.min.js',
'select2.js': '../xstatic/select2.min.js',
}
if debug_mode:
mappings['jquery.js'] = '../xstatic/jquery.js'
mappings['jquery-ui.js'] = '../xstatic/jquery-ui.js'
mappings['select2.js'] = 'select2/select2.js'
mappings['select2.js'] = '../xstatic/select2.js'
if not get_request().is_in_backoffice():
branding_cfg = get_publisher().cfg.get('branding') or {}
for included_js_library in branding_cfg.get('included_js_libraries') or []:
@ -136,7 +136,7 @@ class HTTPResponse(quixote.http_response.HTTPResponse):
self.add_javascript(['../../i18n.js', 'jquery.js', 'qommon.slugify.js'])
if script_name == 'select2.js':
self.add_javascript(['jquery.js', '../../i18n.js', 'qommon.forms.js', 'select2.js'])
self.add_css_include('../js/select2/select2.css')
self.add_css_include('select2.css')
def add_javascript_code(self, code):
if not self.javascript_code_parts:
@ -166,6 +166,13 @@ class HTTPResponse(quixote.http_response.HTTPResponse):
return s
def add_css_include(self, css_include):
debug_mode = get_publisher().cfg.get('debug', {}).get('debug_mode', False)
mappings = {
'select2.css': '../xstatic/select2.min.css',
}
if debug_mode:
mappings['select2.css'] = '../xstatic/select2.css'
css_include = mappings.get(css_include, css_include)
if not self.css_includes:
self.css_includes = []
if css_include not in self.css_includes:

View File

@ -1,12 +0,0 @@
Copyright 2012 Igor Vaynberg
Version: @@ver@@ Timestamp: @@timestamp@@
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in
compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.

View File

@ -1,68 +0,0 @@
Select2
=================
Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results. Look and feel of Select2 is based on the excellent [Chosen](http://harvesthq.github.com/chosen/) library.
To get started -- checkout http://ivaynberg.github.com/select2!
What Does Select2 Support That Chosen Does Not?
-------------------------------------------------
* Working with large datasets: Chosen requires the entire dataset to be loaded as `option` tags in the DOM, which limits
it to working with small-ish datasets. Select2 uses a function to find results on-the-fly, which allows it to partially
load results.
* Paging of results: Since Select2 works with large datasets and only loads a small amount of matching results at a time
it has to support paging. Select2 will call the search function when the user scrolls to the bottom of currently loaded
result set allowing for the 'infinite scrolling' of results.
* Custom markup for results: Chosen only supports rendering text results because that is the only markup supported by
`option` tags. Select2 provides an extension point which can be used to produce any kind of markup to represent results.
* Ability to add results on the fly: Select2 provides the ability to add results from the search term entered by the user, which allows it to be used for
tagging.
Browser Compatibility
--------------------
* IE 8+ (7 mostly works except for [issue with z-index](https://github.com/ivaynberg/select2/issues/37))
* Chrome 8+
* Firefox 3.5+
* Safari 3+
* Opera 10.6+
Integrations
------------
* [Wicket-Select2](https://github.com/ivaynberg/wicket-select2) (Java / Apache Wicket)
* [select2-rails](https://github.com/argerim/select2-rails) (Ruby on Rails)
* [AngularUI](http://angular-ui.github.com/#directives-select2) ([AngularJS](angularjs.org))
* [Django](https://github.com/applegrew/django-select2)
Bug tracker
-----------
Have a bug? Please create an issue here on GitHub!
https://github.com/ivaynberg/select2/issues
Mailing list
------------
Have a question? Ask on our mailing list!
select2@googlegroups.com
https://groups.google.com/d/forum/select2
Copyright and License
---------------------
Copyright 2012 Igor Vaynberg
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in
compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.

View File

@ -1,63 +0,0 @@
#!/bin/bash
set -e
echo -n "Enter the version for this release: "
read ver
if [ ! $ver ]; then
echo "Invalid version."
exit
fi
name="select2"
js="$name.js"
mini="$name.min.js"
css="$name.css"
release="$name-$ver"
tag="release-$ver"
branch="build-$ver"
curbranch=`git branch | grep "*" | sed "s/* //"`
timestamp=$(date)
tokens="s/@@ver@@/$ver/g;s/\@@timestamp@@/$timestamp/g"
remote="github"
git branch "$branch"
git checkout "$branch"
echo "Tokenizing..."
find . -name "$js" | xargs -I{} sed -e "$tokens" -i "" {}
find . -name "$css" | xargs -I{} sed -e "$tokens" -i "" {}
git add "$js"
git add "$css"
echo "Minifying..."
echo "/*" > "$mini"
cat LICENSE | sed "$tokens" >> "$mini"
echo "*/" >> "$mini"
curl -s \
-d compilation_level=SIMPLE_OPTIMIZATIONS \
-d output_format=text \
-d output_info=compiled_code \
--data-urlencode "js_code@$js" \
http://closure-compiler.appspot.com/compile \
>> "$mini"
git add "$mini"
git commit -m "release $ver"
echo "Tagging..."
git tag -a "$tag" -m "tagged version $ver"
git push "$remote" --tags
echo "Cleaning Up..."
git checkout "$curbranch"
git branch -D "$branch"
echo "Done"

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 613 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 845 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -196,6 +196,7 @@ class StaticsDirectory(Directory):
'xstatic:opensans',
'xstatic:leaflet',
'xstatic:leaflet_gesturehandling',
'xstatic:select2',
],
}