Skip to content

Instantly share code, notes, and snippets.

@seeschloss
Last active December 15, 2015 19:29
Show Gist options
  • Save seeschloss/5311799 to your computer and use it in GitHub Desktop.
Save seeschloss/5311799 to your computer and use it in GitHub Desktop.
diff --git a/asset.module b/asset.module
index a39f07f..6eaa645 100644
--- a/asset.module
+++ b/asset.module
@@ -320,28 +320,30 @@ function asset_menu() {
'file' => 'includes/asset.admin.inc',
);
- $items['admin/assets/get'] = array(
+ $items['admin/assets/tag/%/%/%'] = array(
'theme callback' => 'asset_get_frontend_theme',
- 'page callback' => 'assets_get_content',
- 'page arguments' => array(3),
+ 'page callback' => '_asset_get_tag',
+ 'page arguments' => array(3, 4, 5),
'access arguments' => array('administer assets'),
'type' => MENU_CALLBACK,
'file' => 'includes/asset.admin.inc',
+ 'delivery callback' => 'asset_json_delivery',
);
- $items['admin/assets/getfull'] = array(
+ // @todo: Add custom delivery callback for partial asset rendering to the following menu items.
+ $items['admin/assets/get'] = array(
'theme callback' => 'asset_get_frontend_theme',
- 'page callback' => 'asset_get_full_content',
+ 'page callback' => 'assets_get_content',
'page arguments' => array(3),
'access arguments' => array('administer assets'),
'type' => MENU_CALLBACK,
'file' => 'includes/asset.admin.inc',
);
- $items['admin/assets/tag/%/%/%'] = array(
+ $items['admin/assets/getfull'] = array(
'theme callback' => 'asset_get_frontend_theme',
- 'page callback' => '_asset_get_tag',
- 'page arguments' => array(3, 4, 5),
+ 'page callback' => 'asset_get_full_content',
+ 'page arguments' => array(3),
'access arguments' => array('administer assets'),
'type' => MENU_CALLBACK,
'file' => 'includes/asset.admin.inc',
@@ -355,22 +357,23 @@ function asset_menu() {
'access arguments' => array('view', 'asset', 2),
'type' => MENU_CALLBACK,
'file' => 'includes/asset.admin.inc',
- 'delivery_callback' => 'asset_html_delivery',
);
return $items;
}
/**
- * Delivery callback for HTML rendering.
+ * Delivery callback for json format.
*/
-function asset_html_delivery($page_callback_result) {
- // Check if header is set.
- if (is_null(drupal_get_http_header('Content-Type'))) {
- drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
+function asset_json_delivery($page_callback_result) {
+ if (!empty($page_callback_result['tag']) && !empty($page_callback_result['content'])) {
+ print drupal_json_encode(
+ array(
+ 'tag' => $page_callback_result['tag'],
+ 'content' => $page_callback_result['content'],
+ )
+ );
}
-
- print $page_callback_result;
}
/**
diff --git a/ckeditor/assets-editor.css b/ckeditor/assets-editor.css
index d06d550..b4dbe5a 100644
--- a/ckeditor/assets-editor.css
+++ b/ckeditor/assets-editor.css
@@ -30,3 +30,9 @@
margin: 0 0 0 8px;
float: right;
}
+
+.asset.editor.asset-align-center {
+ margin-left: auto;
+ margin-right: auto;
+ display: block;
+}
diff --git a/ckeditor/cut.png b/ckeditor/cut.png
new file mode 100644
index 0000000..d6b3e06
Binary files /dev/null and b/ckeditor/cut.png differ
diff --git a/ckeditor/delete.png b/ckeditor/delete.png
new file mode 100644
index 0000000..9ae5870
Binary files /dev/null and b/ckeditor/delete.png differ
diff --git a/ckeditor/edit.png b/ckeditor/edit.png
index a1179df..ffd4a58 100644
Binary files a/ckeditor/edit.png and b/ckeditor/edit.png differ
diff --git a/ckeditor/gear.png b/ckeditor/gear.png
deleted file mode 100644
index 29e66f9..0000000
Binary files a/ckeditor/gear.png and /dev/null differ
diff --git a/ckeditor/override.png b/ckeditor/override.png
new file mode 100644
index 0000000..ddb49bd
Binary files /dev/null and b/ckeditor/override.png differ
diff --git a/ckeditor/paste.png b/ckeditor/paste.png
new file mode 100644
index 0000000..70ee833
Binary files /dev/null and b/ckeditor/paste.png differ
diff --git a/ckeditor/plugin.js b/ckeditor/plugin.js
index 909ce64..4b9e89c 100644
--- a/ckeditor/plugin.js
+++ b/ckeditor/plugin.js
@@ -4,13 +4,28 @@
*/
var Assets;
(function ($) {
+ // Temporary container for asset html.
var tempContainer = document.createElement('DIV'),
tagCache = {},
cutted = null;
+ // Assets object.
Assets = {
selectedElement: null,
+ getCKeditorVersion: function () {
+ if (CKEDITOR.version) {
+ var explodedVersion = CKEDITOR.version.split('.');
+ return explodedVersion[0] ? parseInt(explodedVersion[0]) : null;
+ }
+ },
+
+ select: function (element) {
+ this.deselect();
+ this.selectedElement = element;
+ this.selectedElement.addClass('selected');
+ },
+
deselect: function () {
var element = null, removeSelectedClass = function (el) {
var cl, i, cl_arr;
@@ -49,12 +64,6 @@ var Assets;
return element;
},
- select: function (element) {
- this.deselect();
- this.selectedElement = element;
- this.selectedElement.addClass('selected');
- },
-
getSelected: function (editor) {
if (this.selectedElement) {
return this.selectedElement;
@@ -135,6 +144,15 @@ var Assets;
};
},
+ adjustDialogHeight: function () {
+ // CKeditor 4 have bug into plugins/dialog/plugin.js line 1036.
+ // Developers forgot to add height:100% into iframe wrapper.
+ // In CKeditor 3 this code present.
+ setTimeout(function () {
+ $('.cke_dialog_contents .cke_dialog_ui_vbox.cke_dialog_page_contents').css('height','100%');
+ }, 0);
+ },
+
openDialog: function (editor, dialogName, src, element) {
editor.openDialog(dialogName, function () {
this.definition.contents[0].elements[0].src = src;
@@ -142,13 +160,16 @@ var Assets;
if (typeof(element) !== 'undefined') {
this._outdatedAssetEl = element;
}
+
+ // Fix height iframe wrapper issue with ckeditor 4.
+ Assets.adjustDialogHeight();
});
},
searchDialog: function () {
return {
title: 'Media Assets',
- minWidth: 1000,
+ minWidth: 800,
minHeight: 600,
contents: [{
id: 'asset_frame',
@@ -188,6 +209,9 @@ var Assets;
}
}
);
+
+ // Fix height iframe wrapper issue with ckeditor 4.
+ Assets.adjustDialogHeight();
}
}]
}],
@@ -207,19 +231,36 @@ var Assets;
if ($asset_div.size()) {
$asset_div.attr('data-asset-cid', tagId);
- if ((align == 'left') || (align == 'right')) {
+ if ((align == 'center') || (align == 'left') || (align == 'right')) {
// Add special classes for visual feedback in wysiwyg.
var $image = $asset_div.find('img');
var $video = $asset_div.find('object');
if ($image.size() || $video.size()) {
- if ($image.size()) {
- $image.css('float', align).siblings('div.field').css('clear', 'both');
+ // Center aligment handler.
+ if (align == 'center') {
+ if ($image.size()) {
+ $image.css({'margin-left':'auto', 'margin-right':'auto', 'display':'block'});
+ }
+ else if ($video.size()) {
+ $video.css({'margin-left':'auto', 'margin-right':'auto', 'display':'block'});
+ }
}
- else if ($video.size()) {
- $video.parents('div.field').css('float', align).next('div.field').css('clear', 'both')
+ // Left, right handler.
+ else {
+ if ($image.size()) {
+ $image.css('float', align).parent().siblings('div.field').css('clear', 'both');
+ }
+ else if ($video.size()) {
+ $video.parents('div.field').css('float', align).next('div.field').css('clear', 'both')
+ }
}
}
+ // Add style to wrapper.
else {
+ if (align == 'center') {
+ $asset_div.removeClass('rtecenter').addClass('rtecenter');
+ }
+
if (align == 'left') {
$asset_div.removeClass('rteright').addClass('rteleft');
}
@@ -231,7 +272,7 @@ var Assets;
}
// Need for small mode, and none align.
else {
- $asset_div.removeClass('rteleft rteright');
+ $asset_div.removeClass('rteleft rteright rtecenter');
}
}
return tempContainer;
@@ -331,11 +372,12 @@ var Assets;
}
};
+ // Ckeditor plugin body.
CKEDITOR.plugins.add('asset', {
lang: ['en', 'fr', 'ru'],
- buttons: [],
-
requires: ['htmlwriter', 'iframedialog'],
+
+ // Callbacks.
replaceAsset: function (tag_id, tag) {
if (Assets.outdated) {
$.ajax({
@@ -367,46 +409,164 @@ var Assets;
init: function (editor) {
var path = this.path;
+ // Ckeditor instanceReady event.
editor.on('instanceReady', function (evt) {
var editor = evt.editor;
editor.document.appendStyleSheet(path + 'assets-editor.css');
- // For webkit set cursor of wysiwyg to the end to prevent wrong pasting of asset.
- // Webkit works incorrectly with contentEditable.
- if (CKEDITOR.instances && CKEDITOR.env && CKEDITOR.env.webkit) {
- editor.focus();
+ if (CKEDITOR.instances && CKEDITOR.env) {
+ // For webkit set cursor of wysiwyg to the end to prevent asset in asset pasting.
+ if (CKEDITOR.env.webkit) {
+ // Handle case for CKeditor 4.
+ if (Assets.getCKeditorVersion() >= 4) {
+ // Сreate a range for the entire contents of the editor document body.
+ var range = editor.createRange();
+ // Move to the end of the range.
+ range.moveToPosition(range.root, CKEDITOR.POSITION_BEFORE_END);
+ // Putting the current selection there.
+ editor.getSelection().selectRanges([range]);
+ }
+ }
- // Getting selection.
- var selected = editor.getSelection();
- // Getting ranges.
- var selected_ranges = selected.getRanges();
- // Selecting the starting node.
- var node = selected_ranges[0].startContainer;
- var parents = node.getParents(true);
+ // Fix for CKeditor 3 & Chrome and for CKeditor 4 && FF.
+ if ((Assets.getCKeditorVersion() < 4 && CKEDITOR.env.webkit)
+ || (Assets.getCKeditorVersion() >= 4 && CKEDITOR.env.gecko)) {
+ editor.focus();
+
+ // Getting selection.
+ var selected = editor.getSelection();
+ // Getting ranges.
+ var selected_ranges = selected.getRanges();
+ // Selecting the starting node.
+ var range = selected_ranges[0];
+
+ if (range) {
+ var node = range.startContainer;
+ var parents = node.getParents(true);
+
+ node = parents[parents.length - 2].getFirst();
+ if (node) {
+ while (true) {
+ var x = node ? node.getNext() : null;
+
+ if (x == null) {
+ break;
+ }
- node = parents[parents.length - 2].getFirst();
- if (node) {
- while (true) {
- var x = node ? node.getNext() : null;
+ node = x;
+ }
- if (x == null) {
- break;
+ selected.selectElement(node);
}
- node = x;
+ selected_ranges = selected.getRanges();
+ // False collapses the range to the end of the selected node, true before the node.
+ selected_ranges[0].collapse(false);
+ // Putting the current selection there.
+ selected.selectRanges(selected_ranges);
}
+ }
+ }
+ });
- selected.selectElement(node);
+ // Wrapper for contentDom group events.
+ editor.on('contentDom', function (evt) {
+ editor.document.on('click', function (evt) {
+ var element = evt.data.getTarget();
+
+ while (element && !(element.type === CKEDITOR.NODE_ELEMENT && element.data('asset-cid'))) {
+ element = element.getParent();
}
- selected_ranges = selected.getRanges();
- // False collapses the range to the end of the selected node, true before the node.
- selected_ranges[0].collapse(false);
- // Putting the current selection there.
- selected.selectRanges(selected_ranges);
+ if (element) {
+ editor.getSelection().selectElement(element);
+ Assets.select(element);
+ }
+ else {
+ Assets.deselect(element);
+ }
+ });
+
+ editor.document.on('mousedown', function (evt) {
+ var element = evt.data.getTarget();
+
+ if (element.is('img')) {
+ while (element && !(element.type === CKEDITOR.NODE_ELEMENT && element.data('asset-cid'))) {
+ element = element.getParent();
+ }
+ if (element) {
+ evt.data.preventDefault(true);
+ }
+ }
+ });
+ });
+
+ // Paste event.
+ editor.on('paste', function (evt) {
+ var data = evt.data, dataProcessor = new pasteProcessor(), htmlFilter = dataProcessor.htmlFilter,
+ processed = {};
+
+ htmlFilter.addRules({
+ elements: {
+ 'div': function (element) {
+ var wrapper, tagId, tag_id;
+ Assets.deselect(element);
+
+ if (element.attributes && element.attributes['data-asset-cid']) {
+ tag_id = element.attributes['data-asset-cid'];
+
+ // @todo: Check for webkit this functionality is forbidden.
+ if (CKEDITOR.env.webkit) {
+ return false;
+ }
+
+ if (!processed[tag_id]) {
+ tagId = Assets.generateId(tag_id);
+
+ if (typeof(tagCache[tag_id]) === 'undefined') {
+ Assets.getDataById(tagId);
+ }
+
+ processed[tagId] = 1;
+ wrapper = new CKEDITOR.htmlParser.fragment.fromHtml(tagCache[tagId].html);
+
+ return wrapper.children[0];
+ }
+ }
+ return element;
+ }
+ }
+ });
+
+ try {
+ data['html'] = dataProcessor.toHtml(data['html']);
}
+ catch (e) {
+ if (typeof(console) !== 'undefined') {
+ console.log(editor.lang.asset.assets_error_paste);
+ }
+ }
+ Assets.deselect();
+ }, this);
+
+ // Double click event.
+ editor.on('doubleclick', function (evt) {
+ var editor = evt.editor;
+
+ // Getting selection.
+ var element = Assets.getSelected(editor), tag_id, tag, src;
+
+ // Open dialog frame.
+ if (element) {
+ Assets.outdated = element;
+ tag_id = element.data('asset-cid');
+ tag = encodeURIComponent(tagCache[tag_id].tag);
+ src = Drupal.settings.basePath + 'admin/assets/override?render=popup&tag=' + tag;
+ Assets.openDialog(editor, 'asset_' + Assets.parseId(tag_id, 'type'), src, element);
+ }
});
+ // Common functionality for the plugin.
this.Assets = Assets;
var conf = Drupal.settings.ckeditor.plugins.asset, assetType, type, execFn;
@@ -431,7 +591,7 @@ var Assets;
editorFocus: CKEDITOR.env.ie || CKEDITOR.env.webkit
});
- editor.ui.addButton(type, {
+ editor.ui.addButton && editor.ui.addButton(type, {
label: conf[assetType].name,
command: type,
icon: this.path + 'buttons/' + conf[assetType].icon
@@ -451,6 +611,7 @@ var Assets;
return editor.document.createElement('br');
};
+ // Add commands for asset.
editor.addCommand('addLineAfter', {
exec: function (editor) {
var node = Assets.getSelected(editor), newline;
@@ -477,8 +638,8 @@ var Assets;
CKEDITOR.dialog.add('assetSearch', Assets.searchDialog);
editor.addCommand('assetSearch', new CKEDITOR.dialogCommand('assetSearch'));
- editor.ui.addButton('assetSearch', {
- label: editor.lang.assets_btn_search,
+ editor.ui.addButton && editor.ui.addButton('assetSearch', {
+ label: (Assets.getCKeditorVersion() >= 4) ? editor.lang.asset.assets_btn_search : editor.lang.assets_btn_search,
command: 'assetSearch',
icon: this.path + 'search.png'
});
@@ -558,90 +719,76 @@ var Assets;
editorFocus: CKEDITOR.env.ie || CKEDITOR.env.webkit
});
- editor.on('contentDom', function (evt) {
- editor.document.on('click', function (evt) {
- var element = evt.data.getTarget();
-
- while (element && !(element.type === CKEDITOR.NODE_ELEMENT && element.data('asset-cid'))) {
- element = element.getParent();
- }
-
- if (element) {
- editor.getSelection().selectElement(element);
- Assets.select(element);
- }
- else {
- Assets.deselect(element);
- }
- });
-
- editor.document.on('mousedown', function (evt) {
- var element = evt.data.getTarget();
-
- if (element.is('img')) {
- while (element && !(element.type === CKEDITOR.NODE_ELEMENT && element.data('asset-cid'))) {
- element = element.getParent();
- }
- if (element) {
- evt.data.preventDefault(true);
- }
- }
- });
- });
-
+ // Create context menu.
if (editor.addMenuItem) {
- editor.addMenuGroup('asset');
-
- editor.addMenuItem('assetoverride', {
- label: editor.lang.assets_override,
- command: 'assetOverride',
- group: 'asset',
- icon: this.path + 'gear.png'
- });
+ editor.addMenuGroup('asset_operations', 100);
- editor.addMenuItem('assetedit', {
- label: editor.lang.assets_edit,
- command: 'assetEdit',
- group: 'asset',
- icon: this.path + 'edit.png'
- });
-
- editor.addMenuItem('assetdelete', {
- label: editor.lang.assets_delete,
- command: 'assetDelete',
- group: 'asset'
- });
-
- editor.addMenuItem('assetcut', {
- label: editor.lang.assets_cut,
- command: 'assetCut',
- group: 'asset'
- });
-
- editor.addMenuItem('assetpaste', {
- label: editor.lang.assets_paste,
- command: 'assetPaste',
- group: 'asset'
+ editor.addMenuItems({
+ assetcut: {
+ label: (Assets.getCKeditorVersion() >= 4) ? editor.lang.asset.assets_cut : editor.lang.assets_cut,
+ command: 'assetCut',
+ group: 'asset_operations',
+ icon: this.path + 'cut.png',
+ order: 1
+ },
+ assetpaste: {
+ label: (Assets.getCKeditorVersion() >= 4) ? editor.lang.asset.assets_paste : editor.lang.assets_paste,
+ command: 'assetPaste',
+ group: 'asset_operations',
+ icon: this.path + 'paste.png',
+ order: 2
+ },
+ assetdelete: {
+ label: (Assets.getCKeditorVersion() >= 4) ? editor.lang.asset.assets_delete : editor.lang.assets_delete,
+ command: 'assetDelete',
+ group: 'asset_operations',
+ icon: this.path + 'delete.png',
+ order: 3
+ }
});
- editor.addMenuGroup('newline', 200);
+ editor.addMenuGroup('asset_newline', 200);
editor.addMenuItems({
addLineBefore: {
- label: editor.lang.assets_nl_before,
+ label: (Assets.getCKeditorVersion() >= 4) ? editor.lang.asset.assets_nl_before : editor.lang.assets_nl_before,
command: 'addLineBefore',
- group: 'newline',
+ group: 'asset_newline',
order: 1
},
addLineAfter: {
- label: editor.lang.assets_nl_after,
+ label: (Assets.getCKeditorVersion() >= 4) ? editor.lang.asset.assets_nl_after : editor.lang.assets_nl_after,
command: 'addLineAfter',
- group: 'newline',
+ group: 'asset_newline',
+ order: 2
+ }
+ });
+
+ editor.addMenuGroup('asset_edit', 300);
+ editor.addMenuItems({
+ assetoverride: {
+ label: (Assets.getCKeditorVersion() >= 4) ? editor.lang.asset.assets_override : editor.lang.assets_override,
+ command: 'assetOverride',
+ group: 'asset_edit',
+ icon: this.path + 'override.png',
+ order: 1
+ },
+ assetedit: {
+ label: (Assets.getCKeditorVersion() >= 4) ? editor.lang.asset.assets_edit : editor.lang.assets_edit,
+ command: 'assetEdit',
+ group: 'asset_edit',
+ icon: this.path + 'edit.png',
order: 2
}
});
}
if (editor.contextMenu) {
+ // Remove items from div plugin.
+ editor.removeMenuItem('editdiv');
+ editor.removeMenuItem('removediv');
+ // Remove default menu item paste.
+ editor.removeMenuItem('paste');
+
editor.contextMenu.addListener(function (element, selection) {
var type, conf, menu = {};
@@ -649,19 +796,25 @@ var Assets;
element = element.getParent();
}
+ // Open context menu.
if (element) {
+ // Select asset element, if element wasn't selected before.
+ if (!element.hasClass('selected')) {
+ Assets.select(element)
+ }
+
type = Assets.parseId(element.data('asset-cid'), 'type');
conf = Drupal.settings.ckeditor.plugins.asset[type];
- if (!(conf.modes.length === 1 && conf.modes.full && !conf.fields.length)) {
- menu.assetoverride = CKEDITOR.TRISTATE_ON;
- }
-
- menu.assetedit = CKEDITOR.TRISTATE_ON;
- menu.assetdelete = CKEDITOR.TRISTATE_ON;
menu.assetcut = CKEDITOR.TRISTATE_ON;
+ menu.assetdelete = CKEDITOR.TRISTATE_ON;
menu.addLineBefore = CKEDITOR.TRISTATE_ON;
menu.addLineAfter = CKEDITOR.TRISTATE_ON;
+ menu.assetedit = CKEDITOR.TRISTATE_ON;
+
+ if (conf && conf.modes && !(conf.modes.length === 1 && conf.modes.full && !conf.fields.length)) {
+ menu.assetoverride = CKEDITOR.TRISTATE_ON;
+ }
}
else {
if (cutted !== null) {
@@ -687,53 +840,6 @@ var Assets;
return writer.getHtml(true);
}
};
-
- editor.on('paste', function (evt) {
- var data = evt.data, dataProcessor = new pasteProcessor(), htmlFilter = dataProcessor.htmlFilter,
- processed = {};
-
- htmlFilter.addRules({
- elements: {
- 'div': function (element) {
- var wrapper, tagId, tag_id;
- Assets.deselect(element);
-
- if (element.attributes && element.attributes['data-asset-cid']) {
- tag_id = element.attributes['data-asset-cid'];
-
- // @todo: Check for webkit this functionality is forbidden.
- if (CKEDITOR.env.webkit) {
- return false;
- }
-
- if (!processed[tag_id]) {
- tagId = Assets.generateId(tag_id);
-
- if (typeof(tagCache[tag_id]) === 'undefined') {
- Assets.getDataById(tagId);
- }
-
- processed[tagId] = 1;
- wrapper = new CKEDITOR.htmlParser.fragment.fromHtml(tagCache[tagId].html);
-
- return wrapper.children[0];
- }
- }
- return element;
- }
- }
- });
-
- try {
- data['html'] = dataProcessor.toHtml(data['html']);
- }
- catch (e) {
- if (typeof(console) !== 'undefined') {
- console.log(editor.lang.assets_error_paste);
- }
- }
- Assets.deselect();
- }, this);
},
afterInit: function (editor) {
diff --git a/css/assets.css b/css/assets.css
index 08a937a..5c191e3 100644
--- a/css/assets.css
+++ b/css/assets.css
@@ -10,7 +10,7 @@
margin: 0 0 0 8px;
}
-.asset.asset-align-right img {
+.asset.asset-align-right img, .asset.asset-align-right object {
float: right;
}
@@ -19,18 +19,16 @@
margin: 0 8px 0 0;
}
-.asset.asset-align-left img {
+.asset.asset-align-left img, .asset.asset-align-left object {
float: left;
}
-.asset.asset-align-left object {
- float: left;
-}
-
-.asset.asset-align-right object {
- float: right;
-}
-
.asset div.field {
clear: both;
}
+
+.asset.asset-align-center img, .asset.asset-align-center object {
+ margin-left: auto;
+ margin-right: auto;
+ display: block;
+}
diff --git a/includes/asset.admin.inc b/includes/asset.admin.inc
index 5be7191..25b9018 100644
--- a/includes/asset.admin.inc
+++ b/includes/asset.admin.inc
@@ -60,9 +60,11 @@ function asset_type_form($form, &$form_state, $asset_type, $op = 'edit') {
$icons_options = $icons_options + $module_icons;
}
+ $icons_options = array_keys($icons_options);
+
$form['icons']['icon'] = array(
'#type' => 'radios',
- '#default_value' => $asset_type->icon ? $asset_type->icon : reset(array_keys($icons_options)),
+ '#default_value' => $asset_type->icon ? $asset_type->icon : reset($icons_options),
'#options' => $icons_options,
'#title' => t('Button icon'),
);
@@ -236,7 +238,7 @@ function assets_add($type) {
*/
function _assets_wysiwyg_fields(&$form, $asset, $options) {
$entity_info = $asset->entityInfo();
- $align = isset($options['align']) && in_array($options['align'], array('left', 'right', ''), TRUE)
+ $align = isset($options['align']) && in_array($options['align'], array('center', 'left', 'right', ''), TRUE)
? $options['align']
: '';
$mode = isset($options['mode']) ? $options['mode'] : '';
@@ -291,6 +293,7 @@ function _assets_wysiwyg_fields(&$form, $asset, $options) {
'#default_value' => $align,
'#options' => array(
'' => t('None'),
+ 'center' => t('Center'),
'left' => t('Left'),
'right' => t('Right'),
),
@@ -602,10 +605,7 @@ function asset_get_full_content() {
* Page callback, return html of asset by wysiwyg view mode.
*/
function _asset_get_tag($tag_id, $view_mode = NULL, $align = NULL) {
- $output = '';
- $placeholder = '';
-
- $tags = explode(':', $tag_id);
+ $tags = !empty($tag_id) ? explode(':', $tag_id) : array();
$asset = !empty($tags[0]) ? asset_load($tags[0]) : NULL;
if ($asset) {
@@ -628,20 +628,14 @@ function _asset_get_tag($tag_id, $view_mode = NULL, $align = NULL) {
'align' => $align,
)
);
+
$placeholder = str_replace("\r\n", '\n', $placeholder);
$asset_content = $asset->view($view_mode);
$output = render($asset_content);
- }
- print drupal_json_encode(
- array(
- 'tag' => $placeholder,
- 'content' => $output,
- )
- );
-
- drupal_exit();
+ return array('tag' => $placeholder, 'content' => $output);
+ }
}
/**
@@ -656,5 +650,5 @@ function asset_tooltip_content($asset, $view_mode) {
*/
function asset_view_asset($asset, $view_mode = ASSET_DEFAULT_MODE) {
$output = $asset->view($view_mode);
- return render($output);
+ return $output;
}
diff --git a/modules/asset_widget/asset_widget.admin.inc b/modules/asset_widget/asset_widget.admin.inc
index 2e1f2ec..3a380f5 100644
--- a/modules/asset_widget/asset_widget.admin.inc
+++ b/modules/asset_widget/asset_widget.admin.inc
@@ -23,7 +23,7 @@ function asset_widget_get_tab_by_id($target_tab_id = FALSE) {
}
// Render all tabs content.
else {
- $use_cookie_fallback = variable_get('asset_widget_save_last_search', FALSE);
+ $use_cookie_fallback = variable_get('asset_widget_save_last_search', TRUE);
foreach (asset_widget_get_tabs_info() as $tab_id => $info) {
$output = asset_widget_get_rendered_tab_content($info, $_POST, $use_cookie_fallback);
if ($output) {
@@ -44,7 +44,7 @@ function asset_widget_get_tab_by_id($target_tab_id = FALSE) {
}
// Set first tab as active on first load, or search results in case of cookie-stored search.
- if (!$target_tab_id && variable_get('asset_widget_save_last_search', FALSE) && !empty($_COOKIE['Drupal_asset_widget_filter_params'])) {
+ if (!$target_tab_id && variable_get('asset_widget_save_last_search', TRUE) && !empty($_COOKIE['Drupal_asset_widget_filter_params'])) {
$target_tab = 'results';
}
else {
diff --git a/modules/asset_widget/asset_widget.module b/modules/asset_widget/asset_widget.module
index 52e8f68..a44f029 100644
--- a/modules/asset_widget/asset_widget.module
+++ b/modules/asset_widget/asset_widget.module
@@ -249,9 +249,8 @@ function asset_widget_pre_render_text_format($element) {
// Store element id.
$attached[$element['#id']] = $element['#id'];
}
-
- return $element;
}
+ return $element;
}
/**
@@ -736,8 +735,9 @@ function asset_widget_views_ajax_data_alter(&$commands, &$view) {
// Set filter params into internal vars.
$filter_params = drupal_http_build_query(_asset_widget_views_get_exposed_values($view));
- // @todo we still have problems with cookie.
- if (variable_get('asset_widget_save_last_search', FALSE)) {
+ // We can disable this functionality using variable.
+ // @todo: Provide settings form for module with this setting.
+ if (variable_get('asset_widget_save_last_search', TRUE)) {
global $base_path;
setcookie('Drupal_asset_widget_filter_params', $filter_params, (time() + 60 * 60 * 24), $base_path);
}
diff --git a/modules/asset_widget/css/asset-widget-custom.css b/modules/asset_widget/css/asset-widget-custom.css
index a308c3e..4a3ae3f 100644
--- a/modules/asset_widget/css/asset-widget-custom.css
+++ b/modules/asset_widget/css/asset-widget-custom.css
@@ -123,7 +123,6 @@
}
/*--Rubik themes style fixes--*/
-
/*--Pager styles--*/
.assets-module .pager-container .item-list{
@@ -164,6 +163,62 @@
}
/*--end pager styles--*/
+/*--end rubik themes style fixes--*/
+
+.assets-module .assets-module-inner .assets-content .tab-contents .tab-contents-bottom .mid .tab .pager-container ul .pager-current {
+ color: #333;
+ text-shadow: white 0px 1px 0px;
+}
+
+.assets-module .assets-module-inner .assets-content .tab-contents .tab-contents-bottom .mid .tab .pager-container ul li span {
+ padding: 0;
+}
+
+.assets-module .assets-module-inner .assets-content .tab-contents .tab-contents-bottom .mid .tab .pager-container ul li a {
+ padding: 0;
+}
+
+.assets-module .pager-container ul {
+ float: none;
+}
+.assets-module .pager-container .pager {
+ margin: 0;
+}
-/*--end rubik themes style fixes--*/
\ No newline at end of file
+.assets-module .pager-container ul.pager-list {
+ float: none;
+ text-align: center;
+ padding: 0 60px;
+}
+
+.assets-module .pager-container ul.pager-list li {
+ float: none;
+}
+
+.assets-module .pager-container ul.pager-links {
+ float: none;
+ margin-top: -20px;
+ position: relative;
+}
+
+.assets-module .pager-container ul.pager-links .pager-next {
+ position: absolute !important;
+ right: 40px;
+ top: 0 !important;
+}
+
+.assets-module .pager-container ul.pager-links .pager-last {
+ float: right
+}
+
+.assets-module .pager-container ul.pager-links .pager-previous {
+ position: absolute !important;
+ left: 40px;
+ top: 0 !important;
+}
+
+.assets-module .pager-container ul.pager-links .pager-first {
+ float: left;
+ margin-top: -10px;
+}
diff --git a/modules/asset_widget/css/asset-widget-inner-form.css b/modules/asset_widget/css/asset-widget-inner-form.css
index e772fbb..f6b8abe 100644
--- a/modules/asset_widget/css/asset-widget-inner-form.css
+++ b/modules/asset_widget/css/asset-widget-inner-form.css
@@ -326,4 +326,58 @@ table.sticky-header {
height: 130px;
padding: 7px;
line-height: 16px;
+}
+
+/* override rubik theme css */
+html {
+ overflow-y: visible;
+}
+
+body {
+ background: #E2DFDD !important;
+}
+
+.block {
+ background: transparent;
+}
+
+.block-content {
+ background: transparent;
+ padding: 0;
+}
+
+.form-item {
+ background: transparent;
+}
+
+form .form-actions {
+ background: transparent;
+ border: none;
+ margin-bottom: 20px;
+ padding: 0;
+}
+
+form .form-actions input {
+ margin-top: 0;
+}
+
+table {
+ background: transparent;
+}
+
+.form-type-textarea:after {
+ content: " ";
+ display: block;
+ height: 0;
+ clear: both;
+ overflow: hidden;
+ visibility: hidden;
+}
+
+.text-format-wrapper .form-item {
+ background: none;
+}
+
+tbody tr td {
+ width: 100%;
}
\ No newline at end of file
diff --git a/modules/asset_widget/css/asset-widget.css b/modules/asset_widget/css/asset-widget.css
index e464860..af219c2 100644
--- a/modules/asset_widget/css/asset-widget.css
+++ b/modules/asset_widget/css/asset-widget.css
@@ -851,7 +851,7 @@
}
.assets-module .assets-module-inner .assets-content .tab-contents .tab-contents-top .mid {
width: 349px;
- padding: 17px 15px;
+ padding: 11px 15px;
min-height: 15px;
height: 65px;
background: url('../images/bgs/bg_filters_a.png') repeat-y 0 0;
diff --git a/modules/asset_widget/js/asset-widget.js b/modules/asset_widget/js/asset-widget.js
index f034892..5a5d64b 100644
--- a/modules/asset_widget/js/asset-widget.js
+++ b/modules/asset_widget/js/asset-widget.js
@@ -862,17 +862,11 @@ assetWidget.allowDrop = false;
$form.find('textarea.match-field').parent().addClass('field-refuse');
// Handle inputs.
var $fieldWrapper = $form.find('input.match-field').parent();
- var $multipleFieldWrapper = $form.find('input.match-field').parents('tr td');
-
- if ($multipleFieldWrapper.size()) {
- $multipleFieldWrapper.addClass('field-refuse');
- }
- else {
- $fieldWrapper.addClass('field-refuse');
- }
+ $fieldWrapper.addClass('field-refuse');
$.each($match, function() {
var $this = $(this);
+
// We haven't case when we can restrict to add some types to wysiwyg.
// Add accept style to matched fields.
var $fieldWrapper = $this.parent();
@@ -1114,7 +1108,7 @@ assetWidget.allowDrop = false;
$searchParams.removeClass('tab-contents-top-empty').animate({"top":"-60px"}, 150, 'linear');
}
else {
- $searchParams.removeClass('tab-contents-top-empty').animate({"top":"-110px"}, 150, 'linear');
+ $searchParams.removeClass('tab-contents-top-empty').animate({"top":"-103px"}, 150, 'linear');
}
}
};
@@ -1123,9 +1117,8 @@ assetWidget.allowDrop = false;
* Hide search filters block.
*/
assetWidget.paramDown = function () {
+ // @todo we have problem with that class, because it could be added with delay after paramUp complete.
assetWidget.$widget.find(".tab-contents-top").animate({"top":"-11px"}, 150, 'linear', function () {
- // @todo we have problem with that class, becuase it could be added with delay after paramUp complete.
- //$(this).addClass('tab-contents-top-empty');
});
};
diff --git a/theme/theme.inc b/theme/theme.inc
index b5d459f..f645ad2 100644
--- a/theme/theme.inc
+++ b/theme/theme.inc
@@ -32,7 +32,7 @@ function template_preprocess_asset_wrapper(&$vars) {
if ($view_mode !== ASSET_DEFAULT_MODE) {
$options = !empty($asset->asset_options) && is_array($asset->asset_options) ? $asset->asset_options : array();
- if (!empty($options['align']) && in_array($options['align'], array('', 'left', 'right'), TRUE)) {
+ if (!empty($options['align']) && in_array($options['align'], array('', 'center', 'left', 'right'), TRUE)) {
$classes_array[] = drupal_html_class('asset-align-' . $options['align']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment