AntonLV 10 anos atrás
pai
commit
7e881097e4

+ 9 - 2
inc/js/jquery.dolPopup.js

@@ -200,7 +200,11 @@
                 }
                 
                 setTimeout(function () {
-                    o.onShow($el);                    
+                	if(typeof(o.onShow) == 'function')
+                		o.onShow($el);
+                    else if(typeof(o.onShow) == 'string')
+                    	eval(o.onShow);
+
                     $el.find('input[type=text]:first').focus(); // put cursor to the first input element
                 }, o.speed);
 
@@ -266,7 +270,10 @@
             $(window).off('resize.popupPointer');
             $(window).off('resize.popupFog');
 
-            o.onBeforeHide($el);
+            if(typeof(o.onBeforeHide) == 'function')
+            	o.onBeforeHide($el);
+            else if(typeof(o.onBeforeHide) == 'string')
+            	eval(o.onBeforeHide);
 
             $el.removeClass('bx-popup-active').addClass('bx-popup-inactive');
 

+ 11 - 0
studio/js/builder_page.js

@@ -178,6 +178,17 @@ BxDolStudioBuilderPage.prototype.onChangeVisibleFor = function(oSelect) {
 	$(oSelect).parents('form:first').find('#bx-form-element-visible_for_levels').bx_anim($(oSelect).val() == 'all' ? 'hide' : 'show', this.sAnimationEffect, this.iAnimationSpeed);
 };
 
+BxDolStudioBuilderPage.prototype.onEditBlockBeforeShow = function(oPopup) {
+	var oContentEditor = CodeMirror.fromTextArea($(oPopup).find("textarea[name = 'content']").get(0), {
+        lineNumbers: true,
+        mode: "htmlmixed",
+        htmlMode: true,
+        matchBrackets: true
+    }).on('blur', function(oEditor) {
+    	oEditor.save();
+    });
+};
+
 BxDolStudioBuilderPage.prototype.onEditBlock = function(oData) {
 	window.location.href = this.parsePageUrl({page: this.sPage});
 };

+ 20 - 10
studio/js/page.js

@@ -10,6 +10,13 @@ function BxDolStudioPage(oOptions) {
     this.sObjName = oOptions.sObjName == undefined ? 'oBxDolStudioPage' : oOptions.sObjName;
     this.sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'slide' : oOptions.sAnimationEffect;
     this.iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
+    this.oPopupOptions = {
+		fog: {
+			color: '#fff',
+			opacity: .7
+	    },
+	    closeOnOuterClick: false
+    };
 }
 
 BxDolStudioPage.prototype.processJson = function (oData) {
@@ -23,16 +30,19 @@ BxDolStudioPage.prototype.processJson = function (oData) {
 
     //--- Show Popup
     if(oData && oData.popup != undefined) {
-    	var oPopup = $(oData.popup).hide(); 
-
-    	$('#' + oPopup.attr('id')).remove();
-        oPopup.prependTo('body').dolPopup({
-            fog: {
-				color: '#fff',
-				opacity: .7
-            },
-            closeOnOuterClick: false
-        });
+    	if (typeof(oData.popup) == 'object') {
+    		var oPopup = $(oData.popup.html).hide(); 
+    		var oPopupOptions = $.extend({}, this.oPopupOptions, oData.popup.options);
+
+	    	$('#' + oPopup.attr('id')).remove();
+	        oPopup.prependTo('body').dolPopup(oPopupOptions);
+    	}
+    	else {
+	    	var oPopup = $(oData.popup).hide(); 
+	
+	    	$('#' + oPopup.attr('id')).remove();
+	        oPopup.prependTo('body').dolPopup(this.oPopupOptions);
+    	}
     }
 
     //--- Evaluate JS code

+ 12 - 7
studio/template/scripts/BxBaseStudioBuilderPage.php

@@ -73,12 +73,17 @@ class BxBaseStudioBuilderPage extends BxDolStudioBuilderPage
 				$oUploader->addCssJs();
 		}
 
-        return array_merge(parent::getPageCss(), array('page_layouts.css', 'builder_page.css'));
+        return array_merge(parent::getPageCss(), array(
+        	BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'codemirror/|codemirror.css',
+        	'page_layouts.css', 
+        	'builder_page.css'
+        ));
     }
 
     function getPageJs()
     {
         return array_merge(parent::getPageJs(), array(
+        	'codemirror/codemirror.min.js',
             'jquery-ui/jquery.ui.core.min.js',
             'jquery-ui/jquery.ui.widget.min.js',
             'jquery-ui/jquery.ui.mouse.min.js',
@@ -683,7 +688,7 @@ class BxBaseStudioBuilderPage extends BxDolStudioBuilderPage
                     ),
                     'required' => '0',
                     'attrs' => array(
-                        'onchange' => $this->getPageJsObject() . '.onChangeVisibleFor(this)'
+                        'onchange' => $sJsObject . '.onChangeVisibleFor(this)'
                     ),
                     'db' => array (
                         'pass' => 'Xss',
@@ -720,14 +725,14 @@ class BxBaseStudioBuilderPage extends BxDolStudioBuilderPage
                     array(
                         'type' => 'submit',
                         'name' => 'do_submit',
-                        'value' => _t('_adm_bp_btn_block_save'),
+                        'value' => _t('_adm_bp_btn_block_save')
                     ),
                     array (
                         'type' => 'reset',
                         'name' => 'close',
                         'value' => _t('_adm_bp_btn_block_cancel'),
                         'attrs' => array(
-                            'onclick' => $this->getPageJsObject() . '.onEditBlockCancel(this)',
+                            'onclick' => $sJsObject . '.onEditBlockCancel(this)',
                             'class' => 'bx-def-margin-sec-left',
                         ),
                     )
@@ -750,7 +755,7 @@ class BxBaseStudioBuilderPage extends BxDolStudioBuilderPage
                 'name' => 'close',
                 'value' => _t('_adm_bp_btn_block_delete'),
                 'attrs' => array(
-                    'onclick' => $this->getPageJsObject() . ".deleteBlock(" . $aBlock['id'] . ")",
+                    'onclick' => $sJsObject . '.deleteBlock(' . $aBlock['id'] . ')',
                     'class' => 'bx-def-margin-sec-left',
                 ),
             );
@@ -773,7 +778,7 @@ class BxBaseStudioBuilderPage extends BxDolStudioBuilderPage
             'form' => $oForm->getCode(true)
         )));
 
-        return array('popup' => $sContent);
+        return array('popup' => array('html' => $sContent, 'options' => array('onBeforeShow' => $sJsObject . '.onEditBlockBeforeShow($el)')));
     }
 
     protected function actionBlockDelete()
@@ -1272,7 +1277,7 @@ class BxBaseStudioBuilderPage extends BxDolStudioBuilderPage
                         'required' => '0',
                 		'code' => 1,
                         'db' => array (
-                            'pass' => 'Xss',
+                            'pass' => 'XssHtml',
                         ),
                     ),
                 );