How to use insert method in elementium

Best Python code snippet using elementium_python

editor-plugin-39.js

Source:editor-plugin-39.js Github

copy

Full Screen

1(function() {2 // TinyMCE plugin start.3 tinymce.PluginManager.add( 'CherryTinyMCEShortcodes', function( editor, url ) {4 // Register a command to open the dialog.5 editor.addCommand( 'cherry_open_dialog', function( ui, v ) {6 cherrySelectedShortcodeType = v;7 selectedText = editor.selection.getContent({format: 'text'});8 tb_dialog_helper.loadShortcodeDetails();9 tb_dialog_helper.setupShortcodeType( v );10 jQuery( '#shortcode-options' ).addClass( 'shortcode-' + v );11 jQuery( '#selected-shortcode' ).val( v );12 var f=jQuery(window).width();13 b=jQuery(window).height();14 f=720<f?720:f;15 f+=32;16 b-=120;17 tb_show( "Insert ["+ v +"] shortcode", "#TB_inline?width="+f+"&height="+b+"&inlineId=dialog" );18 });19 // Register a command to insert the self-closing shortcode immediately.20 editor.addCommand( 'cherry_insert_self_immediate', function( ui, v ) {21 editor.insertContent( '[' + v + ']' );22 });23 // Register a command to insert the enclosing shortcode immediately.24 editor.addCommand( 'cherry_insert_immediate', function( ui, v ) {25 var selected = editor.selection.getContent({format: 'text'});26 editor.insertContent( '[' + v + ']' + selected + '[/' + v + ']' );27 });28 // Register a command to insert the N-enclosing shortcode immediately.29 editor.addCommand( 'cherry_insert_immediate_n', function( ui, v ) {30 var arr = v.split('|'),31 selected = editor.selection.getContent({format: 'text'}),32 sortcode;33 for (var i = 0, len = arr.length; i < len; i++) {34 if (0 === i) {35 sortcode = '[' + arr[i] + ']' + selected + '[/' + arr[i] + ']';36 } else {37 sortcode += '[' + arr[i] + '][/' + arr[i] + ']';38 };39 };40 editor.insertContent( sortcode );41 });42 // Register a command to insert `Tabs` shortcode.43 editor.addCommand( 'cherry_insert_tabs', function( ui, v ) {44 editor.insertContent( '[tabs direction="top" tab1="Title #1" tab2="Title #2" tab3="Title #3"] [tab1] Tab 1 content... [/tab1] [tab2] Tab 2 content... [/tab2] [tab3] Tab 3 content... [/tab3] [/tabs]' ); // direction - top, right, below, left45 });46 // Register a command to insert `Accordion` shortcode.47 editor.addCommand( 'cherry_insert_accordions', function( ui, v ) {48 editor.insertContent( '[accordions] [accordion title="title1" visible="yes"] tab content [/accordion] [accordion title="title2"] another content tab [/accordion] [/accordions]' );49 });50 // Register a command to insert `Table` shortcode.51 editor.addCommand( 'cherry_insert_table', function( ui, v ) {52 editor.insertContent( '[table td1="#" td2="Title" td3="Value"] [td1] 1 [/td1] [td2] some title 1 [/td2] [td3] some value 1 [/td3] [/table]' );53 });54 // Add a button that opens a window55 editor.addButton( 'cherry_shortcodes_button', {56 type: 'menubutton',57 icon: 'icon icon-puzzle-piece',58 tooltip: 'Insert a Cherry Shortcode',59 menu: [60 // Posts menu.61 {text: 'Posts', menu: [62 {text: 'Posts Grid', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'posts_grid', { title: 'Posts Grid' } ); } },63 {text: 'Posts List', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'posts_list', { title: 'Posts List' } ); } },64 {text: 'Mini Posts Grid', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'mini_posts_grid', { title: 'Mini Posts Grid' } ); } },65 {text: 'Mini Posts List', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'mini_posts_list', { title: 'Mini Posts List' } ); } },66 {text: 'Recent Posts', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'recentposts', { title: 'Recent Posts' } ); } },67 {text: 'Recent Testimonials', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'recenttesti', { title: 'Recent Testimonials' } ); } }68 ]},69 // Basic menu.70 {text: 'Basic', menu: [71 {text: 'Banner', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'banner', { title: 'Banner' } ); } },72 {text: 'Comments', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'recentcomments', { title: 'Comments' } ); } },73 {text: 'Post Cycle', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'post_cycle', { title: 'Post Cycle' } ); } },74 {text: 'Carousel (Elasti)', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'carousel', { title: 'Carousel (Elasti)' } ); } },75 {text: 'Carousel (OWL)', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'carousel_owl', { title: 'Carousel (OWL)' } ); } },76 {text: 'Roundabout', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'roundabout', { title: 'Roundabout' } ); } },77 {text: 'Service Box', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'service_box', { title: 'Service Box' } ); } },78 {text: 'Hero Unit', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'hero_unit', { title: 'Hero Unit' } ); } },79 {text: 'Categories', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'categories', { title: 'Categories' } ); } },80 {text: 'Tags', onclick: function() { editor.execCommand( 'cherry_insert_self_immediate', false, 'tags', { title: 'Tags' } ); } },81 ]},82 // Columns menu.83 {text: 'Columns', menu: [84 {text: 'row', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'row', { title: 'row' } ); } },85 {text: 'row inner', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'row_in', { title: 'row inner' } ); } },86 {text: 'span1', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'span1', { title: 'span1' } ); } },87 {text: 'span2', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'span2', { title: 'span2' } ); } },88 {text: 'span3', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'span3', { title: 'span3' } ); } },89 {text: 'span4', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'span4', { title: 'span4' } ); } },90 {text: 'span5', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'span5', { title: 'span5' } ); } },91 {text: 'span6', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'span6', { title: 'span6' } ); } },92 {text: 'span7', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'span7', { title: 'span7' } ); } },93 {text: 'span8', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'span8', { title: 'span8' } ); } },94 {text: 'span9', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'span9', { title: 'span9' } ); } },95 {text: 'span10', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'span10', { title: 'span10' } ); } },96 {text: 'span11', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'span11', { title: 'span11' } ); } },97 {text: 'span12', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'span12', { title: 'span12' } ); } }98 ]},99 // Fluid Columns menu.100 {text: 'Fluid Columns', menu: [101 {text: 'row fluid', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'row_fluid', { title: 'row fluid' } ); } },102 {text: '1/2', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'one_half', { title: '1/2' } ); } },103 {text: '1/3', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'one_third', { title: '1/3' } ); } },104 {text: '2/3', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'two_third', { title: '2/3' } ); } },105 {text: '1/4', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'one_fourth', { title: '1/4' } ); } },106 {text: '3/4', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'three_fourth', { title: '3/4' } ); } },107 {text: '1/6', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'one_sixth', { title: '1/6' } ); } },108 {text: '5/6', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'five_sixth', { title: '5/6' } ); } }109 ]},110 // 2 Columns menu.111 {text: '2 Columns', menu: [112 {text: '1/2 | 1/2', onclick: function() { editor.execCommand( 'cherry_insert_immediate_n', false, 'span6|span6', { title: '1/2 | 1/2' } ); } },113 {text: '2/3 | 1/3', onclick: function() { editor.execCommand( 'cherry_insert_immediate_n', false, 'span8|span4', { title: '2/3 | 1/3' } ); } },114 {text: '1/3 | 2/3', onclick: function() { editor.execCommand( 'cherry_insert_immediate_n', false, 'span4|span8', { title: '1/3 | 2/3' } ); } }115 ]},116 // 3 Columns menu.117 {text: '3 Columns', menu: [118 {text: '1/3 | 1/3 | 1/3', onclick: function() { editor.execCommand( 'cherry_insert_immediate_n', false, 'span4|span4|span4', { title: '1/3 | 1/3 | 1/3' } ); } },119 {text: '1/2 | 1/4 | 1/4', onclick: function() { editor.execCommand( 'cherry_insert_immediate_n', false, 'span6|span3|span3', { title: '1/2 | 1/4 | 1/4' } ); } },120 {text: '1/4 | 1/2 | 1/4', onclick: function() { editor.execCommand( 'cherry_insert_immediate_n', false, 'span3|span6|span3', { title: '1/4 | 1/2 | 1/4' } ); } },121 {text: '1/4 | 1/4 | 1/2', onclick: function() { editor.execCommand( 'cherry_insert_immediate_n', false, 'span3|span3|span6', { title: '1/4 | 1/4 | 1/2' } ); } }122 ]},123 // 4 Columns menu.124 {text: '4 Columns', menu: [125 {text: '1/4 | 1/4 | 1/4 | 1/4', onclick: function() { editor.execCommand( 'cherry_insert_immediate_n', false, 'span3|span3|span3|span3', { title: '1/4 | 1/4 | 1/4 | 1/4' } ); } }126 ]},127 // Elements menu.128 {text: 'Elements', menu: [129 {text: 'Label', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'label', { title: 'Label' } ); } },130 {text: 'Text Highlight', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'highlight', { title: 'Text Highlight' } ); } },131 {text: 'Button', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'button', { title: 'Button' } ); } },132 {text: 'Drop Cap', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'dropcap', { title: 'Drop Cap' } ); } },133 // {text: 'Blockquote', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'blockquote', { title: 'Blockquote' } ); } },134 {text: 'Icon', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'icon', { title: 'Icon' } ); } },135 // {text: 'Frame', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'frame', { title: 'Frame' } ); } },136 {text: 'Horizontal Rule', onclick: function() { editor.execCommand( 'cherry_insert_self_immediate', false, 'hr', { title: 'Horizontal Rule' } ); } },137 {text: 'Small Horizontal Rule', onclick: function() { editor.execCommand( 'cherry_insert_self_immediate', false, 'sm_hr', { title: 'Small Horizontal Rule' } ); } },138 {text: 'Vertical Rule', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'vr', { title: 'Vertical Rule' } ); } },139 {text: 'Spacer', onclick: function() { editor.execCommand( 'cherry_insert_self_immediate', false, 'spacer', { title: 'Spacer' } ); } },140 {text: 'Progressbar', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'progressbar', { title: 'Progressbar' } ); } },141 {text: 'Address', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'address', { title: 'Address' } ); } },142 {text: 'Clear', onclick: function() { editor.execCommand( 'cherry_insert_self_immediate', false, 'clear', { title: 'Clear' } ); } },143 {text: 'Extra Wrap', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'extra_wrap', { title: 'Extra Wrap' } ); } },144 {text: 'Content Box', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'content_box', { title: 'Content Box' } ); } }145 ]},146 // Lists menu.147 {text: 'Lists', menu: [148 {text: 'Unstyled', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'list_un', { title: 'Unstyled' } ); } },149 {text: 'Check List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'check_list', { title: 'Check List' } ); } },150 {text: 'Check 2 List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'check2_list', { title: 'Check 2 List' } ); } },151 {text: 'OK Circle List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'ok_circle_list', { title: 'OK Circle List' } ); } },152 {text: 'OK Sign List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'ok_sign_list', { title: 'OK Sign List' } ); } },153 {text: 'Arrow List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'arrow_list', { title: 'Arrow List' } ); } },154 {text: 'Arrow 2 List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'arrow2_list', { title: 'Arrow 2 List' } ); } },155 {text: 'Circle Arrow List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'circle_arrow_list', { title: 'Circle Arrow List' } ); } },156 {text: 'Caret List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'caret_list', { title: 'Caret List' } ); } },157 {text: 'Angle List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'angle_list', { title: 'Angle List' } ); } },158 {text: 'Double Angle List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'double_angle_list', { title: 'Double Angle List' } ); } },159 {text: 'Star List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'star_list', { title: 'Star List' } ); } },160 {text: 'Plus List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'plus_list', { title: 'Plus List' } ); } },161 {text: 'Minus List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'minus_list', { title: 'Minus List' } ); } },162 {text: 'Circle List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'circle_list', { title: 'Circle List' } ); } },163 {text: 'Circle Blank List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'circle_blank_list', { title: 'Circle Blank List' } ); } },164 {text: 'Custom List', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'custom_list', { title: 'Custom List' } ); } }165 ]},166 // Misc menu.167 {text: 'Misc', menu: [168 {text: 'Alert Box', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'alert_box', { title: 'Alert Box' } ); } },169 {text: 'Well', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'well', { title: 'Well' } ); } },170 {text: 'Small', onclick: function() { editor.execCommand( 'cherry_insert_immediate', false, 'small', { title: 'Small' } ); } },171 {text: 'Title Box', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'title', { title: 'Title Box' } ); } },172 {text: 'Template URL', onclick: function() { editor.execCommand( 'cherry_insert_self_immediate', false, 'template_url', { title: 'Template URL' } ); } },173 {text: 'Sitemap', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'site_map', { title: 'Sitemap' } ); } }174 ]},175 {text: 'Video Preview', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'video_preview', { title: 'Video Preview' } ); } },176 {text: 'Tabs', onclick: function() { editor.execCommand( 'cherry_insert_tabs', false, 'tabs', { title: 'Tabs' } ); } },177 {text: 'Accordion', onclick: function() { editor.execCommand( 'cherry_insert_accordions', false, 'accordions', { title: 'Accordion' } ); } },178 {text: 'Table', onclick: function() { editor.execCommand( 'cherry_insert_table', false, 'table', { title: 'Table' } ); } },179 {text: 'Pricing Table', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'chp_pricing_table', { title: 'Pricing Table' } ); } },180 {text: 'Google Map', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'map', { title: 'Google Map' } ); } },181 {text: 'Google Map Api', onclick: function() { editor.execCommand( 'cherry_open_dialog', false, 'google_map_api', { title: 'Google Map Api' } ); } }182 ]183 });184 }); // TinyMCE plugin end....

Full Screen

Full Screen

quick_insert.js

Source:quick_insert.js Github

copy

Full Screen

...64 table: {65 icon: 'insertTable',66 callback: function () {67 this.quickInsert.hide();68 this.table.insert(2, 2);69 this.undo.saveStep();70 },71 requiredPlugin: 'table',72 title: 'Insert Table'73 },74 ol: {75 icon: 'formatOL',76 callback: function () {77 this.quickInsert.hide();78 this.lists.format('OL');79 this.undo.saveStep();80 },81 requiredPlugin: 'lists',82 title: 'Ordered List'...

Full Screen

Full Screen

bootstrap-wysihtml5.js

Source:bootstrap-wysihtml5.js Github

copy

Full Screen

1!function($, wysi) {2 "use strict";3 var templates = {4 "font-styles": "<li class='dropdown'>" +5 "<a class='btn dropdown-toggle' data-toggle='dropdown' href='#'>" +6 "<i class='icon-font'></i>&nbsp;<span class='current-font'>Normal text</span>&nbsp;<b class='caret'></b>" +7 "</a>" +8 "<ul class='dropdown-menu'>" +9 "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='div'>Normal text</a></li>" +10 "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h1'>Heading 1</a></li>" +11 "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h2'>Heading 2</a></li>" +12 "</ul>" +13 "</li>",14 "emphasis": "<li>" +15 "<div class='btn-group'>" +16 "<a class='btn' data-wysihtml5-command='bold' title='CTRL+B'>Bold</a>" +17 "<a class='btn' data-wysihtml5-command='italic' title='CTRL+I'>Italic</a>" +18 "<a class='btn' data-wysihtml5-command='underline' title='CTRL+U'>Underline</a>" +19 "</div>" +20 "</li>",21 "lists": "<li>" +22 "<div class='btn-group'>" +23 "<a class='btn' data-wysihtml5-command='insertUnorderedList' title='Unordered List'><i class='icon-list'></i></a>" +24 "<a class='btn' data-wysihtml5-command='insertOrderedList' title='Ordered List'><i class='icon-th-list'></i></a>" +25 "<a class='btn' data-wysihtml5-command='Outdent' title='Outdent'><i class='icon-indent-right'></i></a>" +26 "<a class='btn' data-wysihtml5-command='Indent' title='Indent'><i class='icon-indent-left'></i></a>" +27 "</div>" +28 "</li>",29 "link": "<li>" +30 "<div class='bootstrap-wysihtml5-insert-link-modal modal hide fade'>" +31 "<div class='modal-header'>" +32 "<a class='close' data-dismiss='modal'>&times;</a>" +33 "<h3>Insert Link</h3>" +34 "</div>" +35 "<div class='modal-body'>" +36 "<input value='http://' class='bootstrap-wysihtml5-insert-link-url input-xlarge'>" +37 "</div>" +38 "<div class='modal-footer'>" +39 "<a href='#' class='btn' data-dismiss='modal'>Cancel</a>" +40 "<a href='#' class='btn btn-primary' data-dismiss='modal'>Insert link</a>" +41 "</div>" +42 "</div>" +43 "<a class='btn' data-wysihtml5-command='createLink' title='Link'><i class='icon-share'></i></a>" +44 "</li>",45 "image": "<li>" +46 "<div class='bootstrap-wysihtml5-insert-image-modal modal hide fade'>" +47 "<div class='modal-header'>" +48 "<a class='close' data-dismiss='modal'>&times;</a>" +49 "<h3>Insert Image</h3>" +50 "</div>" +51 "<div class='modal-body'>" +52 "<input value='http://' class='bootstrap-wysihtml5-insert-image-url input-xlarge'>" +53 "</div>" +54 "<div class='modal-footer'>" +55 "<a href='#' class='btn' data-dismiss='modal'>Cancel</a>" +56 "<a href='#' class='btn btn-primary' data-dismiss='modal'>Insert image</a>" +57 "</div>" +58 "</div>" +59 "<a class='btn' data-wysihtml5-command='insertImage' title='Insert image'><i class='icon-picture'></i></a>" +60 "</li>",61 "html":62 "<li>" +63 "<div class='btn-group'>" +64 "<a class='btn' data-wysihtml5-action='change_view' title='Edit HTML'><i class='icon-pencil'></i></a>" +65 "</div>" +66 "</li>"67 };68 var defaultOptions = {69 "font-styles": true,70 "emphasis": true,71 "lists": true,72 "html": false,73 "link": true,74 "image": true,75 events: {},76 parserRules: {77 tags: {78 "b": {},79 "i": {},80 "br": {},81 "ol": {},82 "ul": {},83 "li": {},84 "h1": {},85 "h2": {},86 "u": 1,87 "img": {88 "check_attributes": {89 "width": "numbers",90 "alt": "alt",91 "src": "url",92 "height": "numbers"93 }94 },95 "a": {96 set_attributes: {97 target: "_blank",98 rel: "nofollow"99 },100 check_attributes: {101 href: "url" // important to avoid XSS102 }103 }104 }105 },106 stylesheets: []107 };108 var Wysihtml5 = function(el, options) {109 this.el = el;110 this.toolbar = this.createToolbar(el, options || defaultOptions);111 this.editor = this.createEditor(options);112 window.editor = this.editor;113 $('iframe.wysihtml5-sandbox').each(function(i, el){114 $(el.contentWindow).off('focus.wysihtml5').on({115 'focus.wysihtml5' : function(){116 $('li.dropdown').removeClass('open');117 }118 });119 });120 };121 Wysihtml5.prototype = {122 constructor: Wysihtml5,123 createEditor: function(options) {124 options = $.extend(defaultOptions, options || {});125 options.toolbar = this.toolbar[0];126 var editor = new wysi.Editor(this.el[0], options);127 if(options && options.events) {128 for(var eventName in options.events) {129 editor.on(eventName, options.events[eventName]);130 }131 }132 return editor;133 },134 createToolbar: function(el, options) {135 var self = this;136 var toolbar = $("<ul/>", {137 'class' : "wysihtml5-toolbar",138 'style': "display:none"139 });140 for(var key in defaultOptions) {141 var value = false;142 if(options[key] !== undefined) {143 if(options[key] === true) {144 value = true;145 }146 } else {147 value = defaultOptions[key];148 }149 if(value === true) {150 toolbar.append(templates[key]);151 if(key == "html") {152 this.initHtml(toolbar);153 }154 if(key == "link") {155 this.initInsertLink(toolbar);156 }157 if(key == "image") {158 this.initInsertImage(toolbar);159 }160 }161 }162 toolbar.find("a[data-wysihtml5-command='formatBlock']").click(function(e) {163 var el = $(e.srcElement);164 self.toolbar.find('.current-font').text(el.html());165 });166 this.el.before(toolbar);167 return toolbar;168 },169 initHtml: function(toolbar) {170 var changeViewSelector = "a[data-wysihtml5-action='change_view']";171 toolbar.find(changeViewSelector).click(function(e) {172 toolbar.find('a.btn').not(changeViewSelector).toggleClass('disabled');173 });174 },175 initInsertImage: function(toolbar) {176 var self = this;177 var insertImageModal = toolbar.find('.bootstrap-wysihtml5-insert-image-modal');178 var urlInput = insertImageModal.find('.bootstrap-wysihtml5-insert-image-url');179 var insertButton = insertImageModal.find('a.btn-primary');180 var initialValue = urlInput.val();181 var insertImage = function() {182 var url = urlInput.val();183 urlInput.val(initialValue);184 self.editor.composer.commands.exec("insertImage", url);185 };186 urlInput.keypress(function(e) {187 if(e.which == 13) {188 insertImage();189 insertImageModal.modal('hide');190 }191 });192 insertButton.click(insertImage);193 insertImageModal.on('shown', function() {194 urlInput.focus();195 });196 insertImageModal.on('hide', function() {197 self.editor.currentView.element.focus();198 });199 toolbar.find('a[data-wysihtml5-command=insertImage]').click(function() {200 insertImageModal.modal('show');201 insertImageModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {202 e.stopPropagation();203 });204 return false;205 });206 },207 initInsertLink: function(toolbar) {208 var self = this;209 var insertLinkModal = toolbar.find('.bootstrap-wysihtml5-insert-link-modal');210 var urlInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-url');211 var insertButton = insertLinkModal.find('a.btn-primary');212 var initialValue = urlInput.val();213 var insertLink = function() {214 var url = urlInput.val();215 urlInput.val(initialValue);216 self.editor.composer.commands.exec("createLink", {217 href: url,218 target: "_blank",219 rel: "nofollow"220 });221 };222 var pressedEnter = false;223 urlInput.keypress(function(e) {224 if(e.which == 13) {225 insertLink();226 insertLinkModal.modal('hide');227 }228 });229 insertButton.click(insertLink);230 insertLinkModal.on('shown', function() {231 urlInput.focus();232 });233 insertLinkModal.on('hide', function() {234 self.editor.currentView.element.focus();235 });236 toolbar.find('a[data-wysihtml5-command=createLink]').click(function() {237 insertLinkModal.modal('show');238 insertLinkModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {239 e.stopPropagation();240 });241 return false;242 });243 }244 };245 $.fn.wysihtml5 = function (options) {246 return this.each(function () {247 var $this = $(this);248 $this.data('wysihtml5', new Wysihtml5($this, options));249 });250 };251 $.fn.wysihtml5.Constructor = Wysihtml5;...

Full Screen

Full Screen

mediamanager.js

Source:mediamanager.js Github

copy

Full Screen

...23 // Focus in the editor.24 editor.events.focus(true);25 editor.selection.restore();26 // Insert the link.27 editor.html.insert('<a href="' + link + '" id="fr-inserted-file" class="fr-file">' + text + '</a>');28 // Get the file.29 var $file = editor.$el.find('#fr-inserted-file');30 $file.removeAttr('id');31 editor.undo.saveStep()32 this.hide()33 }34 })35 }36 function onInsertImage() {37 var $currentImage = editor.image.get(),38 selection = editor.selection.get(),39 range = editor.selection.ranges(0);40 new $.oc.mediaManager.popup({41 alias: 'ocmediamanager',42 cropAndInsertButton: true,43 onInsert: function(items) {44 editor.selection.clear();45 selection.addRange(range);46 47 if (!items.length) {48 $.oc.alert($.oc.lang.get('mediamanager.invalid_image_empty_insert'))49 return50 }51 var imagesInserted = 052 for (var i=0, len=items.length; i<len; i++) {53 if (items[i].documentType !== 'image') {54 $.oc.alert($.oc.lang.get('mediamanager.invalid_image_invalid_insert', 'The file "'+items[i].title+'" is not an image.'))55 continue56 }57 editor.image.insert(items[i].publicUrl, false, {}, $currentImage)58 imagesInserted++59 if (imagesInserted == 1) {60 $currentImage = null61 }62 }63 if (imagesInserted !== 0) {64 this.hide()65 editor.undo.saveStep()66 }67 }68 })69 }70 function onInsertVideo() {71 new $.oc.mediaManager.popup({...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run elementium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful