PATH:
home
/
letacommog
/
letaweb
/
scripts
/* Stylesheet helper functions */ var SelectorList = function(name) { this.list = []; this.name = name; this.copy = function(arr) { if($.isArray(arr)) this.list = this.copyArray(arr); else this.list = this.copyArray( arr.getList() ); }; this.copyArray = function(arr) { var rs = []; for(var i = 0; i < arr.length; i++) { var selector = arr[i].selector; var selector_body = arr[i].selector_body != undefined ? arr[i].selector_body : []; var sb = []; for(var j = 0; j < selector_body.length; j++) { sb.push( { property : selector_body[j].property, value : selector_body[j].value } ); } rs.push( {selector:selector, selector_body : sb } ); } return rs; }; this.editBlock = function(selector, block) { return this._editBlock(selector, block); }; this._editBlock = function(selector, block) { var flag = false; var index = -1; for(var i = 0; i < this.list.length;i++) { if(this.list[i].selector == selector) { flag = true; index = i; this.list[i].selector_body = block; break; } } if(!flag) { if(selector[0] == '@') { var n = {selector: selector, rules: block }; } else n = {selector: selector, selector_body: block }; this.list.push(n); index = this.list.length - 1; } return index; }; this.add = function(selector, parentIndex) { var search_list = this.list; if(parentIndex >=0 && this.list[parentIndex] != undefined) { search_list = this.list[parentIndex]; } if(selector[0] == '@') search_list.push({selector: selector, rules: [] }); else search_list.push({selector: selector, selector_body: [] }); return search_list.length - 1; }; this.edit = function(selector, property, value, parentIndex) { var search_list = this.list; if(parentIndex >=0 && this.list[parentIndex] != undefined) { search_list = this.list[parentIndex]; } var flag = false; var index = -1; for(var i = 0; i < search_list.length;i++) { if(search_list[i].selector == selector) { flag = true; var iflag = false; index = i; for(var j = 0;j < search_list[i].selector_body.length;j++) { if(search_list[i].selector_body[j].property == property) { iflag = true; search_list[i].selector_body[j].value = value; } } if(!iflag) { search_list[i].selector_body.push( {property:property, value: value} ); } break; } } if(!flag) { var n = {selector: selector, selector_body: [] }; n.selector_body.push( {property:property, value: value} ); search_list.push(n); index = search_list.length - 1; } return index; }; this.remove = function(index,parentIndex) { var search_list = this.list; if(parentIndex >=0 && this.list[parentIndex] != undefined) { search_list = this.list[parentIndex]; } search_list.splice(index,1); } this.editBackgroundGradient = function(selector, property, value) { var flag = false; var index = -1; var gradient_tags = StyleSheet.gradient_tags; var type = ''; for(var i = 0; i < gradient_tags.length;i++) { if( value.indexOf( gradient_tags[i] ) != -1 ) { type = gradient_tags[i]; break; } } if(type == '') return -1; for(var i = 0; i < this.list.length;i++) { if(this.list[i].selector == selector ) { flag = true; var iflag = false; index = i; for(var j = 0;j < this.list[i].selector_body.length;j++) { if(this.list[i].selector_body[j].property == property && this.list[i].selector_body[j].value.indexOf( type ) == 0) { iflag = true; this.list[i].selector_body[j].value = value; } } if(!iflag) { this.list[i].selector_body.push( {property:property, value: value} ); } break; } } if(!flag) { var n = {selector: selector, selector_body: [] }; n.selector_body.push( {property:property, value: value} ); this.list.push(n); index = this.list.length - 1; } return index; }; this.deleteSelector = function(selector) { var rs = []; for(var i = this.list.length - 1; i >= 0;i--) { if(this.list[i].selector == selector) { this.list.splice(i, 1); rs.push(i) } } return rs; }; this.deleteProperty = function(selector, property) { var rs = []; for(var i = this.list.length - 1; i >= 0;i--) { if(this.list[i].selector == selector) { for(var j = this.list[i].selector_body.length - 1;j >= 0 ;j--) { if(this.list[i].selector_body[j].property == property) { this.list[i].selector_body.splice(j, 1); } } rs.push(i); } } return rs; }; this.getIndex = function(selector) { for(var i = 0; i < this.list.length;i++) { if(this.list[i].selector == selector) { return i; } } return -1; }; this.getValue = function(index) { if(this.list[index]) return this.list[index]; return null; }; this.setValue = function(value,index) { this.list[index] = value; }; this.getList = function() { return this.list; }; this.getLength = function() { return this.list.length; }; }; var StyleSheetObj = function(styleSheetObj, name) { this.styleSheet = styleSheetObj; this.selectorList = new SelectorList('selector'); this.selectorList_bak = new SelectorList('selector backup'); this.selectorList_original = new SelectorList('selector original'); this.skinSelectorList = new SelectorList('skin list'); this.skinSelectorList_bak = new SelectorList('skin list backup'); this.skinSelectorList_original = new SelectorList('skin list original'); this.name = name; this.history = []; this.styleSheet = styleSheetObj; this.getObject = function() { return {name: this.name, css: this.selectorList.list, skin : this.skinSelectorList.list}; }; this.getStylesById = function(id) { var rules = []; var index = 0; for(var i in this.selectorList) { if( !this.selectorList.hasOwnProperty( i ) ) continue; var selector = this.selectorList[i]['selector']; var selector_body = this.selectorList[i]['selector_body']; if(selector.indexOf(id) >=0) { rules[index] = {}; rules[index].selector = selector; rules[index].selector_body = selector_body; rules[index].index = i; } index++; } return stringRules; }; this.getPropertyValue = function(selector, property) { var list = this.selectorList.list for(var i in list) { if( !list.hasOwnProperty( i ) ) continue; var s = $.trim(list[i]['selector']); selector = $.trim(selector); if(s == selector ) { var selector_body = list[i]['selector_body']; for(var j in selector_body) { if( !selector_body.hasOwnProperty( j) ) continue; if(selector_body[j].property == property) return selector_body[j].value; } } } }; this.removeProperty = function(selector, property) { var s = (this.backup_mode == true ? this.selectorList_bak : this.selectorList); var rs = s.deleteProperty(selector, property); for(var i = 0;i < rs.length;i++) { this.updateSelectorList(s.list, rs[i]); } }; this.updateSelectorList = function(list,i) { var s = this.getStringRules(list[i].selector_body); this.updateRule(list[i].selector, s, i); }; this.removeStylesByClass = function(cl) { this.removeStylesById(cl); }; this.removeStylesById = function(id) { var rules = []; var s = (this.backup_mode == true ? this.selectorList_bak : this.selectorList); var l = s.list.length; for(var i=l-1;i>= 0;i--) { var selector = s.list[i]['selector']; if(!selector) continue; if(selector.indexOf(id) >=0) { if(this.removeRule(i)) s.list.splice(i,1); } } s = (this.backup_mode == true ? this.skinSelectorList_bak : this.skinSelectorList); var l = s.list.length; for(var i=l-1;i>= 0;i--) { var selector = s.list[i]['selector']; if(!selector) continue; if(selector.indexOf(id) >=0) { s.list.splice(i,1); } } }; this.getResponse = function(response) { var href = this.styleSheet.href; if( !response[ href ] ) return; if( !response[ href ] [ 'css' ] && !response[ href ] [ 'skin' ] ) return; var css = response[ href ] [ 'css' ]; var skin = response[ href ] [ 'skin' ]; this.selectorList.copy(css); this.selectorList_bak.copy(css); this.selectorList_original.copy(css); this.skinSelectorList.copy(skin); this.skinSelectorList_bak.copy(skin); this.skinSelectorList_original.copy(skin); var that = this; $(document).bind('changePalette', function() { that.changePalette(); }); this.loaded = true; }; this.getSelectorList = function(response) { }; this.importStylesheetContent = function(data) { var css = data; this.selectorList.copy(css); this.selectorList_bak.copy(css); this.selectorList_original.copy(css); //this.skinSelectorList.copy(skin); //this.skinSelectorList_bak.copy(skin); //this.skinSelectorList_original.copy(skin); var that = this; $(document).bind('changePalette', function() { that.changePalette(); }); //this.loaded = true; }; this.getHref = function(){ return this.styleSheet.href}; this.is_loaded = function() { if(this.loaded) return true; return false;} this.getStylesheetContents = function () { if(this.loaded) return; var href = this.styleSheet.href; var that =this; PM.communication.getStylesheetContents(href, function(response) { that.getResponse(response); }); }; this.changePalette = function() { var l = this.skinSelectorList.getList(); for(var i = 0;i < l.length;i++) { var selector = l[i].selector; if(l[i].selector_body != undefined) for(var j = 0;j < l[i].selector_body.length;j++) this._setCSS(selector, l[i].selector_body[j].property, l[i].selector_body[j].value); if(l[i].rules != undefined) for(var j = 0;j < l[i].selector_body.length;j++) this._setMediaCSS(selector, l[i].rules); } }; this.getStringRules = function(selector_body) { if(selector_body == undefined) return false; var stringRules = ''; for(var j = 0; j< selector_body.length;j++) { stringRules += selector_body[j]['property'] + ':' + selector_body[j]['value'] + ';'; } return stringRules; }; this.getMediaStringRules = function(rules) { var stringRules = ''; for(var j = 0; j< rules.length;j++) { stringRules += rules[j]['selector'] + '{'; for(var i = 0; i< rules[j]['selector_body'].length;i++) { stringRules += rules[j]['selector_body'][i]['property'] + ':' + rules[j]['selector_body'][i]['value'] + ';'; } stringRules += '}' } return stringRules; }; this.updateCSS = function(css) { var i =0; var s = (this.backup_mode == true ? this.selectorList_bak : this.selectorList); var j = s.length >= css.length ? css.length : s.length for(;i<j;i++) { this.updateRule(css[i]['selector'], this.getStringRules(css[i]['selector_body']), i, global); } for(i = this.selectorList.length - 1;i >=j;i--) { this.removeRule(i); } for(i=j;i < css.length;i++) { this.addRule(css[i]['selector'], this.getStringRules(css[i]['selector_body']), i); } this.selectorList = css.slice(); this.selectorList_bak = css.slice(); }; this.getCSSCode = function() { var s = this.selectorList.list; console.log(s); var stringRules = ''; var index = 0; for(var i in s) { if( !s.hasOwnProperty( i ) ) continue; var selector = s[i]['selector']; stringRules = stringRules + '\n' +selector + '\n{'; var selector_body = s[i]['selector_body']; if(selector_body != undefined) for(var j = 0;j < selector_body.length;j++) { var skinValue = this.getCSSSkinCodeValue(selector, selector_body[j]['property']); stringRules += '\n\t' + selector_body[j]['property'] + ':' + (skinValue || selector_body[j]['value']) +';'; } var rules = s[i]['rules']; if(rules != undefined) { for(var j = 0;j < rules.length;j++) { stringRules = stringRules + '\n' +rules[k].selector + '\n{'; for(var k = 0; k < rules[j].selector_body;k++) { var skinValue = this.getCSSSkinCodeValue(rules[k].selector, rules[k].selector_body['property'],i); stringRules += '\n\t' + rules[k].selector_body['property'] + ':' + (skinValue || rules[k].selector_body['value']) +';'; } stringRules += '\n}'; } } stringRules += '\n}'; } return stringRules; }; this.getCSSSkinCodeValue = function(selector, property, parentIndex) { var stringRules = ''; var s = this.skinSelectorList.list; if(s[parentIndex] != undefined) s = s[parentIndex]; for(var i in s) { if( !s.hasOwnProperty( i ) ) continue; if(selector == s[i]['selector']) { var selector_body = s[i]['selector_body']; for(var j = 0;j < selector_body.length;j++) { if(property == selector_body[j]['property']) return selector_body[j]['value']; } } stringRules += '\n}'; } }; this.updateSkinSelectorList = function(selector, property, value, parentStyleIndex,isImportant) { var s = (this.backup_mode == true ? this.skinSelectorList_bak : this.skinSelectorList); if(property.indexOf('background-image') != -1 && value.indexOf('gradient') != -1 ) s.editBackgroundGradient(selector, property, value); else s.edit(selector, property, value); }; this.removeSkinSelectorList = function(selector, property, value, isImportant) { var s = (this.backup_mode == true ? this.skinSelectorList_bak : this.skinSelectorList); s.deleteProperty(selector, property); }; this.parseSkinValue = function(value,isImportant) { var v = value; if(window.palette) { index = 0; while( (index=v.indexOf("##",index)) != -1) { var spaceIndex = v.indexOf(' ', index); if(spaceIndex == -1) spaceIndex = v.length; var colorIndex = v.substr(index + 2, spaceIndex - 1); colorIndex = parseInt(colorIndex); var color = window.palette.getColor(colorIndex)+(isImportant?" !important":""); v = v.substr(0, index) + color + (spaceIndex <v.length-1 ? ' ' + v.substr(spaceIndex+1, v.length): ''); } } return v; }; this.getCSSValue = function(ss, property, value, isImportant) { var v = ''; value += ""; if( value !== "" &&value !== "NaN" ) { if( value.indexOf(" ")!==-1 && value.indexOf(",")==-1 && property.indexOf("background")==-1 && property.indexOf("border")==-1 && property.indexOf("text")==-1 && property.indexOf("box-shadow")==-1 && property.indexOf("transition")==-1 && property.indexOf("padding")==-1 && property.indexOf("margin")==-1 && property.indexOf("display")==-1 && property.indexOf("position")==-1 && property.indexOf("list-style")==-1 && property.indexOf("font")==-1) { v += $.trim(value)+"'"+(isImportant?" !important":""); } else { v += value+(isImportant?" !important":""); } if(property.indexOf("content") >= 0) { v = ''; v += $.trim(value); } var index; if((index =value.indexOf("##")) != -1) { if(window.palette) { } v = this.parseSkinValue(value, isImportant); } if(property.indexOf("background-image") != -1 && value.indexOf("##") != -1 && value.indexOf("gradient") != -1) { v = ''; v = StyleSheet.createGradientString(value); } } return v; }; this.setEditedSelector = function (s ) { this.editSelector = s; }; this.setCSS = function ( property, value, isImportant ) { this._setCSS( this.editSelector,property, value, isImportant ); }; this.setBackgroundGradient = function( property, value) { this._setBackgroundGradient( this.editSelector,property, value, isImportant ); }; this._setBackgroundGradient = function( ss, property, value) { this.checkGradientSkinValue( ss, property, value) ; var stringRules = ''; var s = (this.backup_mode == true ? this.selectorList_bak : this.selectorList); var index = 0; var index1 = s.getIndex(ss); var value = this.getCSSValue(ss, property, value); index = s.editBackgroundGradient(ss, property, value); stringRules = this.getStringRules( s.getValue(index).selector_body ); if(index1 < 0) { var length = s.getLength(); this.addRule(ss, stringRules, length - 1); } else { this.updateRule(ss, stringRules, index); } this.changed = true; this.changedOriginal = true; }; this._setMediaCSS = function ( ss,rules ) { var index1 = s.getIndex(ss); var need_add = index1 < 0; var oldCSS; if(index1) oldCSS = s.getValue(index1); if(index1 < 0) { index1 = s.add(ss); } for(var i = 0;i < rules.length;i++) { this.checkSkinValue( rules[i]['selector'], rules[i]['selector_body'].property, rules[i]['selector_body'].value, index1) ; s.edit(rules[i]['selector'], rules[i]['selector_body'].property, rules[i]['selector_body'].value, index1); } stringRules = this.getMediaStringRules( s.getValue(index1).rules ); if(need_add) { var length = s.getLength(); try { this.addRule(ss, stringRules, length - 1); } catch(e) { console.log(e); s.remove(index); } } else { try { this.updateRule(ss, stringRules, index); } catch(e) { console.log(e); s.setValue(oldCSS, index); } } this.changed = true; this.changedOriginal = true; }; this._setCSS = function ( ss,property, value, isImportant ) { if(property == 'background-image' && value.indexOf('gradient') != -1) { this._setBackgroundGradient( ss, property, value); return; } this.checkSkinValue( ss, property, value) ; var stringRules = ''; var s = (this.backup_mode == true ? this.selectorList_bak : this.selectorList); var index = 0; var index1 = s.getIndex(ss); var value = this.getCSSValue(ss, property, value, isImportant); var oldCSS; if(index1) oldCSS = s.getValue(index1); index = s.edit(ss, property, value); stringRules = this.getStringRules( s.getValue(index).selector_body ); if(index1 < 0) { var length = s.getLength(); try { this.addRule(ss, stringRules, length - 1); } catch(e) { console.log(e); s.remove(index); } } else { try { this.updateRule(ss, stringRules, index); } catch(e) { console.log(e); s.setValue(oldCSS, index); } } this.changed = true; this.changedOriginal = true; //this.addToHistory(ss, hrl,index); }; this.replaceContent = function(content) { this.clearContent(); var css = StyleSheet.parseCSS(content); for(var i in css) { if(!css[i]) continue; var selector = css[i].selector; var selector_body = css[i].selector_body; if(css[i].selector_body != undefined) this._setCSSBlock(selector, css[i].selector_body); else if(css[i].rules != undefined) { this._setCSSMediaBlock(selector, css[i].rules); } else if(StyleSheet.isMediaType(selector) && !StyleSheet.isMediaCombinableType(selector)) { this._setCSSMedia(selector); } } this.changed = true; this.changedOriginal = true; }; this.clearContent = function() { var s = (this.backup_mode == true ? this.selectorList_bak : this.selectorList); var sk = (this.backup_mode == true ? this.skinSelectorList_bak : this.skinSelectorList); var l = s.list.length - 1; for(var i = l; i >=0 ;i--) { this.removeRule(i); } s.list = []; sk.list = []; this.changed = true; this.changedOriginal = true; }; this.checkSkinValue = function(ss, property, value, parentStyleIndex,isImportant ) { if(/*property.indexOf("color") != -1 && */value.indexOf("##") != -1) { this.updateSkinSelectorList(ss, property, value, parentStyleIndex,isImportant); } else /*if(property.indexOf("color") != -1)*/ { this.removeSkinSelectorList(ss, property, value, parentStyleIndex,isImportant); } }; this.checkGradientSkinValue = function(ss, property, value, isImportant ) { if(property.indexOf("background-image") != -1 && value.indexOf("gradient") != -1 && value.indexOf("##") != -1) { this.updateSkinSelectorList(ss, property, value, isImportant); } else if(property.indexOf("background-image") != -1 && value.indexOf("gradient") != -1) { this.removeSkinSelectorList(ss, property, value, isImportant); } }; this.setCSSBlock = function ( b, isImportant ) { this._setCSSBlock( this.editSelector, b, isImportant ) }; this._setCSSMedia = function ( ss ) { var s = (this.backup_mode == true ? this.selectorList_bak : this.selectorList); var index1 = s.getIndex(ss); index = s.editBlock(ss); if(index1 < 0) { var length = s.getLength(); this.addMediaRule(ss, length - 1); } else { this.updateMediaRule(ss, index); } this.changed = true; this.changedOriginal = true; }; this._setCSSMediaBlock = function ( ss,rules, isImportant ) { var stringRules = ''; var s = (this.backup_mode == true ? this.selectorList_bak : this.selectorList); var index = 0; var sr = ''; var index1 = s.getIndex(ss); var srules = [] for(var i = 0; i < rules.length;i++) { var selector = rules[i]['selector']; var selector_body = rules[i]['selector_body']; var sbody = []; for(var j = 0;j < selector_body.length;j++) { this.checkSkinValue(ss, selector_body[j].property, selector_body[j].value, index1); var v = this.getCSSValue(selector, selector_body[j].property, selector_body[j].value); sbody.push({property: selector_body.property, value: v}); } srules.push({selector:selector, selector_body:sbody}); } stringRules = ''; index = s.editBlock(ss, srules); var srules = s.getValue(index).rules; for(var i = 0; i < srules.length;i++) { stringRules += this.getStringRules( srules[i].selector_body ); } if(index1 < 0) { var length = s.getLength(); this.addRule(ss, stringRules, length - 1); } else { this.updateRule(ss, stringRules, index); } this.changed = true; this.changedOriginal = true; }; this._setCSSBlock = function ( ss,b, isImportant ) { var stringRules = ''; var s = (this.backup_mode == true ? this.selectorList_bak : this.selectorList); var index = 0; var selector_body = []; var sr = ''; for(var i = 0; i < b.length;i++) { this.checkGradientSkinValue(ss, b[i].property, b[i].value); this.checkSkinValue(ss, b[i].property, b[i].value); var v = this.getCSSValue(ss, b[i].property, b[i].value); selector_body.push({property: b[i].property, value: v}); } stringRules = ''; var index1 = s.getIndex(ss); index = s.editBlock(ss, selector_body); stringRules = this.getStringRules( s.getValue(index).selector_body ); if(index1 < 0) { var length = s.getLength(); this.addRule(ss, stringRules, length - 1); } else { this.updateRule(ss, stringRules, index); } this.changed = true; this.changedOriginal = true; }; this.setBackupMode = function() { this.backup_mode = true; this.selectorList_bak.copy(this.selectorList); this.skinSelectorList_bak.copy(this.skinSelectorList); delete this.changed; }; this.endBackupMode = function() { this.backup_mode = false; this.selectorList.copy(this.selectorList_bak); this.skinSelectorList.copy(this.skinSelectorList_bak); delete this.changed; }; this.changepage = function() { delete this.changedOriginal; delete this.backup_mode; this.selectorList_original.copy(this.selectorList); this.skinSelectorList_original.copy(this.skinSelectorList); }; this.backupCSS = function() { this.setBackupMode(); }; this.restore2Origin = function() { var se = (this.backup_mode == true ? this.selectorList_bak : this.selectorList); var ske = (this.backup_mode == true ? this.skinSelectorList_bak : this.skinSelectorList); if( this.changedOriginal) { var l = se.list.length - 1; for(var i = l; i >=0 ;i--) { this.removeRule(i); } var s = new SelectorList(); s.copy(this.selectorList_original); var sk = new SelectorList(); sk.copy(this.skinSelectorList_original); var css = s.list; this.selectorList = new SelectorList(); this.skinSelectorList = new SelectorList(); for(var i in css) { if(!css[i]) continue; var selector = css[i].selector; var selector_body = css[i].selector_body; this._setCSSBlock(selector, selector_body); } this.skinSelectorList.copy(sk); this.selectorList_bak.copy(this.selectorList); this.skinSelectorList_bak.copy(this.skinSelectorList); } delete this.backup_mode; delete this.changedOriginal; }; this.restoreCSS = function() { if(this.backup_mode && this.changed) { this.backup_mode = false; var l = this.selectorList_bak.list.length - 1; for(var i = l; i >=0 ;i--) { this.removeRule(i); } var s = new SelectorList(); s.copy(this.selectorList); var sk = new SelectorList(); sk.copy(this.skinSelectorList); var css = s.list; this.selectorList = new SelectorList(); this.skinSelectorList = new SelectorList(); for(var i in css) { if(!css[i]) continue; var selector = css[i].selector; var selector_body = css[i].selector_body; this._setCSSBlock(selector, selector_body); } this.skinSelectorList.copy(sk); } delete this.backup_mode; delete this.changed; }; this.addToHistory = function(selector, stringRules,index) { if(!this.history) this.history = []; var h= this.history; var i = h.length; h[i] = {}; h[i].selector = selector; h[i].selector_body = stringRules; h[i].index = index; }; this.updateRule = function( selector, stringRules, prop_index_browser ) { var stylesheet = this.styleSheet; try { if($.browser.msie) { stylesheet.removeRule(prop_index_browser); stylesheet.addRule(selector, stringRules, prop_index_browser); } else { stylesheet.deleteRule(prop_index_browser); stylesheet.insertRule(selector+ ((" { " + stringRules + " } ")), prop_index_browser); } } catch(e) { //return false; throw e; } return true; }; this.addRule = function( selector, stringRules, prop_index_browser ) { var stylesheet = this.styleSheet; try { if($.browser.msie) { stylesheet.addRule(selector, stringRules, prop_index_browser); } else { stylesheet.insertRule(selector+( (" { " + stringRules + " } ")), prop_index_browser); } } catch(e) { throw e; } return true; }; this.updateMediaRule = function( selector, prop_index_browser ) { var stylesheet = this.styleSheet; try { if($.browser.msie) { stylesheet.removeRule(prop_index_browser); stylesheet.addRule(selector, '', prop_index_browser); } else { stylesheet.deleteRule(prop_index_browser); stylesheet.insertRule(selector, prop_index_browser); } } catch(e) { //return false; throw e; } return true; }; this.addMediaRule = function( selector, prop_index_browser ) { var stylesheet = this.styleSheet; try { if($.browser.msie) { stylesheet.addRule(selector, '', prop_index_browser); } else { stylesheet.insertRule(selector, prop_index_browser); } } catch(e) { throw e; } return true; }; this.removeRule = function(prop_index_browser) { var stylesheet = this.styleSheet; try { if($.browser.msie) { stylesheet.removeRule(prop_index_browser); } else { stylesheet.deleteRule(prop_index_browser); } } catch(e) { return false; } return true; }; if(styleSheetObj != undefined) { //this.getStylesheetContents(); } }; var LinkedStyleSheetObj = function(styleSheetObj, name){this.name = name; this.styleSheet = styleSheetObj;}; LinkedStyleSheetObj.prototype = new StyleSheetObj(); var DynamicFonts = new function() { this.available_fonts = { "OpenSans": "'Open Sans', sans-serif", "JosefinSlab":"'Josefin Slab', serif", "Arvo":"'Arvo', serif", "Lato":"'Lato', sans-serif", "Vollkorn":"'Vollkorn', serif", "AbrilFatface":"'Abril Fatface', cursive", "Ubuntu":"'Ubuntu', sans-serif", "PT Sans":"'PT Sans', sans-serif", "OldStandardTT":"'Old Standard TT', serif", "Droid Sans":"'Droid Sans', sans-serif", "Alike": "Alike", "Merriweather": "Merriweather", }; this.getFonts = function(communication) { if(this.fonts) return this.fonts; var that = this; return communication.getConfiguration('WEB_FONT_LOAD').then(function(json) { if(json == null) return []; var fonts = json.split(','); that.fonts = []; for(var i = 0;i < fonts.length;i++) { var a = $.trim( fonts[i] ); if(that.available_fonts[ a ] ) { that.fonts.push(that.available_fonts[ a ] ); } else that.fonts.push( a ); } return that.fonts; }); }; this.reloadFonts = function() { delete this.fonts; return this.getFonts(); }; }; var StyleSheet = new function() { this.animation_types = ['bounce','flash','pulse','rubberBand','shake','swing','tada','wobble','jello','bounceIn','bounceInDown','bounceInLeft' ,'bounceInRight','bounceInUp','bounceOut','bounceOutDown','bounceOutLeft','bounceOutRight','bounceOutUp','fadeIn','fadeInDown' ,'fadeInDownBig','fadeInLeft','fadeInLeftBig','fadeInRight','fadeInRightBig','fadeInUp','fadeInUpBig','fadeOut','fadeOutDown' ,'fadeOutDownBig','fadeOutLeft','fadeOutLeftBig','fadeOutRight','fadeOutRightBig','fadeOutUp','fadeOutUpBig','flipInX','flipInY','flipOutX','flipOutY' ,'lightSpeedIn','lightSpeedOut','rotateIn','rotateInDownLeft','rotateInDownRight','rotateInUpLeft','rotateInUpRight','rotateOut', 'rotateOutDownLeft','rotateOutDownRight','rotateOutUpLeft','rotateOutUpRight','hinge','rollIn','rollOut','zoomIn','zoomInDown','zoomInLeft', 'zoomInRight','zoomInUp','zoomOut','zoomOutDown','zoomOutLeft','zoomOutRight','zoomOutUp','slideInDown','slideInLeft','slideInRight','slideInUp','slideOutDown','slideOutLeft','slideOutRight','slideOutUp']; this.revslider_easing = [ {value:'Linear.easeNone',name:'Linear.easeNone'}, {value:'Power0.easeIn',name:'Power0.easeIn'}, {value:'Power0.easeInOut',name:'Power0.easeInOut'}, {value:'Power0.easeOut',name:'Power0.easeOut'}, {value:'Power1.easeIn',name:'Power1.easeIn'}, {value:'Power1.easeInOut',name:'Power1.easeInOut'}, {value:'Power1.easeOut',name:'Power1.easeOut'}, {value:'Power2.easeIn',name:'Power2.easeIn'}, {value:'Power2.easeInOut',name:'Power2.easeInOut'}, {value:'Power2.easeOut',name:'Power2.easeOut'}, {value:'Power3.easeIn',name:'Power3.easeIn'}, {value:'Power3.easeInOut',name:'Power3.easeInOut'}, {value:'Power3.easeOut',name:'Power3.easeOut'}, {value:'Power4.easeIn',name:'Power4.easeIn'}, {value:'Power4.easeInOut',name:'Power4.easeInOut'}, {value:'Power4.easeOut',name:'Power4.easeOut'}, {value:'Quad.easeIn',name:'Quad.easeIn'}, {value:'Quad.easeInOut',name:'Quad.easeInOut'}, {value:'Quad.easeOut',name:'Quad.easeOut'}, {value:'Cubic.easeIn',name:'Cubic.easeIn'}, {value:'Cubic.easeInOut',name:'Cubic.easeInOut'}, {value:'Cubic.easeOut',name:'Cubic.easeOut'}, {value:"Quart.easeIn" ,name:"Quart.easeIn (same as Power3.easeIn)"}, {value:"Quart.easeInOut" ,name:"Quart.easeInOut (same as Power3.easeInOut)"}, {value:"Quart.easeOut" ,name:"Quart.easeOut (same as Power3.easeOut)"}, {value:"Quint.easeIn" ,name:"Quint.easeIn (same as Power4.easeIn)"}, {value:"Quint.easeInOut" ,name:"Quint.easeInOut (same as Power4.easeInOut)"}, {value:"Quint.easeOut" ,name:"Quint.easeOut (same as Power4.easeOut)"}, {value: "Strong.easeIn" ,name:"Strong.easeIn (same as Power4.easeIn)"}, {value:"Strong.easeInOut" ,name:"Strong.easeInOut (same as Power4.easeInOut)"}, {value:"Strong.easeOut" ,name:"Strong.easeOut (same as Power4.easeOut)"}, {value:"Back.easeIn" ,name:"Back.easeIn"}, {value:"Back.easeInOut" ,name:"Back.easeInOut"}, {value:"Back.easeOut" ,name:"Back.easeOut"}, {value:"Bounce.easeIn" ,name:"Bounce.easeIn"}, {value:"Bounce.easeInOut" ,name:"Bounce.easeInOut"}, {value:"Bounce.easeOut" ,name:"Bounce.easeOut"}, {value:"Circ.easeIn" ,name:"Circ.easeIn"}, {value:"Circ.easeInOut" ,name:"Circ.easeInOut"}, {value:"Circ.easeOut" ,name:"Circ.easeOut"}, {value:"Elastic.easeIn" ,name:"Elastic.easeIn"}, {value:"Elastic.easeInOut" ,name:"Elastic.easeInOut"}, {value:"Elastic.easeOut" ,name:"Elastic.easeOut"}, {value:"Expo.easeIn" ,name:"Expo.easeIn"}, {value:"Expo.easeInOut" ,name:"Expo.easeInOut"}, {value:"Expo.easeOut" ,name:"Expo.easeOut"}, {value:"Sine.easeIn" ,name:"Sine.easeIn"}, {value:"Sine.easeInOut" ,name:"Sine.easeInOut"}, {value:"Sine.easeOut" ,name:"Sine.easeOut"}, {value:"SlowMo.ease" ,name:"SlowMo.ease"}, {value:"easeOutBack" ,name:"easeOutBack"}, {value:"easeInQuad" ,name:"easeInQuad"}, {value:"easeOutQuad" ,name:"easeOutQuad"}, {value:"easeInOutQuad" ,name:"easeInOutQuad"}, {value:"easeInCubic" ,name:"easeInCubic"}, {value:"easeOutCubic" ,name:"easeOutCubic"}, {value:"easeInOutCubic" ,name:"easeInOutCubic"}, {value:"easeInQuart" ,name:"easeInQuart"}, {value:"easeOutQuart" ,name:"easeOutQuart"}, {value:"easeInOutQuart" ,name:"easeInOutQuart"}, {value:"easeInQuint" ,name:"easeInQuint"}, {value:"easeOutQuint" ,name:"easeOutQuint"}, {value:"easeInOutQuint" ,name:"easeInOutQuint"}, {value:"easeInSine" ,name:"easeInSine"}, {value:"easeOutSine" ,name:"easeOutSine"}, {value:"easeInOutSine" ,name:"easeInOutSine"}, {value:"easeInExpo" ,name:"easeInExpo"}, {value:"easeOutExpo" ,name:"easeOutExpo"}, {value:"easeInOutExpo" ,name:"easeInOutExpo"}, {value:"easeInCirc" ,name:"easeInCirc"}, {value:"easeOutCirc" ,name:"easeOutCirc"}, {value:"easeInOutCirc" ,name:"easeInOutCirc"}, {value:"easeInElastic" ,name:"easeInElastic"}, {value:"easeOutElastic" ,name:"easeOutElastic"}, {value:"easeInOutElastic" ,name:"easeInOutElastic"}, {value:"easeInBack" ,name:"easeInBack"}, {value:"easeInOutBack" ,name:"easeInOutBack"}, {value:"easeInBounce" ,name:"easeInBounce"}, {value:"easeOutBounce" ,name:"easeOutBounce"}, {value:"easeInOutBounce" ,name:"easeInOutBounce"} ]; this.revslider_layers_transitions = [ {value:'fade',name:'Fade'}, {value:'sft',name:'Short from Top'}, {value:'sfb',name:'Short from Bottom'}, {value:'sfl',name:'Short from Left'}, {value:'sfr',name:'Short from Right'}, {value:'lft',name:'Long from Top'}, {value:'lfb',name:'Long from Bottom'}, {value:'lfl',name:'Long from Left'}, {value:'lfr',name:'Long from Right'}, {value:'skewfromright',name:'Skew from Right'}, {value:'skewfromleft',name:'Skew from Left'}, {value:'skewfromleftshort',name:'Skew from short Right'}, {value:'skewfromrightshort',name:'Skew from short Left'}, {value:'randomrotate',name:'Random rotate'}, ]; this.revslider_layers_transitionouts = [ {value:'fadeout',name:'Fade'}, {value:'stt',name:'Short to Top'}, {value:'stb',name:'Short to Bottom'}, {value:'stl',name:'Short to Left'}, {value:'str',name:'Short to Right'}, {value:'ltt',name:'Long to Top'}, {value:'ltb',name:'Long to Bottom'}, {value:'ltl',name:'Long to Left'}, {value:'ltr',name:'Long to Right'}, {value:'skewtoright',name:'Skew to Right'}, {value:'skewtoleft',name:'Skew to Left'}, {value:'skewtoleftshort',name:'Skew to short Right'}, {value:'skewtorightshort',name:'Skew to short Left'}, {value:'randomrotateout',name:'Random rotate'}, ]; this.revslider_slide_transitions = [ {value:'random-static',name:'Random Flat'}, {value:'random-premium',name:'Random Premium'}, {value:'random',name:'Random'}, {value:'slideup',name:'Slide to Top'}, {value:'slideleft',name:'Slide to Left'}, {value:'slideright',name:'Slide to Right'}, {value:'slidebottom',name:'Slide to Bottom'}, {value:'slidehorizontal',name:'Slide Horizontal'}, {value:'slidevertical',name:'Slide Vertical'}, {value:'boxslide',name:'Slide Boxes'}, {value:'slotslide-horizontal',name:'Slide Slots Horizontal'}, {value:'slotslide-vertical',name:'Slide Slots Vertical'}, {value:'notransition',name:'No transition'}, {value:'fade',name:'Fade'}, {value:'boxfade',name:'Fade Boxes'}, {value:'fadefromtop',name:'Fade from Top'}, {value:'fadefromright',name:'Fade from Right'}, {value:'fadefromleft',name:'Fade from Left'}, {value:'fadefrombottom',name:'Fade from Bottom'}, {value:'fadetoleftfadefromright',name:'Fade to Left & Fade from right'}, {value:'fadetorightfadetoleft',name:'Fade to Right & Fade to Left'}, {value:'fadetobottomfadefromtop',name:'Fade to Bottom & Fade from Top'}, {value:'fadetotopfadefrombottom',name:'Fade to Top & Fade from Bottom'}, {value:'slotfade-horizontal',name:'Fade slots Horizontal'}, {value:'slotfade-vertical',name:'Fade slots Vertical'}, {value:'parallaxtotop',name:'Parallax to Top'}, {value:'parallaxtoleft',name:'Parallax to Left'}, {value:'parallaxtobottom',name:'Parallax to Bottom'}, {value:'parallaxtoright',name:'Parallax to Right'}, {value:'zoomin',name:'Zoom in'}, {value:'zoomout',name:'Zoom out'}, {value:'scaledownfromright',name:'Zoom out & Fade from Right'}, {value:'scaledownfromleft',name:'Zoom out & Fade from Left'}, {value:'scaledownfromtop',name:'Zoom out & Fade from Top'}, {value:'scaledownfrombottom',name:'Zoom out & Fade from Bottom'}, {value:'slotzoom-horizontal',name:'Zoom slots Horizontal'}, {value:'slotzoom-vertical',name:'Zoom slots Vertical'}, {value:'curtain-1',name:'Curtain from Left'}, {value:'curtain-2',name:'Curtain from Right'}, {value:'curtain-3',name:'Curtain from Middle'}, {value:'3dcurtain-horizontal',name:'3D Curtain Horizontal'}, {value:'3dcurtain-vertical',name:'3D Curtain Vertical'}, {value:'papercut',name:'Paper cut'}, {value:'cubic',name:'Cubic'}, {value:'cube',name:'Cube'}, {value:'flyin',name:'Flying'}, {value:'turnoff',name:'Turn off'}, {value:'cubic-horizontal',name:'Cubic Horizontal'}, {value:'cube-horizontal',name:'Cube Horizontal'}, {value:'incube-horizontal',name:'Incube Horizontal'}, {value:'turnoff-vertical',name:'Turn off Horizontal'}, ]; this.special_modules = [['page_load_progress', 'Page load progress bar'],['back_to_top','Back to top button']]; this.fonts = [ 'Arial,Helvetica,sans-serif', '"Times New Roman",Times, serif', '"Courier New",Courier,monospace', 'Georgia,"Times New Roman",Times, serif', '"Trebuchet MS",Arial,Helvetica,sans-serif', 'Verdana,Arial,Helvetica,sans-serif', 'Geneva,Arial, Helvetica,sans-serif', 'Lobster,cursive', 'Geneva,Tahoma,sans-serif', ]; this.editor_fonts = [ 'Arial,Helvetica,sans-serif', '"Times New Roman",Times, serif', '"Courier New",Courier,monospace', 'Georgia,"Times New Roman",Times, serif', 'Verdana,Arial,Helvetica,sans-serif', 'Geneva,Arial, Helvetica,sans-serif', 'Geneva,Tahoma,sans-serif', ]; this.fontSize_tags = [ '8px','9px','10px','11px','12px','14px','16px','18px','20px','22px','24px','26px','28px','36px','48px','72px' ]; this.csstag = [ ['font-family','select',this.fonts], ['font-size','number'] , ['font-weight','select',['inherit', 'normal', 'bold', 'bolder', 'lighter'] ], ['line-height','number', ['normal','8px','9px','10px','11px','12px','14px','16px','18px','20px','22px','24px','26px','28px','36px','48px','72px'] ], ['font-variant','select',['inherit', 'normal', 'small-caps'] ], ['letter-spacing','number', 0, 100], ['font-style','select',['inherit', 'normal', 'italic', 'oblique']], ['color','color'], ['text-align','select',['inherit', 'left', 'center', 'left', 'justify'] ], ['text-decoration','select',['inherit', 'none', 'underline', 'overline', 'line-through', 'blink'] ], ['text-transform','select',['inherit', 'none', 'capitalize', 'uppercase', 'lowercase'] ], ['text-indent','number', 0, 100], ['word-wrap','select',['normal', 'break-word'] ], ['word-spacing','number', 0, 100] , ['margin-top','number', 0, 100], ['margin-left','number', 0, 100], ['margin-right','number', 0, 100] , ['margin-bottom','number', 0, 100] , ['padding-top','number', 0, 100], ['padding-left','number', 0, 100] , ['padding-right','number', 0, 100] , ['padding-bottom','number', 0, 100] , ['display','select',['inherit', 'none', 'block', 'inline', 'list-item']], ['float','select',['inherit', 'none', 'left', 'right']], ['overflow','select',['inherit', 'none', 'visible', 'scroll', 'auto']], ['position','select',['none','absolute', 'relative', 'fixed', 'static']], ['opacity','percent'], ['visibility','select',['inherit', 'visible', 'hidden'] ], ['clear','select',['none', 'left', 'right', 'bold'] ], ['cursor','select',['auto', 'crosshair', 'default', 'hand', 'move', 'e-resize', 'ne-resize', 'nw-resize', 'n-resize', 'se-resize', 'sw-resize', 's-resize', 'w-resize', 'text', 'wait', 'help'] ], ['z-index','number', 0, 100000], ['background-color','color'], ['background-image','image'], ['background-repeat','select',['repeat', 'repeat-x', 'repeat-y', 'no-repeat'] ], ['background-position','select',['left top', 'left center', 'left bottom', 'center top', 'center center', 'center bottom', 'right top', 'right center', 'right bottom'] ], ['background-attachment','select',['scroll', 'fixed'] ], ['box-shadow-color','color'], ['borderradius-width','number', 0, 30], ['box-shadow-horizontal-offset','number', 0, 30], ['box-shadow-vertical-offset','number', 0, 30], ['box-shadow-blur-radius','number', 0, 30], ['box-shadow-spread-radius','number', 0, 30], ['width','number', 50, 2000], ['height','number', 1, 10000], ['border-bottom-right-radius','number', 0, 100], ['border-top-right-radius','number', 0, 100], ['border-top-left-radius','number', 0, 100], ['border-bottom-left-radius','number', 0, 100], ['border-width','number', 0, 50], ['border-color','color'], ['border-style','select',['none', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset']], ['margin','margin', 0, 100], ['padding','padding', 0, 100], ['border-radius','border-radius', 0, 50], ['border-top-left-radius','number', 0, 50], ['border-top-right-radius','number', 0, 50], ['border-bottom-left-radius','number', 0, 50], ['border-bottom-right-radius','number', 0, 50], ['border-bottom-color','color'], ['border-top-color','color'], ['border-top-width','number', 0, 100], ['border-bottom-width','number', 0, 100], ['border-left-width','number', 0, 100], ['border-right-width','number', 0, 100], ['bottom','number', -1000, 1000], ['top','number', -1000, 1000], ['content','content', -100, 100], ]; this.font_tags = [ ['Entire website','body','<div/>'], ['Heading XL','h1', '<h1/>'], ['Heading L','h2', '<h2/>'], ['Heading M','h3', '<h3/>'], ['Heading S','h4', '<h4/>'], ['Paragraph','p', '<p/>'], ['Link','a', '<a/>'], ['Link hover','a:hover', '<a/>'], ]; this.font_size_tags = [ ['Automatic',''], ['8px','fontsize-8'], ['10px','fontsize-10'], ['11px','fontsize-11'], ['12px','fontsize-12'], ['13px','fontsize-13'], ['14px','fontsize-14'], ['16px','fontsize-16'], ['18px','fontsize-18'], ['20px','fontsize-20'], ['22px','fontsize-22'], ['24px','fontsize-24'], ['26px','fontsize-26'], ['28px','fontsize-28'], ['30px','fontsize-30'], ['32px','fontsize-32'], ['34px','fontsize-34'], ['36px','fontsize-36'], ['38px','fontsize-38'], ['40px','fontsize-40'], ['42px','fontsize-42'], ['44px','fontsize-44'], ['46px','fontsize-46'], ['50px','fontsize-50'], ['54px','fontsize-54'], ['56px','fontsize-56'], ['60px','fontsize-60'], ['68px','fontsize-68'], ['72px','fontsize-72'], ]; this.fontPreviewText = 'The quick brown for jump over the lazy dogs'; this.background_tags = [ ['Entire Website','body'], ['Header','#header_wrapper'], ['Main','#main_wrapper'], ['Footer','#footer_wrapper'], ]; this.defaultUnit = 'px'; this.cssunit = [ ['pixel', 'px'], ['em space', 'em'], ['x space', 'ex'], ['percent', '%'], ['point', 'pt'], ['picas', 'pc'], ['centimeters', 'cm'], ['inches', 'in'], ['milimeters', 'mm'], ]; this.convertPropertiesArrayToString = function ( propertiesArray ) { var ret = ''; if (propertiesArray.length > 0) { for( var i in propertiesArray ) { if( !propertiesArray.hasOwnProperty( i ) ) continue; ret += propertiesArray[i][0]+": "+propertiesArray[i][1]+"; "; } } return ret; }; this.easing = ['linear','easeInCubic','easeOutCubic','easeInOutCubic','easeInCirc','easeOutCirc','easeInOutCirc','easeInExpo','easeOutExpo','easeInOutExpo','easeInQuad','easeOutQuad','easeInOutQuad','easeInQuart','easeOutQuart','easeInOutQuart','easeInQuint','easeOutQuint','easeInOutQuint','easeInSine','easeOutSine','easeInOutSine','easeInBack','easeOutBack','easeInOutBack']; this.isStyleObjEqual = function ( styleObj1, styleObj2 ) { return styleObj1.file_name == styleObj2.file_name && styleObj1.selector == styleObj2.selector && styleObj1.prop_index_file == styleObj2.prop_index_file; }; this.parseURI = function(url) { var m = String(url).match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/); // authority = '//' + user + ':' + pass '@' + hostname + ':' port return (m ? { href : m[0] || '', protocol : m[1] || '', authority: m[2] || '', host : m[3] || '', hostname : m[4] || '', port : m[5] || '', pathname : m[6] || '', search : m[7] || '', hash : m[8] || '' } : null); }; this.stripUnits = function (value) { var numb = ( (value+"").replace(/%|e(?:m|x)|p(?:x|t|c)|i(?:n)|c(?:m)|m(?:m)/g, '') ); return isNaN(parseFloat(numb)*1) ? 0 : parseFloat(numb); }; this.getUnits = function(value) { value = (value+"").replace(/(\s)*!important(\s)*/g, ""); var unit = value.replace(/[^%|em|ex|px|in|cm|mm|pt|pc]/g, ''); return unit.search("%|em|ex|px|in|cm|mm|pt|pc") == -1 ? 'px' : unit; }; this.rgbToHexCSS = function(value) { if(value.indexOf("rgb") == -1) return value; return value.replace(/\brgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)/gi, function(_, r, g, b) { return '#' + ((1 << 24) + (r << 16) + (g << 8) + (b << 0)).toString(16).substr(-6).toUpperCase(); }); }; this.HexToRgbaCSS = function(value) { if (!value.match(/^#?([0-9A-Fa-f]){3}\s*$|^#?([0-9A-Fa-f]){6}\s*$|^#?([0-9A-Fa-f]){8}\s*$/)) { return false; } var hex = value.replace(' ',''); hex = ( hex.charAt(0) == "#" ? hex.substr(1) : hex ); if (hex.length == 8) { r = parseInt(hex.substring(0, 2), 16); g = parseInt(hex.substring(2, 4), 16); b = parseInt(hex.substring(4, 6), 16); a = parseInt(hex.substring(6, 8), 16) ; a = Math.precision(a / 255, 2) } if (hex.length == 6) { r = parseInt(hex.substring(0, 2), 16); g = parseInt(hex.substring(2, 4), 16); b = parseInt(hex.substring(4, 6), 16); a = 1; } else if (hex.length == 3) { r = parseInt(hex.substring(0, 1) + hex.substring(0, 1), 16); g = parseInt(hex.substring(1, 2) + hex.substring(1, 2), 16); b = parseInt(hex.substring(2, 3) + hex.substring(2, 3), 16); a = 1; } var rs = a == 1 ? 'rgb(' + r + ',' + g + ',' + b + ')' : 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; return rs; }; this.SkinIndexToRgbaCSS = function(value) { if (value.indexOf('##') == -1) { return false; } if(!window.palette) return false; var i = parseInt(value.substring(2)); var c = window.palette.getColor(i); return this.HexToRgbaCSS(c.toHex()); }; this.getBackgroundSrc = function ( url ) { if( url == "undefined" ) return "undefined"; url = url.replace(/^url\(["']?/, '').replace(/["']?\)$/, ''); return url; }; this.convertBgPosToInt = function ( string ) { if( string == "undefined" ) return "undefined"; return string .replace(/top/g, "0%") .replace(/center/g, "50%") .replace(/bottom/g, "100%") }; this.isArrEl = function( elem ) { if( typeof elem == "function" ) return false; if( typeof elem == "undefined" ) return false; return true; }; this.gradient_tag_strings = [ '-moz-linear-gradient( {0}, {1}, {2} )', '-webkit-gradient(linear, {0}, from({1}), to({2}))', '-webkit-linear-gradient( {0}, {1}, {2} )', '-o-linear-gradient( {0}, {1}, {2} )', 'linear-gradient( {0}, {1}, {2} )' ]; this.gradient_tags = [ '-moz-linear-gradient', '-webkit-gradient', '-webkit-linear-gradient', '-o-linear-gradient', 'linear-gradient' ]; this.gradient_pos_tags = [ ['90deg', '-90deg', '180deg', '-180deg'], ['left top, left bottom', 'left top, left bottom', 'left top, left bottom' , 'left top, left bottom'], ['90deg', '-90deg', '180deg', '-180deg'], ['90deg', '-90deg', '180deg', '-180deg'], ['to bottom', 'to top', 'to left', 'to right'] ]; this.gradient_css_values = [ { name:'None' }, { name:'Gradient style 1', value: [ '-moz-linear-gradient(top, rgba(125,126,125,0.3) 0%, rgba(14,14,14,0.3) 100%)', '-webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(125,126,125,0.3)), color-stop(100%,rgba(14,14,14,0.3)))', '-webkit-linear-gradient(top, rgba(125,126,125,0.3) 0%,rgba(14,14,14,0.3) 100%)', '-o-linear-gradient(top, rgba(125,126,125,0.3) 0%,rgba(14,14,14,0.3) 100%)', '-ms-linear-gradient(top, rgba(125,126,125,0.3) 0%,rgba(14,14,14,0.3) 100%)', 'linear-gradient(to bottom, rgba(125,126,125,0.3) 0%,rgba(14,14,14,0.3) 100%)' ] }, { name:'Gradient style 2', value: [ '-moz-linear-gradient(top, rgba(69,72,77,0.2) 0%, rgba(0,0,0,0.4) 100%)', '-webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(69,72,77,0.2)), color-stop(100%,rgba(0,0,0,0.4)))', '-webkit-linear-gradient(top, rgba(69,72,77,0.2) 0%,rgba(0,0,0,0.4) 100%)', '-o-linear-gradient(top, rgba(69,72,77,0.2) 0%,rgba(0,0,0,0.4) 100%)', '-ms-linear-gradient(top, rgba(69,72,77,0.2) 0%,rgba(0,0,0,0.4) 100%)', 'linear-gradient(to bottom, rgba(69,72,77,0.2) 0%,rgba(0,0,0,0.4) 100%)' ] }, { name:'Gradient style 3', value: [ '-moz-linear-gradient(top, rgba(181,189,200,0.24) 0%, rgba(130,140,149,0.28) 36%, rgba(40,52,59,0.36) 100%)', '-webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(181,189,200,0.24)), color-stop(36%,rgba(130,140,149,0.28)), color-stop(100%,rgba(40,52,59,0.36)))', '-webkit-linear-gradient(top, rgba(181,189,200,0.24) 0%,rgba(130,140,149,0.28) 36%,rgba(40,52,59,0.36) 100%)', '-o-linear-gradient(top, rgba(181,189,200,0.24) 0%,rgba(130,140,149,0.28) 36%,rgba(40,52,59,0.36) 100%)', '-ms-linear-gradient(top, rgba(181,189,200,0.24) 0%,rgba(130,140,149,0.28) 36%,rgba(40,52,59,0.36) 100%)', 'linear-gradient(to bottom, rgba(181,189,200,0.24) 0%,rgba(130,140,149,0.28) 36%,rgba(40,52,59,0.36) 100%)' ] }, { name:'Gradient style 4', value: [ '-moz-linear-gradient(top, rgba(174,188,191,0.2) 0%, rgba(110,119,116,0.2) 50%, rgba(10,14,10,0.2) 51%, rgba(10,8,9,0.2) 100%)', '-webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(174,188,191,0.2)), color-stop(50%,rgba(110,119,116,0.2)), color-stop(51%,rgba(10,14,10,0.2)), color-stop(100%,rgba(10,8,9,0.2)))', '-webkit-linear-gradient(top, rgba(174,188,191,0.2) 0%,rgba(110,119,116,0.2) 50%,rgba(10,14,10,0.2) 51%,rgba(10,8,9,0.2) 100%)', '-o-linear-gradient(top, rgba(174,188,191,0.2) 0%,rgba(110,119,116,0.2) 50%,rgba(10,14,10,0.2) 51%,rgba(10,8,9,0.2) 100%)', '-ms-linear-gradient(top, rgba(174,188,191,0.2) 0%,rgba(110,119,116,0.2) 50%,rgba(10,14,10,0.2) 51%,rgba(10,8,9,0.2) 100%)', 'linear-gradient(to bottom, rgba(174,188,191,0.2) 0%,rgba(110,119,116,0.2) 50%,rgba(10,14,10,0.2) 51%,rgba(10,8,9,0.2) 100%)' ] }, { name:'Gradient style 5', value: [ '-moz-linear-gradient(top, rgba(76,76,76,0.3) 0%, rgba(89,89,89,0.3) 12%, rgba(102,102,102,0.3) 25%, rgba(71,71,71,0.3) 39%, rgba(44,44,44,0.3) 50%, rgba(0,0,0,0.3) 51%, rgba(17,17,17,0.3) 60%, rgba(43,43,43,0.3) 76%, rgba(28,28,28,0.3) 91%, rgba(19,19,19,0.3) 100%)', '-webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(76,76,76,0.3)), color-stop(12%,rgba(89,89,89,0.3)), color-stop(25%,rgba(102,102,102,0.3)), color-stop(39%,rgba(71,71,71,0.3)), color-stop(50%,rgba(44,44,44,0.3)), color-stop(51%,rgba(0,0,0,0.3)), color-stop(60%,rgba(17,17,17,0.3)), color-stop(76%,rgba(43,43,43,0.3)), color-stop(91%,rgba(28,28,28,0.3)), color-stop(100%,rgba(19,19,19,0.3)))', '-webkit-linear-gradient(top, rgba(76,76,76,0.3) 0%,rgba(89,89,89,0.3) 12%,rgba(102,102,102,0.3) 25%,rgba(71,71,71,0.3) 39%,rgba(44,44,44,0.3) 50%,rgba(0,0,0,0.3) 51%,rgba(17,17,17,0.3) 60%,rgba(43,43,43,0.3) 76%,rgba(28,28,28,0.3) 91%,rgba(19,19,19,0.3) 100%)', '-o-linear-gradient(top, rgba(76,76,76,0.3) 0%,rgba(89,89,89,0.3) 12%,rgba(102,102,102,0.3) 25%,rgba(71,71,71,0.3) 39%,rgba(44,44,44,0.3) 50%,rgba(0,0,0,0.3) 51%,rgba(17,17,17,0.3) 60%,rgba(43,43,43,0.3) 76%,rgba(28,28,28,0.3) 91%,rgba(19,19,19,0.3) 100%)', '-ms-linear-gradient(top, rgba(76,76,76,0.3) 0%,rgba(89,89,89,0.3) 12%,rgba(102,102,102,0.3) 25%,rgba(71,71,71,0.3) 39%,rgba(44,44,44,0.3) 50%,rgba(0,0,0,0.3) 51%,rgba(17,17,17,0.3) 60%,rgba(43,43,43,0.3) 76%,rgba(28,28,28,0.3) 91%,rgba(19,19,19,0.3) 100%)', 'linear-gradient(to bottom, rgba(76,76,76,0.3) 0%,rgba(89,89,89,0.3) 12%,rgba(102,102,102,0.3) 25%,rgba(71,71,71,0.3) 39%,rgba(44,44,44,0.3) 50%,rgba(0,0,0,0.3) 51%,rgba(17,17,17,0.3) 60%,rgba(43,43,43,0.3) 76%,rgba(28,28,28,0.3) 91%,rgba(19,19,19,0.3) 100%)' ] } ], this.getBorderValue = function(element, with_unit) { var element = jQuery(element); var style = element[0].style; function getValue(v) { var value = element.css('border-'+v+'-width'); value = StyleSheet.stripUnits(value); var unit = StyleSheet.getUnits(value); var style = element.css('border-'+v+'-style'); var color = element.css('border-'+v+'-color'); if(with_unit) return {value:value, unit:unit,style:style,color:color}; else return {value:value,style:style,color:color}; } var borders = {}; var sides = ['top','bottom','left','right']; for(var i = 0;i < sides.length;i++) { borders[sides[i]]=getValue(sides[i]); } return borders; } this.getMarginValue = function(element,type,with_unit) { var element = jQuery(element); function getValue(v) { var value = element.css(type+ '-'+v); value = StyleSheet.stripUnits(value); var unit = StyleSheet.getUnits(value); if(with_unit) return {value:value, unit:unit}; else return value; } var sides = ['top','bottom','left','right']; var margins = {}; for(var i = 0;i < sides.length;i++) { margins[sides[i]]=getValue(sides[i]); } return margins; } this.getCSSValues = function(element, with_unit) { var element = jQuery(element); var style = element[0].style; var rs = {}; for(var i = 0;i < this.csstag.length;i++) { var s = this.csstag[i][0]; var type = this.csstag[i][1]; if(style[s]!= undefined) { var v = jQuery(element).css(s);//style[s]; var u = ''; if(type== 'number') { v = this.stripUnits(v); u = this.getUnits(v); if(with_unit) rs[s] = {value:v,unit:u}; else rs[s] = v; } else rs[s] = v; var v = s.replace('-','_'); //console.log(v); rs[v] = rs[s]; } } return rs; } this.getFontAwesomeCode = function() { if(this.font_awsome_codes) return this.font_awsome_codes; this.font_awsome_codes = []; var a = [0,1,2,3,4,5,6,7,8,9,'a','b','c','d','e', 'f']; var prefix = '\\f'; var rs = []; for(var i = 0; i < a.length;i++) { if(a[i] != 'b') for(var j = 0; j < a.length - 1;j++) rs.push(prefix + '0' + a[i] + a[j]); } for(var i = 0; i <= 8;i++) { for(var j = 0; j < a.length - 1;j++) rs.push(prefix + '1' + a[i] + a[j]); } rs.push('\f02f'); this.font_awsome_codes = rs; return this.font_awsome_codes; }; this.parsePaddingValue = function(v) { var v = v.split(' '); var l = v.length; if(l == 1) { return {top: v[0],right: v[0],bottom: v[0],left: v[0] }; } else if(l == 2) { return {top: v[0], bottom: v[0], right: v[1], left: v[1] } ; } else if(l == 3) { return {top: v[0], bottom: v[2], right:v[1], left:v[1]}; } else if(l == 4) { return {top: v[0],right: v[1],bottom: v[2],left: v[3] }; } }; this.parseBorderRadiusValue = function(v) { var v = v.split(' '); var l = v.length; if(l == 1) { return {topleft: v[0],topright: v[0],bottomright: v[0],bottomleft: v[0] }; } else if(l == 2) { return {topleft: v[0], bottomright: v[0], topright: v[1], bottomleft: v[1] } ; } else if(l == 3) { return {topleft: v[0], bottomleft: v[2], topright:v[1], bottomright:v[1]}; } else if(l == 4) { return {topleft: v[0],topright: v[1],bottomright: v[2],bottomleft: v[3] }; } }; this.checkGradientBackground = function(p) { return p.indexOf('gradient') != -1; }; this.checkGradientBackgroundSkin = function(p) { return p.indexOf('##') != -1; }; this.createGradient = function(pos, color1, color2 ) { var arr = []; for(var i = 0; i < this.gradient_tag_strings.length; i++) { var str = this.gradient_tag_strings[i]; var gpt = this.gradient_pos_tags[i]; var p = gpt[pos]; str = str.format([ p, color1, color2 ]); arr.push(str); } return arr; }; this.createGradientString = function(s ) { var p = s; var arr = []; var i = 0; while(i < s.length - 1) { if(s[i] == '#' && s[i + 1] == '#') { var j = i; var t = ''; while(s[j] != ')' && s[j] != ',' && s[j] != ' ' ) { t = t +s[j]; j++; } var v = ''; if(window.palette) { v = ''; var index = parseInt(t.substring(2)); v += window.palette.getColor(index); } arr.push( {o: t, n : v} ); } i++; } for(var i = 0; i < arr.length;i++) { p = p.replace(arr[i].o, arr[i].n); } return p; }; this.getContent = function() { var rs = []; for(var i in this.contents) { if(!this.contents[i]) continue; if(this.contents[i].name=='themes') continue; rs.push(this.contents[i].getObject() ); } return rs; }; this.restore2Origin = function() { if(this.contents) { for(var i = 0;i < this.contents.length;i++) { this.contents[i].restore2Origin(); } } }; this.changepage = function() { if(this.contents) { for(var i = 0;i < this.contents.length;i++) { this.contents[i].changepage(); } } }; this.getStylesheetContents = function (iframe, completed) { this.contents = []; var linkedStyleSheets = iframe.document.styleSheets; //var localStyleSheetObj = linkedStyleSheets[linkedStyleSheets.length - 5]; ///this.local = new StyleSheetObj(localStyleSheetObj, window.edit_page.PageEdit.get_page_name() ); var j = false; for(var i = 0;i < linkedStyleSheets.length;i++) { var href = linkedStyleSheets[i].href; if(href.indexOf('themes') >= 0) { j = i; break; } } if(!j) return; var themes_StyleSheetObj = linkedStyleSheets[j]; this.themes = new StyleSheetObj(themes_StyleSheetObj, 'themes'); var common_skinStyleSheetObj = linkedStyleSheets[j + 1]; this.common_skin = new StyleSheetObj(common_skinStyleSheetObj, 'common_skin'); var skinStyleSheetObj = linkedStyleSheets[j + 2]; this.skin = new StyleSheetObj(skinStyleSheetObj, 'skin'); var globalStyleSheetObj = linkedStyleSheets[j + 3]; this.global = new StyleSheetObj(globalStyleSheetObj, 'style'); this.local = this.global; var mainStyleSheetObj = linkedStyleSheets[j + 4]; this.main = new StyleSheetObj(mainStyleSheetObj, 'main'); var StyleSheets = window.document.styleSheets; //var shopping_editorStyleSheetObj = StyleSheets[StyleSheets.length - 1]; //this.shopping_editor = new LinkedStyleSheetObj(shopping_editorStyleSheetObj, 'shopping_editor'); this.contents.push(this.themes); this.contents.push(this.common_skin); this.contents.push(this.skin); this.contents.push(this.global); this.contents.push(this.main); //this.contents.push(this.shopping_editor); var hrefs = ''; for(var i = 0;i < this.contents.length;i++) { if(! this.contents[i].is_loaded() ) hrefs += this.contents[i].getHref() + ';'; } var that = this; PM.communication.getStylesheetContents(hrefs, function(response) { for(var i = 0;i < that.contents.length;i++) { if(! that.contents[i].is_loaded() ) that.contents[i].getResponse(response); } jQuery.event.trigger('stylesheetLoadCompleted'); if(typeof completed == 'function') completed(); }); }; this.getSmallStylesheetContents = function (iframe) { return this.getStylesheetContents(iframe); }; this.wrapCSS = function(css,id) { var rules = []; if(!css) return rules; css = this.removeComments(css); var blocks = css.split('}'); blocks.pop(); var len = blocks.length; for (var i = 0; i < len; i++) { var pair = blocks[i].split('{'); //rules[$.trim(pair[0])] = this.parseCSSBlock(pair[1]); rules[i] = {}; rules[i]['selector'] = $.trim(pair[0]); rules[i]['selector'] = '#'+ id+ ' ' + rules[i]['selector']; rules[i]['selector_body'] = this.parseCSSBlock(pair[1]); } return rules; }; this.getMediaType = function(selector) { if(selector[0] != '@') return false; var s = selector.split(' '); s = s[0]; return s.substr(1); } this.isMediaType = function(selector) { if(selector[0] != '@') return false; return true; } this.isMediaCombinableType = function(selector) { var combinable_media_query = { 'font-face':false, 'keyframes':true, 'media':true, 'charset':false } var type = this.getMediaType(selector); if(type == false) return false; return combinable_media_query[type]; } this.parseCSS = function(css) { function isBreakChar(c) { for(var i = 0;i < break_chars.length;i++) { if(c == break_chars[i]) return true; } return false; } var rules = []; if(!css) return rules; css = this.removeComments(css); var current_token = ''; var tokens = []; var rules=[]; var brakets = []; var START_STYLE_BLOCK = 1; var START_MEDIA_BLOCK = 2; var WHITE_SPACE = ' '; var END_STYLE_BLOCK = 3; var END_MEDIA_BLOCK = 4; var parsed_css = []; var index = -1; var child_index = -1; var break_chars = ['{',';']; for(var i = 0;i < css.length;i++) { var current_char = css[i]; var rule = {}; var child_rule ; if(!isBreakChar(current_char)) { current_token += current_char; } else { current_token = $.trim(current_token); if(current_token.length!=0) tokens.push($.trim(current_token)); tokens.push(current_char); if(current_char == ';') { if(brakets[brakets.length - 1] == undefined) { if(current_token[0] == '@') { index++; parsed_css.push({selector:current_token}); } } else break_chars = ['}','{',':']; } if(current_char == '{') { break_chars = ['{',':','}']; rule = {}; rule['selector']=current_token; if(brakets[brakets.length - 1] == undefined || brakets[brakets.length - 1] == START_MEDIA_BLOCK) { if(brakets[brakets.length - 1] == START_MEDIA_BLOCK) { brakets.push( START_STYLE_BLOCK ); child_index++; parsed_css[index].rules.push({selector:current_token}); } else if(this.isMediaType(current_token)) { if(this.isMediaCombinableType(current_token)) { brakets.push( START_MEDIA_BLOCK ); index++; child_index=-1; parsed_css.push({selector:current_token}); parsed_css[index].rules=[]; } else { child_index=-1; index++; parsed_css.push({selector:current_token}); brakets.push( START_STYLE_BLOCK );; } } else { child_index=-1; index++; parsed_css.push({selector:current_token}); brakets.push( START_STYLE_BLOCK ); } } else throw ('Parse Error:Unexpected { at char ' + i + ':' + css[i]); } if(current_char == '}') { break_chars = ['}','{']; var top_braket = brakets.pop(); if(top_braket == undefined && top_braket != START_MEDIA_BLOCK && top_braket != START_STYLE_BLOCK) { throw ('Parse Error:Expected } at char ' + i + ':' + css[i]); } if(top_braket == START_STYLE_BLOCK) { var top_token; var selector_body = [] var css_style = {}; tokens.pop(); if(tokens[tokens.length - 1] != ';') { tokens.push(';'); } while((top_token=tokens.pop()) != '{') { if(top_token == ';') { if(tokens[tokens.length - 1] == ';') continue; css_style = {}; var value = tokens.pop(); if(value == '{') break; var colons = tokens.pop(); if(colons != ':') throw ('Parse Error:Expected : at char ' + i + ', value is ' + colons); var property= tokens.pop(); css_style = {property:property, value:value}; selector_body.unshift(css_style); } } tokens.pop(); if(index >=0) { if(child_index >= 0) { parsed_css[index].rules[child_index]['selector_body'] = selector_body; } else { parsed_css[index]['selector_body'] = selector_body; } } } else { tokens.pop(); tokens.pop(); tokens.pop(); } } if(current_char == ':') { break_chars = ['}',';']; } current_token = ''; } } return parsed_css; }; this.removeComments = function(css) { return css.replace(/\/\*(\r|\n|.)*\*\//g,""); }; this.parseCSSBlock= function(css) { var rule = []; var declarations = css.split(';'); declarations.pop(); var len = declarations.length; for (var i = 0; i < len; i++) { var loc = declarations[i].indexOf(':'); var property = $.trim(declarations[i].substring(0, loc)); var value = $.trim(declarations[i].substring(loc + 1)); rule[i] = {}; if (property != "" && value != "") { rule[i]['property'] = property; rule[i]['value'] = value; } } return rule; }; }; StyleSheet.data = new function() { this.editedArchive= Array(); this.history= Array(); this.edited= {}; this.styles= Array(); this.changed= false; this.stylesheetContents= Array(); this.historyIndex= 0; this.historyClear= true; this.historyActive= true; this.selectedObj=''; this.selectedElementId= ''; this.timer_updateRule = 0; this.setStylesheets = function (ssObjs) { this.styleSheets = ssObjs; }; this.setSelectedId= function ( id ) { this.selectedElementId = id; }; this.getSelectedId= function () { return this.selectedElementId; }; this.getEditedArchiveIndex = function ( styleObj ) { if( styleObj.file_name !== "undefined" && styleObj.selector !== "undefined" && styleObj.prop_index_file !== "undefined") { for( var i in StyleSheet.data.editedArchive ) { if( !StyleSheet.data.editedArchive.hasOwnProperty( i ) ) continue; if (StyleSheet.isStyleObjEqual( StyleSheet.data.editedArchive[i], styleObj) ) { return parseInt(i, 10); } } var ei = StyleSheet.data.editedArchive.length; StyleSheet.data.editedArchive[ei] = $.extend({}, styleObj); return ei; } return -1; }; this.addToHistoryIfFirst = function (editedIndex, property, value) { var found = false; var l = StyleSheet.data.history.length; for( var i = 0; i<l; i++ ) { if( StyleSheet.data.history[i].ei == editedIndex && StyleSheet.data.history[i].property == property ) { found = true; break; } } // ha nem talalta meg, akkor hozza kell adni (rogziteni kell az aktualis erteket) if( !found ) { StyleSheet.data.addToHistory(editedIndex, property, value); return true; } return false; }; this.getItemProp = function(fieldId) { var ei = StyleSheet.data.getEditedArchiveIndex( StyleSheet.data.edited ); var props_arr = StyleSheet.data.editedArchive[ei].properties.split(";"); for(var i in props_arr) { if( !props_arr.hasOwnProperty( i ) ) continue; var prop_arr = props_arr[i].split(":"); if( $.trim(prop_arr[0]) == fieldId) { prop_arr.splice(0, 1); return $.trim(prop_arr.join(":")); } } return ""; }; };
[+]
..
[+]
sample_images
[-] ssultils.js
[edit]
[-] dialog.js
[edit]
[-] colorpicker.js
[edit]
[-] script.js
[edit]
[+]
libraries
[-] ui.dbfilter-editing.js
[edit]
[-] stgrid.js
[edit]
[-] ui.category-editing.js
[edit]
[-] forms.js
[edit]
[-] player.swf
[edit]
[-] language.js
[edit]
[-] im.js
[edit]
[-] terms_en.js
[edit]
[-] skinutils.js
[edit]
[-] create_page.js
[edit]
[-] ihover.js
[edit]
[-] builder.js
[edit]
[-] ui.tab-content.js
[edit]
[-] admin.js
[edit]
[-] ui.tab-editing.js
[edit]
[-] login.js
[edit]
[-] popup.js
[edit]
[-] ecommerce.js
[edit]
[-] stEditor.js
[edit]
[-] colorutils.js
[edit]
[-] livedemo.js
[edit]
[-] palette.js
[edit]
[+]
editor