merged arabic textbox code

This commit is contained in:
sanj 2010-03-15 01:29:35 +05:30
parent 94c1f5c2dd
commit e78fda7297
7 changed files with 143 additions and 63 deletions

View File

@ -1,6 +1,15 @@
from files.models import File, Category, Type
from django.contrib import admin
from django.contrib.auth.models import User
from django_firefogg.forms import FirefoggInput
from django import forms
class filesForm(forms.ModelForm):
file = forms.FileField(label='Upload File',
required=False,
widget=FirefoggInput({'passthrough': True}))
class Meta:
model = File
class FilesAdmin(admin.ModelAdmin):
list_display = ('title', 'type', 'file_date')
@ -8,6 +17,7 @@ class FilesAdmin(admin.ModelAdmin):
ordering = ('-file_date',)
search_fields = ('title', 'description')
exclude = ('userID',)
form = filesForm
def save_model(self, request, obj, form, change):
if not change:

View File

@ -101,7 +101,7 @@ INSTALLED_APPS = (
# 'south',
'django.contrib.comments',
'sorl.thumbnail',
'firefogg',
'django_firefogg',
)
#overwrite default settings with local settings

View File

@ -1,5 +1,5 @@
#ajaxBusy {
position: absolute;
position: fixed;
top: 10px;
right: 10px;
width: 6px;
@ -24,6 +24,21 @@
margin-bottom:80px;
}
.newTextBox {
background-color:grey;
padding-top:10px;
border-style:solid;
border-width:1px;
height:13px;
width:140px;
font-size: 11px;
cursor: move;
}
.arabic {
direction: rtl;
}
.ruler_horiz {
position: relative;
top: 50%;
@ -117,13 +132,25 @@
width: 16px;
}
.navControls {
background-color:lightgrey;
padding-top:10px;
padding-bottom:10px;
padding-left:10px;
padding-right:10px;
border-bottom-style:solid;
border-bottom-width:1px;
font-size:13px;
margin-left: -10px;
}
#bin {
border-style:solid;
border-width:1px;
position: absolute;
left: 900px;
left: 850px;
top: 20px;
width: 250px;
width: 300px;
height: 90%;
position:fixed;
@ -136,9 +163,11 @@
position: absolute;
}
#searchCat {
background-color:lightgrey;
padding-left:30px;
margin-left: auto;
margin-right: auto;
padding-top:10px;
height:30px;
}
@ -251,16 +280,6 @@ margin-top:0px;
font-size:13px;
}
.navControls {
background-color:lightgrey;
padding-top:10px;
padding-bottom:10px;
padding-left:10px;
padding-right:10px;
border-bottom-style:solid;
border-bottom-width:1px;
font-size:13px;
}
.searchBin {
margin-top:5px;

View File

@ -0,0 +1,25 @@
@font-face {
font-family: GraublauWeb;
src: url(/static/fonts/GraublauWeb.otf) format("opentype");
}
@font-face {
font-family: Tallys;
src: url(/static/fonts/Tallys_15.otf) format("opentype");
}
@font-face {
font-family: Fontin;
src: url(/static/fonts/Fontin-Regular.otf) format("opentype");
}
@font-face {
font-family: Tagesschrift;
src: url(/static/fonts/YanoneTagesschrift.ttf) format("truetype");
}
body {
font-size: 14px;
}

View File

@ -93,7 +93,7 @@ function handleRevision(json) {
default:
var box = canvas.getBox(json);
if (json.prop == 'html') {
box.jq.html(json.new_val);
box.jq.find('.textbox_canvas_content').html(json.new_val);
} else {
var d = {};
var noPxArr = ['opacity', 'z-index', 'background', 'border-color', 'border-style'];
@ -132,7 +132,7 @@ $(document).ready(function() {
});
*/
$('.newTextBox').tooltip();
$('#newPage').click(function(e) {
e.preventDefault();
@ -249,7 +249,7 @@ Canvas.prototype.init = function() {
containment: 'parent',
axis: 'y'
});
this.jq.droppable({accept:'.resource, #newTextBox',
this.jq.droppable({accept:'.resource, .newTextBox',
drop: function(ev, ui) {
var box = $(this).getBox().jq;
c = edgeArticle[$(this).attr('data-index')];
@ -288,13 +288,17 @@ Canvas.prototype.init = function() {
}
}
else {
var elem = $(ui.draggable);
top = $(this).position().top;
left = $(this).position().left;
t = new TextBox(c);
width = parseInt(t.jq.css('width')) / 2;
height = parseInt(t.jq.css('height')) / 2;
if (elem.hasClass('arabic')) {
t = new TextBox(c, {'html': '<p class="textbox_canvas_text">انقر على مربع التحرير</p>', 'css': {'direction': 'rtl'}});
} else {
t = new TextBox(c);
}
width = parseInt(t.jq.css('width') / 2);
height = parseInt(t.jq.css('height') / 2);
t.setCSS({'top':toPx((ev.pageY - top) - height), 'left': toPx((ev.pageX - left) - width)});
highest_index = getHighestIndex(c.jq);
new_index = parseInt(highest_index) + 1;
@ -431,6 +435,7 @@ TextBox.prototype.create = function(json) {
'html': '<p class="textbox_canvas_text">Click to edit textbox</p>',
'resource_id': 0,
'css': {
'direction': 'ltr',
'height': '300px',
'width': '300px',
'background-color': '#ffffff',
@ -561,6 +566,12 @@ Call this from the outside to update CSS both client and server-side. css can be
*/
TextBox.prototype.setCSS = function(css, callServer) {
/* for (var c in css) {
if (css.hasOwnProperty(c)) {
this.css[c] = css[c];
}
}
*/
this.jq.css(css);
var srv = callServer == undefined ? true : callServer;
if (srv) {
@ -963,7 +974,7 @@ var Resource = function(json, index) {
Resource.prototype.addToBin = function() {
var that = this;
var e = this.getBinElem();
edgeBin.jq.append(e);
edgeBin.jq.find('.binResources').append(e);
this.jq = $('#' + that.divid);
this.addEventHandlers();
};
@ -1090,7 +1101,7 @@ window.onload = function()
};
*/
$(document).ready(function(){
$("#newTextBox").draggable({ revert: true, helper: 'clone'});
$(".newTextBox").draggable({ revert: true, helper: 'clone'});
});
/*
@ -1230,6 +1241,10 @@ $(".box").live("click", function(e){
$(".properties").css('left', toPx((e.pageX)));
} else {
$(".properties").remove();
//BAD HACK: removes the nudge binder if present. Got to be a better way to do this -- potentially bind to document using a custom nudge event, but not sure.
$(document).unbind("keydown");
//This should click itself, to then display properties wherever it is clicked, but it does not work:(
// $(this).trigger("click");
}
// i.setCSS({'top':toPx((ev.pageY - top) - height), 'left': toPx((ev.pageX - left) - width)});
@ -1364,20 +1379,20 @@ $(".box").live("click", function(e){
$(".crop_imagebox").bind("click", function(e){
e.preventDefault();
text_edit_mode = true;
box.resizable( 'disable' );
box.resizable( 'disable' );
$(canvas).append(tmpl('tmpl_imagebox_crop', {}));
canvas_top = parseInt(canvas.offset().top);
canvas_left = parseInt(canvas.offset().left);
canvas_top = parseInt(canvas.offset().top);
canvas_left = parseInt(canvas.offset().left);
box_top = box.css('top');
box_left = box.css('left');
crop_box_top = parseInt(box_top) + parseInt(box.css('height')) + 5;
crop_box_left = parseInt(box_left);
$(".imagebox_crop").css('top', crop_box_top);
$(".imagebox_crop").css('left', crop_box_left);
$(".imagebox_crop").css('top', crop_box_top);
$(".imagebox_crop").css('left', crop_box_left);
image = box.find('.edgeImage');
this_imagebox_id = box.attr('data-id');
@ -1386,7 +1401,7 @@ $(".box").live("click", function(e){
});
$('.properties').remove();
$(".do_crop_imagebox").bind("click", function(e){
$(".do_crop_imagebox").bind("click", function(e){
e.preventDefault();
box.resizable( 'enable' );
@ -1411,22 +1426,21 @@ $(".box").live("click", function(e){
});
$(".cancel_crop_imagebox").bind("click", function(e){
jcrop.destroy();
$('.imagebox_crop').remove();
box.resizable( 'enable' );
jcrop.destroy();
$('.imagebox_crop').remove();
box.resizable( 'enable' );
text_edit_mode = false;
text_edit_mode = false;
});
});
$(".nudge_box").bind("click", function(e){
e.preventDefault();
$(document).keydown( function (event) {
$(document).bind("keydown", function(event) {
// console.log(event.keyCode);
if (event.keyCode == '38') {
event.preventDefault();
event.preventDefault();
top = box.css('top');
if (parseInt(top) > 1) {
boxObj.setCSS({'top': toPx(parseInt(top) - 1)});
@ -1434,40 +1448,40 @@ $(".box").live("click", function(e){
}
}
if (event.keyCode == '40') {
event.preventDefault();
event.preventDefault();
top = box.css('top');
height = box.outerHeight();
lower_edge = parseInt(top) + parseInt(height);
canvas_height = canvas.css('height');
console.log('canvas_height:' + canvas_height);
console.log('box lower:' + lower_edge);
height = box.outerHeight();
lower_edge = parseInt(top) + parseInt(height);
canvas_height = canvas.css('height');
console.log('canvas_height:' + canvas_height);
console.log('box lower:' + lower_edge);
if (lower_edge < parseInt(canvas_height)) {
boxObj.setCSS({'top': toPx(parseInt(top) + 1)});
// console.log('down?');
}
}
}
if (event.keyCode == '39') {
event.preventDefault();
event.preventDefault();
left = box.css('left');
width = box.outerWidth();
right_edge = parseInt(left) + parseInt(width);
canvas_width = canvas.css('width');
width = box.outerWidth();
right_edge = parseInt(left) + parseInt(width);
canvas_width = canvas.css('width');
if (right_edge < parseInt(canvas_width)) {
boxObj.setCSS({'left': toPx(parseInt(left) + 1)});
}
}
}
}
if (event.keyCode == '37') {
event.preventDefault();
event.preventDefault();
left = box.css('left');
if (parseInt(left) > 0) {
boxObj.setCSS({'left': toPx(parseInt(left) - 1)});
}
}
}
}
});
});
});
$(".edit_textbox").bind("click", function(e){
e.preventDefault();
@ -1477,9 +1491,14 @@ $(".box").live("click", function(e){
box.css('z-index', '1000');
element = box.find('.textbox_canvas_content');
replaceDiv( element[0] );
box = $(element).getBox().jq;
box.draggable( 'disable' );
box.resizable( 'disable' );
boxObj = $(element).getBox();
// console.log(boxObj);
box = boxObj.jq;
if (box.css("direction") == 'rtl') {
setTimeout(function() { $($('iframe').get(0).contentDocument).find('html').attr("dir", "rtl") }, 500);
}
box.draggable('disable');
box.resizable('disable');
text_edit_mode = true;
$(element).parent().siblings('.save_text').show();
});

View File

@ -4,6 +4,7 @@
<link rel="stylesheet" href="/static/css/ui-lightness/jquery-ui-1.7.2.custom.css" />
<link rel="stylesheet" href="/static/css/farbtastic.css" />
<link rel="stylesheet" href="/static/css/editor.css" />
<link rel="stylesheet" href="/static/css/fonts.css" />
<link rel="stylesheet" href="/static/css/jquery.tooltip.css" />
<link rel="stylesheet" href="/static/colorpicker/css/colorpicker.css" type="text/css" />
<link rel="stylesheet" media="screen" type="text/css" href="/static/colorpicker/css/layout.css" />
@ -190,16 +191,21 @@
</select>
</div>
<div id="addElements">
<div id='newTextBox' style='background-color:grey;padding-top:10px;padding-left:5px;border-style:solid;border-width:1px;height:30px;width:120px;'>
<a href="#">+ TEXTBOX</a>
<div class='newTextBox english' title="Drag to page to add an english textbox">
+ TEXTBOX
</div>
</div>
<div class="newTextBox arabic" title="Drag to page to add an arabic textbox">
إضافة مربع
</div>
<div class="navControls">
Displaying <span class="start_index">0</span> to <span class="end_index">0</span> of <span class="totalResources">0</span> resources<br />
<a href="#" onclick='return false;' class="prevPage"><< Prev</a>
<a href="#" onclick='return false;' class="nextPage">Next >></a>
<br>
<input class="searchBin" />
</div>
<div class="binResources">
</div>
</div>

View File

@ -2,6 +2,7 @@
-e bzr+http://code.0xdb.org/python-oxdjango/#egg=python-oxdjango
-e svn+http://django-tagging.googlecode.com/svn/trunk/#egg=tagging
-e bzr+http://firefogg.org/dev/python-firefogg/#egg=python-firefogg
-e bzr+http://firefogg.org/dev/django_firefogg/#egg=django_firefogg
django_extensions
django-debug-toolbar
sorl-thumbnail