Skip to content

Commit

Permalink
Little clean up: Relocates the positioning code, so it's provided to
Browse files Browse the repository at this point in the history
the constructor rather than in a second call to its property access
method.

git-svn-id: svn://cherokee-project.com/CTK/trunk@5753 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information
alobbs committed Nov 12, 2010
1 parent 8e95978 commit 59a9bf5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions CTK/Dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from Image import ImageStock
from Box import Box
from PageCleaner import Uniq_Block
from util import props_to_str
from util import props_to_str, json_dump


HEADERS = [
Expand All @@ -46,20 +46,15 @@
/* Initialize */
dialog_obj.dialog (%(dialog_props)s);
/* Positioning */
dialog_obj.dialog ('option', 'position', ['center', 85]);
"""

def py2js_dic (d):
js_pairs = []

for key in d:
val = d[key]
if type(val) == bool:
js_pairs.append ("'%s': %s" %(key, ('false', 'true')[val]))
elif type(val) == int:
js_pairs.append ("'%s': %d" %(key, val))
if type(val) in (bool, int, float, list):
js_pairs.append ("'%s': %s" %(key, json_dump(val)))
elif type(val) == str:
if '/* code */' in val:
js_pairs.append ("'%s': %s" %(key, val))
Expand Down Expand Up @@ -93,6 +88,8 @@ def __init__ (self, js_props={}, props={}):
self.js_props['autoOpen'] = False
if 'draggable' not in self.js_props:
self.js_props['draggable'] = False
if 'position' not in self.js_props:
self.js_props['position'] = ['center', 85]

# Special cases
if not self.js_props['autoOpen']:
Expand Down

0 comments on commit 59a9bf5

Please sign in to comment.