Version Description
- 12 December 2020 =
- Developer: jQuery updates for WordPress 5.6.
Download this release
Release Info
Developer | SiteOrigin |
Plugin | SiteOrigin CSS |
Version | 1.2.12 |
Comparing to | |
See all releases |
Code changes from version 1.2.11 to 1.2.12
- js/editor.js +13 -13
- js/editor.min.js +1 -1
- js/inspector.js +9 -9
- js/inspector.min.js +1 -1
- readme.txt +6 -3
- so-css.php +2 -2
js/editor.js
CHANGED
@@ -53,7 +53,7 @@
|
|
53 |
triggerEvent: function ( event ) {
|
54 |
event.preventDefault();
|
55 |
var $target = $( event.currentTarget );
|
56 |
-
$target.blur
|
57 |
var value = $target.attr( 'href' ).replace( '#', '' );
|
58 |
this.$el.trigger( 'click_' + value );
|
59 |
},
|
@@ -588,9 +588,9 @@
|
|
588 |
this.originalUri.host() !== newUri.host() ||
|
589 |
this.originalUri.protocol() !== newUri.protocol()
|
590 |
) {
|
591 |
-
$$.blur
|
592 |
alert( $$.data( 'invalid-uri' ) );
|
593 |
-
$$.focus
|
594 |
}
|
595 |
else {
|
596 |
newUri.addQuery( 'so_css_preview', 1 );
|
@@ -679,7 +679,7 @@
|
|
679 |
}
|
680 |
|
681 |
// Click on the first one
|
682 |
-
this.$( '.snippets li.snippet' ).eq( 0 ).click
|
683 |
|
684 |
this.attach();
|
685 |
return this;
|
@@ -863,7 +863,7 @@
|
|
863 |
}
|
864 |
|
865 |
// Switch to the first tab.
|
866 |
-
this.$( '.section-tabs li' ).eq( 0 ).click
|
867 |
},
|
868 |
|
869 |
onTabClick: function ( event ) {
|
@@ -1105,7 +1105,7 @@
|
|
1105 |
activeSelector = dropdown.find( 'option' ).eq( 0 ).attr( 'val' );
|
1106 |
}
|
1107 |
if ( !_.isEmpty( activeSelector ) ) {
|
1108 |
-
dropdown.val( activeSelector ).change
|
1109 |
}
|
1110 |
},
|
1111 |
|
@@ -1132,7 +1132,7 @@
|
|
1132 |
|
1133 |
if ( dropdown.val() === selector ) {
|
1134 |
// Trigger a change event to load the existing selector
|
1135 |
-
dropdown.change
|
1136 |
}
|
1137 |
else {
|
1138 |
// The selector doesn't exist, so add it to the CSS, then reload
|
@@ -1385,7 +1385,7 @@
|
|
1385 |
var val = this.args.value.replace( '{{url}}', attachment.url );
|
1386 |
|
1387 |
// Change the field value and trigger a change event
|
1388 |
-
this.field.val( val ).change
|
1389 |
this.trigger( 'set_value', val );
|
1390 |
|
1391 |
// Close the image selector
|
@@ -1604,7 +1604,7 @@
|
|
1604 |
var direction = $button.is( '.dec-button' ) ? -1 : 1;
|
1605 |
var intervalId;
|
1606 |
var timeoutId;
|
1607 |
-
$button.
|
1608 |
this.stepValue( direction );
|
1609 |
timeoutId = setTimeout( function () {
|
1610 |
intervalId = setInterval( function () {
|
@@ -1688,7 +1688,7 @@
|
|
1688 |
var direction = $button.is( '.dec-button' ) ? this.args.decrement : this.args.increment;
|
1689 |
var intervalId;
|
1690 |
var timeoutId;
|
1691 |
-
$button.
|
1692 |
this.stepValue( direction );
|
1693 |
timeoutId = setTimeout( function () {
|
1694 |
intervalId = setInterval( function () {
|
@@ -1810,7 +1810,7 @@ jQuery( function ( $ ) {
|
|
1810 |
editor.setSnippets( socssOptions.snippets );
|
1811 |
|
1812 |
// This is for hiding the getting started video
|
1813 |
-
$( '#so-custom-css-getting-started a.hide' ).
|
1814 |
e.preventDefault();
|
1815 |
$( '#so-custom-css-getting-started' ).slideUp();
|
1816 |
$.get( $( this ).attr( 'href' ) );
|
@@ -1819,7 +1819,7 @@ jQuery( function ( $ ) {
|
|
1819 |
window.socss.mainEditor = editor;
|
1820 |
$( socss ).trigger( 'initialized' );
|
1821 |
|
1822 |
-
$( '.button-primary[name="siteorigin_custom_css_save"]' ).
|
1823 |
-
$( '#so-custom-css-form' ).submit
|
1824 |
} );
|
1825 |
} );
|
53 |
triggerEvent: function ( event ) {
|
54 |
event.preventDefault();
|
55 |
var $target = $( event.currentTarget );
|
56 |
+
$target.trigger( 'blur' );
|
57 |
var value = $target.attr( 'href' ).replace( '#', '' );
|
58 |
this.$el.trigger( 'click_' + value );
|
59 |
},
|
588 |
this.originalUri.host() !== newUri.host() ||
|
589 |
this.originalUri.protocol() !== newUri.protocol()
|
590 |
) {
|
591 |
+
$$.trigger( 'blur' );
|
592 |
alert( $$.data( 'invalid-uri' ) );
|
593 |
+
$$.trigger( 'focus' );
|
594 |
}
|
595 |
else {
|
596 |
newUri.addQuery( 'so_css_preview', 1 );
|
679 |
}
|
680 |
|
681 |
// Click on the first one
|
682 |
+
this.$( '.snippets li.snippet' ).eq( 0 ).trigger( 'click' );
|
683 |
|
684 |
this.attach();
|
685 |
return this;
|
863 |
}
|
864 |
|
865 |
// Switch to the first tab.
|
866 |
+
this.$( '.section-tabs li' ).eq( 0 ).trigger( 'click' );
|
867 |
},
|
868 |
|
869 |
onTabClick: function ( event ) {
|
1105 |
activeSelector = dropdown.find( 'option' ).eq( 0 ).attr( 'val' );
|
1106 |
}
|
1107 |
if ( !_.isEmpty( activeSelector ) ) {
|
1108 |
+
dropdown.val( activeSelector ).trigger( 'change' );
|
1109 |
}
|
1110 |
},
|
1111 |
|
1132 |
|
1133 |
if ( dropdown.val() === selector ) {
|
1134 |
// Trigger a change event to load the existing selector
|
1135 |
+
dropdown.trigger( 'change' );
|
1136 |
}
|
1137 |
else {
|
1138 |
// The selector doesn't exist, so add it to the CSS, then reload
|
1385 |
var val = this.args.value.replace( '{{url}}', attachment.url );
|
1386 |
|
1387 |
// Change the field value and trigger a change event
|
1388 |
+
this.field.val( val ).trigger( 'change' );
|
1389 |
this.trigger( 'set_value', val );
|
1390 |
|
1391 |
// Close the image selector
|
1604 |
var direction = $button.is( '.dec-button' ) ? -1 : 1;
|
1605 |
var intervalId;
|
1606 |
var timeoutId;
|
1607 |
+
$button.on( 'mousedown', function() {
|
1608 |
this.stepValue( direction );
|
1609 |
timeoutId = setTimeout( function () {
|
1610 |
intervalId = setInterval( function () {
|
1688 |
var direction = $button.is( '.dec-button' ) ? this.args.decrement : this.args.increment;
|
1689 |
var intervalId;
|
1690 |
var timeoutId;
|
1691 |
+
$button.on( 'mousedown', function() {
|
1692 |
this.stepValue( direction );
|
1693 |
timeoutId = setTimeout( function () {
|
1694 |
intervalId = setInterval( function () {
|
1810 |
editor.setSnippets( socssOptions.snippets );
|
1811 |
|
1812 |
// This is for hiding the getting started video
|
1813 |
+
$( '#so-custom-css-getting-started a.hide' ).on( 'click', function( e ) {
|
1814 |
e.preventDefault();
|
1815 |
$( '#so-custom-css-getting-started' ).slideUp();
|
1816 |
$.get( $( this ).attr( 'href' ) );
|
1819 |
window.socss.mainEditor = editor;
|
1820 |
$( socss ).trigger( 'initialized' );
|
1821 |
|
1822 |
+
$( '.button-primary[name="siteorigin_custom_css_save"]' ).on( 'click', function() {
|
1823 |
+
$( '#so-custom-css-form' ).trigger( 'submit' );
|
1824 |
} );
|
1825 |
} );
|
js/editor.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,t,i){var s={model:{},collection:{},view:{},fn:{}};window.socss=s,s.model.CustomCssModel=Backbone.Model.extend({defaults:{postId:null,postTitle:null,css:null},urlRoot:i.postCssUrlRoot,url:function(){return this.urlRoot+"&postId="+this.get("postId")}}),s.model.CustomCssCollection=Backbone.Collection.extend({model:s.model.CustomCssModel,modelId:function(e){return e.postId}}),s.model.CSSEditorModel=Backbone.Model.extend({defaults:{customCssPosts:null}}),s.view.toolbar=Backbone.View.extend({button:t.template('<li><a href="#<%= action %>" class="toolbar-button socss-button"><%= text %></a></li>'),events:{"click .socss-button":"triggerEvent"},triggerEvent:function(t){t.preventDefault();var i=e(t.currentTarget);i.blur();var s=i.attr("href").replace("#","");this.$el.trigger("click_"+s)},addButton:function(t,i){return e(this.button({text:t,action:i})).appendTo(this.$(".toolbar-function-buttons .toolbar-buttons"))}}),s.view.editor=Backbone.View.extend({codeMirror:null,snippets:null,toolbar:null,visualProperties:null,inspector:null,cssSelectors:[],initValue:null,events:{"click_expand .custom-css-toolbar":"toggleExpand","click_visual .custom-css-toolbar":"showVisualEditor",submit:"onSubmit"},initialize:function(e){this.listenTo(this.model,"change:selectedPost",this.getSelectedPostCss),this.getSelectedPostCss().then(function(){e.openVisualEditor&&this.showVisualEditor()}.bind(this))},getSelectedPostCss:function(){var t=this.model.get("selectedPost");return(t&&!t.has("css")?t.fetch():(new e.Deferred).resolve()).then(this.render.bind(this))},render:function(){var t=this.model.get("selectedPost");return t&&!t.has("css")?this:(this.codeMirror||this.setupEditor(),this.toolbar||(this.toolbar=new s.view.toolbar({el:this.$(".custom-css-toolbar"),model:this.model}),this.toolbar.render()),this.visualProperties||(this.visualProperties=new s.view.properties({editor:this,el:e("#so-custom-css-properties")}),this.visualProperties.render()),this.preview||(this.preview=new s.view.preview({editor:this,model:this.model,el:this.$(".custom-css-preview"),initURL:i.homeURL}),this.preview.render()),t&&(this.codeMirror.setValue(t.get("css")),this.codeMirror.clearHistory()),this)},setupEditor:function(){this.registerCodeMirrorAutocomplete();var t=this.$("textarea.css-editor");this.initValue=t.val();var s=this.initValue.match(/\n/gm),r=(s&&s.length,this.initValue);t.val(r),this.codeMirror=CodeMirror.fromTextArea(t.get(0),{tabSize:2,lineNumbers:!0,mode:"css",theme:"neat",inputStyle:"contenteditable",gutters:["CodeMirror-lint-markers"],lint:!0,search:!0,dialog:!0,annotateScrollbar:!0,extraKeys:{"Ctrl-F":"findPersistent","Alt-G":"jumpToLine"}}),this.codeMirror.on("change",function(e,t){var i=this.model.get("selectedPost");i&&i.get("css")!==e.getValue().trim()&&i.set("css",e.getValue().trim())}.bind(this)),e(window).on("beforeunload",function(){if(this.codeMirror.getValue().trim()!==this.initValue)return i.loc.leave}.bind(this)),this.$el.find(".custom-css-container").css("overflow","visible"),this.scaleEditor(),e(window).on("resize",function(){this.scaleEditor()}.bind(this)),this.setupCodeMirrorExtensions()},onSubmit:function(){this.initValue=this.codeMirror.getValue().trim()},registerCodeMirrorAutocomplete:function(){var e={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};CodeMirror.registerHelper("hint","css",function(t){var i=t.getCursor(),s=t.getTokenAt(i),r=CodeMirror.innerMode(t.getMode(),s.state);if("css"===r.mode.name){if("keyword"===s.type&&0==="!important".indexOf(s.string))return{list:["!important"],from:CodeMirror.Pos(i.line,s.start),to:CodeMirror.Pos(i.line,s.end)};var o=s.start,n=i.ch,l=s.string.slice(0,n-o);/[^\w$_-]/.test(l)&&(l="",o=n=i.ch);var a=CodeMirror.resolveMode("text/css"),c=[],p=r.state.state;if("top"===p){for(var d=t.getLine(i.line).trim(),h=this.cssSelectors,u=0;u<h.length;u++)-1!==h[u].selector.indexOf(d)&&c.push(h[u].selector);if(c.length)return{list:c,from:CodeMirror.Pos(i.line,0),to:CodeMirror.Pos(i.line,n)}}else if("pseudo"===p||"variable-3"===s.type?v(e):"block"===p||"maybeprop"===p?v(a.propertyKeywords):"prop"===p||"parens"===p||"at"===p||"params"===p?(v(a.valueKeywords),v(a.colorKeywords)):"media"!==p&&"media_parens"!==p||(v(a.mediaTypes),v(a.mediaFeatures)),c.length)return{list:c,from:CodeMirror.Pos(i.line,o),to:CodeMirror.Pos(i.line,n)}}function v(e){for(var t in e)l&&0!==t.lastIndexOf(l,0)||c.push(t)}}.bind(this))},setupCodeMirrorExtensions:function(){this.codeMirror.on("cursorActivity",function(e){var t=e.getCursor(),i=e.getTokenAt(t);CodeMirror.innerMode(e.getMode(),i.state);if("qualifier"===i.type||"tag"===i.type||"builtin"===i.type){var s=e.getLine(t.line).substring(0,i.end);this.preview.highlight(s)}else this.preview.clearHighlight()}.bind(this)),this.codeMirror.on("keyup",(function(e,t){(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode&&!t.shiftKey||190===t.keyCode&&!t.shiftKey||51===t.keyCode&&t.shiftKey||189===t.keyCode&&t.shiftKey)&&e.showHint({completeSingle:!1})}))},scaleEditor:function(){var t=e(window).outerHeight();if(this.$el.hasClass("expanded"))this.$el.find(".CodeMirror-scroll").css("max-height",""),this.codeMirror.setSize("100%",t-this.$(".custom-css-toolbar").outerHeight());else{var i=e("#so-custom-css-form"),s=e("#wpadminbar").outerHeight(!0)+e("#siteorigin-custom-css").find("> h2").outerHeight(!0)+i.find("> .custom-css-toolbar").outerHeight(!0)+i.find("> p.description").outerHeight(!0)+i.find("> p.so-custom-css-submit").outerHeight(!0)+parseFloat(e("#wpbody-content").css("padding-bottom"));this.$el.find(".CodeMirror-scroll").css("max-height",t-s),this.codeMirror.setSize("100%","auto")}},isExpanded:function(){return this.$el.hasClass("expanded")},toggleExpand:function(){this.$el.toggleClass("expanded"),this.scaleEditor()},setExpand:function(e){e?this.$el.addClass("expanded"):this.$el.removeClass("expanded"),this.scaleEditor()},showVisualEditor:function(){this.visualProperties.loadCSS(this.codeMirror.getValue().trim()),this.visualProperties.show()},setSnippets:function(e){t.isEmpty(e)||(this.snippets=new s.view.snippets({snippets:e}),this.snippets.editor=this,this.snippets.render(),this.toolbar.addButton("Snippets","snippets"),this.toolbar.on("click_snippets",function(){this.snippets.show()}.bind(this)))},addCode:function(e){var t=this.codeMirror,i="";i=1===t.doc.lineCount()&&0===t.doc.getLine(t.doc.lastLine()).length?"":0===t.doc.getLine(t.doc.lastLine()).length?"\n":"\n\n",t.doc.setCursor(t.doc.lastLine(),t.doc.getLine(t.doc.lastLine()).length),t.doc.replaceSelection(i+e)},addEmptySelector:function(e){this.addCode(e+" {\n \n}")},setInspector:function(e){this.inspector=e,this.cssSelectors=e.pageSelectors,e.on("click_selector",function(e){this.visualProperties.isVisible()?this.visualProperties.addSelector(e):this.addEmptySelector(e)}.bind(this)),e.on("click_property",function(e){this.visualProperties.isVisible()||this.codeMirror.replaceSelection(e+";\n ")}.bind(this)),e.on("set_active_element",function(e,t){this.visualProperties.isVisible()&&t.length&&this.visualProperties.addSelector(t[0].selector)}.bind(this))}}),s.view.preview=Backbone.View.extend({template:t.template(e("#template-preview-window").html()),editor:null,originalUri:null,currentUri:null,events:{"mouseleave #preview-iframe":"clearHighlight",'keydown #preview-navigator input[type="text"]':"reloadPreview"},initialize:function(e){this.editor=e.editor,this.listenTo(this.model,"change:selectedPost",this.render.bind(this)),this.originalUri=new URI(e.initURL),this.currentUri=new URI(e.initURL),this.editor.codeMirror.on("change",function(e,t){this.updatePreviewCss()}.bind(this))},render:function(){var e=this.model.get("selectedPost");if(e&&!e.has("postUrl"))return e.fetch().then(this.render.bind(this)),this;this.$el.html(this.template()),e&&(this.currentUri=new URI(e.get("postUrl"))),this.currentUri.removeQuery("so_css_preview",1),this.$("#preview-navigator input").val(this.currentUri.toString()),this.currentUri.addQuery("so_css_preview",1),this.$("#preview-iframe").attr("src",this.currentUri.toString()).on("load",this.initPreview.bind(this))},initPreview:function(){var t=this.$("#preview-iframe");this.currentUri=new URI(t.contents().get(0).location.href),this.currentUri.removeQuery("so_css_preview"),this.$("#preview-navigator input").val(this.currentUri.toString()),this.currentUri.addQuery("so_css_preview",1),t.contents().find("a").each((function(){var t=e(this).attr("href");if(void 0===t)return!0;var i=-1===t.indexOf("?")?"?":"&";e(this).attr("href",t+i+"so_css_preview=1")})),this.updatePreviewCss()},reloadPreview:function(e){var t=this.$('#preview-navigator input[type="text"]');if(13===e.keyCode){e.preventDefault();var i=new URI(t.val());this.originalUri.host()!==i.host()||this.originalUri.protocol()!==i.protocol()?(t.blur(),alert(t.data("invalid-uri")),t.focus()):(i.addQuery("so_css_preview",1),this.$("#preview-iframe").attr("src",i.toString()))}},updatePreviewCss:function(){var e=this.$("#preview-iframe");if(0!==e.length){var t=e.contents().find("head");0===t.find("style.siteorigin-custom-css").length&&t.append('<style class="siteorigin-custom-css" type="text/css"></style>');var i=t.find("style.siteorigin-custom-css"),s=this.editor.codeMirror.getValue().trim();i.html(s)}},highlight:function(e){try{this.editor.inspector.hl.highlight(e)}catch(e){console.log("No inspector to highlight with")}},clearHighlight:function(){try{this.editor.inspector.hl.clear()}catch(e){console.log("No inspector to highlight with")}}}),s.view.snippets=Backbone.View.extend({template:t.template(e("#template-snippet-browser").html()),snippet:t.template('<li class="snippet"><%- name %></li>'),className:"css-editor-snippet-browser",snippets:null,editor:null,events:{"click .close":"hide","click .buttons .insert-snippet":"insertSnippet","click .snippet":"clickSnippet"},currentSnippet:null,initialize:function(e){this.snippets=e.snippets},render:function(){this.$el.html(this.template());for(var t=0;t<this.snippets.length;t++)e(this.snippet({name:this.snippets[t].Name})).data({description:this.snippets[t].Description,css:this.snippets[t].css}).appendTo(this.$("ul.snippets"));return this.$(".snippets li.snippet").eq(0).click(),this.attach(),this},clickSnippet:function(t){t.preventDefault();var i=e(t.currentTarget);this.$(".snippets li.snippet").removeClass("active"),e(this).addClass("active"),this.viewSnippet({name:i.html(),description:i.data("description"),css:i.data("css")})},viewSnippet:function(e){var t=this.$(".main .snippet-view");t.find(".snippet-title").html(e.name),t.find(".snippet-description").html(e.description),t.find(".snippet-code").html(e.css),this.currentSnippet=e},insertSnippet:function(){var e=this.editor.codeMirror,t=this.currentSnippet.css,i="";i=1===e.doc.lineCount()&&0===e.doc.getLine(e.doc.lastLine()).length?"":0===e.doc.getLine(e.doc.lastLine()).length?"\n":"\n\n",e.doc.setCursor(e.doc.lastLine(),e.doc.getLine(e.doc.lastLine()).length),e.doc.replaceSelection(i+t),this.hide()},attach:function(){this.$el.appendTo("body")},show:function(){this.$el.show()},hide:function(){this.$el.hide()}}),s.view.properties=Backbone.View.extend({tabTemplate:t.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),sectionTemplate:t.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),controllerTemplate:t.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),propertyControllers:[],editor:null,css:"",parsed:{},activeSelector:"",editorExpandedBefore:!1,events:{"click .close":"hide","click .section-tabs li":"onTabClick","change .toolbar select":"onToolbarSelectChange"},initialize:function(e){this.parser=window.css,this.editor=e.editor},render:function(){this.$(".section-tabs").empty(),this.$(".sections").empty(),this.$(".toolbar select").off(),this.propertyControllers=[];var r=i.propertyControllers;for(var o in r){e(this.tabTemplate({id:o,icon:r[o].icon,title:r[o].title})).appendTo(this.$(".section-tabs"));var n=e(this.sectionTemplate({id:o})).appendTo(this.$(".sections"));if(!t.isEmpty(r[o].controllers))for(var l=0;l<r[o].controllers.length;l++){var a,c=e(this.controllerTemplate({title:r[o].controllers[l].title})).appendTo(n.find("tbody")),p=r[o].controllers[l];a=void 0===s.view.properties.controllers[p.type]?new s.view.propertyController({el:c.find("td"),propertiesView:this,args:void 0===p.args?{}:p.args}):new s.view.properties.controllers[p.type]({el:c.find("td"),propertiesView:this,args:void 0===p.args?{}:p.args}),this.propertyControllers.push(a),a.render()}}this.$(".section-tabs li").eq(0).click()},onTabClick:function(t){var i=e(t.currentTarget),s=this.$('.sections .section[data-section="'+i.data("section")+'"]');this.$(".sections .section").not(s).hide().removeClass("active"),s.show().addClass("active"),this.$(".section-tabs li").not(i).removeClass("active"),i.addClass("active")},onToolbarSelectChange:function(t){this.setActiveSelector(e(t.currentTarget).find(":selected").data("selector"))},setRuleValue:function(e,i){if(void 0!==this.activeSelector&&void 0!==this.activeSelector.declarations){for(var s=this.activeSelector.declarations,r=!0,o=!1,n=0;n<s.length;n++)if(s[n].property===e){r=!1;var l=s[n];l.value!==i&&(l.value=i,o=!0),t.isEmpty(l.value)&&s.splice(s.indexOf(l));break}r&&!t.isEmpty(i)&&(s.push({property:e,value:i,type:"declaration"}),o=!0),o&&this.updateMainEditor(!1)}},addImport:function(e){var i=t.filter(this.parsed.stylesheet.rules,(function(e){return"import"===e.type}));t.any(i,(function(t){return t.import===e.import}))||(this.parsed.stylesheet.rules.unshift(e),this.updateMainEditor(!1))},findImport:function(e){return t.find(this.parsed.stylesheet.rules,(function(t){return"import"===t.type&&t.import.indexOf(e)>-1}))},updateImport:function(e,t){var i=this.findImport(e);i.import!==t.import&&(i.import=t.import,this.updateMainEditor(!1))},removeImport:function(e){var i=t.findIndex(this.parsed.stylesheet.rules,(function(t){return"import"===t.type&&t.import.indexOf(e)>-1}));i>-1&&this.parsed.stylesheet.rules.splice(i,1)},getRuleValue:function(e){if(void 0===this.activeSelector||void 0===this.activeSelector.declarations)return"";for(var t=this.activeSelector.declarations,i=0;i<t.length;i++)if(t[i].property===e)return t[i].value;return""},updateMainEditor:function(e){this.editor.codeMirror.setValue(this.parser.stringify(this.parsed))},show:function(){this.editorExpandedBefore=this.editor.isExpanded(),this.editor.setExpand(!0),this.$el.show().animate({left:0},"fast")},hide:function(){this.editor.setExpand(this.editorExpandedBefore),this.$el.animate({left:-338},"fast",(function(){e(this).hide()})),this.updateMainEditor(!0)},isVisible:function(){return this.$el.is(":visible")},loadCSS:function(i,s){this.css=i,this.parsed=this.parser.parse(i,{silent:!0});for(var r=this.parsed.stylesheet.rules,o=this.$(".toolbar select").empty(),n=0;n<r.length;n++){var l=r[n];if(t.contains(["rule","media"],l.type))if("media"===l.type)for(var a=0;a<l.rules.length;a++){var c="@media "+l.media,p=l.rules[a];"rule"==p.type&&o.append(e("<option>").html(c+": "+p.selectors.join(",")).attr("val",c+": "+p.selectors.join(",")).data("selector",p))}else o.append(e("<option>").html(l.selectors.join(",")).attr("val",l.selectors.join(",")).data("selector",l))}void 0===s&&(s=o.find("option").eq(0).attr("val")),t.isEmpty(s)||o.val(s).change()},setActiveSelector:function(e){this.activeSelector=e;for(var t=0;t<this.propertyControllers.length;t++)this.propertyControllers[t].refreshFromRule()},addSelector:function(e){var t=this.$(".toolbar select");t.val(e),t.val()===e?t.change():(this.editor.addEmptySelector(e),this.loadCSS(this.editor.codeMirror.getValue().trim(),e)),t.addClass("highlighted"),setTimeout((function(){t.removeClass("highlighted")}),2e3)}}),s.view.propertyController=Backbone.View.extend({template:t.template('<input type="text" value="" class="socss-property-controller-input"/>'),activeRule:null,args:null,propertiesView:null,events:{"change .socss-property-controller-input":"onChange","keyup input.socss-property-controller-input":"onChange"},initialize:function(e){this.args=e.args,this.propertiesView=e.propertiesView,this.events=t.extend(s.view.propertyController.prototype.events,this.events),this.delegateEvents(this.events),this.on("set_value",this.updateRule,this),this.on("change",this.updateRule,this)},render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input.socss-property-controller-input")},onChange:function(){this.trigger("change",this.field.val())},updateRule:function(){this.propertiesView.setRuleValue(this.args.property,this.getValue())},refreshFromRule:function(){var e=this.propertiesView.getRuleValue(this.args.property);this.setValue(e,{silent:!0})},getValue:function(){return this.field.val()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),i.silent||this.trigger("set_value",e)},reset:function(e){e=t.extend({silent:!1},e),this.setValue("",e)}}),s.view.properties.controllers={},s.view.properties.controllers.color=s.view.propertyController.extend({render:function(){s.view.propertyController.prototype.render.apply(this,arguments),this.field.minicolors({})},onChange:function(){this.trigger("change",this.field.minicolors("value"))},getValue:function(){return this.field.minicolors("value").trim()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.minicolors("value",e),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.select=s.view.propertyController.extend({template:t.template('<select class="socss-property-controller-input"></select>'),events:{"click .select-tab":"onSelect"},render:function(){for(var t in this.$el.append(e(this.template({}))),this.field=this.$("select"),this.field.append(e('<option value=""></option>').html("")),this.args.options)this.field.append(e("<option></option>").attr("value",t).html(this.args.options[t]));void 0!==this.args.option_icons&&this.setupVisualSelect()},setupVisualSelect:function(){this.field.hide();var t=e('<div class="select-tabs"></div>').appendTo(this.$el);for(var i in e('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo(t),this.args.option_icons)e('<div class="select-tab"></div>').appendTo(t).append(e('<span class="fa"></span>').addClass("fa-"+this.args.option_icons[i])).attr("data-value",i);t.find(".select-tab").css("width",100/t.find(">div").length+"%")},onSelect:function(t){this.$(".select-tab").removeClass("active");var i=e(t.currentTarget);i.addClass("active"),this.field.val(i.data("value")).trigger("change")},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),this.$(".select-tabs .select-tab").removeClass("active").filter('[data-value="'+e+'"]').addClass("active"),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.image=s.view.propertyController.extend({template:t.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),events:{"click .select":"openMedia"},render:function(){this.media=wp.media({title:i.loc.select_image,library:{type:"image"},button:{text:i.loc.select,close:!1}}),this.$el.append(e(this.template({select:i.loc.select}))),this.field=this.$el.find("input"),this.media.on("select",function(){var e=this.media.state().get("selection").first().attributes,t=this.args.value.replace("{{url}}",e.url);this.field.val(t).change(),this.trigger("set_value",t),this.media.close()}.bind(this))},openMedia:function(){this.media.open()}}),s.view.properties.controllers.measurement=s.view.propertyController.extend({wrapperClass:"socss-field-measurement",events:{"click .toggle-dropdown":"toggleUnitDropdown","click .dropdown li":"onSelectUnit","keydown .socss-field-input":"onInputKeyPress","keyup .socss-field-input":"onInputKeyUp"},render:function(){s.view.propertyController.prototype.render.apply(this,arguments),this.setupMeasurementField()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e).trigger("measurement_refresh"),i.silent||this.trigger("set_value",e)},units:["px","%","em","cm","mm","in","pt","pc","ex","ch","rem","vw","vh","vmin","vmax"],parseUnits:function(e){var t=this.units.map((function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")})),i=new RegExp("([0-9\\.\\-]+)("+t.join("|")+")?","i").exec(e);return null===i?{value:"",unit:""}:{value:i[1],unit:void 0===i[2]?"":i[2]}},setupMeasurementField:function(){this.field.hide(),this.$el.addClass(this.wrapperClass).data("unit","px");var t=e('<input type="text" class="socss-field-input"/>').appendTo(this.$el);e('<span class="toggle-dropdown dashicons dashicons-arrow-down"></span>').appendTo(this.$el);for(var i=e('<ul class="dropdown"></ul>').appendTo(this.$el),s=e('<span class="units"></span>').html("px").appendTo(this.$el),r=0;r<this.units.length;r++){var o=e("<li></li>").html(this.units[r]).data("unit",this.units[r]);"px"===this.units[r]&&o.addClass("active"),i.append(o)}this.field.on("measurement_refresh",function(){var i=this.parseUnits(this.field.val());t.val(i.value);var r=""===i.unit?"px":i.unit;this.$el.data("unit",r),s.html(r);var o=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(i.value).appendTo("body"),n=o.width();n=Math.min(n,63),o.remove(),s.css("left",n+12)}.bind(this));var n=e('<div class="socss-diw"></div>').appendTo(this.$el),l=e('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo(n),a=e('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo(n);this.setupStepButton(l),this.setupStepButton(a)},updateValue:function(){var e=this.$(".socss-field-input"),t=this.parseUnits(e.val());""!==t.unit&&t.unit!==this.$el.data("unit")&&(e.val(t.value),this.setUnit(t.unit)),""===t.value?this.field.val(""):this.field.val(t.value+this.$el.data("unit")),this.field.trigger("change")},setUnit:function(e){this.$(".units").html(e),this.$el.data("unit",e),this.$(".socss-field-input").trigger("keydown")},toggleUnitDropdown:function(){this.$(".dropdown").toggle()},onSelectUnit:function(t){this.toggleUnitDropdown(),this.setUnit(e(t.currentTarget).data("unit")),this.updateValue()},onInputKeyUp:function(e){this.onInputKeyPress(e),this.updateValue()},onInputKeyPress:function(t){var i=this.$(".socss-field-input"),s="";"keydown"===t.type&&(t.keyCode>=48&&t.keyCode<=57?s=String.fromCharCode(t.keyCode):189===t.keyCode?s="-":190===t.keyCode&&(s="."));var r=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(i.val()+s).appendTo("body"),o=r.width();o=Math.min(o,63),r.remove(),this.$(".units").css("left",o+12)},stepValue:function(e){var t=Number.parseInt(this.parseUnits(this.field.val()).value);Number.isNaN(t)&&(t=0);var i=t+e;this.$(".socss-field-input").val(i),this.updateValue(),this.field.trigger("measurement_refresh")},setupStepButton:function(e){var t,i,s=e.is(".dec-button")?-1:1;e.mousedown(function(){this.stepValue(s),i=setTimeout(function(){t=setInterval(function(){this.stepValue(s)}.bind(this),50)}.bind(this),500)}.bind(this)).on("mouseup mouseout",(function(){i&&(clearTimeout(i),i=null),t&&(clearInterval(t),t=null)}))}}),s.view.properties.controllers.number=s.view.propertyController.extend({initialize:function(e){s.view.propertyController.prototype.initialize.apply(this,arguments),this.args=t.extend({change:null,default:0,increment:1,decrement:-1,max:null,min:null},e.args)},render:function(){s.view.propertyController.prototype.render.apply(this,arguments),this.setupNumberField()},setupNumberField:function(){this.$el.addClass("socss-field-number");var t=e('<div class="socss-diw"></div>').appendTo(this.$el),i=e('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo(t),s=e('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo(t);return this.setupStepButton(i),this.setupStepButton(s),this},stepValue:function(e){var t=Number.parseFloat(this.field.val());Number.isNaN(t)&&(t=this.args.default);var i=t+e;i=Math.round(100*i)/100,null!==this.args.max&&(i=Math.min(this.args.max,i)),null!==this.args.min&&(i=Math.max(this.args.min,i)),this.field.val(i),this.field.trigger("change")},setupStepButton:function(e){var t,i,s=e.is(".dec-button")?this.args.decrement:this.args.increment;e.mousedown(function(){this.stepValue(s),i=setTimeout(function(){t=setInterval(function(){this.stepValue(s)}.bind(this),50)}.bind(this),500)}.bind(this)).on("mouseup mouseout",(function(){i&&(clearTimeout(i),i=null),t&&(clearInterval(t),t=null)}))}}),s.view.properties.controllers.sides=s.view.propertyController.extend({template:t.template(e("#template-sides-field").html().trim()),controllers:[],events:{"click .select-tab":"onTabClick"},render:function(){s.view.propertyController.prototype.render.apply(this,arguments),this.args.hasAll||(this.$(".select-tab").eq(0).remove(),this.$(".select-tab").css("width","25%")),this.$(".select-tab").each(function(i,r){for(var o=e(r).data("direction"),n=e('<li class="side">').appendTo(this.$(".sides")).hide(),l=0;l<this.args.controllers.length;l++){var a=this.args.controllers[l];s.view.properties.controllers[a.type];var c="";c="all"===o?a.args.propertyAll:a.args.property.replace("{dir}",o);var p=t.extend({},a.args,{property:c}),d=new s.view.properties.controllers[a.type]({el:e("<div>").appendTo(n),propertiesView:this.propertiesView,args:p});d.render(),this.propertiesView.propertyControllers.push(d)}}.bind(this)),this.$(".select-tab").eq(0).click()},onTabClick:function(t){var i=this.$(".select-tab");i.removeClass("active");var s=e(t.currentTarget);s.addClass("active");var r=this.$(".sides .side");r.hide(),r.eq(i.index(s)).show()}}),s.view.properties.controllers.font_select=s.view.propertyController.extend({template:t.template(e("#template-webfont-teaser").html().trim())})}(jQuery,_,socssOptions),jQuery((function(e){var t=window.socss,i=new t.model.CSSEditorModel({customCssPosts:socssOptions.customCssPosts}),s=new t.view.editor({el:e("#so-custom-css-form").get(0),model:i,openVisualEditor:socssOptions.openVisualEditor});s.setSnippets(socssOptions.snippets),e("#so-custom-css-getting-started a.hide").click((function(t){t.preventDefault(),e("#so-custom-css-getting-started").slideUp(),e.get(e(this).attr("href"))})),window.socss.mainEditor=s,e(t).trigger("initialized"),e('.button-primary[name="siteorigin_custom_css_save"]').click((function(){e("#so-custom-css-form").submit()}))}));
|
1 |
+
!function(e,t,i){var s={model:{},collection:{},view:{},fn:{}};window.socss=s,s.model.CustomCssModel=Backbone.Model.extend({defaults:{postId:null,postTitle:null,css:null},urlRoot:i.postCssUrlRoot,url:function(){return this.urlRoot+"&postId="+this.get("postId")}}),s.model.CustomCssCollection=Backbone.Collection.extend({model:s.model.CustomCssModel,modelId:function(e){return e.postId}}),s.model.CSSEditorModel=Backbone.Model.extend({defaults:{customCssPosts:null}}),s.view.toolbar=Backbone.View.extend({button:t.template('<li><a href="#<%= action %>" class="toolbar-button socss-button"><%= text %></a></li>'),events:{"click .socss-button":"triggerEvent"},triggerEvent:function(t){t.preventDefault();var i=e(t.currentTarget);i.trigger("blur");var s=i.attr("href").replace("#","");this.$el.trigger("click_"+s)},addButton:function(t,i){return e(this.button({text:t,action:i})).appendTo(this.$(".toolbar-function-buttons .toolbar-buttons"))}}),s.view.editor=Backbone.View.extend({codeMirror:null,snippets:null,toolbar:null,visualProperties:null,inspector:null,cssSelectors:[],initValue:null,events:{"click_expand .custom-css-toolbar":"toggleExpand","click_visual .custom-css-toolbar":"showVisualEditor",submit:"onSubmit"},initialize:function(e){this.listenTo(this.model,"change:selectedPost",this.getSelectedPostCss),this.getSelectedPostCss().then(function(){e.openVisualEditor&&this.showVisualEditor()}.bind(this))},getSelectedPostCss:function(){var t=this.model.get("selectedPost");return(t&&!t.has("css")?t.fetch():(new e.Deferred).resolve()).then(this.render.bind(this))},render:function(){var t=this.model.get("selectedPost");return t&&!t.has("css")?this:(this.codeMirror||this.setupEditor(),this.toolbar||(this.toolbar=new s.view.toolbar({el:this.$(".custom-css-toolbar"),model:this.model}),this.toolbar.render()),this.visualProperties||(this.visualProperties=new s.view.properties({editor:this,el:e("#so-custom-css-properties")}),this.visualProperties.render()),this.preview||(this.preview=new s.view.preview({editor:this,model:this.model,el:this.$(".custom-css-preview"),initURL:i.homeURL}),this.preview.render()),t&&(this.codeMirror.setValue(t.get("css")),this.codeMirror.clearHistory()),this)},setupEditor:function(){this.registerCodeMirrorAutocomplete();var t=this.$("textarea.css-editor");this.initValue=t.val();var s=this.initValue.match(/\n/gm),r=(s&&s.length,this.initValue);t.val(r),this.codeMirror=CodeMirror.fromTextArea(t.get(0),{tabSize:2,lineNumbers:!0,mode:"css",theme:"neat",inputStyle:"contenteditable",gutters:["CodeMirror-lint-markers"],lint:!0,search:!0,dialog:!0,annotateScrollbar:!0,extraKeys:{"Ctrl-F":"findPersistent","Alt-G":"jumpToLine"}}),this.codeMirror.on("change",function(e,t){var i=this.model.get("selectedPost");i&&i.get("css")!==e.getValue().trim()&&i.set("css",e.getValue().trim())}.bind(this)),e(window).on("beforeunload",function(){if(this.codeMirror.getValue().trim()!==this.initValue)return i.loc.leave}.bind(this)),this.$el.find(".custom-css-container").css("overflow","visible"),this.scaleEditor(),e(window).on("resize",function(){this.scaleEditor()}.bind(this)),this.setupCodeMirrorExtensions()},onSubmit:function(){this.initValue=this.codeMirror.getValue().trim()},registerCodeMirrorAutocomplete:function(){var e={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};CodeMirror.registerHelper("hint","css",function(t){var i=t.getCursor(),s=t.getTokenAt(i),r=CodeMirror.innerMode(t.getMode(),s.state);if("css"===r.mode.name){if("keyword"===s.type&&0==="!important".indexOf(s.string))return{list:["!important"],from:CodeMirror.Pos(i.line,s.start),to:CodeMirror.Pos(i.line,s.end)};var o=s.start,n=i.ch,l=s.string.slice(0,n-o);/[^\w$_-]/.test(l)&&(l="",o=n=i.ch);var a=CodeMirror.resolveMode("text/css"),c=[],p=r.state.state;if("top"===p){for(var d=t.getLine(i.line).trim(),h=this.cssSelectors,u=0;u<h.length;u++)-1!==h[u].selector.indexOf(d)&&c.push(h[u].selector);if(c.length)return{list:c,from:CodeMirror.Pos(i.line,0),to:CodeMirror.Pos(i.line,n)}}else if("pseudo"===p||"variable-3"===s.type?v(e):"block"===p||"maybeprop"===p?v(a.propertyKeywords):"prop"===p||"parens"===p||"at"===p||"params"===p?(v(a.valueKeywords),v(a.colorKeywords)):"media"!==p&&"media_parens"!==p||(v(a.mediaTypes),v(a.mediaFeatures)),c.length)return{list:c,from:CodeMirror.Pos(i.line,o),to:CodeMirror.Pos(i.line,n)}}function v(e){for(var t in e)l&&0!==t.lastIndexOf(l,0)||c.push(t)}}.bind(this))},setupCodeMirrorExtensions:function(){this.codeMirror.on("cursorActivity",function(e){var t=e.getCursor(),i=e.getTokenAt(t);CodeMirror.innerMode(e.getMode(),i.state);if("qualifier"===i.type||"tag"===i.type||"builtin"===i.type){var s=e.getLine(t.line).substring(0,i.end);this.preview.highlight(s)}else this.preview.clearHighlight()}.bind(this)),this.codeMirror.on("keyup",(function(e,t){(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode&&!t.shiftKey||190===t.keyCode&&!t.shiftKey||51===t.keyCode&&t.shiftKey||189===t.keyCode&&t.shiftKey)&&e.showHint({completeSingle:!1})}))},scaleEditor:function(){var t=e(window).outerHeight();if(this.$el.hasClass("expanded"))this.$el.find(".CodeMirror-scroll").css("max-height",""),this.codeMirror.setSize("100%",t-this.$(".custom-css-toolbar").outerHeight());else{var i=e("#so-custom-css-form"),s=e("#wpadminbar").outerHeight(!0)+e("#siteorigin-custom-css").find("> h2").outerHeight(!0)+i.find("> .custom-css-toolbar").outerHeight(!0)+i.find("> p.description").outerHeight(!0)+i.find("> p.so-custom-css-submit").outerHeight(!0)+parseFloat(e("#wpbody-content").css("padding-bottom"));this.$el.find(".CodeMirror-scroll").css("max-height",t-s),this.codeMirror.setSize("100%","auto")}},isExpanded:function(){return this.$el.hasClass("expanded")},toggleExpand:function(){this.$el.toggleClass("expanded"),this.scaleEditor()},setExpand:function(e){e?this.$el.addClass("expanded"):this.$el.removeClass("expanded"),this.scaleEditor()},showVisualEditor:function(){this.visualProperties.loadCSS(this.codeMirror.getValue().trim()),this.visualProperties.show()},setSnippets:function(e){t.isEmpty(e)||(this.snippets=new s.view.snippets({snippets:e}),this.snippets.editor=this,this.snippets.render(),this.toolbar.addButton("Snippets","snippets"),this.toolbar.on("click_snippets",function(){this.snippets.show()}.bind(this)))},addCode:function(e){var t=this.codeMirror,i="";i=1===t.doc.lineCount()&&0===t.doc.getLine(t.doc.lastLine()).length?"":0===t.doc.getLine(t.doc.lastLine()).length?"\n":"\n\n",t.doc.setCursor(t.doc.lastLine(),t.doc.getLine(t.doc.lastLine()).length),t.doc.replaceSelection(i+e)},addEmptySelector:function(e){this.addCode(e+" {\n \n}")},setInspector:function(e){this.inspector=e,this.cssSelectors=e.pageSelectors,e.on("click_selector",function(e){this.visualProperties.isVisible()?this.visualProperties.addSelector(e):this.addEmptySelector(e)}.bind(this)),e.on("click_property",function(e){this.visualProperties.isVisible()||this.codeMirror.replaceSelection(e+";\n ")}.bind(this)),e.on("set_active_element",function(e,t){this.visualProperties.isVisible()&&t.length&&this.visualProperties.addSelector(t[0].selector)}.bind(this))}}),s.view.preview=Backbone.View.extend({template:t.template(e("#template-preview-window").html()),editor:null,originalUri:null,currentUri:null,events:{"mouseleave #preview-iframe":"clearHighlight",'keydown #preview-navigator input[type="text"]':"reloadPreview"},initialize:function(e){this.editor=e.editor,this.listenTo(this.model,"change:selectedPost",this.render.bind(this)),this.originalUri=new URI(e.initURL),this.currentUri=new URI(e.initURL),this.editor.codeMirror.on("change",function(e,t){this.updatePreviewCss()}.bind(this))},render:function(){var e=this.model.get("selectedPost");if(e&&!e.has("postUrl"))return e.fetch().then(this.render.bind(this)),this;this.$el.html(this.template()),e&&(this.currentUri=new URI(e.get("postUrl"))),this.currentUri.removeQuery("so_css_preview",1),this.$("#preview-navigator input").val(this.currentUri.toString()),this.currentUri.addQuery("so_css_preview",1),this.$("#preview-iframe").attr("src",this.currentUri.toString()).on("load",this.initPreview.bind(this))},initPreview:function(){var t=this.$("#preview-iframe");this.currentUri=new URI(t.contents().get(0).location.href),this.currentUri.removeQuery("so_css_preview"),this.$("#preview-navigator input").val(this.currentUri.toString()),this.currentUri.addQuery("so_css_preview",1),t.contents().find("a").each((function(){var t=e(this).attr("href");if(void 0===t)return!0;var i=-1===t.indexOf("?")?"?":"&";e(this).attr("href",t+i+"so_css_preview=1")})),this.updatePreviewCss()},reloadPreview:function(e){var t=this.$('#preview-navigator input[type="text"]');if(13===e.keyCode){e.preventDefault();var i=new URI(t.val());this.originalUri.host()!==i.host()||this.originalUri.protocol()!==i.protocol()?(t.trigger("blur"),alert(t.data("invalid-uri")),t.trigger("focus")):(i.addQuery("so_css_preview",1),this.$("#preview-iframe").attr("src",i.toString()))}},updatePreviewCss:function(){var e=this.$("#preview-iframe");if(0!==e.length){var t=e.contents().find("head");0===t.find("style.siteorigin-custom-css").length&&t.append('<style class="siteorigin-custom-css" type="text/css"></style>');var i=t.find("style.siteorigin-custom-css"),s=this.editor.codeMirror.getValue().trim();i.html(s)}},highlight:function(e){try{this.editor.inspector.hl.highlight(e)}catch(e){console.log("No inspector to highlight with")}},clearHighlight:function(){try{this.editor.inspector.hl.clear()}catch(e){console.log("No inspector to highlight with")}}}),s.view.snippets=Backbone.View.extend({template:t.template(e("#template-snippet-browser").html()),snippet:t.template('<li class="snippet"><%- name %></li>'),className:"css-editor-snippet-browser",snippets:null,editor:null,events:{"click .close":"hide","click .buttons .insert-snippet":"insertSnippet","click .snippet":"clickSnippet"},currentSnippet:null,initialize:function(e){this.snippets=e.snippets},render:function(){this.$el.html(this.template());for(var t=0;t<this.snippets.length;t++)e(this.snippet({name:this.snippets[t].Name})).data({description:this.snippets[t].Description,css:this.snippets[t].css}).appendTo(this.$("ul.snippets"));return this.$(".snippets li.snippet").eq(0).trigger("click"),this.attach(),this},clickSnippet:function(t){t.preventDefault();var i=e(t.currentTarget);this.$(".snippets li.snippet").removeClass("active"),e(this).addClass("active"),this.viewSnippet({name:i.html(),description:i.data("description"),css:i.data("css")})},viewSnippet:function(e){var t=this.$(".main .snippet-view");t.find(".snippet-title").html(e.name),t.find(".snippet-description").html(e.description),t.find(".snippet-code").html(e.css),this.currentSnippet=e},insertSnippet:function(){var e=this.editor.codeMirror,t=this.currentSnippet.css,i="";i=1===e.doc.lineCount()&&0===e.doc.getLine(e.doc.lastLine()).length?"":0===e.doc.getLine(e.doc.lastLine()).length?"\n":"\n\n",e.doc.setCursor(e.doc.lastLine(),e.doc.getLine(e.doc.lastLine()).length),e.doc.replaceSelection(i+t),this.hide()},attach:function(){this.$el.appendTo("body")},show:function(){this.$el.show()},hide:function(){this.$el.hide()}}),s.view.properties=Backbone.View.extend({tabTemplate:t.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),sectionTemplate:t.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),controllerTemplate:t.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),propertyControllers:[],editor:null,css:"",parsed:{},activeSelector:"",editorExpandedBefore:!1,events:{"click .close":"hide","click .section-tabs li":"onTabClick","change .toolbar select":"onToolbarSelectChange"},initialize:function(e){this.parser=window.css,this.editor=e.editor},render:function(){this.$(".section-tabs").empty(),this.$(".sections").empty(),this.$(".toolbar select").off(),this.propertyControllers=[];var r=i.propertyControllers;for(var o in r){e(this.tabTemplate({id:o,icon:r[o].icon,title:r[o].title})).appendTo(this.$(".section-tabs"));var n=e(this.sectionTemplate({id:o})).appendTo(this.$(".sections"));if(!t.isEmpty(r[o].controllers))for(var l=0;l<r[o].controllers.length;l++){var a,c=e(this.controllerTemplate({title:r[o].controllers[l].title})).appendTo(n.find("tbody")),p=r[o].controllers[l];a=void 0===s.view.properties.controllers[p.type]?new s.view.propertyController({el:c.find("td"),propertiesView:this,args:void 0===p.args?{}:p.args}):new s.view.properties.controllers[p.type]({el:c.find("td"),propertiesView:this,args:void 0===p.args?{}:p.args}),this.propertyControllers.push(a),a.render()}}this.$(".section-tabs li").eq(0).trigger("click")},onTabClick:function(t){var i=e(t.currentTarget),s=this.$('.sections .section[data-section="'+i.data("section")+'"]');this.$(".sections .section").not(s).hide().removeClass("active"),s.show().addClass("active"),this.$(".section-tabs li").not(i).removeClass("active"),i.addClass("active")},onToolbarSelectChange:function(t){this.setActiveSelector(e(t.currentTarget).find(":selected").data("selector"))},setRuleValue:function(e,i){if(void 0!==this.activeSelector&&void 0!==this.activeSelector.declarations){for(var s=this.activeSelector.declarations,r=!0,o=!1,n=0;n<s.length;n++)if(s[n].property===e){r=!1;var l=s[n];l.value!==i&&(l.value=i,o=!0),t.isEmpty(l.value)&&s.splice(s.indexOf(l));break}r&&!t.isEmpty(i)&&(s.push({property:e,value:i,type:"declaration"}),o=!0),o&&this.updateMainEditor(!1)}},addImport:function(e){var i=t.filter(this.parsed.stylesheet.rules,(function(e){return"import"===e.type}));t.any(i,(function(t){return t.import===e.import}))||(this.parsed.stylesheet.rules.unshift(e),this.updateMainEditor(!1))},findImport:function(e){return t.find(this.parsed.stylesheet.rules,(function(t){return"import"===t.type&&t.import.indexOf(e)>-1}))},updateImport:function(e,t){var i=this.findImport(e);i.import!==t.import&&(i.import=t.import,this.updateMainEditor(!1))},removeImport:function(e){var i=t.findIndex(this.parsed.stylesheet.rules,(function(t){return"import"===t.type&&t.import.indexOf(e)>-1}));i>-1&&this.parsed.stylesheet.rules.splice(i,1)},getRuleValue:function(e){if(void 0===this.activeSelector||void 0===this.activeSelector.declarations)return"";for(var t=this.activeSelector.declarations,i=0;i<t.length;i++)if(t[i].property===e)return t[i].value;return""},updateMainEditor:function(e){this.editor.codeMirror.setValue(this.parser.stringify(this.parsed))},show:function(){this.editorExpandedBefore=this.editor.isExpanded(),this.editor.setExpand(!0),this.$el.show().animate({left:0},"fast")},hide:function(){this.editor.setExpand(this.editorExpandedBefore),this.$el.animate({left:-338},"fast",(function(){e(this).hide()})),this.updateMainEditor(!0)},isVisible:function(){return this.$el.is(":visible")},loadCSS:function(i,s){this.css=i,this.parsed=this.parser.parse(i,{silent:!0});for(var r=this.parsed.stylesheet.rules,o=this.$(".toolbar select").empty(),n=0;n<r.length;n++){var l=r[n];if(t.contains(["rule","media"],l.type))if("media"===l.type)for(var a=0;a<l.rules.length;a++){var c="@media "+l.media,p=l.rules[a];"rule"==p.type&&o.append(e("<option>").html(c+": "+p.selectors.join(",")).attr("val",c+": "+p.selectors.join(",")).data("selector",p))}else o.append(e("<option>").html(l.selectors.join(",")).attr("val",l.selectors.join(",")).data("selector",l))}void 0===s&&(s=o.find("option").eq(0).attr("val")),t.isEmpty(s)||o.val(s).trigger("change")},setActiveSelector:function(e){this.activeSelector=e;for(var t=0;t<this.propertyControllers.length;t++)this.propertyControllers[t].refreshFromRule()},addSelector:function(e){var t=this.$(".toolbar select");t.val(e),t.val()===e?t.trigger("change"):(this.editor.addEmptySelector(e),this.loadCSS(this.editor.codeMirror.getValue().trim(),e)),t.addClass("highlighted"),setTimeout((function(){t.removeClass("highlighted")}),2e3)}}),s.view.propertyController=Backbone.View.extend({template:t.template('<input type="text" value="" class="socss-property-controller-input"/>'),activeRule:null,args:null,propertiesView:null,events:{"change .socss-property-controller-input":"onChange","keyup input.socss-property-controller-input":"onChange"},initialize:function(e){this.args=e.args,this.propertiesView=e.propertiesView,this.events=t.extend(s.view.propertyController.prototype.events,this.events),this.delegateEvents(this.events),this.on("set_value",this.updateRule,this),this.on("change",this.updateRule,this)},render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input.socss-property-controller-input")},onChange:function(){this.trigger("change",this.field.val())},updateRule:function(){this.propertiesView.setRuleValue(this.args.property,this.getValue())},refreshFromRule:function(){var e=this.propertiesView.getRuleValue(this.args.property);this.setValue(e,{silent:!0})},getValue:function(){return this.field.val()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),i.silent||this.trigger("set_value",e)},reset:function(e){e=t.extend({silent:!1},e),this.setValue("",e)}}),s.view.properties.controllers={},s.view.properties.controllers.color=s.view.propertyController.extend({render:function(){s.view.propertyController.prototype.render.apply(this,arguments),this.field.minicolors({})},onChange:function(){this.trigger("change",this.field.minicolors("value"))},getValue:function(){return this.field.minicolors("value").trim()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.minicolors("value",e),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.select=s.view.propertyController.extend({template:t.template('<select class="socss-property-controller-input"></select>'),events:{"click .select-tab":"onSelect"},render:function(){for(var t in this.$el.append(e(this.template({}))),this.field=this.$("select"),this.field.append(e('<option value=""></option>').html("")),this.args.options)this.field.append(e("<option></option>").attr("value",t).html(this.args.options[t]));void 0!==this.args.option_icons&&this.setupVisualSelect()},setupVisualSelect:function(){this.field.hide();var t=e('<div class="select-tabs"></div>').appendTo(this.$el);for(var i in e('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo(t),this.args.option_icons)e('<div class="select-tab"></div>').appendTo(t).append(e('<span class="fa"></span>').addClass("fa-"+this.args.option_icons[i])).attr("data-value",i);t.find(".select-tab").css("width",100/t.find(">div").length+"%")},onSelect:function(t){this.$(".select-tab").removeClass("active");var i=e(t.currentTarget);i.addClass("active"),this.field.val(i.data("value")).trigger("change")},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),this.$(".select-tabs .select-tab").removeClass("active").filter('[data-value="'+e+'"]').addClass("active"),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.image=s.view.propertyController.extend({template:t.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),events:{"click .select":"openMedia"},render:function(){this.media=wp.media({title:i.loc.select_image,library:{type:"image"},button:{text:i.loc.select,close:!1}}),this.$el.append(e(this.template({select:i.loc.select}))),this.field=this.$el.find("input"),this.media.on("select",function(){var e=this.media.state().get("selection").first().attributes,t=this.args.value.replace("{{url}}",e.url);this.field.val(t).trigger("change"),this.trigger("set_value",t),this.media.close()}.bind(this))},openMedia:function(){this.media.open()}}),s.view.properties.controllers.measurement=s.view.propertyController.extend({wrapperClass:"socss-field-measurement",events:{"click .toggle-dropdown":"toggleUnitDropdown","click .dropdown li":"onSelectUnit","keydown .socss-field-input":"onInputKeyPress","keyup .socss-field-input":"onInputKeyUp"},render:function(){s.view.propertyController.prototype.render.apply(this,arguments),this.setupMeasurementField()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e).trigger("measurement_refresh"),i.silent||this.trigger("set_value",e)},units:["px","%","em","cm","mm","in","pt","pc","ex","ch","rem","vw","vh","vmin","vmax"],parseUnits:function(e){var t=this.units.map((function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")})),i=new RegExp("([0-9\\.\\-]+)("+t.join("|")+")?","i").exec(e);return null===i?{value:"",unit:""}:{value:i[1],unit:void 0===i[2]?"":i[2]}},setupMeasurementField:function(){this.field.hide(),this.$el.addClass(this.wrapperClass).data("unit","px");var t=e('<input type="text" class="socss-field-input"/>').appendTo(this.$el);e('<span class="toggle-dropdown dashicons dashicons-arrow-down"></span>').appendTo(this.$el);for(var i=e('<ul class="dropdown"></ul>').appendTo(this.$el),s=e('<span class="units"></span>').html("px").appendTo(this.$el),r=0;r<this.units.length;r++){var o=e("<li></li>").html(this.units[r]).data("unit",this.units[r]);"px"===this.units[r]&&o.addClass("active"),i.append(o)}this.field.on("measurement_refresh",function(){var i=this.parseUnits(this.field.val());t.val(i.value);var r=""===i.unit?"px":i.unit;this.$el.data("unit",r),s.html(r);var o=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(i.value).appendTo("body"),n=o.width();n=Math.min(n,63),o.remove(),s.css("left",n+12)}.bind(this));var n=e('<div class="socss-diw"></div>').appendTo(this.$el),l=e('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo(n),a=e('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo(n);this.setupStepButton(l),this.setupStepButton(a)},updateValue:function(){var e=this.$(".socss-field-input"),t=this.parseUnits(e.val());""!==t.unit&&t.unit!==this.$el.data("unit")&&(e.val(t.value),this.setUnit(t.unit)),""===t.value?this.field.val(""):this.field.val(t.value+this.$el.data("unit")),this.field.trigger("change")},setUnit:function(e){this.$(".units").html(e),this.$el.data("unit",e),this.$(".socss-field-input").trigger("keydown")},toggleUnitDropdown:function(){this.$(".dropdown").toggle()},onSelectUnit:function(t){this.toggleUnitDropdown(),this.setUnit(e(t.currentTarget).data("unit")),this.updateValue()},onInputKeyUp:function(e){this.onInputKeyPress(e),this.updateValue()},onInputKeyPress:function(t){var i=this.$(".socss-field-input"),s="";"keydown"===t.type&&(t.keyCode>=48&&t.keyCode<=57?s=String.fromCharCode(t.keyCode):189===t.keyCode?s="-":190===t.keyCode&&(s="."));var r=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(i.val()+s).appendTo("body"),o=r.width();o=Math.min(o,63),r.remove(),this.$(".units").css("left",o+12)},stepValue:function(e){var t=Number.parseInt(this.parseUnits(this.field.val()).value);Number.isNaN(t)&&(t=0);var i=t+e;this.$(".socss-field-input").val(i),this.updateValue(),this.field.trigger("measurement_refresh")},setupStepButton:function(e){var t,i,s=e.is(".dec-button")?-1:1;e.on("mousedown",function(){this.stepValue(s),i=setTimeout(function(){t=setInterval(function(){this.stepValue(s)}.bind(this),50)}.bind(this),500)}.bind(this)).on("mouseup mouseout",(function(){i&&(clearTimeout(i),i=null),t&&(clearInterval(t),t=null)}))}}),s.view.properties.controllers.number=s.view.propertyController.extend({initialize:function(e){s.view.propertyController.prototype.initialize.apply(this,arguments),this.args=t.extend({change:null,default:0,increment:1,decrement:-1,max:null,min:null},e.args)},render:function(){s.view.propertyController.prototype.render.apply(this,arguments),this.setupNumberField()},setupNumberField:function(){this.$el.addClass("socss-field-number");var t=e('<div class="socss-diw"></div>').appendTo(this.$el),i=e('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo(t),s=e('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo(t);return this.setupStepButton(i),this.setupStepButton(s),this},stepValue:function(e){var t=Number.parseFloat(this.field.val());Number.isNaN(t)&&(t=this.args.default);var i=t+e;i=Math.round(100*i)/100,null!==this.args.max&&(i=Math.min(this.args.max,i)),null!==this.args.min&&(i=Math.max(this.args.min,i)),this.field.val(i),this.field.trigger("change")},setupStepButton:function(e){var t,i,s=e.is(".dec-button")?this.args.decrement:this.args.increment;e.on("mousedown",function(){this.stepValue(s),i=setTimeout(function(){t=setInterval(function(){this.stepValue(s)}.bind(this),50)}.bind(this),500)}.bind(this)).on("mouseup mouseout",(function(){i&&(clearTimeout(i),i=null),t&&(clearInterval(t),t=null)}))}}),s.view.properties.controllers.sides=s.view.propertyController.extend({template:t.template(e("#template-sides-field").html().trim()),controllers:[],events:{"click .select-tab":"onTabClick"},render:function(){s.view.propertyController.prototype.render.apply(this,arguments),this.args.hasAll||(this.$(".select-tab").eq(0).remove(),this.$(".select-tab").css("width","25%")),this.$(".select-tab").each(function(i,r){for(var o=e(r).data("direction"),n=e('<li class="side">').appendTo(this.$(".sides")).hide(),l=0;l<this.args.controllers.length;l++){var a=this.args.controllers[l];s.view.properties.controllers[a.type];var c="";c="all"===o?a.args.propertyAll:a.args.property.replace("{dir}",o);var p=t.extend({},a.args,{property:c}),d=new s.view.properties.controllers[a.type]({el:e("<div>").appendTo(n),propertiesView:this.propertiesView,args:p});d.render(),this.propertiesView.propertyControllers.push(d)}}.bind(this)),this.$(".select-tab").eq(0).click()},onTabClick:function(t){var i=this.$(".select-tab");i.removeClass("active");var s=e(t.currentTarget);s.addClass("active");var r=this.$(".sides .side");r.hide(),r.eq(i.index(s)).show()}}),s.view.properties.controllers.font_select=s.view.propertyController.extend({template:t.template(e("#template-webfont-teaser").html().trim())})}(jQuery,_,socssOptions),jQuery((function(e){var t=window.socss,i=new t.model.CSSEditorModel({customCssPosts:socssOptions.customCssPosts}),s=new t.view.editor({el:e("#so-custom-css-form").get(0),model:i,openVisualEditor:socssOptions.openVisualEditor});s.setSnippets(socssOptions.snippets),e("#so-custom-css-getting-started a.hide").on("click",(function(t){t.preventDefault(),e("#so-custom-css-getting-started").slideUp(),e.get(e(this).attr("href"))})),window.socss.mainEditor=s,e(t).trigger("initialized"),e('.button-primary[name="siteorigin_custom_css_save"]').on("click",(function(){e("#so-custom-css-form").trigger("submit")}))}));
|
js/inspector.js
CHANGED
@@ -65,7 +65,7 @@
|
|
65 |
});
|
66 |
|
67 |
// Setup the click event
|
68 |
-
$('body *').click
|
69 |
if( !thisView.active || thisView.$el.is(':hover') ) {
|
70 |
return true;
|
71 |
}
|
@@ -74,15 +74,15 @@
|
|
74 |
e.stopPropagation();
|
75 |
|
76 |
var $$ = $(this);
|
77 |
-
$$.blur
|
78 |
thisView.setActiveEl( thisView.hoverEl );
|
79 |
});
|
80 |
|
81 |
-
this.$('.socss-enable-inspector').
|
82 |
thisView.toggleActive();
|
83 |
} );
|
84 |
|
85 |
-
this.$el.
|
86 |
thisView.hl.clear();
|
87 |
} );
|
88 |
|
@@ -160,10 +160,10 @@
|
|
160 |
.data('el', $('body'));
|
161 |
|
162 |
this.$('.socss-hierarchy .socss-selector')
|
163 |
-
.
|
164 |
thisView.hl.highlight($(this).data('el'));
|
165 |
})
|
166 |
-
.click
|
167 |
e.preventDefault();
|
168 |
e.stopPropagation();
|
169 |
thisView.setActiveEl($(this).data('el'));
|
@@ -193,10 +193,10 @@
|
|
193 |
);
|
194 |
} );
|
195 |
container.find('> div')
|
196 |
-
.
|
197 |
thisView.hl.highlight( $(this).data('selector') );
|
198 |
} )
|
199 |
-
.
|
200 |
e.preventDefault();
|
201 |
e.stopPropagation();
|
202 |
|
@@ -215,7 +215,7 @@
|
|
215 |
} );
|
216 |
|
217 |
container.find('> div')
|
218 |
-
.
|
219 |
e.preventDefault();
|
220 |
e.stopPropagation();
|
221 |
|
65 |
});
|
66 |
|
67 |
// Setup the click event
|
68 |
+
$('body *').on( 'click', function( e ) {
|
69 |
if( !thisView.active || thisView.$el.is(':hover') ) {
|
70 |
return true;
|
71 |
}
|
74 |
e.stopPropagation();
|
75 |
|
76 |
var $$ = $(this);
|
77 |
+
$$.trigger( 'blur' );
|
78 |
thisView.setActiveEl( thisView.hoverEl );
|
79 |
});
|
80 |
|
81 |
+
this.$('.socss-enable-inspector').on( 'click', function(){
|
82 |
thisView.toggleActive();
|
83 |
} );
|
84 |
|
85 |
+
this.$el.on( 'mouseenter', function() {
|
86 |
thisView.hl.clear();
|
87 |
} );
|
88 |
|
160 |
.data('el', $('body'));
|
161 |
|
162 |
this.$('.socss-hierarchy .socss-selector')
|
163 |
+
.on( 'mouseenter', function () {
|
164 |
thisView.hl.highlight($(this).data('el'));
|
165 |
})
|
166 |
+
.on( 'click', function(e) {
|
167 |
e.preventDefault();
|
168 |
e.stopPropagation();
|
169 |
thisView.setActiveEl($(this).data('el'));
|
193 |
);
|
194 |
} );
|
195 |
container.find('> div')
|
196 |
+
.on( 'mouseenter', function() {
|
197 |
thisView.hl.highlight( $(this).data('selector') );
|
198 |
} )
|
199 |
+
.on( 'click', function( e ) {
|
200 |
e.preventDefault();
|
201 |
e.stopPropagation();
|
202 |
|
215 |
} );
|
216 |
|
217 |
container.find('> div')
|
218 |
+
.on( 'click', function( e ) {
|
219 |
e.preventDefault();
|
220 |
e.stopPropagation();
|
221 |
|
js/inspector.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,t,s){var i={model:{},collection:{},view:{},fn:{}},
|
1 |
+
!function(e,t,s){var i={model:{},collection:{},view:{},fn:{}},o=function(e,t){for(var s=[],i=SPECIFICITY.calculate(e),r=0;r<i.length;r++){var c=i[r];if(t)for(var a=0;a<c.parts.length;a++){var n=c.parts[a];s=s.concat(o(n.selector))}else s.push({selector:c.selector.trim(),specificity:parseInt(c.specificity.replace(/,/g,""))})}return s};i.view.inspector=Backbone.View.extend({active:!1,hl:!1,hoverEl:!1,pageSelectors:[],selectorTemplate:t.template('<div class="socss-selector"><%= selector %></div>'),initialize:function(){var t=this;this.hl=new i.view.highlighter,this.hl.initialize(),this.pageSelectors=i.fn.pageSelectors(),e("body").on("mouseover","*",(function(s){if(!t.active)return!0;0===e(this).closest(".socss-element").length&&(s.stopPropagation(),t.setHoverEl(e(this)))})),e("body *").on("click",(function(s){if(!t.active||t.$el.is(":hover"))return!0;s.preventDefault(),s.stopPropagation(),e(this).trigger("blur"),t.setActiveEl(t.hoverEl)})),this.$(".socss-enable-inspector").on("click",(function(){t.toggleActive()})),this.$el.on("mouseenter",(function(){t.hl.clear()}));try{parent.socss.mainEditor.setInspector(this)}catch(e){console.log("No editor to register this inspector with")}},setHoverEl:function(e){this.hoverEl=e,this.hl.highlight(e)},activate:function(){this.active=!0,e("body").addClass("socss-active"),e("body").removeClass("socss-inactive")},deactivate:function(){this.active=!1,e("body").addClass("socss-inactive"),e("body").removeClass("socss-active"),this.hl.clear(),this.$(".socss-hierarchy").empty()},toggleActive:function(){this.active?this.deactivate():this.activate()},setActiveEl:function(s){var o=this,r=this.$(".socss-hierarchy");if(r.empty(),s){if("body"!==s.prop("tagName").toLowerCase()){var c=e(s);do{e(this.selectorTemplate({selector:i.fn.elSelector(c)})).prependTo(r).data("el",c),c=c.parent()}while("body"!==c.prop("tagName").toLowerCase());e(this.selectorTemplate({selector:"body"})).prependTo(r).data("el",e("body")),this.$(".socss-hierarchy .socss-selector").on("mouseenter",(function(){o.hl.highlight(e(this).data("el"))})).on("click",(function(t){t.preventDefault(),t.stopPropagation(),o.setActiveEl(e(this).data("el"))}))}r.scrollLeft(99999);var a=this.pageSelectors.filter((function(e){try{return s.is(e.selector)}catch(e){return!1}})),n=this.$(".socss-selectors-window").empty();t.each(a,(function(t){n.append(e(o.selectorTemplate(t)).data(t))})),n.find("> div").on("mouseenter",(function(){o.hl.highlight(e(this).data("selector"))})).on("click",(function(t){t.preventDefault(),t.stopPropagation(),o.trigger("click_selector",e(this).data("selector"))}));var l=i.fn.elementAttributes(s);n=this.$(".socss-properties-window").empty(),t.each(l,(function(t,s){n.append(e(o.selectorTemplate({selector:"<strong>"+s+"</strong>: "+t})).data("property",s+": "+t))})),n.find("> div").on("click",(function(t){t.preventDefault(),t.stopPropagation(),o.trigger("click_property",e(this).data("property"))}));var h=s.closest("a[href]"),p=this.$(".socss-link");h.length?p.show().find("a").html(h.attr("href").replace(/[\?&]*so_css_preview=1/,"")).attr("href",h.attr("href")):p.hide(),this.trigger("set_active_element",s,a)}}}),i.view.highlighter=Backbone.View.extend({template:t.template(e("#socss-template-hover").html().trim()),highlighted:[],highlight:function(t){this.clear();var s=this;e(t).each((function(t,i){if(!(i=e(i)).is(":visible"))return!0;var o,r=e(s.template());r.css({top:i.offset().top,left:i.offset().left,width:i.outerWidth(),height:i.outerHeight()}).appendTo("body");var c=i.padding();for(var a in c)parseInt(c[a])>0&&(o=r.find(".socss-guide-padding.socss-guide-"+a).show(),"top"===a||"bottom"===a?o.css("height",c[a]):(o.css("width",c[a]),o.css({width:c[a],top:c.top,bottom:c.bottom})));var n=i.margin();for(var a in n)parseInt(n[a])>0&&(o=r.find(".socss-guide-margin.socss-guide-"+a).show(),"top"===a||"bottom"===a?o.css("height",n[a]):o.css("width",n[a]));s.highlighted.push(r)}))},clear:function(){for(;this.highlighted.length;)this.highlighted.pop().remove()}}),i.parsedCss={},i.fn.getParsedCss=function(){if(0===Object.keys(i.parsedCss).length){var t=window.css;e(".socss-theme-styles").each((function(){var s=e(this),o=t.parse(s.html(),{silent:!0});i.parsedCss[s.attr("id")]=o}))}return i.parsedCss},i.fn.pageSelectors=function(){var s=[],r=i.fn.getParsedCss();for(var c in r)for(var a=r[c].stylesheet.rules,n=0;n<a.length;n++)if(void 0!==a[n].selectors)for(var l=0;l<a[n].selectors.length;l++)s=s.concat(o(a[n].selectors[l]));e("body *").each((function(){var t=e(this),r=i.fn.elSelector(t);s=s.concat(o(r))}));var h=e("body"),p=i.fn.elSelector(h);return s=s.concat(o(p,!0)),(s=t.uniq(s,!1,(function(e){return e.selector}))).sort((function(e,t){return e.specificity>t.specificity?-1:1})),s},i.fn.elementAttributes=function(e){if(!document.styleSheets)return[];var t=[],s=i.fn.getParsedCss(),o=function(e){switch(e){case"charset":case"custom-media":case"document":case"font-face":case"host":case"import":case"keyframes":case"keyframe":case"media":case"namespace":case"page":case"supports":return!0}return!1};for(var r in s)for(var c=s[r].stylesheet.rules,a=0;a<c.length;a++){var n=c[a];if(void 0!==n.selectors&&!o(n.type))for(var l=0;l<n.selectors.length;l++)for(var h=SPECIFICITY.calculate(n.selectors[l]),p=0;p<h.length;p++)try{if(e.is(h[p].selector)){var f=n.declarations;for(p=0;p<f.length;p++)t.push({name:f[p].property,value:f[p].value,specificity:parseInt(h[p].specificity.replace(/,/g,""))})}}catch(e){}}t.sort((function(e,t){return e.specificity>t.specificity?1:-1})).reverse();for(var d={},v=0;v<t.length;v++)void 0===d[t[v].name]&&(d[t[v].name]=t[v].value);return d},i.fn.elSelector=function(e){var t="";return void 0!==e.attr("id")&&(t+="#"+e.attr("id")),void 0!==e.attr("class")&&(t+="."+e.attr("class").replace(/\s+/g,".")),""===t&&(t=e.prop("tagName").toLowerCase()),t},window.socssInspector=i}(jQuery,_,socssOptions),jQuery((function(e){var t=new window.socssInspector.view.inspector({el:e("#socss-inspector-interface").get(0)});t.activate(),window.socssInspector.mainInspector=t}));
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== SiteOrigin CSS ===
|
2 |
Tags: css, design, edit, customize
|
3 |
Requires at least: 3.9
|
4 |
-
Tested up to: 5.
|
5 |
-
Stable tag: 1.2.
|
6 |
-
Build time: 2020-
|
7 |
License: GPLv2 or later
|
8 |
Contributors: gpriday
|
9 |
Donate link: https://siteorigin.com/downloads/premium/
|
@@ -65,6 +65,9 @@ We offer free support on the [SiteOrigin support forums](https://siteorigin.com/
|
|
65 |
|
66 |
== Changelog ==
|
67 |
|
|
|
|
|
|
|
68 |
= 1.2.11 - 21 October 2020 =
|
69 |
* Fixed Background image setting writing to CSS.
|
70 |
|
1 |
=== SiteOrigin CSS ===
|
2 |
Tags: css, design, edit, customize
|
3 |
Requires at least: 3.9
|
4 |
+
Tested up to: 5.6
|
5 |
+
Stable tag: 1.2.12
|
6 |
+
Build time: 2020-12-12T15:10:19+02:00
|
7 |
License: GPLv2 or later
|
8 |
Contributors: gpriday
|
9 |
Donate link: https://siteorigin.com/downloads/premium/
|
65 |
|
66 |
== Changelog ==
|
67 |
|
68 |
+
= 1.2.12 - 12 December 2020 =
|
69 |
+
* Developer: jQuery updates for WordPress 5.6.
|
70 |
+
|
71 |
= 1.2.11 - 21 October 2020 =
|
72 |
* Fixed Background image setting writing to CSS.
|
73 |
|
so-css.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: SiteOrigin CSS
|
4 |
Description: An advanced CSS editor from SiteOrigin.
|
5 |
-
Version: 1.2.
|
6 |
Author: SiteOrigin
|
7 |
Author URI: https://siteorigin.com
|
8 |
Plugin URI: https://siteorigin.com/css/
|
@@ -14,7 +14,7 @@ Text Domain: so-css
|
|
14 |
// Handle the legacy CSS editor that came with SiteOrigin themes
|
15 |
include plugin_dir_path( __FILE__ ) . 'inc/legacy.php';
|
16 |
|
17 |
-
define( 'SOCSS_VERSION', '1.2.
|
18 |
define( 'SOCSS_JS_SUFFIX', '.min' );
|
19 |
|
20 |
/**
|
2 |
/*
|
3 |
Plugin Name: SiteOrigin CSS
|
4 |
Description: An advanced CSS editor from SiteOrigin.
|
5 |
+
Version: 1.2.12
|
6 |
Author: SiteOrigin
|
7 |
Author URI: https://siteorigin.com
|
8 |
Plugin URI: https://siteorigin.com/css/
|
14 |
// Handle the legacy CSS editor that came with SiteOrigin themes
|
15 |
include plugin_dir_path( __FILE__ ) . 'inc/legacy.php';
|
16 |
|
17 |
+
define( 'SOCSS_VERSION', '1.2.12' );
|
18 |
define( 'SOCSS_JS_SUFFIX', '.min' );
|
19 |
|
20 |
/**
|