merge
authorSandrine Ribeau <sandrine.ribeau@logilab.fr>
Thu, 16 Jul 2009 12:57:17 -0700
changeset 2541 09615ea7533e
parent 2540 fba943784b1c (current diff)
parent 2387 ea1defea9636 (diff)
child 2542 d72115de4043
merge
--- a/web/data/cubicweb.htmlhelpers.js	Thu Jul 16 12:54:46 2009 -0700
+++ b/web/data/cubicweb.htmlhelpers.js	Thu Jul 16 12:57:17 2009 -0700
@@ -16,78 +16,6 @@
     return '';
 }
 
-// XXX this is used exactly ONCE in web/views/massmailing.py
-function insertText(text, areaId) {
-    var textarea = jQuery('#' + areaId);
-    if (document.selection) { // IE
-        var selLength;
-        textarea.focus();
-        sel = document.selection.createRange();
-        selLength = sel.text.length;
-        sel.text = text;
-        sel.moveStart('character', selLength-text.length);
-        sel.select();
-    } else if (textarea.selectionStart || textarea.selectionStart == '0') { // mozilla
-        var startPos = textarea.selectionStart;
-        var endPos = textarea.selectionEnd;
-	// insert text so that it replaces the [startPos, endPos] part
-        textarea.value = textarea.value.substring(0,startPos) + text + textarea.value.substring(endPos,textarea.value.length);
-	// set cursor pos at the end of the inserted text
-        textarea.selectionStart = textarea.selectionEnd = startPos+text.length;
-        textarea.focus();
-    } else { // safety belt for other browsers
-        textarea.value += text;
-    }
-}
-
-/* taken from dojo toolkit */
-// XXX this looks unused
-function setCaretPos(element, start, end){
-    if(!end){ end = element.value.length; }  // NOTE: Strange - should be able to put caret at start of text?
-    // Mozilla
-    // parts borrowed from http://www.faqts.com/knowledge_base/view.phtml/aid/13562/fid/130
-    if(element.setSelectionRange){
-        element.focus();
-        element.setSelectionRange(start, end);
-    } else if(element.createTextRange){ // IE
-        var range = element.createTextRange();
-        with(range){
-            collapse(true);
-            moveEnd('character', end);
-            moveStart('character', start);
-            select();
-        }
-    } else { //otherwise try the event-creation hack (our own invention)
-        // do we need these?
-        element.value = element.value;
-        element.blur();
-        element.focus();
-        // figure out how far back to go
-        var dist = parseInt(element.value.length)-end;
-        var tchar = String.fromCharCode(37);
-        var tcc = tchar.charCodeAt(0);
-        for(var x = 0; x < dist; x++){
-            var te = document.createEvent("KeyEvents");
-            te.initKeyEvent("keypress", true, true, null, false, false, false, false, tcc, tcc);
-            element.dispatchEvent(te);
-        }
-    }
-}
-
-
-// XXX this looks unused
-function setProgressMessage(label) {
-    var body = document.getElementsByTagName('body')[0];
-    body.appendChild(DIV({id: 'progress'}, label));
-    jQuery('#progress').show();
-}
-
-// XXX this looks unused
-function resetProgressMessage() {
-    var body = document.getElementsByTagName('body')[0];
-    jQuery('#progress').hide();
-}
-
 
 /* set body's cursor to 'progress' */
 function setProgressCursor() {
@@ -151,7 +79,7 @@
 
 
 /* toggles visibility of login popup div */
-// XXX used exactly ONCE
+// XXX used exactly ONCE in basecomponents
 function popupLoginBox() {
     toggleVisibility('popupLoginBox');
     jQuery('#__login:visible').focus();
@@ -193,14 +121,6 @@
     forEach(filter(filterfunc, elements), function(cb) {cb.checked=checked;});
 }
 
-/* centers an HTML element on the screen */
-// XXX looks unused
-function centerElement(obj){
-    var vpDim = getViewportDimensions();
-    var elemDim = getElementDimensions(obj);
-    setElementPosition(obj, {'x':((vpDim.w - elemDim.w)/2),
-			     'y':((vpDim.h - elemDim.h)/2)});
-}
 
 /* this function is a hack to build a dom node from html source */
 function html2dom(source) {
@@ -223,12 +143,6 @@
 function isTextNode(domNode) { return domNode.nodeType == 3; }
 function isElementNode(domNode) { return domNode.nodeType == 1; }
 
-// XXX this looks unused
-function changeLinkText(link, newText) {
-    jQuery(link).text(newText);
-}
-
-
 function autogrow(area) {
     if (area.scrollHeight > area.clientHeight && !window.opera) {
 	if (area.rows < 20) {
@@ -236,13 +150,6 @@
 	}
     }
 }
-
-// XXX this looks unused
-function limitTextAreaSize(textarea, size) {
-    var $area = jQuery(textarea);
-    $area.val($area.val().slice(0, size));
-}
-
 //============= page loading events ==========================================//
 
 CubicWeb.rounded = [
@@ -250,8 +157,6 @@
 		    ['div.boxTitle, div.boxPrefTitle, div.sideBoxTitle, th.month', 'top 6px']
 		    ];
 
-
-
 function roundedCorners(node) {
     node = jQuery(node);
     for(var r=0; r < CubicWeb.rounded.length; r++) {
@@ -259,7 +164,8 @@
     }
 }
 
-jQuery(document).ready(function () {roundedCorners(this.body)});
+jQuery(document).ready(function () {roundedCorners(this.body);});
+
+CubicWeb.provide('corners.js');
 
 CubicWeb.provide('htmlhelpers.js');
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/data/cubicweb.massmailing.js	Thu Jul 16 12:57:17 2009 -0700
@@ -0,0 +1,23 @@
+
+function insertText(text, areaId) {
+    var textarea = jQuery('#' + areaId);
+    if (document.selection) { // IE
+        var selLength;
+        textarea.focus();
+        sel = document.selection.createRange();
+        selLength = sel.text.length;
+        sel.text = text;
+        sel.moveStart('character', selLength-text.length);
+        sel.select();
+    } else if (textarea.selectionStart || textarea.selectionStart == '0') { // mozilla
+        var startPos = textarea.selectionStart;
+        var endPos = textarea.selectionEnd;
+	// insert text so that it replaces the [startPos, endPos] part
+        textarea.value = textarea.value.substring(0,startPos) + text + textarea.value.substring(endPos,textarea.value.length);
+	// set cursor pos at the end of the inserted text
+        textarea.selectionStart = textarea.selectionEnd = startPos+text.length;
+        textarea.focus();
+    } else { // safety belt for other browsers
+        textarea.value += text;
+    }
+}
--- a/web/data/cubicweb.python.js	Thu Jul 16 12:54:46 2009 -0700
+++ b/web/data/cubicweb.python.js	Thu Jul 16 12:57:17 2009 -0700
@@ -157,7 +157,7 @@
 // ========== ARRAY EXTENSIONS ========== ///
 Array.prototype.contains = function(element) {
     return findValue(this, element) != -1;
-}
+};
 
 // ========== END OF ARRAY EXTENSIONS ========== ///
 
@@ -201,7 +201,7 @@
  * [0,2,4,6,8]
  */
 function list(iterable) {
-    iterator = iter(iterable);
+    var iterator = iter(iterable);
     var result = [];
     while (true) {
 	/* iterates until StopIteration occurs */
@@ -267,14 +267,6 @@
 function min() { return listMin(arguments); }
 function max() { return listMax(arguments); }
 
-// tricky multiple assign
-// function assign(lst, varnames) {
-//     var length = min(lst.length, varnames.length);
-//     for(var i=0; i<length; i++) {
-// 	window[varnames[i]] = lst[i];
-//     }
-// }
-
 /*
  * >>> d = dict(["x", "y", "z"], [0, 1, 2])
  * >>> d['y']
@@ -335,7 +327,7 @@
 function makeConstructor(userctor) {
     return function() {
 	// this is a proxy to user's __init__
-	if(userctor) {
+	if (userctor) {
 	    userctor.apply(this, arguments);
 	}
     };
@@ -369,7 +361,7 @@
 	}
     }
     var userctor = basemeths['__init__'];
-    constructor = makeConstructor(userctor);
+    var constructor = makeConstructor(userctor);
 
     // python-like interface
     constructor.__name__ = name;
--- a/web/data/tabs-no-images.css	Thu Jul 16 12:54:46 2009 -0700
+++ b/web/data/tabs-no-images.css	Thu Jul 16 12:57:17 2009 -0700
@@ -3,7 +3,7 @@
 ul.css-tabs {
 	margin:0 !important;
 	padding:0;
-	height:24px;
+	height:20px;
 	border-bottom:1px solid #666;
 }
 
@@ -24,12 +24,10 @@
 	text-decoration:none;
 	border:1px solid #666;
 	border-bottom:0px;
-	height:18px;
+	height:14px;
 	background-color:#efefef;
 	color:#777;
 	margin-right:2px;
-	-moz-border-radius-topleft: 4px;
-	-moz-border-radius-topright:4px;
 	position:relative;
 	top:1px;
 }
@@ -42,9 +40,8 @@
 /* selected tab */
 ul.css-tabs a.current {
 	background-color: white;
-	border-bottom:2px solid #ddd;
+	border-bottom:2px solid white;
 	color:#000;
-	cursor:default;
 }
 
 
--- a/web/views/massmailing.py	Thu Jul 16 12:54:46 2009 -0700
+++ b/web/views/massmailing.py	Thu Jul 16 12:57:17 2009 -0700
@@ -123,7 +123,7 @@
 
     def call(self):
         req = self.req
-        req.add_js('cubicweb.widgets.js')
+        req.add_js('cubicweb.widgets.js', 'cubicweb.massmailing.js')
         req.add_css('cubicweb.mailform.css')
         from_addr = '%s <%s>' % (req.user.dc_title(), req.user.get_email())
         form = self.vreg.select('forms', 'massmailing', self.req, rset=self.rset,
--- a/web/views/primary.py	Thu Jul 16 12:54:46 2009 -0700
+++ b/web/views/primary.py	Thu Jul 16 12:57:17 2009 -0700
@@ -39,12 +39,7 @@
 
     def cell_call(self, row, col):
         self.row = row
-        # XXX move render_entity implementation here
-        self.render_entity(self.complete_entity(row, col))
-        self.maxrelated = self.req.property_value('navigation.related-limit')
-
-    def render_entity(self, entity):
-        """return html to display the given entity"""
+        entity = self.complete_entity(row, col)
         self.render_entity_title(entity)
         self.render_entity_metadata(entity)
         # entity's attributes and relations, excluding meta data
@@ -54,23 +49,9 @@
             self.w(u'<table width="100%"><tr><td style="width: 75%">')
         self.w(u'<div class="mainInfo">')
         self.content_navigation_components('navcontenttop')
-        try:
-            self.render_entity_attributes(entity)
-        except TypeError, e: # XXX bw compat
-            if 'render_entity' not in e.args[0]:
-                raise
-            warn('siderelations argument of render_entity_attributes is '
-                 'deprecated (%s)' % self.__class__)
-            self.render_entity_attributes(entity, [])
+        self.render_entity_attributes(entity)
         if self.main_related_section:
-            try:
-                self.render_entity_relations(entity)
-            except TypeError, e: # XXX bw compat
-                if 'render_entity' not in e.args[0]:
-                    raise
-                warn('siderelations argument of render_entity_relations is '
-                     'deprecated')
-                self.render_entity_relations(entity, [])
+            self.render_entity_relations(entity)
         self.w(u'</div>')
         # side boxes
         if boxes or hasattr(self, 'render_side_related'):
@@ -83,7 +64,7 @@
             self.w(u'</div>')
             self.w(u'</td></tr></table>')
         self.content_navigation_components('navcontentbottom')
-
+        self.maxrelated = self.req.property_value('navigation.related-limit')
 
     def content_navigation_components(self, context):
         self.w(u'<div class="%s">' % context)
--- a/web/views/schema.py	Thu Jul 16 12:54:46 2009 -0700
+++ b/web/views/schema.py	Thu Jul 16 12:57:17 2009 -0700
@@ -27,7 +27,7 @@
 
 def skip_types(req):
     if int(req.form.get('skipmeta', True)):
-        return schema.SKIP_TYPES
+        return SKIP_TYPES
     return ()
 
 class ViewSchemaAction(action.Action):
@@ -191,15 +191,15 @@
 
 class RestrictedSchemaVisitorMixIn(object):
     def __init__(self, req, *args, **kwargs):
+        self.req = req
         super(RestrictedSchemaVisitorMixIn, self).__init__(*args, **kwargs)
-        self.req = req
 
-    def should_display_schema(self, schema):
-        return (super(RestrictedSchemaVisitorMixIn, self).should_display_schema(schema)
+    def should_display_schema(self, rschema):
+        return (super(RestrictedSchemaVisitorMixIn, self).should_display_schema(rschema)
                 and rschema.has_local_role('read') or rschema.has_perm(self.req, 'read'))
 
-    def should_display_attr(self, schema):
-        return (super(RestrictedSchemaVisitorMixIn, self).should_display_attr(schema)
+    def should_display_attr(self, rschema):
+        return (super(RestrictedSchemaVisitorMixIn, self).should_display_attr(rschema)
                 and rschema.has_local_role('read') or rschema.has_perm(self.req, 'read'))
 
 
--- a/web/views/tabs.py	Thu Jul 16 12:54:46 2009 -0700
+++ b/web/views/tabs.py	Thu Jul 16 12:57:17 2009 -0700
@@ -107,12 +107,9 @@
         active_tab = self.active_tab(tabs, default)
         # build the html structure
         w = self.w
-        if entity:
-            w(u'<div id="entity-tabs-%s">' % entity.eid)
-        else:
-            uid = make_uid('tab')
-            w(u'<div id="entity-tabs-%s">' % uid)
-        w(u'<ul class="css-tabs" id="tabs-%s">' % entity.eid)
+        uid = entity and entity.eid or make_uid('tab')
+        w(u'<div id="entity-tabs-%s">' % uid)
+        w(u'<ul class="css-tabs" id="tabs-%s">' % uid)
         for tab in tabs:
             w(u'<li>')
             w(u'<a href="#as-%s">' % tab)
@@ -123,7 +120,7 @@
             w(u'</li>')
         w(u'</ul>')
         w(u'</div>')
-        w(u'<div id="panes-%s">' % entity.eid)
+        w(u'<div id="panes-%s">' % uid)
         for tab in tabs:
             w(u'<div>')
             if entity:
@@ -134,11 +131,12 @@
         w(u'</div>')
         # call the set_tab() JS function *after* each tab is generated
         # because the callback binding needs to be done before
+        # XXX make work history: true
         self.req.add_onload(u'''
     jQuery(function() {
       jQuery("#tabs-%(eeid)s").tabs("#panes-%(eeid)s > div", {initialIndex: %(tabindex)s});
       set_tab('%(vid)s', '%(cookiename)s');
-    });''' % {'eeid' : entity.eid,
+    });''' % {'eeid' : (entity and entity.eid or uid),
               'vid'  : active_tab,
               'cookiename' : self.cookie_name,
               'tabindex' : tabs.index(active_tab)})