Cerothen 8 anni fa
parent
commit
165604413e
2 ha cambiato i file con 8 aggiunte e 20 eliminazioni
  1. 4 9
      functions.php
  2. 4 11
      settings.php

+ 4 - 9
functions.php

@@ -1578,10 +1578,12 @@ function buildSettings($array) {
 				var newVals = {};
 				var hasVals = false;
 				var errorFields = [];
-				$(\'#'.$pageID.'_form\').find(\'[data-changed=true]\').each(function() {
+				$(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').each(function() {
 					hasVals = true;
 					if (this.type == \'checkbox\') {
 						newVals[this.name] = this.checked;
+					} else if ($(this).hasClass(\'summernote\')) {
+						newVals[$(this).attr(\'name\')] = $(this).siblings(\'.note-editor\').find(\'.panel-body\').html();
 					} else {
 						if (this.value && this.pattern && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { errorFields.push(this.name); }
 						var fieldVal = $(this).val();
@@ -1593,13 +1595,6 @@ function buildSettings($array) {
 							}
 						}
 						newVals[this.name] = fieldVal;
-        if ( $( ".note-editable panel-body" ).length ) {
-
-            newVals["homepageNoticeMessage"] = $( ".note-editable panel-body" ).html();
-            console.log("gothomepage");
-        }else{
-            console.log("not set homepage");
-        }
 					}
 				});
 				if (errorFields.length) {
@@ -1607,7 +1602,7 @@ function buildSettings($array) {
 				} else if (hasVals) {
 					console.log(newVals);
 					ajax_request(\'POST\', \''.(isset($array['submitAction'])?$array['submitAction']:'update-config').'\', newVals, function(data, code) {
-						$(\'#'.$pageID.'_form\').find(\'[data-changed=true]\').removeAttr(\'data-changed\');
+						$(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').removeAttr(\'data-changed\');
 					});
 				} else {
 					parent.notify(\'Nothing to update!\', \'bullhorn\', \'success\', 5000, \'bar\', \'slidetop\');

+ 4 - 11
settings.php

@@ -1123,7 +1123,7 @@ echo buildSettings(
 					),*/
         array(
 						'type' => 'custom',
-						'html' => '<div id="summernote">'.HOMEPAGENOTICEMESSAGE.'</div>',
+						'html' => '<div class="summernote" name="homepageNoticeMessage">'.HOMEPAGENOTICEMESSAGE.'</div>',
 					),
 				),
 			),
@@ -2241,12 +2241,7 @@ echo buildSettings(
 
             $(function () {
                 
-                $('#summernote').summernote({
-                    callbacks: {
-                        onChange: function(contents, $editable) {
-                            console.log('onChange:', contents, $editable);
-                        }
-                    },
+                $('.summernote').summernote({
                     height: 120,
                     toolbar: [
                       //[groupname, [button list]]
@@ -2261,10 +2256,8 @@ echo buildSettings(
                   });
 
                 // summernote.change
-                $('#summernote').on('summernote.change', function(we, contents, $editable) {
-                    console.log(contents);
-                    $(this).parents('.note-editable panel-body').first().attr('data-changed', 'true');
-                    //$('.note-editable panel-body').attr('data-changed', true);
+                $('.summernote').on('summernote.change', function(we, contents, $editable) {
+                    $(this).attr('data-changed', 'true');
                 });