PluginProbe ʕ •ᴥ•ʔ
SiteOrigin CSS / 1.0.2
SiteOrigin CSS v1.0.2
1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.10 1.5.11 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0
so-css / js / editor.min.js
so-css / js Last commit date
css.js 11 years ago css.min.js 11 years ago csslint.js 11 years ago csslint.min.js 11 years ago editor.js 11 years ago editor.min.js 11 years ago inspector.js 11 years ago inspector.min.js 11 years ago jquery.sizes.js 11 years ago jquery.sizes.min.js 11 years ago specificity.js 11 years ago specificity.min.js 11 years ago
editor.min.js
63 lines
1
2 (function($,_,socssOptions){var socss={model:{},collection:{},view:{},fn:{}};window.socss=socss;socss.view.toolbar=Backbone.View.extend({button:_.template('<li><a href="#" class="toolbar-button socss-button"><%= text %></a></li>'),editor:null,initialize:function(attr){this.editor=attr.editor;var thisView=this;this.$('.editor-expand').click(function(e){e.preventDefault();$(this).blur();thisView.trigger('click_expand');});this.$('.editor-visual').click(function(e){e.preventDefault();$(this).blur();thisView.trigger('click_visual');});},addButton:function(text,action){var thisView=this;var button=$(this.button({text:text})).appendTo(this.$('.toolbar-function-buttons .toolbar-buttons')).click(function(e){e.preventDefault();$(this).blur();thisView.trigger('click_'+action);});return button;}});socss.view.editor=Backbone.View.extend({codeMirror:null,snippets:null,toolbar:null,visualProperties:null,inspector:null,cssSelectors:[],initialize:function(args){this.setupEditor();},render:function(){var thisView=this;this.toolbar=new socss.view.toolbar({editor:this,el:this.$('.custom-css-toolbar')});this.toolbar.editor=this;this.toolbar.render();this.visualProperties=new socss.view.properties({editor:this,el:$('#so-custom-css-properties')});this.visualProperties.render();this.toolbar.on('click_expand',function(){thisView.toggleExpand();});this.toolbar.on('click_visual',function(){thisView.visualProperties.loadCSS(thisView.codeMirror.getValue());thisView.visualProperties.show();});this.preview=new socss.view.preview({editor:this,el:this.$('.custom-css-preview')});this.preview.render();},setupEditor:function(){var thisView=this;this.registerCodeMirrorAutocomplete();this.codeMirror=CodeMirror.fromTextArea(this.$('textarea.css-editor').get(0),{tabSize:2,mode:'css',theme:'neat',gutters:["CodeMirror-lint-markers"],lint:true});var startCss=this.$('textarea.css-editor').val();this.$el.on('submit',function(){startCss=thisView.codeMirror.getValue();});$(window).bind('beforeunload',function(){if(thisView.codeMirror.getValue()!==startCss){return socssOptions.loc.leave;}});this.$el.find('.custom-css-container').css('overflow','visible');this.scaleEditor();$(window).resize(function(){thisView.scaleEditor();});this.setupCodeMirrorExtensions();},registerCodeMirrorAutocomplete:function(){var thisView=this;var pseudoClasses={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(cm){var cur=cm.getCursor(),token=cm.getTokenAt(cur);var inner=CodeMirror.innerMode(cm.getMode(),token.state);if(inner.mode.name!=="css"){return;}
3 if(token.type==="keyword"&&"!important".indexOf(token.string)===0){return{list:["!important"],from:CodeMirror.Pos(cur.line,token.start),to:CodeMirror.Pos(cur.line,token.end)};}
4 var start=token.start,end=cur.ch,word=token.string.slice(0,end-start);if(/[^\w$_-]/.test(word)){word="";start=end=cur.ch;}
5 var spec=CodeMirror.resolveMode("text/css");var result=[];function add(keywords){for(var name in keywords){if(!word||name.lastIndexOf(word,0)===0){result.push(name);}}}
6 var st=inner.state.state;if(st==='top'){var line=cm.getLine(cur.line).trim();var selectors=thisView.cssSelectors;for(var i=0;i<selectors.length;i++){if(selectors[i].selector.indexOf(line)!==-1){result.push(selectors[i].selector);}}
7 if(result.length){return{list:result,from:CodeMirror.Pos(cur.line,0),to:CodeMirror.Pos(cur.line,end)};}}
8 else{if(st==="pseudo"||token.type==="variable-3"){add(pseudoClasses);}
9 else if(st==="block"||st==="maybeprop"){add(spec.propertyKeywords);}
10 else if(st==="prop"||st==="parens"||st==="at"||st==="params"){add(spec.valueKeywords);add(spec.colorKeywords);}
11 else if(st==="media"||st==="media_parens"){add(spec.mediaTypes);add(spec.mediaFeatures);}
12 if(result.length){return{list:result,from:CodeMirror.Pos(cur.line,start),to:CodeMirror.Pos(cur.line,end)};}}});},setupCodeMirrorExtensions:function(){var thisView=this;this.codeMirror.on('cursorActivity',function(cm){var cur=cm.getCursor(),token=cm.getTokenAt(cur);var inner=CodeMirror.innerMode(cm.getMode(),token.state);if(token.type==='qualifier'||token.type==='tag'||token.type==='builtin'){var line=cm.getLine(cur.line);var selector=line.substring(0,token.end);thisView.preview.highlight(selector);}
13 else{thisView.preview.clearHighlight();}});this.codeMirror.on('keyup',function(cm,e){if((e.keyCode>=65&&e.keyCode<=90)||(e.keyCode===189&&!e.shiftKey)||(e.keyCode===190&&!e.shiftKey)||(e.keyCode===51&&e.shiftKey)||(e.keyCode===189&&e.shiftKey)){cm.showHint(e);}});},scaleEditor:function(){if(this.$el.hasClass('expanded')){this.codeMirror.setSize('100%',$(window).outerHeight()-this.$('.custom-css-toolbar').outerHeight());}
14 else{this.codeMirror.setSize('100%','auto');}},isExpanded:function(){return this.$el.hasClass('expanded');},toggleExpand:function(){this.$el.toggleClass('expanded');this.scaleEditor();},setExpand:function(expanded){if(expanded){this.$el.addClass('expanded');}
15 else{this.$el.removeClass('expanded');}
16 this.scaleEditor();},setSnippets:function(snippets){if(!_.isEmpty(snippets)){var thisView=this;this.snippets=new socss.view.snippets({snippets:snippets});this.snippets.editor=this;this.snippets.render();this.toolbar.addButton('Snippets','snippets');this.toolbar.on('click_snippets',function(){thisView.snippets.show();});}},addCode:function(css){var editor=this.codeMirror;var before_css='';if(editor.doc.lineCount()===1&&editor.doc.getLine(editor.doc.lastLine()).length===0){before_css="";}
17 else if(editor.doc.getLine(editor.doc.lastLine()).length===0){before_css="\n";}
18 else{before_css="\n\n";}
19 editor.doc.setCursor(editor.doc.lastLine(),editor.doc.getLine(editor.doc.lastLine()).length);editor.doc.replaceSelection(before_css+css);},addEmptySelector:function(selector){this.addCode(selector+" {\n \n}");},setInspector:function(inspector){var thisView=this;this.inspector=inspector;this.cssSelectors=inspector.pageSelectors;inspector.on('click_selector',function(selector){if(thisView.visualProperties.isVisible()){thisView.visualProperties.addSelector(selector);}
20 else{thisView.addEmptySelector(selector);}});inspector.on('click_property',function(property){if(!thisView.visualProperties.isVisible()){thisView.codeMirror.replaceSelection(property+";\n ");}});inspector.on('set_active_element',function(el,selectors){if(thisView.visualProperties.isVisible()&&selectors.length){thisView.visualProperties.addSelector(selectors[0].selector);}});}});socss.view.preview=Backbone.View.extend({template:_.template('<iframe class="preview-iframe" seamless="seamless"></iframe>'),editor:null,initialize:function(attr){this.editor=attr.editor;var thisView=this;this.editor.codeMirror.on('change',function(cm,c){thisView.updatePreviewCss();});},render:function(){var thisView=this;this.$el.html(this.template());this.$('.preview-iframe').attr('src',socssOptions.homeURL).load(function(){var $$=$(this);$$.contents().find('a').each(function(){var href=$(this).attr('href');if(href===undefined){return true;}
21 var firstSeperator=(href.indexOf('?')===-1?'?':'&');$(this).attr('href',href+firstSeperator+'so_css_preview=1');});thisView.updatePreviewCss();}).mouseleave(function(){thisView.clearHighlight();});},updatePreviewCss:function(){var preview=this.$('.preview-iframe');if(preview.length===0){return;}
22 var head=preview.contents().find('head');if(head.find('style.siteorigin-custom-css').length===0){head.append('<style class="siteorigin-custom-css" type="text/css"></style>');}
23 var style=head.find('style.siteorigin-custom-css');var css=this.editor.codeMirror.getValue();style.html(css);},highlight:function(selector){try{this.editor.inspector.hl.highlight(selector);}
24 catch(err){console.log('No inspector to highlight with');}},clearHighlight:function(){try{this.editor.inspector.hl.clear();}
25 catch(err){console.log('No inspector to highlight with');}}});socss.view.snippets=Backbone.View.extend({template:_.template($('#template-snippet-browser').html()),snippet:_.template('<li class="snippet"><%- name %></li>'),className:'css-editor-snippet-browser',snippets:null,editor:null,events:{'click .close':'hide','click .buttons .insert-snippet':'insertSnippet'},currentSnippet:null,initialize:function(args){this.snippets=args.snippets;},render:function(){var thisView=this;var clickSnippet=function(e){e.preventDefault();var $$=$(this);thisView.$('.snippets li.snippet').removeClass('active');$(this).addClass('active');thisView.viewSnippet({name:$$.html(),description:$$.data('description'),css:$$.data('css')});};this.$el.html(this.template());for(var i=0;i<this.snippets.length;i++){$(this.snippet({name:this.snippets[i].Name})).data({'description':this.snippets[i].Description,'css':this.snippets[i].css}).appendTo(this.$('ul.snippets')).click(clickSnippet);}
26 thisView.$('.snippets li.snippet').eq(0).click();this.attach();return this;},viewSnippet:function(args){var w=this.$('.main .snippet-view');w.find('.snippet-title').html(args.name);w.find('.snippet-description').html(args.description);w.find('.snippet-code').html(args.css);this.currentSnippet=args;},insertSnippet:function(){var editor=this.editor.codeMirror;var css=this.currentSnippet.css;var before_css='';if(editor.doc.lineCount()===1&&editor.doc.getLine(editor.doc.lastLine()).length===0){before_css="";}
27 else if(editor.doc.getLine(editor.doc.lastLine()).length===0){before_css="\n";}
28 else{before_css="\n\n";}
29 editor.doc.setCursor(editor.doc.lastLine(),editor.doc.getLine(editor.doc.lastLine()).length);editor.doc.replaceSelection(before_css+css);this.hide();},attach:function(){this.$el.appendTo('body');},show:function(){this.$el.show();},hide:function(){this.$el.hide();}});socss.view.properties=Backbone.View.extend({model:socss.model.cssRules,tabTemplate:_.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),sectionTemplate:_.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),controllerTemplate:_.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),propertyControllers:[],editor:null,css:'',parsed:{},activeSelector:'',editorExpandedBefore:false,events:{'click .close':'hide'},initialize:function(attr){this.parser=new cssjs();this.editor=attr.editor;},render:function(){var thisView=this;var controllers=socssOptions.propertyControllers;for(var id in controllers){var $t=$(this.tabTemplate({id:id,icon:controllers[id].icon,title:controllers[id].title})).appendTo(this.$('.section-tabs'));var $s=$(this.sectionTemplate({id:id})).appendTo(this.$('.sections'));if(!_.isEmpty(controllers[id].controllers)){for(var i=0;i<controllers[id].controllers.length;i++){var $c=$(thisView.controllerTemplate({title:controllers[id].controllers[i].title})).appendTo($s.find('tbody'));var controllerAtts=controllers[id].controllers[i];var controller;if(typeof socss.view.properties.controllers[controllerAtts.type]==='undefined'){controller=new socss.view.propertyController({el:$c.find('td'),propertiesView:thisView,args:(typeof controllerAtts.args==='undefined'?{}:controllerAtts.args)});}
30 else{controller=new socss.view.properties.controllers[controllerAtts.type]({el:$c.find('td'),propertiesView:thisView,args:(typeof controllerAtts.args==='undefined'?{}:controllerAtts.args)});}
31 thisView.propertyControllers.push(controller);controller.render();controller.initChangeEvents();}}}
32 this.$('.section-tabs li').click(function(){var $$=$(this);var show=thisView.$('.sections .section[data-section="'+$$.data('section')+'"]');thisView.$('.sections .section').not(show).hide().removeClass('active');show.show().addClass('active');thisView.$('.section-tabs li').not($$).removeClass('active');$$.addClass('active');}).eq(0).click();this.$('.toolbar select').change(function(){thisView.setActivateSelector($(this).find(':selected').data('selector'));});},setRuleValue:function(rule,value){if(typeof this.activeSelector==='undefined'||typeof this.activeSelector.rules==='undefined'){return;}
33 var newRule=true;for(var i=0;i<this.activeSelector.rules.length;i++){if(this.activeSelector.rules[i].directive===rule){this.activeSelector.rules[i].value=value;newRule=false;break;}}
34 if(newRule){this.activeSelector.rules.push({directive:rule,value:value});}
35 this.updateMainEditor(false);},getRuleValue:function(rule){if(typeof this.activeSelector==='undefined'||typeof this.activeSelector.rules==='undefined'){return'';}
36 for(var i=0;i<this.activeSelector.rules.length;i++){if(this.activeSelector.rules[i].directive===rule){return this.activeSelector.rules[i].value;}}
37 return'';},updateMainEditor:function(compress){var css;if(typeof compress==='undefined'||compress===true){css=this.parser.compressCSS(this.parsed);css=css.filter(function(v){return(typeof v.type!=='undefined'||v.rules.length>0);});}
38 else{css=this.parsed;}
39 this.editor.codeMirror.setValue(this.parser.getCSSForEditor(css).trim());},show:function(){this.editorExpandedBefore=this.editor.isExpanded();this.editor.setExpand(true);this.$el.show().animate({'left':0},'fast');},hide:function(){this.editor.setExpand(this.editorExpandedBefore);this.$el.animate({'left':-338},'fast',function(){$(this).hide();});this.updateMainEditor(true);},isVisible:function(){return this.$el.is(':visible');},loadCSS:function(css,activeSelector){this.css=css;this.parsed=this.parser.compressCSS(this.parser.parseCSS(css));var dropdown=this.$('.toolbar select').empty();for(var i=0;i<this.parsed.length;i++){var rule=this.parsed[i];if(typeof rule.subStyles!=='undefined'){for(var j=0;j<rule.subStyles.length;j++){var subRule=rule.subStyles[j];dropdown.append($('<option>').html(rule.selector+': '+subRule.selector).attr('val',rule.selector+': '+subRule.selector).data('selector',subRule));}}
40 else{dropdown.append($('<option>').html(rule.selector).attr('val',rule.selector).data('selector',rule));}}
41 if(typeof activeSelector==='undefined'){activeSelector=dropdown.find('option').eq(0).attr('val');}
42 dropdown.val(activeSelector).change();},setActivateSelector:function(selector){this.activeSelector=selector;for(var i=0;i<this.propertyControllers.length;i++){this.propertyControllers[i].refreshFromRule();}},addSelector:function(selector){var dropdown=this.$('.toolbar select');dropdown.val(selector);if(dropdown.val()===selector){dropdown.change();}
43 else{this.editor.addEmptySelector(selector);this.loadCSS(this.editor.codeMirror.getValue(),selector);}
44 dropdown.addClass('highlighted');setTimeout(function(){dropdown.removeClass('highlighted');},2000);}});socss.view.propertyController=Backbone.View.extend({template:_.template('<input type="text" value="" />'),activeRule:null,args:null,propertiesView:null,initialize:function(args){this.args=args.args;this.propertiesView=args.propertiesView;this.on('set_value',this.updateRule,this);this.on('change',this.updateRule,this);},render:function(){this.$el.append($(this.template({})));this.field=this.$('input');},initChangeEvents:function(){var thisView=this;this.field.on('change keyup',function(){thisView.trigger('change',$(this).val());});},updateRule:function(){this.propertiesView.setRuleValue(this.args.property,this.getValue());},refreshFromRule:function(){var value=this.propertiesView.getRuleValue(this.args.property);this.setValue(value,{silent:true});},getValue:function(){return this.field.val();},setValue:function(val,options){options=_.extend({silent:false},options);this.field.val(val);if(!options.silent){this.trigger('set_value',val);}},reset:function(options){options=_.extend({silent:false},options);this.setValue('',options);}});socss.view.properties.controllers={};socss.view.properties.controllers.color=socss.view.propertyController.extend({template:_.template('<input type="text" value="" />'),render:function(){var thisView=this;this.$el.append($(this.template({})));this.field=this.$el.find('input');this.field.minicolors({});},initChangeEvents:function(){var thisView=this;this.field.on('change keyup',function(){thisView.trigger('change',thisView.field.minicolors('value'));});},getValue:function(){return this.field.minicolors('value');},setValue:function(val,options){options=_.extend({silent:false},options);this.field.minicolors('value',val);if(!options.silent){this.trigger('set_value',val);}}});socss.view.properties.controllers.select=socss.view.propertyController.extend({template:_.template('<select></select>'),render:function(){var thisView=this;this.$el.append($(this.template({})));this.field=this.$el.find('select');this.field.append($('<option value=""></option>').html(''));for(var k in this.args.options){this.field.append($('<option></option>').attr('value',k).html(this.args.options[k]));}
45 if(typeof this.args.option_icons!=='undefined'){this.setupVisualSelect();}},setupVisualSelect:function(){var thisView=this;this.field.hide();var $tc=$('<div class="select-tabs"></div>').appendTo(this.$el);$('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo($tc);for(var k in this.args.option_icons){$('<div class="select-tab"></div>').appendTo($tc).append($('<span class="fa"></span>').addClass('fa-'+this.args.option_icons[k])).attr('data-value',k);}
46 $tc.find('.select-tab').css('width',100/($tc.find('>div').length)+"%").click(function(){var $t=$(this);$tc.find('.select-tab').removeClass('active');$t.addClass('active');thisView.field.val($t.data('value')).change();});},setValue:function(val,options){options=_.extend({silent:false},options);this.field.val(val);this.$('.select-tabs .select-tab').removeClass('active').filter('[data-value="'+val+'"]').addClass('active');if(!options.silent){this.trigger('set_value',val);}}});socss.view.properties.controllers.image=socss.view.propertyController.extend({template:_.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),render:function(){var thisView=this;this.media=wp.media({title:socssOptions.loc.select_image,library:{type:'image'},button:{text:socssOptions.loc.select,close:false}});this.$el.append($(this.template({select:socssOptions.loc.select})));this.field=this.$el.find('input');this.$('.select').click(function(){thisView.media.open();});this.media.on('select',function(){var attachment=this.state().get('selection').first().attributes;var val=thisView.args.value.replace('{{url}}',attachment.url);thisView.field.val(val).change();thisView.media.close();},this.media);}});socss.view.properties.controllers.measurement=socss.view.propertyController.extend({wrapperClass:'socss-field-measurement',render:function(){this.$el.append($(this.template({})));this.field=this.$('input');this.setupMeasurementField(this.field,{});},setValue:function(val,options){options=_.extend({silent:false},options);this.field.val(val).trigger('measurement_refresh');if(!options.silent){this.trigger('set_value',val);}},units:['px','%','em','cm','mm','in','pt','pc','ex','ch','rem','vw','vh','vmin','vmax'],parseUnits:function(value){var escapeRegExp=function(str){return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");};var regexUnits=this.units.map(escapeRegExp);var regex=new RegExp('([0-9\\.\\-]+)('+regexUnits.join('|')+')?','i');var result=regex.exec(value);if(result===null){return{value:'',unit:''};}
47 else{return{value:result[1],unit:result[2]===undefined?'':result[2]};}},setupMeasurementField:function($el,options){var thisView=this;var $p=$el.parent();options=_.extend({defaultUnit:'px'},options);$el.hide();$p.addClass(this.wrapperClass).data('unit',options.defaultUnit);var $fi=$('<input type="text" class="socss-field-input"/>').appendTo($p);var $da=$('<span class="dashicons dashicons-arrow-down"></span>').appendTo($p);var $dd=$('<ul class="dropdown"></ul>').appendTo($p);var $u=$('<span class="units"></span>').html(options.defaultUnit).appendTo($p);for(var i=0;i<thisView.units.length;i++){var $o=$('<li></li>').html(thisView.units[i]).data('unit',thisView.units[i]);if(thisView.units[i]===options.defaultUnit){$o.addClass('active');}
48 $dd.append($o);}
49 var updateValue=function(){var value=thisView.parseUnits($fi.val());if(value.unit!==''&&value.unit!==$p.data('unit')){$fi.val(value.value);setUnit(value.unit);}
50 if(value.value===''){$el.val('');}
51 else{$el.val(value.value+$p.data('unit'));}};var setUnit=function(unit){$u.html(unit);$p.data('unit',unit);$fi.trigger('keydown');};$da.click(function(){$dd.toggle();});$dd.find('li').click(function(){$dd.toggle();setUnit($(this).data('unit'));updateValue();$el.trigger('change');});$fi.on('keyup keydown',function(e){var $$=$(this);var char='';if(e.type==='keydown'){if(e.keyCode>=48&&e.keyCode<=57){char=String.fromCharCode(e.keyCode);}
52 else if(e.keyCode===189){char='-';}
53 else if(e.keyCode===190){char='.';}}
54 var $pl=$('<span class="socss-hidden-placeholder"></span>').css({'font-size':'14px'}).html($fi.val()+char).appendTo('body');var width=$pl.width();width=Math.min(width,63);$pl.remove();$u.css('left',width+12);});$fi.on('keyup',function(e){updateValue();$el.trigger('change');});$el.on('measurement_refresh',function(){var value=thisView.parseUnits($el.val());$fi.val(value.value);var unit=value.unit===''?options.defaultUnit:value.unit;$p.data('unit',unit);$u.html(unit);var $pl=$('<span class="socss-hidden-placeholder"></span>').css({'font-size':'14px'}).html(value.value).appendTo('body');var width=$pl.width();width=Math.min(width,63);$pl.remove();$u.css('left',width+12);});var $diw=$('<div class="socss-diw"></div>').appendTo($p);var $dec=$('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo($diw);var $inc=$('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo($diw);$inc.click(function(){var value=thisView.parseUnits($el.val());if(value.value===''){return true;}
55 var newVal=Math.ceil(value.value*1.05);$fi.val(newVal);updateValue();$el.trigger('change').trigger('measurement_refresh');});$dec.click(function(){var value=thisView.parseUnits($el.val());if(value.value===''){return true;}
56 var newVal=Math.floor(value.value/1.05);$fi.val(newVal);updateValue();$el.trigger('change').trigger('measurement_refresh');});}});socss.view.properties.controllers.number=socss.view.propertyController.extend({render:function(){this.$el.append($(this.template({})));this.field=this.$('input');this.setupNumberField(this.field,this.args);},setupNumberField:function($el,options){options=_.extend({change:null,default:0,increment:1,decrement:-1,max:null,min:null},options);var $p=$el.parent();$p.addClass('socss-field-number');var $diw=$('<div class="socss-diw"></div>').appendTo($p);var $dec=$('<div class="dec-button socss-button">-</div>').appendTo($diw);var $inc=$('<div class="inc-button socss-button">+</div>').appendTo($diw);$diw.find('> div').click(function(e){e.preventDefault();var val=options.default;if($el.val()!==''){val=Number($el.val());}
57 val=val+($(this).is($dec)?options.decrement:options.increment);val=Math.round(val*100)/100;if(options.max!==null){val=Math.min(options.max,val);}
58 if(options.min!==null){val=Math.max(options.min,val);}
59 $el.val(val);$el.trigger('change');});return this;}});socss.view.properties.controllers.sides=socss.view.propertyController.extend({template:_.template($('#template-sides-field').html().trim()),controllers:[],render:function(){var thisView=this;this.$el.append($(this.template({})));this.field=this.$el.find('input');if(!thisView.args.hasAll){this.$('.select-tab').eq(0).remove();this.$('.select-tab').css('width','25%');}
60 this.$('.select-tab').each(function(){var dir=$(this).data('direction');var container=$('<li class="side">').appendTo(thisView.$('.sides')).hide();for(var i=0;i<thisView.args.controllers.length;i++){var controllerArgs=thisView.args.controllers[i];if(typeof socss.view.properties.controllers[controllerArgs.type]){var property='';if(dir==='all'){property=controllerArgs.args.propertyAll;}
61 else{property=controllerArgs.args.property.replace('{dir}',dir);}
62 var theseControllerArgs=_.extend({},controllerArgs.args,{property:property});var controller=new socss.view.properties.controllers[controllerArgs.type]({el:$('<div>').appendTo(container),propertiesView:thisView.propertiesView,args:theseControllerArgs});controller.render();controller.initChangeEvents();thisView.propertiesView.propertyControllers.push(controller);}}
63 $(this).on('click',function(){thisView.$('.select-tab').removeClass('active');$(this).addClass('active');thisView.$('.sides .side').hide();container.show();});});this.$('.select-tab').eq(0).click();}});})(jQuery,_,socssOptions);jQuery(function($){var socss=window.socss;var editor=new socss.view.editor({el:$('#so-custom-css-form').get(0)});editor.render();editor.setSnippets(socssOptions.snippets);window.socss.mainEditor=editor;$('#so-custom-css-getting-started a.hide').click(function(e){e.preventDefault();$('#so-custom-css-getting-started').slideUp();$.get($(this).attr('href'));});});