Browse Source

Add minify file, may have to uglify it now, improved touch, ask for biggest texture size

Felix Schultze 9 years ago
parent
commit
bfca844f62

+ 15 - 1
Gruntfile.js

@@ -59,14 +59,28 @@ module.exports = function(grunt) {
                     interrupt: true
                 }
             }
+        },
+
+
+        uglify: {
+            options: {
+                // the banner is inserted at the top of the output
+                banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
+            },
+            dist: {
+                files: {
+                    'static/js/threeJsHelper/dist/<%= pkg.jsname %>.min.js': ['<%= concat.dist.dest %>']
+                }
+            }
         }
     });
 
     grunt.loadNpmTasks('grunt-contrib-concat');
     grunt.loadNpmTasks('grunt-contrib-watch');
     grunt.loadNpmTasks('grunt-shell');
+    grunt.loadNpmTasks('grunt-contrib-uglify');
 
-    grunt.registerTask('default', ['concat']);
+    grunt.registerTask('default', ['concat', 'uglify']);
     grunt.registerTask('dev-watch', ['concat:dist']);
     grunt.registerTask('update-version', ['shell:bumbVersion']);
     grunt.registerTask('deploy', ['concat', 'shell:pkg', 'shell:scp', 'shell:rmPkg', 'shell:deploy']);

+ 1 - 0
package.json

@@ -13,6 +13,7 @@
   "devDependencies": {
     "grunt": "~0.4",
     "grunt-contrib-concat": "~0.3.0",
+    "grunt-contrib-uglify": "^0.8.0",
     "grunt-contrib-watch": "~0.6.1",
     "grunt-shell": "^1.1.1"
   }

File diff suppressed because it is too large
+ 1 - 2590
static/js/threeJsHelper/dist/threeJsHelper.js


+ 25 - 13
static/js/threeJsHelper/src/Application.js

@@ -27,14 +27,6 @@ IPE.app = {
         IPE.app.bindEvents();
         IPE.app.initData();
 
-        $resSpan.text(config.defaultSize);
-        textureSizes = config.textureSizes;
-        textureSizes.forEach(function(size) {
-            href = size == config.defaultSize ? '' : 'href="#"';
-
-            $resLinkHolder.append('<a '+href+' class="res-link" data="'+size+'">'+size+'</a>  ');
-        });
-
         // Getting info file
         $.ajax({
             url: infoUrl + config.defaultSize,
@@ -98,7 +90,6 @@ IPE.app = {
         volumeId = $('#volumeId').val();
 
         $resSpan = $('span#currentRes');
-        $resLinkHolder = $('#resolution-link-holder');
 
         volumeUrl = homeUrl + 'volumes/' + volumeId + '/';
         infoUrl = volumeUrl + 'texture-info/';
@@ -141,6 +132,8 @@ IPE.app = {
         $(document).on('firstFrameSpritesCompleted', function() {
             init();
 
+            addResolutionLinks();
+
             overviewHelper.initOverview(containerOverview);
 
             animate();
@@ -173,8 +166,7 @@ IPE.app = {
             renderer.domElement.style.height = rendererSizeHolder.height.percent + '%';
         });
 
-
-        $('#resolution-link-holder').on('click', 'a', function(e) {
+        $resolutionLinks.on('click', 'a', function(e) {
             e.preventDefault();
             e.stopPropagation();
 
@@ -203,6 +195,10 @@ IPE.app = {
                     useDownloadedTextureImmediately = true;
                     helper.downloadImage(spriteUrl + textureInfo.sprites[0][0].$oid, 0, 0, false);
                     $resSpan.text(requestedSize);
+
+                    if($('input#hide-content-small-devices').is(':visible')) {
+                        $('input#hide-content-small-devices').trigger('click');
+                    }
                 },
                 dataType: 'json'
             });
@@ -253,8 +249,7 @@ IPE.app = {
 
 
         $('input#hide-content-small-devices').on('click', function() {
-            var $this = $(this)
-            $overlay = $('div#overlay-small-devices'),
+            var $overlay = $('div#overlay-small-devices'),
                 $content = $('div#content-small-devices'),
                 source = $overlay.attr('source'),
                 $source = $('#' + source);
@@ -551,6 +546,9 @@ function init() {
     renderer.setClearColor(0xffffff, 1);
     container.appendChild(renderer.domElement);
 
+    maximumTextureSize = renderer.context.getParameter(renderer.context.MAX_TEXTURE_SIZE);
+    // we have to take an power of 2 less
+    maximumTextureSize /= 2;
 
     $canvas = $('canvas', $container);
 
@@ -897,3 +895,17 @@ function hideBottomControlsContainer() {
 
     return filledById;
 }
+
+function addResolutionLinks() {
+    $resSpan.text(config.defaultSize);
+    textureSizes = config.textureSizes;
+    textureSizes.forEach(function(size) {
+        if(size > maximumTextureSize) {
+            return;
+        }
+
+        href = size == config.defaultSize ? '' : 'href="#"';
+
+        $resolutionLinks.append('<a '+href+' class="res-link" data="'+size+'">'+size+'</a>  ');
+    });
+}

+ 3 - 1
static/js/threeJsHelper/src/Globals.js

@@ -1,8 +1,9 @@
 var volumeId;
 var stats, container, $container, containerHeader, $containerHeader, $canvas, cameraRTT, camera, sceneRTT, scene, renderer, controls, controls2;
+var maximumTextureSize;
 var containerOverview, $containerOverview;
 var $resSpan;
-var $resLinkHolder;
+var $resolutionLinks;
 var raycaster;
 var width, height;
 var steps, adjustSteps;
@@ -69,6 +70,7 @@ var Globals = (function() {
             originalVolumeDimension = new VolumeDimension();
             zoomedVolumeDimension = new VolumeDimension();
             currentVolumeDimension = originalVolumeDimension;
+            $resolutionLinks = $('#resolution-links');
         }
     }
 }());

+ 4 - 2
templates/volumes/render.html

@@ -14,7 +14,7 @@
             "{% static 'js/lib/helvetiker_regular.typeface.js' %}?{{ VERSION }}",
             "{% static 'js/lib/kinetic-v5.0.2.min.js' %}?{{ VERSION }}",
             "{% static 'js/generic-slider.js' %}?{{ VERSION }}",
-            "{% static 'js/threeJsHelper/dist/threeJsHelper.js' %}?{{ VERSION }}"
+            "{% static 'js/threeJsHelper/dist/threeJsHelper.min.js' %}?{{ VERSION }}"
         ];
         IPE.additionalCssFiles = [
             "{% static 'css/application.css' %}?{{ VERSION }}"
@@ -24,7 +24,9 @@
         };
     </script>
 {% endblock %}
+
 {% block content-class %}complete-width complete-height{% endblock %}
+
 {% block content %}
     <input type="hidden" id="volumeId" value="{{ volume.id }}"/>
     <div id="wait" class="hidden">&nbsp;</div>
@@ -174,7 +176,7 @@
             </div>
             <div id="volume-information" class="float-left">
                 volume name: <span class="bold">{{ volume.name }}</span> current texture res: <span class="bold" id="currentRes"></span> px<br />
-                <div id="resolution-link-holder"></div>
+                <div id="resolution-link-holder"><div id="resolution-links"></div></div>
                 <div id="zoom-status">zoomed out</div>
                 <div id="progress">
                     <div id="progress-container" class="hidden">

Some files were not shown because too many files changed in this diff