Best JavaScript code snippet using stryker-parent
editor-plugin-39.js
Source:editor-plugin-39.js
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....
quick_insert.js
Source:quick_insert.js
...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'...
bootstrap-wysihtml5.js
Source:bootstrap-wysihtml5.js
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> <span class='current-font'>Normal text</span> <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'>×</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'>×</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;...
mediamanager.js
Source:mediamanager.js
...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({...
bootstrap-wysihtml5-0.0.2.js
Source:bootstrap-wysihtml5-0.0.2.js
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> <span class='current-font'>Normal text</span> <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'><i class='icon-bold'></i></a>"17 + "<a class='btn' data-wysihtml5-command='italic' title='CTRL+I'><i class='icon-italic'></i></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'>Ã</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'>Ã</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 };107 var Wysihtml5 = function(el, options) {108 this.el = el;109 this.toolbar = this.createToolbar(el, options || defaultOptions);110 this.editor = this.createEditor(options);111 window.editor = this.editor;112 $('iframe.wysihtml5-sandbox').each(function(i, el){113 $(el.contentWindow).off('focus.wysihtml5').on({114 'focus.wysihtml5' : function(){115 $('li.dropdown').removeClass('open');116 }117 });118 });119 };120 Wysihtml5.prototype = {121 constructor: Wysihtml5,122 createEditor: function(options) {123 var parserRules = defaultOptions.parserRules;124 if(options && options.parserRules) {125 parserRules = options.parserRules;126 }127 var editor = new wysi.Editor(this.el.attr('id'), {128 toolbar: this.toolbar.attr('id'),129 parserRules: parserRules130 });131 if(options && options.events) {132 for(var eventName in options.events) {133 editor.on(eventName, options.events[eventName]);134 }135 }136 return editor;137 },138 createToolbar: function(el, options) {139 var self = this;140 var toolbar = $("<ul/>", {141 'id' : el.attr('id') + "-wysihtml5-toolbar",142 'class' : "wysihtml5-toolbar",143 'style': "display:none"144 });145 for(var key in defaultOptions) {146 var value = false;147 if(options[key] != undefined) {148 if(options[key] == true) {149 value = true;150 }151 } else {152 value = defaultOptions[key];153 }154 if(value == true) {155 toolbar.append(templates[key]);156 if(key == "html") {157 this.initHtml(toolbar);158 }159 if(key == "link") {160 this.initInsertLink(toolbar);161 }162 if(key == "image") {163 this.initInsertImage(toolbar);164 }165 }166 }167 var self = this;168 toolbar.find("a[data-wysihtml5-command='formatBlock']").click(function(e) {169 var el = $(e.srcElement);170 self.toolbar.find('.current-font').text(el.html())171 });172 this.el.before(toolbar);173 return toolbar;174 },175 initHtml: function(toolbar) {176 var changeViewSelector = "a[data-wysihtml5-action='change_view']";177 toolbar.find(changeViewSelector).click(function(e) {178 toolbar.find('a.btn').not(changeViewSelector).toggleClass('disabled');179 });180 },181 initInsertImage: function(toolbar) {182 var self = this;183 var insertImageModal = toolbar.find('.bootstrap-wysihtml5-insert-image-modal');184 var urlInput = insertImageModal.find('.bootstrap-wysihtml5-insert-image-url');185 var insertButton = insertImageModal.find('a.btn-primary');186 var initialValue = urlInput.val();187 var insertImage = function() {188 var url = urlInput.val();189 urlInput.val(initialValue);190 self.editor.composer.commands.exec("insertImage", url);191 };192 urlInput.keypress(function(e) {193 if(e.which == 13) {194 insertImage();195 insertImageModal.modal('hide');196 }197 });198 insertButton.click(insertImage);199 insertImageModal.on('shown', function() {200 urlInput.focus();201 });202 insertImageModal.on('hide', function() {203 self.editor.currentView.element.focus();204 });205 toolbar.find('a[data-wysihtml5-command=insertImage]').click(function() {206 insertImageModal.modal('show');207 });208 },209 initInsertLink: function(toolbar) {210 var self = this;211 var insertLinkModal = toolbar.find('.bootstrap-wysihtml5-insert-link-modal');212 var urlInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-url');213 var insertButton = insertLinkModal.find('a.btn-primary');214 var initialValue = urlInput.val();215 var insertLink = function() {216 var url = urlInput.val();217 urlInput.val(initialValue);218 self.editor.composer.commands.exec("createLink", {219 href: url,220 target: "_blank",221 rel: "nofollow"222 });223 };224 var pressedEnter = false;225 urlInput.keypress(function(e) {226 if(e.which == 13) {227 insertLink();228 insertLinkModal.modal('hide');229 }230 });231 insertButton.click(insertLink);232 insertLinkModal.on('shown', function() {233 urlInput.focus();234 });235 insertLinkModal.on('hide', function() {236 self.editor.currentView.element.focus();237 });238 toolbar.find('a[data-wysihtml5-command=createLink]').click(function() {239 insertLinkModal.modal('show');240 });241 }242 };243 $.fn.wysihtml5 = function (options) {244 return this.each(function () {245 var $this = $(this);246 $this.data('wysihtml5', new Wysihtml5($this, options));247 })248 };249 $.fn.wysihtml5.Constructor = Wysihtml5;...
config.js
Source:config.js
1/**2 * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.3 * For licensing, see LICENSE.md or http://ckeditor.com/license4 */5CKEDITOR.editorConfig = function( config ) {6 config.allowedContent = true; // To disable CKEditor ACF7 config.enterMode = CKEDITOR.ENTER_BR;8 config.shiftEnterMode = CKEDITOR.ENTER_P;9 config.entities_latin = false;10 var sourceName = config.useInlineMode ? 'Sourcedialog' : 'Source';11 config.toolbar_Standard = config.toolbar_Default =12 [13 [sourceName, '-'],14 ['Undo', 'Redo', '-'],15 ['Bold', 'Italic', 'Underline', 'TextColor', '-'],16 ['Styles'],17 ['NumberedList', 'BulletedList', 'Outdent', 'Indent', '-'],18 ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-'],19 ['InsertLink', 'Unlink', '-'],20 ['InsertImageOrMedia', 'QuicklyInsertImage', 'Table', 'InsertWidget', 'InsertMacro', '-'],21 ['Maximize']22 ];23 config.toolbar_Full = [24 [sourceName, '-'],25 ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', 'Scayt', '-'],26 ['Undo', 'Redo', 'Find', 'Replace', 'RemoveFormat', '-'],27 ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-'],28 ['NumberedList', 'BulletedList', 'Outdent', 'Indent', 'Blockquote', 'CreateDiv', '-'],29 ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-'],30 '/',31 ['InsertLink', 'Unlink', 'Anchor', '-'],32 ['InsertImageOrMedia', 'QuicklyInsertImage', 'Table', 'HorizontalRule', 'SpecialChar', '-'],33 ['InsertForms', 'InsertPolls', 'InsertRating', 'InsertYouTubeVideo', 'InsertWidget', '-'],34 ['Styles', 'Format', 'Font', 'FontSize'],35 ['TextColor', 'BGColor', '-'],36 ['InsertMacro', '-'],37 ['Maximize', 'ShowBlocks']38 ];39 config.toolbar_Basic = [40 ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'InsertLink', 'Unlink']41 ];42 config.toolbar_BizForm = [43 ['Source', '-'],44 ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-'],45 ['Undo', 'Redo', 'Find', 'Replace', 'RemoveFormat', '-'],46 ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-'],47 ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-'],48 ['NumberedList', 'BulletedList', 'Outdent', 'Indent', '-'],49 ['InsertLink', 'Unlink', 'Anchor', '-'],50 ['InsertImageOrMedia', 'Table', 'HorizontalRule', 'SpecialChar', '-'],51 ['Styles', 'Format', 'Font', 'FontSize'],52 ['TextColor', 'BGColor', '-'],53 ['InsertMacro', '-'],54 ['Maximize']55 ];56 config.toolbar_Forum = [57 ['Bold', 'Italic', '-', 'InsertLink', 'InsertUrl', 'InsertImageOrMedia', 'InsertImage', 'InsertQuote', '-', 'NumberedList', 'BulletedList', '-', 'TextColor', 'BGColor']58 ];59 config.toolbar_Reporting = [60 ['Source', '-'],61 ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-'],62 ['Undo', 'Redo', 'Find', 'Replace', 'RemoveFormat', '-'],63 ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-'],64 ['NumberedList', 'BulletedList', 'Outdent', 'Indent', '-'],65 ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-'],66 ['InsertLink', 'Unlink', 'Anchor', '-'],67 ['InsertImageOrMedia', 'QuicklyInsertImage', 'Table', 'HorizontalRule', 'SpecialChar', '-'],68 ['Styles', 'Format', 'Font', 'FontSize'],69 ['TextColor', 'BGColor', '-'],70 ['InsertMacro', '-'],71 ['Maximize']72 ];73 config.toolbar_SimpleEdit = [74 ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-'],75 ['Undo', 'Redo', 'Find', 'Replace', 'RemoveFormat', '-'],76 ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-'],77 ['NumberedList', 'BulletedList', 'Outdent', 'Indent', '-'],78 ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-'],79 ['InsertLink', 'Unlink', 'Anchor', '-'],80 ['InsertImageOrMedia', 'QuicklyInsertImage', 'Table', 'HorizontalRule', 'SpecialChar', '-'],81 ['Styles', 'Format', 'Font', 'FontSize'],82 ['TextColor', 'BGColor', '-'],83 ['Maximize']84 ];85 config.toolbar_Invoice = [86 ['Source', '-'],87 ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', 'Scayt', '-'],88 ['Undo', 'Redo', 'Find', 'Replace', 'RemoveFormat', '-'],89 ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-'],90 ['NumberedList', 'BulletedList', 'Outdent', 'Indent', 'Blockquote', 'CreateDiv', '-'],91 ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-'],92 ['InsertImageOrMedia', 'Table', 'HorizontalRule', 'SpecialChar', '-'],93 ['Styles', 'Format', 'Font', 'FontSize'],94 ['TextColor', 'BGColor', '-'],95 ['InsertMacro', '-'],96 ['Maximize', 'ShowBlocks']97 ];98 config.toolbar_Group = [99 ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'InsertLink', 'Unlink', 'InsertGroupPolls']100 ];101 config.toolbar_Widgets = [102 ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'InsertLink', 'Unlink', 'InsertImageOrMedia', '-'],103 ['Format', 'Font', 'FontSize'],104 ['TextColor', 'BGColor']105 ];106 107 config.toolbar_EmailWidgets = [108 ['Bold', 'Italic', 'Underline', '-', 'NumberedList', 'BulletedList', '-', 'PasteText', 'PasteFromWord', '-', 'InsertMacro', '-']109 ];110 config.toolbar_Consents_ShortText = [111 ['Source', '-', 'Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'InsertLink', 'Unlink', '-', 'PasteText', 'PasteFromWord']112 ];113 config.toolbar_Consents_FullText = [114 ['Source', '-', 'Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'InsertLink', 'Unlink', '-', 'PasteText', 'PasteFromWord'],115 ['Styles', 'Format', 'Font', 'FontSize'],116 ['TextColor', 'BGColor', '-']117 ];118 config.toolbar_Disabled = [119 ['Maximize']120 ];121 config.toolbar = config.toolbar_Standard;122 config.scayt_customerid = '1:vhwPv1-GjUlu4-PiZbR3-lgyTz1-uLT5t-9hGBg2-rs6zY-qWz4Z3-ujfLE3-lheru4-Zzxzv-kq4';...
collection-mocks.js
Source:collection-mocks.js
1/**2 * @summary The mock collection variable. A null collection used to mock the results of a db operation3 */4var mockCollection = new Mongo.Collection(null);5/**6 * @summary The mock method. It is applied to the Mongo.Collection prototype and mocks the results of a db operation7 * @locus Anywhere8 * @method mock9 * @memberOf Mongo.Collection10 * @param {Object | Array} insert An array of arguments to be passed to the mockCollection's insert method11 * @param {Object | Array} update An array of arguments to be passed to the mockCollection's update method12 * @param {Object | Array} find An array of arguments to be passed to the mockCollection's findOne method13 * @return {Object} The result of findOne14 */15Mongo.Collection.prototype.mock = function (insert, update, find) {16 var self = this;17 // clear out the mock collection in case any previous calls failed to clean18 // up after themselves19 mockCollection.remove({});20 21 // if the user doesn't pass an insert argument, lets try to find the document22 // they're trying to update by searching the real collection (self)23 if (! insert) {24 if (! _.isArray(update))25 throw new Error("implicit insert requires two update arguments");26 insert = self.findOne(update[0]);27 }28 29 // insert is actually the array of arguments to be passed to the30 // insert method, but we don't want to force users to call mock with31 // an array if they don't want to32 if (! _.isArray(insert)) {33 insert = [insert];34 }35 // insert the document into the mock collection36 var insertResult;37 if (insert && insert[0])38 insertResult = mockCollection.insert.apply(mockCollection, insert);39 // just like insert, update is the array of arguments that we pass to the40 // update method; we use the insertResult document as the query selector41 if (update) {42 if (! _.isArray(update)) {43 update = [insertResult, update];44 }45 /*var updateResult = */mockCollection.update.apply(mockCollection, update);46 }47 // use the document we just inserted if no find argument exists48 if (! find) find = insertResult;49 // Make sure we pass an array to findOne50 if (! _.isArray(find)) {51 find = [find];52 }53 // find the document in the mock collection54 var findResult = mockCollection.findOne.apply(mockCollection, find);55 // return the results of the findOne method56 return findResult;57};58/**59 * @summary The mockMulti method. It differs from mock in that the insert operation accepts an array, and the find operation returns find().fetch()60 * @locus Anywhere61 * @method mockMulti62 * @memberOf Mongo.Collection63 * @param {Array} insert An array of arguments to be passed to the mockCollection's insert method64 * @param {Object | Array} update An array of arguments to be passed to the mockCollection's update method65 * @param {Object} flags An object to be passed to the mockCollection's update method (e.g. { multi: true })66 * @param {Object | Array} find An array of arguments to be passed to the mockCollection's find method67 * @return {Object} The result of findOne68 */69// XXX should we merge mockMulti with mock since there is a lot of overlapping code?70Mongo.Collection.prototype.mockMulti = function (insert, update, find) {71 var self = this;72 // clear out the mock collection in case any previous calls failed to clean73 // up after themselves74 mockCollection.remove({});75 76 // if the user doesn't pass an insert argument, lets try to find the document77 // they're trying to update by searching the real collection (self)78 if (! insert) {79 if (! _.isArray(update))80 throw new Error("implicit insert requires two update arguments");81 insert = self.find(update[0]).fetch();82 }83 84 // insert is actually the array of arguments to be passed to the85 // insert method, but we don't want to force users to call mock with86 // an array if they don't want to87 if (! _.isArray(insert)) {88 insert = [insert];89 }90 // insert the documents into the mock collection91 var insertResults = [];92 if (insert && insert[0]) {93 // bulk insert does not work in meteor so we need to save all the inserted documents94 _.each(insert, function(args) {95 if (!_.isArray(args))96 args = [args];97 insertResults.push(mockCollection.insert.apply(mockCollection, args));98 });99 }100 // since there are more than 1 documents inserted we will use the $in operator to construct our selector101 var insertResult = { _id: { $in: insertResults } };102 // just like insert, update is the array of arguments that we pass to the103 // update method; we use the insertResults array as the query selector104 if (update) {105 if (! _.isArray(update)) {106 throw new Error("mockMulti requires an array for the update argument");107 }108 mockCollection.update.apply(mockCollection, update);109 }110 // use the document we just inserted if no find argument exists111 if (! find) find = insertResult;112 // Make sure we pass an array to find113 if (! _.isArray(find)) {114 find = [find];115 }116 // find the document in the mock collection117 var findResult = mockCollection.find.apply(mockCollection, find).fetch();118 // return the fetched results119 return findResult;...
index.js
Source:index.js
1"use strict";2const _ = require('lodash');3const fs = require('fs');4const Promise = require('bluebird');5const createTable = require('./source/createTableScriptGenerator');6const cleanUp = require('./source/cleanUpScriptGenerator');7const insertLocation = require('./source/generateLocationScriptGenerator');8const insertUser = require('./source/generateUsersScriptGenerator');9const insertOrganization = require('./source/generateOrganizationScriptGenerator');10const insertConversation = require('./source/generateConversationScriptGenerator');11const insertWall = require('./source/generateWallScriptGenerator');12const insertPartOf = require('./source/generatePartOfScriptGenerator');13const insertComment = require('./source/generateCommentScriptGenerator');14const insertPost = require('./source/generatePostScriptGenerator');15const insertFollow = require('./source/generateFollowScriptGenerator');16const insertMessage = require('./source/generateMessageScriptGenerator');17const insertCommentReaction = require('./source/generateCommentReactionScriptGenerator');18const insertPostReaction = require('./source/generatePostReactionScriptGenerator');19const insertWorkPeriod = require('./source/generateWorkPeriodGenerator');20const insertStudyPeriod = require('./source/generateStudyPeriodGenerator');21const cleanCreateDatabase = require('./source/generateCleanDatabaseGenerator');22const cleanSequence = require('./source/generateCleanSequenceGenerator');23const tables = require('./tableSchema');24console.log('Set ok')25const init_cache = () => {26 let cache = {};27 _.forEach(_.keys(tables), (key) => {28 cache[key] = {};29 })30 return cache;31}32let cache = init_cache();33let fileStream = fs.createWriteStream('../datagenerated.sql');34cleanCreateDatabase(fileStream, '', cache)35 .then(()=>insertLocation(fileStream, 'location', cache))36 .then(() => insertUser(fileStream, 'users', cache))37 .then(() => insertOrganization(fileStream, 'organization', cache))38 .then(() => insertConversation(fileStream, 'conversation', cache))39 .then(() => insertWall(fileStream, 'wall', cache))40 .then(() => insertPartOf(fileStream, 'partof', cache))41 .then(() => insertPost(fileStream, 'post', cache))42 .then(() => insertComment(fileStream, 'comment', cache))43 .then(() => insertFollow(fileStream, 'follows', cache))44 .then(() => insertMessage(fileStream, 'message', cache))45 .then(() => insertCommentReaction(fileStream, 'commentreaction', cache))46 .then(() => insertPostReaction(fileStream, 'postreaction', cache))47 .then(() => insertWorkPeriod(fileStream, 'workperiod', cache))48 .then(() => insertStudyPeriod(fileStream, 'studyperiod', cache))...
Using AI Code Generation
1var strykerParent = require('stryker-parent');2var strykerChild = require('stryker-child');3var strykerChild2 = require('stryker-child2');4var strykerChild3 = require('stryker-child3');5var strykerChild4 = require('stryker-child4');6var stryker = require('stryker');7var strykerChild = require('stryker-child');8var strykerChild2 = require('stryker-child2');9var strykerChild3 = require('stryker-child3');10var strykerChild4 = require('stryker-child4');11var strykerChild5 = require('stryker-child5');12var strykerChild6 = require('stryker-child6');13var strykerChild7 = require('stryker-child7');14var strykerChild8 = require('stryker-child8');15var strykerChild9 = require('stryker-child9');16var strykerChild10 = require('stryker-child10');17var strykerChild11 = require('stryker-child11');18var strykerChild12 = require('stryker-child12');19var strykerChild13 = require('stryker-child13');20var strykerChild14 = require('stryker-child14');21var strykerChild15 = require('stryker-child15');
Using AI Code Generation
1var strykerParent = require('stryker-parent');2strykerParent.insert('test.js');3var strykerParent = require('stryker-parent');4strykerParent.insert('test.js');5var strykerParent = require('stryker-parent');6strykerParent.insert('test.js');7var strykerParent = require('stryker-parent');8strykerParent.insert('test.js');9var strykerParent = require('stryker-parent');10strykerParent.insert('test.js');11var strykerParent = require('stryker-parent');12strykerParent.insert('test.js');13var strykerParent = require('stryker-parent');14strykerParent.insert('test.js');15var strykerParent = require('stryker-parent');16strykerParent.insert('test.js');17var strykerParent = require('stryker-parent');18strykerParent.insert('test.js');19var strykerParent = require('stryker-parent');20strykerParent.insert('test.js');21var strykerParent = require('stryker-parent');22strykerParent.insert('test.js');23var strykerParent = require('stryker-parent');24strykerParent.insert('test.js');25var strykerParent = require('stryker-parent');26strykerParent.insert('test.js');
Using AI Code Generation
1var strykerParent = require('stryker-parent');2var strykerParent = new strykerParent();3strykerParent.insert('test');4var strykerParent = require('stryker-parent');5var strykerParent = new strykerParent();6strykerParent.insert('test');7var strykerParent = require('stryker-parent');8var strykerParent = new strykerParent();9strykerParent.insert('test');10var strykerParent = require('stryker-parent');11var strykerParent = new strykerParent();12strykerParent.insert('test');13var strykerParent = require('stryker-parent');14var strykerParent = new strykerParent();15strykerParent.insert('test');16var strykerParent = require('stryker-parent');17var strykerParent = new strykerParent();18strykerParent.insert('test');19var strykerParent = require('stryker-parent');20var strykerParent = new strykerParent();21strykerParent.insert('test');22var strykerParent = require('stryker-parent');23var strykerParent = new strykerParent();24strykerParent.insert('test');25var strykerParent = require('stryker-parent');26var strykerParent = new strykerParent();27strykerParent.insert('test');28var strykerParent = require('stryker-parent');29var strykerParent = new strykerParent();30strykerParent.insert('test');31var strykerParent = require('stry
Using AI Code Generation
1var strykerParent = require('stryker-parent');2var strykerParent = new strykerParent();3strykerParent.insert('test');4var strykerParent = require('stryker-parent');5var strykerParent = new strykerParent();6strykerParent.insert('test');7var strykerParent = require('stryker-parent');8var strykerParent = new strykerParent();9strykerParent.insert('test');10var strykerParent = require('stryker-parent');11var strykerParent = new strykerParent();12strykerParent.insert('test');13var strykerParent = require('stryker-parent');14var strykerParent = new strykerParent();15strykerParent.insert('test');16var strykerParent = require 'stryker-parent');17var strykerParent = new strykerParent();18strykerParent.insert('test');19var strykerParent = require('stryker-parent');20var strykerParent = new strykerParent();21strykerParent.insert('test');22var strykerParent = require('stryker-parent');23var strykerParent = new strykerParent();24strykerParent.insert('test');25var strykerParent = require('stryker-parent');26var strykerParent = new strykerParent();27strykerParent.insert('test');28var strykerParent = require('stryker-parent');29var strykerParent = new strykerParent();30strykerParent.insert('test');31var strykerParent = require('stry
Using AI Code Generation
1parent.insert(1, 2, 3);2child.insert(1, 2, 3);3parent.insert(1, 2, 3);4child.insert(1, 2, 3);5parent.insert(1, 2, 3);6child.insert(1, 2, 3);
Using AI Code Generation
1var strykerParent = require('stryker-parent');2var stryker = new strykerParent();3stryker.insert('test', function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var strykerParent = require('stryker-parent');11var stryker = new strykerParent();12stryker.read('test', function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19var strykerParent = require('stryker-parent');20var stryker = new strykerParent();21var update = {22};23stryker.update('test', update, function(err, data) {24 if (err) {25 console.log(err);26 } else {27 console.log(data);28 }29});30var strykerParent = require('stryrt method of stryker-parent31parent.insert(1, 2, 3);32child.insert(1, 2, 3);33parent.insert(1, 2, 3);34child.insert(1, 2, 3);35parent.insert(1, 2, 3);36child.insert(1, 2, 3);37parent.insert(1, 2, 3);38child.insert(1, 2, 3);39parent.insert(1, 2, 3);40child.insert(1, 2, 3);41parent.insert(1, 2, 3);42child.insert(1, 2, 3);43parent.insert(1, 2, 3);44child.insert(1, 2,
Using AI Code Generation
1var strykerParent = require('stryker-parent');2var stryker = new strykerParent();3stryker.insert('test', function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var strykerParent = require('stryker-parent');11var stryker = new strykerParent();12stryker.read('test', function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19var strykerParent = require('stryker-parent');20var stryker = new strykerParent();21var update = {22};23stryker.update('test', update, function(err, data) {24 if (err) {25 console.log(err);26 } else {27 console.log(data);28 }29});30var strykerParent = require('stry
Using AI Code Generation
1var strykerParent = require('stryker-parent');2var strykerParent = new strykerParent();3strykerParent.insert('test', 'test', function (err, result) {4 if (err) {5 console.log(err);6 } else {7 console.log(result);8 }9});10var strykerParent = require('stryker-parent');11var strykerParent = new strykerParent();12strykerParent.update('test', 'test', function (err, result) {13 if (err) {14 console.log(err);15 } else {16 console.log(result);17 }18});19var strykerParent = require('stryker-parent');20var strykerParent = new strykerParent();21strykerParent.delete('test', function (err, result) {22 if (err) {23 console.log(err);24 } else {25 console.log(result);26 }27});28var strykerParent = require('stryker-parent');29var strykerParent = new strykerParent();30strykerParent.find('test', function (err, result) {31 if (err) {32 console.log(err);33 } else {34 console.log(result);35 }36});37var strykerParent = require('stryker-parent');38var strykerParent = new strykerParent();39strykerParent.findall('test', function (err, result) {40 if (err) {41 console.log(err);42 } else {43 console.log(result);44 }45});46var strykerParent = require('stryker-parent');47var strykerParent = new strykerParent();48strykerParent.findall('test', function (err, result) {49 if (err) {50 console.log(err);51 } else {52 console.log(result);53 }54});55var strykerParent = require('stryker-parent');
Using AI Code Generation
1var parent = require('stryker-parent');2var parentObj = new parent();3parentObj.insert('test', 'test');4var child = require('stryker-child');5var childObj = new child();6childObj.insert('test', 'test');7var child = require('stryker-child');8var childObj = new child();9childObj.insert('test', 'test');10var child = require('stryker-child');11var childObj = new child();12childObj.insert('test', 'test');13var child = require('stryker-child');14var childObj = new child();15childObj.insert('test', 'test');16var child = require('stryker-child');17var childObj = new child();18childObj.insert('test', 'test');19var child = require('stryker-child');20var childObj = new child();21childObj.insert('test', 'test');22var child = require('stryker-child');23var childObj = new child();24childObj.insert('test', 'test');25var child = require('stryker-child');26var childObj = new child();27childObj.insert('test', 'test');28var child = require('stryker-child');29var childObj = new child();30childObj.insert('test', 'test');31var child = require('stryker-child');32var childObj = new child();33childObj.insert('test', 'test');34var child = require('stryker-child');35var childObj = new child();36childObj.insert('test', 'test');
Using AI Code Generation
1var stryker = require('stryker-parent');2var stryker = new stryker();3stryker.insert('localhost', 27017, 'test', 'test', {a: 1}, function(err, result) {4 if (err) {5 console.log(err);6 } else {7 console.log(result);8 }9});10var stryker = require('stryker-parent');11var stryker = new stryker();12var query = {a: 1};13var update = {$set: {a: 2}};14stryker.update('localhost', 27017, 'test', 'test', query, update, function(err, result) {15 if (err) {16 console.log(err);17 } else {18 console.log(result);19 }20});21var stryker = require('stryker-parent');22var stryker = new stryker();23var query = {a: 1};24stryker.remove('localhost', 27017, 'test', 'test', query, function(err, result) {25 if (err) {26 console.log(err);27 } else {28 console.log(result);29 }30});31var stryker = require('stryker-parent');32var stryker = new stryker();33var query = {a: 1};34stryker.find('localhost', 27017, 'test', 'test', query, function(err, result) {35 if (err) {36 console.log(err);37 } else {38 console.log(result);39 }40});
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!