public function FieldHolder()
 {
     Requirements::javascript('dataobject_manager/javascript/jquery.wysiwyg.js');
     Requirements::css('dataobject_manager/css/jquery.wysiwyg.css');
     Requirements::customScript("\n\t\t\t\$(function() {\n\t\t\t\t\$('#{$this->id()}').wysiwyg({\n\t\t\t\t\t{$this->getConfig()}\n\t\t\t\t}).parents('.simplehtmleditor').removeClass('hidden');\n\t\t\t\t\n\t\t\t});\n\t\t");
     return parent::FieldHolder();
 }
Ejemplo n.º 2
0
    public function FieldHolder($attributes = array())
    {
        Requirements::javascript('//tinymce.cachefly.net/4.1/tinymce.min.js');
        $plugins = "'paste'";
        $extra_options = "";
        if ($this->word_count_limit > 0) {
            $plugins .= ", 'wordcount'";
            $extra_options = ",  wordcount_limit : {$this->word_count_limit}";
        }
        $script = <<<SCRIPT
tinymce.init({
    menubar: false,
    content_css: '//www.openstack.org/summit/css/tinymce.css',
    selector: 'textarea.tinymceeditor',
    plugins: [
        {$plugins}
    ],
    paste_auto_cleanup_on_paste : true,
    paste_remove_styles: true,
    paste_remove_styles_if_webkit: true,
    paste_strip_class_attributes: true,
    paste_retain_style_properties: 'font-size, font-style, color',
    toolbar: 'bold italic | alignleft aligncenter | bullist numlist | paste',
    statusbar : false
    {$extra_options}
});
SCRIPT;
        Requirements::customScript($script);
        $this->addExtraClass('tinymceeditor');
        return parent::FieldHolder($attributes);
    }
 /**
  * Returns the field holder used by templates
  * @return {string} HTML to be used
  */
 public function FieldHolder($properties = array())
 {
     Requirements::css('vendor/etdsolutions/simplemde-markdown-editor/simplemde.min.css');
     Requirements::javascript('vendor/etdsolutions/simplemde-markdown-editor/simplemde.min.js');
     Requirements::css(MARKDOWN_MODULE_BASE . '/css/editor.css');
     Requirements::javascript(MARKDOWN_MODULE_BASE . '/javascript/editor.js');
     return parent::FieldHolder($properties);
 }
 /**
  * Returns the field holder used by templates
  *
  * @param  array $properties
  * @return string            HTML to be used
  */
 public function FieldHolder($properties = array())
 {
     $this->extraClasses['stacked'] = 'stacked';
     Requirements::css(MARKDOWN_DIR . '/templates/css/styles.css');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript(MARKDOWN_DIR . '/thirdparty/textinputs_jquery.js');
     Requirements::javascript(MARKDOWN_DIR . '/templates/javascript/script.js');
     return parent::FieldHolder($properties);
 }
 /**
  * Returns the field holder used by templates
  * @return {string} HTML to be used
  */
 public function FieldHolder($properties = array())
 {
     $this->extraClasses['stacked'] = 'stacked';
     Requirements::css(MARKDOWN_MODULE_BASE . '/css/MarkdownEditor.css');
     Requirements::javascript(MARKDOWN_MODULE_BASE . '/thirdparty/ace/ace.js');
     Requirements::javascript(MARKDOWN_MODULE_BASE . '/thirdparty/ace/mode-markdown.js');
     Requirements::javascript(MARKDOWN_MODULE_BASE . '/thirdparty/ace/theme-textmate.js');
     Requirements::javascript(MARKDOWN_MODULE_BASE . '/thirdparty/ace/theme-twilight.js');
     Requirements::javascript(MARKDOWN_MODULE_BASE . '/javascript/MarkdownEditor.js');
     return parent::FieldHolder($properties);
 }
 /**
  * Builds the form field, includes JavaScript, and sets defaults
  *
  * @param array $attributes The attributes to include on the form field
  * @return SimpleHtmlEditorField
  */
 public function FieldHolder($attributes = array())
 {
     Requirements::javascript("bootstrap_forms/javascript/tinymce/jscripts/tiny_mce/jquery.tinymce.js");
     Requirements::javascript("bootstrap_forms/javascript/tinymce/jscripts/tiny_mce/tiny_mce.js");
     if (!$this->getAttribute('data-buttons')) {
         $this->setButtons(self::$default_buttons);
     }
     if (!$this->getAttribute('data-blockformats')) {
         $this->setBlockFormats(self::$default_blockformats);
     }
     $this->addExtraClass('wysiwyg');
     return parent::FieldHolder($attributes);
 }
 public function FieldHolder($properties = array())
 {
     $this->extraClasses['stacked'] = 'stacked';
     $this->include_js();
     Requirements::css(MARKDOWN_MODULE_BASE . '/thirdparty/font-awesome-4.3.0/css/font-awesome.min.css');
     Requirements::css(MARKDOWN_MODULE_BASE . '/css/MarkdownEditor.css');
     Requirements::css(MARKDOWN_MODULE_BASE . '/thirdparty/editor/simplemde.min.css');
     if (0 && Director::isDev()) {
         Requirements::javascript(MARKDOWN_MODULE_BASE . '/thirdparty/editor/sourcefiles/codemirror/codemirror.js');
         Requirements::javascript(MARKDOWN_MODULE_BASE . '/thirdparty/editor/sourcefiles/simplemde.js');
     } else {
         Requirements::javascript(MARKDOWN_MODULE_BASE . '/thirdparty/editor/simplemde.min.js');
     }
     Requirements::javascript(MARKDOWN_MODULE_BASE . '/javascript/MarkdownEditorField.js');
     Requirements::javascript(MARKDOWN_MODULE_BASE . '/javascript/MarkDownShortCode.js');
     $this->extend("updateFieldHolder");
     return parent::FieldHolder($properties);
 }
    public function FieldHolder($attributes = array())
    {
        Requirements::javascript('//tinymce.cachefly.net/4.3/tinymce.min.js');
        $script = '';
        $plugins = "'paste'";
        $extra_options = ",setup : function(ed) {";
        if ($this->word_count_limit > 0) {
            $plugins .= ", 'wordcount'";
            $extra_options = ",  wordcount_limit : {$this->word_count_limit}";
        } else {
            if ($this->max_char_limit > 0) {
                $script .= <<<JS

      var max_chars   = {$this->max_char_limit}; //max characters
      var allowed_keys = [8, 13, 16, 17, 18, 20, 33, 34, 35,36, 37, 38, 39, 40, 46];

      function alarmChars(chars_without_html, container_id){
        if(chars_without_html > (max_chars - 10))
        {
            \$('#chars_left_'+container_id).css('color','red');
        }
        else
        {
            \$('#chars_left_'+container_id).css('color','gray');

        }
      }
JS;
                $extra_options .= <<<JS
    ed.on("KeyDown", function(ed, evt) {
        var chars_without_html = \$.trim(tinyMCE.activeEditor.getBody().textContent).length;
        var container_id       = tinyMCE.activeEditor.id;
        var key = ed.keyCode;

        \$('#chars_left_'+container_id).html(max_chars - chars_without_html);

        if(allowed_keys.indexOf(key) != -1){
            alarmChars(chars_without_html, container_id);
            return;
        }

        if (chars_without_html > ( max_chars - 1 )){
            ed.stopPropagation();
            ed.preventDefault();
            return false;
        }
         alarmChars(chars_without_html, container_id);
    });

    ed.on("Paste", function(ed, evt, o) {
          setTimeout(function(){
               var txt = tinyMCE.activeEditor.getBody().textContent;
               var chars_without_html = \$.trim(txt).length;
               var container_id       = tinyMCE.activeEditor.id;
               if(txt.length > max_chars)
               {
                    txt = txt.substr(0, max_chars);
                    chars_without_html  = max_chars;
               }
               \$('#chars_left_'+container_id).html(max_chars - chars_without_html);
               alarmChars(chars_without_html, container_id);
               tinyMCE.activeEditor.setContent(txt.trim());
           },200);
    });



JS;
            }
        }
        if ($this->required) {
            $extra_options .= <<<JS

                ed.on("Change", function(ed){
                    tinyMCE.triggerSave();
                    console.log('change');
                });
JS;
        }
        $extra_options .= ' }';
        $script .= <<<SCRIPT
tinymce.init({
    menubar: false,
    content_css: '//www.openstack.org/summit/css/tinymce.css',
    selector: 'textarea.tinymceeditor',
    plugins: [
        {$plugins}
    ],
    paste_auto_cleanup_on_paste : true,
    paste_remove_styles: true,
    paste_remove_styles_if_webkit: true,
    paste_strip_class_attributes: true,
    paste_retain_style_properties: 'font-size, font-style, color',
    toolbar: 'bold italic | alignleft aligncenter | bullist numlist | paste',
    statusbar : false,
    valid_elements : "@[id|class|style|title"
        + "a[name|href|target|title|class],strong/b,em/i,strike,u,"
        + "#p,-ol[type|compact],-ul[type|compact],-li,br,"
        + "img[src|border|alt=|title|width|height|align],"
        + "-blockquote,-table[border=0|cellspacing|cellpadding|width|frame|rules|"
        + "height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|"
        + "height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,"
        + "#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor"
        + "|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,"
        + "-span,-code,-pre,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face"
        + "|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],"
        + "col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|"
        + "valign|width],fieldset,label[for],legend,q[cite],small,"
        + "textarea[cols|rows|disabled|name|readonly],big"
    {$extra_options}
});
SCRIPT;
        if ($this->max_char_limit > 0) {
            $script .= <<<JS

 var chars_without_html = \$.trim(\$("#{$this->ID()}").text().replace(/(<([^>]+)>)/ig,"")).length;
 \$('#chars_left_{$this->ID()}').html(max_chars - chars_without_html);
 alarmChars('{$this->ID()}', chars_without_html);
JS;
        }
        if ($this->required) {
            $form_id = $this->getForm()->FormName();
            $script .= <<<JS
                \$(document).ready(function(){

                    var form = \$('#{$form_id}');

                    if(form.length > 0)
                    {

                        \$( "#{$this->ID()}" ).rules( "add", {
                          required: true,
                          messages: {
                            required: '{$this->Name} field is required.'
                          }
                        });


                        form.submit(function(e){
                             tinyMCE.triggerSave();
                             var is_valid = form.valid();
                             if(!is_valid)
                             {
                                return false;
                             }
                             return true;
                        });
                    }
                });
JS;
        }
        Requirements::customScript($script);
        $this->addExtraClass('tinymceeditor');
        return parent::FieldHolder($attributes);
    }
 public function FieldHolder()
 {
     $html = "<div class=\"display_anything_field upload_anything_field\">";
     $id = $this->controller->{$this->name}()->getField('ID');
     $migrated_value = $this->controller->{$this->name}()->getField('Migrated');
     $migrator = FALSE;
     if ($this->detect_image_gallery_module && $migrated_value == 0) {
         //display only if we want to detect imagegallery albums and it's not already migrated
         $list = $this->ImageGalleryAlbums();
         if (!empty($list)) {
             $migrator = TRUE;
             $html .= "<div class=\"field_content migrate\">";
             $html .= "<fieldset><h5>Display Anything has detected an ImageGallery album associated with this page</h5>";
             $html .= "<p>Do you wish to migrate it to your new gallery?<p>";
             $html .= "<p>Migration notes:</p><ul>";
             $html .= "<li>The original ImageGallery album will remain untouched.</li>";
             $html .= "<li>Files will be copied alongside current files, this will allow you to remove the old gallery as and when required.</li>";
             $html .= "</ul>";
             $migrate = new DropDownField("{$this->name}[{$id}][MigrateImageGalleryAlbumID]", "Choose an album to migrate images from", $list, '', NULL, '[Do not migrate]');
             $html .= $migrate->FieldHolder();
             $html .= "</fieldset>";
             $html .= "</div>";
         }
     } else {
         if ($migrated_value == 1) {
             $migrator = TRUE;
         }
     }
     $html .= "<div class=\"field_content\">";
     $html .= "<fieldset><h5>Gallery settings and options</h5>";
     $title = new TextField("{$this->name}[{$id}][Title]", "Title", $this->controller->{$this->name}()->getField('Title'));
     $html .= $title->FieldHolder();
     $description = new TextareaField("{$this->name}[{$id}][Description]", "Description", 3, NULL, $this->controller->{$this->name}()->getField('Description'));
     $html .= $description->FieldHolder();
     $visible = new CheckboxField("{$this->name}[{$id}][Visible]", "Publicly Visible", $this->controller->{$this->name}()->getField('Visible') == 1 ? TRUE : FALSE);
     $html .= $visible->FieldHolder();
     if ($migrator && $migrated_value == 1) {
         //only need to show this post migration
         $migrated = new CheckboxField("{$this->name}[{$id}][Migrated]", "Image Gallery migration complete (uncheck and save to display migration options)", TRUE);
         $html .= $migrated->FieldHolder();
     }
     $html .= "</fieldset></div>";
     $html .= "<div class=\"field_content\">";
     $html .= "<fieldset><h5>Gallery Items</h5>";
     if (!empty($id)) {
         $html .= parent::FieldHolder();
     } else {
         $html .= "<div class=\"message\"><p>Gallery items can be uploaded after the gallery is saved for the first time</p></div>";
     }
     $html .= "</fieldset></div>";
     $html .= "</div>";
     return $html;
 }
Ejemplo n.º 10
0
 public function FieldHolder($properties = array())
 {
     $this->addExtraClass('stacked');
     return parent::FieldHolder($properties);
 }
Ejemplo n.º 11
0
    public function FieldHolder($attributes = array())
    {
        Requirements::javascript('//tinymce.cachefly.net/4.3/tinymce.min.js');
        $script = '';
        $plugins = "'paste'";
        $extra_options = ",setup : function(ed) {";
        if ($this->word_count_limit > 0) {
            $plugins .= ", 'wordcount'";
            $extra_options = ",  wordcount_limit : {$this->word_count_limit}";
        } else {
            if ($this->max_char_limit > 0) {
                $script .= <<<JS

      var max_chars   = {$this->max_char_limit}; //max characters
      var allowed_keys = [8, 13, 16, 17, 18, 20, 33, 34, 35,36, 37, 38, 39, 40, 46];

      function alarmChars(chars_without_html, container_id){
        if(chars_without_html > (max_chars - 10))
        {
            \$('#chars_left_'+container_id).css('color','red');
        }
        else
        {
            \$('#chars_left_'+container_id).css('color','gray');

        }
      }
JS;
                $extra_options .= <<<JS
    ed.on("KeyDown", function(ed, evt) {
        var chars_without_html = \$.trim(tinyMCE.activeEditor.getBody().textContent).length;
        var container_id       = tinyMCE.activeEditor.id;
        var key = ed.keyCode;

        \$('#chars_left_'+container_id).html(max_chars - chars_without_html);

        if(allowed_keys.indexOf(key) != -1){
            alarmChars(chars_without_html, container_id);
            return;
        }

        if (chars_without_html > ( max_chars - 1 )){
            ed.stopPropagation();
            ed.preventDefault();
            return false;
        }
         alarmChars(chars_without_html, container_id);
    });

    ed.on("Paste", function(ed, evt, o) {
          setTimeout(function(){
               var txt = tinyMCE.activeEditor.getBody().textContent;
               var chars_without_html = \$.trim(txt).length;
               var container_id       = tinyMCE.activeEditor.id;
               if(txt.length > max_chars)
               {
                    txt = txt.substr(0, max_chars);
                    chars_without_html  = max_chars;
               }
               \$('#chars_left_'+container_id).html(max_chars - chars_without_html);
               alarmChars(chars_without_html, container_id);
               tinyMCE.activeEditor.setContent(txt.trim());
           },200);
    });



JS;
            }
        }
        if ($this->required) {
            $extra_options .= <<<JS

                ed.on("Change", function(ed){
                    tinyMCE.triggerSave();
                    console.log('change');
                });
JS;
        }
        $extra_options .= ' }';
        $script .= <<<SCRIPT
tinymce.init({
    menubar: false,
    content_css: '//www.openstack.org/summit/css/tinymce.css',
    selector: 'textarea.tinymceeditor',
    plugins: [
        {$plugins}
    ],
    paste_auto_cleanup_on_paste : true,
    paste_remove_styles: true,
    paste_remove_styles_if_webkit: true,
    paste_strip_class_attributes: true,
    paste_retain_style_properties: 'font-size, font-style, color',
    toolbar: 'bold italic | alignleft aligncenter | bullist numlist | paste',
    statusbar : false
    {$extra_options}
});
SCRIPT;
        if ($this->max_char_limit > 0) {
            $script .= <<<JS

 var chars_without_html = \$.trim(\$("#{$this->ID()}").text().replace(/(<([^>]+)>)/ig,"")).length;
 \$('#chars_left_{$this->ID()}').html(max_chars - chars_without_html);
 alarmChars('{$this->ID()}', chars_without_html);
JS;
        }
        if ($this->required) {
            $form_id = $this->getForm()->FormName();
            $script .= <<<JS
                \$(document).ready(function(){

                    var form = \$('#{$form_id}');

                    if(form.length > 0)
                    {

                        \$( "#{$this->ID()}" ).rules( "add", {
                          required: true,
                          messages: {
                            required: '{$this->Name} field is required.'
                          }
                        });


                        form.submit(function(e){
                             tinyMCE.triggerSave();
                             var is_valid = form.valid();
                             if(!is_valid)
                             {
                                return false;
                             }
                             return true;
                        });
                    }
                });
JS;
        }
        Requirements::customScript($script);
        $this->addExtraClass('tinymceeditor');
        return parent::FieldHolder($attributes);
    }