//Copy content of the file: app/code/Ves/BaseWidget/view/adminhtml/web/js/builder/widget.js if(typeof(Ves_Builder) === 'undefined') { /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ var Ves_Builder = function () { this.builder = null; this.callback = {}; this.currentCol = null; this.currentWidget = null; this.currentShortcode = ''; } var turnoffTinyMCEs = []; var getContentTinyMCEs = []; var getTinyMCEFields = []; var VesBuilder = null; var VesCallBack = {}; var VesCurrentCol = null; var VesCurrentWidget = null; var VesCurrentShortcode = ""; /*get widget type from shortcode*/ if(typeof(getWidgetTypeByShortcode) !== 'function') { function getWidgetTypeByShortcode(short_code) { var widgetType = ""; if (short_code.indexOf('{{widget') != -1) { short_code.gsub(/([a-z0-9\_]+)\s*\=\s*[\"]{1}([^\"]+)[\"]{1}/i, function(match){ if (match[1] == 'type') { widgetType = match[2]; } }); } return widgetType; } } } //Copy content of the file: app/code/Ves/BaseWidget/view/adminhtml/web/js/builder/script.js if(typeof(triggerSaveForm) === 'undefined') { var WPO_DataRow = function () { this.index = 0; this.wcls = ''; this.cls = ''; this.incls = ''; this.css = ''; this.bgcolor = ''; this.bgimage = ''; this.bgrepeat = ''; this.bgposition = ''; this.bgattachment = ''; this.padding = ''; this.margin = ''; this.nogutters = 0; this.fullwidth = 0; this.parallax = 0; this.iscontainer = 0; this.p_percent = '50%'; this.p_scroll = '0.4'; this.inbgcolor = ''; this.inbgimage = ''; this.inbgrepeat = ''; this.inbgposition = ''; this.inbgattachment = ''; this.inparallax = 0; this.inp_percent = '50%'; this.inp_scroll = '0.4'; this.sfxcls = ''; this.offcanvas = ''; } var WPO_DataCol = function () { this.index = 0; this.cols = ''; this.wcls = ''; this.cls = ''; this.incls = ''; this.css = ''; this.sfxcls = ''; this.bgcolor = ''; this.bgimage = ''; this.bgrepeat = ''; this.bgposition = ''; this.bgattachment = ''; this.padding = ''; this.margin = ''; this.inrow = 0; this.lgcol = 4; this.mdcol = 4; this.smcol = 6; this.xscol = 12; this.offcol = ''; } var WPO_DataWidget = function () { this.cls = ''; this.incls = ''; this.css = ''; this.bgcolor = ''; this.bgimage = ''; this.bgrepeat = ''; this.bgposition = ''; this.bgattachment = ''; this.padding = ''; this.margin = ''; this.sfxcls = ''; this.sfxa = ''; this.sfxaduration = ''; this.sfxadelay = ''; this.sfxaoffset = ''; this.sfxaiteration = ''; this.wtype = ''; this.wkey =''; this.shortcode = ''; this.settings = ''; this.widget = ''; this.isajax = 0; this.desktop = 1; this.tablet = 1; this.mobile = 1; this.name = ''; } var current_id_tab = 1; if(typeof(getWidgetTypeByShortcode) !== 'function') { function getWidgetTypeByShortcode(short_code) { var widgetType = ""; if (short_code.indexOf('{{widget') != -1) { short_code.gsub(/([a-z0-9\_]+)\s*\=\s*[\"]{1}([^\"]+)[\"]{1}/i, function(match){ if (match[1] == 'type') { widgetType = match[2]; } }); } return widgetType; } } function initClipboard(button_class, content_id, row) { var copyCommandSupported = document.queryCommandSupported('copy'); console.log('Copy command supported: ' + copyCommandSupported); if(jQuery( button_class, row ).length > 0) { jQuery( button_class, row ).click(function($) { if(!content_id) { content_id = "#shortcode_content"; } if(content_id == "#shortcode_content") { var shortcode = getRowShortCode(row); if( jQuery("[name=shortcode]", "#row_editshortcode").length > 0 ) { jQuery(content_id).html( shortcode ); initJSONEditor(jQuery(content_id), "#row_editshortcode"); } } var preElement = jQuery(content_id)[0]; var msg_id = ""; copyToClipboard(preElement, showSuccessMsg, msg_id); }); } } var getCacheStorage = function(storage){ if (!storage) return false; if (storage === true) return window.localStorage; if (typeof storage === "object" && 'getItem' in storage && 'removeItem' in storage && 'setItem' in storage) { return storage; } throw new TypeError("localCache must either be a boolean value, " + "or an object which implements the Storage interface."); }; var removeCacheFromStorage = function(cacheKey){ var storage = getCacheStorage(true); if(storage) { storage.removeItem(cacheKey); storage.removeItem(cacheKey + 'cachettl'); storage.removeItem(cacheKey + 'dataType'); } }; function wysiwygExists() { return (typeof tinyMCE != 'undefined'); } function getLayoutData( container ){ var clear_shortcode = arguments[1]||1; var output = new Array(); jQuery( container ).children('.inner ').children(".wpo-row").each( function(){ var _row = jQuery(this); var data = _row.data('rowcfg'); //Check row options empty data then remove it var rowsArray = new WPO_DataRow(); for( var k in rowsArray ){ if(k !="cols" && typeof(data[k]) !== "undefined" && data[k] == "" ){ delete data[k]; } }//End Check row options empty data then remove it data.cols = new Array(); jQuery(_row).children('.inner').children( '.wpo-col' ).each( function(){ var _col = jQuery(this).data('colcfg'); //Check column options empty data then remove it var colsArray = new WPO_DataCol(); for( var j in colsArray ){ if((j !="widgets" || j !="rows") && typeof(_col[j]) !== "undefined" && _col[j] == "" ){ delete _col[j]; } }//End Check column options empty data then remove it _col.widgets = new Array(); jQuery(this).children('.inner').children('.wpo-content ').children( '.wpo-ijwidget' ).each( function() { wd = jQuery(this).data("wgcfg"); //Check widget options empty data then remove it var widgetsArray = new WPO_DataWidget(); for( var i in widgetsArray ){ if(typeof(wd[i]) !== "undefined" && wd[i] == "" ){ delete wd[i]; } }//End Check widget options empty data then remove it //Remove widget shortcode if shortcode was stored in widgets array if((clear_shortcode == 1) && jQuery('#wpowidget'+wd.wkey).length > 0 && ("" != jQuery('#wpowidget'+wd.wkey).val())){ wd.shortcode = ""; }//End Remove widget shortcode if shortcode was stored in widgets array _col.widgets.push( wd ); } ); _col.rows = new Array(); if( jQuery(this).children('.inner').children( '.wpo-row' ).length > 0 ){ _col.rows = getLayoutData( this, clear_shortcode ); } data.cols.push( _col ); } ); output.push( data ); } ); return output; } function getRowShortCode( _row ) { var output = new Array(); var _row = jQuery(_row); var data = _row.data('rowcfg'); data.cols = new Array(); jQuery(_row).children('.inner').children( '.wpo-col' ).each( function(){ var _col = jQuery(this).data('colcfg'); _col.widgets = new Array(); jQuery(this).children('.inner').children('.wpo-content ').children( '.wpo-ijwidget' ).each( function() { wd = jQuery(this).data("wgcfg"); _col.widgets.push( wd ); } ); _col.rows = new Array(); if( jQuery(this).children('.inner').children( '.wpo-row' ).length > 0 ){ _col.rows = getLayoutData( this ); } data.cols.push( _col ); } ); output.push( data ); var j = JSON.stringify( output ); return j; } /** * add event triggers to operator in form of selected column and selected row */ //triggerSaveForm(); function triggerSaveForm(){ var clear_shortcode = arguments[0]||1; jQuery(".layout-builder-wrapper").each( function(){ var output = getLayoutData( jQuery(this).find(".layout-builder"), clear_shortcode ); var j = JSON.stringify( output ); jQuery(".hidden-content-layout",this).html( j ); //if(wysiwygExists()) { //tinyMCE.activeEditor.setContent( j ); //} } ); } function afterCreateWidget(shortcode, wpo_id) { //Load widget meta information var widget_type = getWidgetTypeByShortcode(shortcode); var check_widget_type = widget_type.replace(/\\/g, '/'); var available_widgets = ["Magento/Cms/Block/Widget/Block","Ves/PageBuilder/Block/Widget/Builder","Ves/BaseWidget/Block/Widget/Image","Ves/BaseWidget/Block/Widget/Html","Ves/BaseWidget/Block/Widget/Ourservice","Ves/BaseWidget/Block/Widget/ContentHtml","Ves/BaseWidget/Block/Widget/Heading"]; if(0 <= available_widgets.indexOf(check_widget_type)) { ajaxUpdateWidgetInfo(check_widget_type, shortcode, wpo_id); } //End load widget meta information } function buildWidgetHtml(shortcode) { var $widget_type = getWidgetTypeByShortcode(shortcode); var $html = ""; var $widget_info = null; if($widget_type != "") { $widget_info = getWidgetsInfo( $widget_type, shortcode ); var widget_group = "other"; var widget_code = $widget_type.replace("/","_"); var widget_icon = "other"; var widget_font_icon = ""; var widget_title = $widget_type.replace("/"," - "); var widget_description = ""; if($widget_info != null && $widget_info != "") { widget_group = $widget_info.group; widget_code = $widget_info.code; widget_icon = $widget_info.icon; widget_font_icon = $widget_info.font_icon; widget_title = $widget_info.title; widget_description = $widget_info.description; } $html = '
'; $html += '
'; $html += '
'; if(widget_font_icon) { $html += '