Commit 8ede2d78 authored by Malcolm Blaney's avatar Malcolm Blaney

Move code from Post->Callback to it's own function, CustomSettings,

which now also provides custom settings for enclosures. Bug fix in
Writer module js, enclosure was being stringify'd twice. Extended
module js also needed some changes to handle new Post custom
settings options. Support .mov files in SimplePie microformats
parser as browsers support them. A few other small bug fixes and
missing file includes for microformats.php which is now used more.
parent 35cc1c9d
Pipeline #36118102 passed with stage
in 1 minute and 9 seconds
......@@ -51,108 +51,11 @@ class Post extends Base {
}
return ['status' => $status];
}
// 'mode' is used by the Extended module, which calls this function.
if (!isset($_POST['mode']) || $_POST['mode'] !== 'box') {
return ['error' => 'Unknown mode'];
if (isset($_POST['mode']) && $_POST['mode'] === 'box') {
return $this->CustomSettings();
}
$object = [];
$mysqli = connect_db();
$id = (int)substr($_POST['id'], 9);
$query = 'SELECT title, description, author, category, enclosure, ' .
'permalink FROM post WHERE user = "' . $this->owner . '" AND ' .
'box_id = ' . $id;
if ($result = $mysqli->query($query)) {
if ($post = $result->fetch_assoc()) {
$object['editor'] = true;
$object['source'] = $post['description'];
// When notify is set to false, it's possible that the current version
// of the post will be saved without sending notifications. In this
// case create a notify flag to ignore the content check done later.
if (isset($_POST['notify']) && $_POST['notify'] === 'false') {
$object['notify'] = true;
}
$object['permalink'] = $post['permalink'];
// Check the 'Send to Twitter' box if a link was added previously.
$twitter_checked = '';
$twitter_link = 'https://brid.gy/publish/twitter';
if (strpos($post['description'], $twitter_link) !== false) {
$twitter_checked = ' checked="checked"';
}
// Set Webaction if a class name is found in the description.
$class = '';
$url = '';
$options = '<option></option><option>like</option>' .
'<option>reply</option><option>share</option>';
if (strpos($post['description'], 'u-like-of') !== false) {
$class = 'u-like-of';
$options = '<option></option>' .
'<option selected="selected">like</option>' .
'<option>reply</option><option>share</option>';
}
else if (strpos($post['description'], 'u-repost-of') !== false) {
$class = 'u-repost-of';
$options = '<option></option><option>like</option>' .
'<option>reply</option>' .
'<option selected="selected">share</option>';
}
else if (strpos($post['description'], 'u-in-reply-to') !== false) {
$class = 'u-in-reply-to';
$options = '<option></option><option>like</option>' .
'<option selected="selected">reply</option>' .
'<option>share</option>';
}
if ($class !== '') {
$regex = '/<a href="(.*)" class="' . $class . '"/i';
if (preg_match($regex, $post['description'], $match)) {
$url = $match[1];
}
}
// The Extended module uses the name attribute to assign content.
$object['custom'] = '<form id="extended-custom-settings">' .
'<div class="form-spacing">' .
'<label for="post-title-input">Title:</label>' .
'<input id="post-title-input" name="title" type="text" ' .
'value="' . htmlspecialchars($post['title']) . '" ' .
'maxlength="180">' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-author-input">Author:</label>' .
'<input id="post-author-input" name="author" type="text" ' .
'value="' . $post['author'] . '" maxlength="50">' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-category-input">Category:</label>' .
'<input id="post-category-input" name="category" type="text" ' .
'value="' . htmlspecialchars($post['category']) . '" ' .
'maxlength="200">' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-action-url-input">Webaction Url:</label>' .
'<input id="post-action-url-input" name="webactionUrl" ' .
'type="text" value="' . $url . '" maxlength="200">' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-action-type-input">Webaction Type:</label>' .
'<select id="post-action-type-input" name="webactionType">' .
$options . '</select>' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-twitter-input">Send to Twitter:</label>' .
'<input id="post-twitter-input" name="twitter" type="checkbox"' .
$twitter_checked . '>' .
'</div>' .
'<button type="submit">Submit</button>' .
'</form>';
}
$result->close();
}
else {
$this->Log('Post->Callback: ' . $mysqli->error);
}
$mysqli->close();
return $object;
return ['error' => 'Unknown mode'];
}
public function CanAdd($page) {
......@@ -193,7 +96,7 @@ class Post extends Base {
$title = htmlspecialchars($post['title']);
$description = $post['description'];
$enclosure = json_decode($post['enclosure'], true);
$count = count($enclosure);
$count = is_array($enclosure) ? count($enclosure) : 0;
if ($count === 1) {
$media .= '<p><img class="u-photo" src="' . $enclosure[0] .'"></p>';
}
......@@ -759,11 +662,10 @@ class Post extends Base {
$us_enclosure = '';
if (isset($us_content['enclosure'])) {
if ($micropub) {
$us_content['properties']['photo'] =
json_decode($us_content['enclosure'], true);
$us_content['properties']['photo'] = $us_content['enclosure'];
}
else {
$us_enclosure = $us_content['enclosure'];
$us_enclosure = json_encode($us_content['enclosure']);
}
}
// If a webaction is set, make sure it's marked up correctly.
......@@ -1104,6 +1006,122 @@ class Post extends Base {
return $status;
}
private function CustomSettings() {
$settings = [];
$id = (int)substr($_POST['id'], 9);
$mysqli = connect_db();
$query = 'SELECT title, description, author, category, enclosure, ' .
'permalink FROM post WHERE user = "' . $this->owner . '" AND ' .
'box_id = ' . $id;
if ($result = $mysqli->query($query)) {
if ($post = $result->fetch_assoc()) {
$settings['editor'] = true;
$settings['source'] = $post['description'];
// When notify is set to false, it's possible that the current version
// of the post will be saved without sending notifications. In this
// case create a notify flag to ignore the content check done later.
if (isset($_POST['notify']) && $_POST['notify'] === 'false') {
$settings['notify'] = true;
}
$settings['permalink'] = $post['permalink'];
// Check the 'Send to Twitter' box if a link was added previously.
$twitter_checked = '';
$twitter_link = 'https://brid.gy/publish/twitter';
if (strpos($post['description'], $twitter_link) !== false) {
$twitter_checked = ' checked="checked"';
}
// Set Webaction if a class name is found in the description.
$class = '';
$url = '';
$options = '<option></option><option>like</option>' .
'<option>reply</option><option>share</option>';
if (strpos($post['description'], 'u-like-of') !== false) {
$class = 'u-like-of';
$options = '<option></option>' .
'<option selected="selected">like</option>' .
'<option>reply</option><option>share</option>';
}
else if (strpos($post['description'], 'u-repost-of') !== false) {
$class = 'u-repost-of';
$options = '<option></option><option>like</option>' .
'<option>reply</option>' .
'<option selected="selected">share</option>';
}
else if (strpos($post['description'], 'u-in-reply-to') !== false) {
$class = 'u-in-reply-to';
$options = '<option></option><option>like</option>' .
'<option selected="selected">reply</option>' .
'<option>share</option>';
}
if ($class !== '') {
$regex = '/<a href="(.*)" class="' . $class . '"/i';
if (preg_match($regex, $post['description'], $match)) {
$url = $match[1];
}
}
$media = '<fieldset id="post-media"><legend>Media</legend>';
$enclosure_list = json_decode($post['enclosure'], true);
if (is_array($enclosure_list)) {
foreach ($enclosure_list as $enclosure) {
$media .= '<div class="form-spacing">' .
'<button type="button" class="post-remove-photo">remove' .
'</button>' .
'<input name="enclosure" type="text" maxlength="200" ' .
'value="' . htmlspecialchars($enclosure) . '">' .
'</div>';
}
}
// type="button" is used to avoid default submit action.
$media .= '<button type="button" id="post-add-photo">add photo' .
'</button></fieldset>';
// The Extended module uses the name attribute to assign content.
$settings['custom'] = '<form id="extended-custom-settings">' .
'<div class="form-spacing">' .
'<label for="post-title-input">Title:</label>' .
'<input id="post-title-input" name="title" type="text" ' .
'value="' . htmlspecialchars($post['title']) . '" ' .
'maxlength="180">' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-author-input">Author:</label>' .
'<input id="post-author-input" name="author" type="text" ' .
'value="' . $post['author'] . '" maxlength="50">' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-category-input">Category:</label>' .
'<input id="post-category-input" name="category" type="text" ' .
'value="' . htmlspecialchars($post['category']) . '" ' .
'maxlength="200">' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-action-url-input">Webaction Url:</label>' .
'<input id="post-action-url-input" name="webactionUrl" ' .
'type="text" value="' . $url . '" maxlength="200">' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-action-type-input">Webaction Type:</label>' .
'<select id="post-action-type-input" name="webactionType">' .
$options . '</select>' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-twitter-input">Send to Twitter:</label>' .
'<input id="post-twitter-input" name="twitter" type="checkbox"' .
$twitter_checked . '>' .
'</div>' .
$media .
'<button type="submit">Submit</button>' .
'</form>';
}
$result->close();
}
else {
$this->Log('Post->CustomSettings: ' . $mysqli->error);
}
$mysqli->close();
return $settings;
}
private function Endpoint($url) {
$endpoint = discover_endpoint($url, 'webmention');
if ($endpoint === '') {
......@@ -1201,6 +1219,7 @@ class Post extends Base {
}
private function LookupAuthor($name, $url) {
$photo = '';
if ($name === '' &&
preg_match('/^https?:\/\/([^\/]+)/i', $url, $match)) {
$name = $match[1];
......
......@@ -64,7 +64,7 @@ dobrado.log('Loading action...','info');$.post('/php/request.php',{request:'writ
var webactionInfo=JSON.parse(response);$('#writer-webaction-info').html(webactionInfo.content);$('#writer-remove-action').button({icon:'ui-icon-closethick',showLabel:false}).click(removeActionExplicit);if(dobrado.reader){$('#writer-follow').button().click(dobrado.reader.addFeed);}});};dobrado.writer.select=function(filename){$('#writer-photo-selected').append('<img src="'+filename+'">');};dobrado.writer.showEditor=function(){function clearContent(){if(dobrado.editor.getData()===defaultText){dobrado.editor.setData('');}}
if(dobrado.editMode){dobrado.closeEditor();}
$('#writer-content').parents('div').each(function(){if(/^dobrado-/.test($(this).attr('id'))){dobrado.current='#'+$(this).attr('id');return false;}});$(dobrado.current).data('label','writer');var editorCssProperties=['background','background-attachment','background-color','background-image','background-position','background-repeat','background-size','clear','color','direction','empty-cells','font','font-family','font-size','font-style','font-variant','font-weight','letter-spacing','line-height','list-style','list-style-image','list-style-position','list-style-type','margin','margin-left','margin-right','margin-top','margin-bottom','opacity','outline','outline-color','outline-style','outline-width','padding','padding-bottom','padding-left','padding-right','padding-top','size','text-align','text-decoration','text-indent','text-transform','white-space','word-spacing'];var css='.cke_editable { ';var current=$(dobrado.current);for(var i=0;i<editorCssProperties.length;i++){var property=editorCssProperties[i];var value=current.css(property);if(value){css+=property+': '+value+';';}}
css+='}';CKEDITOR.addCss(css);var content=$('#writer-content').text();$('#writer-content').val(content);dobrado.editor=CKEDITOR.replace('writer-content',{allowedContent:true,autoGrow_minHeight:$('#writer-content').height(),autoGrow_onStartup:true,disableNativeSpellChecker:false,enterMode:CKEDITOR.ENTER_BR,extraPlugins:'autogrow,extended',filebrowserBrowseUrl:'/php/browse.php',removePlugins:'elementspath,tableselection,tabletools,contextmenu,liststyle',resize_enabled:false,on:{focus:clearContent},toolbar:[['Undo','Redo','-','Bold','Italic','-','Link','Unlink','-','Image','Extended']]});$('.writer-post').button('option','disabled',false);};dobrado.writer.newModuleCallback=function(id,context){var data=dobrado.editor?dobrado.editor.getData():$('#writer-content').val();var enclosure=[];$('#writer-photo-selected > img').each(function(){enclosure.push($(this).attr('src'));});var content={data:data,dataOnly:false,title:$('#writer-title').val(),author:$('#writer-author').val(),category:$('#writer-tag-input').val(),enclosure:JSON.stringify(enclosure),twitter:sendToTwitter,webactionType:webactionType,webactionUrl:webactionUrl};if(context==='post'){$.post('/php/content.php',{id:id,label:'post',content:JSON.stringify(content),url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'writer callback')){return;}
css+='}';CKEDITOR.addCss(css);var content=$('#writer-content').text();$('#writer-content').val(content);dobrado.editor=CKEDITOR.replace('writer-content',{allowedContent:true,autoGrow_minHeight:$('#writer-content').height(),autoGrow_onStartup:true,disableNativeSpellChecker:false,enterMode:CKEDITOR.ENTER_BR,extraPlugins:'autogrow,extended',filebrowserBrowseUrl:'/php/browse.php',removePlugins:'elementspath,tableselection,tabletools,contextmenu,liststyle',resize_enabled:false,on:{focus:clearContent},toolbar:[['Undo','Redo','-','Bold','Italic','-','Link','Unlink','-','Image','Extended']]});$('.writer-post').button('option','disabled',false);};dobrado.writer.newModuleCallback=function(id,context){var data=dobrado.editor?dobrado.editor.getData():$('#writer-content').val();var enclosure=[];$('#writer-photo-selected > img').each(function(){enclosure.push($(this).attr('src'));});var content={data:data,dataOnly:false,title:$('#writer-title').val(),author:$('#writer-author').val(),category:$('#writer-tag-input').val(),enclosure:enclosure,twitter:sendToTwitter,webactionType:webactionType,webactionUrl:webactionUrl};if(context==='post'){$.post('/php/content.php',{id:id,label:'post',content:JSON.stringify(content),url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'writer callback')){return;}
var formatted=JSON.parse(response);if(formatted.html){$(id).html(formatted.html);$(id).show();}
if(dobrado.editMode){var element=$(id+' .dobrado-editable').get(0);if(element){dobrado.inlineEditor(element);}}
if(dobrado.editor){dobrado.editor.setData(defaultText);}
......
......@@ -395,15 +395,12 @@ if (!this.dobrado.writer) {
$('#writer-photo-selected > img').each(function() {
enclosure.push($(this).attr('src'));
});
var content = { data: data,
dataOnly: false,
var content = { data: data, dataOnly: false,
title: $('#writer-title').val(),
author: $('#writer-author').val(),
category: $('#writer-tag-input').val(),
enclosure: JSON.stringify(enclosure),
twitter: sendToTwitter,
webactionType: webactionType,
webactionUrl: webactionUrl };
enclosure: enclosure, twitter: sendToTwitter,
webactionType: webactionType, webactionUrl: webactionUrl };
if (context === 'post') {
$.post('/php/content.php',
{ id: id, label: 'post', content: JSON.stringify(content),
......
......@@ -25,53 +25,54 @@
// for the JavaScript code in this page.
if(!this.dobrado.extended){dobrado.extended={};}
(function(){'use strict';var customChange=false;var notify=false;var media="";var mediaList=[];var rules={};var cssProperties=["azimuth","background","background-attachment","background-color","background-image","background-position","background-repeat","border","border-bottom","border-bottom-color","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-style","border-top-width","border-width","bottom","box-shadow","caption-side","clear","clip","color","content","counter-increment","counter-reset","cue","cue-after","cue-before","cursor","direction","display","elevation","empty-cells","filter","float","font","font-family","font-size","font-style","font-variant","font-weight","height","left","letter-spacing","line-height","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","max-height","max-width","min-height","min-width","opacity","orphans","outline","outline-color","outline-style","outline-width","overflow","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","pitch","pitch-range","play-during","position","quotes","richness","right","size","speak","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","text-align","text-decoration","text-indent","text-transform","top","unicode-bidi","vertical-align","visibility","voice-family","volume","white-space","widows","width","word-spacing","z-index"];var cssValues={"azimuth":["left-side","far-left","left","center-left","center","center-right","right","far-right","right-side","behind","leftwards","rightwards"],"background-attachment":["scroll","fixed"],"background-position":["left","center","right","top","bottom"],"background-repeat":["repeat","repeat-x","repeat-y","no-repeat"],"border-collapse":["collapse","separate"],"caption-side":["top","bottom"],"clear":["none","left","right","both"],"content":["normal","none","open-quote","close-quote","no-open-quote","no-close-quote"],"cursor":["auto","crosshair","default","pointer","move","e-resize","ne-resize","nw-resize","n-resize","se-resize","sw-resize","s-resize","w-resize","text","wait","help","progress"],"direction":["ltr","rtl"],"display":["inline","block","none","flex","grid","list-item","inline-block","table","inline-table","table-row-group","table-header-group","table-footer-group","table-row","table-column-group","table-column","table-cell","table-caption"],"elevation":["below","level","above","higher","lower"],"empty-cells":["show","hide"],"float":["left","right","none"],"font-style":["normal","italic","oblique"],"font-variant":["normal","small-caps"],"font-weight":["normal","bold","bolder","lighter","100","200","300","400","500","600","700","800","900"],"list-style-position":["inside","outside"],"list-style-type":["disc","circle","square","decimal","decimal-leading-zero","lower-roman","upper-roman","lower-greek","lower-latin","upper-latin","armenian","georgian","lower-alpha","upper-alpha","none"],"page-break-after":["auto","always","avoid","left","right"],"page-break-before":["auto","always","avoid","left","right"],"page-break-inside":["avoid","auto"],"pitch":["x-low","low","medium","high","x-high"],"position":["static","relative","absolute","fixed"],"speak-header":["once","always"],"speak-numeral":["digits","continuous"],"speak-punctuation":["code","none"],"speak":["normal","none","spell-out"],"speech-rate":["x-slow","slow","medium","fast","x-fast","faster","slower"],"text-align":["left","right","center","justify"],"text-decoration":["none","underline","overline","line-through","blink"],"text-transform":["capitalize","uppercase","lowercase","none"],"unicode-bidi":["normal","embed","bidi-override"],"vertical-align":["baseline","sub","super","top","text-top","middle","bottom","text-bottom"],"visibility":["visible","hidden","collapse"],"volume":["silent","x-soft","soft","medium","loud","x-loud"],"white-space":["normal","pre","nowrap","pre-wrap","pre-line"]};$(function(){$(".extended").dialog({show:true,autoOpen:false,width:750,height:500,position:{my:"top",at:"top+50",of:window},title:"Editor",close:close,create:dobrado.fixedDialog});$("#colorpicker").addClass("ui-widget-content").hide();});function saveStyle(){if(!$.isEmptyObject(rules)){var call=$(".extended").data("mode")+"_style";var updateAllPages=$("#extended-update-all-pages:checked").length;$.post("/php/"+call+".php",{url:location.href,style:JSON.stringify(rules),media:media,updateAllPages:updateAllPages,token:dobrado.token},function(response){dobrado.checkResponseError(response,call);});rules={};}}
function resetStyleEditor(){var updateAllPages="";var hidden=" hidden";if($(".extended").data("mode")==="page"){hidden="";}
if($("#extended-style .update-all-pages").length!==0){updateAllPages='<div class="update-all-pages'+hidden+'">'+'<label for="extended-update-all-pages">Copy changes to all pages?'+'</label>'+'<input id="extended-update-all-pages" type="checkbox">'+'</div>';}
(function(){'use strict';var customChange=false;var notify=false;var media='';var mediaList=[];var rules={};var cssProperties=['align-content','align-items','align-self','background','background-attachment','background-color','background-image','background-position','background-repeat','border','border-bottom','border-bottom-color','border-bottom-style','border-bottom-width','border-collapse','border-color','border-image','border-left','border-left-color','border-left-style','border-left-width','border-radius','border-right','border-right-color','border-right-style','border-right-width','border-spacing','border-style','border-top','border-top-color','border-top-style','border-top-width','border-width','bottom','box-shadow','clear','clip','color','content','cursor','direction','display','empty-cells','flex','flex-basis','flex-direction','flex-flow','flex-grow','flex-shrink','flex-wrap','float','font','font-family','font-size','font-style','font-variant','font-weight','grid','grid-area','grid-auto-columns','grid-auto-flow','grid-auto-rows','grid-column','grid-column-end','grid-column-gap','grid-column-start','grid-gap','grid-row','grid-row-end','grid-row-gap','grid-row-start','grid-template','grid-template-areas','grid-template-columns','grid-template-rows','height','justify-content','justify-items','justify-self','left','letter-spacing','line-height','list-style','list-style-image','list-style-position','list-style-type','margin','margin-bottom','margin-left','margin-right','margin-top','max-height','max-width','min-height','min-width','opacity','order','orphans','outline','outline-color','outline-style','outline-width','overflow','padding','padding-bottom','padding-left','padding-right','padding-top','page','page-break-after','page-break-before','page-break-inside','place-content','place-items','place-self','position','right','size','text-align','text-decoration','text-indent','text-transform','top','vertical-align','visibility','white-space','width','widows','word-spacing','z-index'];var cssValues={'align-content':['flex-start','flex-end','center','space-between','space-around','space-evenly','stretch','start','end'],'align-items':['auto','flex-start','flex-end','center','baseline','stretch','start','end'],'align-self':['auto','flex-start','flex-end','center','baseline','stretch','start','end'],'background-attachment':['scroll','fixed'],'background-position':['left','center','right','top','bottom'],'background-repeat':['repeat','repeat-x','repeat-y','no-repeat'],'border-collapse':['collapse','separate'],'clear':['none','left','right','both'],'content':['normal','none','open-quote','close-quote','no-open-quote','no-close-quote'],'cursor':['auto','crosshair','default','pointer','move','e-resize','ne-resize','nw-resize','n-resize','se-resize','sw-resize','s-resize','w-resize','text','wait','help','progress'],'direction':['ltr','rtl'],'display':['inline','block','none','flex','grid','list-item','inline-block','inline-grid','table','inline-table','table-row-group','table-header-group','table-footer-group','table-row','table-column-group','table-column','table-cell','table-caption'],'empty-cells':['show','hide'],'float':['left','right','none'],'flex-direction':['column','colum-reverse','row','row-reverse'],'flex-wrap':['nowrap','wrap','wrap-reverse'],'font-style':['normal','italic','oblique'],'font-variant':['normal','small-caps'],'font-weight':['normal','bold','bolder','lighter','100','200','300','400','500','600','700','800','900'],'grid-auto-flow':['row','column','row dense','column dense'],'justify-content':['flex-start','flex-end','center','space-between','space-around','space-evenly','start','end'],'justify-items':['start','end','center','stretch'],'justify-self':['start','end','center','stretch'],'list-style-position':['inside','outside'],'list-style-type':['disc','circle','square','decimal','decimal-leading-zero','lower-roman','upper-roman','lower-greek','lower-latin','upper-latin','armenian','georgian','lower-alpha','upper-alpha','none'],'page-break-after':['auto','always','avoid','left','right'],'page-break-before':['auto','always','avoid','left','right'],'page-break-inside':['avoid','auto'],'position':['static','sticky','relative','absolute','fixed'],'text-align':['left','right','center','justify'],'text-decoration':['none','underline','overline','line-through','blink'],'text-transform':['capitalize','uppercase','lowercase','none'],'vertical-align':['baseline','sub','super','top','text-top','middle','bottom','text-bottom'],'visibility':['visible','hidden','collapse'],'white-space':['normal','pre','nowrap','pre-wrap','pre-line']};$(function(){$('.extended').dialog({show:true,autoOpen:false,width:750,height:500,position:{my:'top',at:'top+50',of:window},title:'Editor',close:close,create:dobrado.fixedDialog});$('#colorpicker').addClass('ui-widget-content').hide();});function saveStyle(){if(!$.isEmptyObject(rules)){var call=$('.extended').data('mode')+'_style';var updateAllPages=$('#extended-update-all-pages:checked').length;$.post('/php/'+call+'.php',{style:JSON.stringify(rules),media:media,updateAllPages:updateAllPages,url:location.href,token:dobrado.token},function(response){dobrado.checkResponseError(response,call);});rules={};}}
function resetStyleEditor(){var updateAllPages='';var hidden=' hidden';if($('.extended').data('mode')==='page'){hidden='';}
if($('#extended-style .update-all-pages').length!==0){updateAllPages='<div class="update-all-pages'+hidden+'">'+'<label for="extended-update-all-pages">Copy changes to all pages?'+'</label>'+'<input id="extended-update-all-pages" type="checkbox">'+'</div>';}
var html='<div id="extended-style">'+
updateAllPages+'<div class="form-spacing">'+'<label for="extended-media-query">Media query: </label>'+'<input id="extended-media-query" type="text">'+'</div>'+'<div class="style-editor">'+'<h3><a href="#">Add a new style group</a></h3>'+'<div class="form-spacing">'+'<label for="extended-new-selector">Selector: </label>'+'<input id="extended-new-selector" type="text">'+'</div>'+'</div>'+'</div>';$("#extended-style").remove();$("#extended-content").after(html);}
function close(){function formatDate(){var d=new Date();var year=d.getFullYear();var month=d.getMonth()+1;var day=d.getDate();if(month<10){month="0"+month;}
if(day<10){day="0"+day;}
return year+"-"+month+"-"+day;}
saveStyle();media="";var content={dataOnly:false,notify:notify};$("#extended-custom-settings").find(":input").each(function(){var name=$(this).attr("name");if(name){if($(this).is(":radio")||$(this).is(":checkbox")){if($(this).is(":checked")){content[name]=1;}
updateAllPages+'<div class="form-spacing">'+'<label for="extended-media-query">Media query: </label>'+'<input id="extended-media-query" type="text">'+'</div>'+'<div class="style-editor">'+'<h3><a href="#">Add a new style group</a></h3>'+'<div class="form-spacing">'+'<label for="extended-new-selector">Selector: </label>'+'<input id="extended-new-selector" type="text">'+'</div>'+'</div>'+'</div>';$('#extended-style').remove();$('#extended-content').after(html);}
function close(){function formatDate(){var d=new Date();var year=d.getFullYear();var month=d.getMonth()+1;var day=d.getDate();if(month<10){month='0'+month;}
if(day<10){day='0'+day;}
return year+'-'+month+'-'+day;}
saveStyle();media='';var content={dataOnly:false,notify:notify};$('#extended-custom-settings').find(':input').each(function(){var name=$(this).attr('name');if(name){if($(this).is(':radio')||$(this).is(':checkbox')){if($(this).is(':checked')){content[name]=1;}
else{content[name]=0;}}
else{if(name==="title"&&$(this).val()!==""){var title=$(this).val().replace(/[^a-z0-9\s_-]/gi,"");title=title.replace(/\s/g,"_");dobrado.permalink=formatDate()+"-"+title;}
content[name]=$(this).val();}}});dobrado.closeEditor(content,customChange);$("#extended-tabs").tabs("destroy");if($(".extended").data("mode")==="box"){CKEDITOR.clearCss();if(dobrado.editMode){$(".dobrado-editable").each(function(){dobrado.inlineEditor($(this).get(0));});}}
$(".extended").data("mode","");resetStyleEditor();customChange=false;}
function mediaQuery(){var mode=$(".extended").data("mode");var parameters={request:"extended",mode:mode,action:"display",media:media,url:location.href,token:dobrado.token};if(mode==="box"){var id=dobrado.current;var content={data:dobrado.editor.getData()};parameters.id=id;parameters.label=$(id).data("label");parameters.content=JSON.stringify(content);}
dobrado.log("Loading media query.","info");$.post("/php/request.php",parameters,function(response){if(dobrado.checkResponseError(response,"mediaQuery")){return;}
else{if(name==='title'&&$(this).val()!==''){var title=$(this).val().replace(/[^a-z0-9\s_-]/gi,'');title=title.replace(/\s/g,'_');dobrado.permalink=formatDate()+'-'+title;}
if(name==='enclosure'){if(!content.enclosure){content.enclosure=[];}
content.enclosure.push($(this).val());}
else{content[name]=$(this).val();}}}});dobrado.closeEditor(content,customChange);$('#extended-tabs').tabs('destroy');if($('.extended').data('mode')==='box'){CKEDITOR.clearCss();if(dobrado.editMode){$('.dobrado-editable').each(function(){dobrado.inlineEditor($(this).get(0));});}}
$('.extended').data('mode','');resetStyleEditor();customChange=false;}
function mediaQuery(){var mode=$('.extended').data('mode');var parameters={request:'extended',mode:mode,action:'display',media:media,url:location.href,token:dobrado.token};if(mode==='box'){var id=dobrado.current;var content={data:dobrado.editor.getData()};parameters.id=id;parameters.label=$(id).data('label');parameters.content=JSON.stringify(content);}
dobrado.log('Loading media query.','info');$.post('/php/request.php',parameters,function(response){if(dobrado.checkResponseError(response,'mediaQuery')){return;}
var extended=JSON.parse(response);dobrado.extended.styleEditor(extended.style,extended.media);});}
function selectMediaQuery(event,ui){resetStyleEditor();media=ui.item.value;mediaQuery();}
function loadMediaQuery(event){if(event.keyCode!==13){return;}
event.preventDefault();resetStyleEditor();media=$(this).val();mediaQuery();}
function updateStyleRuleComponents(){$(".style-property").each(function(){$(this).one("click",dobrado.select);if(!$(this).attr("readonly")){$(this).autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:cssProperties});}
else if(cssValues[$(this).val()]){$(this).parent().next().children().autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:cssValues[$(this).val()]});}});$(".remove-style-rule").button({icon:'ui-icon-closethick',showLabel:false});$(".style-value").each(function(){if(/^#[a-f0-9]+$/i.test($(this).val())){$.farbtastic("#colorpicker").linkTo(this);$.farbtastic("#colorpicker").setColor($(this).val());}});$(".style-value").click(function(){if(/^#[a-f0-9]+$/i.test($(this).val())){$.farbtastic("#colorpicker").linkTo(this);$("#colorpicker").show().position({of:this,my:"top",at:"bottom",collision:"none"});$(this).blur(function(){$("#colorpicker").hide();});}});}
function updateStyleRuleComponents(){$('.style-property').each(function(){$(this).one('click',dobrado.select);if(!$(this).attr('readonly')){$(this).autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:cssProperties});}
else if(cssValues[$(this).val()]){$(this).parent().next().children().autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:cssValues[$(this).val()]});}});$('.remove-style-rule').button({icon:'ui-icon-closethick',showLabel:false});$('.style-value').each(function(){if(/^#[a-f0-9]+$/i.test($(this).val())){$.farbtastic('#colorpicker').linkTo(this);$.farbtastic('#colorpicker').setColor($(this).val());}});$('.style-value').click(function(){if(/^#[a-f0-9]+$/i.test($(this).val())){$.farbtastic('#colorpicker').linkTo(this);$('#colorpicker').show().position({of:this,my:'top',at:'bottom',collision:'none'});$(this).blur(function(){$('#colorpicker').hide();});}});}
function addNewSelector(event){if(event.keyCode!==13){return;}
event.preventDefault();var selector=$(this).val();selector=selector.replace(/>/g,"&gt;");selector=selector.replace(/</g,"&lt;");if(selector){var newStyleGroup='<h3><a href="#">'+selector+'</a></h3>'+'<div class="style-group">'+'<div class="style-rule">'+'<button class="remove-style-rule">remove</button>'+'<span class="ui-widget">'+'<input class="style-property" type="text" value="property">'+'</span>'+'<span class="ui-widget">'+'<input class="style-value" type="text" value="value">'+'</span>'+'</div>'+'<button class="new-style-rule">Add a new style rule</button>'+'</div>';$(this).val("");$(".style-editor").accordion("destroy");$(newStyleGroup).insertAfter($(this).parent());dobrado.extended.styleEditor();}}
event.preventDefault();var selector=$(this).val();selector=selector.replace(/>/g,'&gt;');selector=selector.replace(/</g,'&lt;');if(selector){var newStyleGroup='<h3><a href="#">'+selector+'</a></h3>'+'<div class="style-group">'+'<div class="style-rule">'+'<button class="remove-style-rule">remove</button>'+'<span class="ui-widget">'+'<input class="style-property" type="text" value="property">'+'</span>'+'<span class="ui-widget">'+'<input class="style-value" type="text" value="value">'+'</span>'+'</div>'+'<button class="new-style-rule">Add a new style rule</button>'+'</div>';$(this).val('');$('.style-editor').accordion('destroy');$(newStyleGroup).insertAfter($(this).parent());dobrado.extended.styleEditor();}}
function addStyleRuleEvents(){function save(selector,property,value){var current={};if(rules[selector]){current=rules[selector];}
current[property]=value;rules[selector]=current;}
function customSelector(text){if(dobrado.current){return text==="General"?dobrado.current:dobrado.current+" "+text;}
function customSelector(text){if(dobrado.current){return text==='General'?dobrado.current:dobrado.current+' '+text;}
return text;}
function saveSelector(selector,property,value){if(value==="value"){return;}
var custom=customSelector(selector);$(custom).css(property.val(),value);save(custom,property.val(),value);property.attr("readonly",true);}
$(".style-group").on("click",".remove-style-rule",function(){var property=$(this).next(".ui-widget").children(".style-property");var selector=$(this).parents(".style-group").prev("h3").text();saveSelector(selector,property,"");$(this).parent().remove();});$(".style-group").one("click",".style-property",dobrado.select).on("blur",".style-property",function(){if(cssValues[$(this).val()]){$(this).parent().next().children().autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:cssValues[$(this).val()]});}});$(".style-group").one("click",".style-value",dobrado.select).on("blur keypress",".style-value",function(event){if(event.type==="keypress"&&event.keyCode!==13){return;}
event.preventDefault();var selector=$(this).parents(".style-group").prev("h3").text();var property=$(this).parent().prev().children(".style-property");saveSelector(selector,property,$(this).val());});$(".new-style-rule").button().click(function(){var newStyleRule='<div class="style-rule">'+'<button class="remove-style-rule">remove</button>'+'<span class="ui-widget">'+'<input class="style-property" type="text" value="property">'+'</span>'+'<span class="ui-widget">'+'<input class="style-value" type="text" value="value">'+'</span>'+'</div>';$(newStyleRule).insertBefore($(this));updateStyleRuleComponents();});}
dobrado.extended.selectTab=function(event,ui){if($(ui.oldTab).text()==="Style"){saveStyle();}};dobrado.extended.styleEditor=function(style,updateMedia){if(style){$(".style-editor").append(style);}
function saveSelector(selector,property,value){if(value==='value'){return;}
var custom=customSelector(selector);$(custom).css(property.val(),value);save(custom,property.val(),value);property.attr('readonly',true);}
$('.style-group').on('click','.remove-style-rule',function(){var property=$(this).next('.ui-widget').children('.style-property');var selector=$(this).parents('.style-group').prev('h3').text();saveSelector(selector,property,'');$(this).parent().remove();});$('.style-group').one('click','.style-property',dobrado.select).on('blur','.style-property',function(){if(cssValues[$(this).val()]){$(this).parent().next().children().autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:cssValues[$(this).val()]});}});$('.style-group').one('click','.style-value',dobrado.select).on('blur keypress','.style-value',function(event){if(event.type==='keypress'&&event.keyCode!==13){return;}
event.preventDefault();var selector=$(this).parents('.style-group').prev('h3').text();var property=$(this).parent().prev().children('.style-property');saveSelector(selector,property,$(this).val());});$('.new-style-rule').button().click(function(){var newStyleRule='<div class="style-rule">'+'<button class="remove-style-rule">remove</button>'+'<span class="ui-widget">'+'<input class="style-property" type="text" value="property">'+'</span>'+'<span class="ui-widget">'+'<input class="style-value" type="text" value="value">'+'</span>'+'</div>';$(newStyleRule).insertBefore($(this));updateStyleRuleComponents();});}
dobrado.extended.select=function(filename){var enclosure='<div class="form-spacing">'+'<button class="post-remove-photo">remove</button>'+'<input name="enclosure" type="text" maxlength="200" '+'value="'+filename+'">'+'</div>';$(enclosure).insertBefore('#post-add-photo').children('.post-remove-photo').button({icon:'ui-icon-closethick',showLabel:false}).click(function(){$(this).parent().remove();return false;});};dobrado.extended.selectTab=function(event,ui){if($(ui.oldTab).text()==='Style'){saveStyle();}};dobrado.extended.styleEditor=function(style,updateMedia){if(style){$('.style-editor').append(style);}
if(updateMedia){mediaList=updateMedia;}
$("#extended-media-query").val(media);$(".style-editor").accordion({heightStyle:"content"});addStyleRuleEvents();updateStyleRuleComponents();$("#extended-media-query").autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:mediaList,select:selectMediaQuery});$("#extended-media-query").keypress(loadMediaQuery);$("#extended-new-selector").keypress(addNewSelector);$("#extended-tabs").show().tabs({activate:dobrado.extended.selectTab});if(!dobrado.editor&&$("#extended-content > div.edit").html()===""){$("#extended-tabs").tabs("disable",1);}
if($("#extended-custom > div.custom").html()===""){$("#extended-tabs").tabs("disable",0);if(dobrado.editor||$("#extended-content > div.edit").html()!==""){$("#extended-tabs").tabs("option","active",1);}
else{$("#extended-tabs").tabs("option","active",2);}}};dobrado.extended.editor=function(response){dobrado.editorLoading=false;if(dobrado.checkResponseError(response,"extended.editor")){$(".extended").dialog("close");return;}
dobrado.editor=null;$(".dobrado-editable").attr("contenteditable",false);$.each(CKEDITOR.instances,function(){this.destroy();});var extended=JSON.parse(response);var custom="";var source="";if(extended.content.custom){custom=extended.content.custom;}
$('#extended-media-query').val(media);$('.style-editor').accordion({heightStyle:'content'});addStyleRuleEvents();updateStyleRuleComponents();$('#extended-media-query').autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:mediaList,select:selectMediaQuery});$('#extended-media-query').keypress(loadMediaQuery);$('#extended-new-selector').keypress(addNewSelector);$('#extended-tabs').show().tabs({activate:dobrado.extended.selectTab});if(!dobrado.editor&&$('#extended-content > div.edit').html()===''){$('#extended-tabs').tabs('disable',1);}
if($('#extended-custom > div.custom').html()===''){$('#extended-tabs').tabs('disable',0);if(dobrado.editor||$('#extended-content > div.edit').html()!==''){$('#extended-tabs').tabs('option','active',1);}
else{$('#extended-tabs').tabs('option','active',2);}}};dobrado.extended.editor=function(response){dobrado.editorLoading=false;if(dobrado.checkResponseError(response,'extended.editor')){$('.extended').dialog('close');return;}
dobrado.editor=null;$('.dobrado-editable').attr('contenteditable',false);$.each(CKEDITOR.instances,function(){this.destroy();});var extended=JSON.parse(response);var custom='';var source='';if(extended.content.custom){custom=extended.content.custom;}
if(extended.content.source){source=extended.content.source;}
notify=false;if(extended.content.notify){notify=extended.content.notify;}
var label=$(dobrado.current).data("label");if(label==="commenteditor"){label="Comment Manager";}
else if(label==="simple"){label="Text Area";}
var label=$(dobrado.current).data('label');if(label==='commenteditor'){label='Comment Manager';}
else if(label==='simple'){label='Text Area';}
else{label=label.charAt(0).toUpperCase()+label.slice(1);}
$("#extended-tabs li a").first().html(label);$("#extended-custom").html('<div class="custom">'+custom+'</div>');$("#extended-content").html('<div class="edit">'+source+'</div>');dobrado.oldPermalink=extended.content.permalink;$("#extended-custom-settings").find(":input").change(function(){customChange=true;});$("#extended-custom-settings :submit").button().click(function(){$(".extended").dialog("close");return false;});if(extended.content.editor===true){var edit=$("#extended-content > div.edit");var editorCssProperties=["azimuth","background","background-attachment","background-color","background-image","background-position","background-repeat","background-size","caption-side","clear","clip","color","content","counter-increment","counter-reset","cue","cue-after","cue-before","cursor","direction","empty-cells","filter","font","font-family","font-size","font-style","font-variant","font-weight","letter-spacing","line-height","list-style","list-style-image","list-style-position","list-style-type","opacity","orphans","outline","outline-color","outline-style","outline-width","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","pitch","pitch-range","play-during","quotes","richness","size","speak","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","text-align","text-decoration","text-indent","text-transform","unicode-bidi","vertical-align","voice-family","volume","white-space","widows","word-spacing"];var css=".cke_editable { ";var current=$(dobrado.current);for(var i=0;i<editorCssProperties.length;i++){var property=editorCssProperties[i];var value=current.css(property);if(value){css+=property+": "+value+";";}}
css+="}";CKEDITOR.addCss(css);dobrado.editor=CKEDITOR.replace(edit.get(0),{allowedContent:true,disableNativeSpellChecker:false,enterMode:CKEDITOR.ENTER_BR,filebrowserBrowseUrl:'/php/browse.php',height:240,removePlugins:'elementspath,tableselection,tabletools,contextmenu,liststyle',resize_enabled:false,toolbar:[['Source','-','NewPage'],['Undo','Redo','-','SelectAll','RemoveFormat'],['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],['Bold','Italic','Underline','Strike'],['Subscript','Superscript'],['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['Link','Unlink','Anchor'],['Image','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],['Format','Font','FontSize'],['TextColor','BGColor'],['Maximize','ShowBlocks','-','About']]});}
dobrado.extended.styleEditor(extended.style,extended.media);$("#extended-history").html(extended.history);$(".extended").dialog("open");$(".extended").data("mode","box");};}());jQuery.fn.farbtastic=function(callback){$.farbtastic(this,callback);return this;};jQuery.farbtastic=function(container,callback){container=$(container).get(0);return container.farbtastic||(container.farbtastic=new jQuery._farbtastic(container,callback));}
jQuery._farbtastic=function(container,callback){var fb=this;$(container).html('<div class="farbtastic"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>');var e=$('.farbtastic',container);fb.wheel=$('.wheel',container).get(0);fb.radius=84;fb.square=100;fb.width=194;if(navigator.appVersion.match(/MSIE [0-6]\./)){$('*',e).each(function(){if(this.currentStyle.backgroundImage!='none'){var image=this.currentStyle.backgroundImage;image=this.currentStyle.backgroundImage.substring(5,image.length-2);$(this).css({'backgroundImage':'none','filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='"+image+"')"});}});}
fb.linkTo=function(callback){if(typeof fb.callback=='object'){$(fb.callback).unbind('keyup',fb.updateValue);}
$('#extended-tabs li a').first().html(label);$('#extended-custom').html('<div class="custom">'+custom+'</div>');$('#extended-content').html('<div class="edit">'+source+'</div>');dobrado.oldPermalink=extended.content.permalink;$('#extended-custom-settings').find(":input").change(function(){customChange=true;});$('#extended-custom-settings :submit').button().click(function(){$('.extended').dialog('close');return false;});$('.post-remove-photo').button({icon:'ui-icon-closethick',showLabel:false}).click(function(){$(this).parent().remove();return false;});$('#post-add-photo').button().click(function(){dobrado.createModule('browser','browser','extended');return false;});if(extended.content.editor===true){var edit=$('#extended-content > div.edit');var editorCssProperties=['background','background-attachment','background-color','background-image','background-position','background-repeat','background-size','clear','clip','color','content','cursor','direction','empty-cells','filter','font','font-family','font-size','font-style','font-variant','font-weight','letter-spacing','line-height','list-style','list-style-image','list-style-position','list-style-type','opacity','outline','outline-color','outline-style','outline-width','padding','padding-bottom','padding-left','padding-right','padding-top','size','text-align','text-decoration','text-indent','text-transform','white-space','word-spacing'];var css='.cke_editable { ';var current=$(dobrado.current);for(var i=0;i<editorCssProperties.length;i++){var property=editorCssProperties[i];var value=current.css(property);if(value){css+=property+': '+value+';';}}
css+='}';CKEDITOR.addCss(css);dobrado.editor=CKEDITOR.replace(edit.get(0),{allowedContent:true,disableNativeSpellChecker:false,enterMode:CKEDITOR.ENTER_BR,filebrowserBrowseUrl:'/php/browse.php',height:240,removePlugins:'elementspath,tableselection,tabletools,contextmenu,liststyle',resize_enabled:false,toolbar:[['Source','-','NewPage'],['Undo','Redo','-','SelectAll','RemoveFormat'],['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],['Bold','Italic','Underline','Strike'],['Subscript','Superscript'],['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['Link','Unlink','Anchor'],['Image','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],['Format','Font','FontSize'],['TextColor','BGColor'],['Maximize','ShowBlocks','-','About']]});}
dobrado.extended.styleEditor(extended.style,extended.media);$('#extended-history').html(extended.history);$('.extended').dialog('open');$('.extended').data('mode','box');};}());jQuery.fn.farbtastic=function(callback){$.farbtastic(this,callback);return this;};jQuery.farbtastic=function(container,callback){container=$(container).get(0);return container.farbtastic||(container.farbtastic=new jQuery._farbtastic(container,callback));}
jQuery._farbtastic=function(container,callback){var fb=this;$(container).html('<div class="farbtastic"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>');var e=$('.farbtastic',container);fb.wheel=$('.wheel',container).get(0);fb.radius=84;fb.square=100;fb.width=194;fb.linkTo=function(callback){if(typeof fb.callback=='object'){$(fb.callback).unbind('keyup',fb.updateValue);}
fb.color=null;if(typeof callback=='function'){fb.callback=callback;}
else if(typeof callback=='object'||typeof callback=='string'){fb.callback=$(callback);fb.callback.bind('keyup',fb.updateValue);if(fb.callback.get(0).value){fb.setColor(fb.callback.get(0).value);}}
return this;}
......
......@@ -36,126 +36,126 @@ if (!this.dobrado.extended) {
// to send out notifications even though content has not changed.
var notify = false;
// The name of the current media query for style rules.
var media = "";
var media = '';
// The array passed to autocomplete of existing media queries.
var mediaList = [];
// Style rules that need to be saved when the style editor is closed.
var rules = {};
// Autocomplete css properties.
var cssProperties =
["azimuth", "background", "background-attachment", "background-color",
"background-image", "background-position", "background-repeat",
"border", "border-bottom", "border-bottom-color", "border-bottom-style",
"border-bottom-width", "border-collapse", "border-color",
"border-image", "border-left", "border-left-color", "border-left-style",
"border-left-width", "border-radius", "border-right",
"border-right-color", "border-right-style", "border-right-width",
"border-spacing", "border-style", "border-top", "border-top-color",
"border-top-style", "border-top-width", "border-width", "bottom",
"box-shadow", "caption-side", "clear", "clip", "color", "content",
"counter-increment", "counter-reset", "cue", "cue-after", "cue-before",
"cursor", "direction", "display", "elevation", "empty-cells", "filter",
"float", "font", "font-family", "font-size", "font-style",
"font-variant", "font-weight", "height", "left", "letter-spacing",
"line-height", "list-style", "list-style-image", "list-style-position",
"list-style-type", "margin", "margin-bottom", "margin-left",
"margin-right", "margin-top", "max-height", "max-width", "min-height",
"min-width", "opacity", "orphans", "outline", "outline-color",
"outline-style", "outline-width", "overflow", "padding", "padding-bottom",
"padding-left", "padding-right", "padding-top", "page",
"page-break-after", "page-break-before", "page-break-inside", "pause",
"pause-after", "pause-before", "pitch", "pitch-range", "play-during",
"position", "quotes", "richness", "right", "size", "speak",
"speak-header", "speak-numeral", "speak-punctuation", "speech-rate",
"stress", "text-align", "text-decoration", "text-indent",
"text-transform", "top", "unicode-bidi", "vertical-align", "visibility",
"voice-family", "volume", "white-space", "widows", "width",
"word-spacing", "z-index"];
['align-content', 'align-items', 'align-self', 'background',
'background-attachment', 'background-color', 'background-image',
'background-position', 'background-repeat', 'border', 'border-bottom',
'border-bottom-color', 'border-bottom-style', 'border-bottom-width',
'border-collapse', 'border-color', 'border-image', 'border-left',
'border-left-color', 'border-left-style', 'border-left-width',
'border-radius', 'border-right', 'border-right-color',
'border-right-style', 'border-right-width', 'border-spacing',
'border-style', 'border-top', 'border-top-color', 'border-top-style',
'border-top-width', 'border-width', 'bottom', 'box-shadow', 'clear',
'clip', 'color', 'content', 'cursor', 'direction', 'display',
'empty-cells', 'flex', 'flex-basis', 'flex-direction', 'flex-flow',
'flex-grow', 'flex-shrink', 'flex-wrap', 'float', 'font', 'font-family',
'font-size', 'font-style', 'font-variant', 'font-weight', 'grid',
'grid-area', 'grid-auto-columns', 'grid-auto-flow', 'grid-auto-rows',
'grid-column', 'grid-column-end', 'grid-column-gap', 'grid-column-start',
'grid-gap', 'grid-row', 'grid-row-end', 'grid-row-gap', 'grid-row-start',
'grid-template', 'grid-template-areas', 'grid-template-columns',
'grid-template-rows', 'height', 'justify-content', 'justify-items',
'justify-self', 'left', 'letter-spacing', 'line-height', 'list-style',
'list-style-image', 'list-style-position', 'list-style-type', 'margin',
'margin-bottom', 'margin-left', 'margin-right', 'margin-top', 'max-height',
'max-width', 'min-height', 'min-width', 'opacity', 'order', 'orphans',
'outline', 'outline-color', 'outline-style', 'outline-width', 'overflow',
'padding', 'padding-bottom', 'padding-left', 'padding-right',
'padding-top', 'page', 'page-break-after', 'page-break-before',
'page-break-inside', 'place-content', 'place-items', 'place-self',
'position', 'right', 'size', 'text-align', 'text-decoration',
'text-indent', 'text-transform', 'top', 'vertical-align', 'visibility',
'white-space', 'width', 'widows', 'word-spacing', 'z-index'];
// Autocomplete css values from property names.
var cssValues = {
"azimuth" : ["left-side", "far-left", "left", "center-left", "center",
"center-right", "right", "far-right", "right-side",
"behind", "leftwards", "rightwards"],
"background-attachment" : ["scroll", "fixed"],
"background-position" : ["left", "center", "right", "top", "bottom"],
"background-repeat" : ["repeat","repeat-x","repeat-y", "no-repeat"],
"border-collapse" : ["collapse", "separate"],
"caption-side" : ["top", "bottom"],
"clear" : ["none", "left", "right", "both"],
"content" : ["normal", "none", "open-quote", "close-quote",
"no-open-quote", "no-close-quote"],
"cursor" : ["auto", "crosshair", "default", "pointer", "move", "e-resize",
"ne-resize", "nw-resize", "n-resize", "se-resize", "sw-resize",
"s-resize", "w-resize", "text", "wait", "help", "progress"],
"direction" : ["ltr", "rtl"],
"display" : ["inline", "block", "none", "flex", "grid", "list-item",
"inline-block", "table", "inline-table", "table-row-group",
"table-header-group", "table-footer-group", "table-row",
"table-column-group", "table-column", "table-cell",
"table-caption"],
"elevation" : ["below", "level", "above", "higher", "lower"],
"empty-cells" : ["show", "hide"],
"float" : ["left", "right", "none"],
"font-style" : ["normal", "italic", "oblique"],
"font-variant" : ["normal", "small-caps"],
"font-weight" : ["normal", "bold", "bolder", "lighter", "100", "200",
"300", "400", "500", "600", "700", "800", "900"],
"list-style-position" : ["inside", "outside"],
"list-style-type" : ["disc", "circle", "square", "decimal",
"decimal-leading-zero", "lower-roman", "upper-roman",
"lower-greek", "lower-latin", "upper-latin",
"armenian", "georgian", "lower-alpha",
"upper-alpha", "none"],
"page-break-after" : ["auto", "always", "avoid", "left", "right"],
"page-break-before" : [