fixed tool for webkit

This commit is contained in:
Sanj 2011-05-15 21:22:03 +05:30
parent f56c713c3f
commit 98aadae1c7
2 changed files with 33 additions and 22 deletions

View File

@ -117,10 +117,13 @@ function handleRevision(json) {
}
$(document).ready(function() {
if (window.navigator.userAgent.indexOf("Firefox") == -1) {
alert("Sorry, this currently only works in Firefox.");
if ($.browser.msie) {
alert("Sorry, this does not currently work in Internet Explorer.");
window.location.href = "/";
return false;
}
if (ARTICLE_ID != 0) {
loadArticle(ARTICLE_ID);
} else {
@ -263,11 +266,11 @@ Canvas.prototype.init = function() {
if ($(ui.draggable).attr('class') == 'resource ui-draggable') {
r = edgeBin.allResources[$(ui.draggable).attr("data-index")];
if (r.mime == 'image') {
top = $(this).position().top;
left = $(this).position().left;
height = parseInt(r.height) / 2;
var top = $(this).position().top;
var left = $(this).position().left;
var height = parseInt(r.height) / 2;
// console.log("heightFOO: " + height);
width = parseInt(r.width) / 2;
var width = parseInt(r.width) / 2;
highest_index = getHighestIndex(c.jq);
new_index = parseInt(highest_index) + 1;
// console.log('index: ' + new_index);
@ -278,8 +281,8 @@ Canvas.prototype.init = function() {
} else {
var elem = $(ui.draggable);
top = $(this).position().top;
left = $(this).position().left;
var top = $(this).position().top;
var left = $(this).position().left;
if (elem.hasClass('arabic')) {
t = new TextBox(c, {'html': '<p class="textbox_canvas_text">انقر على مربع التحرير</p>', 'css': {'direction': 'rtl'}});
} else {
@ -503,6 +506,13 @@ TextBox.prototype.init = function() {
var that = this;
var e = $('<div />');
e.html(tmpl('tmpl_textbox', {'html': that.html})).attr("data-id", that.id).attr("data-index", that.index).css(that.css).addClass("box").addClass("textBox");
/* Workaround for strange webkit behaviour */
if (e.css("position") == "relative" || e.css("position") == '') {
e.css("position", "absolute");
}
// console.log(e.css("position"));
// GLOB = e.css("position");
// e.append($('<div />').addClass("boxText"));
e.draggable({
snap: '.box, .ruler',
@ -1250,8 +1260,8 @@ $(".box").live("click", function(e){
return false;
}
e.preventDefault();
top = parseInt($(this).css('top'));
left = parseInt($(this).css('left'));
var top = parseInt($(this).css('top'));
var left = parseInt($(this).css('left'));
var box = $(this).find('*').getBox().jq;
var boxObj = $(this).find('*').getBox();
if ($(".properties").length == 0) {
@ -1469,7 +1479,7 @@ $(".box").live("click", function(e){
// console.log(event.keyCode);
if (event.keyCode == '38') {
event.preventDefault();
top = box.css('top');
var top = box.css('top');
if (parseInt(top) > 1) {
boxObj.setCSS({'top': toPx(parseInt(top) - 1)});
// console.log('up?');
@ -1477,10 +1487,10 @@ $(".box").live("click", function(e){
}
if (event.keyCode == '40') {
event.preventDefault();
top = box.css('top');
height = box.outerHeight();
lower_edge = parseInt(top) + parseInt(height);
canvas_height = canvas.css('height');
var top = box.css('top');
var height = box.outerHeight();
var lower_edge = parseInt(top) + parseInt(height);
var canvas_height = canvas.css('height');
// console.log('canvas_height:' + canvas_height);
// console.log('box lower:' + lower_edge);
if (lower_edge < parseInt(canvas_height)) {
@ -1491,9 +1501,9 @@ $(".box").live("click", function(e){
}
if (event.keyCode == '39') {
event.preventDefault();
left = box.css('left');
width = box.outerWidth();
right_edge = parseInt(left) + parseInt(width);
var left = box.css('left');
var width = box.outerWidth();
var right_edge = parseInt(left) + parseInt(width);
canvas_width = canvas.css('width');
if (right_edge < parseInt(canvas_width)) {
boxObj.setCSS({'left': toPx(parseInt(left) + 1)});
@ -1533,10 +1543,10 @@ $(".box").live("click", function(e){
$(".z-index-add").bind("click", function(e){
e.preventDefault();
canvas = box.parents('.canvas');
var canvas = box.parents('.canvas');
highest_index = getHighestIndex(canvas);
// console.log(highest_index);
new_index = highest_index + 1;
var new_index = highest_index + 1;
boxObj.setCSS({'z-index': new_index});
reSortBoxes(canvas);
});
@ -1559,8 +1569,8 @@ $(".box").live("click", function(e){
$(".canvas").live("mousemove", function(e){
left = parseInt($(this).position().left) + parseInt($(this).css('margin-left'));
top = parseInt($(this).position().top) + parseInt($(this).css('margin-top'));
var left = parseInt($(this).position().left) + parseInt($(this).css('margin-left'));
var top = parseInt($(this).position().top) + parseInt($(this).css('margin-top'));
// console.log(top);
var pageCoords = "( " + (e.pageX - left) + ", " + (e.pageY - top) + " )";
$('#coordinates').html(pageCoords);

View File

@ -6,6 +6,7 @@
cursor: pointer;
font-family: sans-serif;
margin-bottom: 6px;
margin-left: 12px;
color: #393939;
}