mirror of
https://github.com/gtbu/Typesetter-5.3-p8.git
synced 2025-04-18 20:23:14 +02:00
js-minimizer only js and not min.js
Js-minimizer minimizes now only js - fiesl and not ,min.js (but adds all) ---- hammer.js added
This commit is contained in:
parent
8d7f8820cd
commit
de61d1c311
5 changed files with 136 additions and 41 deletions
21
include/thirdparty/jquery.touch/hammer/LICENSE.md
vendored
Normal file
21
include/thirdparty/jquery.touch/hammer/LICENSE.md
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (C) 2011-2014 by Jorik Tangelder (Eight Media)
|
||||
|
||||
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.
|
51
include/thirdparty/jquery.touch/hammer/README.md
vendored
Normal file
51
include/thirdparty/jquery.touch/hammer/README.md
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
# Hammer.js 2.0.6
|
||||
|
||||
[](https://travis-ci.org/hammerjs/hammer.js)
|
||||
|
||||
## Support, Questions, and Collaboration
|
||||
|
||||
[](https://hammerjs.herokuapp.com/)
|
||||
|
||||
## Documentation
|
||||
|
||||
Visit [hammerjs.github.io](http://hammerjs.github.io) for detailed documentation.
|
||||
|
||||
```js
|
||||
// get a reference to an element
|
||||
var stage = document.getElementById('stage');
|
||||
|
||||
// create a manager for that element
|
||||
var mc = new Hammer.Manager(stage);
|
||||
|
||||
// create a recognizer
|
||||
var Rotate = new Hammer.Rotate();
|
||||
|
||||
// add the recognizer
|
||||
mc.add(Rotate);
|
||||
|
||||
// subscribe to events
|
||||
mc.on('rotate', function(e) {
|
||||
// do something cool
|
||||
var rotation = Math.round(e.rotation);
|
||||
stage.style.transform = 'rotate('+rotation+'deg)';
|
||||
});
|
||||
```
|
||||
|
||||
An advanced demo is available here: [http://codepen.io/runspired/full/ZQBGWd/](http://codepen.io/runspired/full/ZQBGWd/)
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
Read the [contributing guidelines](./CONTRIBUTING.md).
|
||||
|
||||
For PRs.
|
||||
|
||||
- Use [Angular Style commit messages](https://github.com/angular/angular.js/blob/v1.4.8/CONTRIBUTING.md#commit)
|
||||
- Rebase your PR branch when necessary
|
||||
- If you add a feature or fix a bug, please add or fix any necessary tests.
|
||||
- If a new feature, open a docs PR to go with.
|
||||
|
||||
## Building
|
||||
|
||||
You can get the pre-build versions from the Hammer.js website, or do this by yourself running
|
||||
`npm install -g grunt-cli && npm install && grunt build`
|
7
include/thirdparty/jquery.touch/hammer/hammer.min.js
vendored
Normal file
7
include/thirdparty/jquery.touch/hammer/hammer.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
include/thirdparty/jquery.touch/hammer/hammer.min.js.map
vendored
Normal file
1
include/thirdparty/jquery.touch/hammer/hammer.min.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -573,6 +573,11 @@ class Combine{
|
|||
'jquery-touch' => [
|
||||
'file' => '/include/thirdparty/jquery.touch/jquery.touch.min.js',
|
||||
],
|
||||
|
||||
// hammer - touch gestures
|
||||
'hammer' => [
|
||||
'file' => '/include/thirdparty/jquery.touch/hammer/hammer.min.js',
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
|
@ -721,62 +726,72 @@ class Combine{
|
|||
* Combine JS files
|
||||
*
|
||||
*/
|
||||
|
||||
public function CombineJS($full_paths){
|
||||
global $config;
|
||||
global $config;
|
||||
|
||||
ob_start();
|
||||
\gp\tool::jsStart();
|
||||
ob_start();
|
||||
\gp\tool::jsStart();
|
||||
|
||||
foreach($full_paths as $full_path){
|
||||
readfile($full_path);
|
||||
echo ";\n";
|
||||
}
|
||||
$combined_content = ob_get_clean();
|
||||
$minify_stats = [
|
||||
'date' => date('Y-m-d H:i'),
|
||||
'errors' => [],
|
||||
'mem_before' => memory_get_peak_usage(true),
|
||||
'size_before' => 0,
|
||||
'size_after' => 0,
|
||||
'allocated_memory' => 0,
|
||||
'compression_rate' => '0%',
|
||||
];
|
||||
|
||||
//minify js
|
||||
if( $config['minifyjs'] ){
|
||||
$minify_enabled = $config['minifyjs'];
|
||||
|
||||
$minify_stats = [
|
||||
'date' => date('Y-m-d H:i'),
|
||||
'errors' => 'none',
|
||||
];
|
||||
foreach ($full_paths as $full_path) {
|
||||
$content = file_get_contents($full_path);
|
||||
$is_minified = substr_compare($full_path, '.min.js', -7) === 0;
|
||||
|
||||
$minify_stats['mem_before'] = memory_get_peak_usage(true);
|
||||
$minify_stats['size_before'] = strlen($combined_content);
|
||||
if (!$is_minified && $minify_enabled) {
|
||||
$original_size = strlen($content);
|
||||
$minify_stats['size_before'] += $original_size;
|
||||
|
||||
try{
|
||||
$combined_content = \JShrink\Minifier::minify(
|
||||
$combined_content,
|
||||
['flaggedComments'=>false]
|
||||
);
|
||||
}catch( Exception $e ){
|
||||
$minify_stats['errors'] = $e->getMessage();
|
||||
}
|
||||
try {
|
||||
$mem_before = memory_get_peak_usage(true);
|
||||
$minified_content = \JShrink\Minifier::minify($content, ['flaggedComments' => false]);
|
||||
$mem_after = memory_get_peak_usage(true);
|
||||
|
||||
$minify_stats['mem_after'] = memory_get_peak_usage(true);
|
||||
$minify_stats['size_after'] = strlen($combined_content);
|
||||
$minified_size = strlen($minified_content);
|
||||
$minify_stats['size_after'] += $minified_size;
|
||||
$minify_stats['allocated_memory'] += ($mem_after - $mem_before);
|
||||
|
||||
$minify_stats['compression_rate'] = (
|
||||
round(
|
||||
(1 - $minify_stats['size_after'] / $minify_stats['size_before']) * 1000) / 10
|
||||
) .
|
||||
'%';
|
||||
$content = $minified_content;
|
||||
} catch (Exception $e) {
|
||||
$minify_stats['errors'][] = $e->getMessage();
|
||||
$minify_stats['size_after'] += $original_size;
|
||||
}
|
||||
} else {
|
||||
$minify_stats['size_after'] += strlen($content);
|
||||
}
|
||||
|
||||
$minify_stats['size_before'] = \gp\admin\Tools::FormatBytes($minify_stats['size_before']);
|
||||
$minify_stats['size_after'] = \gp\admin\Tools::FormatBytes($minify_stats['size_after']);
|
||||
echo $content . ";\n";
|
||||
}
|
||||
|
||||
$minify_stats['allocated_memory'] = \gp\admin\Tools::FormatBytes(
|
||||
$minify_stats['mem_after'] - $minify_stats['mem_before']
|
||||
);
|
||||
$combined_content = ob_get_clean();
|
||||
|
||||
unset($minify_stats['mem_before'], $minify_stats['mem_after']);
|
||||
if ($minify_enabled) {
|
||||
if ($minify_stats['size_before'] > 0) {
|
||||
$compression_rate = (1 - $minify_stats['size_after'] / $minify_stats['size_before']) * 100;
|
||||
$minify_stats['compression_rate'] = round($compression_rate, 1) . '%';
|
||||
}
|
||||
|
||||
$combined_content = 'var minify_js_stats = ' . json_encode($minify_stats) . ';' . "\n\n" . $combined_content;
|
||||
}
|
||||
$minify_stats['size_before'] = \gp\admin\Tools::FormatBytes($minify_stats['size_before']);
|
||||
$minify_stats['size_after'] = \gp\admin\Tools::FormatBytes($minify_stats['size_after']);
|
||||
$minify_stats['allocated_memory'] = \gp\admin\Tools::FormatBytes($minify_stats['allocated_memory']);
|
||||
$minify_stats['errors'] = empty($minify_stats['errors']) ? 'none' : implode(', ', $minify_stats['errors']);
|
||||
|
||||
return $combined_content;
|
||||
}
|
||||
$combined_content = 'var minify_js_stats = ' . json_encode($minify_stats) . ";\n\n" . $combined_content;
|
||||
}
|
||||
|
||||
return $combined_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure the file is a css or js file and that it exists
|
||||
|
|
Loading…
Reference in a new issue