imgselectarea模态窗口删除选择

时间:2015-02-04 08:31:34

标签: javascript css twitter-bootstrap imageareaselect

我的imgAreaSelect插件有点问题。 这是我做的例子。 http://jsfiddle.net/H4hEx/19/

但是当你关闭模态窗口并再次点击模态窗口按钮时,选择区域没有删除。那么关闭模态窗口时如何破坏选择呢? (即使你没有点击按钮"关闭"或者"保存更改") 我想我需要编写一个会破坏x1,x2,y1,y2的代码。是不是?

我尝试做的另一件事是限制选择区域。如何限制选择区域,以便用户无法选择图像右侧的白框?



$(document).ready(function () {

    $('#thumbnail').imgAreaSelect({ aspectRatio: '1:1', handles: 'True', parent: '#parent',

onSelectEnd: function (img, selection) {
            $('input[name="x1"]').val(selection.x1);
            $('input[name="y1"]').val(selection.y1);
            $('input[name="x2"]').val(selection.x2);
            $('input[name="y2"]').val(selection.y2);       
//alert(selection.x1 + ',' + selection.y1 + ',' + selection.x2 + ',' + selection.y2);			
        
    }

});
});
var c = 0; // current image (array key index)

function loadImage(){
    $("<img/>").attr({src:image[c], id:"image", class:"img-thumbnail", style:"width:80%;"}).load(function() {
      $('#thumbnail').html( this );
  }); 
}
loadImage(); // load 1 image
&#13;
/*
 * imgAreaSelect default style
 */

.imgareaselect-border1 {
	background: url(border-v.gif) repeat-y left top;
}

.imgareaselect-border2 {
    background: url(border-h.gif) repeat-x left top;
}

.imgareaselect-border3 {
    background: url(border-v.gif) repeat-y right top;
}

.imgareaselect-border4 {
    background: url(border-h.gif) repeat-x left bottom;
}

.imgareaselect-border1, .imgareaselect-border2,
.imgareaselect-border3, .imgareaselect-border4 {
    filter: alpha(opacity=50);
	opacity: 0.5;
}

.imgareaselect-handle {
    background-color: #fff;
    border: solid 1px #000;
    filter: alpha(opacity=50);
    opacity: 0.5;
}

.imgareaselect-outer {
    background-color: #000;
    filter: alpha(opacity=50);
    opacity: 0.5;
}

.imgareaselect-selection {  
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://krept.com/knoted/js/jquery.imgareaselect.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<!-- Button trigger modal -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal-1">
  Modal-1
</button>


<!-- Modal-1 -->
<div class="modal fade" id="myModal-1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
          <div id="parent" style="position:relative;"><span id="thumbnail" style="display: inline-block;"><img id="image" style="width:80%;" src="http://upload.wikimedia.org/wikipedia/en/f/fa/416_into_Ottawa.png" /></span></div>
          
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
&#13;
&#13;
&#13;

0 个答案:

没有答案