Browse Source

Merge branch 'pr/111'

master
Igor Zhukov 11 years ago
parent
commit
641a657e9f
  1. 3
      .gitignore
  2. 56
      app/css/app.css
  3. BIN
      app/img/emojisprite_0.png
  4. BIN
      app/img/emojisprite_1.png
  5. BIN
      app/img/emojisprite_2.png
  6. BIN
      app/img/emojisprite_3.png
  7. BIN
      app/img/emojisprite_4.png
  8. BIN
      app/img/icons/EmojiTabSheet.png
  9. 24
      app/js/app.js
  10. 4
      app/js/lib/config.js
  11. 113
      app/vendor/jquery.emojiarea/jquery.emojiarea.js

3
.gitignore vendored

@ -1,8 +1,9 @@
.DS_Store .DS_Store
.idea
# Node.js package manager # Node.js package manager
/node_modules /node_modules
/npm-debug.log /npm-debug.log
dist dist
package_dist package_dist
webogram*.zip webogram*.zip

56
app/css/app.css

@ -1642,7 +1642,7 @@ img.img_fullsize {
z-index: 999; z-index: 999;
width: 180px; width: 180px;
margin-left: -91px; margin-left: -91px;
margin-top: -232px; margin-top: -260px;
overflow: hidden; overflow: hidden;
} }
.emoji-items-wrap1 { .emoji-items-wrap1 {
@ -1652,12 +1652,62 @@ img.img_fullsize {
-moz-border-radius: 3px; -moz-border-radius: 3px;
border-radius: 3px; border-radius: 3px;
} }
.emoji-items-wrap1 .emoji-menu-tabs {
width: 100%;
}
.emoji-items-wrap1 .emoji-menu-tabs td {
text-align: center;
color: white;
}
.emoji-menu-tabs .emoji-menu-tab {
display: inline-block;
width: 24px;
height: 24px;
background: url(../img/icons/EmojiTabSheet.png) no-repeat;
background-size: 120px 48px;
}
.icon-smile {
background-position: 0 0 !important;
}
.icon-smile-selected {
background-position: 0 -24px !important;
border-bottom: 1px solid white;
}
.icon-flower {
background-position: -24px 0 !important;
}
.icon-flower-selected {
background-position: -24px -24px !important;
border-bottom: 1px solid white;
}
.icon-bell {
background-position: -48px 0 !important;
}
.icon-bell-selected {
background-position: -48px -24px !important;
border-bottom: 1px solid white;
}
.icon-car {
background-position: -72px 0 !important;
}
.icon-car-selected {
background-position: -72px -24px !important;
border-bottom: 1px solid white;
}
.icon-grid {
background-position: -96px 0 !important;
}
.icon-grid-selected {
background-position: -96px -24px !important;
border-bottom: 1px solid white;
}
.emoji-menu .emoji-items-wrap { .emoji-menu .emoji-items-wrap {
position: relative; position: relative;
height: 190px; height: 190px;
} }
.emoji-menu .emoji-items { .emoji-menu .emoji-items {
padding-right: 8px; padding-right: 8px;
outline: 0 !important;
} }
.emoji-menu img { .emoji-menu img {
width: 20px; width: 20px;
@ -1665,7 +1715,7 @@ img.img_fullsize {
vertical-align: middle; vertical-align: middle;
border: 0 none; border: 0 none;
} }
.emoji-menu a { .emoji-menu .emoji-items a {
margin: -1px 0 0 -1px; margin: -1px 0 0 -1px;
/*border: 1px solid #f2f2f2;*/ /*border: 1px solid #f2f2f2;*/
padding: 4px; padding: 4px;
@ -1673,7 +1723,7 @@ img.img_fullsize {
float: left; float: left;
border-radius: 2px; border-radius: 2px;
} }
.emoji-menu a:hover { .emoji-menu .emoji-items a:hover {
background-color: rgba(0,0,0, 0.5); background-color: rgba(0,0,0, 0.5);
/*background-color: #fffae7;*/ /*background-color: #fffae7;*/
} }

BIN
app/img/emojisprite_0.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 KiB

BIN
app/img/emojisprite_1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 KiB

BIN
app/img/emojisprite_2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 944 KiB

BIN
app/img/emojisprite_3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 KiB

BIN
app/img/emojisprite_4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 KiB

BIN
app/img/icons/EmojiTabSheet.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

24
app/js/app.js

@ -38,21 +38,23 @@ angular.module('myApp', [
]). ]).
config(['$locationProvider', '$routeProvider', '$compileProvider', function($locationProvider, $routeProvider, $compileProvider) { config(['$locationProvider', '$routeProvider', '$compileProvider', function($locationProvider, $routeProvider, $compileProvider) {
var icons = {}, reverseIcons = {}, i, j, hex, name, dataItem, var icons = {}, reverseIcons = {}, i, j, hex, name, dataItem, row, column, totalColumns;
ranges = [[0x1f600, 0x1f637], [0x261d, 0x263f], [0x270a, 0x270c], [0x1f446, 0x1f450]];
for (j in ranges) { for (j = 0; j < Config.EmojiCategories.length; j++) {
for (i = ranges[j][0]; i <= ranges[j][1]; i++) { totalColumns = Config.EmojiCategorySpritesheetDimens[j][1];
hex = i.toString(16); for (i = 0; i < Config.EmojiCategories[j].length; i++) {
if (dataItem = Config.Emoji[hex]) { dataItem = Config.Emoji[Config.EmojiCategories[j][i]];
name = dataItem[1][0]; name = dataItem[1][0];
icons[':' + name + ':'] = hex + '.png'; row = Math.floor(i / totalColumns);
reverseIcons[name] = dataItem[0]; column = (i % totalColumns);
} icons[':' + name + ':'] = [j, row, column, ':'+name+':'];
reverseIcons[name] = dataItem[0];
} }
} }
$.emojiarea.path = 'vendor/gemoji/images'; $.emojiarea.spritesheetPath = 'img/emojisprite_!.png';
$.emojiarea.spritesheetDimens = Config.EmojiCategorySpritesheetDimens;
$.emojiarea.iconSize = 20;
$.emojiarea.icons = icons; $.emojiarea.icons = icons;
$.emojiarea.reverseIcons = reverseIcons; $.emojiarea.reverseIcons = reverseIcons;

4
app/js/lib/config.js

File diff suppressed because one or more lines are too long

113
app/vendor/jquery.emojiarea/jquery.emojiarea.js vendored

@ -29,8 +29,14 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*! MODIFICATION START
Options 'spritesheetPath', 'spritesheetDimens', 'iconSize' added by Andre Staltz.
*/
$.emojiarea = { $.emojiarea = {
path: '', path: '',
spritesheetPath: '',
spritesheetDimens: [],
iconSize: 20,
icons: {}, icons: {},
defaults: { defaults: {
button: null, button: null,
@ -38,6 +44,7 @@
buttonPosition: 'after' buttonPosition: 'after'
} }
}; };
/*! MODIFICATION END */
$.fn.emojiarea = function(options) { $.fn.emojiarea = function(options) {
options = $.extend({}, $.emojiarea.defaults, options); options = $.extend({}, $.emojiarea.defaults, options);
@ -198,14 +205,28 @@
this.$button = $button; this.$button = $button;
}; };
/*! MODIFICATION START
This function was modified by Andre Staltz so that the icon is created from a spritesheet.
*/
EmojiArea.createIcon = function(emoji) { EmojiArea.createIcon = function(emoji) {
var filename = $.emojiarea.icons[emoji]; var category = emoji[0];
var path = $.emojiarea.path || ''; var row = emoji[1];
if (path.length && path.charAt(path.length - 1) !== '/') { var column = emoji[2];
path += '/'; var name = emoji[3];
} var filename = $.emojiarea.spritesheetPath;
return '<img src="' + path + filename + '" alt="' + util.htmlEntities(emoji) + '">'; var xoffset = -($.emojiarea.iconSize * column);
var yoffset = -($.emojiarea.iconSize * row);
var scaledWidth = ($.emojiarea.spritesheetDimens[category][1] * $.emojiarea.iconSize);
var scaledHeight = ($.emojiarea.spritesheetDimens[category][0] * $.emojiarea.iconSize);
var style = 'display:inline-block;';
style += 'width:' + $.emojiarea.iconSize + 'px;';
style += 'height:' + $.emojiarea.iconSize + 'px;';
style += 'background:url(\'' + filename.replace('!',category) + '\') ' + xoffset + 'px ' + yoffset + 'px no-repeat;';
style += 'background-size:' + scaledWidth + 'px ' + scaledHeight + 'px;';
return '<img src="img/blank.gif" class="img" style="'+ style +'" alt="' + util.htmlEntities(name) + '">';
}; };
/*! MODIFICATION END */
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -272,7 +293,8 @@
var emojis = $.emojiarea.icons; var emojis = $.emojiarea.icons;
for (var key in emojis) { for (var key in emojis) {
if (emojis.hasOwnProperty(key)) { if (emojis.hasOwnProperty(key)) {
html = html.replace(new RegExp(util.escapeRegex(key), 'g'), EmojiArea.createIcon(key)); /* MODIFICATION: Following line was modified by Andre Staltz, to use new implementation of createIcon function.*/
html = html.replace(new RegExp(util.escapeRegex(key), 'g'), EmojiArea.createIcon(emojis[key]));
} }
} }
this.$editor.html(html); this.$editor.html(html);
@ -293,17 +315,17 @@
Following code was modified by Igor Zhukov, in order to improve rich text paste Following code was modified by Igor Zhukov, in order to improve rich text paste
*/ */
EmojiArea_WYSIWYG.prototype.onPaste = function(e) { EmojiArea_WYSIWYG.prototype.onPaste = function(e) {
var text = (e.originalEvent || e).clipboardData.getData('text/plain'), var text = (e.originalEvent || e).clipboardData.getData('text/plain'),
self = this; self = this;
setTimeout(function () { setTimeout(function () {
self.onChange(); self.onChange();
}, 0); }, 0);
if (text.length) { if (text.length) {
document.execCommand('insertText', false, text); document.execCommand('insertText', false, text);
return cancelEvent(e); return cancelEvent(e);
} }
return true; return true;
} };
/*! MODIFICATION END */ /*! MODIFICATION END */
EmojiArea_WYSIWYG.prototype.onChange = function(e) { EmojiArea_WYSIWYG.prototype.onChange = function(e) {
@ -312,7 +334,8 @@
EmojiArea_WYSIWYG.prototype.insert = function(emoji) { EmojiArea_WYSIWYG.prototype.insert = function(emoji) {
var content; var content;
var $img = $(EmojiArea.createIcon(emoji)); /* MODIFICATION: Following line was modified by Andre Staltz, to use new implementation of createIcon function.*/
var $img = $(EmojiArea.createIcon($.emojiarea.icons[emoji]));
if ($img[0].attachEvent) { if ($img[0].attachEvent) {
$img[0].attachEvent('onresizestart', function(e) { e.returnValue = false; }, false); $img[0].attachEvent('onresizestart', function(e) { e.returnValue = false; }, false);
} }
@ -403,8 +426,16 @@
/*! MODIFICATION START /*! MODIFICATION START
Following code was modified by Igor Zhukov, in order to add scrollbars and tail to EmojiMenu Following code was modified by Igor Zhukov, in order to add scrollbars and tail to EmojiMenu
Also modified by Andre Staltz, to include tabs for categories, on the menu header.
*/ */
this.$itemsTailWrap = $('<div class="emoji-items-wrap1"></div>').appendTo(this.$menu); this.$itemsTailWrap = $('<div class="emoji-items-wrap1"></div>').appendTo(this.$menu);
this.$categoryTabs = $('<table class="emoji-menu-tabs"><tr>' +
'<td><a class="emoji-menu-tab icon-smile" ></a></td>' +
'<td><a class="emoji-menu-tab icon-flower"></a></td>' +
'<td><a class="emoji-menu-tab icon-bell"></a></td>' +
'<td><a class="emoji-menu-tab icon-car"></a></td>' +
'<td><a class="emoji-menu-tab icon-grid"></a></td>' +
'</tr></table>').appendTo(this.$itemsTailWrap);
this.$itemsWrap = $('<div class="emoji-items-wrap nano"></div>').appendTo(this.$itemsTailWrap); this.$itemsWrap = $('<div class="emoji-items-wrap nano"></div>').appendTo(this.$itemsTailWrap);
this.$items = $('<div class="emoji-items content">').appendTo(this.$itemsWrap); this.$items = $('<div class="emoji-items content">').appendTo(this.$itemsWrap);
$('<div class="emoji-menu-tail">').appendTo(this.$menu); $('<div class="emoji-menu-tail">').appendTo(this.$menu);
@ -447,6 +478,16 @@
}); });
this.$menu.on('click', 'a', function(e) { this.$menu.on('click', 'a', function(e) {
/*! MODIFICATION START
Following code was modified by Andre Staltz, to capture clicks on category tabs and change the category selection.
*/
if ($(this).hasClass('emoji-menu-tab')) {
if (self.getTabIndex(this) !== self.currentCategory) {
self.selectCategory(self.getTabIndex(this));
}
return false;
}
/*! MODIFICATION END */
var emoji = $('.label', $(this)).text(); var emoji = $('.label', $(this)).text();
window.setTimeout(function() { window.setTimeout(function() {
self.onItemSelected(emoji); self.onItemSelected(emoji);
@ -462,14 +503,38 @@
return false; return false;
}); });
this.load(); /* MODIFICATION: Following line was modified by Andre Staltz, in order to select a default category. */
this.selectCategory(0);
}; };
/*! MODIFICATION START
Following code was added by Andre Staltz, to implement category selection.
*/
EmojiMenu.prototype.getTabIndex = function(tab) {
return this.$categoryTabs.find('.emoji-menu-tab').index(tab);
};
EmojiMenu.prototype.selectCategory = function(category) {
var self = this;
this.$categoryTabs.find('.emoji-menu-tab').each(function(index) {
if (index === category) {
this.className += '-selected';
}
else {
this.className = this.className.replace('-selected', '');
}
});
this.currentCategory = category;
this.load(category);
};
/*! MODIFICATION END */
EmojiMenu.prototype.onItemSelected = function(emoji) { EmojiMenu.prototype.onItemSelected = function(emoji) {
this.emojiarea.insert(emoji); this.emojiarea.insert(emoji);
}; };
EmojiMenu.prototype.load = function() { /* MODIFICATION: The following function argument was modified by Andre Staltz, in order to load only icons from a category. */
EmojiMenu.prototype.load = function(category) {
var html = []; var html = [];
var options = $.emojiarea.icons; var options = $.emojiarea.icons;
var path = $.emojiarea.path; var path = $.emojiarea.path;
@ -478,9 +543,9 @@
} }
for (var key in options) { for (var key in options) {
if (options.hasOwnProperty(key)) { /* MODIFICATION: The following 2 lines were modified by Andre Staltz, in order to load only icons from the specified category. */
var filename = options[key]; if (options.hasOwnProperty(key) && options[key][0] === category) {
html.push('<a href="javascript:void(0)" title="' + util.htmlEntities(key) + '">' + EmojiArea.createIcon(key) + '<span class="label">' + util.htmlEntities(key) + '</span></a>'); html.push('<a href="javascript:void(0)" title="' + util.htmlEntities(key) + '">' + EmojiArea.createIcon(options[key]) + '<span class="label">' + util.htmlEntities(key) + '</span></a>');
} }
} }

Loading…
Cancel
Save