审查视图

public/assets/libs/jcrop/demos/panel.html 16.2 KB
王智 authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Feature Panel | Jcrop Demos</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="../js/Jcrop.js"></script>
    <script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script src="http://jcrop-dev.tapmodo.com/Jcrop/js/jquery.color.js"></script>
    <script type="text/javascript">
      var cb, filter;
      
      jQuery(function($){
      
        var $targ = $('#target');
        var $easing = $('#easing');
        
        $('#target').Jcrop({
          animEasing: 'easeOutQuart',
          bgOpacity: .35,
          linked: false,
          multi: true
        },function(){
          this.container.addClass('jcrop-dark jcrop-hl-active');
          interface_load(this);
        });
        
        function interface_load(obj){
          cb = obj;
          
          cb.newSelection();
          cb.setSelect([ 147, 55, 456, 390 ]);
          cb.refresh();
          // Hack a "special" selection...
          var logosel = cb.newSelection().update($.Jcrop.wrapFromXywh([73,268,400,100]));
          
          $.extend(logosel,{
            special: true, // custom value used in our local script here
            bgColor: '#999',
            bgOpacity: 0.8,
            canResize: false,
            canDelete: false
          });
          
          logosel.element.prepend('<img src="http://tapmodo.com/img/tapmodo-official.png" style="position:absolute;background-color:white;width:100%;height:100%;" />');
          logosel.aspectRatio = 400/100;
          logosel.refresh();
          cb.ui.multi[1].focus();
          
          // Select an interesting easing function
          $easing[0].selectedIndex = 24;
          
          // Set up the easing function select element event
          cb.opt.animEasing = $easing.change(function(e){
            var $targ = $(e.target);
            cb.opt.animEasing = $targ.val();
            e.preventDefault();
            cb.ui.selection.animateTo([Math.random()*300,Math.random()*200,(Math.random()*540)+50,(Math.random()*340)+60]);
          }).val();
          
          $('#filter-selections input').attr('checked',false);
          $('#page-interface').on('startselect',function(e){
            e.preventDefault();
          });
          
          /**
           *  
           */
          cb.container.on('cropfocus cropblur cropstart cropend',function(e){
            var sel = $(e.target).data('selection');
            switch(e.type){
              case 'cropfocus':
                $('#can_size')[0].checked = sel.canResize?true:false;
                $('#can_delete')[0].checked = sel.canDelete?true:false;
                $('#can_drag')[0].checked = sel.canDrag?true:false;
                $('#set_minsize')[0].checked = (sel.minSize[0]>8)?true:false;
                $('#set_maxsize')[0].checked = (sel.maxSize[0])?true:false;
                $('#set_bounds')[0].checked = (sel.edge.n)?true:false;
                $('#is_linked')[0].disabled = sel.special?true:false;
                $('#is_linked')[0].checked = sel.linked?true:false;
                $('#shading-tools a')[0].disabled = sel.special?true:false;
                $('#shading-tools a')[sel.special?'addClass':'removeClass']('disabled');
                
                $('#ar-links').find('.active').removeClass('active');
                if (sel.aspectRatio) {
                  if (!$('#ar-links').find('[data-value="'+sel.aspectRatio+'"]').addClass('active').length)
                    $('#ar-lock').addClass('active');
                } else $('#ar-free').addClass('active');
            }
          });
          
          $('#aspect_ratio').on('change',function(e){
            var s = cb.ui.selection;
            var b = s.get();
            s.aspectRatio = e.target.checked? b.w/b.h : 0;
            s.refresh();
          });
          $('#is_linked').on('change',function(e){
            cb.ui.selection.linked = e.target.checked;
          });
          
          $('#selection-options').on('change','[data-filter-toggle]',function(e){
            var tog = $(e.target).data('filter-toggle');
            var o = { };
            o[tog] = e.target.checked? true: false;
            cb.setOptions(o);
          });
          
          var cycle_colors = [
            'red',
            'blue',
            'gray',
            'yellow',
            'orange',
            'green',
            'white'
          ];
          
          function random_coords() {
            return [
              Math.random()*300,
              Math.random()*200,
              (Math.random()*540)+50,
              (Math.random()*340)+60
            ];
          }
          
          $('#can_drag,#can_size,#can_delete,#enablesel,#multisel,#anim_mode').attr('checked','checked');
          $('#is_linked,#aspect_ratio').attr('checked',false);
          
          function anim_mode(){
            return document.getElementById('anim_mode').checked;
          }
          
          // A simple function to cleanup multiple spawned selections
          function run_cleanup(){
            var m = cb.ui.multi, s = cb.ui.selection;
            
            for(var i=0;i<m.length;i++)
              if (s !== m[i]) m[i].remove();
              
            cb.ui.multi = [ s ];
            s.center();
            s.focus();
          }
          
          // Animate button event
          $(document.body).on('click','[data-action]',function(e){
            var $targ = $(e.target);
            var action = $targ.data('action');
            
            switch(action){
              case 'set-maxsize':
                cb.setOptions({ maxSize: e.target.checked? [400,350]: [0,0] });
                break;
              case 'set-minsize':
                cb.setOptions({ minSize: e.target.checked? [60,60]: [8,8] });
                break;
              case 'set-bounds':
                if (e.target.checked){
                  cb.setOptions({ edge: {
                    n: 15,
                    e: -20,
                    s: -40,
                    w: 28
                  }});
                }
                else {
                  cb.setOptions({ edge: {
                    n: 0,
                    e: 0,
                    s: 0,
                    w: 0
                  }});
                }
                break;
              case 'set-image':
                $targ.parent().find('.active').removeClass('active');
                $targ.addClass('active');
                $('#target').attr('src','//jcrop-cdn.tapmodo.com/assets/images/'+$targ.data('image')+'-750.jpg');
                break;
              case 'set-ar':
                var value = $targ.data('value');
                $targ.parent().find('.active').removeClass('active');
                if (value == 'lock'){
                  var b = cb.ui.selection.get();
                  value = b.w / b.h;
                }
                $targ.addClass('active');
                cb.setOptions({ aspectRatio: value });
                break;
              case 'set-selmode':
                $targ.parent().find('.active').removeClass('active');
                $targ.addClass('active');
                switch($targ.data('mode')){
                  case 'none':
                    cb.container.addClass('jcrop-nodrag');
                    cb.setOptions({ allowSelect: false });
                    break;
                  case 'single':
                    cb.container.removeClass('jcrop-nodrag');
                    cb.setOptions({ allowSelect: true, multi: false });
                    break;
                  case 'multi':
                    cb.container.removeClass('jcrop-nodrag');
                    cb.setOptions({ allowSelect: true, multi: true });
                    break;
                }
                break;
              case 'enable-selections':
                cb.ui.stage.dragger.active = e.target.checked;
                break;
              case 'enable-multi':
                cb.ui.stage.dragger.multi = e.target.checked;
                break;
              case 'color-cycle':
                var cc = cycle_colors.shift();
                cb.setOptions({ bgColor: cc });
                cycle_colors.push(cc);
                break;
              case 'set-opacity':
                $targ.parent().find('.active').removeClass('active');
                $targ.addClass('active');
                cb.setOptions({ bgOpacity: $targ.data('opacity'), bgColor: 'black' });
                break;
              case 'cleanup-all':
                run_cleanup();
                break;
              case 'random-move':
                cb[anim_mode()?'animateTo':'setSelect'](random_coords());
                break;
            }
            
          }).on('keydown',function(e){
            if (e.keyCode == 8) e.preventDefault();
          }).on('selectstart',function(e){
            e.preventDefault();
          }).on('click','a[data-action]',function(e){
            e.preventDefault();
          });
        }
        
      });
      
    </script>
    <link rel="stylesheet" href="demo_files/main.css">
    <link rel="stylesheet" href="demo_files/demos.css">
    <link rel="stylesheet" href="../css/Jcrop.css">
  </head>
  <body>
    <div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <button type="button" data-toggle="collapse" data-target="nav-collapse" class="btn btn-navbar"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a href="../" class="brand">Jcrop</a>
          <div class="nav-collapse collapse">
            <ul class="nav">
              <li class="active"><a href="./basic.html">Demos</a>
              </li>
              <li><a href="http://beta.jcrop.org/doc/">Docs</a>
              </li>
              <li><a href="http://beta.jcrop.org/contact/">Contact</a>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
    <div class="container">
      <div class="row">
        <div class="span12">
          <div class="jc-demo-box">
            <div class="page-header">
              <h1>Feature Panel</h1>
            </div>
            <div class="demo-nav menu-box">
              <h3>Jcrop Demos</h3>
              <ul class="links">
                <li><a href="basic.html">Hello World</a></li>
                <li><a href="thumbnail.html">Thumbnail Preview</a></li>
                <li><b>Feature Panel</b></li>
                <li><a href="coords.html">Dimensions</a></li>
                <li><a href="circle.html">Circles</a></li>
              </ul>
            </div>
            <div class="page-interface"><img src="http://jcrop-cdn.tapmodo.com/assets/images/sierra2-750.jpg" id="target">
              <div class="row-fluid">
                <div class="span4">
                  <h5>Selection Properties</h5>
                  <div id="selection-options">
                    <label class="checkbox">
                      <input type="checkbox" data-filter-toggle="canDrag" id="can_drag">Draggable
                    </label>
                    <label class="checkbox">
                      <input type="checkbox" data-filter-toggle="canResize" id="can_size">Resizable
                    </label>
                    <label class="checkbox">
                      <input type="checkbox" data-filter-toggle="canDelete" id="can_delete">Deletable
                    </label>
                  </div>
                  <label class="checkbox">
                    <input type="checkbox" data-action="set-bounds" id="set_bounds">Enable boundary
                  </label>
                  <label class="checkbox">
                    <input type="checkbox" data-action="set-minsize" id="set_minsize">Minimum Size
                  </label>
                  <label class="checkbox">
                    <input type="checkbox" data-action="set-maxsize" id="set_maxsize">Maximum Size
                  </label>
                </div>
                <div class="span4">
                  <h5>Aspect Ratio</h5>
                  <div class="btn-toolbar"><span id="ar-links" class="btn-group"><a href="#" data-action="set-ar" data-value="0" id="ar-free" class="btn active btn-small">Free</a><a href="#" data-action="set-ar" data-value="lock" id="ar-lock" class="btn btn-small">Lock</a><a href="#" data-action="set-ar" data-value="1.4" class="btn btn-small">Wide</a><a href="#" data-action="set-ar" data-value=".8" class="btn btn-small">Tall</a></span></div>
                  <h5>Shading</h5>
                  <div id="shading-tools" class="btn-toolbar"><a href="#" data-action="color-cycle" class="btn btn-small">Color</a><span class="btn-group"><a href="#" data-action="set-opacity" data-opacity=".35" class="btn active btn-small">Light</a><a href="#" data-action="set-opacity" data-opacity=".55" class="btn btn-small">Medium</a><a href="#" data-action="set-opacity" data-opacity=".75" class="btn btn-small">Dark</a></span></div>
                  <h5>Animation</h5>
                  <label class="checkbox">
                    <input type="checkbox" id="anim_mode">Enable Animation
                  </label>
                  <select data-action="update-easing" id="easing" class="select">
                    <option>linear</option>
                    <option>swing</option>
                    <option>easeInOutQuad</option>
                    <option>easeInQuad</option>
                    <option>easeOutQuad</option>
                    <option>easeInOutExpo</option>
                    <option>easeInExpo</option>
                    <option>easeOutExpo</option>
                    <option>easeInOutSine</option>
                    <option>easeInSine</option>
                    <option>easeOutSine</option>
                    <option>easeOutBounce</option>
                    <option>easeInOutCirc</option>
                    <option>easeInCirc</option>
                    <option>easeOutCirc</option>
                    <option>easeInOutCubic</option>
                    <option>easeInCubic</option>
                    <option>easeOutCubic</option>
                    <option>easeOutElastic</option>
                    <option>easeInOutBack</option>
                    <option>easeInBack</option>
                    <option>easeOutBack</option>
                    <option>easeInOutQuart</option>
                    <option>easeInQuart</option>
                    <option>easeOutQuart</option>
                    <option>easeInOutQuint</option>
                    <option>easeInQuint</option>
                    <option>easeOutQuint</option>
                  </select>
                </div>
                <div class="span4">
                  <h5>Current Selection</h5>
                  <label class="checkbox">
                    <input type="checkbox" data-filter-toggle="ratio" id="is_linked">Linked Selection
                  </label>
                  <div class="btn-toolbar"><a href="#" data-action="random-move" id="moveselection" class="btn btn-small">Move</a><a href="#" data-action="cleanup-all" class="btn btn-small">Cleanup</a></div>
                  <h5>New Selections</h5>
                  <div class="btn-toolbar"><span class="btn-group"><a href="#" data-action="set-selmode" data-mode="none" class="btn btn-small">None</a><a href="#" data-action="set-selmode" data-mode="single" class="btn btn-small">Single</a><a href="#" data-action="set-selmode" data-mode="multi" class="btn active btn-small">Multi</a></span></div>
                  <h5>Test Image</h5>
                  <div class="btn-toolbar"><span class="btn-group"><a href="#" data-action="set-image" data-image="sierra" class="btn btn-small">Sierra1</a><a href="#" data-action="set-image" data-image="sierra2" class="btn active btn-small">Sierra2</a><a href="#" data-action="set-image" data-image="market" class="btn btn-small">Market</a></span></div>
                </div>
              </div>
            </div>
            <div class="tapmodo-footer"><a href="http://tapmodo.com" class="tapmodo-logo segment">tapmodo.com</a>
              <div class="segment"><b>&copy; 2008-2013 Tapmodo Interactive LLC</b>
                <div>Jcrop is free software released under <a href="../MIT-LICENSE.txt">MIT License</a></div>
              </div>
            </div>
            <div class="clearfix"></div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>