def get_advanced_definition_wdg(my): # add the advanced entry advanced = DivWdg() advanced.add_style("margin-top: 10px") advanced.add_style("padding: 10px") advanced.add_border() title = DivWdg() title.add_style("color: black") title.add("Advanced - XML Column Definition") title.add_style("margin-top: -23") advanced.add(title) advanced.add("<br/>") input = TextAreaWdg("config_xml") input.set_id("config_xml") input.set_option("rows", "10") input.set_option("cols", "70") input.set_value(my.config_string) advanced.add(input) advanced.add(HtmlElement.br(2)) button_div = DivWdg() button_div.add_style("text-align: center") button = ActionButtonWdg(title="Save Definition") #button = ProdIconButtonWdg("Save Definition") button.add_event("onclick", "spt.custom_project.save_definition_cbk()") button_div.add(button) button_div.add_style("margin-left: 130px") advanced.add(button_div) return advanced
def get_advanced_definition_wdg(self): # add the advanced entry advanced = DivWdg() advanced.add_style("margin-top: 10px") advanced.add_style("padding: 10px") advanced.add_border() title = DivWdg() title.add_style("color: black") title.add("Advanced - XML Column Definition") title.add_style("margin-top: -23") advanced.add(title) advanced.add("<br/>") input = TextAreaWdg("config_xml") input.set_id("config_xml") input.set_option("rows", "10") input.set_option("cols", "70") input.set_value(self.config_string) advanced.add(input) advanced.add(HtmlElement.br(2)) button_div = DivWdg() button_div.add_style("text-align: center") button = ActionButtonWdg(title="Save Definition") #button = ProdIconButtonWdg("Save Definition") button.add_event("onclick", "spt.custom_project.save_definition_cbk()") button_div.add(button) button_div.add_style("margin-left: 130px") advanced.add(button_div) return advanced
def get_instructions_textarea_wdg(instructions_sobject, width=600, height=600): """ Given an instructions sobject, get a TextArea widget to hold all of its text. Optionally, pass in the width and height of the TextArea widget. :param instructions_sobject: twog/instructions sobject :param width: int :param height: int :return: DivWdg (holding the TextArea widget) """ instructions_div = DivWdg() instructions_div.add_style('margin', '10px') instructions_textarea_wdg = TextAreaWdg() instructions_textarea_wdg.set_id('instructions_textarea') instructions_textarea_wdg.set_name('instructions_textarea') instructions_textarea_wdg.add_style('width', '{0}px'.format(width)) instructions_textarea_wdg.add_style('height', '{0}px'.format(height)) instructions_text = instructions_sobject.get('instructions_text') instructions_textarea_wdg.set_value(instructions_text) instructions_div.add(instructions_textarea_wdg) return instructions_div
def get_text_area_input_wdg(name, width=400, styles=None): textarea_wdg = TextAreaWdg() textarea_wdg.set_id(name) textarea_wdg.set_name(name) textarea_wdg.add_style('width', '{0}px'.format(width)) if styles is None: styles = [] for style in styles: textarea_wdg.add_style(style[0], style[1]) return textarea_wdg
def get_text_area_input_wdg(self, name, id): text_area_wdg = TextAreaWdg() text_area_wdg.set_id(id) if hasattr(self, id): text_area_wdg.set_value(getattr(self, id)) text_area_div = DivWdg(name) text_area_div.add_style('font-weight', 'bold') section_div = DivWdg() section_div.add_style('margin', '10px') section_div.add(text_area_div) section_div.add(text_area_wdg) return section_div
def get_general_comments_section(self): general_comments_div = DivWdg() general_comments_div.add_style('margin', '10px') general_comments_wdg = TextAreaWdg() general_comments_wdg.set_id('general_comments') general_comments_wdg.set_input_prefix('test') if self.prequal_eval_sobject: general_comments_wdg.set_value(self.prequal_eval_sobject.get_value('general_comments')) general_comments_text_div = DivWdg('General Comments') general_comments_text_div.add_style('font-weight', 'bold') general_comments_div.add(general_comments_text_div) general_comments_div.add(general_comments_wdg) return general_comments_div
def get_general_comments_section(self): general_comments_div = DivWdg() general_comments_div.add_style('margin', '10px') general_comments_wdg = TextAreaWdg() general_comments_wdg.set_id('general_comments') general_comments_wdg.set_name('general_comments') if hasattr(self, 'general_comments'): general_comments_wdg.set_value(self.general_comments) general_comments_text_div = DivWdg('General Comments') general_comments_text_div.add_style('font-weight', 'bold') general_comments_div.add(general_comments_text_div) general_comments_div.add(general_comments_wdg) return general_comments_div
class CKEditorWdg(BaseRefreshWdg): def init(self): name = self.kwargs.get("name") assert(name) self.text = TextAreaWdg(name) self.text_id = self.kwargs.get("text_id") if not self.text_id: self.text_id = self.text.set_unique_id() def get_display(self): top = self.top top.add_style("min-width: 600px") top.add_class("spt_ckeditor_top") top.add_attr("text_id", self.text_id) top.add(self.text) value = self.kwargs.get("value") if value: self.text.set_value(value) self.text.add_style("width: 100%") self.text.add_style("height: 100%") self.text.add_style("min-height: 500px") self.text.add_style("display: none") self.text.set_id(self.text_id) self.text.add_behavior( { 'type': 'load', 'color': self.text.get_color("background", -10), 'text_id': self.text_id, 'cbjs_action': ''' /* var js_file = "ckeditor/ckeditor.js"; var url = "/context/spt_js/" + js_file; var js_el = document.createElement("script"); js_el.setAttribute("type", "text/javascript"); js_el.setAttribute("src", url); var head = document.getElementsByTagName("head")[0]; head.appendChild(js_el); */ var init = function() { CKEDITOR.on( 'instanceReady', function( ev ) { ev.editor.dataProcessor.writer.indentationChars = ' '; }); var config = { toolbar: 'Full', uiColor: bvr.color, height: '800px' }; /* config.toolbar_Full = [ ['Source'], //['Cut','Copy','Paste'], ['Undo','Redo','-','Find','Replace'], ['Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'], ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'], '/', ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['HorizontalRule','SpecialChar'], ['Styles','Format','FontSize'], ['TextColor','BGColor'], ['Maximize', 'ShowBlocks'] ]; */ config.toolbar_Full = [ { name: 'document', items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] }, { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] }, { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] }, { name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] }, '/', { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] }, { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv', '-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] }, { name: 'links', items : [ 'Link','Unlink','Anchor' ] }, { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] }, '/', { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] }, { name: 'colors', items : [ 'TextColor','BGColor' ] }, { name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] } ]; config.entities = false; config.basicEntities = false; config.extraAllowedContent = 'iframe[*]'; config.allowedContent = true; config.enterMode = CKEDITOR.ENTER_BR; var instance = CKEDITOR.instances[ bvr.text_id ]; if (instance) instance.destroy(); CKEDITOR.replace(bvr.text_id, config ); //var html = ''; //editor = CKEDITOR.appendTo( bvr.text_id, config, html ); bvr.src_el.setStyle("display", "none"); spt.ckeditor = {}; spt.ckeditor.get_value = function(text_id) { var text_value = CKEDITOR.instances[ text_id ].getData(); return text_value; } spt.ckeditor.set_value = function(text_id, data) { CKEDITOR.instances[ text_id ].setData(data); } } spt.dom.load_js(['ckeditor/ckeditor.js'], init); ''' } ) return top
class CKEditorWdg(BaseRefreshWdg): def init(self): name = self.kwargs.get("name") assert (name) self.text = TextAreaWdg(name) self.text_id = self.kwargs.get("text_id") if not self.text_id: self.text_id = self.text.set_unique_id() def get_display(self): top = self.top top.add_style("min-width: 600px") top.add_class("spt_ckeditor_top") top.add_attr("text_id", self.text_id) top.add(self.text) value = self.kwargs.get("value") if value: self.text.set_value(value) self.text.add_style("width: 100%") self.text.add_style("height: 100%") self.text.add_style("min-height: 500px") self.text.add_style("display: none") self.text.set_id(self.text_id) self.text.add_behavior({ 'type': 'load', 'color': self.text.get_color("background", -10), 'text_id': self.text_id, 'cbjs_action': ''' /* var js_file = "ckeditor/ckeditor.js"; var url = "/context/spt_js/" + js_file; var js_el = document.createElement("script"); js_el.setAttribute("type", "text/javascript"); js_el.setAttribute("src", url); var head = document.getElementsByTagName("head")[0]; head.appendChild(js_el); */ var init = function() { CKEDITOR.on( 'instanceReady', function( ev ) { ev.editor.dataProcessor.writer.indentationChars = ' '; }); var config = { toolbar: 'Full', uiColor: bvr.color, height: '800px' }; /* config.toolbar_Full = [ ['Source'], //['Cut','Copy','Paste'], ['Undo','Redo','-','Find','Replace'], ['Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'], ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'], '/', ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['HorizontalRule','SpecialChar'], ['Styles','Format','FontSize'], ['TextColor','BGColor'], ['Maximize', 'ShowBlocks'] ]; */ config.toolbar_Full = [ { name: 'document', items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] }, { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] }, { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] }, { name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] }, '/', { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] }, { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv', '-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] }, { name: 'links', items : [ 'Link','Unlink','Anchor' ] }, { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] }, '/', { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] }, { name: 'colors', items : [ 'TextColor','BGColor' ] }, { name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] } ]; config.entities = false; config.basicEntities = false; config.extraAllowedContent = 'iframe[*]'; config.allowedContent = true; config.enterMode = CKEDITOR.ENTER_BR; var instance = CKEDITOR.instances[ bvr.text_id ]; if (instance) instance.destroy(); CKEDITOR.replace(bvr.text_id, config ); //var html = ''; //editor = CKEDITOR.appendTo( bvr.text_id, config, html ); bvr.src_el.setStyle("display", "none"); spt.ckeditor = {}; spt.ckeditor.get_value = function(text_id) { var text_value = CKEDITOR.instances[ text_id ].getData(); return text_value; } spt.ckeditor.set_value = function(text_id, data) { CKEDITOR.instances[ text_id ].setData(data); } } spt.dom.load_js(['ckeditor/ckeditor.js'], init); ''' }) return top